Class CitusResourceDAO
- java.lang.Object
-
- org.linuxforhealth.fhir.persistence.jdbc.dao.impl.FHIRDbDAOImpl
-
- org.linuxforhealth.fhir.persistence.jdbc.dao.impl.ResourceDAOImpl
-
- org.linuxforhealth.fhir.persistence.jdbc.postgres.PostgresResourceDAO
-
- org.linuxforhealth.fhir.persistence.jdbc.citus.CitusResourceDAO
-
- All Implemented Interfaces:
FHIRDbDAO
,ResourceDAO
public class CitusResourceDAO extends PostgresResourceDAO
Data access object for writing FHIR resources to Citus database using the stored procedure (or function, in this case)
-
-
Field Summary
-
Fields inherited from class org.linuxforhealth.fhir.persistence.jdbc.dao.impl.ResourceDAOImpl
DEFAULT_VALUE_REINDEX_TSTAMP, IDX_DATA, IDX_IS_DELETED, IDX_LAST_UPDATED, IDX_LOGICAL_ID, IDX_LOGICAL_RESOURCE_ID, IDX_RESOURCE_ID, IDX_RESOURCE_PAYLOAD_KEY, IDX_RESOURCE_TYPE_ID, IDX_VERSION_ID
-
-
Constructor Summary
Constructors Constructor Description CitusResourceDAO(java.sql.Connection connection, java.lang.String schemaName, FHIRDbFlavor flavor, javax.transaction.TransactionSynchronizationRegistry trxSynchRegistry, FHIRPersistenceJDBCCache cache, ParameterTransactionDataImpl ptdi, java.lang.Short shardKey)
Public constructorCitusResourceDAO(java.sql.Connection connection, java.lang.String schemaName, FHIRDbFlavor flavor, FHIRPersistenceJDBCCache cache, java.lang.Short shardKey)
Public constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected long
createOrLockLogicalResourceIdent(int resourceTypeId, java.lang.String logicalId)
Call the ADD_LOGICAL_RESOURCE_IDENT procedure to create or lock (select for update) the logical_resource_ident record.Resource
insert(Resource resource, java.util.List<ExtractedParameterValue> parameters, java.lang.String parameterHashB64, ParameterDAO parameterDao, java.lang.Integer ifNoneMatch)
Inserts the passed Resource DTO and its associated search parameters to the appropriate FHIR resource tables.Resource
read(java.lang.String logicalId, java.lang.String resourceType)
Reads and returns the latest version of the Resource with the passed logical id and resource type.Resource
versionRead(java.lang.String logicalId, java.lang.String resourceType, int versionId)
Reads and returns the version of the Resource with the passed logical id, resource type, and version id.-
Methods inherited from class org.linuxforhealth.fhir.persistence.jdbc.postgres.PostgresResourceDAO
getOrCreateResourceType, getResourceTypeId, readResourceTypeId
-
Methods inherited from class org.linuxforhealth.fhir.persistence.jdbc.dao.impl.ResourceDAOImpl
checkIfNoneMatch, createDTO, getCache, getResourceTypeId, getSearchByIdsNoDataSql, getSearchByIdsSql, getTransactionData, history, historyCount, readAllResourceTypeNames, readLogicalResourceId, readLogicalResourceIdList, search, search, searchByIds, searchCount, searchCount, searchForIds, searchWholeSystem, setInt, setPersistenceContext, setString
-
Methods inherited from class org.linuxforhealth.fhir.persistence.jdbc.dao.impl.FHIRDbDAOImpl
buildExceptionWithIssue, buildFHIRPersistenceDBConnectException, cleanup, cleanup, createDTOs, getConnection, getFlavor, getSchemaName, getTranslator, runCountQuery, runCountQuery, runQuery, runQuery, runQuery_STR_VALUES, severe, severe
-
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.linuxforhealth.fhir.persistence.jdbc.dao.api.FHIRDbDAO
getConnection, getFlavor
-
-
-
-
Constructor Detail
-
CitusResourceDAO
public CitusResourceDAO(java.sql.Connection connection, java.lang.String schemaName, FHIRDbFlavor flavor, FHIRPersistenceJDBCCache cache, java.lang.Short shardKey)
Public constructor- Parameters:
connection
-schemaName
-flavor
-cache
-rrd
-
-
CitusResourceDAO
public CitusResourceDAO(java.sql.Connection connection, java.lang.String schemaName, FHIRDbFlavor flavor, javax.transaction.TransactionSynchronizationRegistry trxSynchRegistry, FHIRPersistenceJDBCCache cache, ParameterTransactionDataImpl ptdi, java.lang.Short shardKey)
Public constructor- Parameters:
connection
-schemaName
-flavor
-trxSynchRegistry
-cache
-rrd
-ptdi
-
-
-
Method Detail
-
read
public Resource read(java.lang.String logicalId, java.lang.String resourceType) throws FHIRPersistenceDataAccessException, FHIRPersistenceDBConnectException
Description copied from interface:ResourceDAO
Reads and returns the latest version of the Resource with the passed logical id and resource type. If no matching resource is found, null is returned.- Specified by:
read
in interfaceResourceDAO
- Overrides:
read
in classPostgresResourceDAO
- Returns:
- Resource - The most recent version of the Resource with the passed logical id and resource type, or null if not found.
- Throws:
FHIRPersistenceDataAccessException
FHIRPersistenceDBConnectException
-
versionRead
public Resource versionRead(java.lang.String logicalId, java.lang.String resourceType, int versionId) throws FHIRPersistenceDataAccessException, FHIRPersistenceDBConnectException
Description copied from interface:ResourceDAO
Reads and returns the version of the Resource with the passed logical id, resource type, and version id. If no matching resource is found, null is returned.- Specified by:
versionRead
in interfaceResourceDAO
- Overrides:
versionRead
in classPostgresResourceDAO
- Returns:
- Resource - The version of the Resource with the passed logical id, resource type, and version id or null if not found.
- Throws:
FHIRPersistenceDataAccessException
FHIRPersistenceDBConnectException
-
insert
public Resource insert(Resource resource, java.util.List<ExtractedParameterValue> parameters, java.lang.String parameterHashB64, ParameterDAO parameterDao, java.lang.Integer ifNoneMatch) throws FHIRPersistenceException
Description copied from interface:ResourceDAO
Inserts the passed Resource DTO and its associated search parameters to the appropriate FHIR resource tables. After insert, the generated primary key is acquired and set in the Resource object.- Specified by:
insert
in interfaceResourceDAO
- Overrides:
insert
in classPostgresResourceDAO
- Parameters:
resource
- A Resource Data Transfer Objectparameters
- A collection of search parameters to be persisted along with the passed ResourceparameterHashB64
- Base64 encoded SHA-256 hash of parametersparameterDao
- The Parameter DAOifNoneMatch
- 0 for conditional create-on-update behavior; otherwise null- Returns:
- Resource The Resource DTO
- Throws:
FHIRPersistenceDataAccessException
FHIRPersistenceDBConnectException
FHIRPersistenceVersionIdMismatchException
FHIRPersistenceException
-
createOrLockLogicalResourceIdent
protected long createOrLockLogicalResourceIdent(int resourceTypeId, java.lang.String logicalId) throws java.sql.SQLException
Call the ADD_LOGICAL_RESOURCE_IDENT procedure to create or lock (select for update) the logical_resource_ident record. For Citus we run this step first because this function is distributed by the logical_id parameter.- Parameters:
resourceTypeId
-logicalId
-- Returns:
- Throws:
java.sql.SQLException
-
-