Package ca.uhn.fhir.rest.server.provider
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 Summary
Fields Modifier and Type Field Description protected Map<String,LinkedList<T>>myIdToHistoryprotected Map<String,TreeMap<Long,T>>myIdToVersionToResourceMapprotected LinkedList<T>myTypeHistory
-
Constructor Summary
Constructors Constructor Description HashMapResourceProvider(ca.uhn.fhir.context.FhirContext theFhirContext, Class<T> theResourceType)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clear all data held in this resource providervoidclearCounts()Clear the counts used bygetCountRead()and other count methodsca.uhn.fhir.rest.api.MethodOutcomecreate(T theResource)ca.uhn.fhir.rest.api.MethodOutcomedelete(org.hl7.fhir.instance.model.api.IIdType theId)longgetCountCreate()This method returns a simple operation count.longgetCountDelete()This method returns a simple operation count.longgetCountRead()This method returns a simple operation count.longgetCountSearch()This method returns a simple operation count.longgetCountUpdate()This method returns a simple operation count.ca.uhn.fhir.context.FhirContextgetFhirContext()Class<T>getResourceType()Returns the type of resource returned by this providerList<T>getStoredResources()Returns an unmodifiable list containing the current version of all resources stored in this providerList<T>historyInstance(org.hl7.fhir.instance.model.api.IIdType theId, RequestDetails theRequestDetails)List<T>historyType()Tread(org.hl7.fhir.instance.model.api.IIdType theId, RequestDetails theRequestDetails)List<T>searchAll(RequestDetails theRequestDetails)List<T>searchById(ca.uhn.fhir.rest.param.TokenAndListParam theIds, RequestDetails theRequestDetails)org.hl7.fhir.instance.model.api.IIdTypestore(T theResource)This is a utility method that can be used to store a resource without having to use the outside API.ca.uhn.fhir.rest.api.MethodOutcomeupdate(T theResource, String theConditional)
-
-
-
Field Detail
-
myIdToVersionToResourceMap
protected Map<String,TreeMap<Long,T extends org.hl7.fhir.instance.model.api.IBaseResource>> myIdToVersionToResourceMap
-
myIdToHistory
protected Map<String,LinkedList<T extends org.hl7.fhir.instance.model.api.IBaseResource>> myIdToHistory
-
myTypeHistory
protected LinkedList<T extends org.hl7.fhir.instance.model.api.IBaseResource> myTypeHistory
-
-
Constructor Detail
-
HashMapResourceProvider
public HashMapResourceProvider(ca.uhn.fhir.context.FhirContext theFhirContext, Class<T> theResourceType)
Constructor- Parameters:
theFhirContext- The FHIR contexttheResourceType- The resource type to support
-
-
Method Detail
-
clear
public void clear()
Clear all data held in this resource provider
-
clearCounts
public void clearCounts()
Clear the counts used bygetCountRead()and other count methods
-
delete
public ca.uhn.fhir.rest.api.MethodOutcome delete(org.hl7.fhir.instance.model.api.IIdType theId)
-
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:IResourceProviderReturns the type of resource returned by this provider- Specified by:
getResourceTypein interfaceIResourceProvider- Returns:
- Returns the type of resource returned by this provider
-
historyInstance
public List<T> 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<T> searchAll(RequestDetails theRequestDetails)
-
searchById
public List<T> searchById(ca.uhn.fhir.rest.param.TokenAndListParam theIds, RequestDetails theRequestDetails)
-
update
public ca.uhn.fhir.rest.api.MethodOutcome update(T theResource, String theConditional)
- 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
public List<T> getStoredResources()
Returns an unmodifiable list containing the current version of all resources stored in this provider- Since:
- 4.1.0
-
-