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_RESOURCE_PAYLOAD_KEY, IDX_RESOURCE_TYPE_ID, IDX_VERSION_ID
-
-
Constructor Summary
Constructors Constructor Description PostgresResourceDAO(java.sql.Connection connection, java.lang.String schemaName, FHIRDbFlavor flavor, FHIRPersistenceJDBCCache cache, IResourceReferenceDAO rrd)
PostgresResourceDAO(java.sql.Connection connection, java.lang.String schemaName, FHIRDbFlavor flavor, javax.transaction.TransactionSynchronizationRegistry trxSynchRegistry, FHIRPersistenceJDBCCache cache, IResourceReferenceDAO rrd, ParameterTransactionDataImpl ptdi)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
deleteFromParameterTable(java.sql.Connection conn, java.lang.String tableName, long logicalResourceId)
Delete all parameters for the given resourceId from the parameters tableint
getOrCreateResourceType(java.lang.String resourceTypeName, java.sql.Connection conn)
stored-procedure-less implementation for managing the resource_types tableprotected java.lang.Integer
getResourceTypeId(java.lang.String resourceTypeName, java.sql.Connection conn)
Read the id for the named typeResource
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.java.lang.Integer
readResourceTypeId(java.lang.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
checkIfNoneMatch, createDTO, getCache, getResourceReferenceDAO, getResourceTypeId, getSearchByIdsNoDataSql, getSearchByIdsSql, getTransactionData, history, historyCount, read, readAllResourceTypeNames, search, search, searchByIds, searchCount, searchCount, searchForIds, searchWholeSystem, setInt, setPersistenceContext, setString, 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(java.sql.Connection connection, java.lang.String schemaName, FHIRDbFlavor flavor, FHIRPersistenceJDBCCache cache, IResourceReferenceDAO rrd)
-
PostgresResourceDAO
public PostgresResourceDAO(java.sql.Connection connection, java.lang.String schemaName, FHIRDbFlavor flavor, javax.transaction.TransactionSynchronizationRegistry trxSynchRegistry, FHIRPersistenceJDBCCache cache, IResourceReferenceDAO rrd, ParameterTransactionDataImpl ptdi)
-
-
Method Detail
-
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 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(java.sql.Connection conn, java.lang.String tableName, long logicalResourceId) throws java.sql.SQLException
Delete all parameters for the given resourceId from the parameters table- Overrides:
deleteFromParameterTable
in classResourceDAOImpl
- Parameters:
conn
-tableName
-logicalResourceId
-- Throws:
java.sql.SQLException
-
getResourceTypeId
protected java.lang.Integer getResourceTypeId(java.lang.String resourceTypeName, java.sql.Connection conn) throws java.sql.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:
java.sql.SQLException
-
getOrCreateResourceType
public int getOrCreateResourceType(java.lang.String resourceTypeName, java.sql.Connection conn) throws java.sql.SQLException
stored-procedure-less implementation for managing the resource_types table- Parameters:
resourceTypeName
-conn
-- Throws:
java.sql.SQLException
-
readResourceTypeId
public java.lang.Integer readResourceTypeId(java.lang.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
-
-