Class EntityInstanceDBService

java.lang.Object
org.trustdeck.service.EntityInstanceDBService

@Service public class EntityInstanceDBService extends Object
This class encapsulates the database access for entity instances.
Author:
Armin Müller
  • 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 data
      request - 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 null when 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 ID
      request - the http request object containing information necessary for the audit trail
      Returns:
      the retrieved entity instance when successfully found, or null when 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 String
      request - the http request object containing information necessary for the audit trail
      Returns:
      the retrieved entity instance when successfully found, or null when 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 object
      request - the http request object containing information necessary for the audit trail
      Returns:
      the retrieved entity instance when successfully found, or null when 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 ID
      request - the http request object containing information necessary for the audit trail
      Returns:
      the retrieved entity instance when successfully found, or null when 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 ID
      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
    • 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 updated
      newEntityInstanceDTO - the entity instance object containing the data to use for the update
      request - the http request object containing information necessary for the audit trail
      Returns:
      the updated entity instance object when successful, null when 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 query
      request - 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 done
      entityTypeId - the id of the instance's type
      linkageValues - a map of attribute-value-combinations that should be searched for
      limit - the maximum amount of matches that should be returned
      request - the http request object containing information necessary for the audit trail
      Returns:
      a list of entity instances that match the given linkage values