Class 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).
    • 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>
      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)
      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.
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • PARTITION_HASH_BASE64_DIGITS

        public static final int PARTITION_HASH_BASE64_DIGITS
        See Also:
        Constant Field Values
    • Constructor Detail

      • FHIRPayloadPersistenceCassandraImpl

        public FHIRPayloadPersistenceCassandraImpl()
        Public constructor
    • 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 interface FHIRPayloadPersistence
        Parameters:
        resourceType - the type name of the resource
        resourceTypeId - the database id assigned to this resource type
        logicalId - the logical id of the resource
        version - the version of the resource
        resourcePayloadKey - the unique key used to tie this to the RDBMS record
        resource - 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 interface FHIRPayloadPersistence
        Parameters:
        resourceType - the expected resource type class
        rowResourceTypeName - the resource type name of the resource read from the database (matching the resourceTypeId)
        resourceTypeId - the unique int identifier for the resource type name
        logicalId - the logical identifier of the desired resource
        version - the specific version of the desired resource
        resourcePayloadKey - the resource payload key connecting the entry to the RDBMS record
        elements - 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 interface FHIRPayloadPersistence
        version - the version id, or null for all versions
        resourcePayloadKey - 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 interface FHIRPayloadPersistence
        lastUpdated - the last modification time of the resource in the RDBMS record
        Returns:
        Throws:
        FHIRPersistenceException