Package dev.dsf.fhir.dao
Interface ResourceDao<R extends org.hl7.fhir.r4.model.Resource>
- All Known Subinterfaces:
ActivityDefinitionDao,BinaryDao,BundleDao,CodeSystemDao,DocumentReferenceDao,EndpointDao,GroupDao,HealthcareServiceDao,LibraryDao,LocationDao,MeasureDao,MeasureReportDao,NamingSystemDao,OrganizationAffiliationDao,OrganizationDao,PatientDao,PractitionerDao,PractitionerRoleDao,ProvenanceDao,QuestionnaireDao,QuestionnaireResponseDao,ResearchStudyDao,StructureDefinitionDao,SubscriptionDao,TaskDao,ValueSetDao
- All Known Implementing Classes:
ActivityDefinitionDaoJdbc,BinaryDaoJdbc,BundleDaoJdbc,CodeSystemDaoJdbc,DocumentReferenceDaoJdbc,EndpointDaoJdbc,GroupDaoJdbc,HealthcareServiceDaoJdbc,LibraryDaoJdbc,LocationDaoJdbc,MeasureDaoJdbc,MeasureReportDaoJdbc,NamingSystemDaoJdbc,OrganizationAffiliationDaoJdbc,OrganizationDaoJdbc,PatientDaoJdbc,PractitionerDaoJdbc,PractitionerRoleDaoJdbc,ProvenanceDaoJdbc,QuestionnaireDaoJdbc,QuestionnaireResponseDaoJdbc,ResearchStudyDaoJdbc,StructureDefinitionDaoJdbc,StructureDefinitionSnapshotDaoJdbc,SubscriptionDaoJdbc,TaskDaoJdbc,ValueSetDaoJdbc
public interface ResourceDao<R extends org.hl7.fhir.r4.model.Resource>
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptioncreateSearchQuery(Identity identity, int page, int count) createSearchQueryWithoutUserFilter(int page, int count) createWithId(R resource, UUID uuid) createWithTransactionAndId(Connection connection, R resource, UUID uuid) booleanReturnsfalseif a matching resource was already marked as deletedvoiddeletePermanently(UUID uuid) Permanently delete a resource that was previously marked as deleted.voiddeletePermanentlyWithTransaction(Connection connection, UUID uuid) Permanently delete a resource that was previously marked as deleted.booleandeleteWithTransaction(Connection connection, UUID uuid) Returnsfalseif a matching resource was already marked as deletedbooleanexistsNotDeleted(String id, String version) booleanexistsNotDeletedWithTransaction(Connection connection, String id, String version) readAll()readAllWithTransaction(Connection connection) readIncludingDeleted(UUID uuid) readIncludingDeletedWithTransaction(Connection connection, UUID uuid) readVersion(UUID uuid, long version) readVersionWithTransaction(Connection connection, UUID uuid, long version) readWithTransaction(Connection connection, UUID uuid) search(DbSearchQuery query) searchWithTransaction(Connection connection, DbSearchQuery query) default RSets the version of the stored resource to latest version from DB plus 1.Sets the version of the stored resource to latest version from DB plus 1.default RupdateWithTransaction(Connection connection, R resource) Sets the version of the stored resource to latest version from DB plus 1.updateWithTransaction(Connection connection, R resource, Long expectedVersion) Sets the version of the stored resource to latest version from DB plus 1.
-
Field Details
-
FIRST_VERSION
static final int FIRST_VERSION- See Also:
-
FIRST_VERSION_STRING
-
-
Method Details
-
getResourceTypeName
String getResourceTypeName() -
getResourceType
-
newReadWriteTransaction
- Throws:
SQLException
-
create
- Parameters:
resource- notnull- Returns:
- the stored resource, not the same object as the given resource (defensive copy)
- Throws:
SQLException- if database access errors occur
-
createWithId
- Parameters:
resource- notnulluuid- notnull- Returns:
- the stored resource, not the same object as the given resource (defensive copy)
- Throws:
SQLException- if database access errors occur
-
createWithTransactionAndId
- Parameters:
connection- notnull, notConnection.isReadOnly()resource- notnulluuid- notnull- Returns:
- the stored resource, not the same object as the given resource
- Throws:
SQLException- if database access errors occurIllegalArgumentException- if the given connection isConnection.isReadOnly()
-
read
- Parameters:
uuid- may benull- Returns:
Optional.empty()if the given uuid isnullor no resource could be found for the given uuid- Throws:
SQLException- if database access errors occurResourceDeletedException- if a resource with the given uuid could be found, but is marked as delete
-
readWithTransaction
Optional<R> readWithTransaction(Connection connection, UUID uuid) throws SQLException, ResourceDeletedException - Parameters:
connection- notnulluuid- may benull- Returns:
Optional.empty()if the given uuid isnullor no resource could be found for the given uuid- Throws:
SQLException- if database access errors occurResourceDeletedException- if a resource with the given uuid could be found, but is marked as delete
-
readVersion
- Parameters:
uuid- may benullversion- may be less then 1- Returns:
Optional.empty()if the given uuid isnull, the given version is less then 1 or no resource could be found for the given uuid and version- Throws:
SQLException- if database access errors occurResourceDeletedException- if a resource with the given uuid and version could be found, but is the delete history entry
-
readVersionWithTransaction
Optional<R> readVersionWithTransaction(Connection connection, UUID uuid, long version) throws SQLException, ResourceDeletedException - Parameters:
connection- notnulluuid- may benullversion- may be less then 1- Returns:
Optional.empty()if the given uuid isnull, the given version is less then 1 or no resource could be found for the given uuid and version- Throws:
SQLException- if database access errors occurResourceDeletedException- if a resource with the given uuid and version could be found, but is the delete history entry
-
readIncludingDeleted
- Parameters:
uuid- may benull- Returns:
Optional.empty()if the given uuid isnullor no resource could be found for the given uuid- Throws:
SQLException- if database access errors occur
-
readIncludingDeletedWithTransaction
Optional<R> readIncludingDeletedWithTransaction(Connection connection, UUID uuid) throws SQLException - Parameters:
connection- notnulluuid- may benull- Returns:
Optional.empty()if the given uuid isnullor no resource could be found for the given uuid- Throws:
SQLException- if database access errors occur
-
readAll
- Throws:
SQLException
-
readAllWithTransaction
- Parameters:
connection- notnull- Returns:
Listcontaining matching resources- Throws:
SQLException- if database access errors occur
-
existsNotDeleted
- Parameters:
id- notnullversion- may benull- Returns:
- if the given id is null
false; if the given version isnullor blank and a resource with the given id exists and is not marked as deletedtrue; if the given version is notnulland not blank and a resource with the given id and version exists and is not marked as deletedtrue - Throws:
SQLException- if database access errors occur- See Also:
-
existsNotDeletedWithTransaction
boolean existsNotDeletedWithTransaction(Connection connection, String id, String version) throws SQLException - Parameters:
connection- notnullid- notnullversion- may benull- Returns:
- if the given id is null
false; if the given version isnullor blank and a resource with the given id exists and is not marked as deletedtrue; if the given version is notnulland not blank and a resource with the given id and version exists and is not marked as deletedtrue - Throws:
SQLException- if database access errors occur- See Also:
-
update
Sets the version of the stored resource to latest version from DB plus 1. Does not check the latest version in DB before storing the update. Resurrects all old versions (removes deleted flag) if the latest version in DB is marked as deleted.- Parameters:
resource- notnull- Returns:
- the stored resource, not the same object as the given resource (defensive copy)
- Throws:
SQLException- if database access errors occurResourceNotFoundException- if the given resource could not be found- See Also:
-
update
R update(R resource, Long expectedVersion) throws SQLException, ResourceNotFoundException, ResourceVersionNoMatchException Sets the version of the stored resource to latest version from DB plus 1. If the given expectedVersion is notnull, checks if the given expectedVersion is the latest version in DB before storing the update. Resurrects all old versions (removes deleted flag) if the latest version in DB is marked as deleted.- Parameters:
resource- notnullexpectedVersion- may benull- Returns:
- the stored resource, not the same object as the given resource (defensive copy)
- Throws:
SQLException- if database access errors occurResourceNotFoundException- if the given resource could not be foundResourceVersionNoMatchException- if the given expectedVersion is notnulland the latest version does not match the given expectedVersion
-
updateWithTransaction
default R updateWithTransaction(Connection connection, R resource) throws SQLException, ResourceNotFoundException Sets the version of the stored resource to latest version from DB plus 1. Does not check the latest version in DB before storing the update. Resurrects all old versions (removes deleted flag) if the latest version in DB is marked as deleted.- Parameters:
connection- notnull, notConnection.isReadOnly()and notConnection.getAutoCommit()andConnection.getTransactionIsolation()one ofConnection.TRANSACTION_REPEATABLE_READorConnection.TRANSACTION_SERIALIZABLEresource- notnull- Returns:
- the stored resource, not the same object as the given resource (defensive copy)
- Throws:
SQLException- if database access errors occurResourceNotFoundException- if the given resource could not be foundIllegalArgumentException- if the given connection isConnection.isReadOnly()or isConnection.getAutoCommit()orConnection.getTransactionIsolation()is not one ofConnection.TRANSACTION_REPEATABLE_READorConnection.TRANSACTION_SERIALIZABLE
-
updateWithTransaction
R updateWithTransaction(Connection connection, R resource, Long expectedVersion) throws SQLException, ResourceNotFoundException, ResourceVersionNoMatchException Sets the version of the stored resource to latest version from DB plus 1. If the given expectedVersion is notnull, checks if the given expectedVersion is the latest version in DB before storing the update. Resurrects all old versions (removes deleted flag) if the latest version in DB is marked as deleted.- Parameters:
connection- notnull, notConnection.isReadOnly()and notConnection.getAutoCommit()andConnection.getTransactionIsolation()one ofConnection.TRANSACTION_REPEATABLE_READorConnection.TRANSACTION_SERIALIZABLEresource- notnullexpectedVersion- may benull- Returns:
- the stored resource, not the same object as the given resource (defensive copy)
- Throws:
SQLException- if database access errors occurResourceNotFoundException- if the given resource could not be foundResourceVersionNoMatchException- if the given expectedVersion is notnulland is not the latest versionIllegalArgumentException- if the given connection isConnection.isReadOnly()or isConnection.getAutoCommit()orConnection.getTransactionIsolation()is not one ofConnection.TRANSACTION_REPEATABLE_READorConnection.TRANSACTION_SERIALIZABLE
-
delete
Returnsfalseif a matching resource was already marked as deleted- Parameters:
uuid- may benull- Returns:
trueif a resource with the given uuid could be found and marked as deleted,falseif a resource with the given uuid was already marked as deleted- Throws:
SQLException- if database access errors occurResourceNotFoundException- if the given uuid isnullor no resource could be found with the given uuid
-
deleteWithTransaction
boolean deleteWithTransaction(Connection connection, UUID uuid) throws SQLException, ResourceNotFoundException Returnsfalseif a matching resource was already marked as deleted- Parameters:
connection- notnull, notConnection.isReadOnly()uuid- may benull- Returns:
trueif a resource with the given uuid could be found and marked as deleted,falseif a resource with the given uuid was already marked as deleted- Throws:
SQLException- if database access errors occurResourceNotFoundException- if the given uuid isnullor no resource could be found with the given uuid
-
search
- Parameters:
query- notnull- Returns:
PartialResultthat matched the search query- Throws:
SQLException- if database access errors occur
-
searchWithTransaction
PartialResult<R> searchWithTransaction(Connection connection, DbSearchQuery query) throws SQLException - Parameters:
connection- notnullquery- notnull- Returns:
PartialResultthat matched the search query- Throws:
SQLException- if database access errors occur
-
createSearchQuery
-
createSearchQueryWithoutUserFilter
-
deletePermanently
void deletePermanently(UUID uuid) throws SQLException, ResourceNotFoundException, ResourceNotMarkedDeletedException Permanently delete a resource that was previously marked as deleted.- Parameters:
uuid- may benull- Throws:
SQLException- if database access errors occurResourceNotFoundException- if the given uuid isnullor no resource could be found with the given uuidResourceNotMarkedDeletedException- if the resource was not marked as deleted
-
deletePermanentlyWithTransaction
void deletePermanentlyWithTransaction(Connection connection, UUID uuid) throws SQLException, ResourceNotFoundException, ResourceNotMarkedDeletedException Permanently delete a resource that was previously marked as deleted.- Parameters:
connection- notnull, notConnection.isReadOnly()uuid- may benull- Throws:
SQLException- if database access errors occurResourceNotFoundException- if the given uuid isnullor no resource could be found with the given uuidResourceNotMarkedDeletedException- if the resource was not marked as deleted
-