Package dev.dsf.fhir.dao.jdbc
Class StructureDefinitionDaoJdbc
java.lang.Object
dev.dsf.fhir.dao.jdbc.StructureDefinitionDaoJdbc
- All Implemented Interfaces:
ReadByUrlDao<org.hl7.fhir.r4.model.StructureDefinition>,ResourceDao<org.hl7.fhir.r4.model.StructureDefinition>,StructureDefinitionDao,org.springframework.beans.factory.InitializingBean
-
Field Summary
Fields inherited from interface dev.dsf.fhir.dao.ResourceDao
FIRST_VERSION, FIRST_VERSION_STRING -
Constructor Summary
ConstructorsConstructorDescriptionStructureDefinitionDaoJdbc(DataSource dataSource, DataSource permanentDeleteDataSource, ca.uhn.fhir.context.FhirContext fhirContext) -
Method Summary
Modifier and TypeMethodDescriptionvoidprotected org.hl7.fhir.r4.model.StructureDefinitioncopy(org.hl7.fhir.r4.model.StructureDefinition resource) final org.hl7.fhir.r4.model.StructureDefinitioncreate(org.hl7.fhir.r4.model.StructureDefinition resource) final SearchQuery<org.hl7.fhir.r4.model.StructureDefinition>createSearchQuery(Identity identity, int page, int count) SearchQuery<org.hl7.fhir.r4.model.StructureDefinition>createSearchQueryWithoutUserFilter(int page, int count) org.hl7.fhir.r4.model.StructureDefinitioncreateWithId(org.hl7.fhir.r4.model.StructureDefinition resource, UUID uuid) org.hl7.fhir.r4.model.StructureDefinitioncreateWithTransactionAndId(Connection connection, org.hl7.fhir.r4.model.StructureDefinition resource, UUID uuid) protected final booleandelete(Connection connection, UUID uuid) final 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 idString, String versionString) booleanexistsNotDeletedWithTransaction(Connection connection, String idString, String versionString) protected static <R extends org.hl7.fhir.r4.model.Resource>
SearchQueryParameterFactory<R>factory(String parameterName, Supplier<SearchQueryParameter<R>> supplier) protected static <R extends org.hl7.fhir.r4.model.Resource>
SearchQueryParameterFactory<R>factory(String parameterName, Supplier<SearchQueryParameter<R>> supplier, List<String> nameModifiers) protected static <R extends org.hl7.fhir.r4.model.Resource>
SearchQueryParameterFactory<R>factory(String parameterName, Supplier<SearchQueryParameter<R>> supplier, List<String> nameModifiers, Supplier<SearchQueryIncludeParameter<R>> includeSupplier, List<String> includeParameterValues) protected static SearchQueryRevIncludeParameterFactoryfactory(Supplier<SearchQueryRevIncludeParameter> revIncludeSupplier, List<String> revIncludeParameterValues) protected DataSourceprotected final dev.dsf.fhir.dao.jdbc.AbstractResourceDaoJdbc.LatestVersiongetLatestVersion(UUID uuid, Connection connection) protected final dev.dsf.fhir.dao.jdbc.AbstractResourceDaoJdbc.LatestVersiongetLatestVersion(org.hl7.fhir.r4.model.StructureDefinition resource, Connection connection) protected final Optional<dev.dsf.fhir.dao.jdbc.AbstractResourceDaoJdbc.LatestVersion>getLatestVersionIfExists(UUID uuid, Connection connection) protected dev.dsf.fhir.dao.jdbc.PreparedStatementFactory<org.hl7.fhir.r4.model.StructureDefinition>protected org.hl7.fhir.r4.model.StructureDefinitiongetResource(ResultSet result, int index) protected Stringprotected Stringprotected StringClass<org.hl7.fhir.r4.model.StructureDefinition>protected voidmodifySearchResultResource(org.hl7.fhir.r4.model.StructureDefinition resource, Connection connection) Override this method to modify resources retrieved by search queries before returning to the user.final Optional<org.hl7.fhir.r4.model.StructureDefinition>List<org.hl7.fhir.r4.model.StructureDefinition>readAll()List<org.hl7.fhir.r4.model.StructureDefinition>readAllWithTransaction(Connection connection) Optional<org.hl7.fhir.r4.model.StructureDefinition>readByUrlAndVersion(String urlAndVersion) Optional<org.hl7.fhir.r4.model.StructureDefinition>readByUrlAndVersion(String url, String version) Optional<org.hl7.fhir.r4.model.StructureDefinition>readByUrlAndVersionWithTransaction(Connection connection, String urlAndVersion) Optional<org.hl7.fhir.r4.model.StructureDefinition>readByUrlAndVersionWithTransaction(Connection connection, String url, String version) Optional<org.hl7.fhir.r4.model.StructureDefinition>readIncludingDeleted(UUID uuid) Optional<org.hl7.fhir.r4.model.StructureDefinition>readIncludingDeletedWithTransaction(Connection connection, UUID uuid) final Optional<org.hl7.fhir.r4.model.StructureDefinition>readVersion(UUID uuid, long version) Optional<org.hl7.fhir.r4.model.StructureDefinition>readVersionWithTransaction(Connection connection, UUID uuid, long version) Optional<org.hl7.fhir.r4.model.StructureDefinition>readWithTransaction(Connection connection, UUID uuid) final PartialResult<org.hl7.fhir.r4.model.StructureDefinition>search(DbSearchQuery query) PartialResult<org.hl7.fhir.r4.model.StructureDefinition>searchWithTransaction(Connection connection, DbSearchQuery query) protected final Longprotected final UUIDfinal org.hl7.fhir.r4.model.StructureDefinitionSets the version of the stored resource to latest version from DB plus 1.org.hl7.fhir.r4.model.StructureDefinitionupdateWithTransaction(Connection connection, org.hl7.fhir.r4.model.StructureDefinition resource, Long expectedVersion) Sets the version of the stored resource to latest version from DB plus 1.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface dev.dsf.fhir.dao.ResourceDao
create, createSearchQuery, createSearchQueryWithoutUserFilter, createWithId, createWithTransactionAndId, delete, deletePermanently, deletePermanentlyWithTransaction, deleteWithTransaction, existsNotDeleted, existsNotDeletedWithTransaction, getResourceType, getResourceTypeName, newReadWriteTransaction, read, readAll, readAllWithTransaction, readIncludingDeleted, readIncludingDeletedWithTransaction, readVersion, readVersionWithTransaction, readWithTransaction, search, searchWithTransaction, update, update, updateWithTransaction, updateWithTransaction
-
Constructor Details
-
StructureDefinitionDaoJdbc
public StructureDefinitionDaoJdbc(DataSource dataSource, DataSource permanentDeleteDataSource, ca.uhn.fhir.context.FhirContext fhirContext)
-
-
Method Details
-
copy
protected org.hl7.fhir.r4.model.StructureDefinition copy(org.hl7.fhir.r4.model.StructureDefinition resource) -
readByUrlAndVersion
public Optional<org.hl7.fhir.r4.model.StructureDefinition> readByUrlAndVersion(String urlAndVersion) throws SQLException - Specified by:
readByUrlAndVersionin interfaceReadByUrlDao<org.hl7.fhir.r4.model.StructureDefinition>- Throws:
SQLException
-
readByUrlAndVersionWithTransaction
public Optional<org.hl7.fhir.r4.model.StructureDefinition> readByUrlAndVersionWithTransaction(Connection connection, String urlAndVersion) throws SQLException - Specified by:
readByUrlAndVersionWithTransactionin interfaceReadByUrlDao<org.hl7.fhir.r4.model.StructureDefinition>- Throws:
SQLException
-
readByUrlAndVersion
public Optional<org.hl7.fhir.r4.model.StructureDefinition> readByUrlAndVersion(String url, String version) throws SQLException - Specified by:
readByUrlAndVersionin interfaceReadByUrlDao<org.hl7.fhir.r4.model.StructureDefinition>- Throws:
SQLException
-
readByUrlAndVersionWithTransaction
public Optional<org.hl7.fhir.r4.model.StructureDefinition> readByUrlAndVersionWithTransaction(Connection connection, String url, String version) throws SQLException - Specified by:
readByUrlAndVersionWithTransactionin interfaceReadByUrlDao<org.hl7.fhir.r4.model.StructureDefinition>- Throws:
SQLException
-
factory
protected static <R extends org.hl7.fhir.r4.model.Resource> SearchQueryParameterFactory<R> factory(String parameterName, Supplier<SearchQueryParameter<R>> supplier) -
factory
protected static SearchQueryRevIncludeParameterFactory factory(Supplier<SearchQueryRevIncludeParameter> revIncludeSupplier, List<String> revIncludeParameterValues) -
factory
protected static <R extends org.hl7.fhir.r4.model.Resource> SearchQueryParameterFactory<R> factory(String parameterName, Supplier<SearchQueryParameter<R>> supplier, List<String> nameModifiers, Supplier<SearchQueryIncludeParameter<R>> includeSupplier, List<String> includeParameterValues) -
factory
protected static <R extends org.hl7.fhir.r4.model.Resource> SearchQueryParameterFactory<R> factory(String parameterName, Supplier<SearchQueryParameter<R>> supplier, List<String> nameModifiers) -
afterPropertiesSet
- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
Exception
-
getDataSource
-
getResourceTable
-
getResourceIdColumn
-
getResourceColumn
-
getPreparedStatementFactory
protected dev.dsf.fhir.dao.jdbc.PreparedStatementFactory<org.hl7.fhir.r4.model.StructureDefinition> getPreparedStatementFactory() -
getResourceTypeName
- Specified by:
getResourceTypeNamein interfaceResourceDao<R extends org.hl7.fhir.r4.model.Resource>
-
getResourceType
- Specified by:
getResourceTypein interfaceResourceDao<R extends org.hl7.fhir.r4.model.Resource>
-
newReadWriteTransaction
- Specified by:
newReadWriteTransactionin interfaceResourceDao<R extends org.hl7.fhir.r4.model.Resource>- Throws:
SQLException
-
create
public final org.hl7.fhir.r4.model.StructureDefinition create(org.hl7.fhir.r4.model.StructureDefinition resource) throws SQLException - Specified by:
createin interfaceResourceDao<R extends org.hl7.fhir.r4.model.Resource>- 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
public org.hl7.fhir.r4.model.StructureDefinition createWithId(org.hl7.fhir.r4.model.StructureDefinition resource, UUID uuid) throws SQLException - Specified by:
createWithIdin interfaceResourceDao<R extends org.hl7.fhir.r4.model.Resource>- 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
public org.hl7.fhir.r4.model.StructureDefinition createWithTransactionAndId(Connection connection, org.hl7.fhir.r4.model.StructureDefinition resource, UUID uuid) throws SQLException - Specified by:
createWithTransactionAndIdin interfaceResourceDao<R extends org.hl7.fhir.r4.model.Resource>- 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 occur
-
getResource
protected org.hl7.fhir.r4.model.StructureDefinition getResource(ResultSet result, int index) throws SQLException - Throws:
SQLException
-
read
public final Optional<org.hl7.fhir.r4.model.StructureDefinition> read(UUID uuid) throws SQLException, ResourceDeletedException - Specified by:
readin interfaceResourceDao<R extends org.hl7.fhir.r4.model.Resource>- 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
public Optional<org.hl7.fhir.r4.model.StructureDefinition> readWithTransaction(Connection connection, UUID uuid) throws SQLException, ResourceDeletedException - Specified by:
readWithTransactionin interfaceResourceDao<R extends org.hl7.fhir.r4.model.Resource>- 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
public final Optional<org.hl7.fhir.r4.model.StructureDefinition> readVersion(UUID uuid, long version) throws SQLException, ResourceDeletedException - Specified by:
readVersionin interfaceResourceDao<R extends org.hl7.fhir.r4.model.Resource>- 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
public Optional<org.hl7.fhir.r4.model.StructureDefinition> readVersionWithTransaction(Connection connection, UUID uuid, long version) throws SQLException, ResourceDeletedException - Specified by:
readVersionWithTransactionin interfaceResourceDao<R extends org.hl7.fhir.r4.model.Resource>- 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
public Optional<org.hl7.fhir.r4.model.StructureDefinition> readIncludingDeleted(UUID uuid) throws SQLException - Specified by:
readIncludingDeletedin interfaceResourceDao<R extends org.hl7.fhir.r4.model.Resource>- 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
public Optional<org.hl7.fhir.r4.model.StructureDefinition> readIncludingDeletedWithTransaction(Connection connection, UUID uuid) throws SQLException - Specified by:
readIncludingDeletedWithTransactionin interfaceResourceDao<R extends org.hl7.fhir.r4.model.Resource>- 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
- Specified by:
readAllin interfaceResourceDao<R extends org.hl7.fhir.r4.model.Resource>- Throws:
SQLException
-
readAllWithTransaction
public List<org.hl7.fhir.r4.model.StructureDefinition> readAllWithTransaction(Connection connection) throws SQLException - Specified by:
readAllWithTransactionin interfaceResourceDao<R extends org.hl7.fhir.r4.model.Resource>- Parameters:
connection- notnull- Returns:
Listcontaining matching resources- Throws:
SQLException- if database access errors occur
-
existsNotDeleted
- Specified by:
existsNotDeletedin interfaceResourceDao<R extends org.hl7.fhir.r4.model.Resource>- Parameters:
idString- notnullversionString- 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
public boolean existsNotDeletedWithTransaction(Connection connection, String idString, String versionString) throws SQLException - Specified by:
existsNotDeletedWithTransactionin interfaceResourceDao<R extends org.hl7.fhir.r4.model.Resource>- Parameters:
connection- notnullidString- notnullversionString- 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
public final org.hl7.fhir.r4.model.StructureDefinition update(org.hl7.fhir.r4.model.StructureDefinition resource, Long expectedVersion) throws SQLException, ResourceNotFoundException, ResourceVersionNoMatchException Description copied from interface:ResourceDaoSets 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.- Specified by:
updatein interfaceResourceDao<R extends org.hl7.fhir.r4.model.Resource>- 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
public org.hl7.fhir.r4.model.StructureDefinition updateWithTransaction(Connection connection, org.hl7.fhir.r4.model.StructureDefinition resource, Long expectedVersion) throws SQLException, ResourceNotFoundException, ResourceVersionNoMatchException Description copied from interface:ResourceDaoSets 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.- Specified by:
updateWithTransactionin interfaceResourceDao<R extends org.hl7.fhir.r4.model.Resource>- 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 version
-
toUuid
-
toLong
-
getLatestVersion
protected final dev.dsf.fhir.dao.jdbc.AbstractResourceDaoJdbc.LatestVersion getLatestVersion(org.hl7.fhir.r4.model.StructureDefinition resource, Connection connection) throws SQLException, ResourceNotFoundException -
getLatestVersion
protected final dev.dsf.fhir.dao.jdbc.AbstractResourceDaoJdbc.LatestVersion getLatestVersion(UUID uuid, Connection connection) throws SQLException, ResourceNotFoundException -
getLatestVersionIfExists
protected final Optional<dev.dsf.fhir.dao.jdbc.AbstractResourceDaoJdbc.LatestVersion> getLatestVersionIfExists(UUID uuid, Connection connection) throws SQLException, ResourceNotFoundException -
delete
Description copied from interface:ResourceDaoReturnsfalseif a matching resource was already marked as deleted- Specified by:
deletein interfaceResourceDao<R extends org.hl7.fhir.r4.model.Resource>- 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
public boolean deleteWithTransaction(Connection connection, UUID uuid) throws SQLException, ResourceNotFoundException Description copied from interface:ResourceDaoReturnsfalseif a matching resource was already marked as deleted- Specified by:
deleteWithTransactionin interfaceResourceDao<R extends org.hl7.fhir.r4.model.Resource>- 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
-
delete
protected final boolean delete(Connection connection, UUID uuid) throws SQLException, ResourceNotFoundException -
search
public final PartialResult<org.hl7.fhir.r4.model.StructureDefinition> search(DbSearchQuery query) throws SQLException - Specified by:
searchin interfaceResourceDao<R extends org.hl7.fhir.r4.model.Resource>- Parameters:
query- notnull- Returns:
PartialResultthat matched the search query- Throws:
SQLException- if database access errors occur
-
searchWithTransaction
public PartialResult<org.hl7.fhir.r4.model.StructureDefinition> searchWithTransaction(Connection connection, DbSearchQuery query) throws SQLException - Specified by:
searchWithTransactionin interfaceResourceDao<R extends org.hl7.fhir.r4.model.Resource>- Parameters:
connection- notnullquery- notnull- Returns:
PartialResultthat matched the search query- Throws:
SQLException- if database access errors occur
-
modifySearchResultResource
protected void modifySearchResultResource(org.hl7.fhir.r4.model.StructureDefinition resource, Connection connection) throws SQLException Override this method to modify resources retrieved by search queries before returning to the user. This method can be used, if the resource returned by the search is not complete and additional content needs to be retrieved. For example the content of aBinaryresource might not be stored in the json column.- Parameters:
resource- notnullconnection- notnull- Throws:
SQLException- if database access errors occur
-
createSearchQuery
public final SearchQuery<org.hl7.fhir.r4.model.StructureDefinition> createSearchQuery(Identity identity, int page, int count) - Specified by:
createSearchQueryin interfaceResourceDao<R extends org.hl7.fhir.r4.model.Resource>
-
createSearchQueryWithoutUserFilter
public SearchQuery<org.hl7.fhir.r4.model.StructureDefinition> createSearchQueryWithoutUserFilter(int page, int count) - Specified by:
createSearchQueryWithoutUserFilterin interfaceResourceDao<R extends org.hl7.fhir.r4.model.Resource>
-
deletePermanently
public void deletePermanently(UUID uuid) throws SQLException, ResourceNotFoundException, ResourceNotMarkedDeletedException Description copied from interface:ResourceDaoPermanently delete a resource that was previously marked as deleted.- Specified by:
deletePermanentlyin interfaceResourceDao<R extends org.hl7.fhir.r4.model.Resource>- 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
public void deletePermanentlyWithTransaction(Connection connection, UUID uuid) throws SQLException, ResourceNotFoundException, ResourceNotMarkedDeletedException Description copied from interface:ResourceDaoPermanently delete a resource that was previously marked as deleted.- Specified by:
deletePermanentlyWithTransactionin interfaceResourceDao<R extends org.hl7.fhir.r4.model.Resource>- 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
-