Class FhirConsumer<AuditDatasetType extends FhirAuditDataset>
- java.lang.Object
-
- org.apache.camel.support.service.BaseService
-
- org.apache.camel.support.service.ServiceSupport
-
- org.apache.camel.support.DefaultConsumer
-
- org.openehealth.ipf.platform.camel.ihe.fhir.core.FhirConsumer<AuditDatasetType>
-
- All Implemented Interfaces:
AutoCloseable
,Predicate<RequestDetails>
,org.apache.camel.Consumer
,org.apache.camel.EndpointAware
,org.apache.camel.RouteAware
,org.apache.camel.Service
,org.apache.camel.ShutdownableService
,org.apache.camel.spi.RouteIdAware
,org.apache.camel.StatefulService
,org.apache.camel.SuspendableService
,RequestConsumer
public class FhirConsumer<AuditDatasetType extends FhirAuditDataset> extends org.apache.camel.support.DefaultConsumer implements org.apache.camel.SuspendableService, RequestConsumer
FHIR consumer, which is an implementation of aRequestConsumer
that handles requests by sending the request data and parameters into a Camel route and returning the result of the route processing.- Since:
- 3.1
- Author:
- Christian Ohr
-
-
Constructor Summary
Constructors Constructor Description FhirConsumer(FhirEndpoint<AuditDatasetType,? extends FhirComponent<AuditDatasetType>> endpoint, org.apache.camel.Processor processor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
doStart()
protected void
doStop()
protected IBundleProvider
getBundleProvider(Object payload, Map<String,Object> headers)
Returns theIBundleProvider
, providing the matching bundles.FhirEndpoint<AuditDatasetType,FhirComponent<AuditDatasetType>>
getEndpoint()
FhirContext
getFhirContext()
String
getName()
MethodOutcome
handleAction(Object payload, Map<String,Object> headers)
Handles a Create / Update / Validate / Delete action request.IBundleProvider
handleBundleProviderRequest(Object payload, Map<String,Object> headers)
Handles the request for a bundle provider, effectively constructing a list of resources.<R extends IBaseResource>
List<R>handleBundleRequest(Object payload, Map<String,Object> headers)
Handles the (search) request for a bundle, effectively being a list of resources.protected <T> T
handleInRoute(Object payload, Map<String,Object> headers, Class<T> resultClass)
Forwards the request to be handled into a Camel route<R extends IBaseResource>
RhandleResourceRequest(Object payload, Map<String,Object> headers, Class<R> resultClass)
This method can be called byIResourceProvider
objects to send the received (and potentially handled) request further down a Camel route.int
handleSizeRequest(Object payload, Map<String,Object> headers)
Optional method that request the result size of a bundle request.<T extends IBaseBundle>
ThandleTransactionRequest(Object payload, Map<String,Object> headers, Class<T> bundleClass)
Handles transaction requestsprotected org.apache.camel.Exchange
runRoute(Object payload, Map<String,Object> headers)
boolean
supportsLazyLoading()
boolean
test(RequestDetails requestDetails)
Returns true if this RequestConsumer can handle the provided FHIR payload-
Methods inherited from class org.apache.camel.support.DefaultConsumer
createUoW, doInit, doneUoW, getAsyncProcessor, getExceptionHandler, getProcessor, getRoute, getRouteId, handleException, handleException, setExceptionHandler, setRoute, setRouteId, toString
-
Methods inherited from class org.apache.camel.support.service.BaseService
build, doBuild, doFail, doLifecycleChange, doResume, doShutdown, doSuspend, fail, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
-
-
-
Constructor Detail
-
FhirConsumer
public FhirConsumer(FhirEndpoint<AuditDatasetType,? extends FhirComponent<AuditDatasetType>> endpoint, org.apache.camel.Processor processor)
-
-
Method Detail
-
test
public boolean test(RequestDetails requestDetails)
Description copied from interface:RequestConsumer
Returns true if this RequestConsumer can handle the provided FHIR payload- Specified by:
test
in interfacePredicate<AuditDatasetType extends FhirAuditDataset>
- Specified by:
test
in interfaceRequestConsumer
- Parameters:
requestDetails
- FHIR requestDetails- Returns:
- true if this RequestConsumer can handle the provided FHIR request, false otherwise
-
getName
public String getName()
- Specified by:
getName
in interfaceRequestConsumer
-
getFhirContext
public FhirContext getFhirContext()
- Specified by:
getFhirContext
in interfaceRequestConsumer
- Returns:
- the FhirContext used by this consumer
-
doStart
protected void doStart() throws Exception
- Overrides:
doStart
in classorg.apache.camel.support.DefaultConsumer
- Throws:
Exception
-
doStop
protected void doStop() throws Exception
- Overrides:
doStop
in classorg.apache.camel.support.DefaultConsumer
- Throws:
Exception
-
getEndpoint
public FhirEndpoint<AuditDatasetType,FhirComponent<AuditDatasetType>> getEndpoint()
- Specified by:
getEndpoint
in interfaceorg.apache.camel.EndpointAware
- Overrides:
getEndpoint
in classorg.apache.camel.support.DefaultConsumer
-
handleResourceRequest
public final <R extends IBaseResource> R handleResourceRequest(Object payload, Map<String,Object> headers, Class<R> resultClass)
This method can be called byIResourceProvider
objects to send the received (and potentially handled) request further down a Camel route.- Specified by:
handleResourceRequest
in interfaceRequestConsumer
- Type Parameters:
R
- Resource type being returned- Parameters:
payload
- FHIR request contentheaders
- headersresultClass
- class of the result resource- Returns:
- result of processing the FHIR request in Camel
-
handleBundleRequest
public <R extends IBaseResource> List<R> handleBundleRequest(Object payload, Map<String,Object> headers)
Description copied from interface:RequestConsumer
Handles the (search) request for a bundle, effectively being a list of resources.If
RequestConsumer.supportsLazyLoading()
returns true, the headers may containConstants.FHIR_FROM_INDEX
andConstants.FHIR_TO_INDEX
entries, indicating that only a part of the result is requested. Implementations must return only the requested entries.- Specified by:
handleBundleRequest
in interfaceRequestConsumer
- Type Parameters:
R
- resource type- Parameters:
payload
- request payloadheaders
- request parameters, e.g. search parameters- Returns:
- list of resources to be packaged into a bundle
-
handleBundleProviderRequest
public IBundleProvider handleBundleProviderRequest(Object payload, Map<String,Object> headers)
Description copied from interface:RequestConsumer
Handles the request for a bundle provider, effectively constructing a list of resources. The returned IBundleProvider takes over the responsibility to fetch the required subset of the result, usually by indirectly callingRequestConsumer.handleBundleRequest(Object, Map)
as required.- Specified by:
handleBundleProviderRequest
in interfaceRequestConsumer
- Parameters:
payload
- request payloadheaders
- request parameters, e.g. search parameters- Returns:
- a bundle provider
-
handleTransactionRequest
public <T extends IBaseBundle> T handleTransactionRequest(Object payload, Map<String,Object> headers, Class<T> bundleClass)
Description copied from interface:RequestConsumer
Handles transaction requests- Specified by:
handleTransactionRequest
in interfaceRequestConsumer
- Parameters:
payload
- request payloadheaders
- request parameters- Returns:
- transaction response bundle
-
handleAction
public MethodOutcome handleAction(Object payload, Map<String,Object> headers)
Description copied from interface:RequestConsumer
Handles a Create / Update / Validate / Delete action request.- Specified by:
handleAction
in interfaceRequestConsumer
- Parameters:
payload
- request payloadheaders
- request parameters, e.g. search parameters- Returns:
- result of the action execution
-
handleSizeRequest
public int handleSizeRequest(Object payload, Map<String,Object> headers)
Description copied from interface:RequestConsumer
Optional method that request the result size of a bundle request. Only used for lazy bundle providers. The headers contain aConstants.FHIR_REQUEST_SIZE_ONLY
entry flag. This method only needs to be implemented isRequestConsumer.supportsLazyLoading()
returns true.- Specified by:
handleSizeRequest
in interfaceRequestConsumer
- Parameters:
payload
- request payloadheaders
- request parameters- Returns:
- transaction response bundle
-
supportsLazyLoading
public boolean supportsLazyLoading()
- Specified by:
supportsLazyLoading
in interfaceRequestConsumer
- Returns:
- returns true indicating that lazy loading of search results is supported, false otherwise.
-
handleInRoute
protected <T> T handleInRoute(Object payload, Map<String,Object> headers, Class<T> resultClass)
Forwards the request to be handled into a Camel route- Parameters:
payload
- request payload, will become the Camel message bodyheaders
- request parameters, will be added to the Camel headersresultClass
- expected body type to be returned- Returns:
- request result, type-converted into the required result class
-
getBundleProvider
protected IBundleProvider getBundleProvider(Object payload, Map<String,Object> headers)
Returns theIBundleProvider
, providing the matching bundles. Depending onFhirEndpointConfiguration.isLazyLoadBundles()
, the bundle provider either eagerly fetches all matching bundles or fetches the requested subset on request.- Parameters:
payload
- request payloadheaders
- request headers- Returns:
- resulting bundle provider
-
-