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>
,Consumer
,EndpointAware
,HealthCheckAware
,RouteAware
,Service
,ShutdownableService
,RouteIdAware
,StatefulService
,SuspendableService
,RequestConsumer
public class FhirConsumer<AuditDatasetType extends FhirAuditDataset>
extends org.apache.camel.support.DefaultConsumer
implements SuspendableService, RequestConsumer
FHIR consumer, which is an implementation of a
RequestConsumer
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
-
Field Summary
Fields inherited from class org.apache.camel.support.service.BaseService
BUILT, FAILED, INITIALIZED, INITIALIZING, lock, NEW, SHUTDOWN, SHUTTING_DOWN, STARTED, STARTING, status, STOPPED, STOPPING, SUSPENDED, SUSPENDING
-
Constructor Summary
ConstructorDescriptionFhirConsumer
(FhirEndpoint<AuditDatasetType, ? extends FhirComponent<AuditDatasetType>> endpoint, Processor processor) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
doStart()
protected void
doStop()
protected IBundleProvider
getBundleProvider
(Object payload, Map<String, Object> headers) Returns theIBundleProvider
, providing the matching bundles.getName()
handleAction
(Object payload, Map<String, Object> headers) Handles a Create / Update / Validate / Delete action request.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
Forwards the request to be handled into a Camel routefinal <R extends IBaseResource>
RThis 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>
THandles transaction requestsprotected Exchange
boolean
boolean
test
(RequestDetails requestDetails) Returns true if this RequestConsumer can handle the provided FHIR payloadMethods inherited from class org.apache.camel.support.DefaultConsumer
createExchange, createUoW, defaultConsumerCallback, doBuild, doInit, doneUoW, doShutdown, getAsyncProcessor, getExceptionHandler, getHealthCheck, getProcessor, getRoute, getRouteId, handleException, handleException, handleException, releaseExchange, setExceptionHandler, setHealthCheck, setRoute, setRouteId, toString
Methods inherited from class org.apache.camel.support.service.BaseService
build, doFail, doLifecycleChange, doResume, 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
Methods inherited from interface org.apache.camel.ShutdownableService
shutdown
Methods inherited from interface org.apache.camel.StatefulService
getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspending
Methods inherited from interface org.apache.camel.SuspendableService
isSuspended, resume, suspend
-
Constructor Details
-
FhirConsumer
public FhirConsumer(FhirEndpoint<AuditDatasetType, ? extends FhirComponent<AuditDatasetType>> endpoint, Processor processor)
-
-
Method Details
-
test
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
- Specified by:
getName
in interfaceRequestConsumer
-
getFhirContext
- Specified by:
getFhirContext
in interfaceRequestConsumer
- Returns:
- the FhirContext used by this consumer
-
doStart
- Overrides:
doStart
in classorg.apache.camel.support.DefaultConsumer
- Throws:
Exception
-
doStop
- Overrides:
doStop
in classorg.apache.camel.support.DefaultConsumer
- Throws:
Exception
-
getEndpoint
- Specified by:
getEndpoint
in interfaceEndpointAware
- 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
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
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
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
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
-
runRoute
-
getBundleProvider
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
-