Class FHIRPayloadPersistenceCassandraImpl
- java.lang.Object
-
- com.ibm.fhir.persistence.cassandra.payload.FHIRPayloadPersistenceCassandraImpl
-
- All Implemented Interfaces:
FHIRPayloadPersistence
public class FHIRPayloadPersistenceCassandraImpl extends java.lang.Object implements FHIRPayloadPersistence
Implementation to store and retrieve FHIR payload data using Cassandra. Because of Cassandra's consistency model, we can't rely on it to support deterministic version of FHIR resources. The version number must be known ahead of time (using another service with true ACID support).
-
-
Field Summary
Fields Modifier and Type Field Description static int
PARTITION_HASH_BASE64_DIGITS
static boolean
PAYLOAD_COMPRESSED
-
Constructor Summary
Constructors Constructor Description FHIRPayloadPersistenceCassandraImpl()
Public constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
deletePayload(java.lang.String resourceType, int resourceTypeId, java.lang.String logicalId, java.lang.Integer version, java.lang.String resourcePayloadKey)
Delete the payload item.protected com.datastax.oss.driver.api.core.CqlSession
getCqlSession()
Get a tenant-specific session for Cassandra<T extends Resource>
TreadResource(java.lang.Class<T> resourceType, java.lang.String rowResourceTypeName, int resourceTypeId, java.lang.String logicalId, int version, java.lang.String resourcePayloadKey, java.util.List<java.lang.String> elements)
Retrieve the payload data for the given resourceTypeId, logicalId and version.<T extends Resource>
java.util.concurrent.CompletableFuture<ResourceResult<? extends Resource>>readResourceAsync(java.lang.Class<T> resourceType, java.lang.String rowResourceTypeName, int resourceTypeId, java.lang.String logicalId, int version, java.lang.String resourcePayloadKey, java.time.Instant lastUpdated, java.util.List<java.lang.String> elements)
Async retrieval of the payload data for the given resourceTypeId, logicalId and version.PayloadPersistenceResponse
storePayload(java.lang.String resourceType, int resourceTypeId, java.lang.String logicalId, int version, java.lang.String resourcePayloadKey, Resource resource)
Store the payload.
-
-
-
Field Detail
-
PARTITION_HASH_BASE64_DIGITS
public static final int PARTITION_HASH_BASE64_DIGITS
- See Also:
- Constant Field Values
-
PAYLOAD_COMPRESSED
public static final boolean PAYLOAD_COMPRESSED
- See Also:
- Constant Field Values
-
-
Method Detail
-
getCqlSession
protected com.datastax.oss.driver.api.core.CqlSession getCqlSession()
Get a tenant-specific session for Cassandra
-
storePayload
public PayloadPersistenceResponse storePayload(java.lang.String resourceType, int resourceTypeId, java.lang.String logicalId, int version, java.lang.String resourcePayloadKey, Resource resource) throws FHIRPersistenceException
Description copied from interface:FHIRPayloadPersistence
Store the payload. The business key is the tuple {resourceTypeId, logicalId, version} This data is stored directly, and should ideally be compressed.- Specified by:
storePayload
in interfaceFHIRPayloadPersistence
- Parameters:
resourceType
- the type name of the resourceresourceTypeId
- the database id assigned to this resource typelogicalId
- the logical id of the resourceversion
- the version of the resourceresourcePayloadKey
- the unique key used to tie this to the RDBMS recordresource
- the resource to store- Returns:
- the payload key details and future result status.
- Throws:
FHIRPersistenceException
-
readResource
public <T extends Resource> T readResource(java.lang.Class<T> resourceType, java.lang.String rowResourceTypeName, int resourceTypeId, java.lang.String logicalId, int version, java.lang.String resourcePayloadKey, java.util.List<java.lang.String> elements) throws FHIRPersistenceException
Description copied from interface:FHIRPayloadPersistence
Retrieve the payload data for the given resourceTypeId, logicalId and version. Synchronous.- Specified by:
readResource
in interfaceFHIRPayloadPersistence
- Parameters:
resourceType
- the expected resource type classrowResourceTypeName
- the resource type name of the resource read from the database (matching the resourceTypeId)resourceTypeId
- the unique int identifier for the resource type namelogicalId
- the logical identifier of the desired resourceversion
- the specific version of the desired resourceresourcePayloadKey
- the resource payload key connecting the entry to the RDBMS recordelements
- to filter elements within the resource - can be null- Returns:
- the fhirResourcePayload exactly as it was provided to
#storePayload(String, int, String, int, String, byte[])
- Throws:
FHIRPersistenceException
-
deletePayload
public void deletePayload(java.lang.String resourceType, int resourceTypeId, java.lang.String logicalId, java.lang.Integer version, java.lang.String resourcePayloadKey) throws FHIRPersistenceException
Description copied from interface:FHIRPayloadPersistence
Delete the payload item. This may be called to clean up after a failed transaction or by the reconciliation process when it finds an orphaned record. when performing a hard delete on a resource.- Specified by:
deletePayload
in interfaceFHIRPayloadPersistence
version
- the version id, or null for all versionsresourcePayloadKey
- the key to make sure the entry matches the RDBMS record- Throws:
FHIRPersistenceException
-
readResourceAsync
public <T extends Resource> java.util.concurrent.CompletableFuture<ResourceResult<? extends Resource>> readResourceAsync(java.lang.Class<T> resourceType, java.lang.String rowResourceTypeName, int resourceTypeId, java.lang.String logicalId, int version, java.lang.String resourcePayloadKey, java.time.Instant lastUpdated, java.util.List<java.lang.String> elements) throws FHIRPersistenceException
Description copied from interface:FHIRPayloadPersistence
Async retrieval of the payload data for the given resourceTypeId, logicalId and version.- Specified by:
readResourceAsync
in interfaceFHIRPayloadPersistence
lastUpdated
- the last modification time of the resource in the RDBMS record- Returns:
- Throws:
FHIRPersistenceException
-
-