Class DomainDBAccessService

java.lang.Object
org.trustdeck.service.DomainDBAccessService

@Service public class DomainDBAccessService extends Object
This class is used to encapsulate all methods needed to access the database for handling domains.
Author:
Armin Müller and Eric Wündisch
  • Field Details

    • DOMAIN_NOT_FOUND

      public static final Integer DOMAIN_NOT_FOUND
      Representation for a domain that is not found during counting the records in it.
    • INSERTION_DUPLICATE

      public static final String INSERTION_DUPLICATE
      Represents the duplication status of a requested insertion of a domain into the database.
      See Also:
    • INSERTION_ERROR

      public static final String INSERTION_ERROR
      Represents an erroneous insertion of a domain into the database.
      See Also:
    • INSERTION_SUCCESS

      public static final String INSERTION_SUCCESS
      Represents a successful insertion of a domain into the database.
      See Also:
  • Constructor Details

    • DomainDBAccessService

      public DomainDBAccessService()
  • Method Details

    • getDomainByName

      public Domain getDomainByName(String domainName, jakarta.servlet.http.HttpServletRequest request)
      Method to retrieve a domain from the database given its name.
      Parameters:
      domainName - the name of the domain you want to get
      request - the request object that is needed for creating the audit database-entries. If no auditing should be performed, you can pass null.
      Returns:
      the retrieved domain as a jOOQ Domain object, or null if nothing was found
    • getDomainByID

      public Domain getDomainByID(int domainID, jakarta.servlet.http.HttpServletRequest request)
      This method retrieves a domain for a given ID
      Parameters:
      domainID - the id of the domain you want to get
      request - the request object that is needed for creating the audit database-entries. If no auditing should be performed, you can pass null.
      Returns:
      the retrieved domain as a jOOQ Domain object, or null if nothing was found
    • getSubtreeFromDomainName

      @Transactional public List<DomainDTO> getSubtreeFromDomainName(String domainName, jakarta.servlet.http.HttpServletRequest request)
      Helper method that creates the subtree of a domain starting from the given domain.
      Parameters:
      domainName - a domain name from which the search should start
      request - the request object that is needed for creating the audit database-entries. If no auditing should be performed, you can pass null.
      Returns:
      a list of domain DTOs which represent all domains of the subtree starting with the given domain
    • getDomainTreeStructure

      public List<Domain> getDomainTreeStructure(Domain domain)
      Helper method that creates the complete tree of domains for any given domain inside this tree.
      Parameters:
      domain - any domain object from the tree
      Returns:
      a list of domain objects which represent all domains of the tree surrounding the given domain
    • getRootDomainFromTree

      public Domain getRootDomainFromTree(List<Domain> nodes)
      Retrieves the root domain from a list of domain nodes. The list of nodes need to be in a tree and connected via the super-domain properties, otherwise a random parent-less domain is returned.
      Parameters:
      nodes - a list of domain objects representing the nodes in the domain tree
      Returns:
      the root domain object if found, or null if anything went wrong
    • getLinkedPseudonyms

      public List<org.springframework.data.util.Pair<PseudonymDTO,PseudonymDTO>> getLinkedPseudonyms(String sourceDomainName, String sourceIdentifier, String sourceIdType, String sourcePsn, String targetDomainName, jakarta.servlet.http.HttpServletRequest request)
      Method to find pseudonym(s) linked to the given one in the provided domain. For that, either the identifier and idType or the psn of the starting record is needed.
      Parameters:
      sourceDomainName - the name of the domain to start from
      sourceIdentifier - the identifier of the record to start the search from
      sourceIdType - the idType of the starting identifier
      sourcePsn - the pseudonym of the record to start the search from
      targetDomainName - the name of the domain where to find the matching pseudonym records in
      request - the request object that is needed for creating the audit database-entries. If no auditing should be performed, you can pass null.
      Returns:
      a list of pairs (A, B) of linked pseudonym records, with A being the source record, and B being the linked record, i.e., [(A, B), (A, C), (A, D), ..., (A, N)] or null.
    • getAllPseudonymValuesInDomain

      public List<String> getAllPseudonymValuesInDomain(String domainName, jakarta.servlet.http.HttpServletRequest request)
      Method to retrieve all pseudonym-values that exist in a domain from the database.
      Parameters:
      domainName - the name of the domain where the values should be retrieved from
      request - the request object that is needed for creating the audit database-entries. If no auditing should be performed, you can pass null.
      Returns:
      a list of pseudonyms existing in the given domain when successful, null otherwise
    • getAllRecordsInDomain

      @Transactional public List<PseudonymDTO> getAllRecordsInDomain(String domainName, jakarta.servlet.http.HttpServletRequest request)
      Method to retrieve all records stored in a domain.
      Parameters:
      domainName - the name of the domain where the records should be retrieved from
      request - the request object that is needed for creating the audit database-entries. If no auditing should be performed, you can pass null.
      Returns:
      a list of records stored in the given domain when successful, null otherwise
    • getAmountOfRecordsInDomain

      public Integer getAmountOfRecordsInDomain(String domainName, jakarta.servlet.http.HttpServletRequest request)
      Returns the number of records in a domain
      Parameters:
      domainName - the name of the domain where the number of records should be retrieved from
      request - the request object that is needed for creating the audit database-entries. If no auditing should be performed, you can pass null.
      Returns:
      the counted number
    • deleteDomain

      public boolean deleteDomain(String domainName, boolean recursiveDeletion, jakarta.servlet.http.HttpServletRequest request)
      Deletes a record from the domain table.
      Parameters:
      domainName - the name of the domain that should be deleted
      recursiveDeletion - determines if possible child domains should also be deleted
      request - the request object that is needed for creating the audit database-entries. If no auditing should be performed, you can pass null.
      Returns:
      true when the deletion was successful or the record was not in the database, false otherwise
    • insertDomain

      public String insertDomain(Domain domain, jakarta.servlet.http.HttpServletRequest request)
      Method to insert information of a domain into the according table.
      Parameters:
      domain - the domain object to insert
      request - the request object that is needed for creating the audit database-entries. If no auditing should be performed, you can pass null.
      Returns:
      INSERTION_SUCCESS when the insertion was successful, INSERTION_DUPLICATE when the domain was already in the database, INSERTION_ERROR otherwise.
    • listDomains

      @Transactional public List<DomainDTO> listDomains(jakarta.servlet.http.HttpServletRequest request)
      This method lists all domains from the database.
      Parameters:
      request - the request object that is needed for creating the audit database-entries. If no auditing should be performed, you can pass null.
      Returns:
      a list of domains, if nothing was found an empty list is returned.
    • updateCounter

      public boolean updateCounter(Long counter, String domainName)
      Method to update only the counter value of a domain.
      Parameters:
      counter - the new counter value
      domainName - the name of the domain where the counter should be updated
      Returns:
      true, when the update was successful, false otherwise.
    • updateDomain

      public Domain updateDomain(Domain oldDomain, Domain newDomain, boolean recursiveChanges, jakarta.servlet.http.HttpServletRequest request)
      Method to update a domain in the database. Updates only those parameters that aren't null. Recursive updating of affected child-domains is possible.
      Parameters:
      oldDomain - the domain object of the domain that should be updated
      newDomain - the domain object of the new domain; variables that aren't needed can be null
      recursiveChanges - determines if possible child domains should also be updated
      request - the request object that is needed for creating the audit database-entries. If no auditing should be performed, you can pass null.
      Returns:
      true if the update was successful, false otherwise