Package org.ehrbase.dao.access.jooq
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
Persistence operations on Folder.
- Since:
- 1.0.0
- Author:
- Luis Marco-Ruiz
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final StringFields inherited from interface org.ehrbase.dao.access.interfaces.I_DomainAccess
DBCP2_POOL, KEY_AUTO_RECONNECT, KEY_CONNECTION_MODE, KEY_DATABASE, KEY_DIALECT, KEY_HOST, KEY_INITIAL_CONNECTIONS, KEY_INTROSPECT_CACHE, KEY_KNOWLEDGE, KEY_LOG_ABANDONNED, KEY_LOGIN, KEY_MAX_ACTIVE, KEY_MAX_CONNECTION, KEY_MAX_IDLE, KEY_PASSWORD, KEY_PORT, KEY_REMOVE_ABANDONNED, KEY_REMOVE_ABANDONNED_TIMEOUT, KEY_SCHEMA, KEY_SET_MAX_PREPARED_STATEMENTS, KEY_SET_POOL_PREPARED_STATEMENTS, KEY_TEST_ON_BORROW, KEY_URL, KEY_WAIT_MS, PG_POOL -
Method Summary
Modifier and TypeMethodDescriptionvoidInvoke physical deletion.static I_FolderAccessbuildNewFolderAccessHierarchy(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.static I_FolderAccessbuildPlainFolderAccess(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.commit(LocalDateTime transactionTime, UUID contributionId) Commit the object with the necessary metadata, which will be derived from the contribution.commit(LocalDateTime transactionTime, UUID systemId, UUID committerId, String description) Commit the object with the necessary metadata.intintdelete(LocalDateTime timestamp, UUID contribution) Delete the object with the necessary metadata, which will be derived from the contribution.intdelete(LocalDateTime timestamp, UUID systemId, UUID committerId, String description) Delete the object with the necessary metadata.getAudit()getEhrId()Getters and Setters for the FolderRecord to storecom.nedap.archie.rm.datastructures.ItemStructuregetId()List<com.nedap.archie.rm.support.identification.ObjectRef<? extends com.nedap.archie.rm.support.identification.ObjectId>>getItems()Get the items references stored as a part of the givenFolderstatic IntegergetLastVersionNumber(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.static I_FolderAccessgetNewFolderAccessInstance(I_DomainAccess domainAccess, com.nedap.archie.rm.directory.Folder folder, org.joda.time.DateTime dateTime, UUID ehrId, String tenantIdentifier) Builds theI_FolderAccessfor persisting theFolderprovided as param.Get the list of subfolders for theFolderthat corresponds to thisI_FolderAccessstatic TimestampgetTimestampForVersion(I_DomainAccess domainAccess, com.nedap.archie.rm.support.identification.ObjectVersionId rootFolderId, Integer version) static intgetVersionNumberAtTime(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.static booleanhasPreviousVersion(I_DomainAccess domainAccess, UUID folderId) Checks if there are existing entries for given folder uuid at the folder history table.static booleanisDeleted(I_DomainAccess domainAccess, UUID versionedObjectId) booleanstatic I_FolderAccessretrieveByVersion(I_DomainAccess domainAccess, UUID folderId, int version) 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.static I_FolderAccessretrieveInstanceForExistingFolder(I_DomainAccess domainAccess, UUID folderId) Retrieve instance ofI_FolderAccesswith the information needed retrieve the folder and its sub-folders.voidvoidsetContributionAccess(I_ContributionAccess contributionAccess) voidvoidsetFolderDetails(com.nedap.archie.rm.datastructures.ItemStructure folderDetails) voidsetFolderId(UUID folderId) voidsetFolderName(String folderName) voidsetFolderNArchetypeNodeId(String folderArchetypeNodeId) voidsetFolderSysPeriod(AbstractMap.SimpleEntry<OffsetDateTime, OffsetDateTime> folderSysPeriod) voidsetFolderSysTransaction(Timestamp folderSysTransaction) voidsetInContribution(UUID inContribution) voidsetIsFolderActive(boolean folderActive) booleanupdate(LocalDateTime transactionTime, UUID contribution) Update the object with the necessary metadata, which will be derived from the contribution.booleanupdate(LocalDateTime transactionTime, UUID systemId, UUID committerId, String description, I_ConceptAccess.ContributionChangeType changeType) Update the object with the necessary metadata.Methods inherited from class org.ehrbase.dao.access.support.DataAccess
getConnection, getContext, getDialect, getIntrospectService, getKnowledgeManager, getServerConfig, releaseConnection
-
Field Details
-
SUBFOLDERS
- See Also:
-
PARENT_FOLDER
- See Also:
-
CHILD_FOLDER
- See Also:
-
CALLED_INVALID_ACCESS_LAYER_METHOD
- See Also:
-
-
Method Details
-
isDeleted
-
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:
updatein interfaceI_VersionedCRUD- Parameters:
transactionTime- Time of operationsystemId- Audit committercommitterId- Audit systemdescription- (Optional) Audit descriptionchangeType- Specific change type, because there are more than DELETED.- Returns:
- Boolean representing success of update
-
update
Update the object with the necessary metadata, which will be derived from the contribution.- Specified by:
updatein interfaceI_VersionedCRUD- Parameters:
transactionTime- Time of operationcontribution- 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:
commitin interfaceI_VersionedCRUD- Parameters:
transactionTime- - Timestamp which will be applied to all folder sys_transaction valuessystemId- System ID for auditcommitterId- Committer ID for auditdescription- Optional description for audit- Returns:
- UUID of the new created root folder
-
commit
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:
commitin interfaceI_VersionedCRUD- Parameters:
transactionTime- - Timestamp which will be applied to all folder sys_transaction valuescontributionId- - 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 ofI_FolderAccesswith the information needed retrieve the folder and its sub-folders.- Parameters:
domainAccess- providing the information about the DB connection.folderId-UUIDof theFolderto be fetched from the DB.- Returns:
- the
I_FolderAccessthat provides DB access to theFolderthat 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 objectcontribution- Given contribution ID to check fornodeName- 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 theI_FolderAccessfor persisting theFolderprovided as param.- Parameters:
domainAccess- providing the information about the DB connection.folder- to define theI_FolderAccessthat allows its DB access.dateTime- that will be set as transaction date when theFolderis persistedehrId- of theEhrthat references theFolderprovided as param.- Returns:
I_FolderAccesswith the information to persist the providedFolder
-
delete
Delete the object with the necessary metadata.
Includes sub-folders.- Specified by:
deletein interfaceI_VersionedCRUD- Parameters:
timestamp- Time of operationsystemId- Audit committercommitterId- Audit systemdescription- (Optional) Audit description- Returns:
- Number of deleted objects
-
delete
Delete the object with the necessary metadata, which will be derived from the contribution.
Includes sub-folders.- Specified by:
deletein interfaceI_VersionedCRUD- Parameters:
timestamp- Time of operationcontribution- 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 correspondingI_FolderAccessfor allowing its persistence.timestamp- that will be set as transaction date when theFolderis persistedehrId- of theEhrthat references thisFolder- Returns:
I_FolderAccesswith the information to persist the providedFolder
-
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 contextfolder- - Folder to create access fortimeStamp- - Current time for transaction auditehrId- - Corresponding EHRcontributionAccess- - 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 contextfolderId- - ObjectVersionUid of the folder to check for the last version- Returns:
- Latest version number for the folder
-
hasPreviousVersion
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 contextfolderId- - 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 instancerootFolderId- - Root folder idsysTransaction- - 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
Getters and Setters for the FolderRecord to store- Specified by:
getEhrIdin interfaceI_FolderAccess
-
setEhrId
-
getContributionAccess
-
setContributionAccess
-
getSubfoldersList
Description copied from interface:I_FolderAccessGet the list of subfolders for theFolderthat corresponds to thisI_FolderAccess- Specified by:
getSubfoldersListin interfaceI_FolderAccess- Returns:
- Map<UUID, I_FolderAccess> whose key is the UUID of the child
Folder, and whose value is the I_FolderAccess for the childFolder.
-
getItems
public List<com.nedap.archie.rm.support.identification.ObjectRef<? extends com.nedap.archie.rm.support.identification.ObjectId>> getItems()Description copied from interface:I_FolderAccessGet the items references stored as a part of the givenFolder- Specified by:
getItemsin interfaceI_FolderAccess- Returns:
- items of the
Folderthat corresponds to thisI_FolderAccess
-
getFolderId
- Specified by:
getFolderIdin interfaceI_FolderAccess
-
setFolderId
- Specified by:
setFolderIdin interfaceI_FolderAccess
-
getInContribution
- Specified by:
getInContributionin interfaceI_FolderAccess
-
setInContribution
- Specified by:
setInContributionin interfaceI_FolderAccess
-
getFolderName
- Specified by:
getFolderNamein interfaceI_FolderAccess
-
setFolderName
- Specified by:
setFolderNamein interfaceI_FolderAccess
-
getFolderArchetypeNodeId
- Specified by:
getFolderArchetypeNodeIdin interfaceI_FolderAccess
-
setFolderNArchetypeNodeId
- Specified by:
setFolderNArchetypeNodeIdin interfaceI_FolderAccess
-
isFolderActive
public boolean isFolderActive()- Specified by:
isFolderActivein interfaceI_FolderAccess
-
setIsFolderActive
public void setIsFolderActive(boolean folderActive) - Specified by:
setIsFolderActivein interfaceI_FolderAccess
-
getFolderDetails
public com.nedap.archie.rm.datastructures.ItemStructure getFolderDetails()- Specified by:
getFolderDetailsin interfaceI_FolderAccess
-
setFolderDetails
public void setFolderDetails(com.nedap.archie.rm.datastructures.ItemStructure folderDetails) - Specified by:
setFolderDetailsin interfaceI_FolderAccess
-
setFolderSysTransaction
- Specified by:
setFolderSysTransactionin interfaceI_FolderAccess
-
getFolderSysTransaction
- Specified by:
getFolderSysTransactionin interfaceI_FolderAccess
-
getFolderSysPeriod
- Specified by:
getFolderSysPeriodin interfaceI_FolderAccess
-
setFolderSysPeriod
public void setFolderSysPeriod(AbstractMap.SimpleEntry<OffsetDateTime, OffsetDateTime> folderSysPeriod) - Specified by:
setFolderSysPeriodin interfaceI_FolderAccess
-
getAudit
- Specified by:
getAuditin interfaceI_FolderAccess
-
setAudit
- Specified by:
setAuditin interfaceI_FolderAccess
-
getDataAccess
- Specified by:
getDataAccessin interfaceI_DomainAccess
-
compareTo
- Specified by:
compareToin interfaceComparable<FolderAccess>
-
adminDeleteFolder
public void adminDeleteFolder()Description copied from interface:I_FolderAccessInvoke physical deletion.- Specified by:
adminDeleteFolderin interfaceI_FolderAccess
-
getSysTransaction
- Specified by:
getSysTransactionin interfaceI_Compensatable
-
getContributionId
- Specified by:
getContributionIdin interfaceI_Compensatable
-
getId
- Specified by:
getIdin interfaceI_Compensatable
-