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.
-
-
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 voiddeleteFromParameterTable(Connection conn, String tableName, long logicalResourceId)Delete all parameters for the given resourceId from the parameters tableintgetOrCreateResourceType(String resourceTypeName, Connection conn)stored-procedure-less implementation for managing the resource_types tableprotected IntegergetResourceTypeId(String resourceTypeName, Connection conn)Read the id for the named typeResourceinsert(Resource resource, List<ExtractedParameterValue> parameters, ParameterDAO parameterDao)Inserts the passed FHIR Resource and associated search parameters to a postgresql FHIR database.IntegerreadResourceTypeId(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, createDTO, getCache, getResourceReferenceDAO, getResourceTypeIdFromCaches, getSearchByIdsSql, getTransactionData, history, historyCount, read, readAllResourceTypeNames, search, search, searchByIds, searchCount, searchCount, searchForIds, searchStringValues, setPersistenceContext, versionRead
-
Methods inherited from class com.ibm.fhir.persistence.jdbc.dao.impl.FHIRDbDAOImpl
buildExceptionWithIssue, buildFHIRPersistenceDBConnectException, cleanup, cleanup, createDTOs, getConnection, getFlavor, getSchemaName, isDb2Database, runCountQuery, 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, ParameterDAO parameterDao) throws FHIRPersistenceException
Inserts the passed FHIR Resource and associated search parameters to a postgresql FHIR database.- Specified by:
insertin interfaceResourceDAO- Overrides:
insertin classResourceDAOImpl- Parameters:
resource- The FHIR Resource to be inserted.parameters- The Resource's search parameters to be inserted.parameterDao-- Returns:
- The Resource DTO
- Throws:
FHIRPersistenceExceptionFHIRPersistenceDataAccessExceptionFHIRPersistenceDBConnectExceptionFHIRPersistenceVersionIdMismatchException
-
deleteFromParameterTable
protected void deleteFromParameterTable(Connection conn, String tableName, long logicalResourceId) throws SQLException
Delete all parameters for the given resourceId from the parameters table- 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-- 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-- Throws:
SQLException
-
readResourceTypeId
public Integer readResourceTypeId(String resourceType) throws FHIRPersistenceDBConnectException, FHIRPersistenceDataAccessException
Description copied from interface:ResourceDAOReads 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:
readResourceTypeIdin interfaceResourceDAO- Overrides:
readResourceTypeIdin classResourceDAOImpl- Returns:
- Integer - the id associated with the name of the passed Resource type.
- Throws:
FHIRPersistenceDBConnectExceptionFHIRPersistenceDataAccessException
-
-