Class EntityTypeDBService

java.lang.Object
org.trustdeck.service.EntityTypeDBService

@Service public class EntityTypeDBService extends Object
This class encapsulates the database access for entity types.
Author:
Armin Müller
  • Constructor Details

    • EntityTypeDBService

      public EntityTypeDBService()
  • Method Details

    • createEntityType

      @Transactional public EntityTypeDTO createEntityType(EntityTypeDTO entityTypeDTO, jakarta.servlet.http.HttpServletRequest request) throws CreationException, DuplicateEntityTypeException
      Method to insert a new entity type into the database.
      Parameters:
      entityTypeDTO - the entity type data transfer object containing the necessary data
      request - the http request object containing information necessary for the audit trail
      Returns:
      The newly inserted entity type object when the insertion was successful, the original entity type object if the given one was a duplicate, and null when the insertion failed.
      Throws:
      CreationException - when the creation of the entity type or the partition in the database failed to abort and roll back this transaction.
      DuplicateEntityTypeException - when an entity type with the same name already exists
    • getEntityTypeByName

      @Transactional public EntityTypeDTO getEntityTypeByName(String name, Integer projectID, jakarta.servlet.http.HttpServletRequest request)
      Method to retrieve an entity type from the database by explicitly providing the two variables name and projectID. Tuples of these are unique in the database. Base types will have no projectID, so it can be null.
      Parameters:
      name - the entity type's name
      projectID - the project to which the entity type is assigned to
      request - the http request object containing information necessary for the audit trail
      Returns:
      the retrieved entity type when successfully found, or null when nothing was found.
    • getEntityTypeById

      @Transactional public EntityTypeDTO getEntityTypeById(int entityTypeId, Integer projectID, jakarta.servlet.http.HttpServletRequest request)
      Method to retrieve an entity type from the database by explicitly providing the two variables name and projectID. Tuples of these are unique in the database. Base types will have no projectID, so it can be null.
      Parameters:
      entityTypeId - the entity type's ID
      projectID - the project to which the entity type is assigned to
      request - the http request object containing information necessary for the audit trail
      Returns:
      the retrieved entity type when successfully found, or null when nothing was found.
    • getEntityType

      @Transactional public EntityTypeDTO getEntityType(EntityTypeDTO entityTypeDTO, jakarta.servlet.http.HttpServletRequest request)
      Method to retrieve an entity type from the database by providing an EntityTypeDTO containing at least name and projectID. Tuples of these are unique in the database.
      Parameters:
      entityTypeDTO - the entity type data transfer object containing the necessary data (at least name and projectID)
      request - the http request object containing information necessary for the audit trail
      Returns:
      the entity type as a DTO, or null if nothing was found or the search failed
    • deleteEntityType

      @Transactional public boolean deleteEntityType(EntityTypeDTO type, jakarta.servlet.http.HttpServletRequest request) throws UnexpectedResultSizeException
      Method to delete an entity type. Only possible if the entity type is not used anywhere.
      Parameters:
      type - the entity type's DTO including the name and the projectID
      request - the http request object containing information necessary for the audit trail
      Returns:
      true when deletion was successful, false when anything went wrong during the deletion
      Throws:
      UnexpectedResultSizeException - when the deletion would have affected an unexpected number of database entries
    • updateEntityType

      @Transactional public EntityTypeDTO updateEntityType(EntityTypeDTO oldEntityTypeDTO, EntityTypeDTO newEntityTypeDTO, jakarta.servlet.http.HttpServletRequest request)
      Method to update an entity type. Only works when the entity type is not used anywhere.
      Parameters:
      oldEntityTypeDTO - the entity type data transfer object containing the necessary data to identify the type that should be updated
      newEntityTypeDTO - the entity type object containing the data to use for the update; null-values lead to keeping the old values
      request - the http request object containing information necessary for the audit trail
      Returns:
      the updated entity type object when successful, null when anything went wrong
    • searchEntityType

      @Transactional public List<EntityTypeDTO> searchEntityType(String query, int projectId, jakarta.servlet.http.HttpServletRequest request)
      Method to search for entity types. This search supports full-text-searching over all attributes of an entity type, as well as multiple words.
      Parameters:
      query - the (multi-word) search query
      projectId - the id of the project
      request - the http request object containing information necessary for the audit trail
      Returns:
      a list of entity types that match the search query
    • getEntityTypeNames

      @Transactional(readOnly=true) public String[] getEntityTypeNames(Integer[] entityTypeIDs)
      This method retrieves the names for the given entity type IDs from a project.
      Parameters:
      entityTypeIDs - the array of entity type IDs stored in a project
      Returns:
      an array of the names of the entity types in the same order as the IDs were given.
    • getEntityTypeIDs

      @Transactional(readOnly=true) public Integer[] getEntityTypeIDs(Integer projectId, String[] entityTypeNames)
      This method retrieves the IDs for the given entity type names from a project.
      Parameters:
      projectId - the ID of the project where the entity types are scoped in
      entityTypeNames - the array of entity type names stored in a project
      Returns:
      an array of the IDs of the entity types in the same order as the names were given, or null when something went wrong