Class JDBCIdentityCacheImpl
- java.lang.Object
-
- org.linuxforhealth.fhir.persistence.jdbc.dao.impl.JDBCIdentityCacheImpl
-
- All Implemented Interfaces:
JDBCIdentityCache
public class JDBCIdentityCacheImpl extends java.lang.Object implements JDBCIdentityCache
Pulls together the DAOs and tenant-specific cache to provide a single place where we can look up the identity of various records we need
-
-
Constructor Summary
Constructors Constructor Description JDBCIdentityCacheImpl(FHIRPersistenceJDBCCache cache, ResourceDAO resourceDAO, ParameterDAO parameterDAO, ICommonValuesDAO commonValuesDAO)Public constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.LonggetCanonicalId(java.lang.String canonicalValue)Get the database id for the given canonical value.java.lang.IntegergetCodeSystemId(java.lang.String codeSystemName)Get the database id for the named code-system.java.lang.LonggetCommonTokenValueId(java.lang.String codeSystem, java.lang.String tokenValue)Get the common_token_value_id for the given tokenValue and codeSystem.java.util.List<java.lang.Long>getCommonTokenValueIdList(java.lang.String tokenValue)Get a list of matching common_token_value_id values.java.util.Set<java.lang.Long>getCommonTokenValueIds(java.util.Collection<CommonTokenValue> tokenValues)Get the common_token_value_ids for the given tokenValues.java.lang.LonggetLogicalResourceId(java.lang.String resourceType, java.lang.String logicalId)Get the database id for the given (resourceType, logicalId) tuple.java.util.List<java.lang.Long>getLogicalResourceIdList(java.lang.String logicalId)Get a list of logical_resource_id values matching the given logicalId without knowing the resource type.java.util.Set<java.lang.Long>getLogicalResourceIds(java.util.Collection<ResourceReferenceValue> referenceValues)Get the logical_resource_ids for the given referenceValues.java.lang.IntegergetParameterNameId(java.lang.String parameterName)Get the database id for the given parameter name.java.lang.IntegergetResourceTypeId(java.lang.String resourceType)Get the database id for the named resourceType.java.util.List<java.lang.Integer>getResourceTypeIds()Get the list of all resource type ids.java.lang.StringgetResourceTypeName(java.lang.Integer resourceTypeId)Get the resource type name for the resourceTypeId.java.util.List<java.lang.String>getResourceTypeNames()Get the list of all resource type names.
-
-
-
Constructor Detail
-
JDBCIdentityCacheImpl
public JDBCIdentityCacheImpl(FHIRPersistenceJDBCCache cache, ResourceDAO resourceDAO, ParameterDAO parameterDAO, ICommonValuesDAO commonValuesDAO)
Public constructor- Parameters:
cache-parameterDAO-commonValuesDAO-
-
-
Method Detail
-
getResourceTypeId
public java.lang.Integer getResourceTypeId(java.lang.String resourceType) throws FHIRPersistenceExceptionDescription copied from interface:JDBCIdentityCacheGet the database id for the named resourceType. Reads from a cache or database if required.- Specified by:
getResourceTypeIdin interfaceJDBCIdentityCache- Returns:
- Throws:
FHIRPersistenceException
-
getResourceTypeName
public java.lang.String getResourceTypeName(java.lang.Integer resourceTypeId) throws FHIRPersistenceExceptionDescription copied from interface:JDBCIdentityCacheGet the resource type name for the resourceTypeId. Reads from a cache or database if required.- Specified by:
getResourceTypeNamein interfaceJDBCIdentityCache- Returns:
- Throws:
FHIRPersistenceException
-
getCodeSystemId
public java.lang.Integer getCodeSystemId(java.lang.String codeSystemName) throws FHIRPersistenceExceptionDescription copied from interface:JDBCIdentityCacheGet the database id for the named code-system. Creates new records if necessary- Specified by:
getCodeSystemIdin interfaceJDBCIdentityCache- Returns:
- Throws:
FHIRPersistenceException
-
getParameterNameId
public java.lang.Integer getParameterNameId(java.lang.String parameterName) throws FHIRPersistenceExceptionDescription copied from interface:JDBCIdentityCacheGet the database id for the given parameter name. Creates new records if necessary.- Specified by:
getParameterNameIdin interfaceJDBCIdentityCache- Returns:
- Throws:
FHIRPersistenceException
-
getCanonicalId
public java.lang.Long getCanonicalId(java.lang.String canonicalValue) throws FHIRPersistenceExceptionDescription copied from interface:JDBCIdentityCacheGet the database id for the given canonical value. Read only. If the value does not exist, -1 is returned.- Specified by:
getCanonicalIdin interfaceJDBCIdentityCache- Returns:
- Throws:
FHIRPersistenceException
-
getCommonTokenValueId
public java.lang.Long getCommonTokenValueId(java.lang.String codeSystem, java.lang.String tokenValue)Description copied from interface:JDBCIdentityCacheGet the common_token_value_id for the given tokenValue and codeSystem. Reads from a cache, or the database if not found in the cache.- Specified by:
getCommonTokenValueIdin interfaceJDBCIdentityCache- Returns:
- The common token value id or null if it doesn't exist
-
getCommonTokenValueIds
public java.util.Set<java.lang.Long> getCommonTokenValueIds(java.util.Collection<CommonTokenValue> tokenValues)
Description copied from interface:JDBCIdentityCacheGet the common_token_value_ids for the given tokenValues. Reads from a cache, or the database if not found in the cache. CommonTokenValues with no corresponding record in the database will be omitted from the result set.- Specified by:
getCommonTokenValueIdsin interfaceJDBCIdentityCache- Returns:
- A non-null, possibly-empty set of common token value ids
-
getCommonTokenValueIdList
public java.util.List<java.lang.Long> getCommonTokenValueIdList(java.lang.String tokenValue)
Description copied from interface:JDBCIdentityCacheGet a list of matching common_token_value_id values. Implementations may decide to cache, but only if the cache can be invalidated when the list changes due to ingestion. The simplest approach is to always read from the database. The performance benefit to the FHIR search query this is being used for is orders of magnitude greater than the cost of this query (think 80+ seconds to 250 milliseconds improvement in search query time).- Specified by:
getCommonTokenValueIdListin interfaceJDBCIdentityCache- Returns:
-
getResourceTypeNames
public java.util.List<java.lang.String> getResourceTypeNames() throws FHIRPersistenceExceptionDescription copied from interface:JDBCIdentityCacheGet the list of all resource type names.- Specified by:
getResourceTypeNamesin interfaceJDBCIdentityCache- Returns:
- Throws:
FHIRPersistenceException
-
getResourceTypeIds
public java.util.List<java.lang.Integer> getResourceTypeIds() throws FHIRPersistenceExceptionDescription copied from interface:JDBCIdentityCacheGet the list of all resource type ids.- Specified by:
getResourceTypeIdsin interfaceJDBCIdentityCache- Returns:
- Throws:
FHIRPersistenceException
-
getLogicalResourceId
public java.lang.Long getLogicalResourceId(java.lang.String resourceType, java.lang.String logicalId) throws FHIRPersistenceExceptionDescription copied from interface:JDBCIdentityCacheGet the database id for the given (resourceType, logicalId) tuple. This represents records in logical_resource_ident which may be created before the actual resource is created.- Specified by:
getLogicalResourceIdin interfaceJDBCIdentityCache- Returns:
- Throws:
FHIRPersistenceException
-
getLogicalResourceIds
public java.util.Set<java.lang.Long> getLogicalResourceIds(java.util.Collection<ResourceReferenceValue> referenceValues) throws FHIRPersistenceException
Description copied from interface:JDBCIdentityCacheGet the logical_resource_ids for the given referenceValues. Reads from a cache, or the database if not found in the cache. Values with no corresponding record in the database will be omitted from the result set.- Specified by:
getLogicalResourceIdsin interfaceJDBCIdentityCache- Returns:
- a non-null, possibly empty set of logical_resource_ids.
- Throws:
FHIRPersistenceException
-
getLogicalResourceIdList
public java.util.List<java.lang.Long> getLogicalResourceIdList(java.lang.String logicalId) throws FHIRPersistenceExceptionDescription copied from interface:JDBCIdentityCacheGet a list of logical_resource_id values matching the given logicalId without knowing the resource type. This means we could get back multiple ids, one per resource type, such as:- Claim/foo
- Observation/foo
- Patient/foo
- Specified by:
getLogicalResourceIdListin interfaceJDBCIdentityCache- Returns:
- Throws:
FHIRPersistenceException
-
-