Package org.ehrbase.dao.access.jooq
Class CompositionAccess
- java.lang.Object
-
- org.ehrbase.dao.access.support.DataAccess
-
- org.ehrbase.dao.access.jooq.CompositionAccess
-
- All Implemented Interfaces:
I_CompositionAccess,I_DomainAccess,I_VersionedCRUD
public class CompositionAccess extends DataAccess implements I_CompositionAccess
operations on the static part of Compositions (eg. non archetyped attributes)Created by Christian Chevalley on 4/2/2015.
-
-
Field Summary
Fields Modifier and Type Field Description static StringCOMPOSITION_LITERAL-
Fields inherited from interface org.ehrbase.dao.access.interfaces.I_CompositionAccess
COMPOSER_ID, COMPOSER_JOIN, composerId, composerRef, COMPOSITION_JOIN, compositionRef, CONCEPT_JOIN, conceptRef, EVENT_CONTEXT_JOIN, eventContextRef, F_COMPOSER_ID_ISSUER, F_COMPOSER_ID_TYPE_NAME, F_COMPOSER_ID_VALUE, F_COMPOSER_NAME, F_COMPOSER_REF_NAMESPACE, F_COMPOSER_REF_SCHEME, F_COMPOSER_REF_TYPE, F_COMPOSER_REF_VALUE, F_COMPOSITION_ID, F_CONCEPT_DESCRIPTION, F_CONCEPT_ID, F_CONTEXT_END_TIME, F_CONTEXT_END_TIME_TZID, F_CONTEXT_LOCATION, F_CONTEXT_OTHER_CONTEXT, F_CONTEXT_SETTING, F_CONTEXT_START_TIME, F_CONTEXT_START_TIME_TZID, F_ENTRY, F_ENTRY_TEMPLATE, F_FACILITY_ID_ISSUER, F_FACILITY_ID_TYPE_NAME, F_FACILITY_ID_VALUE, F_FACILITY_NAME, F_FACILITY_REF_NAMESPACE, F_FACILITY_REF_SCHEME, F_FACILITY_REF_TYPE, F_FACILITY_REF_VALUE, F_LANGUAGE, F_PARTICIPATION_FUNCTION, F_PARTICIPATION_MODE, F_PARTICIPATION_START_TIME, F_PARTICIPATION_START_TIME_TZID, F_PERFORMER_ID_ISSUER, F_PERFORMER_ID_TYPE_NAME, F_PERFORMER_ID_VALUE, F_PERFORMER_NAME, F_PERFORMER_REF_NAMESPACE, F_PERFORMER_REF_SCHEME, F_PERFORMER_REF_TYPE, F_PERFORMER_REF_VALUE, F_TERRITORY, F_TERRITORY_CODE, F_VERSION, FACILITY_ID, FACILITY_JOIN, facilityId, facilityRef, PARTICIPATION_JOIN, participationRef, PERFORMER_JOIN, performerRef, TERRITORY_JOIN, territoryRef
-
Fields 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
-
-
Constructor Summary
Constructors Constructor Description CompositionAccess(I_DomainAccess domainAccess, com.nedap.archie.rm.composition.Composition composition, UUID ehrId)Constructor with convenientI_DomainAccessparameter, for better readability.CompositionAccess(org.jooq.DSLContext context, I_KnowledgeCache knowledgeManager, IntrospectService introspectCache, ServerConfig serverConfig, com.nedap.archie.rm.composition.Composition composition, UUID ehrId)Basic constructor for composition.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intaddContent(I_EntryAccess entry)add an entry to the compositionvoidadminDelete()Invoke physical deletion.UUIDcommit(LocalDateTime timestamp, UUID contribution)Commit the object with the necessary metadata, which will be derived from the contribution.UUIDcommit(LocalDateTime timestamp, UUID committerId, UUID systemId, String description)Commit the object with the necessary metadata.intdelete(LocalDateTime timestamp, UUID contribution)Delete the object with the necessary metadata, which will be derived from the contribution.intdelete(LocalDateTime timestamp, UUID committerId, UUID systemId, String description)Delete the object with the necessary metadata.static booleanexists(I_DomainAccess domainAccess, UUID versionedObjectId)Checks if the given versionedObjectID points to an existing composition.UUIDgetAttestationRef()I_AuditDetailsAccessgetAuditDetailsAccess()UUIDgetAuditDetailsId()UUIDgetComposerId()get the composer IdList<I_EntryAccess>getContent()get the list of entries for this compositionList<UUID>getContentIds()get the list of entry Ids for this compositionOptional<UUID>getContextId()get the event context idUUIDgetContributionId()get the contribution idDataAccessgetDataAccess()UUIDgetEhrid()get the EHR id to which this composition belongs toStringgetFeederAudit()UUIDgetId()get the composition IdStringgetLanguageCode()get the language code for this composition (eg.static IntegergetLastVersionNumber(I_DomainAccess domainAccess, UUID compositionId)retrieve the number of versions for this composition or 1 if no history presentStringgetLinks()TimestampgetSysTransaction()IntegergetTerritoryCode()FIXME: bug? comment says 2-letter while methods are saying Integer get the 2-letters country codeTimestampgetTimeCommitted()Gets time_committed from contribution of composition.IntegergetVersion()static intgetVersionFromTimeStamp(I_DomainAccess domainAccess, UUID vCompositionUid, Timestamp timeCommitted)Calculate the version corresponding to aVersionedCompositionwhich is the closest in time (before) theTimestampprovided.static Map<Integer,I_CompositionAccess>getVersionMapOfComposition(I_DomainAccess domainAccess, UUID compositionId)Creates Map containing all versions as their Access object with their matching version number.static booleanhasPreviousVersion(I_DomainAccess domainAccess, UUID compositionId)check if a composition has a previous version in historystatic booleanisDeleted(I_DomainAccess domainAccess, UUID versionedObjectId)Checks if given composition ID is ID of a logically deleted composition.static Map<com.nedap.archie.rm.support.identification.ObjectVersionId,I_CompositionAccess>retrieveCompositionsInContribution(I_DomainAccess domainAccess, UUID contribution, String node)static I_CompositionAccessretrieveCompositionVersion(I_DomainAccess domainAccess, UUID id, int version)Retrieve composition(s) for an identified versionstatic I_CompositionAccessretrieveInstance(I_DomainAccess domainAccess, UUID id)Retrieve a composition access instance from the persistence layerstatic I_CompositionAccessretrieveInstanceByTimestamp(I_DomainAccess domainAccess, UUID compositionUid, Timestamp timeCommitted)Returns the instance of aVersionedCompositioncorresponding to the version which is the closest in time before the timeCommitted provided.voidsetAuditDetailsAccess(I_AuditDetailsAccess auditDetailsAccess)voidsetAuditDetailsId(UUID auditId)voidsetComposerId(UUID composerId)set the composer idvoidsetComposition(com.nedap.archie.rm.composition.Composition composition)voidsetCompositionRecord(CompositionHistoryRecord historyRecord)Set the record via converting from a history record.voidsetCompositionRecord(CompositionRecord record)voidsetCompositionRecord(org.jooq.Result<?> records)voidsetContent(List<I_EntryAccess> content)voidsetContext(com.nedap.archie.rm.composition.EventContext eventContext)voidsetContextCompositionId(UUID contextId)set the event context idvoidsetContributionAccess(I_ContributionAccess contributionAccess)voidsetContributionId(UUID contributionId)set the contribution id for this compositionvoidsetEhrid(UUID ehrId)set the EHR idvoidsetFeederAudit(com.nedap.archie.rm.archetyped.FeederAudit feederAudit)voidsetLanguageCode(String code)set the language codevoidsetLinks(List<com.nedap.archie.rm.archetyped.Link> links)voidsetTerritoryCode(Integer code)FIXME: bug? comment says 2-letter while methods are saying Integer set the 2-letters territory codebooleanupdate(LocalDateTime timestamp, UUID contribution)Update the object with the necessary metadata, which will be derived from the contribution.booleanupdate(LocalDateTime timestamp, UUID committerId, UUID systemId, String description, I_ConceptAccess.ContributionChangeType changeType)Update the object with the necessary metadata.voidupdateCompositionData(com.nedap.archie.rm.composition.Composition newComposition)-
Methods inherited from class org.ehrbase.dao.access.support.DataAccess
getConnection, getContext, getDialect, getIntrospectService, getKnowledgeManager, getServerConfig, releaseConnection
-
-
-
-
Field Detail
-
COMPOSITION_LITERAL
public static final String COMPOSITION_LITERAL
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CompositionAccess
public CompositionAccess(org.jooq.DSLContext context, I_KnowledgeCache knowledgeManager, IntrospectService introspectCache, ServerConfig serverConfig, com.nedap.archie.rm.composition.Composition composition, UUID ehrId)Basic constructor for composition.- Parameters:
context- DB context object of current server contextknowledgeManager- Knowledge cache object of current server contextintrospectCache- Introspect cache object of current server contextserverConfig- Server config object of current server contextcomposition- Object representation of given new compositionehrId- Given ID of EHR this composition will be created for- Throws:
IllegalArgumentException- when seeking language code, territory code or composer ID failed
-
CompositionAccess
public CompositionAccess(I_DomainAccess domainAccess, com.nedap.archie.rm.composition.Composition composition, UUID ehrId)
Constructor with convenientI_DomainAccessparameter, for better readability.- Parameters:
domainAccess- Current domain access objectcomposition- Object representation of given new compositionehrId- Given ID of EHR this composition will be created for- Throws:
IllegalArgumentException- when seeking language code, territory code or composer ID failed
-
-
Method Detail
-
commit
public UUID commit(LocalDateTime timestamp, UUID committerId, UUID systemId, String description)
Commit the object with the necessary metadata.- Specified by:
commitin interfaceI_VersionedCRUD- Parameters:
timestamp- Time of operationcommitterId- Audit committersystemId- Audit systemdescription- (Optional) Audit description- Returns:
- ID of object
-
commit
public UUID commit(LocalDateTime timestamp, UUID contribution)
Commit the object with the necessary metadata, which will be derived from the contribution.- Specified by:
commitin interfaceI_VersionedCRUD- Parameters:
timestamp- Time of operationcontribution- Given contribution to use and derive audit data from- Returns:
- ID of object
-
update
public boolean update(LocalDateTime timestamp, UUID committerId, UUID systemId, String description, I_ConceptAccess.ContributionChangeType changeType)
Update the object with the necessary metadata.- Specified by:
updatein interfaceI_VersionedCRUD- Parameters:
timestamp- Time of operationcommitterId- Audit committersystemId- Audit systemdescription- (Optional) Audit descriptionchangeType- Specific change type, because there are more than DELETED.- Returns:
- Boolean representing success of update
-
update
public boolean update(LocalDateTime timestamp, UUID contribution)
Update the object with the necessary metadata, which will be derived from the contribution.- Specified by:
updatein interfaceI_VersionedCRUD- Parameters:
timestamp- Time of operationcontribution- Given contribution to use and derive audit data from- Returns:
- Boolean representing success of update
-
delete
public int delete(LocalDateTime timestamp, UUID committerId, UUID systemId, String description)
Delete the object with the necessary metadata.- Specified by:
deletein interfaceI_VersionedCRUD- Parameters:
timestamp- Time of operationcommitterId- Audit committersystemId- Audit systemdescription- (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.- Specified by:
deletein interfaceI_VersionedCRUD- Parameters:
timestamp- Time of operationcontribution- Given contribution to use and derive audit data from- Returns:
- Number of deleted objects
-
retrieveCompositionVersion
public static I_CompositionAccess retrieveCompositionVersion(I_DomainAccess domainAccess, UUID id, int version)
Description copied from interface:I_CompositionAccessRetrieve composition(s) for an identified version- Parameters:
domainAccess- SQL contextid- the versioned_object uuidversion- version number- Returns:
I_CompositionAccessobject of the matching access instance- Throws:
IllegalArgumentException- when version number is not greater 0ObjectNotFoundException- when no composition could be found with given input
-
getLastVersionNumber
public static Integer getLastVersionNumber(I_DomainAccess domainAccess, UUID compositionId)
Description copied from interface:I_CompositionAccessretrieve the number of versions for this composition or 1 if no history present- Returns:
-
hasPreviousVersion
public static boolean hasPreviousVersion(I_DomainAccess domainAccess, UUID compositionId)
Description copied from interface:I_CompositionAccesscheck if a composition has a previous version in history- Returns:
-
retrieveInstance
public static I_CompositionAccess retrieveInstance(I_DomainAccess domainAccess, UUID id)
Description copied from interface:I_CompositionAccessRetrieve a composition access instance from the persistence layer- Parameters:
domainAccess- SQL context, knowledgeid- a composition uuid- Returns:
- a valid
I_CompositionAccess
-
getVersionFromTimeStamp
public static int getVersionFromTimeStamp(I_DomainAccess domainAccess, UUID vCompositionUid, Timestamp timeCommitted)
Description copied from interface:I_CompositionAccessCalculate the version corresponding to aVersionedCompositionwhich is the closest in time (before) theTimestampprovided.- Parameters:
domainAccess- TheI_DomainAccesscontaining the persistence information and DB connection parameters for persisting a composition.vCompositionUid- TheUUIDcorresponding to aVersionedCompositiontimeCommitted-Timestampof commit- Returns:
- version number
- Throws:
ObjectNotFoundException- when no version in compliance with timestamp is availableInternalServerException- on problem with SQL statement or input
-
retrieveInstanceByTimestamp
public static I_CompositionAccess retrieveInstanceByTimestamp(I_DomainAccess domainAccess, UUID compositionUid, Timestamp timeCommitted)
Description copied from interface:I_CompositionAccessReturns the instance of aVersionedCompositioncorresponding to the version which is the closest in time before the timeCommitted provided.- Parameters:
domainAccess-I_DomainAccesswith the persistence SQL Context and knowledge cachecompositionUid-UUIDthat identifies the composition.timeCommitted- {java.sql.Timestamp} that indicates the point in time to search version for the composition backwards.- Returns:
- the number of the version that is the closest in time (before) the timeCommitted parameter provided. If a null timeCommitted is provided the latest composition will be returned.
- Throws:
IllegalArgumentException- when no version in compliance with timestamp is available or when calculated version number is not greater 0InternalServerException- on problem with SQL statement or inputObjectNotFoundException- when no composition could be found with given input
-
retrieveCompositionsInContribution
public static Map<com.nedap.archie.rm.support.identification.ObjectVersionId,I_CompositionAccess> retrieveCompositionsInContribution(I_DomainAccess domainAccess, UUID contribution, String node)
-
getVersionMapOfComposition
public static Map<Integer,I_CompositionAccess> getVersionMapOfComposition(I_DomainAccess domainAccess, UUID compositionId)
Description copied from interface:I_CompositionAccessCreates Map containing all versions as their Access object with their matching version number.- Parameters:
domainAccess- Data AccesscompositionId- Given composition ID- Returns:
- Map referencing all versions by their version number
-
getEhrid
public UUID getEhrid()
Description copied from interface:I_CompositionAccessget the EHR id to which this composition belongs to- Specified by:
getEhridin interfaceI_CompositionAccess- Returns:
UUID
-
setEhrid
public void setEhrid(UUID ehrId)
Description copied from interface:I_CompositionAccessset the EHR id- Specified by:
setEhridin interfaceI_CompositionAccess- Parameters:
ehrId-UUID
-
getComposerId
public UUID getComposerId()
Description copied from interface:I_CompositionAccessget the composer Id- Specified by:
getComposerIdin interfaceI_CompositionAccess- Returns:
UUID
-
setComposerId
public void setComposerId(UUID composerId)
Description copied from interface:I_CompositionAccessset the composer id- Specified by:
setComposerIdin interfaceI_CompositionAccess- Parameters:
composerId-UUID
-
getContextId
public Optional<UUID> getContextId()
Description copied from interface:I_CompositionAccessget the event context id- Specified by:
getContextIdin interfaceI_CompositionAccess- Returns:
- Optional with ID if it exists, otherwise empty Optional
-
getContributionId
public UUID getContributionId()
Description copied from interface:I_CompositionAccessget the contribution id- Specified by:
getContributionIdin interfaceI_CompositionAccess- Returns:
UUID
-
getLanguageCode
public String getLanguageCode()
Description copied from interface:I_CompositionAccessget the language code for this composition (eg. 'en', 'fr' etc.)- Specified by:
getLanguageCodein interfaceI_CompositionAccess- Returns:
- language code as string
-
setLanguageCode
public void setLanguageCode(String code)
Description copied from interface:I_CompositionAccessset the language code- Specified by:
setLanguageCodein interfaceI_CompositionAccess- Parameters:
code- String
-
getTerritoryCode
public Integer getTerritoryCode()
Description copied from interface:I_CompositionAccessFIXME: bug? comment says 2-letter while methods are saying Integer get the 2-letters country code- Specified by:
getTerritoryCodein interfaceI_CompositionAccess- Returns:
-
setTerritoryCode
public void setTerritoryCode(Integer code)
Description copied from interface:I_CompositionAccessFIXME: bug? comment says 2-letter while methods are saying Integer set the 2-letters territory code- Specified by:
setTerritoryCodein interfaceI_CompositionAccess- Parameters:
code- String
-
getContent
public List<I_EntryAccess> getContent()
Description copied from interface:I_CompositionAccessget the list of entries for this composition- Specified by:
getContentin interfaceI_CompositionAccess- Returns:
- the list of entry as
I_EntryAccess - See Also:
I_EntryAccess
-
setContent
public void setContent(List<I_EntryAccess> content)
- Specified by:
setContentin interfaceI_CompositionAccess
-
getId
public UUID getId()
Description copied from interface:I_CompositionAccessget the composition Id- Specified by:
getIdin interfaceI_CompositionAccess- Returns:
-
getFeederAudit
public String getFeederAudit()
- Specified by:
getFeederAuditin interfaceI_CompositionAccess
-
getLinks
public String getLinks()
- Specified by:
getLinksin interfaceI_CompositionAccess
-
setFeederAudit
public void setFeederAudit(com.nedap.archie.rm.archetyped.FeederAudit feederAudit)
- Specified by:
setFeederAuditin interfaceI_CompositionAccess
-
setLinks
public void setLinks(List<com.nedap.archie.rm.archetyped.Link> links)
- Specified by:
setLinksin interfaceI_CompositionAccess
-
setContextCompositionId
public void setContextCompositionId(UUID contextId)
Description copied from interface:I_CompositionAccessset the event context id- Specified by:
setContextCompositionIdin interfaceI_CompositionAccess- Parameters:
contextId-UUID- Throws:
InternalServerException- on problem updating context
-
setContributionId
public void setContributionId(UUID contributionId)
Description copied from interface:I_CompositionAccessset the contribution id for this composition- Specified by:
setContributionIdin interfaceI_CompositionAccess
-
setCompositionRecord
public void setCompositionRecord(CompositionRecord record)
- Specified by:
setCompositionRecordin interfaceI_CompositionAccess
-
setCompositionRecord
public void setCompositionRecord(CompositionHistoryRecord historyRecord)
Description copied from interface:I_CompositionAccessSet the record via converting from a history record.- Specified by:
setCompositionRecordin interfaceI_CompositionAccess- Parameters:
historyRecord- History record
-
setCompositionRecord
public void setCompositionRecord(org.jooq.Result<?> records)
- Specified by:
setCompositionRecordin interfaceI_CompositionAccess- Throws:
IllegalArgumentException- when handling of record failed
-
setComposition
public void setComposition(com.nedap.archie.rm.composition.Composition composition)
- Specified by:
setCompositionin interfaceI_CompositionAccess
-
addContent
public int addContent(I_EntryAccess entry)
Description copied from interface:I_CompositionAccessadd an entry to the composition- Specified by:
addContentin interfaceI_CompositionAccess- Parameters:
entry-I_EntryAccessinstance- Returns:
- >0 success
-
getContentIds
public List<UUID> getContentIds()
Description copied from interface:I_CompositionAccessget the list of entry Ids for this composition- Specified by:
getContentIdsin interfaceI_CompositionAccess- Returns:
- a list of entry
UUIDs
-
getSysTransaction
public Timestamp getSysTransaction()
- Specified by:
getSysTransactionin interfaceI_CompositionAccess
-
getTimeCommitted
public Timestamp getTimeCommitted()
Description copied from interface:I_CompositionAccessGets time_committed from contribution of composition.- Specified by:
getTimeCommittedin interfaceI_CompositionAccess- Returns:
- Timestamp of time of commitment
-
setContributionAccess
public void setContributionAccess(I_ContributionAccess contributionAccess)
- Specified by:
setContributionAccessin interfaceI_CompositionAccess
-
setAuditDetailsAccess
public void setAuditDetailsAccess(I_AuditDetailsAccess auditDetailsAccess)
- Specified by:
setAuditDetailsAccessin interfaceI_CompositionAccess
-
getVersion
public Integer getVersion()
- Specified by:
getVersionin interfaceI_CompositionAccess
-
updateCompositionData
public void updateCompositionData(com.nedap.archie.rm.composition.Composition newComposition)
- Specified by:
updateCompositionDatain interfaceI_CompositionAccess- Throws:
IllegalArgumentException- when seeking language code, territory code or composer ID failed
-
setContext
public void setContext(com.nedap.archie.rm.composition.EventContext eventContext)
- Specified by:
setContextin interfaceI_CompositionAccess
-
getDataAccess
public DataAccess getDataAccess()
- Specified by:
getDataAccessin interfaceI_DomainAccess
-
getAuditDetailsId
public UUID getAuditDetailsId()
- Specified by:
getAuditDetailsIdin interfaceI_CompositionAccess
-
getAuditDetailsAccess
public I_AuditDetailsAccess getAuditDetailsAccess()
- Specified by:
getAuditDetailsAccessin interfaceI_CompositionAccess
-
setAuditDetailsId
public void setAuditDetailsId(UUID auditId)
- Specified by:
setAuditDetailsIdin interfaceI_CompositionAccess
-
exists
public static boolean exists(I_DomainAccess domainAccess, UUID versionedObjectId)
Description copied from interface:I_CompositionAccessChecks if the given versionedObjectID points to an existing composition.- Parameters:
domainAccess- Data access objectversionedObjectId- ID to be checked- Returns:
- True if exists
-
isDeleted
public static boolean isDeleted(I_DomainAccess domainAccess, UUID versionedObjectId)
Description copied from interface:I_CompositionAccessChecks if given composition ID is ID of a logically deleted composition.- Parameters:
domainAccess- Data access objectversionedObjectId- ID to be checked- Returns:
- True if deleted, false if not
-
adminDelete
public void adminDelete()
Description copied from interface:I_CompositionAccessInvoke physical deletion.- Specified by:
adminDeletein interfaceI_CompositionAccess
-
getAttestationRef
public UUID getAttestationRef()
- Specified by:
getAttestationRefin interfaceI_CompositionAccess
-
-