Fix build

This commit is contained in:
jamesagnew 2016-01-01 23:18:44 -05:00
parent 6b96fefeb7
commit c8365ab566
6 changed files with 202 additions and 110 deletions

View File

@ -59,7 +59,6 @@ import ca.uhn.fhir.context.IRuntimeDatatypeDefinition;
import ca.uhn.fhir.context.RuntimeResourceDefinition;
import ca.uhn.fhir.model.api.Bundle;
import ca.uhn.fhir.model.api.IQueryParameterType;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.api.Include;
import ca.uhn.fhir.model.api.TagList;
import ca.uhn.fhir.model.base.resource.BaseConformance;
@ -194,7 +193,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
}
@Override
public MethodOutcome create(IResource theResource) {
public MethodOutcome create(IBaseResource theResource) {
BaseHttpClientInvocation invocation = MethodUtil.createCreateInvocation(theResource, myContext);
if (isKeepResponses()) {
myLastRequest = invocation.asHttpRequest(getServerBase(), createExtraParams(), getEncoding(), isPrettyPrint());
@ -216,7 +215,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
}
@Override
public MethodOutcome delete(final Class<? extends IResource> theType, IdDt theId) {
public MethodOutcome delete(final Class<? extends IBaseResource> theType, IdDt theId) {
HttpDeleteClientInvocation invocation = DeleteMethodBinding.createDeleteInvocation(theId.withResourceType(toResourceName(theType)));
if (isKeepResponses()) {
myLastRequest = invocation.asHttpRequest(getServerBase(), createExtraParams(), getEncoding(), isPrettyPrint());
@ -229,7 +228,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
}
@Override
public MethodOutcome delete(Class<? extends IResource> theType, String theId) {
public MethodOutcome delete(Class<? extends IBaseResource> theType, String theId) {
return delete(theType, new IdDt(theId));
}
@ -328,7 +327,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
}
@Override
public <T extends IResource> Bundle history(final Class<T> theType, IdDt theIdDt, DateTimeDt theSince, Integer theLimit) {
public <T extends IBaseResource> Bundle history(final Class<T> theType, IdDt theIdDt, DateTimeDt theSince, Integer theLimit) {
String resourceName = theType != null ? toResourceName(theType) : null;
String id = theIdDt != null && theIdDt.isEmpty() == false ? theIdDt.getValue() : null;
HttpGetClientInvocation invocation = HistoryMethodBinding.createHistoryInvocation(resourceName, id, theSince, theLimit);
@ -343,7 +342,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
}
@Override
public <T extends IResource> Bundle history(Class<T> theType, String theId, DateTimeDt theSince, Integer theLimit) {
public <T extends IBaseResource> Bundle history(Class<T> theType, String theId, DateTimeDt theSince, Integer theLimit) {
return history(theType, new IdDt(theId), theSince, theLimit);
}
@ -517,7 +516,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
}
@Override
public MethodOutcome update(IdDt theIdDt, IResource theResource) {
public MethodOutcome update(IdDt theIdDt, IBaseResource theResource) {
BaseHttpClientInvocation invocation = MethodUtil.createUpdateInvocation(theResource, null, theIdDt, myContext);
if (isKeepResponses()) {
myLastRequest = invocation.asHttpRequest(getServerBase(), createExtraParams(), getEncoding(), isPrettyPrint());
@ -532,7 +531,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
}
@Override
public MethodOutcome update(String theId, IResource theResource) {
public MethodOutcome update(String theId, IBaseResource theResource) {
return update(new IdDt(theId), theResource);
}
@ -542,7 +541,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
}
@Override
public MethodOutcome validate(IResource theResource) {
public MethodOutcome validate(IBaseResource theResource) {
BaseHttpClientInvocation invocation;
if (myContext.getVersion().getVersion().equals(FhirVersionEnum.DSTU1)) {
invocation = ValidateMethodBindingDstu1.createValidateInvocation(theResource, null, myContext);
@ -573,7 +572,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
/* also deprecated in interface */
@Deprecated
@Override
public <T extends IResource> T vread(final Class<T> theType, IdDt theId, IdDt theVersionId) {
public <T extends IBaseResource> T vread(final Class<T> theType, IdDt theId, IdDt theVersionId) {
return vread(theType, theId.withVersion(theVersionId.getIdPart()));
}
@ -1010,27 +1009,27 @@ public class GenericClient extends BaseClient implements IGenericClient {
}
@Override
public IGetTags forResource(Class<? extends IResource> theClass) {
public IGetTags forResource(Class<? extends IBaseResource> theClass) {
setResourceClass(theClass);
return this;
}
@Override
public IGetTags forResource(Class<? extends IResource> theClass, String theId) {
public IGetTags forResource(Class<? extends IBaseResource> theClass, String theId) {
setResourceClass(theClass);
myId = theId;
return this;
}
@Override
public IGetTags forResource(Class<? extends IResource> theClass, String theId, String theVersionId) {
public IGetTags forResource(Class<? extends IBaseResource> theClass, String theId, String theVersionId) {
setResourceClass(theClass);
myId = theId;
myVersionId = theVersionId;
return this;
}
private void setResourceClass(Class<? extends IResource> theClass) {
private void setResourceClass(Class<? extends IBaseResource> theClass) {
if (theClass != null) {
myResourceName = myContext.getResourceDefinition(theClass).getName();
} else {
@ -1694,9 +1693,9 @@ public class GenericClient extends BaseClient implements IGenericClient {
private final class ResourceListResponseHandler implements IClientResponseHandler<List<IBaseResource>> {
private Class<? extends IResource> myType;
private Class<? extends IBaseResource> myType;
public ResourceListResponseHandler(Class<? extends IResource> theType) {
public ResourceListResponseHandler(Class<? extends IBaseResource> theType) {
myType = theType;
}

View File

@ -75,7 +75,7 @@ public interface IGenericClient extends IRestfulClient {
*
*/
@Deprecated
MethodOutcome create(IResource theResource);
MethodOutcome create(IBaseResource theResource);
/**
* Fluent method for the "delete" operation, which performs a logical delete on a server resource
@ -93,7 +93,7 @@ public interface IGenericClient extends IRestfulClient {
* @deprecated Use {@link #delete()} instead
*/
@Deprecated
MethodOutcome delete(Class<? extends IResource> theType, IdDt theId);
MethodOutcome delete(Class<? extends IBaseResource> theType, IdDt theId);
/**
* Implementation of the "delete instance" method.
@ -106,7 +106,7 @@ public interface IGenericClient extends IRestfulClient {
* @deprecated Use {@link #delete()} instead
*/
@Deprecated
MethodOutcome delete(Class<? extends IResource> theType, String theId);
MethodOutcome delete(Class<? extends IBaseResource> theType, String theId);
/**
* Retrieves the server's conformance statement
@ -150,7 +150,7 @@ public interface IGenericClient extends IRestfulClient {
* @deprecated As of 0.9, use the fluent {@link #history()} method instead
*/
@Deprecated
<T extends IResource> Bundle history(Class<T> theType, IdDt theId, DateTimeDt theSince, Integer theLimit);
<T extends IBaseResource> Bundle history(Class<T> theType, IdDt theId, DateTimeDt theSince, Integer theLimit);
/**
* Implementation of the "history instance" method.
@ -169,7 +169,7 @@ public interface IGenericClient extends IRestfulClient {
* @deprecated As of 0.9, use the fluent {@link #history()} method instead
*/
@Deprecated
<T extends IResource> Bundle history(Class<T> theType, String theId, DateTimeDt theSince, Integer theLimit);
<T extends IBaseResource> Bundle history(Class<T> theType, String theId, DateTimeDt theSince, Integer theLimit);
/**
* Loads the previous/next bundle of resources from a paged set, using the link specified in the "link type=next" tag within the atom bundle.
@ -327,7 +327,7 @@ public interface IGenericClient extends IRestfulClient {
* The new resource body
* @return An outcome containing the results and possibly the new version ID
*/
MethodOutcome update(IdDt theId, IResource theResource);
MethodOutcome update(IdDt theId, IBaseResource theResource);
/**
* Implementation of the "instance update" method.
@ -338,7 +338,7 @@ public interface IGenericClient extends IRestfulClient {
* The new resource body
* @return An outcome containing the results and possibly the new version ID
*/
MethodOutcome update(String theId, IResource theResource);
MethodOutcome update(String theId, IBaseResource theResource);
/**
* Validate a resource
@ -352,7 +352,7 @@ public interface IGenericClient extends IRestfulClient {
* The resource to validate
* @return An outcome containing any validation issues
*/
MethodOutcome validate(IResource theResource);
MethodOutcome validate(IBaseResource theResource);
/**
* Implementation of the "instance vread" method. Note that this method expects <code>theId</code> to contain a resource ID as well as a version ID, and will fail if it does not.
@ -382,7 +382,7 @@ public interface IGenericClient extends IRestfulClient {
* @deprecated Deprecated in 0.7 - IdDt can contain an ID and a version, so this class doesn't make a lot of sense
*/
@Deprecated
<T extends IResource> T vread(Class<T> theType, IdDt theId, IdDt theVersionId);
<T extends IBaseResource> T vread(Class<T> theType, IdDt theId, IdDt theVersionId);
/**
* Implementation of the "instance vread" method.

View File

@ -1,34 +1,15 @@
package ca.uhn.fhir.rest.gclient;
/*
* #%L
* HAPI FHIR - Core Library
* %%
* Copyright (C) 2014 - 2015 University Health Network
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import org.hl7.fhir.instance.model.api.IBaseResource;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.api.TagList;
public interface IGetTags extends IClientExecutable<IGetTags, TagList> {
IGetTags forResource(Class<? extends IResource> theClass);
IGetTags forResource(Class<? extends IBaseResource> theClass);
IGetTags forResource(Class<? extends IResource> theClass, String theId);
IGetTags forResource(Class<? extends IBaseResource> theClass, String theId);
IGetTags forResource(Class<? extends IResource> theClass, String theId, String theVersionId);
IGetTags forResource(Class<? extends IBaseResource> theClass, String theId, String theVersionId);
}

View File

@ -24,6 +24,8 @@ import java.lang.reflect.Method;
import java.util.Collections;
import java.util.Set;
import org.hl7.fhir.instance.model.api.IBaseResource;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.primitive.IdDt;
@ -74,7 +76,7 @@ public class ValidateMethodBindingDstu1 extends BaseOutcomeReturningMethodBindin
return retVal;
}
public static HttpPostClientInvocation createValidateInvocation(IResource theResource, IdDt theId, FhirContext theContext) {
public static HttpPostClientInvocation createValidateInvocation(IBaseResource theResource, IdDt theId, FhirContext theContext) {
StringBuilder urlExtension = new StringBuilder();
urlExtension.append(theContext.getResourceDefinition(theResource).getName());
urlExtension.append('/');

View File

@ -28,6 +28,11 @@ import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.HttpEntityWrapper;
import org.hl7.fhir.dstu21.model.Conformance.ConformanceRestComponent;
import org.hl7.fhir.dstu21.model.Conformance.ConformanceRestResourceComponent;
import org.hl7.fhir.dstu21.model.DecimalType;
import org.hl7.fhir.dstu21.model.Extension;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.ModelMap;
import org.thymeleaf.TemplateEngine;
@ -66,7 +71,7 @@ public class BaseController {
super();
}
protected IResource addCommonParams(HttpServletRequest theServletRequest, final HomeRequest theRequest, final ModelMap theModel) {
protected IBaseResource addCommonParams(HttpServletRequest theServletRequest, final HomeRequest theRequest, final ModelMap theModel) {
if (myConfig.getDebugTemplatesMode()) {
myTemplateEngine.getCacheManager().clearAllCaches();
}
@ -290,14 +295,14 @@ public class BaseController {
return returnsResource;
}
private IResource loadAndAddConf(HttpServletRequest theServletRequest, final HomeRequest theRequest, final ModelMap theModel) {
private IBaseResource loadAndAddConf(HttpServletRequest theServletRequest, final HomeRequest theRequest, final ModelMap theModel) {
switch (theRequest.getFhirVersion(myConfig)) {
case DEV:
return loadAndAddConfDstu2(theServletRequest, theRequest, theModel);
case DSTU1:
return loadAndAddConfDstu1(theServletRequest, theRequest, theModel);
case DSTU2:
return loadAndAddConfDstu2(theServletRequest, theRequest, theModel);
case DSTU2_1:
return loadAndAddConfDstu21(theServletRequest, theRequest, theModel);
}
throw new IllegalStateException("Unknown version: " + theRequest.getFhirVersion(myConfig));
}
@ -422,6 +427,65 @@ public class BaseController {
return conformance;
}
private IBaseResource loadAndAddConfDstu21(HttpServletRequest theServletRequest, final HomeRequest theRequest, final ModelMap theModel) {
CaptureInterceptor interceptor = new CaptureInterceptor();
GenericClient client = theRequest.newClient(theServletRequest, getContext(theRequest), myConfig, interceptor);
org.hl7.fhir.dstu21.model.Conformance conformance;
try {
conformance = (org.hl7.fhir.dstu21.model.Conformance) client.conformance();
} catch (Exception e) {
ourLog.warn("Failed to load conformance statement", e);
theModel.put("errorMsg", "Failed to load conformance statement, error was: " + e.toString());
conformance = new org.hl7.fhir.dstu21.model.Conformance();
}
theModel.put("jsonEncodedConf", getContext(theRequest).newJsonParser().encodeResourceToString(conformance));
Map<String, Number> resourceCounts = new HashMap<String, Number>();
long total = 0;
for (ConformanceRestComponent nextRest : conformance.getRest()) {
for (ConformanceRestResourceComponent nextResource : nextRest.getResource()) {
List<Extension> exts = nextResource.getExtensionsByUrl(RESOURCE_COUNT_EXT_URL);
if (exts != null && exts.size() > 0) {
Number nextCount = ((DecimalType) (exts.get(0).getValue())).getValueAsNumber();
resourceCounts.put(nextResource.getTypeElement().getValue(), nextCount);
total += nextCount.longValue();
}
}
}
theModel.put("resourceCounts", resourceCounts);
if (total > 0) {
for (ConformanceRestComponent nextRest : conformance.getRest()) {
Collections.sort(nextRest.getResource(), new Comparator<ConformanceRestResourceComponent>() {
@Override
public int compare(ConformanceRestResourceComponent theO1, ConformanceRestResourceComponent theO2) {
DecimalType count1 = new DecimalType();
List<Extension> count1exts = theO1.getExtensionsByUrl(RESOURCE_COUNT_EXT_URL);
if (count1exts != null && count1exts.size() > 0) {
count1 = (DecimalType) count1exts.get(0).getValue();
}
DecimalType count2 = new DecimalType();
List<Extension> count2exts = theO2.getExtensionsByUrl(RESOURCE_COUNT_EXT_URL);
if (count2exts != null && count2exts.size() > 0) {
count2 = (DecimalType) count2exts.get(0).getValue();
}
int retVal = count2.compareTo(count1);
if (retVal == 0) {
retVal = theO1.getTypeElement().getValue().compareTo(theO2.getTypeElement().getValue());
}
return retVal;
}
});
}
}
theModel.put("conf", conformance);
theModel.put("requiredParamExtension", ExtensionConstants.PARAM_IS_REQUIRED);
return conformance;
}
protected String logPrefix(ModelMap theModel) {
return "[server=" + theModel.get("serverId") + "] - ";
}

View File

@ -1,6 +1,9 @@
package ca.uhn.fhir.to;
import static org.apache.commons.lang3.StringUtils.*;
import static org.apache.commons.lang3.StringUtils.defaultIfEmpty;
import static org.apache.commons.lang3.StringUtils.defaultString;
import static org.apache.commons.lang3.StringUtils.isBlank;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
import java.io.StringWriter;
import java.util.ArrayList;
@ -14,6 +17,12 @@ import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import org.hl7.fhir.dstu21.model.CodeType;
import org.hl7.fhir.dstu21.model.Conformance.ConformanceRestComponent;
import org.hl7.fhir.dstu21.model.Conformance.ConformanceRestResourceComponent;
import org.hl7.fhir.dstu21.model.Conformance.ConformanceRestResourceSearchParamComponent;
import org.hl7.fhir.dstu21.model.StringType;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.springframework.ui.ModelMap;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping;
@ -21,7 +30,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import ca.uhn.fhir.context.RuntimeResourceDefinition;
import ca.uhn.fhir.model.api.Bundle;
import ca.uhn.fhir.model.api.ExtensionDt;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.api.Include;
import ca.uhn.fhir.model.dstu.resource.Conformance;
import ca.uhn.fhir.model.dstu.resource.Conformance.Rest;
@ -36,7 +44,6 @@ import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.model.primitive.StringDt;
import ca.uhn.fhir.parser.DataFormatException;
import ca.uhn.fhir.rest.client.GenericClient;
import ca.uhn.fhir.rest.client.IGenericClient;
import ca.uhn.fhir.rest.gclient.ICreateTyped;
import ca.uhn.fhir.rest.gclient.IQuery;
import ca.uhn.fhir.rest.gclient.IUntypedQuery;
@ -124,7 +131,7 @@ public class Controller extends BaseController {
long start = System.currentTimeMillis();
try {
client.delete((Class<? extends IResource>) def.getImplementingClass(), new IdDt(id));
client.delete((Class<? extends IBaseResource>) def.getImplementingClass(), new IdDt(id));
} catch (Exception e) {
returnsResource = handleClientException(client, e, theModel);
}
@ -143,7 +150,7 @@ public class Controller extends BaseController {
CaptureInterceptor interceptor = new CaptureInterceptor();
GenericClient client = theRequest.newClient(theReq, getContext(theRequest), myConfig, interceptor);
Class<? extends IResource> resType = null;
Class<? extends IBaseResource> resType = null;
ResultType returnsResource = ResultType.TAGLIST;
String outcomeDescription = "Tag List";
@ -158,7 +165,7 @@ public class Controller extends BaseController {
return "resource";
}
resType = (Class<? extends IResource>) def.getImplementingClass();
resType = (Class<? extends IBaseResource>) def.getImplementingClass();
String id = theReq.getParameter("resource-tags-id");
if (isNotBlank(id)) {
String vid = theReq.getParameter("resource-tags-vid");
@ -287,7 +294,7 @@ public class Controller extends BaseController {
@RequestMapping({ "/resource" })
public String actionResource(HttpServletRequest theServletRequest, final ResourceRequest theRequest, final BindingResult theBindingResult, final ModelMap theModel) {
IResource conformance = addCommonParams(theServletRequest, theRequest, theModel);
IBaseResource conformance = addCommonParams(theServletRequest, theRequest, theModel);
CaptureInterceptor interceptor = new CaptureInterceptor();
GenericClient client = theRequest.newClient(theServletRequest, getContext(theRequest), myConfig, interceptor);
@ -303,13 +310,15 @@ public class Controller extends BaseController {
List<List<String>> queryIncludes = new ArrayList<List<String>>();
switch (theRequest.getFhirVersion(myConfig)) {
case DEV:
case DSTU2:
haveSearchParams = extractSearchParamsDev(conformance, resourceName, includes, revIncludes, sortParams, queries, haveSearchParams, queryIncludes);
break;
case DSTU1:
haveSearchParams = extractSearchParamsDstu1(conformance, resourceName, includes, sortParams, queries, haveSearchParams, queryIncludes);
break;
case DSTU2:
haveSearchParams = extractSearchParamsDstu2(conformance, resourceName, includes, revIncludes, sortParams, queries, haveSearchParams, queryIncludes);
break;
case DSTU2_1:
haveSearchParams = extractSearchParamsDstu21(conformance, resourceName, includes, revIncludes, sortParams, queries, haveSearchParams, queryIncludes);
break;
default:
throw new IllegalStateException("Unknown FHIR version: " + theRequest.getFhirVersion(myConfig));
}
@ -324,7 +333,7 @@ public class Controller extends BaseController {
if (isNotBlank(theRequest.getUpdateId())) {
String updateId = theRequest.getUpdateId();
String updateVid = defaultIfEmpty(theRequest.getUpdateVid(), null);
IResource updateResource = (IResource) client.read(def.getImplementingClass(), new IdDt(resourceName, updateId, updateVid));
IBaseResource updateResource = (IBaseResource) client.read(def.getImplementingClass(), new IdDt(resourceName, updateId, updateVid));
String updateResourceString = theRequest.newParser(getContext(theRequest)).setPrettyPrint(true).encodeResourceToString(updateResource);
theModel.put("updateResource", updateResourceString);
theModel.put("updateResourceId", updateId);
@ -353,7 +362,7 @@ public class Controller extends BaseController {
IQuery query;
if (isNotBlank(theReq.getParameter("resource"))) {
try {
query = search.forResource((Class<? extends IResource>) getResourceType(theRequest, theReq).getImplementingClass());
query = search.forResource((Class<? extends IBaseResource>) getResourceType(theRequest, theReq).getImplementingClass());
} catch (ServletException e) {
theModel.put("errorMsg", e.toString());
return "resource";
@ -528,10 +537,10 @@ public class Controller extends BaseController {
GenericClient client = theRequest.newClient(theReq, getContext(theRequest), myConfig, interceptor);
client.setPrettyPrint(true);
Class<? extends IResource> type = null; // def.getImplementingClass();
Class<? extends IBaseResource> type = null; // def.getImplementingClass();
if ("history-type".equals(theMethod)) {
RuntimeResourceDefinition def = getContext(theRequest).getResourceDefinition(theRequest.getResource());
type = (Class<? extends IResource>) def.getImplementingClass();
type = (Class<? extends IBaseResource>) def.getImplementingClass();
}
String body = validate ? theReq.getParameter("resource-validate-body") : theReq.getParameter("resource-create-body");
@ -542,7 +551,7 @@ public class Controller extends BaseController {
body = preProcessMessageBody(body);
IResource resource;
IBaseResource resource;
try {
if (body.startsWith("{")) {
resource = getContext(theRequest).newJsonParser().parseResource(type, body);
@ -613,10 +622,10 @@ public class Controller extends BaseController {
GenericClient client = theRequest.newClient(theReq, getContext(theRequest), myConfig, interceptor);
String id = null;
Class<? extends IResource> type = null; // def.getImplementingClass();
Class<? extends IBaseResource> type = null; // def.getImplementingClass();
if ("history-type".equals(theMethod)) {
RuntimeResourceDefinition def = getContext(theRequest).getResourceDefinition(theRequest.getResource());
type = (Class<? extends IResource>) def.getImplementingClass();
type = (Class<? extends IBaseResource>) def.getImplementingClass();
id = StringUtils.defaultString(theReq.getParameter("resource-history-id"));
}
@ -647,44 +656,7 @@ public class Controller extends BaseController {
}
private boolean extractSearchParamsDev(IResource theConformance, String resourceName, TreeSet<String> includes, TreeSet<String> theRevIncludes, TreeSet<String> sortParams, List<RestQuery> queries, boolean haveSearchParams,
List<List<String>> queryIncludes) {
ca.uhn.fhir.model.dstu2.resource.Conformance conformance = (ca.uhn.fhir.model.dstu2.resource.Conformance) theConformance;
for (ca.uhn.fhir.model.dstu2.resource.Conformance.Rest nextRest : conformance.getRest()) {
for (ca.uhn.fhir.model.dstu2.resource.Conformance.RestResource nextRes : nextRest.getResource()) {
if (nextRes.getTypeElement().getValue().equals(resourceName)) {
for (StringDt next : nextRes.getSearchInclude()) {
if (next.isEmpty() == false) {
includes.add(next.getValue());
}
}
for (ca.uhn.fhir.model.dstu2.resource.Conformance.RestResourceSearchParam next : nextRes.getSearchParam()) {
if (next.getTypeElement().getValueAsEnum() != ca.uhn.fhir.model.dstu2.valueset.SearchParamTypeEnum.COMPOSITE) {
sortParams.add(next.getNameElement().getValue());
}
}
if (nextRes.getSearchParam().size() > 0) {
haveSearchParams = true;
}
} else {
// It's a different resource from the one we're searching, so
// scan for revinclude candidates
for (ca.uhn.fhir.model.dstu2.resource.Conformance.RestResourceSearchParam next : nextRes.getSearchParam()) {
if (next.getTypeElement().getValueAsEnum() == ca.uhn.fhir.model.dstu2.valueset.SearchParamTypeEnum.REFERENCE) {
for (BoundCodeDt<ResourceTypeEnum> nextTargetType : next.getTarget()) {
if (nextTargetType.getValue().equals(resourceName)) {
theRevIncludes.add(nextRes.getTypeElement().getValue() + ":" + next.getName());
}
}
}
}
}
}
}
return haveSearchParams;
}
private boolean extractSearchParamsDstu1(IResource theConformance, String resourceName, TreeSet<String> includes, TreeSet<String> sortParams, List<RestQuery> queries, boolean haveSearchParams,
private boolean extractSearchParamsDstu1(IBaseResource theConformance, String resourceName, TreeSet<String> includes, TreeSet<String> sortParams, List<RestQuery> queries, boolean haveSearchParams,
List<List<String>> queryIncludes) {
Conformance conformance = (Conformance) theConformance;
for (Rest nextRest : conformance.getRest()) {
@ -733,7 +705,81 @@ public class Controller extends BaseController {
return haveSearchParams;
}
private boolean handleSearchParam(String paramIdxString, HttpServletRequest theReq, IQuery theQuery, JsonGenerator theClientCodeJsonWriter) {
private boolean extractSearchParamsDstu2(IBaseResource theConformance, String resourceName, TreeSet<String> includes, TreeSet<String> theRevIncludes, TreeSet<String> sortParams, List<RestQuery> queries, boolean haveSearchParams,
List<List<String>> queryIncludes) {
ca.uhn.fhir.model.dstu2.resource.Conformance conformance = (ca.uhn.fhir.model.dstu2.resource.Conformance) theConformance;
for (ca.uhn.fhir.model.dstu2.resource.Conformance.Rest nextRest : conformance.getRest()) {
for (ca.uhn.fhir.model.dstu2.resource.Conformance.RestResource nextRes : nextRest.getResource()) {
if (nextRes.getTypeElement().getValue().equals(resourceName)) {
for (StringDt next : nextRes.getSearchInclude()) {
if (next.isEmpty() == false) {
includes.add(next.getValue());
}
}
for (ca.uhn.fhir.model.dstu2.resource.Conformance.RestResourceSearchParam next : nextRes.getSearchParam()) {
if (next.getTypeElement().getValueAsEnum() != ca.uhn.fhir.model.dstu2.valueset.SearchParamTypeEnum.COMPOSITE) {
sortParams.add(next.getNameElement().getValue());
}
}
if (nextRes.getSearchParam().size() > 0) {
haveSearchParams = true;
}
} else {
// It's a different resource from the one we're searching, so
// scan for revinclude candidates
for (ca.uhn.fhir.model.dstu2.resource.Conformance.RestResourceSearchParam next : nextRes.getSearchParam()) {
if (next.getTypeElement().getValueAsEnum() == ca.uhn.fhir.model.dstu2.valueset.SearchParamTypeEnum.REFERENCE) {
for (BoundCodeDt<ResourceTypeEnum> nextTargetType : next.getTarget()) {
if (nextTargetType.getValue().equals(resourceName)) {
theRevIncludes.add(nextRes.getTypeElement().getValue() + ":" + next.getName());
}
}
}
}
}
}
}
return haveSearchParams;
}
private boolean extractSearchParamsDstu21(IBaseResource theConformance, String resourceName, TreeSet<String> includes, TreeSet<String> theRevIncludes, TreeSet<String> sortParams, List<RestQuery> queries, boolean haveSearchParams,
List<List<String>> queryIncludes) {
org.hl7.fhir.dstu21.model.Conformance conformance = (org.hl7.fhir.dstu21.model.Conformance) theConformance;
for (ConformanceRestComponent nextRest : conformance.getRest()) {
for (ConformanceRestResourceComponent nextRes : nextRest.getResource()) {
if (nextRes.getTypeElement().getValue().equals(resourceName)) {
for (StringType next : nextRes.getSearchInclude()) {
if (next.isEmpty() == false) {
includes.add(next.getValue());
}
}
for (ConformanceRestResourceSearchParamComponent next : nextRes.getSearchParam()) {
if (next.getTypeElement().getValue() != org.hl7.fhir.dstu21.model.Enumerations.SearchParamType.COMPOSITE) {
sortParams.add(next.getNameElement().getValue());
}
}
if (nextRes.getSearchParam().size() > 0) {
haveSearchParams = true;
}
} else {
// It's a different resource from the one we're searching, so
// scan for revinclude candidates
for (ConformanceRestResourceSearchParamComponent next : nextRes.getSearchParam()) {
if (next.getTypeElement().getValue() == org.hl7.fhir.dstu21.model.Enumerations.SearchParamType.REFERENCE) {
for (CodeType nextTargetType : next.getTarget()) {
if (nextTargetType.getValue().equals(resourceName)) {
theRevIncludes.add(nextRes.getTypeElement().getValue() + ":" + next.getName());
}
}
}
}
}
}
}
return haveSearchParams;
}
private boolean handleSearchParam(String paramIdxString, HttpServletRequest theReq, IQuery<?> theQuery, JsonGenerator theClientCodeJsonWriter) {
String nextName = theReq.getParameter("param." + paramIdxString + ".name");
if (isBlank(nextName)) {
return false;