Return correct bundle type on $everything operation
This commit is contained in:
parent
6f79f6c5e2
commit
3897167518
|
@ -27,6 +27,8 @@ import java.lang.annotation.Target;
|
|||
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.model.valueset.BundleTypeEnum;
|
||||
|
||||
/**
|
||||
* RESTful method annotation used for a method which provides FHIR "operations".
|
||||
*/
|
||||
|
@ -71,4 +73,11 @@ public @interface Operation {
|
|||
* response to this operation.
|
||||
*/
|
||||
OperationParam[] returnParameters() default {};
|
||||
|
||||
/**
|
||||
* If this operation returns a bundle, this parameter can be used to specify the
|
||||
* bundle type to set in the bundle.
|
||||
*/
|
||||
BundleTypeEnum bundleType() default BundleTypeEnum.COLLECTION;
|
||||
|
||||
}
|
||||
|
|
|
@ -73,11 +73,13 @@ public class OperationMethodBinding extends BaseResourceReturningMethodBinding {
|
|||
private final RestOperationTypeEnum myOtherOperatiopnType;
|
||||
private List<ReturnType> myReturnParams;
|
||||
private final ReturnTypeEnum myReturnType;
|
||||
private BundleTypeEnum myBundleType;
|
||||
|
||||
protected OperationMethodBinding(Class<?> theReturnResourceType, Class<? extends IBaseResource> theReturnTypeFromRp, Method theMethod, FhirContext theContext, Object theProvider, boolean theIdempotent, String theOperationName, Class<? extends IBaseResource> theOperationType,
|
||||
OperationParam[] theReturnParams) {
|
||||
OperationParam[] theReturnParams, BundleTypeEnum theBundleType) {
|
||||
super(theReturnResourceType, theMethod, theContext, theProvider);
|
||||
|
||||
myBundleType = theBundleType;
|
||||
myIdempotent = theIdempotent;
|
||||
myIdParamIndex = MethodUtil.findIdParameterIndex(theMethod, getContext());
|
||||
if (myIdParamIndex != null) {
|
||||
|
@ -168,7 +170,7 @@ public class OperationMethodBinding extends BaseResourceReturningMethodBinding {
|
|||
}
|
||||
|
||||
public OperationMethodBinding(Class<?> theReturnResourceType, Class<? extends IBaseResource> theReturnTypeFromRp, Method theMethod, FhirContext theContext, Object theProvider, Operation theAnnotation) {
|
||||
this(theReturnResourceType, theReturnTypeFromRp, theMethod, theContext, theProvider, theAnnotation.idempotent(), theAnnotation.name(), theAnnotation.type(), theAnnotation.returnParameters());
|
||||
this(theReturnResourceType, theReturnTypeFromRp, theMethod, theContext, theProvider, theAnnotation.idempotent(), theAnnotation.name(), theAnnotation.type(), theAnnotation.returnParameters(), theAnnotation.bundleType());
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
|
@ -184,7 +186,7 @@ public class OperationMethodBinding extends BaseResourceReturningMethodBinding {
|
|||
|
||||
@Override
|
||||
protected BundleTypeEnum getResponseBundleType() {
|
||||
return BundleTypeEnum.COLLECTION;
|
||||
return myBundleType;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -28,21 +28,20 @@ import org.hl7.fhir.instance.model.api.IBaseParameters;
|
|||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.valueset.BundleTypeEnum;
|
||||
import ca.uhn.fhir.rest.annotation.OperationParam;
|
||||
import ca.uhn.fhir.rest.annotation.Validate;
|
||||
import ca.uhn.fhir.rest.client.BaseHttpClientInvocation;
|
||||
import ca.uhn.fhir.rest.param.ResourceParameter;
|
||||
import ca.uhn.fhir.rest.server.Constants;
|
||||
import ca.uhn.fhir.rest.server.EncodingEnum;
|
||||
import ca.uhn.fhir.rest.server.IRestfulServer;
|
||||
import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException;
|
||||
import ca.uhn.fhir.util.ParametersUtil;
|
||||
|
||||
public class ValidateMethodBindingDstu2 extends OperationMethodBinding {
|
||||
|
||||
public ValidateMethodBindingDstu2(Class<?> theReturnResourceType, Class<? extends IBaseResource> theReturnTypeFromRp, Method theMethod, FhirContext theContext, Object theProvider,
|
||||
Validate theAnnotation) {
|
||||
super(theReturnResourceType, theReturnTypeFromRp, theMethod, theContext, theProvider, true, Constants.EXTOP_VALIDATE, theAnnotation.type(), new OperationParam[0]);
|
||||
super(theReturnResourceType, theReturnTypeFromRp, theMethod, theContext, theProvider, true, Constants.EXTOP_VALIDATE, theAnnotation.type(), new OperationParam[0], BundleTypeEnum.COLLECTION);
|
||||
|
||||
List<IParameter> newParams = new ArrayList<IParameter>();
|
||||
int idx = 0;
|
||||
|
|
|
@ -23,6 +23,7 @@ package ca.uhn.fhir.jpa.provider;
|
|||
import ca.uhn.fhir.jpa.dao.IFhirResourceDaoEncounter;
|
||||
import ca.uhn.fhir.model.api.annotation.Description;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Encounter;
|
||||
import ca.uhn.fhir.model.valueset.BundleTypeEnum;
|
||||
import ca.uhn.fhir.rest.annotation.IdParam;
|
||||
import ca.uhn.fhir.rest.annotation.Operation;
|
||||
import ca.uhn.fhir.rest.annotation.OperationParam;
|
||||
|
@ -37,7 +38,7 @@ public class BaseJpaResourceProviderEncounterDstu2 extends JpaResourceProviderDs
|
|||
* Encounter/123/$everything
|
||||
*/
|
||||
//@formatter:off
|
||||
@Operation(name = "everything", idempotent = true)
|
||||
@Operation(name = "everything", idempotent = true, bundleType=BundleTypeEnum.SEARCHSET)
|
||||
public ca.uhn.fhir.rest.server.IBundleProvider EncounterInstanceEverything(
|
||||
|
||||
javax.servlet.http.HttpServletRequest theServletRequest,
|
||||
|
@ -69,7 +70,7 @@ public class BaseJpaResourceProviderEncounterDstu2 extends JpaResourceProviderDs
|
|||
* /Encounter/$everything
|
||||
*/
|
||||
//@formatter:off
|
||||
@Operation(name = "everything", idempotent = true)
|
||||
@Operation(name = "everything", idempotent = true, bundleType=BundleTypeEnum.SEARCHSET)
|
||||
public ca.uhn.fhir.rest.server.IBundleProvider EncounterTypeEverything(
|
||||
|
||||
javax.servlet.http.HttpServletRequest theServletRequest,
|
||||
|
|
|
@ -28,6 +28,7 @@ import ca.uhn.fhir.jpa.dao.IFhirResourceDaoPatient;
|
|||
import ca.uhn.fhir.model.api.annotation.Description;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.model.primitive.StringDt;
|
||||
import ca.uhn.fhir.model.valueset.BundleTypeEnum;
|
||||
import ca.uhn.fhir.rest.annotation.IdParam;
|
||||
import ca.uhn.fhir.rest.annotation.Operation;
|
||||
import ca.uhn.fhir.rest.annotation.OperationParam;
|
||||
|
@ -47,7 +48,7 @@ public class BaseJpaResourceProviderPatientDstu2 extends JpaResourceProviderDstu
|
|||
* @param theRequestDetails
|
||||
*/
|
||||
//@formatter:off
|
||||
@Operation(name = "everything", idempotent = true)
|
||||
@Operation(name = "everything", idempotent = true, bundleType=BundleTypeEnum.SEARCHSET)
|
||||
public ca.uhn.fhir.rest.server.IBundleProvider patientInstanceEverything(
|
||||
|
||||
javax.servlet.http.HttpServletRequest theServletRequest,
|
||||
|
@ -91,7 +92,7 @@ public class BaseJpaResourceProviderPatientDstu2 extends JpaResourceProviderDstu
|
|||
* @param theRequestDetails
|
||||
*/
|
||||
//@formatter:off
|
||||
@Operation(name = "everything", idempotent = true)
|
||||
@Operation(name = "everything", idempotent = true, bundleType=BundleTypeEnum.SEARCHSET)
|
||||
public ca.uhn.fhir.rest.server.IBundleProvider patientTypeEverything(
|
||||
|
||||
javax.servlet.http.HttpServletRequest theServletRequest,
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.hl7.fhir.dstu3.model.UnsignedIntType;
|
|||
|
||||
import ca.uhn.fhir.jpa.dao.IFhirResourceDaoEncounter;
|
||||
import ca.uhn.fhir.model.api.annotation.Description;
|
||||
import ca.uhn.fhir.model.valueset.BundleTypeEnum;
|
||||
import ca.uhn.fhir.rest.annotation.IdParam;
|
||||
import ca.uhn.fhir.rest.annotation.Operation;
|
||||
import ca.uhn.fhir.rest.annotation.OperationParam;
|
||||
|
@ -40,7 +41,7 @@ public class BaseJpaResourceProviderEncounterDstu3 extends JpaResourceProviderDs
|
|||
* Encounter/123/$everything
|
||||
*/
|
||||
//@formatter:off
|
||||
@Operation(name = "everything", idempotent = true)
|
||||
@Operation(name = "everything", idempotent = true, bundleType=BundleTypeEnum.SEARCHSET)
|
||||
public ca.uhn.fhir.rest.server.IBundleProvider EncounterInstanceEverything(
|
||||
|
||||
javax.servlet.http.HttpServletRequest theServletRequest,
|
||||
|
@ -72,7 +73,7 @@ public class BaseJpaResourceProviderEncounterDstu3 extends JpaResourceProviderDs
|
|||
* /Encounter/$everything
|
||||
*/
|
||||
//@formatter:off
|
||||
@Operation(name = "everything", idempotent = true)
|
||||
@Operation(name = "everything", idempotent = true, bundleType=BundleTypeEnum.SEARCHSET)
|
||||
public ca.uhn.fhir.rest.server.IBundleProvider EncounterTypeEverything(
|
||||
|
||||
javax.servlet.http.HttpServletRequest theServletRequest,
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.hl7.fhir.dstu3.model.UnsignedIntType;
|
|||
|
||||
import ca.uhn.fhir.jpa.dao.IFhirResourceDaoPatient;
|
||||
import ca.uhn.fhir.model.api.annotation.Description;
|
||||
import ca.uhn.fhir.model.valueset.BundleTypeEnum;
|
||||
import ca.uhn.fhir.rest.annotation.IdParam;
|
||||
import ca.uhn.fhir.rest.annotation.Operation;
|
||||
import ca.uhn.fhir.rest.annotation.OperationParam;
|
||||
|
@ -50,7 +51,7 @@ public class BaseJpaResourceProviderPatientDstu3 extends JpaResourceProviderDstu
|
|||
* @param theRequestDetails
|
||||
*/
|
||||
//@formatter:off
|
||||
@Operation(name = "everything", idempotent = true)
|
||||
@Operation(name = "everything", idempotent = true, bundleType=BundleTypeEnum.SEARCHSET)
|
||||
public ca.uhn.fhir.rest.server.IBundleProvider patientInstanceEverything(
|
||||
|
||||
javax.servlet.http.HttpServletRequest theServletRequest,
|
||||
|
@ -94,7 +95,7 @@ public class BaseJpaResourceProviderPatientDstu3 extends JpaResourceProviderDstu
|
|||
* @param theRequestDetails
|
||||
*/
|
||||
//@formatter:off
|
||||
@Operation(name = "everything", idempotent = true)
|
||||
@Operation(name = "everything", idempotent = true, bundleType=BundleTypeEnum.SEARCHSET)
|
||||
public ca.uhn.fhir.rest.server.IBundleProvider patientTypeEverything(
|
||||
|
||||
javax.servlet.http.HttpServletRequest theServletRequest,
|
||||
|
|
|
@ -165,7 +165,7 @@ public class SystemProviderDstu2Test extends BaseJpaDstu2Test {
|
|||
assertEquals(200, http.getStatusLine().getStatusCode());
|
||||
|
||||
Bundle responseBundle = ourCtx.newXmlParser().parseResource(Bundle.class, response);
|
||||
assertEquals(BundleTypeEnum.COLLECTION, responseBundle.getTypeElement().getValueAsEnum());
|
||||
assertEquals(BundleTypeEnum.SEARCH_RESULTS, responseBundle.getTypeElement().getValueAsEnum());
|
||||
|
||||
} finally {
|
||||
http.close();
|
||||
|
|
|
@ -1121,6 +1121,8 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
|
|||
|
||||
Parameters output = ourClient.operation().onType(Patient.class).named("everything").withNoParameters(Parameters.class).execute();
|
||||
Bundle b = (Bundle) output.getParameter().get(0).getResource();
|
||||
|
||||
assertEquals(BundleType.SEARCHSET, b.getType());
|
||||
List<IIdType> ids = toUnqualifiedVersionlessIds(b);
|
||||
|
||||
assertThat(ids, containsInAnyOrder(o1Id, o2Id, p1Id, p2Id, c1Id, c2Id));
|
||||
|
|
|
@ -233,7 +233,7 @@ public class SystemProviderDstu3Test extends BaseJpaDstu3Test {
|
|||
assertEquals(200, http.getStatusLine().getStatusCode());
|
||||
|
||||
Bundle responseBundle = ourCtx.newXmlParser().parseResource(Bundle.class, response);
|
||||
assertEquals(BundleType.COLLECTION, responseBundle.getTypeElement().getValue());
|
||||
assertEquals(BundleType.SEARCHSET, responseBundle.getTypeElement().getValue());
|
||||
|
||||
} finally {
|
||||
http.close();
|
||||
|
|
|
@ -202,6 +202,10 @@
|
|||
page the most recent 20000 entries. Now it has
|
||||
no limit.
|
||||
</action>
|
||||
<action type="fix">
|
||||
JPA server returned the wrong Bundle.type value (COLLECTION, should be SEARCHSET)
|
||||
for $everything operation responses. Thanks to Sonali Somase for reporting!
|
||||
</action>
|
||||
</release>
|
||||
<release version="1.4" date="2016-02-04">
|
||||
<action type="add">
|
||||
|
|
Loading…
Reference in New Issue