Class PostgresResourceDAO
- java.lang.Object
-
- com.ibm.fhir.persistence.jdbc.dao.impl.FHIRDbDAOImpl
-
- com.ibm.fhir.persistence.jdbc.dao.impl.ResourceDAOImpl
-
- com.ibm.fhir.persistence.jdbc.postgres.PostgresResourceDAO
-
- All Implemented Interfaces:
FHIRDbDAO
,ResourceDAO
public class PostgresResourceDAO extends ResourceDAOImpl
Data access object for writing FHIR resources to an postgresql database using the stored procedure (or function, in this case)
-
-
Field Summary
-
Fields inherited from class com.ibm.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_VERSION_ID
-
-
Constructor Summary
Constructors Constructor Description PostgresResourceDAO(Connection connection, String schemaName, FHIRDbFlavor flavor, FHIRPersistenceJDBCCache cache, IResourceReferenceDAO rrd)
PostgresResourceDAO(Connection connection, String schemaName, FHIRDbFlavor flavor, TransactionSynchronizationRegistry trxSynchRegistry, FHIRPersistenceJDBCCache cache, IResourceReferenceDAO rrd, ParameterTransactionDataImpl ptdi)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
deleteFromParameterTable(Connection conn, String tableName, long logicalResourceId)
Delete all parameters for the given resourceId from the parameters tableint
getOrCreateResourceType(String resourceTypeName, Connection conn)
stored-procedure-less implementation for managing the resource_types tableprotected Integer
getResourceTypeId(String resourceTypeName, Connection conn)
Read the id for the named typeResource
insert(Resource resource, List<ExtractedParameterValue> parameters, String parameterHashB64, ParameterDAO parameterDao, Integer ifNoneMatch)
Inserts the passed Resource DTO and its associated search parameters to the appropriate FHIR resource tables.Integer
readResourceTypeId(String resourceType)
Reads the id associated with the name of the passed Resource type from the Resource_Types table.-
Methods inherited from class com.ibm.fhir.persistence.jdbc.dao.impl.ResourceDAOImpl
addResourceTypeCacheCandidate, checkIfNoneMatch, createDTO, getCache, getResourceReferenceDAO, getResourceTypeIdFromCaches, getSearchByIdsSql, getTransactionData, history, historyCount, read, readAllResourceTypeNames, search, search, searchByIds, searchCount, searchCount, searchForIds, searchWholeSystem, setInt, setPersistenceContext, versionRead
-
Methods inherited from class com.ibm.fhir.persistence.jdbc.dao.impl.FHIRDbDAOImpl
buildExceptionWithIssue, buildFHIRPersistenceDBConnectException, cleanup, cleanup, createDTOs, getConnection, getFlavor, getSchemaName, getTranslator, isDb2Database, 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 com.ibm.fhir.persistence.jdbc.dao.api.FHIRDbDAO
getConnection, getFlavor, isDb2Database
-
-
-
-
Constructor Detail
-
PostgresResourceDAO
public PostgresResourceDAO(Connection connection, String schemaName, FHIRDbFlavor flavor, FHIRPersistenceJDBCCache cache, IResourceReferenceDAO rrd)
-
PostgresResourceDAO
public PostgresResourceDAO(Connection connection, String schemaName, FHIRDbFlavor flavor, TransactionSynchronizationRegistry trxSynchRegistry, FHIRPersistenceJDBCCache cache, IResourceReferenceDAO rrd, ParameterTransactionDataImpl ptdi)
-
-
Method Detail
-
insert
public Resource insert(Resource resource, List<ExtractedParameterValue> parameters, String parameterHashB64, ParameterDAO parameterDao, 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 classResourceDAOImpl
- 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
-
deleteFromParameterTable
protected void deleteFromParameterTable(Connection conn, String tableName, long logicalResourceId) throws SQLException
Delete all parameters for the given resourceId from the parameters table- Overrides:
deleteFromParameterTable
in classResourceDAOImpl
- Parameters:
conn
-tableName
-logicalResourceId
-- Throws:
SQLException
-
getResourceTypeId
protected Integer getResourceTypeId(String resourceTypeName, Connection conn) throws SQLException
Read the id for the named type- Parameters:
resourceTypeName
-conn
-- Returns:
- the database id, or null if the named record is not found
- Throws:
SQLException
-
getOrCreateResourceType
public int getOrCreateResourceType(String resourceTypeName, Connection conn) throws SQLException
stored-procedure-less implementation for managing the resource_types table- Parameters:
resourceTypeName
-conn
-- Throws:
SQLException
-
readResourceTypeId
public Integer readResourceTypeId(String resourceType) throws FHIRPersistenceDBConnectException, FHIRPersistenceDataAccessException
Description copied from interface:ResourceDAO
Reads the id associated with the name of the passed Resource type from the Resource_Types table. If the id for the passed name is not present in the database, an id is generated, persisted, and returned.- Specified by:
readResourceTypeId
in interfaceResourceDAO
- Overrides:
readResourceTypeId
in classResourceDAOImpl
- Returns:
- Integer - the id associated with the name of the passed Resource type.
- Throws:
FHIRPersistenceDBConnectException
FHIRPersistenceDataAccessException
-
-