Updated GenericClient to call MethodUtil updated signature
This commit is contained in:
parent
ad447126f2
commit
58185d199b
|
@ -69,6 +69,7 @@ import ca.uhn.fhir.model.primitive.UriDt;
|
|||
import ca.uhn.fhir.parser.DataFormatException;
|
||||
import ca.uhn.fhir.parser.IParser;
|
||||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||
import ca.uhn.fhir.rest.api.PatchTypeEnum;
|
||||
import ca.uhn.fhir.rest.api.PreferReturnEnum;
|
||||
import ca.uhn.fhir.rest.api.SortOrderEnum;
|
||||
import ca.uhn.fhir.rest.api.SortSpec;
|
||||
|
@ -2327,6 +2328,8 @@ public class GenericClient extends BaseClient implements IGenericClient {
|
|||
private IBaseResource myResource;
|
||||
private String myResourceBody;
|
||||
private String mySearchUrl;
|
||||
private PatchTypeEnum myPatchType;
|
||||
private String myPatchBody;
|
||||
|
||||
@Override
|
||||
public IPatchWithQueryTyped and(ICriterion<?> theCriterion) {
|
||||
|
@ -2356,22 +2359,23 @@ public class GenericClient extends BaseClient implements IGenericClient {
|
|||
if (getParamEncoding() != null) {
|
||||
myResourceBody = null;
|
||||
}
|
||||
|
||||
BaseHttpClientInvocation invocation;
|
||||
if (mySearchUrl != null) {
|
||||
invocation = MethodUtil.createPatchInvocation(myContext, myResource, myResourceBody, mySearchUrl);
|
||||
} else if (myCriterionList != null) {
|
||||
invocation = MethodUtil.createPatchInvocation(myContext, myResource, myResourceBody, myCriterionList.toParamList());
|
||||
} else {
|
||||
if (myId == null) {
|
||||
myId = myResource.getIdElement();
|
||||
}
|
||||
|
||||
if (myId == null || myId.hasIdPart() == false) {
|
||||
throw new InvalidRequestException("No ID supplied for resource to update, can not invoke server");
|
||||
}
|
||||
invocation = MethodUtil.createUpdateInvocation(myResource, myResourceBody, myId, myContext);
|
||||
|
||||
if (myPatchType == null) {
|
||||
throw new InvalidRequestException("No patch type supplied, cannot invoke server");
|
||||
}
|
||||
if (myPatchBody == null) {
|
||||
throw new InvalidRequestException("No patch body supplied, cannot invoke server");
|
||||
}
|
||||
|
||||
|
||||
if (myId == null) {
|
||||
myId = myResource.getIdElement();
|
||||
}
|
||||
|
||||
if (myId == null || myId.hasIdPart() == false) {
|
||||
throw new InvalidRequestException("No ID supplied for resource to update, can not invoke server");
|
||||
}
|
||||
BaseHttpClientInvocation invocation = MethodUtil.createPatchInvocation(myContext, myId, myPatchType, myPatchBody);
|
||||
|
||||
addPreferHeader(myPrefer, invocation);
|
||||
|
||||
|
@ -2435,6 +2439,18 @@ public class GenericClient extends BaseClient implements IGenericClient {
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPatchTyped patchType(PatchTypeEnum patchType) {
|
||||
myPatchType = patchType;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPatchTyped patchBody(String patchBody) {
|
||||
myPatchBody = patchBody;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class UpdateInternal extends BaseClientExecutable<IUpdateExecutable, MethodOutcome> implements IUpdate, IUpdateTyped, IUpdateExecutable, IUpdateWithQuery, IUpdateWithQueryTyped {
|
||||
|
|
|
@ -22,6 +22,8 @@ package ca.uhn.fhir.rest.gclient;
|
|||
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
|
||||
import ca.uhn.fhir.rest.api.PatchTypeEnum;
|
||||
|
||||
public interface IPatchTyped extends IPatchExecutable {
|
||||
|
||||
IPatchExecutable withId(IIdType theId);
|
||||
|
@ -42,5 +44,18 @@ public interface IPatchTyped extends IPatchExecutable {
|
|||
* @since HAPI 0.9 / FHIR DSTU 2
|
||||
*/
|
||||
IPatchWithQuery conditional();
|
||||
|
||||
/**
|
||||
* Specifies the format of the patch (either XML or JSON)
|
||||
* @param patchType
|
||||
*/
|
||||
IPatchTyped patchType(PatchTypeEnum patchType);
|
||||
|
||||
/**
|
||||
* The body of the patch document serialized in either XML or JSON which conforms to
|
||||
* http://jsonpatch.com/ or http://tools.ietf.org/html/rfc5261
|
||||
* @param patchBody
|
||||
*/
|
||||
IPatchTyped patchBody(String patchBody);
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue