Package org.trustdeck.service
Class DomainDBAccessService
java.lang.Object
org.trustdeck.service.DomainDBAccessService
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final IntegerRepresentation for a domain that is not found during counting the records in it.static final StringRepresents the duplication status of a requested insertion of a domain into the database.static final StringRepresents an erroneous insertion of a domain into the database.static final StringRepresents a successful insertion of a domain into the database. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleandeleteDomain(String domainName, boolean recursiveDeletion, jakarta.servlet.http.HttpServletRequest request) Deletes a record from the domain table.getAllPseudonymValuesInDomain(String domainName, jakarta.servlet.http.HttpServletRequest request) Method to retrieve all pseudonym-values that exist in a domain from the database.getAllRecordsInDomain(String domainName, jakarta.servlet.http.HttpServletRequest request) Method to retrieve all records stored in a domain.getAmountOfRecordsInDomain(String domainName, jakarta.servlet.http.HttpServletRequest request) Returns the number of records in a domaingetDomainByID(int domainID, jakarta.servlet.http.HttpServletRequest request) This method retrieves a domain for a given IDgetDomainByName(String domainName, jakarta.servlet.http.HttpServletRequest request) Method to retrieve a domain from the database given its name.getDomainTreeStructure(Domain domain) Helper method that creates the complete tree of domains for any given domain inside this tree.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.getRootDomainFromTree(List<Domain> nodes) Retrieves the root domain from a list of domain nodes.getSubtreeFromDomainName(String domainName, jakarta.servlet.http.HttpServletRequest request) Helper method that creates the subtree of a domain starting from the given domain.insertDomain(Domain domain, jakarta.servlet.http.HttpServletRequest request) Method to insert information of a domain into the according table.listDomains(jakarta.servlet.http.HttpServletRequest request) This method lists all domains from the database.booleanupdateCounter(Long counter, String domainName) Method to update only the counter value of a domain.updateDomain(Domain oldDomain, Domain newDomain, boolean recursiveChanges, jakarta.servlet.http.HttpServletRequest request) Method to update a domain in the database.
-
Field Details
-
DOMAIN_NOT_FOUND
Representation for a domain that is not found during counting the records in it. -
INSERTION_DUPLICATE
Represents the duplication status of a requested insertion of a domain into the database.- See Also:
-
INSERTION_ERROR
Represents an erroneous insertion of a domain into the database.- See Also:
-
INSERTION_SUCCESS
Represents a successful insertion of a domain into the database.- See Also:
-
-
Constructor Details
-
DomainDBAccessService
public DomainDBAccessService()
-
-
Method Details
-
getDomainByName
Method to retrieve a domain from the database given its name.- Parameters:
domainName- the name of the domain you want to getrequest- the request object that is needed for creating the audit database-entries. If no auditing should be performed, you can passnull.- Returns:
- the retrieved domain as a jOOQ Domain object, or
nullif nothing was found
-
getDomainByID
This method retrieves a domain for a given ID- Parameters:
domainID- the id of the domain you want to getrequest- the request object that is needed for creating the audit database-entries. If no auditing should be performed, you can passnull.- Returns:
- the retrieved domain as a jOOQ Domain object, or
nullif 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 startrequest- the request object that is needed for creating the audit database-entries. If no auditing should be performed, you can passnull.- Returns:
- a list of domain DTOs which represent all domains of the subtree starting with the given domain
-
getDomainTreeStructure
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
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
nullif 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 fromsourceIdentifier- the identifier of the record to start the search fromsourceIdType- the idType of the starting identifiersourcePsn- the pseudonym of the record to start the search fromtargetDomainName- the name of the domain where to find the matching pseudonym records inrequest- the request object that is needed for creating the audit database-entries. If no auditing should be performed, you can passnull.- 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 fromrequest- the request object that is needed for creating the audit database-entries. If no auditing should be performed, you can passnull.- Returns:
- a list of pseudonyms existing in the given domain when successful,
nullotherwise
-
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 fromrequest- the request object that is needed for creating the audit database-entries. If no auditing should be performed, you can passnull.- Returns:
- a list of records stored in the given domain when successful,
nullotherwise
-
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 fromrequest- the request object that is needed for creating the audit database-entries. If no auditing should be performed, you can passnull.- 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 deletedrecursiveDeletion- determines if possible child domains should also be deletedrequest- the request object that is needed for creating the audit database-entries. If no auditing should be performed, you can passnull.- Returns:
truewhen the deletion was successful or the record was not in the database,falseotherwise
-
insertDomain
Method to insert information of a domain into the according table.- Parameters:
domain- the domain object to insertrequest- the request object that is needed for creating the audit database-entries. If no auditing should be performed, you can passnull.- Returns:
INSERTION_SUCCESSwhen the insertion was successful,INSERTION_DUPLICATEwhen the domain was already in the database,INSERTION_ERRORotherwise.
-
listDomains
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 passnull.- Returns:
- a list of domains, if nothing was found an empty list is returned.
-
updateCounter
Method to update only the counter value of a domain.- Parameters:
counter- the new counter valuedomainName- the name of the domain where the counter should be updated- Returns:
true, when the update was successful,falseotherwise.
-
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'tnull. Recursive updating of affected child-domains is possible.- Parameters:
oldDomain- the domain object of the domain that should be updatednewDomain- the domain object of the new domain; variables that aren't needed can benullrecursiveChanges- determines if possible child domains should also be updatedrequest- the request object that is needed for creating the audit database-entries. If no auditing should be performed, you can passnull.- Returns:
trueif the update was successful,falseotherwise
-