Package org.trustdeck.service
Class EntityTypeDBService
java.lang.Object
org.trustdeck.service.EntityTypeDBService
This class encapsulates the database access for entity types.
- Author:
- Armin Müller
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateEntityType(EntityTypeDTO entityTypeDTO, jakarta.servlet.http.HttpServletRequest request) Method to insert a new entity type into the database.booleandeleteEntityType(EntityTypeDTO type, jakarta.servlet.http.HttpServletRequest request) Method to delete an entity type.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.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.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.Integer[]getEntityTypeIDs(Integer projectId, String[] entityTypeNames) This method retrieves the IDs for the given entity type names from a project.String[]getEntityTypeNames(Integer[] entityTypeIDs) This method retrieves the names for the given entity type IDs from a project.searchEntityType(String query, int projectId, jakarta.servlet.http.HttpServletRequest request) Method to search for entity types.updateEntityType(EntityTypeDTO oldEntityTypeDTO, EntityTypeDTO newEntityTypeDTO, jakarta.servlet.http.HttpServletRequest request) Method to update an entity type.
-
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 datarequest- 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
nullwhen 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 nameprojectID- the project to which the entity type is assigned torequest- the http request object containing information necessary for the audit trail- Returns:
- the retrieved entity type when successfully found, or
nullwhen 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 IDprojectID- the project to which the entity type is assigned torequest- the http request object containing information necessary for the audit trail- Returns:
- the retrieved entity type when successfully found, or
nullwhen 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
nullif 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 projectIDrequest- the http request object containing information necessary for the audit trail- Returns:
truewhen deletion was successful,falsewhen 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 updatednewEntityTypeDTO- the entity type object containing the data to use for the update; null-values lead to keeping the old valuesrequest- the http request object containing information necessary for the audit trail- Returns:
- the updated entity type object when successful,
nullwhen 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 queryprojectId- the id of the projectrequest- the http request object containing information necessary for the audit trail- Returns:
- a list of entity types that match the search query
-
getEntityTypeNames
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 inentityTypeNames- 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
nullwhen something went wrong
-