More JPA work

This commit is contained in:
jamesagnew 2014-05-16 17:00:06 -04:00
parent 610bb542ca
commit 4002cc8824
131 changed files with 815 additions and 392 deletions

View File

@ -45,7 +45,7 @@ public interface IQueryParameterAnd {
* for information on the <b>token</b> format
* </p>
*/
public List<List<String>> getValuesAsQueryTokens();
public List<QualifiedParamList> getValuesAsQueryTokens();
}

View File

@ -20,7 +20,7 @@ package ca.uhn.fhir.model.api;
* #L%
*/
import java.util.List;
import ca.uhn.fhir.rest.method.QualifiedParamList;
public interface IQueryParameterOr {
@ -33,7 +33,7 @@ public interface IQueryParameterOr {
* for information on the <b>token</b> format
* </p>
*/
public void setValuesAsQueryTokens(List<String> theParameters);
public void setValuesAsQueryTokens(QualifiedParamList theParameters);
/**
* Returns the value of this type using the <b>token</b> format. This
@ -45,7 +45,7 @@ public interface IQueryParameterOr {
* for information on the <b>token</b> format
* </p>
*/
public List<String> getValuesAsQueryTokens();
public QualifiedParamList getValuesAsQueryTokens();
}

View File

@ -1,5 +1,7 @@
package ca.uhn.fhir.model.api;
import ca.uhn.fhir.context.FhirContext;
/*
* #%L
* HAPI FHIR Library
@ -23,8 +25,7 @@ package ca.uhn.fhir.model.api;
public interface IQueryParameterType {
/**
* Sets the value of this type using the <b>token</b> format. This format is used in HTTP queries as a parameter
* format.
* This method is generally only called by HAPI itself, and should not need to be called from user code.
*
* <p>
* See FHIR specification <a href="http://www.hl7.org/implement/standards/fhir/search.html#ptypes">2.2.2 Search
@ -41,8 +42,7 @@ public interface IQueryParameterType {
public void setValueAsQueryToken(String theQualifier, String theValue);
/**
* Returns the value of this type using the <b>token</b> format. This format is used in HTTP queries as a parameter
* format.
* This method is generally only called by HAPI itself, and should not need to be called from user code.
*
* <p>
* See FHIR specification <a href="http://www.hl7.org/implement/standards/fhir/search.html#ptypes">2.2.2 Search
@ -51,4 +51,12 @@ public interface IQueryParameterType {
*/
public String getValueAsQueryToken();
/**
* This method is generally only called by HAPI itself, and should not need to be called from user code.
*
* This method will return any qualifier that should be appended to the parameter name (e.g ":exact")
* @param theContext TODO
*/
public String getQueryParameterQualifier(FhirContext theContext);
}

View File

@ -38,6 +38,7 @@ package ca.uhn.fhir.model.dstu.composite;
import java.util.List;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.BaseElement;
import ca.uhn.fhir.model.api.ICompositeDatatype;
import ca.uhn.fhir.model.api.IElement;
@ -427,5 +428,10 @@ public class CodingDt
}
}
@Override
public String getQueryParameterQualifier(FhirContext theContext) {
return null;
}
}

View File

@ -38,6 +38,7 @@ package ca.uhn.fhir.model.dstu.composite;
import java.util.List;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.BaseElement;
import ca.uhn.fhir.model.api.ICompositeDatatype;
import ca.uhn.fhir.model.api.IElement;
@ -434,4 +435,9 @@ public class IdentifierDt
}
@Override
public String getQueryParameterQualifier(FhirContext theContext) {
return null;
}
}

View File

@ -25,6 +25,7 @@ import java.util.List;
import org.apache.commons.lang3.StringUtils;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.BaseElement;
import ca.uhn.fhir.model.api.ICompositeDatatype;
import ca.uhn.fhir.model.api.IElement;
@ -430,4 +431,11 @@ public class QuantityDt extends BaseElement implements ICompositeDatatype, IQuer
return b.toString();
}
@Override
public String getQueryParameterQualifier(FhirContext theContext) {
return null;
}
}

View File

@ -22,6 +22,7 @@ package ca.uhn.fhir.model.primitive;
import org.apache.commons.lang3.StringUtils;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.BasePrimitive;
import ca.uhn.fhir.model.api.IQueryParameterType;
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
@ -129,4 +130,9 @@ public class StringDt extends BasePrimitive<String> implements IQueryParameterTy
return super.isEmpty() && StringUtils.isBlank(getValue());
}
@Override
public String getQueryParameterQualifier(FhirContext theContext) {
return null;
}
}

View File

@ -28,6 +28,7 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpRequestBase;
@ -172,10 +173,13 @@ public class GenericClient extends BaseClient implements IGenericClient {
LinkedHashMap<String, List<String>> params = new LinkedHashMap<String, List<String>>();
for (Entry<String, List<IQueryParameterType>> nextEntry : theParams.entrySet()) {
ArrayList<String> valueList = new ArrayList<String>();
params.put(nextEntry.getKey(), valueList);
String qualifier = null;
for (IQueryParameterType nextValue : nextEntry.getValue()) {
valueList.add(nextValue.getValueAsQueryToken());
qualifier = nextValue.getQueryParameterQualifier(myContext);
}
qualifier = StringUtils.defaultString(qualifier);
params.put(nextEntry.getKey()+qualifier, valueList);
}
GetClientInvocation invocation = SearchMethodBinding.createSearchInvocation(toResourceName(theType), params);

View File

@ -152,7 +152,7 @@ public abstract class BaseAddOrDeleteTagsMethodBinding extends BaseMethodBinding
}
for (int idx = 0; idx < theArgs.length; idx++) {
IParameter nextParam = getParameters().get(idx);
nextParam.translateClientArgumentIntoQueryArgument(theArgs[idx], null, retVal);
nextParam.translateClientArgumentIntoQueryArgument(getContext(), theArgs[idx], null, retVal);
}
return retVal;

View File

@ -59,7 +59,7 @@ public class ConformanceMethodBinding extends BaseResourceReturningMethodBinding
if (theArgs != null) {
for (int idx = 0; idx < theArgs.length; idx++) {
IParameter nextParam = getParameters().get(idx);
nextParam.translateClientArgumentIntoQueryArgument(theArgs[idx], null, retVal);
nextParam.translateClientArgumentIntoQueryArgument(getContext(), theArgs[idx], null, retVal);
}
}

View File

@ -65,7 +65,7 @@ public class CreateMethodBinding extends BaseOutcomeReturningMethodBindingWithRe
if (theArgs != null) {
for (int idx = 0; idx < theArgs.length; idx++) {
IParameter nextParam = getParameters().get(idx);
nextParam.translateClientArgumentIntoQueryArgument(theArgs[idx], null, retVal);
nextParam.translateClientArgumentIntoQueryArgument(getContext(), theArgs[idx], null, retVal);
}
}

View File

@ -130,7 +130,7 @@ public class DeleteMethodBinding extends BaseOutcomeReturningMethodBinding {
for (int idx = 0; idx < theArgs.length; idx++) {
IParameter nextParam = getParameters().get(idx);
nextParam.translateClientArgumentIntoQueryArgument(theArgs[idx], null, retVal);
nextParam.translateClientArgumentIntoQueryArgument(getContext(), theArgs[idx], null, retVal);
}
return retVal;

View File

@ -136,7 +136,7 @@ public class GetTagsMethodBinding extends BaseMethodBinding<TagList> {
if (theArgs != null) {
for (int idx = 0; idx < theArgs.length; idx++) {
IParameter nextParam = getParameters().get(idx);
nextParam.translateClientArgumentIntoQueryArgument(theArgs[idx], null, retVal);
nextParam.translateClientArgumentIntoQueryArgument(getContext(), theArgs[idx], null, retVal);
}
}

View File

@ -118,7 +118,7 @@ public class HistoryMethodBinding extends BaseResourceReturningMethodBinding {
if (theArgs != null) {
for (int idx = 0; idx < theArgs.length; idx++) {
IParameter nextParam = getParameters().get(idx);
nextParam.translateClientArgumentIntoQueryArgument(theArgs[idx], retVal.getParameters(),retVal);
nextParam.translateClientArgumentIntoQueryArgument(getContext(), theArgs[idx], retVal.getParameters(),retVal);
}
}

View File

@ -1,5 +1,25 @@
package ca.uhn.fhir.rest.method;
/*
* #%L
* HAPI FHIR Library
* %%
* Copyright (C) 2014 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 java.util.ArrayList;
import java.util.StringTokenizer;
@ -25,10 +45,14 @@ public class QualifiedParamList extends ArrayList<String> {
myQualifier = theQualifier;
}
public static QualifiedParamList singleton(String theQualifier, String theNextParam) {
public static QualifiedParamList singleton(String theParamValue) {
return singleton(null, theParamValue);
}
public static QualifiedParamList singleton(String theQualifier, String theParamValue) {
QualifiedParamList retVal = new QualifiedParamList(1);
retVal.setQualifier(theQualifier);
retVal.add(theNextParam);
retVal.add(theParamValue);
return retVal;
}

View File

@ -133,7 +133,7 @@ public class ReadMethodBinding extends BaseResourceReturningMethodBinding {
for (int idx = 0; idx < theArgs.length; idx++) {
IParameter nextParam = getParameters().get(idx);
nextParam.translateClientArgumentIntoQueryArgument(theArgs[idx], null, retVal);
nextParam.translateClientArgumentIntoQueryArgument(getContext(), theArgs[idx], null, retVal);
}
return retVal;

View File

@ -91,7 +91,7 @@ public class SearchMethodBinding extends BaseResourceReturningMethodBinding {
if (theArgs != null) {
for (int idx = 0; idx < theArgs.length; idx++) {
IParameter nextParam = getParameters().get(idx);
nextParam.translateClientArgumentIntoQueryArgument(theArgs[idx], queryStringArgs, retVal);
nextParam.translateClientArgumentIntoQueryArgument(getContext(), theArgs[idx], queryStringArgs, retVal);
}
}

View File

@ -113,7 +113,7 @@ public class UpdateMethodBinding extends BaseOutcomeReturningMethodBindingWithRe
for (int idx = 0; idx < theArgs.length; idx++) {
IParameter nextParam = getParameters().get(idx);
nextParam.translateClientArgumentIntoQueryArgument(theArgs[idx], null, retVal);
nextParam.translateClientArgumentIntoQueryArgument(getContext(), theArgs[idx], null, retVal);
}
return retVal;

View File

@ -77,7 +77,7 @@ public class ValidateMethodBinding extends BaseOutcomeReturningMethodBindingWith
for (int idx = 0; idx < theArgs.length; idx++) {
IParameter nextParam = getParameters().get(idx);
nextParam.translateClientArgumentIntoQueryArgument(theArgs[idx], null, retVal);
nextParam.translateClientArgumentIntoQueryArgument(getContext(), theArgs[idx], null, retVal);
}
return retVal;

View File

@ -26,6 +26,9 @@ import java.util.Collection;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.dstu.valueset.SearchParamTypeEnum;
import ca.uhn.fhir.rest.client.BaseClientInvocation;
import ca.uhn.fhir.rest.method.QualifiedParamList;
@ -35,7 +38,7 @@ import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
public abstract class BaseQueryParameter implements IParameter {
public abstract List<List<String>> encode(Object theObject) throws InternalErrorException;
public abstract List<QualifiedParamList> encode(FhirContext theContext, Object theObject) throws InternalErrorException;
public abstract String getName();
@ -52,17 +55,17 @@ public abstract class BaseQueryParameter implements IParameter {
public abstract SearchParamTypeEnum getParamType();
@Override
public void translateClientArgumentIntoQueryArgument(Object theSourceClientArgument, Map<String, List<String>> theTargetQueryArguments, BaseClientInvocation theClientInvocation) throws InternalErrorException {
public void translateClientArgumentIntoQueryArgument(FhirContext theContext, Object theSourceClientArgument, Map<String, List<String>> theTargetQueryArguments, BaseClientInvocation theClientInvocation) throws InternalErrorException {
if (theSourceClientArgument == null) {
if (isRequired()) {
throw new NullPointerException("SearchParameter '" + getName() + "' is required and may not be null");
}
} else {
List<List<String>> value = encode(theSourceClientArgument);
List<QualifiedParamList> value = encode(theContext, theSourceClientArgument);
ArrayList<String> paramValues = new ArrayList<String>(value.size());
theTargetQueryArguments.put(getName(), paramValues);
String qualifier=null;
for (List<String> nextParamEntry : value) {
for (QualifiedParamList nextParamEntry : value) {
StringBuilder b = new StringBuilder();
for (String str : nextParamEntry) {
if (b.length() > 0) {
@ -71,8 +74,13 @@ public abstract class BaseQueryParameter implements IParameter {
b.append(str.replace(",", "\\,"));
}
paramValues.add(b.toString());
if (StringUtils.isBlank(qualifier)) {
qualifier=nextParamEntry.getQualifier();
}
}
theTargetQueryArguments.put(getName()+StringUtils.defaultString(qualifier), paramValues);
}
}

View File

@ -27,6 +27,7 @@ import java.util.List;
import ca.uhn.fhir.model.api.IQueryParameterOr;
import ca.uhn.fhir.model.dstu.composite.CodingDt;
import ca.uhn.fhir.rest.method.QualifiedParamList;
public class CodingListParam implements IQueryParameterOr, Iterable<CodingDt> {
@ -96,8 +97,8 @@ public class CodingListParam implements IQueryParameterOr, Iterable<CodingDt> {
}
@Override
public List<String> getValuesAsQueryTokens() {
ArrayList<String> retVal = new ArrayList<String>();
public QualifiedParamList getValuesAsQueryTokens() {
QualifiedParamList retVal = new QualifiedParamList();
for (CodingDt next : myCodings) {
retVal.add(next.getValueAsQueryToken());
}
@ -112,7 +113,7 @@ public class CodingListParam implements IQueryParameterOr, Iterable<CodingDt> {
}
@Override
public void setValuesAsQueryTokens(List<String> theParameters) {
public void setValuesAsQueryTokens(QualifiedParamList theParameters) {
getCodings().clear();
for (String string : theParameters) {
CodingDt dt = new CodingDt();

View File

@ -29,6 +29,7 @@ import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import ca.uhn.fhir.context.ConfigurationException;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.primitive.IntegerDt;
import ca.uhn.fhir.parser.DataFormatException;
import ca.uhn.fhir.rest.annotation.Since;
@ -43,7 +44,7 @@ public class CountParameter implements IParameter {
private Class<?> myType;
@Override
public void translateClientArgumentIntoQueryArgument(Object theSourceClientArgument, Map<String, List<String>> theTargetQueryArguments, BaseClientInvocation theClientInvocation) throws InternalErrorException {
public void translateClientArgumentIntoQueryArgument(FhirContext theContext, Object theSourceClientArgument, Map<String, List<String>> theTargetQueryArguments, BaseClientInvocation theClientInvocation) throws InternalErrorException {
if (theSourceClientArgument != null) {
IntegerDt since = ParameterUtil.toInteger(theSourceClientArgument);
if (since.isEmpty() == false) {

View File

@ -21,7 +21,6 @@ package ca.uhn.fhir.rest.param;
*/
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
@ -157,13 +156,13 @@ public class DateRangeParam implements IQueryParameterAnd {
}
@Override
public List<List<String>> getValuesAsQueryTokens() {
ArrayList<List<String>> retVal = new ArrayList<List<String>>();
public List<QualifiedParamList> getValuesAsQueryTokens() {
ArrayList<QualifiedParamList> retVal = new ArrayList<QualifiedParamList>();
if (myLowerBound != null) {
retVal.add(Collections.singletonList(myLowerBound.getValueAsQueryToken()));
retVal.add(QualifiedParamList.singleton(myLowerBound.getValueAsQueryToken()));
}
if (myUpperBound != null) {
retVal.add(Collections.singletonList(myUpperBound.getValueAsQueryToken()));
retVal.add(QualifiedParamList.singleton(myUpperBound.getValueAsQueryToken()));
}
return retVal;
}

View File

@ -22,13 +22,14 @@ package ca.uhn.fhir.rest.param;
import java.util.List;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.rest.method.QualifiedParamList;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
interface IParamBinder {
List<List<String>> encode(Object theString) throws InternalErrorException;
List<QualifiedParamList> encode(FhirContext theContext, Object theString) throws InternalErrorException;
Object parse(List<QualifiedParamList> theList) throws InternalErrorException, InvalidRequestException;

View File

@ -25,6 +25,7 @@ import java.util.Collection;
import java.util.List;
import java.util.Map;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.rest.client.BaseClientInvocation;
import ca.uhn.fhir.rest.method.Request;
@ -34,7 +35,7 @@ import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
public interface IParameter {
void translateClientArgumentIntoQueryArgument(Object theSourceClientArgument, Map<String, List<String>> theTargetQueryArguments, BaseClientInvocation theClientInvocation) throws InternalErrorException;
void translateClientArgumentIntoQueryArgument(FhirContext theContext, Object theSourceClientArgument, Map<String, List<String>> theTargetQueryArguments, BaseClientInvocation theClientInvocation) throws InternalErrorException;
/**
* This <b>server method</b> method takes the data received by the server in an incoming request, and translates that data into a single argument for a server method invocation. Note that all

View File

@ -25,6 +25,7 @@ import java.util.List;
import ca.uhn.fhir.model.api.IQueryParameterOr;
import ca.uhn.fhir.model.dstu.composite.IdentifierDt;
import ca.uhn.fhir.rest.method.QualifiedParamList;
public class IdentifierListParam implements IQueryParameterOr {
@ -38,8 +39,8 @@ public class IdentifierListParam implements IQueryParameterOr {
}
@Override
public List<String> getValuesAsQueryTokens() {
ArrayList<String> retVal = new ArrayList<String>();
public QualifiedParamList getValuesAsQueryTokens() {
QualifiedParamList retVal = new QualifiedParamList();
for (IdentifierDt next : myIdentifiers) {
retVal.add(next.getValueAsQueryToken());
}
@ -54,7 +55,7 @@ public class IdentifierListParam implements IQueryParameterOr {
}
@Override
public void setValuesAsQueryTokens(List<String> theParameters) {
public void setValuesAsQueryTokens(QualifiedParamList theParameters) {
for (String string : theParameters) {
IdentifierDt dt = new IdentifierDt();
dt.setValueAsQueryToken(null, string);

View File

@ -22,12 +22,12 @@ package ca.uhn.fhir.rest.param;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.TreeSet;
import ca.uhn.fhir.context.ConfigurationException;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.PathSpecification;
import ca.uhn.fhir.model.dstu.valueset.SearchParamTypeEnum;
import ca.uhn.fhir.rest.annotation.IncludeParam;
@ -59,19 +59,19 @@ public class IncludeParameter extends BaseQueryParameter {
@SuppressWarnings("unchecked")
@Override
public List<List<String>> encode(Object theObject) throws InternalErrorException {
ArrayList<List<String>> retVal = new ArrayList<List<String>>();
public List<QualifiedParamList> encode(FhirContext theContext, Object theObject) throws InternalErrorException {
ArrayList<QualifiedParamList> retVal = new ArrayList<QualifiedParamList>();
if (myInstantiableCollectionType == null) {
if (mySpecType == PathSpecification.class) {
retVal.add(Collections.singletonList(((PathSpecification)theObject).getValue()));
retVal.add(QualifiedParamList.singleton(((PathSpecification)theObject).getValue()));
} else {
retVal.add(Collections.singletonList(((String)theObject)));
retVal.add(QualifiedParamList.singleton(((String)theObject)));
}
}else {
Collection<PathSpecification> val = (Collection<PathSpecification>) theObject;
for (PathSpecification pathSpec : val) {
retVal.add(Collections.singletonList(pathSpec.getValue()));
retVal.add(QualifiedParamList.singleton(pathSpec.getValue()));
}
}

View File

@ -25,6 +25,7 @@ import java.util.Collection;
import java.util.List;
import java.util.Map;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.rest.client.BaseClientInvocation;
import ca.uhn.fhir.rest.method.Request;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
@ -33,7 +34,7 @@ import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
class NullParameter implements IParameter {
@Override
public void translateClientArgumentIntoQueryArgument(Object theSourceClientArgument, Map<String, List<String>> theTargetQueryArguments, BaseClientInvocation theClientInvocation) throws InternalErrorException {
public void translateClientArgumentIntoQueryArgument(FhirContext theContext, Object theSourceClientArgument, Map<String, List<String>> theTargetQueryArguments, BaseClientInvocation theClientInvocation) throws InternalErrorException {
//nothing
}

View File

@ -22,6 +22,7 @@ package ca.uhn.fhir.rest.param;
import java.util.Date;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.IQueryParameterType;
import ca.uhn.fhir.model.dstu.valueset.QuantityCompararatorEnum;
import ca.uhn.fhir.model.primitive.DateTimeDt;
@ -123,4 +124,11 @@ public class QualifiedDateParam extends DateTimeDt implements IQueryParameterTyp
}
@Override
public String getQueryParameterQualifier(FhirContext theContext) {
return null;
}
}

View File

@ -22,6 +22,7 @@ package ca.uhn.fhir.rest.param;
import java.util.List;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.IQueryParameterAnd;
import ca.uhn.fhir.rest.method.QualifiedParamList;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
@ -35,8 +36,8 @@ final class QueryParameterAndBinder implements IParamBinder {
}
@Override
public List<List<String>> encode(Object theString) throws InternalErrorException {
List<List<String>> retVal = ((IQueryParameterAnd) theString).getValuesAsQueryTokens();
public List<QualifiedParamList> encode(FhirContext theContext, Object theString) throws InternalErrorException {
List<QualifiedParamList> retVal = ((IQueryParameterAnd) theString).getValuesAsQueryTokens();
return retVal;
}

View File

@ -23,6 +23,7 @@ package ca.uhn.fhir.rest.param;
import java.util.Collections;
import java.util.List;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.IQueryParameterOr;
import ca.uhn.fhir.rest.method.QualifiedParamList;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
@ -36,8 +37,8 @@ final class QueryParameterOrBinder implements IParamBinder {
}
@Override
public List<List<String>> encode(Object theString) throws InternalErrorException {
List<String> retVal = ((IQueryParameterOr) theString).getValuesAsQueryTokens();
public List<QualifiedParamList> encode(FhirContext theContext, Object theString) throws InternalErrorException {
QualifiedParamList retVal = ((IQueryParameterOr) theString).getValuesAsQueryTokens();
return Collections.singletonList(retVal);
}

View File

@ -23,6 +23,7 @@ package ca.uhn.fhir.rest.param;
import java.util.Collections;
import java.util.List;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.IQueryParameterType;
import ca.uhn.fhir.rest.method.QualifiedParamList;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
@ -36,9 +37,11 @@ final class QueryParameterTypeBinder implements IParamBinder {
}
@Override
public List<List<String>> encode(Object theString) throws InternalErrorException {
String retVal = ((IQueryParameterType) theString).getValueAsQueryToken();
return Collections.singletonList(Collections.singletonList(retVal));
public List<QualifiedParamList> encode(FhirContext theContext, Object theString) throws InternalErrorException {
IQueryParameterType param = (IQueryParameterType) theString;
String retVal = param.getValueAsQueryToken();
String qualifier=param.getQueryParameterQualifier(theContext);
return Collections.singletonList(QualifiedParamList.singleton(qualifier, retVal));
}
@Override

View File

@ -1,5 +1,26 @@
package ca.uhn.fhir.rest.param;
/*
* #%L
* HAPI FHIR Library
* %%
* Copyright (C) 2014 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 ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.IQueryParameterType;
import ca.uhn.fhir.model.api.IResource;
@ -50,7 +71,15 @@ public class ReferenceParam implements IQueryParameterType {
@Override
public void setValueAsQueryToken(String theQualifier, String theValue) {
myValue=theValue;
myValue = theValue;
}
@Override
public String getQueryParameterQualifier(FhirContext theContext) {
if (myType != null) {
return ":" + theContext.getResourceDefinition(myType).getName();
}
return null;
}
}

View File

@ -25,6 +25,7 @@ import java.util.Collection;
import java.util.List;
import java.util.Map;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.rest.client.BaseClientInvocation;
import ca.uhn.fhir.rest.method.Request;
@ -40,7 +41,7 @@ public class ResourceParameter implements IParameter {
}
@Override
public void translateClientArgumentIntoQueryArgument(Object theSourceClientArgument, Map<String, List<String>> theTargetQueryArguments, BaseClientInvocation theClientInvocation) throws InternalErrorException {
public void translateClientArgumentIntoQueryArgument(FhirContext theContext, Object theSourceClientArgument, Map<String, List<String>> theTargetQueryArguments, BaseClientInvocation theClientInvocation) throws InternalErrorException {
// TODO Auto-generated method stub
}

View File

@ -24,6 +24,7 @@ import java.util.Collection;
import java.util.List;
import ca.uhn.fhir.context.ConfigurationException;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.IQueryParameterAnd;
import ca.uhn.fhir.model.api.IQueryParameterOr;
import ca.uhn.fhir.model.api.IQueryParameterType;
@ -50,24 +51,28 @@ public class SearchParameter extends BaseQueryParameter {
public SearchParameter() {
}
public SearchParameter(String name, boolean required) {
this.myName = name;
this.myRequired = required;
public SearchParameter(String theName, boolean theRequired) {
this.myName = theName;
this.myRequired = theRequired;
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see ca.uhn.fhir.rest.param.IParameter#encode(java.lang.Object)
*/
@Override
public List<List<String>> encode(Object theObject) throws InternalErrorException {
return myParamBinder.encode(theObject);
public List<QualifiedParamList> encode(FhirContext theContext, Object theObject) throws InternalErrorException {
return myParamBinder.encode(theContext, theObject);
}
public String getDescription() {
return myDescription;
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see ca.uhn.fhir.rest.param.IParameter#getName()
*/
@Override
@ -94,7 +99,9 @@ public class SearchParameter extends BaseQueryParameter {
return myRequired;
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see ca.uhn.fhir.rest.param.IParameter#parse(java.util.List)
*/
@Override
@ -118,16 +125,20 @@ public class SearchParameter extends BaseQueryParameter {
public void setType(final Class<?> type, Class<? extends Collection<?>> theInnerCollectionType, Class<? extends Collection<?>> theOuterCollectionType) {
this.myType = type;
if (IQueryParameterType.class.isAssignableFrom(type)) {
this.myParamBinder = new QueryParameterTypeBinder((Class<? extends IQueryParameterType>) type);
myParamBinder = new QueryParameterTypeBinder((Class<? extends IQueryParameterType>) type);
} else if (IQueryParameterOr.class.isAssignableFrom(type)) {
this.myParamBinder = new QueryParameterOrBinder((Class<? extends IQueryParameterOr>) type);
myParamBinder = new QueryParameterOrBinder((Class<? extends IQueryParameterOr>) type);
} else if (IQueryParameterAnd.class.isAssignableFrom(type)) {
this.myParamBinder = new QueryParameterAndBinder((Class<? extends IQueryParameterAnd>) type);
myParamBinder = new QueryParameterAndBinder((Class<? extends IQueryParameterAnd>) type);
} else if (String.class.equals(type)) {
myParamBinder=new StringBinder();
} else {
throw new ConfigurationException("Unsupported data type for parameter: " + type.getCanonicalName());
}
if (StringDt.class.isAssignableFrom(type)) {
if (String.class.equals(type)) {
myParamType = SearchParamTypeEnum.STRING;
} else if (StringDt.class.isAssignableFrom(type)) {
myParamType = SearchParamTypeEnum.STRING;
} else if (QualifiedDateParam.class.isAssignableFrom(type)) {
myParamType = SearchParamTypeEnum.DATE;
@ -145,13 +156,13 @@ public class SearchParameter extends BaseQueryParameter {
// NB: Once this is enabled, we should return true from handlesMissing if
// it's a collection type
// if (theInnerCollectionType != null) {
// this.parser = new CollectionBinder(this.parser, theInnerCollectionType);
// }
//
// if (theOuterCollectionType != null) {
// this.parser = new CollectionBinder(this.parser, theOuterCollectionType);
// }
// if (theInnerCollectionType != null) {
// this.parser = new CollectionBinder(this.parser, theInnerCollectionType);
// }
//
// if (theOuterCollectionType != null) {
// this.parser = new CollectionBinder(this.parser, theOuterCollectionType);
// }
}

View File

@ -25,6 +25,7 @@ import java.util.Collection;
import java.util.List;
import java.util.Map;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.rest.client.BaseClientInvocation;
import ca.uhn.fhir.rest.method.Request;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
@ -34,7 +35,7 @@ class ServerBaseParameter implements IParameter {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ServerBaseParameter.class);
@Override
public void translateClientArgumentIntoQueryArgument(Object theSourceClientArgument, Map<String, List<String>> theTargetQueryArguments, BaseClientInvocation theClientInvocation) throws InternalErrorException {
public void translateClientArgumentIntoQueryArgument(FhirContext theContext, Object theSourceClientArgument, Map<String, List<String>> theTargetQueryArguments, BaseClientInvocation theClientInvocation) throws InternalErrorException {
/*
* Does nothing, since we just ignore serverbase arguments
*/

View File

@ -25,6 +25,7 @@ import java.util.Collection;
import java.util.List;
import java.util.Map;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.rest.client.BaseClientInvocation;
import ca.uhn.fhir.rest.method.Request;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
@ -34,7 +35,7 @@ class ServletRequestParameter implements IParameter {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ServletRequestParameter.class);
@Override
public void translateClientArgumentIntoQueryArgument(Object theSourceClientArgument, Map<String, List<String>> theTargetQueryArguments, BaseClientInvocation theClientInvocation) throws InternalErrorException {
public void translateClientArgumentIntoQueryArgument(FhirContext theContext, Object theSourceClientArgument, Map<String, List<String>> theTargetQueryArguments, BaseClientInvocation theClientInvocation) throws InternalErrorException {
/*
* Does nothing, since we just ignore HttpServletRequest arguments
*/

View File

@ -25,6 +25,7 @@ import java.util.Collection;
import java.util.List;
import java.util.Map;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.rest.client.BaseClientInvocation;
import ca.uhn.fhir.rest.method.Request;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
@ -34,7 +35,7 @@ class ServletResponseParameter implements IParameter {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ServletResponseParameter.class);
@Override
public void translateClientArgumentIntoQueryArgument(Object theSourceClientArgument, Map<String, List<String>> theTargetQueryArguments, BaseClientInvocation theClientInvocation) throws InternalErrorException {
public void translateClientArgumentIntoQueryArgument(FhirContext theContext, Object theSourceClientArgument, Map<String, List<String>> theTargetQueryArguments, BaseClientInvocation theClientInvocation) throws InternalErrorException {
/*
* Does nothing, since we just ignore HttpServletResponse arguments
*/

View File

@ -29,6 +29,7 @@ import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import ca.uhn.fhir.context.ConfigurationException;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.primitive.InstantDt;
import ca.uhn.fhir.parser.DataFormatException;
import ca.uhn.fhir.rest.annotation.Since;
@ -43,7 +44,7 @@ public class SinceParameter implements IParameter {
private Class<?> myType;
@Override
public void translateClientArgumentIntoQueryArgument(Object theSourceClientArgument, Map<String, List<String>> theTargetQueryArguments, BaseClientInvocation theClientInvocation) throws InternalErrorException {
public void translateClientArgumentIntoQueryArgument(FhirContext theContext, Object theSourceClientArgument, Map<String, List<String>> theTargetQueryArguments, BaseClientInvocation theClientInvocation) throws InternalErrorException {
if (theSourceClientArgument != null) {
InstantDt since = ParameterUtil.toInstant(theSourceClientArgument);
if (since.isEmpty() == false) {

View File

@ -26,6 +26,7 @@ import java.util.List;
import java.util.Map;
import ca.uhn.fhir.context.ConfigurationException;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.rest.annotation.Sort;
import ca.uhn.fhir.rest.api.SortOrderEnum;
import ca.uhn.fhir.rest.api.SortSpec;
@ -38,7 +39,7 @@ import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
public class SortParameter implements IParameter {
@Override
public void translateClientArgumentIntoQueryArgument(Object theSourceClientArgument, Map<String, List<String>> theTargetQueryArguments, BaseClientInvocation theClientInvocation) throws InternalErrorException {
public void translateClientArgumentIntoQueryArgument(FhirContext theContext, Object theSourceClientArgument, Map<String, List<String>> theTargetQueryArguments, BaseClientInvocation theClientInvocation) throws InternalErrorException {
SortSpec ss = (SortSpec) theSourceClientArgument;
if (ss ==null) {
return;

View File

@ -0,0 +1,53 @@
package ca.uhn.fhir.rest.param;
/*
* #%L
* HAPI FHIR Library
* %%
* Copyright (C) 2014 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 java.util.Collections;
import java.util.List;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.rest.method.QualifiedParamList;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
final class StringBinder implements IParamBinder {
StringBinder() {
}
@Override
public List<QualifiedParamList> encode(FhirContext theContext, Object theString) throws InternalErrorException {
String retVal = ((String) theString);
return Collections.singletonList(QualifiedParamList.singleton(retVal));
}
@Override
public Object parse(List<QualifiedParamList> theParams) throws InternalErrorException, InvalidRequestException {
if (theParams.size() == 0 || theParams.get(0).size() == 0) {
return "";
}
if (theParams.size() > 1 || theParams.get(0).size() > 1) {
throw new InvalidRequestException("Multiple values detected");
}
return theParams.get(0).get(0);
}
}

View File

@ -1,5 +1,26 @@
package ca.uhn.fhir.rest.param;
/*
* #%L
* HAPI FHIR Library
* %%
* Copyright (C) 2014 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 ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.primitive.StringDt;
import ca.uhn.fhir.rest.server.Constants;
@ -14,16 +35,30 @@ public class StringParameter extends StringDt {
setValue(theValue);
}
public StringParameter(String theValue, boolean theExact) {
setValue(theValue);
setExact(theExact);
}
@Override
public void setValueAsQueryToken(String theQualifier, String theValue) {
if (Constants.PARAMQUALIFIER_STRING_EXACT.equals(theQualifier)) {
setExact(true);
}else {
} else {
setExact(false);
}
super.setValueAsQueryToken(theQualifier, theValue);
}
@Override
public String getQueryParameterQualifier(FhirContext theContext) {
if (isExact()) {
return Constants.PARAMQUALIFIER_STRING_EXACT;
} else {
return null;
}
}
public boolean isExact() {
return myExact;
}

View File

@ -34,24 +34,24 @@ public class ResourceBinding {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ResourceBinding.class);
private String resourceName;
private List<BaseMethodBinding> methods = new ArrayList<BaseMethodBinding>();
private List<BaseMethodBinding<?>> methods = new ArrayList<BaseMethodBinding<?>>();
public ResourceBinding() {
}
public ResourceBinding(String resourceName, List<BaseMethodBinding> methods) {
public ResourceBinding(String resourceName, List<BaseMethodBinding<?>> methods) {
this.resourceName = resourceName;
this.methods = methods;
}
public BaseMethodBinding getMethod(Request theRequest) throws Exception {
public BaseMethodBinding<?> getMethod(Request theRequest) throws Exception {
if (null == methods) {
ourLog.warn("No methods exist for resource: {}", resourceName);
return null;
}
ourLog.debug("Looking for a handler for {}", theRequest);
for (BaseMethodBinding rm : methods) {
for (BaseMethodBinding<?> rm : methods) {
if (rm.incomingServerRequestMatchesMethod(theRequest)) {
ourLog.debug("Handler {} matches", rm);
return rm;
@ -70,15 +70,15 @@ public class ResourceBinding {
this.resourceName = resourceName;
}
public List<BaseMethodBinding> getMethodBindings() {
public List<BaseMethodBinding<?>> getMethodBindings() {
return methods;
}
public void setMethods(List<BaseMethodBinding> methods) {
public void setMethods(List<BaseMethodBinding<?>> methods) {
this.methods = methods;
}
public void addMethod(BaseMethodBinding method) {
public void addMethod(BaseMethodBinding<?> method) {
this.methods.add(method);
}

View File

@ -68,7 +68,7 @@ public class RestfulServer extends HttpServlet {
private Map<String, ResourceBinding> myResourceNameToProvider = new HashMap<String, ResourceBinding>();
private Collection<IResourceProvider> myResourceProviders;
private ISecurityManager mySecurityManager;
private BaseMethodBinding myServerConformanceMethod;
private BaseMethodBinding<?> myServerConformanceMethod;
private Object myServerConformanceProvider;
private String myServerName = "HAPI FHIR Server";
/** This is configurable but by default we jsut use HAPI version */
@ -363,7 +363,7 @@ public class RestfulServer extends HttpServlet {
if (Modifier.isPublic(m.getModifiers()) && !Modifier.isStatic(m.getModifiers())) {
ourLog.debug("Scanning public method: {}#{}", theProvider.getClass(), m.getName());
BaseMethodBinding foundMethodBinding = BaseMethodBinding.bindMethod(m, myFhirContext, theProvider);
BaseMethodBinding<?> foundMethodBinding = BaseMethodBinding.bindMethod(m, myFhirContext, theProvider);
if (foundMethodBinding != null) {
String resourceName = foundMethodBinding.getResourceName();
@ -407,7 +407,7 @@ public class RestfulServer extends HttpServlet {
if (Modifier.isPublic(m.getModifiers())) {
ourLog.debug("Scanning public method: {}#{}", theSystemProvider.getClass(), m.getName());
BaseMethodBinding foundMethodBinding = BaseMethodBinding.bindMethod(m, myFhirContext, theSystemProvider);
BaseMethodBinding<?> foundMethodBinding = BaseMethodBinding.bindMethod(m, myFhirContext, theSystemProvider);
if (foundMethodBinding != null) {
if (foundMethodBinding instanceof ConformanceMethodBinding) {
myServerConformanceMethod = foundMethodBinding;
@ -527,7 +527,7 @@ public class RestfulServer extends HttpServlet {
}
ResourceBinding resourceBinding = null;
BaseMethodBinding resourceMethod = null;
BaseMethodBinding<?> resourceMethod = null;
if ("metadata".equals(resourceName)) {
resourceMethod = myServerConformanceMethod;
} else if (resourceName == null) {

View File

@ -59,6 +59,7 @@ import ca.uhn.fhir.rest.client.api.IRestfulClient;
import ca.uhn.fhir.rest.param.CodingListParam;
import ca.uhn.fhir.rest.param.DateRangeParam;
import ca.uhn.fhir.rest.param.QualifiedDateParam;
import ca.uhn.fhir.rest.param.StringParameter;
import ca.uhn.fhir.rest.server.IResourceProvider;
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
import ca.uhn.fhir.rest.server.exceptions.ResourceVersionConflictException;
@ -81,7 +82,7 @@ public List<Organization> getAllOrganizations() {
//START SNIPPET: underlyingReq
@Search
public List<Patient> findPatients(
@RequiredParam(name="foo") StringDt theParameter,
@RequiredParam(name="foo") StringParameter theParameter,
HttpServletRequest theRequest,
HttpServletResponse theResponse) {
List<Patient> retVal=new ArrayList<Patient>(); // populate this
@ -145,8 +146,17 @@ public Patient getResourceById(@IdParam IdDt theId,
//START SNIPPET: searchStringParam
@Search()
public List<Patient> searchByLastName(@RequiredParam(name=Patient.SP_FAMILY) StringDt theId) {
public List<Patient> searchByLastName(@RequiredParam(name=Patient.SP_FAMILY) StringParameter theFamily) {
List<Patient> retVal = new ArrayList<Patient>();
String valueToMatch = theFamily.getValue();
if (theFamily.isExact()) {
// Do an exact match search
} else {
// Do a fuzzy search if possible
}
// ...populate...
return retVal;
}
@ -154,7 +164,7 @@ public List<Patient> searchByLastName(@RequiredParam(name=Patient.SP_FAMILY) Str
//START SNIPPET: searchNamedQuery
@Search(queryName="namedQuery1")
public List<Patient> searchByNamedQuery(@RequiredParam(name="someparam") StringDt theSomeParam) {
public List<Patient> searchByNamedQuery(@RequiredParam(name="someparam") StringParameter theSomeParam) {
List<Patient> retVal = new ArrayList<Patient>();
// ...populate...
return retVal;
@ -175,8 +185,8 @@ public List<Patient> searchByIdentifier(@RequiredParam(name=Patient.SP_IDENTIFIE
//START SNIPPET: searchOptionalParam
@Search()
public List<Patient> searchByNames( @RequiredParam(name=Patient.SP_FAMILY) StringDt theFamilyName,
@OptionalParam(name=Patient.SP_GIVEN) StringDt theGivenName ) {
public List<Patient> searchByNames( @RequiredParam(name=Patient.SP_FAMILY) StringParameter theFamilyName,
@OptionalParam(name=Patient.SP_GIVEN) StringParameter theGivenName ) {
String familyName = theFamilyName.getValue();
String givenName = theGivenName != null ? theGivenName.getValue() : null;

View File

@ -504,6 +504,13 @@
classes.
</p>
<p>
Parameters which take a string as their format should use the
<a href="./apidocs/ca/uhn/fhir/rest/param/StringParameter.html">StringParameter</a>
type. They may also use normal java Strings (or HAPI's StringDt), although it is
not possible to use the ":exact" qualifier in that case.
</p>
<macro name="snippet">
<param name="id" value="searchStringParam" />
<param name="file" value="src/site/example/java/example/RestfulPatientResourceProviderMore.java" />

View File

@ -0,0 +1,116 @@
package ca.uhn.fhir.rest.client;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.io.StringReader;
import java.nio.charset.Charset;
import java.util.List;
import org.apache.commons.io.input.ReaderInputStream;
import org.apache.http.HttpResponse;
import org.apache.http.ProtocolVersion;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.message.BasicHeader;
import org.apache.http.message.BasicStatusLine;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.internal.stubbing.defaultanswers.ReturnsDeepStubs;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.Bundle;
import ca.uhn.fhir.model.dstu.resource.Conformance;
import ca.uhn.fhir.model.dstu.resource.Patient;
import ca.uhn.fhir.rest.annotation.RequiredParam;
import ca.uhn.fhir.rest.annotation.Search;
import ca.uhn.fhir.rest.client.api.IBasicClient;
import ca.uhn.fhir.rest.param.StringParameter;
import ca.uhn.fhir.rest.server.Constants;
public class StringClientTest {
private FhirContext ctx;
private HttpClient httpClient;
private HttpResponse httpResponse;
// atom-document-large.xml
@Before
public void before() {
ctx = new FhirContext(Patient.class, Conformance.class);
httpClient = mock(HttpClient.class, new ReturnsDeepStubs());
ctx.getRestfulClientFactory().setHttpClient(httpClient);
httpResponse = mock(HttpResponse.class, new ReturnsDeepStubs());
}
@Test
public void testWithParam() throws Exception {
ArgumentCaptor<HttpUriRequest> capt = ArgumentCaptor.forClass(HttpUriRequest.class);
when(httpClient.execute(capt.capture())).thenReturn(httpResponse);
when(httpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 200, "OK"));
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_ATOM_XML + "; charset=UTF-8"));
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(createBundle()), Charset.forName("UTF-8")));
IClient client = ctx.newRestfulClient(IClient.class, "http://foo");
client.searchWithParam(new StringParameter("hello"));
assertEquals(HttpGet.class, capt.getValue().getClass());
HttpGet get = (HttpGet) capt.getValue();
assertEquals("http://foo/Patient?withParam=hello", get.getURI().toString());
}
@Test
public void testWithoutParam() throws Exception {
ArgumentCaptor<HttpUriRequest> capt = ArgumentCaptor.forClass(HttpUriRequest.class);
when(httpClient.execute(capt.capture())).thenReturn(httpResponse);
when(httpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 200, "OK"));
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_ATOM_XML + "; charset=UTF-8"));
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(createBundle()), Charset.forName("UTF-8")));
IClient client = ctx.newRestfulClient(IClient.class, "http://foo");
client.searchWithoutParam("hello");
assertEquals(HttpGet.class, capt.getValue().getClass());
HttpGet get = (HttpGet) capt.getValue();
assertEquals("http://foo/Patient?withoutParam=hello", get.getURI().toString());
}
@Test
public void testWithParamExact() throws Exception {
ArgumentCaptor<HttpUriRequest> capt = ArgumentCaptor.forClass(HttpUriRequest.class);
when(httpClient.execute(capt.capture())).thenReturn(httpResponse);
when(httpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 200, "OK"));
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_ATOM_XML + "; charset=UTF-8"));
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(createBundle()), Charset.forName("UTF-8")));
IClient client = ctx.newRestfulClient(IClient.class, "http://foo");
client.searchWithParam(new StringParameter("hello", true));
assertEquals(HttpGet.class, capt.getValue().getClass());
HttpGet get = (HttpGet) capt.getValue();
assertEquals("http://foo/Patient?withParam%3Aexact=hello", get.getURI().toString());
}
private String createBundle() {
return ctx.newXmlParser().encodeBundleToString(new Bundle());
}
private interface IClient extends IBasicClient {
@Search(type=Patient.class)
public List<Patient> searchWithParam(@RequiredParam(name="withParam") StringParameter theString);
@Search(type=Patient.class)
public List<Patient> searchWithoutParam(@RequiredParam(name="withoutParam") String theString);
}
}

View File

@ -39,7 +39,7 @@ public class DocumentationTest {
Collection<ResourceBinding> resourceBindings = rs.getResourceBindings();
for (ResourceBinding resourceBinding : resourceBindings) {
if (resourceBinding.getResourceName().equals("Patient")) {
List<BaseMethodBinding> methodBindings = resourceBinding.getMethodBindings();
List<BaseMethodBinding<?>> methodBindings = resourceBinding.getMethodBindings();
SearchMethodBinding binding = (SearchMethodBinding) methodBindings.get(0);
SearchParameter param = (SearchParameter) binding.getParameters().iterator().next();
assertEquals("The patient's identifier (MRN or other card number)", param.getDescription());

View File

@ -62,6 +62,24 @@ public class StringParameterTest {
}
}
@Test
public void testRawString() throws Exception {
{
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?plain=aaa");
HttpResponse status = ourClient.execute(httpGet);
String responseContent = IOUtils.toString(status.getEntity().getContent());
assertEquals(200, status.getStatusLine().getStatusCode());
assertEquals(1, new FhirContext().newXmlParser().parseBundle(responseContent).getEntries().size());
}
{
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?plain=BBB");
HttpResponse status = ourClient.execute(httpGet);
String responseContent = IOUtils.toString(status.getEntity().getContent());
assertEquals(200, status.getStatusLine().getStatusCode());
assertEquals(0, new FhirContext().newXmlParser().parseBundle(responseContent).getEntries().size());
}
}
@Test
public void testSearchExactMatch() throws Exception {
{
@ -133,6 +151,18 @@ public class StringParameterTest {
return retVal;
}
@Search
public List<Patient> findPatient(@RequiredParam(name = "plain") String theParam) {
ArrayList<Patient> retVal = new ArrayList<Patient>();
if (theParam.toLowerCase().equals("aaa")) {
retVal.add(new Patient());
}
return retVal;
}
@Override
public Class<? extends IResource> getResourceType() {
return Patient.class;

View File

@ -18,6 +18,7 @@ package ca.uhn.fhir.testmodel;
import java.util.List;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.BaseElement;
import ca.uhn.fhir.model.api.ICompositeDatatype;
import ca.uhn.fhir.model.api.IElement;
@ -397,5 +398,10 @@ public class IdentifierDt
}
}
@Override
public String getQueryParameterQualifier(FhirContext theContext) {
return null;
}
}

View File

@ -1,19 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/test/java" output="target/test-classes" including="**/*.java"/>
<classpathentry kind="src" path="src/test/resources" output="target/test-classes" excluding="**/*.java"/>
<classpathentry kind="src" path="src/main/java" including="**/*.java"/>
<classpathentry kind="src" path="src/main/resources" excluding="**/*.java"/>
<classpathentry kind="output" path="target/classes"/>
<classpathentry excluding="**/*.java" kind="src" output="target/test-classes" path="src/test/resources"/>
<classpathentry including="**/*.java" kind="src" path="src/main/java"/>
<classpathentry excluding="**/*.java" kind="src" path="src/main/resources"/>
<classpathentry kind="var" path="M2_REPO/javax/activation/activation/1.1/activation-1.1.jar" sourcepath="M2_REPO/javax/activation/activation/1.1/activation-1.1-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/javax/json/javax.json-api/1.0/javax.json-api-1.0.jar" sourcepath="M2_REPO/javax/json/javax.json-api/1.0/javax.json-api-1.0-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/javax/mail/javax.mail-api/1.5.0/javax.mail-api-1.5.0.jar" sourcepath="M2_REPO/javax/mail/javax.mail-api/1.5.0/javax.mail-api-1.5.0-sources.jar">
<attributes>
<attribute value="jar:file:/Users/james/.m2/repository/javax/mail/javax.mail-api/1.5.0/javax.mail-api-1.5.0-javadoc.jar!/" name="javadoc_location"/>
<attribute name="javadoc_location" value="jar:file:/Users/james/.m2/repository/javax/mail/javax.mail-api/1.5.0/javax.mail-api-1.5.0-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="M2_REPO/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0.jar" sourcepath="M2_REPO/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0-sources.jar">
<attributes>
<attribute value="jar:file:/Users/james/.m2/repository/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0-javadoc.jar!/" name="javadoc_location"/>
<attribute name="javadoc_location" value="jar:file:/Users/james/.m2/repository/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="M2_REPO/javax/transaction/jta/1.1/jta-1.1.jar" sourcepath="M2_REPO/javax/transaction/jta/1.1/jta-1.1-sources.jar"/>
@ -24,23 +23,23 @@
<classpathentry kind="var" path="M2_REPO/com/fasterxml/classmate/1.0.0/classmate-1.0.0.jar" sourcepath="M2_REPO/com/fasterxml/classmate/1.0.0/classmate-1.0.0-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/commons-codec/commons-codec/1.9/commons-codec-1.9.jar" sourcepath="M2_REPO/commons-codec/commons-codec/1.9/commons-codec-1.9-sources.jar">
<attributes>
<attribute value="jar:file:/Users/james/.m2/repository/commons-codec/commons-codec/1.9/commons-codec-1.9-javadoc.jar!/" name="javadoc_location"/>
<attribute name="javadoc_location" value="jar:file:/Users/james/.m2/repository/commons-codec/commons-codec/1.9/commons-codec-1.9-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="M2_REPO/commons-dbcp/commons-dbcp/1.4/commons-dbcp-1.4.jar" sourcepath="M2_REPO/commons-dbcp/commons-dbcp/1.4/commons-dbcp-1.4-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/commons-io/commons-io/2.4/commons-io-2.4.jar" sourcepath="M2_REPO/commons-io/commons-io/2.4/commons-io-2.4-sources.jar">
<attributes>
<attribute value="jar:file:/Users/james/.m2/repository/commons-io/commons-io/2.4/commons-io-2.4-javadoc.jar!/" name="javadoc_location"/>
<attribute name="javadoc_location" value="jar:file:/Users/james/.m2/repository/commons-io/commons-io/2.4/commons-io-2.4-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="M2_REPO/org/apache/commons/commons-lang3/3.2.1/commons-lang3-3.2.1.jar" sourcepath="M2_REPO/org/apache/commons/commons-lang3/3.2.1/commons-lang3-3.2.1-sources.jar">
<attributes>
<attribute value="jar:file:/Users/james/.m2/repository/org/apache/commons/commons-lang3/3.2.1/commons-lang3-3.2.1-javadoc.jar!/" name="javadoc_location"/>
<attribute name="javadoc_location" value="jar:file:/Users/james/.m2/repository/org/apache/commons/commons-lang3/3.2.1/commons-lang3-3.2.1-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="M2_REPO/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar" sourcepath="M2_REPO/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1-sources.jar">
<attributes>
<attribute value="jar:file:/Users/james/.m2/repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1-javadoc.jar!/" name="javadoc_location"/>
<attribute name="javadoc_location" value="jar:file:/Users/james/.m2/repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="M2_REPO/commons-pool/commons-pool/1.5.4/commons-pool-1.5.4.jar" sourcepath="M2_REPO/commons-pool/commons-pool/1.5.4/commons-pool-1.5.4-sources.jar"/>
@ -49,12 +48,12 @@
<classpathentry kind="var" path="M2_REPO/com/google/guava/guava/17.0/guava-17.0.jar" sourcepath="M2_REPO/com/google/guava/guava/17.0/guava-17.0-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-all/1.3/hamcrest-all-1.3.jar" sourcepath="M2_REPO/org/hamcrest/hamcrest-all/1.3/hamcrest-all-1.3-sources.jar">
<attributes>
<attribute value="jar:file:/Users/james/.m2/repository/org/hamcrest/hamcrest-all/1.3/hamcrest-all-1.3-javadoc.jar!/" name="javadoc_location"/>
<attribute name="javadoc_location" value="jar:file:/Users/james/.m2/repository/org/hamcrest/hamcrest-all/1.3/hamcrest-all-1.3-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar" sourcepath="M2_REPO/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3-sources.jar">
<attributes>
<attribute value="jar:file:/Users/james/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3-javadoc.jar!/" name="javadoc_location"/>
<attribute name="javadoc_location" value="jar:file:/Users/james/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="/hapi-fhir-base"/>
@ -65,7 +64,7 @@
<classpathentry kind="var" path="M2_REPO/org/hibernate/hibernate-entitymanager/4.3.5.Final/hibernate-entitymanager-4.3.5.Final.jar" sourcepath="M2_REPO/org/hibernate/hibernate-entitymanager/4.3.5.Final/hibernate-entitymanager-4.3.5.Final-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/hibernate/javax/persistence/hibernate-jpa-2.1-api/1.0.0.Final/hibernate-jpa-2.1-api-1.0.0.Final.jar" sourcepath="M2_REPO/org/hibernate/javax/persistence/hibernate-jpa-2.1-api/1.0.0.Final/hibernate-jpa-2.1-api-1.0.0.Final-sources.jar">
<attributes>
<attribute value="jar:file:/Users/james/.m2/repository/org/hibernate/javax/persistence/hibernate-jpa-2.1-api/1.0.0.Final/hibernate-jpa-2.1-api-1.0.0.Final-javadoc.jar!/" name="javadoc_location"/>
<attribute name="javadoc_location" value="jar:file:/Users/james/.m2/repository/org/hibernate/javax/persistence/hibernate-jpa-2.1-api/1.0.0.Final/hibernate-jpa-2.1-api-1.0.0.Final-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="M2_REPO/org/hibernate/hibernate-validator/5.1.0.Final/hibernate-validator-5.1.0.Final.jar" sourcepath="M2_REPO/org/hibernate/hibernate-validator/5.1.0.Final/hibernate-validator-5.1.0.Final-sources.jar"/>
@ -74,23 +73,23 @@
<classpathentry kind="var" path="M2_REPO/org/jboss/jandex/1.1.0.Final/jandex-1.1.0.Final.jar" sourcepath="M2_REPO/org/jboss/jandex/1.1.0.Final/jandex-1.1.0.Final-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/javassist/javassist/3.18.1-GA/javassist-3.18.1-GA.jar" sourcepath="M2_REPO/org/javassist/javassist/3.18.1-GA/javassist-3.18.1-GA-sources.jar">
<attributes>
<attribute value="jar:file:/Users/james/.m2/repository/org/javassist/javassist/3.18.1-GA/javassist-3.18.1-GA-javadoc.jar!/" name="javadoc_location"/>
<attribute name="javadoc_location" value="jar:file:/Users/james/.m2/repository/org/javassist/javassist/3.18.1-GA/javassist-3.18.1-GA-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="M2_REPO/org/glassfish/javax.json/1.0.4/javax.json-1.0.4.jar" sourcepath="M2_REPO/org/glassfish/javax.json/1.0.4/javax.json-1.0.4-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/jboss/logging/jboss-logging/3.1.3.GA/jboss-logging-3.1.3.GA.jar" sourcepath="M2_REPO/org/jboss/logging/jboss-logging/3.1.3.GA/jboss-logging-3.1.3.GA-sources.jar">
<attributes>
<attribute value="jar:file:/Users/james/.m2/repository/org/jboss/logging/jboss-logging/3.1.3.GA/jboss-logging-3.1.3.GA-javadoc.jar!/" name="javadoc_location"/>
<attribute name="javadoc_location" value="jar:file:/Users/james/.m2/repository/org/jboss/logging/jboss-logging/3.1.3.GA/jboss-logging-3.1.3.GA-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="M2_REPO/org/jboss/logging/jboss-logging-annotations/1.2.0.Beta1/jboss-logging-annotations-1.2.0.Beta1.jar" sourcepath="M2_REPO/org/jboss/logging/jboss-logging-annotations/1.2.0.Beta1/jboss-logging-annotations-1.2.0.Beta1-sources.jar">
<attributes>
<attribute value="jar:file:/Users/james/.m2/repository/org/jboss/logging/jboss-logging-annotations/1.2.0.Beta1/jboss-logging-annotations-1.2.0.Beta1-javadoc.jar!/" name="javadoc_location"/>
<attribute name="javadoc_location" value="jar:file:/Users/james/.m2/repository/org/jboss/logging/jboss-logging-annotations/1.2.0.Beta1/jboss-logging-annotations-1.2.0.Beta1-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="M2_REPO/org/jboss/spec/javax/transaction/jboss-transaction-api_1.2_spec/1.0.0.Final/jboss-transaction-api_1.2_spec-1.0.0.Final.jar" sourcepath="M2_REPO/org/jboss/spec/javax/transaction/jboss-transaction-api_1.2_spec/1.0.0.Final/jboss-transaction-api_1.2_spec-1.0.0.Final-sources.jar">
<attributes>
<attribute value="jar:file:/Users/james/.m2/repository/org/jboss/spec/javax/transaction/jboss-transaction-api_1.2_spec/1.0.0.Final/jboss-transaction-api_1.2_spec-1.0.0.Final-javadoc.jar!/" name="javadoc_location"/>
<attribute name="javadoc_location" value="jar:file:/Users/james/.m2/repository/org/jboss/spec/javax/transaction/jboss-transaction-api_1.2_spec/1.0.0.Final/jboss-transaction-api_1.2_spec-1.0.0.Final-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="M2_REPO/org/eclipse/jetty/jetty-continuation/9.1.1.v20140108/jetty-continuation-9.1.1.v20140108.jar" sourcepath="M2_REPO/org/eclipse/jetty/jetty-continuation/9.1.1.v20140108/jetty-continuation-9.1.1.v20140108-sources.jar"/>
@ -103,64 +102,65 @@
<classpathentry kind="var" path="M2_REPO/org/eclipse/jetty/jetty-util/9.1.1.v20140108/jetty-util-9.1.1.v20140108.jar" sourcepath="M2_REPO/org/eclipse/jetty/jetty-util/9.1.1.v20140108/jetty-util-9.1.1.v20140108-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/junit/junit/4.11/junit-4.11.jar" sourcepath="M2_REPO/junit/junit/4.11/junit-4.11-sources.jar">
<attributes>
<attribute value="jar:file:/Users/james/.m2/repository/junit/junit/4.11/junit-4.11-javadoc.jar!/" name="javadoc_location"/>
<attribute name="javadoc_location" value="jar:file:/Users/james/.m2/repository/junit/junit/4.11/junit-4.11-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-api/1.7.6/slf4j-api-1.7.6.jar" sourcepath="M2_REPO/org/slf4j/slf4j-api/1.7.6/slf4j-api-1.7.6-sources.jar">
<attributes>
<attribute value="jar:file:/Users/james/.m2/repository/org/slf4j/slf4j-api/1.7.6/slf4j-api-1.7.6-javadoc.jar!/" name="javadoc_location"/>
<attribute name="javadoc_location" value="jar:file:/Users/james/.m2/repository/org/slf4j/slf4j-api/1.7.6/slf4j-api-1.7.6-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="M2_REPO/org/springframework/spring-aop/4.0.1.RELEASE/spring-aop-4.0.1.RELEASE.jar" sourcepath="M2_REPO/org/springframework/spring-aop/4.0.1.RELEASE/spring-aop-4.0.1.RELEASE-sources.jar">
<attributes>
<attribute value="jar:file:/Users/james/.m2/repository/org/springframework/spring-aop/4.0.1.RELEASE/spring-aop-4.0.1.RELEASE-javadoc.jar!/" name="javadoc_location"/>
<attribute name="javadoc_location" value="jar:file:/Users/james/.m2/repository/org/springframework/spring-aop/4.0.1.RELEASE/spring-aop-4.0.1.RELEASE-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="M2_REPO/org/springframework/spring-beans/4.0.1.RELEASE/spring-beans-4.0.1.RELEASE.jar" sourcepath="M2_REPO/org/springframework/spring-beans/4.0.1.RELEASE/spring-beans-4.0.1.RELEASE-sources.jar">
<attributes>
<attribute value="jar:file:/Users/james/.m2/repository/org/springframework/spring-beans/4.0.1.RELEASE/spring-beans-4.0.1.RELEASE-javadoc.jar!/" name="javadoc_location"/>
<attribute name="javadoc_location" value="jar:file:/Users/james/.m2/repository/org/springframework/spring-beans/4.0.1.RELEASE/spring-beans-4.0.1.RELEASE-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="M2_REPO/org/springframework/spring-context/4.0.1.RELEASE/spring-context-4.0.1.RELEASE.jar" sourcepath="M2_REPO/org/springframework/spring-context/4.0.1.RELEASE/spring-context-4.0.1.RELEASE-sources.jar">
<attributes>
<attribute value="jar:file:/Users/james/.m2/repository/org/springframework/spring-context/4.0.1.RELEASE/spring-context-4.0.1.RELEASE-javadoc.jar!/" name="javadoc_location"/>
<attribute name="javadoc_location" value="jar:file:/Users/james/.m2/repository/org/springframework/spring-context/4.0.1.RELEASE/spring-context-4.0.1.RELEASE-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="M2_REPO/org/springframework/spring-context-support/4.0.1.RELEASE/spring-context-support-4.0.1.RELEASE.jar" sourcepath="M2_REPO/org/springframework/spring-context-support/4.0.1.RELEASE/spring-context-support-4.0.1.RELEASE-sources.jar">
<attributes>
<attribute value="jar:file:/Users/james/.m2/repository/org/springframework/spring-context-support/4.0.1.RELEASE/spring-context-support-4.0.1.RELEASE-javadoc.jar!/" name="javadoc_location"/>
<attribute name="javadoc_location" value="jar:file:/Users/james/.m2/repository/org/springframework/spring-context-support/4.0.1.RELEASE/spring-context-support-4.0.1.RELEASE-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="M2_REPO/org/springframework/spring-core/4.0.1.RELEASE/spring-core-4.0.1.RELEASE.jar" sourcepath="M2_REPO/org/springframework/spring-core/4.0.1.RELEASE/spring-core-4.0.1.RELEASE-sources.jar">
<attributes>
<attribute value="jar:file:/Users/james/.m2/repository/org/springframework/spring-core/4.0.1.RELEASE/spring-core-4.0.1.RELEASE-javadoc.jar!/" name="javadoc_location"/>
<attribute name="javadoc_location" value="jar:file:/Users/james/.m2/repository/org/springframework/spring-core/4.0.1.RELEASE/spring-core-4.0.1.RELEASE-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="M2_REPO/org/springframework/spring-expression/4.0.1.RELEASE/spring-expression-4.0.1.RELEASE.jar" sourcepath="M2_REPO/org/springframework/spring-expression/4.0.1.RELEASE/spring-expression-4.0.1.RELEASE-sources.jar">
<attributes>
<attribute value="jar:file:/Users/james/.m2/repository/org/springframework/spring-expression/4.0.1.RELEASE/spring-expression-4.0.1.RELEASE-javadoc.jar!/" name="javadoc_location"/>
<attribute name="javadoc_location" value="jar:file:/Users/james/.m2/repository/org/springframework/spring-expression/4.0.1.RELEASE/spring-expression-4.0.1.RELEASE-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="M2_REPO/org/springframework/spring-jdbc/4.0.1.RELEASE/spring-jdbc-4.0.1.RELEASE.jar" sourcepath="M2_REPO/org/springframework/spring-jdbc/4.0.1.RELEASE/spring-jdbc-4.0.1.RELEASE-sources.jar">
<attributes>
<attribute value="jar:file:/Users/james/.m2/repository/org/springframework/spring-jdbc/4.0.1.RELEASE/spring-jdbc-4.0.1.RELEASE-javadoc.jar!/" name="javadoc_location"/>
<attribute name="javadoc_location" value="jar:file:/Users/james/.m2/repository/org/springframework/spring-jdbc/4.0.1.RELEASE/spring-jdbc-4.0.1.RELEASE-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="M2_REPO/org/springframework/spring-orm/4.0.1.RELEASE/spring-orm-4.0.1.RELEASE.jar" sourcepath="M2_REPO/org/springframework/spring-orm/4.0.1.RELEASE/spring-orm-4.0.1.RELEASE-sources.jar">
<attributes>
<attribute value="jar:file:/Users/james/.m2/repository/org/springframework/spring-orm/4.0.1.RELEASE/spring-orm-4.0.1.RELEASE-javadoc.jar!/" name="javadoc_location"/>
<attribute name="javadoc_location" value="jar:file:/Users/james/.m2/repository/org/springframework/spring-orm/4.0.1.RELEASE/spring-orm-4.0.1.RELEASE-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="M2_REPO/org/springframework/spring-tx/4.0.1.RELEASE/spring-tx-4.0.1.RELEASE.jar" sourcepath="M2_REPO/org/springframework/spring-tx/4.0.1.RELEASE/spring-tx-4.0.1.RELEASE-sources.jar">
<attributes>
<attribute value="jar:file:/Users/james/.m2/repository/org/springframework/spring-tx/4.0.1.RELEASE/spring-tx-4.0.1.RELEASE-javadoc.jar!/" name="javadoc_location"/>
<attribute name="javadoc_location" value="jar:file:/Users/james/.m2/repository/org/springframework/spring-tx/4.0.1.RELEASE/spring-tx-4.0.1.RELEASE-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="M2_REPO/org/codehaus/woodstox/stax2-api/3.1.1/stax2-api-3.1.1.jar" sourcepath="M2_REPO/org/codehaus/woodstox/stax2-api/3.1.1/stax2-api-3.1.1-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/codehaus/woodstox/woodstox-core-asl/4.2.0/woodstox-core-asl-4.2.0.jar" sourcepath="M2_REPO/org/codehaus/woodstox/woodstox-core-asl/4.2.0/woodstox-core-asl-4.2.0-sources.jar">
<attributes>
<attribute value="jar:file:/Users/james/.m2/repository/org/codehaus/woodstox/woodstox-core-asl/4.2.0/woodstox-core-asl-4.2.0-javadoc.jar!/" name="javadoc_location"/>
<attribute name="javadoc_location" value="jar:file:/Users/james/.m2/repository/org/codehaus/woodstox/woodstox-core-asl/4.2.0/woodstox-core-asl-4.2.0-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -1,2 +1,3 @@
myUnitTestDB/
target/
/bin

View File

@ -240,6 +240,11 @@ public class ${className}
setCode(theParameter);
}
}
@Override
public String getQueryParameterQualifier(FhirContext theContext) {
return null;
}
#end
#if ( ${className} == "HumanNameDt" )
/**
@ -316,6 +321,11 @@ public class ${className}
setValue(theParameter);
}
}
@Override
public String getQueryParameterQualifier(FhirContext theContext) {
return null;
}
#end
#childExtensionTypes( $childExtensionTypes )

View File

@ -1,45 +0,0 @@
#parse ( "/vm/templates.vm" )
package ${packageBase};
@ResourceDef(name="${className}", profile="${profile}", id="${id}")
public class ${className}ResourceTable extends BaseResourceTable<${className}> {
#foreach ( $param in $searchParams )
#if( ${param.typeCapitalized} == 'String' )
@IndexedParam(path="${param.path}")
@Column(length=100)
private String ${param.name};
#elseif( ${param.typeCapitalized} == 'Date' )
@IndexedParam(path="${param.path}")
@Column()
private String ${param.name};
/**
* <b>Fluent Client</b> search parameter constant for <b>${param.name}</b>
* <p>
* Description: <b>${param.description}</b><br/>
* Type: <b>${param.type}</b><br/>
* Path: <b>${param.path}</b><br/>
* </p>
*/
public static final ${param.typeCapitalized}Param ${param.fluentConstantName} = new ${param.typeCapitalized}Param(${param.constantName});
#if( ${param.typeCapitalized} == 'Reference' )
#foreach ( $include in $param.paths )
/**
* Constant for fluent queries to be used to add include statements. Specifies
* the path value of "<b>${include.path}</b>".
*/
public static final Include INCLUDE_${include.includeName} = new Include("${include.path}");
#end
#end
#end
@Override
public Class<${className}> getResourceType() {
return ${className}.class;
}
}

View File

@ -0,0 +1,19 @@
package ${packageBase};
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import ca.uhn.fhir.model.dstu.resource.*;
public class ${className}ResourceTable extends BaseResourceTable<${className}> {
@Entity
@DiscriminatorValue("${className}")
public class PatientResourceTable extends BaseResourceTable<Patient> {
@Override
public Class<${className}> getResourceType() {
return ${className}.class;
}
}

View File

@ -0,0 +1,47 @@
package ${packageBase};
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import ca.uhn.fhir.model.dstu.resource.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import ca.uhn.fhir.jpa.dao.BaseResourceProvider;
import ca.uhn.fhir.model.api.IQueryParameterType;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.api.annotation.Description;
import ca.uhn.fhir.model.dstu.resource.Patient;
import ca.uhn.fhir.model.primitive.StringDt;
import ca.uhn.fhir.rest.annotation.OptionalParam;
import ca.uhn.fhir.rest.annotation.RequiredParam;
import ca.uhn.fhir.rest.annotation.Search;
public class ${className}ResourceProvider extends BaseResourceProvider<${className}> {
@Override
public Class<? extends IResource> getResourceType() {
return ${className}.class;
}
#foreach ( $param in $searchParams )
@Description(shortDefinition="${param.description}")
@OptionalParam(name="${param.name}")
#if (${param.type} == 'string' )
StringParam the${param.nameCapitalized} #{if}($foreach.hasNext), #{end}
#elseif (${param.type} == 'token' )
IdentifierDt the${param.nameCapitalized} #{if}($foreach.hasNext), #{end}
#elseif (${param.type} == 'date' )
DateRangeParam the${param.nameCapitalized} #{if}($foreach.hasNext), #{end}
#elseif (${param.type} == 'quantity' )
QuantityDt the${param.nameCapitalized} #{if}($foreach.hasNext), #{end}
#elseif (${param.type} == 'number' )
QuantityDt the${param.nameCapitalized} #{if}($foreach.hasNext), #{end}
#elseif (${param.type} == 'reference' )
ReferenceParam the${param.nameCapitalized} #{if}($foreach.hasNext), #{end}
#end
#end
}