Package org.trustdeck.service
Class EntityInstanceDBService
java.lang.Object
org.trustdeck.service.EntityInstanceDBService
This class encapsulates the database access for entity instances.
- Author:
- Armin Müller
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateEntityInstance(EntityInstanceDTO entityInstanceDTO, jakarta.servlet.http.HttpServletRequest request) Method to insert a new entity instance into the database.booleandeleteEntityInstance(UUID trustDeckID, jakarta.servlet.http.HttpServletRequest request) Method to delete an entity instance.getEntityInstance(String trustDeckID, jakarta.servlet.http.HttpServletRequest request) Method to retrieve an entity instance from the database by explicitly providing the trustDeckID as a String, which is unique in the database.getEntityInstance(UUID trustDeckID, jakarta.servlet.http.HttpServletRequest request) Method to retrieve an entity instance from the database by explicitly providing the trustDeckID, which is unique in the database.getEntityInstance(EntityInstanceDTO entityInstance, jakarta.servlet.http.HttpServletRequest request) Method to retrieve an entity instance from the database by providing an EntityInstanceDTO.getEntityInstanceByData(org.jooq.JSONB data, jakarta.servlet.http.HttpServletRequest request) Method to retrieve an entity instance from the database by providing the data JSON.searchEntityInstance(String query, jakarta.servlet.http.HttpServletRequest request) Method to search for entity instance.searchRecordLinkageCandidates(int projectId, int entityTypeId, Map<String, com.fasterxml.jackson.databind.JsonNode> linkageValues, int limit, jakarta.servlet.http.HttpServletRequest request) Method to search for record linkage candidates that match a given set of attributes.updateEntityInstance(long oldInstanceID, EntityInstanceDTO newEntityInstanceDTO, jakarta.servlet.http.HttpServletRequest request) Method to update an entity instance.
-
Constructor Details
-
EntityInstanceDBService
public EntityInstanceDBService()
-
-
Method Details
-
createEntityInstance
@Transactional public EntityInstanceDTO createEntityInstance(EntityInstanceDTO entityInstanceDTO, jakarta.servlet.http.HttpServletRequest request) Method to insert a new entity instance into the database.- Parameters:
entityInstanceDTO- the entity instance data transfer object containing the necessary datarequest- the http request object containing information necessary for the audit trail- Returns:
- The newly inserted entity instance object when the insertion was successful,
the original entity instance object if the given one was a duplicate, and
nullwhen the insertion failed.
-
getEntityInstance
@Transactional public EntityInstanceDTO getEntityInstance(UUID trustDeckID, jakarta.servlet.http.HttpServletRequest request) Method to retrieve an entity instance from the database by explicitly providing the trustDeckID, which is unique in the database.- Parameters:
trustDeckID- the entity instance's publicly accessible TrustDeck IDrequest- the http request object containing information necessary for the audit trail- Returns:
- the retrieved entity instance when successfully found, or
nullwhen nothing was found.
-
getEntityInstance
@Transactional public EntityInstanceDTO getEntityInstance(String trustDeckID, jakarta.servlet.http.HttpServletRequest request) Method to retrieve an entity instance from the database by explicitly providing the trustDeckID as a String, which is unique in the database.- Parameters:
trustDeckID- the entity instance's publicly accessible TrustDeck ID as a Stringrequest- the http request object containing information necessary for the audit trail- Returns:
- the retrieved entity instance when successfully found, or
nullwhen nothing was found.
-
getEntityInstanceByData
@Transactional public EntityInstanceDTO getEntityInstanceByData(org.jooq.JSONB data, jakarta.servlet.http.HttpServletRequest request) Method to retrieve an entity instance from the database by providing the data JSON.- Parameters:
data- the entity instance's data objectrequest- the http request object containing information necessary for the audit trail- Returns:
- the retrieved entity instance when successfully found, or
nullwhen nothing was found.
-
getEntityInstance
@Transactional public EntityInstanceDTO getEntityInstance(EntityInstanceDTO entityInstance, jakarta.servlet.http.HttpServletRequest request) Method to retrieve an entity instance from the database by providing an EntityInstanceDTO. Internally it uses only the trustDeckID, which is unique in the database.- Parameters:
entityInstance- the DTO containing at least the instance's publicly accessible TrustDeck IDrequest- the http request object containing information necessary for the audit trail- Returns:
- the retrieved entity instance when successfully found, or
nullwhen nothing was found.
-
deleteEntityInstance
@Transactional public boolean deleteEntityInstance(UUID trustDeckID, jakarta.servlet.http.HttpServletRequest request) throws UnexpectedResultSizeException Method to delete an entity instance. The deletion is done by marking the entry as deleted and not by actually removing the record from the database.- Parameters:
trustDeckID- the entity instance's publicly accessible TrustDeck IDrequest- 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
-
updateEntityInstance
@Transactional public EntityInstanceDTO updateEntityInstance(long oldInstanceID, EntityInstanceDTO newEntityInstanceDTO, jakarta.servlet.http.HttpServletRequest request) Method to update an entity instance.- Parameters:
oldInstanceID- the entity instance database id that is needed to identify the instance that should be updatednewEntityInstanceDTO- the entity instance object containing the data to use for the updaterequest- the http request object containing information necessary for the audit trail- Returns:
- the updated entity instance object when successful,
nullwhen anything went wrong
-
searchEntityInstance
@Transactional public List<EntityInstanceDTO> searchEntityInstance(String query, jakarta.servlet.http.HttpServletRequest request) Method to search for entity instance. This search supports full-text-searching over all attributes of an entity instance, as well as multiple words.- Parameters:
query- the (multi-word) search queryrequest- the http request object containing information necessary for the audit trail- Returns:
- a list of entity instances that match the search query
-
searchRecordLinkageCandidates
@Transactional(readOnly=true) public List<EntityInstanceDTO> searchRecordLinkageCandidates(int projectId, int entityTypeId, Map<String, com.fasterxml.jackson.databind.JsonNode> linkageValues, int limit, jakarta.servlet.http.HttpServletRequest request) Method to search for record linkage candidates that match a given set of attributes.- Parameters:
projectId- the id of the project in which the linkage should be doneentityTypeId- the id of the instance's typelinkageValues- a map of attribute-value-combinations that should be searched forlimit- the maximum amount of matches that should be returnedrequest- the http request object containing information necessary for the audit trail- Returns:
- a list of entity instances that match the given linkage values
-