Class FolderAccess

java.lang.Object
org.ehrbase.dao.access.support.DataAccess
org.ehrbase.dao.access.jooq.FolderAccess
All Implemented Interfaces:
Comparable<FolderAccess>, I_Compensatable, I_DomainAccess, I_FolderAccess, I_VersionedCRUD

public class FolderAccess extends DataAccess implements I_FolderAccess, Comparable<FolderAccess>
Persistence operations on Folder.
Since:
1.0.0
Author:
Luis Marco-Ruiz
  • Field Details

  • Method Details

    • isDeleted

      public static boolean isDeleted(I_DomainAccess domainAccess, UUID versionedObjectId)
    • update

      public boolean update(LocalDateTime transactionTime, UUID systemId, UUID committerId, String description, I_ConceptAccess.ContributionChangeType changeType)
      Update the object with the necessary metadata.
      Specified by:
      update in interface I_VersionedCRUD
      Parameters:
      transactionTime - Time of operation
      systemId - Audit committer
      committerId - Audit system
      description - (Optional) Audit description
      changeType - Specific change type, because there are more than DELETED.
      Returns:
      Boolean representing success of update
    • update

      public boolean update(LocalDateTime transactionTime, UUID contribution)
      Update the object with the necessary metadata, which will be derived from the contribution.
      Specified by:
      update in interface I_VersionedCRUD
      Parameters:
      transactionTime - Time of operation
      contribution - Given contribution to use and derive audit data from
      Returns:
      Boolean representing success of update
    • commit

      public UUID commit(LocalDateTime transactionTime, UUID systemId, UUID committerId, String description)
      Commit the object with the necessary metadata. Additional commit method to store a new entry of folder to the database and get all of inserted sub folders connected by one contribution which has been created before.
      Specified by:
      commit in interface I_VersionedCRUD
      Parameters:
      transactionTime - - Timestamp which will be applied to all folder sys_transaction values
      systemId - System ID for audit
      committerId - Committer ID for audit
      description - Optional description for audit
      Returns:
      UUID of the new created root folder
    • commit

      public UUID commit(LocalDateTime transactionTime, UUID contributionId)
      Commit the object with the necessary metadata, which will be derived from the contribution. Additional commit method to store a new entry of folder to the database and get all of inserted sub folders connected by one contribution which has been created before.
      Specified by:
      commit in interface I_VersionedCRUD
      Parameters:
      transactionTime - - Timestamp which will be applied to all folder sys_transaction values
      contributionId - - ID of contribution for CREATE applied to all folders that will be created
      Returns:
      UUID of the new created root folder
    • retrieveInstanceForExistingFolder

      public static I_FolderAccess retrieveInstanceForExistingFolder(I_DomainAccess domainAccess, UUID folderId)
      Retrieve instance of I_FolderAccess with the information needed retrieve the folder and its sub-folders.
      Parameters:
      domainAccess - providing the information about the DB connection.
      folderId - UUID of the Folder to be fetched from the DB.
      Returns:
      the I_FolderAccess that provides DB access to the Folder that corresponds to the provided folderId param.
    • retrieveFolderVersionIdsInContribution

      public static Set<com.nedap.archie.rm.support.identification.ObjectVersionId> retrieveFolderVersionIdsInContribution(I_DomainAccess domainAccess, UUID contribution, String nodeName)
      Retrieve a set of all folders from a given contribution.
      Parameters:
      domainAccess - Domain access object
      contribution - Given contribution ID to check for
      nodeName - Nodename (e.g. "[...]::NODENAME::[...]") from the service layer, which is not accessible in the access layer
      Returns:
      Set of version ID of matching folders
    • retrieveByVersion

      public static I_FolderAccess retrieveByVersion(I_DomainAccess domainAccess, UUID folderId, int version)
    • getNewFolderAccessInstance

      public static I_FolderAccess getNewFolderAccessInstance(I_DomainAccess domainAccess, com.nedap.archie.rm.directory.Folder folder, org.joda.time.DateTime dateTime, UUID ehrId, String tenantIdentifier)
      Builds the I_FolderAccess for persisting the Folder provided as param.
      Parameters:
      domainAccess - providing the information about the DB connection.
      folder - to define the I_FolderAccess that allows its DB access.
      dateTime - that will be set as transaction date when the Folder is persisted
      ehrId - of the Ehr that references the Folder provided as param.
      Returns:
      I_FolderAccess with the information to persist the provided Folder
    • delete

      public int delete(LocalDateTime timestamp, UUID systemId, UUID committerId, String description)
      Delete the object with the necessary metadata.
      Includes sub-folders.
      Specified by:
      delete in interface I_VersionedCRUD
      Parameters:
      timestamp - Time of operation
      systemId - Audit committer
      committerId - Audit system
      description - (Optional) Audit description
      Returns:
      Number of deleted objects
    • delete

      public int delete(LocalDateTime timestamp, UUID contribution)
      Delete the object with the necessary metadata, which will be derived from the contribution.
      Includes sub-folders.
      Specified by:
      delete in interface I_VersionedCRUD
      Parameters:
      timestamp - Time of operation
      contribution - Given contribution to use and derive audit data from
      Returns:
      Number of deleted objects
    • buildPlainFolderAccess

      public static I_FolderAccess buildPlainFolderAccess(I_DomainAccess domainAccess, com.nedap.archie.rm.directory.Folder folder, Timestamp timestamp, UUID ehrId, I_ContributionAccess contributionAccess, String tenantIdentifier)
      Builds the FolderAccess with the collection of subfolders empty.
      Parameters:
      domainAccess - providing the information about the DB connection.
      folder - to define a corresponding I_FolderAccess for allowing its persistence.
      timestamp - that will be set as transaction date when the Folder is persisted
      ehrId - of the Ehr that references this Folder
      Returns:
      I_FolderAccess with the information to persist the provided Folder
    • buildNewFolderAccessHierarchy

      public static I_FolderAccess buildNewFolderAccessHierarchy(I_DomainAccess domainAccess, com.nedap.archie.rm.directory.Folder folder, Timestamp timeStamp, UUID ehrId, I_ContributionAccess contributionAccess, String tenantIdentifier)
      Builds a folderAccess hierarchy recursively by iterating over all sub folders of given folder instance. This works for all folders, i.e. from root for an insert as well for a sub folder hierarchy for update.
      Parameters:
      domainAccess - - DB connection context
      folder - - Folder to create access for
      timeStamp - - Current time for transaction audit
      ehrId - - Corresponding EHR
      contributionAccess - - Contribution instance for creation of all folders
      Returns:
      FolderAccess instance for folder
    • getLastVersionNumber

      public static Integer getLastVersionNumber(I_DomainAccess domainAccess, com.nedap.archie.rm.support.identification.ObjectVersionId folderId)
      Returns the last version number of a given folder by counting all previous versions of a given folder id. If there are no previous versions in the history table the version number will be 1. Otherwise the current version equals the count of entries in the folder history table plus 1.
      Parameters:
      domainAccess - - Database connection access context
      folderId - - ObjectVersionUid of the folder to check for the last version
      Returns:
      Latest version number for the folder
    • hasPreviousVersion

      public static boolean hasPreviousVersion(I_DomainAccess domainAccess, UUID folderId)
      Checks if there are existing entries for given folder uuid at the folder history table. If there are entries existing, the folder has been modified during previous actions and there are older versions existing.
      Parameters:
      domainAccess - - Database connection access context
      folderId - - UUID of folder to check
      Returns:
      Folder has previous versions or not
    • getVersionNumberAtTime

      public static int getVersionNumberAtTime(I_DomainAccess domainAccess, com.nedap.archie.rm.support.identification.ObjectVersionId rootFolderId, Timestamp sysTransaction)
      Evaluates the version for a folder at a given timestamp by counting all rows from folder history with root folder id and a sys_period timestamp before or at given timestamp value as also from the current folder entry if the sys_period provided is also newer than the sys_period of the current folder.
      Parameters:
      domainAccess - - Database access instance
      rootFolderId - - Root folder id
      sysTransaction - - Timestamp to get version for
      Returns:
      - Version number that has been current at that point in time
    • getTimestampForVersion

      public static Timestamp getTimestampForVersion(I_DomainAccess domainAccess, com.nedap.archie.rm.support.identification.ObjectVersionId rootFolderId, Integer version)
    • getEhrId

      public UUID getEhrId()
      Getters and Setters for the FolderRecord to store
      Specified by:
      getEhrId in interface I_FolderAccess
    • setEhrId

      public void setEhrId(UUID ehrId)
    • getContributionAccess

      public I_ContributionAccess getContributionAccess()
    • setContributionAccess

      public void setContributionAccess(I_ContributionAccess contributionAccess)
    • getSubfoldersList

      public Map<UUID,I_FolderAccess> getSubfoldersList()
      Description copied from interface: I_FolderAccess
      Get the list of subfolders for the Folder that corresponds to this I_FolderAccess
      Specified by:
      getSubfoldersList in interface I_FolderAccess
      Returns:
      Map<UUID, I_FolderAccess> whose key is the UUID of the child Folder, and whose value is the I_FolderAccess for the child Folder.
    • getItems

      public List<com.nedap.archie.rm.support.identification.ObjectRef<? extends com.nedap.archie.rm.support.identification.ObjectId>> getItems()
      Description copied from interface: I_FolderAccess
      Get the items references stored as a part of the given Folder
      Specified by:
      getItems in interface I_FolderAccess
      Returns:
      items of the Folder that corresponds to this I_FolderAccess
    • getFolderId

      public UUID getFolderId()
      Specified by:
      getFolderId in interface I_FolderAccess
    • setFolderId

      public void setFolderId(UUID folderId)
      Specified by:
      setFolderId in interface I_FolderAccess
    • getInContribution

      public UUID getInContribution()
      Specified by:
      getInContribution in interface I_FolderAccess
    • setInContribution

      public void setInContribution(UUID inContribution)
      Specified by:
      setInContribution in interface I_FolderAccess
    • getFolderName

      public String getFolderName()
      Specified by:
      getFolderName in interface I_FolderAccess
    • setFolderName

      public void setFolderName(String folderName)
      Specified by:
      setFolderName in interface I_FolderAccess
    • getFolderArchetypeNodeId

      public String getFolderArchetypeNodeId()
      Specified by:
      getFolderArchetypeNodeId in interface I_FolderAccess
    • setFolderNArchetypeNodeId

      public void setFolderNArchetypeNodeId(String folderArchetypeNodeId)
      Specified by:
      setFolderNArchetypeNodeId in interface I_FolderAccess
    • isFolderActive

      public boolean isFolderActive()
      Specified by:
      isFolderActive in interface I_FolderAccess
    • setIsFolderActive

      public void setIsFolderActive(boolean folderActive)
      Specified by:
      setIsFolderActive in interface I_FolderAccess
    • getFolderDetails

      public com.nedap.archie.rm.datastructures.ItemStructure getFolderDetails()
      Specified by:
      getFolderDetails in interface I_FolderAccess
    • setFolderDetails

      public void setFolderDetails(com.nedap.archie.rm.datastructures.ItemStructure folderDetails)
      Specified by:
      setFolderDetails in interface I_FolderAccess
    • setFolderSysTransaction

      public void setFolderSysTransaction(Timestamp folderSysTransaction)
      Specified by:
      setFolderSysTransaction in interface I_FolderAccess
    • getFolderSysTransaction

      public Timestamp getFolderSysTransaction()
      Specified by:
      getFolderSysTransaction in interface I_FolderAccess
    • getFolderSysPeriod

      Specified by:
      getFolderSysPeriod in interface I_FolderAccess
    • setFolderSysPeriod

      public void setFolderSysPeriod(AbstractMap.SimpleEntry<OffsetDateTime,OffsetDateTime> folderSysPeriod)
      Specified by:
      setFolderSysPeriod in interface I_FolderAccess
    • getAudit

      public UUID getAudit()
      Specified by:
      getAudit in interface I_FolderAccess
    • setAudit

      public void setAudit(UUID auditId)
      Specified by:
      setAudit in interface I_FolderAccess
    • getDataAccess

      public DataAccess getDataAccess()
      Specified by:
      getDataAccess in interface I_DomainAccess
    • compareTo

      public int compareTo(FolderAccess o)
      Specified by:
      compareTo in interface Comparable<FolderAccess>
    • adminDeleteFolder

      public void adminDeleteFolder()
      Description copied from interface: I_FolderAccess
      Invoke physical deletion.
      Specified by:
      adminDeleteFolder in interface I_FolderAccess
    • getSysTransaction

      public Timestamp getSysTransaction()
      Specified by:
      getSysTransaction in interface I_Compensatable
    • getContributionId

      public UUID getContributionId()
      Specified by:
      getContributionId in interface I_Compensatable
    • getId

      public UUID getId()
      Specified by:
      getId in interface I_Compensatable