Package org.ehrbase.repository
Class AbstractVersionedObjectRepository<VR extends org.jooq.UpdatableRecord,DR extends org.jooq.UpdatableRecord,VH extends org.jooq.UpdatableRecord,DH extends org.jooq.UpdatableRecord,O extends com.nedap.archie.rm.archetyped.Locatable>
java.lang.Object
org.ehrbase.repository.AbstractVersionedObjectRepository<VR,DR,VH,DH,O>
- Direct Known Subclasses:
CompositionRepository,EhrFolderRepository,EhrRepository
public abstract class AbstractVersionedObjectRepository<VR extends org.jooq.UpdatableRecord,DR extends org.jooq.UpdatableRecord,VH extends org.jooq.UpdatableRecord,DH extends org.jooq.UpdatableRecord,O extends com.nedap.archie.rm.archetyped.Locatable>
extends Object
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.jooq.DSLContextprotected final ContributionRepositoryprotected static final org.ehrbase.openehr.dbformat.jooq.prototypes.ObjectDataHistoryTablePrototypeprotected static final org.ehrbase.openehr.dbformat.jooq.prototypes.ObjectDataTablePrototypestatic final Stringstatic final Stringstatic final Stringprotected final org.ehrbase.api.service.SystemServiceprotected final TimeProviderprotected static final org.ehrbase.openehr.dbformat.jooq.prototypes.ObjectVersionHistoryTablePrototypeprotected static final org.ehrbase.openehr.dbformat.jooq.prototypes.ObjectVersionTablePrototype -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractVersionedObjectRepository(AuditDetailsTargetType targetType, org.jooq.Table<VR> versionHead, org.jooq.Table<DR> dataHead, org.jooq.Table<VH> versionHistory, org.jooq.Table<DH> dataHistory, org.jooq.DSLContext context, ContributionRepository contributionRepository, org.ehrbase.api.service.SystemService systemService, TimeProvider timeProvider) -
Method Summary
Modifier and TypeMethodDescriptionprotected org.jooq.SelectQuery<org.jooq.Record> buildLocatableDataQuery(org.jooq.Condition condition, boolean head) static com.nedap.archie.rm.support.identification.ObjectVersionIdbuildObjectVersionId(UUID versionedObjectId, int sysVersion, org.ehrbase.api.service.SystemService systemService) buildVersionIdsByContributionQuery(String rmKey, UUID ehrId, UUID contributionId) protected voidcheckIsNextHeadVoId(UUID headVoid, int headVersion, com.nedap.archie.rm.support.identification.UIDBasedId uid) protected voidcommitHead(UUID ehrId, com.nedap.archie.rm.archetyped.Locatable versionDataObject, UUID contributionId, UUID auditId, org.ehrbase.jooq.pg.enums.ContributionChangeType changeType, Consumer<VR> addVersionFieldsFunction, BiConsumer<org.ehrbase.openehr.dbformat.StructureNode, DR> addDataFieldsFunction) protected org.jooq.ConditioncontributionCondition(UUID ehrId, UUID contributionId, org.jooq.Table<?> table) protected voidcopyHeadToHistory(VH versionRecord, OffsetDateTime now) protected OffsetDateTimecreateCurrentTime(OffsetDateTime lowerBound) Determines the current time.protected org.jooq.ArrayAggOrderByStep<org.jooq.Record2<String, org.jooq.JSONB>[]> dataArrayAggregation(org.jooq.Table<?> dataTable) protected org.jooq.ConditiondataRootCondition(org.jooq.Table<?> dataTable) protected voiddelete(UUID ehrId, org.jooq.Condition condition, int version, UUID contributionId, UUID auditId, String notfoundMessage) protected voiddeleteHead(org.jooq.Condition versionCondition, int oldVersion, Function<String, RuntimeException> exceptionProvider) static StringextractSystemId(com.nedap.archie.rm.support.identification.UIDBasedId uid) static UUIDextractUid(com.nedap.archie.rm.support.identification.UIDBasedId uid) static intextractVersion(com.nedap.archie.rm.support.identification.UIDBasedId uid) protected <T> org.jooq.Field<T> field(org.jooq.TableField<? extends org.ehrbase.openehr.dbformat.jooq.prototypes.AbstractRecordPrototype<?>, T> field) findByVersion(org.jooq.Condition condition, org.jooq.Condition historyCondition, int version) findHead(org.jooq.Condition condition) findLatestHistoryRoot(org.jooq.Condition condition) findRootRecordByVersion(org.jooq.Condition condition, org.jooq.Condition historyCondition, int version) protected Optional<com.nedap.archie.rm.support.identification.ObjectVersionId> findVersionByTime(org.jooq.Condition condition, org.jooq.Condition historyCondition, OffsetDateTime time) protected org.jooq.Result<VH> findVersionHeadRecords(org.jooq.Condition condition) protected <R extends org.jooq.Record>
org.jooq.SelectOnConditionStep<R> fromJoinedVersionData(org.jooq.SelectFromStep<R> select, boolean head) protected org.jooq.Field<?>[]getAdditionalSelectFields(org.jooq.Table<?> versionTable, org.jooq.Table<?> dataTable, boolean head) When reading some types of versioned objects additional data may be neededgetOriginalVersion(org.jooq.Condition condition, org.jooq.Condition historyCondition, int version) protected booleanprotected booleanprotected org.jooq.Field<String> jsonDataField(org.jooq.Table<DR> table, String... path) protected <L extends com.nedap.archie.rm.archetyped.Locatable>
Optional<L> toLocatable(org.jooq.Record jsonbRecord, Class<L> locatableClass) protected final VersionDataDbRecordtoRecords(UUID ehrId, com.nedap.archie.rm.archetyped.Locatable versionDataObject, UUID contributionId, UUID auditId) voidupdate(UUID ehrId, O versionedObject, org.jooq.Condition condition, org.jooq.Condition historyCondition, UUID contributionId, UUID auditId, Consumer<VR> addVersionFieldsFunction, BiConsumer<org.ehrbase.openehr.dbformat.StructureNode, DR> addDataFieldsFunction, String notFoundErrorMessage) protected org.jooq.SelectJoinStep<org.jooq.Record> versionHeadQueryExtended(org.jooq.DSLContext context) version head + empty history fields: SYS_PERIOD_UPPER, SYS_DELETED
-
Field Details
-
NOT_MATCH_UID
- See Also:
-
NOT_MATCH_SYSTEM_ID
- See Also:
-
NOT_MATCH_LATEST_VERSION
- See Also:
-
VERSION_PROTOTYPE
protected static final org.ehrbase.openehr.dbformat.jooq.prototypes.ObjectVersionTablePrototype VERSION_PROTOTYPE -
VERSION_HISTORY_PROTOTYPE
protected static final org.ehrbase.openehr.dbformat.jooq.prototypes.ObjectVersionHistoryTablePrototype VERSION_HISTORY_PROTOTYPE -
DATA_PROTOTYPE
protected static final org.ehrbase.openehr.dbformat.jooq.prototypes.ObjectDataTablePrototype DATA_PROTOTYPE -
DATA_HISTORY_PROTOTYPE
protected static final org.ehrbase.openehr.dbformat.jooq.prototypes.ObjectDataHistoryTablePrototype DATA_HISTORY_PROTOTYPE -
tables
-
context
protected final org.jooq.DSLContext context -
contributionRepository
-
systemService
protected final org.ehrbase.api.service.SystemService systemService -
timeProvider
-
-
Constructor Details
-
AbstractVersionedObjectRepository
protected AbstractVersionedObjectRepository(AuditDetailsTargetType targetType, org.jooq.Table<VR> versionHead, org.jooq.Table<DR> dataHead, org.jooq.Table<VH> versionHistory, org.jooq.Table<DH> dataHistory, org.jooq.DSLContext context, ContributionRepository contributionRepository, org.ehrbase.api.service.SystemService systemService, TimeProvider timeProvider)
-
-
Method Details
-
buildObjectVersionId
public static com.nedap.archie.rm.support.identification.ObjectVersionId buildObjectVersionId(UUID versionedObjectId, int sysVersion, org.ehrbase.api.service.SystemService systemService) -
findHead
-
findByVersion
-
field
protected <T> org.jooq.Field<T> field(org.jooq.TableField<? extends org.ehrbase.openehr.dbformat.jooq.prototypes.AbstractRecordPrototype<?>, T> field) -
findRootRecordByVersion
-
buildVersionIdsByContributionQuery
-
contributionCondition
-
isDeleted
protected boolean isDeleted(org.jooq.Condition condition, org.jooq.Condition historyCondition, Integer version) -
findLatestHistoryRoot
-
delete
-
getOriginalVersion
-
hasEhr
-
getLocatableClass
-
extractVersion
public static int extractVersion(com.nedap.archie.rm.support.identification.UIDBasedId uid) -
extractUid
-
extractSystemId
-
commitHead
protected void commitHead(UUID ehrId, com.nedap.archie.rm.archetyped.Locatable versionDataObject, UUID contributionId, UUID auditId, org.ehrbase.jooq.pg.enums.ContributionChangeType changeType, Consumer<VR> addVersionFieldsFunction, BiConsumer<org.ehrbase.openehr.dbformat.StructureNode, DR> addDataFieldsFunction) -
toRecords
protected final VersionDataDbRecord toRecords(UUID ehrId, com.nedap.archie.rm.archetyped.Locatable versionDataObject, UUID contributionId, UUID auditId) -
update
public void update(UUID ehrId, O versionedObject, org.jooq.Condition condition, org.jooq.Condition historyCondition, UUID contributionId, UUID auditId, Consumer<VR> addVersionFieldsFunction, BiConsumer<org.ehrbase.openehr.dbformat.StructureNode, DR> addDataFieldsFunction, String notFoundErrorMessage) -
getAdditionalSelectFields
protected org.jooq.Field<?>[] getAdditionalSelectFields(org.jooq.Table<?> versionTable, org.jooq.Table<?> dataTable, boolean head) When reading some types of versioned objects additional data may be needed- Parameters:
versionTable-dataTable-head-- Returns:
-
buildLocatableDataQuery
protected org.jooq.SelectQuery<org.jooq.Record> buildLocatableDataQuery(org.jooq.Condition condition, boolean head) - Parameters:
condition-head-- Returns:
- SelectQueryinvalid input: '<'Recordinvalid input: '<'UUID, Integer, JSONB, ...>
-
dataArrayAggregation
protected org.jooq.ArrayAggOrderByStep<org.jooq.Record2<String,org.jooq.JSONB>[]> dataArrayAggregation(org.jooq.Table<?> dataTable) -
fromJoinedVersionData
protected <R extends org.jooq.Record> org.jooq.SelectOnConditionStep<R> fromJoinedVersionData(org.jooq.SelectFromStep<R> select, boolean head) -
getVersionDataJoinFields
-
dataRootCondition
protected org.jooq.Condition dataRootCondition(org.jooq.Table<?> dataTable) -
findVersionByTime
protected Optional<com.nedap.archie.rm.support.identification.ObjectVersionId> findVersionByTime(org.jooq.Condition condition, org.jooq.Condition historyCondition, OffsetDateTime time) -
toLocatable
protected <L extends com.nedap.archie.rm.archetyped.Locatable> Optional<L> toLocatable(org.jooq.Record jsonbRecord, Class<L> locatableClass) - Type Parameters:
L-- Parameters:
jsonbRecord- {vo_id, sys_version, jsonData}locatableClass-- Returns:
-
copyHeadToHistory
-
deleteHead
protected void deleteHead(org.jooq.Condition versionCondition, int oldVersion, Function<String, RuntimeException> exceptionProvider) -
versionHeadQueryExtended
protected org.jooq.SelectJoinStep<org.jooq.Record> versionHeadQueryExtended(org.jooq.DSLContext context) version head + empty history fields: SYS_PERIOD_UPPER, SYS_DELETED- Parameters:
context-- Returns:
-
findVersionHeadRecords
-
jsonDataField
-
createCurrentTime
Determines the current time.- Parameters:
lowerBound- For proper version intervals the value is guaranteed to be at least 1 microsecond after lowerBound- Returns:
-
checkIsNextHeadVoId
protected void checkIsNextHeadVoId(UUID headVoid, int headVersion, com.nedap.archie.rm.support.identification.UIDBasedId uid)
-