Class AbstractOperation
- java.lang.Object
-
- com.ibm.fhir.server.spi.operation.AbstractOperation
-
- All Implemented Interfaces:
FHIROperation
- Direct Known Subclasses:
AbstractCqlOperation
,AbstractDataRequirementsOperation
,AbstractMeasureOperation
,AbstractTermOperation
,ApplyOperation
,ConvertOperation
,DocumentOperation
,EraseOperation
,EverythingOperation
,ExportOperation
,HealthcheckOperation
,ImportOperation
,MeasureSubmitDataOperation
,MemberMatchOperation
,ReindexOperation
,RetrieveIndexOperation
,StatusOperation
,ValidateOperation
public abstract class AbstractOperation extends Object implements FHIROperation
-
-
Field Summary
Fields Modifier and Type Field Description protected OperationDefinition
definition
-
Constructor Summary
Constructors Constructor Description AbstractOperation()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected FHIROperationException
buildExceptionWithIssue(String msg, IssueType issueType)
protected FHIROperationException
buildExceptionWithIssue(String msg, IssueType issueType, Throwable cause)
protected abstract OperationDefinition
buildOperationDefinition()
protected int
countParameters(Parameters parameters, String name)
protected abstract Parameters
doInvoke(FHIROperationContext operationContext, Class<? extends Resource> resourceType, String logicalId, String versionId, Parameters parameters, FHIRResourceHelpers resourceHelper)
This is the method that concrete subclasses must implement to perform the operation logic.protected OperationDefinition.Parameter
findOpDefParameter(List<OperationDefinition.Parameter> parameters, String name)
Find the operation definition parameter with the specified name.OperationDefinition
getDefinition()
String
getName()
protected Parameters.Parameter
getParameter(Parameters parameters, String name)
protected List<OperationDefinition.Parameter>
getParameterDefinitions(OperationParameterUse use)
protected List<Parameters.Parameter>
getParameters(Parameters parameters, String name)
protected List<String>
getResourceTypeNames()
Parameters
invoke(FHIROperationContext operationContext, Class<? extends Resource> resourceType, String logicalId, String versionId, Parameters parameters, FHIRResourceHelpers resourceHelper)
Validate the input parameters, invoke the operation, validate the output parameters, and return the result.protected boolean
isAbstractResourceTypesDisallowed()
Determines if the operation disallows abstract resource types, Resource and DomainResource.protected boolean
isAdditionalMethodAllowed(String method)
Determines if any methods (except GET and POST) are allowed for the operation.protected void
validateInputParameters(FHIROperationContext operationContext, Class<? extends Resource> resourceType, String logicalId, String versionId, Parameters parameters)
protected void
validateOperationContext(FHIROperationContext operationContext, Class<? extends Resource> resourceType, Parameters parameters)
protected void
validateOutputParameters(FHIROperationContext operationContext, Parameters result)
protected void
validateParameters(FHIROperationContext operationContext, Parameters parameters, OperationParameterUse use)
-
-
-
Field Detail
-
definition
protected final OperationDefinition definition
-
-
Method Detail
-
getDefinition
public OperationDefinition getDefinition()
- Specified by:
getDefinition
in interfaceFHIROperation
-
getName
public String getName()
- Specified by:
getName
in interfaceFHIROperation
-
invoke
public final Parameters invoke(FHIROperationContext operationContext, Class<? extends Resource> resourceType, String logicalId, String versionId, Parameters parameters, FHIRResourceHelpers resourceHelper) throws FHIROperationException
Validate the input parameters, invoke the operation, validate the output parameters, and return the result.- Specified by:
invoke
in interfaceFHIROperation
- Throws:
FHIROperationException
- if input or output parameters fail validation or an exception occurs
-
buildOperationDefinition
protected abstract OperationDefinition buildOperationDefinition()
-
countParameters
protected int countParameters(Parameters parameters, String name)
-
doInvoke
protected abstract Parameters doInvoke(FHIROperationContext operationContext, Class<? extends Resource> resourceType, String logicalId, String versionId, Parameters parameters, FHIRResourceHelpers resourceHelper) throws FHIROperationException
This is the method that concrete subclasses must implement to perform the operation logic.- Returns:
- the Parameters object to return or null if there is no response Parameters object to return
- Throws:
FHIROperationException
-
getParameter
protected Parameters.Parameter getParameter(Parameters parameters, String name)
-
getParameterDefinitions
protected List<OperationDefinition.Parameter> getParameterDefinitions(OperationParameterUse use)
-
getParameters
protected List<Parameters.Parameter> getParameters(Parameters parameters, String name)
-
validateInputParameters
protected void validateInputParameters(FHIROperationContext operationContext, Class<? extends Resource> resourceType, String logicalId, String versionId, Parameters parameters) throws FHIROperationException
- Throws:
FHIROperationException
-
validateOperationContext
protected void validateOperationContext(FHIROperationContext operationContext, Class<? extends Resource> resourceType, Parameters parameters) throws FHIROperationException
- Throws:
FHIROperationException
-
isAdditionalMethodAllowed
protected boolean isAdditionalMethodAllowed(String method)
Determines if any methods (except GET and POST) are allowed for the operation. This can be overridden by an operation to allow additional methods.- Returns:
- true or false
-
isAbstractResourceTypesDisallowed
protected boolean isAbstractResourceTypesDisallowed()
Determines if the operation disallows abstract resource types, Resource and DomainResource. TODO: Remove this method when Issue #2526 is implemented, at which time, abstract resource types will be disallowed for any operation.- Returns:
- true or false
-
validateOutputParameters
protected void validateOutputParameters(FHIROperationContext operationContext, Parameters result) throws FHIROperationException
- Throws:
FHIROperationException
-
validateParameters
protected void validateParameters(FHIROperationContext operationContext, Parameters parameters, OperationParameterUse use) throws FHIROperationException
- Throws:
FHIROperationException
-
findOpDefParameter
protected OperationDefinition.Parameter findOpDefParameter(List<OperationDefinition.Parameter> parameters, String name)
Find the operation definition parameter with the specified name.- Parameters:
parameters
- the list of parameters from the OperationDefinitionname
- the name of the parameter to find- Returns:
- the operation definition parameter with the specified name or null if not found
-
buildExceptionWithIssue
protected FHIROperationException buildExceptionWithIssue(String msg, IssueType issueType) throws FHIROperationException
- Throws:
FHIROperationException
-
buildExceptionWithIssue
protected FHIROperationException buildExceptionWithIssue(String msg, IssueType issueType, Throwable cause) throws FHIROperationException
- Throws:
FHIROperationException
-
-