Interface ResourceDAO
-
- All Superinterfaces:
FHIRDbDAO
- All Known Implementing Classes:
CitusResourceDAO
,DerbyResourceDAO
,EraseResourceDAO
,PostgresReindexResourceDAO
,PostgresResourceDAO
,PostgresResourceNoProcDAO
,ReindexResourceDAO
,ResourceDAOImpl
public interface ResourceDAO extends FHIRDbDAO
This Data Access Object interface provides methods creating, updating, and retrieving rows in the FHIR Resource tables.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.List<Resource>
history(java.lang.String resourceType, java.lang.String logicalId, java.sql.Timestamp fromDateTime, int offset, int maxResults)
Reads and returns all versions of the Resource with the passed logicalId, ordered by descending version id.int
historyCount(java.lang.String resourceType, java.lang.String logicalId, java.sql.Timestamp fromDateTime)
Reads and returns the COUNT of all versions of the Resource with the passed logicalId.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.java.util.Map<java.lang.String,java.lang.Integer>
readAllResourceTypeNames()
Reads all rows in the resource_types table and returns the data as a Mapjava.lang.Long
readLogicalResourceId(int resourceTypeId, java.lang.String logicalId)
Look up the value of the logical_resource_id from the logical_resource_ident tablejava.util.List<java.lang.Long>
readLogicalResourceIdList(java.lang.String logicalId)
Read all the matching logical_resource_id values for the given logicalIdjava.lang.Integer
readResourceTypeId(java.lang.String parameterName)
Reads the id associated with the name of the passed Resource type from the Resource_Types table.java.util.List<Resource>
search(java.lang.String sqlSelect)
Executes the passed fully-formed SQL Select statement and returns the results If no matching resources are found, an empty collection is returned.java.util.List<Resource>
search(Select select)
Executes the search contained in the passedSelect
, using its encapsulated search string and bind variables.java.util.List<Resource>
searchByIds(java.lang.String resourceType, java.util.List<java.lang.Long> resourceIds, boolean includeResourceData)
Searches for Resources that contain one of the passed ids.int
searchCount(java.lang.String sqlSelectCount)
Executes the passed fully-formed SQL Select COUNT statement and returns the integer count.int
searchCount(Select countQuery)
Executes a count query based on the data contained in the passedSelect
statement, using its encapsulated search string and bind variables.java.util.List<java.lang.Long>
searchForIds(Select dataQuery)
This method supports the execution of a specialized query designed to return Resource ids, based on the contents of the passed select statement.java.util.Map<java.lang.Integer,java.util.List<java.lang.Long>>
searchWholeSystem(Select select)
Executes the whole-system filter search contained in the passedSelect
, using its encapsulated search string and bind variables.void
setPersistenceContext(FHIRPersistenceContext context)
Sets the current persistence contextResource
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 interface org.linuxforhealth.fhir.persistence.jdbc.dao.api.FHIRDbDAO
getConnection, getFlavor
-
-
-
-
Method Detail
-
read
Resource read(java.lang.String logicalId, java.lang.String resourceType) throws FHIRPersistenceDataAccessException, FHIRPersistenceDBConnectException
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.- Parameters:
logicalId
-resourceType
-- 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
Resource versionRead(java.lang.String logicalId, java.lang.String resourceType, int versionId) throws FHIRPersistenceDataAccessException, FHIRPersistenceDBConnectException
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.- Parameters:
logicalId
-resourceType
-version
- id- 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
-
history
java.util.List<Resource> history(java.lang.String resourceType, java.lang.String logicalId, java.sql.Timestamp fromDateTime, int offset, int maxResults) throws FHIRPersistenceDataAccessException, FHIRPersistenceDBConnectException
Reads and returns all versions of the Resource with the passed logicalId, ordered by descending version id. If non-null, the passed fromDateTime is used to limit the returned Resource versions to those that were updated after the fromDateTime.- Parameters:
resourceType
- - The name of a FHIR Resource typelogicalId
- - The logical id of a FHIR ResourcefromDateTime
- - The starting date/time of the version history.- Returns:
- List
- An ordered list of Resource versions. - Throws:
FHIRPersistenceDataAccessException
FHIRPersistenceDBConnectException
-
historyCount
int historyCount(java.lang.String resourceType, java.lang.String logicalId, java.sql.Timestamp fromDateTime) throws FHIRPersistenceDataAccessException, FHIRPersistenceDBConnectException
Reads and returns the COUNT of all versions of the Resource with the passed logicalId. If non-null, the passed fromDateTime is used to limit the count of Resource versions to those that were updated after the fromDateTime.- Parameters:
resourceType
- - The name of a FHIR Resource typelogicalId
- - The logical id of a FHIR ResourcefromDateTime
- - The starting date/time of the version history.- Returns:
- int - The count of Resource versions.
- Throws:
FHIRPersistenceDataAccessException
FHIRPersistenceDBConnectException
-
search
java.util.List<Resource> search(Select select) throws FHIRPersistenceDataAccessException, FHIRPersistenceDBConnectException
Executes the search contained in the passedSelect
, using its encapsulated search string and bind variables.- Parameters:
select
- - Contains a search query and (optionally) bind variables.- Returns:
- List
A list of FHIR Resources satisfying the passed search. - Throws:
FHIRPersistenceDataAccessException
FHIRPersistenceDBConnectException
-
search
java.util.List<Resource> search(java.lang.String sqlSelect) throws FHIRPersistenceDataAccessException, FHIRPersistenceDBConnectException
Executes the passed fully-formed SQL Select statement and returns the results If no matching resources are found, an empty collection is returned.- Parameters:
sqlSelect
- - A fully formed SQL select statement.- Returns:
- List
- A List of Resources that satisfy the passed SQL query string. - Throws:
FHIRPersistenceDataAccessException
FHIRPersistenceDBConnectException
-
searchForIds
java.util.List<java.lang.Long> searchForIds(Select dataQuery) throws FHIRPersistenceDataAccessException, FHIRPersistenceDBConnectException
This method supports the execution of a specialized query designed to return Resource ids, based on the contents of the passed select statement. Note that the first column to be selected MUST be the Resource.id column.- Parameters:
dataQuery
-- Returns:
- Throws:
FHIRPersistenceDataAccessException
FHIRPersistenceDBConnectException
-
searchByIds
java.util.List<Resource> searchByIds(java.lang.String resourceType, java.util.List<java.lang.Long> resourceIds, boolean includeResourceData) throws FHIRPersistenceDataAccessException, FHIRPersistenceDBConnectException
Searches for Resources that contain one of the passed ids.- Parameters:
resourceType
- - The type of the FHIR ResourceresourceIds
- - A List of resource ids.includeResourceData
- - fetch the resource DATA column- Returns:
- List
- A List of resources matching the the passed list of ids. - Throws:
FHIRPersistenceDataAccessException
FHIRPersistenceDBConnectException
-
searchCount
int searchCount(Select countQuery) throws FHIRPersistenceDataAccessException, FHIRPersistenceDBConnectException
Executes a count query based on the data contained in the passedSelect
statement, using its encapsulated search string and bind variables.- Parameters:
countQuery
- - Contains a search string and (optionally) bind variables.- Returns:
- int A count of FHIR Resources satisfying the passed search.
- Throws:
FHIRPersistenceDataAccessException
FHIRPersistenceDBConnectException
-
searchCount
int searchCount(java.lang.String sqlSelectCount) throws FHIRPersistenceDataAccessException, FHIRPersistenceDBConnectException
Executes the passed fully-formed SQL Select COUNT statement and returns the integer count.- Parameters:
sqlSelect
- - A fully formed SQL select count statement.- Returns:
- int - The count of resources that fulfill the passed SQL select statement.
- Throws:
FHIRPersistenceDataAccessException
FHIRPersistenceDBConnectException
-
searchWholeSystem
java.util.Map<java.lang.Integer,java.util.List<java.lang.Long>> searchWholeSystem(Select select) throws FHIRPersistenceDataAccessException, FHIRPersistenceDBConnectException
Executes the whole-system filter search contained in the passedSelect
, using its encapsulated search string and bind variables.- Parameters:
select
- - Contains a search query and (optionally) bind variables.- Returns:
- Map
> A map of FHIR resource type ID to list of logical resource IDs satisfying the passed search. - Throws:
FHIRPersistenceDataAccessException
FHIRPersistenceDBConnectException
-
setPersistenceContext
void setPersistenceContext(FHIRPersistenceContext context)
Sets the current persistence context- Parameters:
context
-
-
readAllResourceTypeNames
java.util.Map<java.lang.String,java.lang.Integer> readAllResourceTypeNames() throws FHIRPersistenceDBConnectException, FHIRPersistenceDataAccessException
Reads all rows in the resource_types table and returns the data as a Map- Returns:
- Map
- A map containing key=parameter-name, value=parameter-name-id - Throws:
FHIRPersistenceDBConnectException
FHIRPersistenceDataAccessException
-
readResourceTypeId
java.lang.Integer readResourceTypeId(java.lang.String parameterName) throws FHIRPersistenceDBConnectException, FHIRPersistenceDataAccessException
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.- Parameters:
String
- A valid FHIR resource type.- Returns:
- Integer - the id associated with the name of the passed Resource type.
- Throws:
FHIRPersistenceDBConnectException
FHIRPersistenceDataAccessException
-
insert
Resource insert(Resource resource, java.util.List<ExtractedParameterValue> parameters, java.lang.String parameterHashB64, ParameterDAO parameterDao, java.lang.Integer ifNoneMatch) throws FHIRPersistenceException
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.- 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
-
readLogicalResourceId
java.lang.Long readLogicalResourceId(int resourceTypeId, java.lang.String logicalId) throws FHIRPersistenceDBConnectException, FHIRPersistenceDataAccessException
Look up the value of the logical_resource_id from the logical_resource_ident table- Parameters:
resourceTypeId
-logicalId
-- Returns:
- Throws:
FHIRPersistenceDBConnectException
FHIRPersistenceDataAccessException
-
readLogicalResourceIdList
java.util.List<java.lang.Long> readLogicalResourceIdList(java.lang.String logicalId) throws FHIRPersistenceDBConnectException, FHIRPersistenceDataAccessException
Read all the matching logical_resource_id values for the given logicalId- Parameters:
logicalId
-- Returns:
- Throws:
FHIRPersistenceDBConnectException
FHIRPersistenceDataAccessException
-
-