Class HashMapResourceProvider<T extends org.hl7.fhir.instance.model.api.IBaseResource>

java.lang.Object
ca.uhn.fhir.rest.server.provider.HashMapResourceProvider<T>
Type Parameters:
T - The resource type to support
All Implemented Interfaces:
IResourceProvider

public class HashMapResourceProvider<T extends org.hl7.fhir.instance.model.api.IBaseResource> extends Object implements IResourceProvider
This class is a simple implementation of the resource provider interface that uses a HashMap to store all resources in memory.

This class currently supports the following FHIR operations:

  • Create
  • Update existing resource
  • Update non-existing resource (e.g. create with client-supplied ID)
  • Delete
  • Search by resource type with no parameters
  • Field Details

  • Constructor Details

    • HashMapResourceProvider

      public HashMapResourceProvider(ca.uhn.fhir.context.FhirContext theFhirContext, Class<T> theResourceType)
      Constructor
      Parameters:
      theFhirContext - The FHIR context
      theResourceType - The resource type to support
  • Method Details

    • clear

      public void clear()
      Clear all data held in this resource provider
    • clearCounts

      public void clearCounts()
      Clear the counts used by getCountRead() and other count methods
    • create

      public ca.uhn.fhir.rest.api.MethodOutcome create(T theResource, RequestDetails theRequestDetails)
    • delete

      public ca.uhn.fhir.rest.api.MethodOutcome delete(org.hl7.fhir.instance.model.api.IIdType theId, RequestDetails theRequestDetails)
    • getCountCreate

      public long getCountCreate()
      This method returns a simple operation count. This is mostly useful for testing purposes.
    • getCountDelete

      public long getCountDelete()
      This method returns a simple operation count. This is mostly useful for testing purposes.
    • getCountRead

      public long getCountRead()
      This method returns a simple operation count. This is mostly useful for testing purposes.
    • getCountSearch

      public long getCountSearch()
      This method returns a simple operation count. This is mostly useful for testing purposes.
    • getCountUpdate

      public long getCountUpdate()
      This method returns a simple operation count. This is mostly useful for testing purposes.
    • getResourceType

      public Class<T> getResourceType()
      Description copied from interface: IResourceProvider
      Returns the type of resource returned by this provider
      Specified by:
      getResourceType in interface IResourceProvider
      Returns:
      Returns the type of resource returned by this provider
    • historyInstance

      public List<org.hl7.fhir.instance.model.api.IBaseResource> historyInstance(org.hl7.fhir.instance.model.api.IIdType theId, RequestDetails theRequestDetails)
    • historyType

      public List<T> historyType()
    • read

      public T read(org.hl7.fhir.instance.model.api.IIdType theId, RequestDetails theRequestDetails)
    • searchAll

      public List<org.hl7.fhir.instance.model.api.IBaseResource> searchAll(RequestDetails theRequestDetails)
    • getAllResources

    • searchById

      public List<org.hl7.fhir.instance.model.api.IBaseResource> searchById(ca.uhn.fhir.rest.param.TokenAndListParam theIds, RequestDetails theRequestDetails)
    • update

      public ca.uhn.fhir.rest.api.MethodOutcome update(T theResource, String theConditional, RequestDetails theRequestDetails)
      Parameters:
      theConditional - This is provided only so that subclasses can implement if they want
    • getFhirContext

      public ca.uhn.fhir.context.FhirContext getFhirContext()
    • store

      public org.hl7.fhir.instance.model.api.IIdType store(T theResource)
      This is a utility method that can be used to store a resource without having to use the outside API. In this case, the storage happens without any interaction with interceptors, etc.
      Parameters:
      theResource - The resource to store. If the resource has an ID, that ID is updated.
      Returns:
      Return the ID assigned to the stored resource
    • getStoredResources

      Returns an unmodifiable list containing the current version of all resources stored in this provider
      Since:
      4.1.0
    • fireInterceptorsAndFilterAsNeeded

      protected static <T extends org.hl7.fhir.instance.model.api.IBaseResource> List<org.hl7.fhir.instance.model.api.IBaseResource> fireInterceptorsAndFilterAsNeeded(List<T> theResources, RequestDetails theRequestDetails)