Searching in JPA server with no search parameters returns deleted

resources when it should exclude them
This commit is contained in:
James Agnew 2015-03-24 18:39:19 -04:00
parent 0c8f50737f
commit f9b8432d65
24 changed files with 157 additions and 142 deletions

View File

@ -94,7 +94,7 @@
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.3</version>
<version>${maven_assembly_plugin_version}</version>
<executions>
<execution>
<phase>package</phase>
@ -104,8 +104,8 @@
<configuration>
<attach>true</attach>
<descriptors>
<descriptor>/Users/t3903uhn/git/hapi-fhir/hapi-fhir-android/src/assembly/android-sources.xml</descriptor>
<descriptor>/Users/t3903uhn/git/hapi-fhir/hapi-fhir-android/src/assembly/android-javadoc.xml</descriptor>
<descriptor>${project.basedir}/src/assembly/android-sources.xml</descriptor>
<descriptor>${project.basedir}/src/assembly/android-javadoc.xml</descriptor>
</descriptors>
</configuration>
</execution>

View File

@ -78,10 +78,10 @@ import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
import ca.uhn.fhir.model.base.composite.BaseContainedDt;
import ca.uhn.fhir.model.base.composite.BaseNarrativeDt;
import ca.uhn.fhir.model.base.composite.BaseResourceReferenceDt;
import ca.uhn.fhir.model.dstu.valueset.RestSearchParameterType;
import ca.uhn.fhir.model.primitive.BoundCodeDt;
import ca.uhn.fhir.model.primitive.ICodedDatatype;
import ca.uhn.fhir.model.primitive.XhtmlDt;
import ca.uhn.fhir.rest.method.RestSearchParameterTypeEnum;
import ca.uhn.fhir.util.ReflectionUtil;
class ModelScanner {
@ -681,11 +681,11 @@ class ModelScanner {
for (Field nextField : theClass.getFields()) {
SearchParamDefinition searchParam = pullAnnotation(nextField, SearchParamDefinition.class);
if (searchParam != null) {
RestSearchParameterType paramType = RestSearchParameterType.valueOf(searchParam.type().toUpperCase());
RestSearchParameterTypeEnum paramType = RestSearchParameterTypeEnum.valueOf(searchParam.type().toUpperCase());
if (paramType == null) {
throw new ConfigurationException("Search param " + searchParam.name() + " has an invalid type: " + searchParam.type());
}
if (paramType == RestSearchParameterType.COMPOSITE) {
if (paramType == RestSearchParameterTypeEnum.COMPOSITE) {
compositeFields.put(nextField, searchParam);
continue;
}
@ -708,7 +708,7 @@ class ModelScanner {
compositeOf.add(param);
}
RuntimeSearchParam param = new RuntimeSearchParam(searchParam.name(), searchParam.description(), searchParam.path(), RestSearchParameterType.COMPOSITE, compositeOf);
RuntimeSearchParam param = new RuntimeSearchParam(searchParam.name(), searchParam.description(), searchParam.path(), RestSearchParameterTypeEnum.COMPOSITE, compositeOf);
theResourceDef.addSearchParam(param);
}
}

View File

@ -5,7 +5,7 @@ import java.util.Collections;
import java.util.List;
import java.util.StringTokenizer;
import ca.uhn.fhir.model.dstu.valueset.RestSearchParameterType;
import ca.uhn.fhir.rest.method.RestSearchParameterTypeEnum;
/*
* #%L
@ -31,15 +31,15 @@ public class RuntimeSearchParam {
private String myDescription;
private String myName;
private RestSearchParameterType myParamType;
private RestSearchParameterTypeEnum myParamType;
private String myPath;
private List<RuntimeSearchParam> myCompositeOf;
public RuntimeSearchParam(String theName, String theDescription, String thePath, RestSearchParameterType theParamType) {
public RuntimeSearchParam(String theName, String theDescription, String thePath, RestSearchParameterTypeEnum theParamType) {
this(theName, theDescription, thePath, theParamType, null);
}
public RuntimeSearchParam(String theName, String theDescription, String thePath, RestSearchParameterType theParamType, List<RuntimeSearchParam> theCompositeOf) {
public RuntimeSearchParam(String theName, String theDescription, String thePath, RestSearchParameterTypeEnum theParamType, List<RuntimeSearchParam> theCompositeOf) {
super();
myName = theName;
myDescription = theDescription;
@ -60,7 +60,7 @@ public class RuntimeSearchParam {
return myName;
}
public RestSearchParameterType getParamType() {
public RestSearchParameterTypeEnum getParamType() {
return myParamType;
}

View File

@ -32,7 +32,6 @@ import ca.uhn.fhir.context.ConfigurationException;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.Include;
import ca.uhn.fhir.model.api.PathSpecification;
import ca.uhn.fhir.model.dstu.valueset.RestSearchParameterType;
import ca.uhn.fhir.rest.annotation.IncludeParam;
import ca.uhn.fhir.rest.param.BaseQueryParameter;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
@ -99,7 +98,7 @@ class IncludeParameter extends BaseQueryParameter {
}
@Override
public RestSearchParameterType getParamType() {
public RestSearchParameterTypeEnum getParamType() {
return null;
}

View File

@ -1,5 +1,5 @@
package ca.uhn.fhir.model.dstu.valueset;
package ca.uhn.fhir.rest.method;
/*
* #%L
@ -26,7 +26,7 @@ import java.util.Map;
import ca.uhn.fhir.model.api.IValueSetEnumBinder;
public enum RestSearchParameterType {
public enum RestSearchParameterTypeEnum {
/**
* Code Value: <b>number</b>
@ -98,18 +98,18 @@ public enum RestSearchParameterType {
*/
public static final String VALUESET_NAME = "SearchParamType";
private static Map<String, RestSearchParameterType> CODE_TO_ENUM = new HashMap<String, RestSearchParameterType>();
private static Map<String, Map<String, RestSearchParameterType>> SYSTEM_TO_CODE_TO_ENUM = new HashMap<String, Map<String, RestSearchParameterType>>();
private static Map<String, RestSearchParameterTypeEnum> CODE_TO_ENUM = new HashMap<String, RestSearchParameterTypeEnum>();
private static Map<String, Map<String, RestSearchParameterTypeEnum>> SYSTEM_TO_CODE_TO_ENUM = new HashMap<String, Map<String, RestSearchParameterTypeEnum>>();
private final String myCode;
private final String mySystem;
static {
for (RestSearchParameterType next : RestSearchParameterType.values()) {
for (RestSearchParameterTypeEnum next : RestSearchParameterTypeEnum.values()) {
CODE_TO_ENUM.put(next.getCode(), next);
if (!SYSTEM_TO_CODE_TO_ENUM.containsKey(next.getSystem())) {
SYSTEM_TO_CODE_TO_ENUM.put(next.getSystem(), new HashMap<String, RestSearchParameterType>());
SYSTEM_TO_CODE_TO_ENUM.put(next.getSystem(), new HashMap<String, RestSearchParameterTypeEnum>());
}
SYSTEM_TO_CODE_TO_ENUM.get(next.getSystem()).put(next.getCode(), next);
}
@ -132,33 +132,33 @@ public enum RestSearchParameterType {
/**
* Returns the enumerated value associated with this code
*/
public RestSearchParameterType forCode(String theCode) {
RestSearchParameterType retVal = CODE_TO_ENUM.get(theCode);
public RestSearchParameterTypeEnum forCode(String theCode) {
RestSearchParameterTypeEnum retVal = CODE_TO_ENUM.get(theCode);
return retVal;
}
/**
* Converts codes to their respective enumerated values
*/
public static final IValueSetEnumBinder<RestSearchParameterType> VALUESET_BINDER = new IValueSetEnumBinder<RestSearchParameterType>() {
public static final IValueSetEnumBinder<RestSearchParameterTypeEnum> VALUESET_BINDER = new IValueSetEnumBinder<RestSearchParameterTypeEnum>() {
@Override
public String toCodeString(RestSearchParameterType theEnum) {
public String toCodeString(RestSearchParameterTypeEnum theEnum) {
return theEnum.getCode();
}
@Override
public String toSystemString(RestSearchParameterType theEnum) {
public String toSystemString(RestSearchParameterTypeEnum theEnum) {
return theEnum.getSystem();
}
@Override
public RestSearchParameterType fromCodeString(String theCodeString) {
public RestSearchParameterTypeEnum fromCodeString(String theCodeString) {
return CODE_TO_ENUM.get(theCodeString);
}
@Override
public RestSearchParameterType fromCodeString(String theCodeString, String theSystemString) {
Map<String, RestSearchParameterType> map = SYSTEM_TO_CODE_TO_ENUM.get(theSystemString);
public RestSearchParameterTypeEnum fromCodeString(String theCodeString, String theSystemString) {
Map<String, RestSearchParameterTypeEnum> map = SYSTEM_TO_CODE_TO_ENUM.get(theSystemString);
if (map == null) {
return null;
}
@ -170,7 +170,7 @@ public enum RestSearchParameterType {
/**
* Constructor
*/
RestSearchParameterType(String theCode, String theSystem) {
RestSearchParameterTypeEnum(String theCode, String theSystem) {
myCode = theCode;
mySystem = theSystem;
}

View File

@ -39,7 +39,6 @@ import ca.uhn.fhir.model.api.IQueryParameterType;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.base.composite.BaseIdentifierDt;
import ca.uhn.fhir.model.base.composite.BaseQuantityDt;
import ca.uhn.fhir.model.dstu.valueset.RestSearchParameterType;
import ca.uhn.fhir.model.primitive.StringDt;
import ca.uhn.fhir.rest.annotation.OptionalParam;
import ca.uhn.fhir.rest.param.BaseQueryParameter;
@ -81,56 +80,56 @@ import ca.uhn.fhir.util.CollectionUtil;
public class SearchParameter extends BaseQueryParameter {
private static final String EMPTY_STRING = "";
private static HashMap<RestSearchParameterType, Set<String>> ourParamQualifiers;
private static HashMap<Class<?>, RestSearchParameterType> ourParamTypes;
private static HashMap<RestSearchParameterTypeEnum, Set<String>> ourParamQualifiers;
private static HashMap<Class<?>, RestSearchParameterTypeEnum> ourParamTypes;
static final String QUALIFIER_ANY_TYPE = ":*";
static {
ourParamTypes = new HashMap<Class<?>, RestSearchParameterType>();
ourParamQualifiers = new HashMap<RestSearchParameterType, Set<String>>();
ourParamTypes = new HashMap<Class<?>, RestSearchParameterTypeEnum>();
ourParamQualifiers = new HashMap<RestSearchParameterTypeEnum, Set<String>>();
ourParamTypes.put(StringParam.class, RestSearchParameterType.STRING);
ourParamTypes.put(StringOrListParam.class, RestSearchParameterType.STRING);
ourParamTypes.put(StringAndListParam.class, RestSearchParameterType.STRING);
ourParamQualifiers.put(RestSearchParameterType.STRING, CollectionUtil.newSet(Constants.PARAMQUALIFIER_STRING_EXACT, Constants.PARAMQUALIFIER_MISSING, EMPTY_STRING));
ourParamTypes.put(StringParam.class, RestSearchParameterTypeEnum.STRING);
ourParamTypes.put(StringOrListParam.class, RestSearchParameterTypeEnum.STRING);
ourParamTypes.put(StringAndListParam.class, RestSearchParameterTypeEnum.STRING);
ourParamQualifiers.put(RestSearchParameterTypeEnum.STRING, CollectionUtil.newSet(Constants.PARAMQUALIFIER_STRING_EXACT, Constants.PARAMQUALIFIER_MISSING, EMPTY_STRING));
ourParamTypes.put(UriParam.class, RestSearchParameterType.URI);
ourParamTypes.put(UriOrListParam.class, RestSearchParameterType.URI);
ourParamTypes.put(UriAndListParam.class, RestSearchParameterType.URI);
ourParamTypes.put(UriParam.class, RestSearchParameterTypeEnum.URI);
ourParamTypes.put(UriOrListParam.class, RestSearchParameterTypeEnum.URI);
ourParamTypes.put(UriAndListParam.class, RestSearchParameterTypeEnum.URI);
// TODO: are these right for URI?
ourParamQualifiers.put(RestSearchParameterType.URI, CollectionUtil.newSet(Constants.PARAMQUALIFIER_STRING_EXACT, Constants.PARAMQUALIFIER_MISSING, EMPTY_STRING));
ourParamQualifiers.put(RestSearchParameterTypeEnum.URI, CollectionUtil.newSet(Constants.PARAMQUALIFIER_STRING_EXACT, Constants.PARAMQUALIFIER_MISSING, EMPTY_STRING));
ourParamTypes.put(TokenParam.class, RestSearchParameterType.TOKEN);
ourParamTypes.put(TokenOrListParam.class, RestSearchParameterType.TOKEN);
ourParamTypes.put(TokenAndListParam.class, RestSearchParameterType.TOKEN);
ourParamQualifiers.put(RestSearchParameterType.TOKEN, CollectionUtil.newSet(Constants.PARAMQUALIFIER_TOKEN_TEXT, Constants.PARAMQUALIFIER_MISSING, EMPTY_STRING));
ourParamTypes.put(TokenParam.class, RestSearchParameterTypeEnum.TOKEN);
ourParamTypes.put(TokenOrListParam.class, RestSearchParameterTypeEnum.TOKEN);
ourParamTypes.put(TokenAndListParam.class, RestSearchParameterTypeEnum.TOKEN);
ourParamQualifiers.put(RestSearchParameterTypeEnum.TOKEN, CollectionUtil.newSet(Constants.PARAMQUALIFIER_TOKEN_TEXT, Constants.PARAMQUALIFIER_MISSING, EMPTY_STRING));
ourParamTypes.put(DateParam.class, RestSearchParameterType.DATE);
ourParamTypes.put(DateOrListParam.class, RestSearchParameterType.DATE);
ourParamTypes.put(DateAndListParam.class, RestSearchParameterType.DATE);
ourParamTypes.put(DateRangeParam.class, RestSearchParameterType.DATE);
ourParamQualifiers.put(RestSearchParameterType.DATE, CollectionUtil.newSet(Constants.PARAMQUALIFIER_MISSING, EMPTY_STRING));
ourParamTypes.put(DateParam.class, RestSearchParameterTypeEnum.DATE);
ourParamTypes.put(DateOrListParam.class, RestSearchParameterTypeEnum.DATE);
ourParamTypes.put(DateAndListParam.class, RestSearchParameterTypeEnum.DATE);
ourParamTypes.put(DateRangeParam.class, RestSearchParameterTypeEnum.DATE);
ourParamQualifiers.put(RestSearchParameterTypeEnum.DATE, CollectionUtil.newSet(Constants.PARAMQUALIFIER_MISSING, EMPTY_STRING));
ourParamTypes.put(QuantityParam.class, RestSearchParameterType.QUANTITY);
ourParamTypes.put(QuantityOrListParam.class, RestSearchParameterType.QUANTITY);
ourParamTypes.put(QuantityAndListParam.class, RestSearchParameterType.QUANTITY);
ourParamQualifiers.put(RestSearchParameterType.QUANTITY, CollectionUtil.newSet(Constants.PARAMQUALIFIER_MISSING, EMPTY_STRING));
ourParamTypes.put(QuantityParam.class, RestSearchParameterTypeEnum.QUANTITY);
ourParamTypes.put(QuantityOrListParam.class, RestSearchParameterTypeEnum.QUANTITY);
ourParamTypes.put(QuantityAndListParam.class, RestSearchParameterTypeEnum.QUANTITY);
ourParamQualifiers.put(RestSearchParameterTypeEnum.QUANTITY, CollectionUtil.newSet(Constants.PARAMQUALIFIER_MISSING, EMPTY_STRING));
ourParamTypes.put(NumberParam.class, RestSearchParameterType.NUMBER);
ourParamTypes.put(NumberOrListParam.class, RestSearchParameterType.NUMBER);
ourParamTypes.put(NumberAndListParam.class, RestSearchParameterType.NUMBER);
ourParamQualifiers.put(RestSearchParameterType.NUMBER, CollectionUtil.newSet(Constants.PARAMQUALIFIER_MISSING, EMPTY_STRING));
ourParamTypes.put(NumberParam.class, RestSearchParameterTypeEnum.NUMBER);
ourParamTypes.put(NumberOrListParam.class, RestSearchParameterTypeEnum.NUMBER);
ourParamTypes.put(NumberAndListParam.class, RestSearchParameterTypeEnum.NUMBER);
ourParamQualifiers.put(RestSearchParameterTypeEnum.NUMBER, CollectionUtil.newSet(Constants.PARAMQUALIFIER_MISSING, EMPTY_STRING));
ourParamTypes.put(ReferenceParam.class, RestSearchParameterType.REFERENCE);
ourParamTypes.put(ReferenceOrListParam.class, RestSearchParameterType.REFERENCE);
ourParamTypes.put(ReferenceAndListParam.class, RestSearchParameterType.REFERENCE);
ourParamTypes.put(ReferenceParam.class, RestSearchParameterTypeEnum.REFERENCE);
ourParamTypes.put(ReferenceOrListParam.class, RestSearchParameterTypeEnum.REFERENCE);
ourParamTypes.put(ReferenceAndListParam.class, RestSearchParameterTypeEnum.REFERENCE);
// --vvvv-- no empty because that gets added from OptionalParam#chainWhitelist
ourParamQualifiers.put(RestSearchParameterType.REFERENCE, CollectionUtil.newSet(Constants.PARAMQUALIFIER_MISSING));
ourParamQualifiers.put(RestSearchParameterTypeEnum.REFERENCE, CollectionUtil.newSet(Constants.PARAMQUALIFIER_MISSING));
ourParamTypes.put(CompositeParam.class, RestSearchParameterType.COMPOSITE);
ourParamTypes.put(CompositeOrListParam.class, RestSearchParameterType.COMPOSITE);
ourParamTypes.put(CompositeAndListParam.class, RestSearchParameterType.COMPOSITE);
ourParamQualifiers.put(RestSearchParameterType.COMPOSITE, CollectionUtil.newSet(Constants.PARAMQUALIFIER_MISSING, EMPTY_STRING));
ourParamTypes.put(CompositeParam.class, RestSearchParameterTypeEnum.COMPOSITE);
ourParamTypes.put(CompositeOrListParam.class, RestSearchParameterTypeEnum.COMPOSITE);
ourParamTypes.put(CompositeAndListParam.class, RestSearchParameterTypeEnum.COMPOSITE);
ourParamQualifiers.put(RestSearchParameterTypeEnum.COMPOSITE, CollectionUtil.newSet(Constants.PARAMQUALIFIER_MISSING, EMPTY_STRING));
}
private List<Class<? extends IQueryParameterType>> myCompositeTypes;
@ -138,7 +137,7 @@ public class SearchParameter extends BaseQueryParameter {
private String myDescription;
private String myName;
private IParamBinder myParamBinder;
private RestSearchParameterType myParamType;
private RestSearchParameterTypeEnum myParamType;
private Set<String> myQualifierBlacklist;
private Set<String> myQualifierWhitelist;
private boolean myRequired;
@ -188,7 +187,7 @@ public class SearchParameter extends BaseQueryParameter {
}
@Override
public RestSearchParameterType getParamType() {
public RestSearchParameterTypeEnum getParamType() {
return myParamType;
}
@ -283,12 +282,12 @@ public class SearchParameter extends BaseQueryParameter {
myParamBinder = new QueryParameterAndBinder((Class<? extends IQueryParameterAnd<?>>) type, myCompositeTypes);
} else if (String.class.equals(type)) {
myParamBinder = new StringBinder();
myParamType = RestSearchParameterType.STRING;
myParamType = RestSearchParameterTypeEnum.STRING;
} else {
throw new ConfigurationException("Unsupported data type for parameter: " + type.getCanonicalName());
}
RestSearchParameterType typeEnum = ourParamTypes.get(type);
RestSearchParameterTypeEnum typeEnum = ourParamTypes.get(type);
if (typeEnum != null) {
Set<String> builtInQualifiers = ourParamQualifiers.get(typeEnum);
if (builtInQualifiers != null) {
@ -310,15 +309,15 @@ public class SearchParameter extends BaseQueryParameter {
if (myParamType != null) {
// ok
} else if (StringDt.class.isAssignableFrom(type)) {
myParamType = RestSearchParameterType.STRING;
myParamType = RestSearchParameterTypeEnum.STRING;
} else if (QualifiedDateParam.class.isAssignableFrom(type)) {
myParamType = RestSearchParameterType.DATE;
myParamType = RestSearchParameterTypeEnum.DATE;
} else if (BaseIdentifierDt.class.isAssignableFrom(type)) {
myParamType = RestSearchParameterType.TOKEN;
myParamType = RestSearchParameterTypeEnum.TOKEN;
} else if (BaseQuantityDt.class.isAssignableFrom(type)) {
myParamType = RestSearchParameterType.QUANTITY;
myParamType = RestSearchParameterTypeEnum.QUANTITY;
} else if (ReferenceParam.class.isAssignableFrom(type)) {
myParamType = RestSearchParameterType.REFERENCE;
myParamType = RestSearchParameterTypeEnum.REFERENCE;
} else {
throw new ConfigurationException("Unknown search parameter type: " + type);
}

View File

@ -25,8 +25,8 @@ import java.util.List;
import ca.uhn.fhir.model.api.IQueryParameterAnd;
import ca.uhn.fhir.model.api.IQueryParameterOr;
import ca.uhn.fhir.model.dstu.valueset.RestSearchParameterType;
import ca.uhn.fhir.rest.method.QualifiedParamList;
import ca.uhn.fhir.rest.method.RestSearchParameterTypeEnum;
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
public abstract class BaseAndListParam<T extends IQueryParameterOr<?>> implements IQueryParameterAnd<T> {
@ -47,7 +47,7 @@ public abstract class BaseAndListParam<T extends IQueryParameterOr<?>> implement
}
}
public abstract RestSearchParameterType getSearchParamType();
public abstract RestSearchParameterTypeEnum getSearchParamType();
abstract T newInstance();

View File

@ -31,11 +31,11 @@ import org.apache.commons.lang3.StringUtils;
import org.hl7.fhir.instance.model.IBaseResource;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.dstu.valueset.RestSearchParameterType;
import ca.uhn.fhir.rest.method.IParameter;
import ca.uhn.fhir.rest.method.QualifiedParamList;
import ca.uhn.fhir.rest.method.Request;
import ca.uhn.fhir.rest.method.RequestDetails;
import ca.uhn.fhir.rest.method.RestSearchParameterTypeEnum;
import ca.uhn.fhir.rest.method.SearchMethodBinding;
import ca.uhn.fhir.rest.method.SearchMethodBinding.QualifierDetails;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
@ -49,7 +49,7 @@ public abstract class BaseQueryParameter implements IParameter {
public abstract String getName();
public abstract RestSearchParameterType getParamType();
public abstract RestSearchParameterTypeEnum getParamType();
/**
* Returns null if blacklist is "none"

View File

@ -1,7 +1,7 @@
package ca.uhn.fhir.rest.param;
import ca.uhn.fhir.model.api.IQueryParameterType;
import ca.uhn.fhir.model.dstu.valueset.RestSearchParameterType;
import ca.uhn.fhir.rest.method.RestSearchParameterTypeEnum;
/*
* #%L
@ -41,8 +41,8 @@ public class CompositeAndListParam<A extends IQueryParameterType, B extends IQue
}
@Override
public RestSearchParameterType getSearchParamType() {
return RestSearchParameterType.COMPOSITE;
public RestSearchParameterTypeEnum getSearchParamType() {
return RestSearchParameterTypeEnum.COMPOSITE;
}

View File

@ -1,6 +1,6 @@
package ca.uhn.fhir.rest.param;
import ca.uhn.fhir.model.dstu.valueset.RestSearchParameterType;
import ca.uhn.fhir.rest.method.RestSearchParameterTypeEnum;
/*
* #%L
@ -31,8 +31,8 @@ public class DateAndListParam extends BaseAndListParam<DateOrListParam> {
}
@Override
public RestSearchParameterType getSearchParamType() {
return RestSearchParameterType.DATE;
public RestSearchParameterTypeEnum getSearchParamType() {
return RestSearchParameterTypeEnum.DATE;
}
}

View File

@ -1,6 +1,6 @@
package ca.uhn.fhir.rest.param;
import ca.uhn.fhir.model.dstu.valueset.RestSearchParameterType;
import ca.uhn.fhir.rest.method.RestSearchParameterTypeEnum;
/*
* #%L
@ -31,8 +31,8 @@ public class NumberAndListParam extends BaseAndListParam<NumberOrListParam> {
}
@Override
public RestSearchParameterType getSearchParamType() {
return RestSearchParameterType.NUMBER;
public RestSearchParameterTypeEnum getSearchParamType() {
return RestSearchParameterTypeEnum.NUMBER;
}
}

View File

@ -1,6 +1,6 @@
package ca.uhn.fhir.rest.param;
import ca.uhn.fhir.model.dstu.valueset.RestSearchParameterType;
import ca.uhn.fhir.rest.method.RestSearchParameterTypeEnum;
/*
* #%L
@ -31,8 +31,8 @@ public class QuantityAndListParam extends BaseAndListParam<QuantityOrListParam>
}
@Override
public RestSearchParameterType getSearchParamType() {
return RestSearchParameterType.QUANTITY;
public RestSearchParameterTypeEnum getSearchParamType() {
return RestSearchParameterTypeEnum.QUANTITY;
}
}

View File

@ -1,6 +1,6 @@
package ca.uhn.fhir.rest.param;
import ca.uhn.fhir.model.dstu.valueset.RestSearchParameterType;
import ca.uhn.fhir.rest.method.RestSearchParameterTypeEnum;
/*
* #%L
@ -31,8 +31,8 @@ public class ReferenceAndListParam extends BaseAndListParam<ReferenceOrListParam
}
@Override
public RestSearchParameterType getSearchParamType() {
return RestSearchParameterType.REFERENCE;
public RestSearchParameterTypeEnum getSearchParamType() {
return RestSearchParameterTypeEnum.REFERENCE;
}

View File

@ -1,6 +1,6 @@
package ca.uhn.fhir.rest.param;
import ca.uhn.fhir.model.dstu.valueset.RestSearchParameterType;
import ca.uhn.fhir.rest.method.RestSearchParameterTypeEnum;
/*
* #%L
@ -31,8 +31,8 @@ public class StringAndListParam extends BaseAndListParam<StringOrListParam> {
}
@Override
public RestSearchParameterType getSearchParamType() {
return RestSearchParameterType.STRING;
public RestSearchParameterTypeEnum getSearchParamType() {
return RestSearchParameterTypeEnum.STRING;
}
}

View File

@ -1,6 +1,6 @@
package ca.uhn.fhir.rest.param;
import ca.uhn.fhir.model.dstu.valueset.RestSearchParameterType;
import ca.uhn.fhir.rest.method.RestSearchParameterTypeEnum;
/*
* #%L
@ -31,8 +31,8 @@ public class TokenAndListParam extends BaseAndListParam<TokenOrListParam> {
}
@Override
public RestSearchParameterType getSearchParamType() {
return RestSearchParameterType.TOKEN;
public RestSearchParameterTypeEnum getSearchParamType() {
return RestSearchParameterTypeEnum.TOKEN;
}

View File

@ -1,6 +1,6 @@
package ca.uhn.fhir.rest.param;
import ca.uhn.fhir.model.dstu.valueset.RestSearchParameterType;
import ca.uhn.fhir.rest.method.RestSearchParameterTypeEnum;
/*
* #%L
@ -31,8 +31,8 @@ public class UriAndListParam extends BaseAndListParam<UriOrListParam> {
}
@Override
public RestSearchParameterType getSearchParamType() {
return RestSearchParameterType.URI;
public RestSearchParameterTypeEnum getSearchParamType() {
return RestSearchParameterTypeEnum.URI;
}
}

View File

@ -90,7 +90,6 @@ import ca.uhn.fhir.model.api.Tag;
import ca.uhn.fhir.model.api.TagList;
import ca.uhn.fhir.model.base.composite.BaseCodingDt;
import ca.uhn.fhir.model.base.composite.BaseResourceReferenceDt;
import ca.uhn.fhir.model.dstu.valueset.RestSearchParameterType;
import ca.uhn.fhir.model.dstu2.composite.MetaDt;
import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.model.primitive.InstantDt;
@ -98,6 +97,7 @@ import ca.uhn.fhir.parser.DataFormatException;
import ca.uhn.fhir.parser.IParser;
import ca.uhn.fhir.rest.method.MethodUtil;
import ca.uhn.fhir.rest.method.QualifiedParamList;
import ca.uhn.fhir.rest.method.RestSearchParameterTypeEnum;
import ca.uhn.fhir.rest.server.IBundleProvider;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
@ -160,7 +160,7 @@ public abstract class BaseFhirDao implements IDao {
RuntimeResourceDefinition def = getContext().getResourceDefinition(theResource);
for (RuntimeSearchParam nextSpDef : def.getSearchParams()) {
if (nextSpDef.getParamType() != RestSearchParameterType.REFERENCE) {
if (nextSpDef.getParamType() != RestSearchParameterTypeEnum.REFERENCE) {
continue;
}

View File

@ -96,7 +96,6 @@ import ca.uhn.fhir.model.base.composite.BaseResourceReferenceDt;
import ca.uhn.fhir.model.dstu.resource.OperationOutcome;
import ca.uhn.fhir.model.dstu.valueset.IssueSeverityEnum;
import ca.uhn.fhir.model.dstu.valueset.QuantityCompararatorEnum;
import ca.uhn.fhir.model.dstu.valueset.RestSearchParameterType;
import ca.uhn.fhir.model.dstu2.composite.CodingDt;
import ca.uhn.fhir.model.dstu2.composite.MetaDt;
import ca.uhn.fhir.model.primitive.IdDt;
@ -105,6 +104,7 @@ import ca.uhn.fhir.model.primitive.UriDt;
import ca.uhn.fhir.model.valueset.BundleEntrySearchModeEnum;
import ca.uhn.fhir.rest.api.SortOrderEnum;
import ca.uhn.fhir.rest.api.SortSpec;
import ca.uhn.fhir.rest.method.RestSearchParameterTypeEnum;
import ca.uhn.fhir.rest.param.CompositeParam;
import ca.uhn.fhir.rest.param.DateParam;
import ca.uhn.fhir.rest.param.DateRangeParam;
@ -1150,7 +1150,7 @@ public abstract class BaseFhirResourceDao<T extends IResource> extends BaseFhirD
if (sp == null) {
throw new ConfigurationException("Unknown search param on resource[" + myResourceName + "] for secondary key[" + mySecondaryPrimaryKeyParamName + "]");
}
if (sp.getParamType() != RestSearchParameterType.TOKEN) {
if (sp.getParamType() != RestSearchParameterTypeEnum.TOKEN) {
throw new ConfigurationException("Search param on resource[" + myResourceName + "] for secondary key[" + mySecondaryPrimaryKeyParamName
+ "] is not a token type, only token is supported");
}
@ -1278,7 +1278,9 @@ public abstract class BaseFhirResourceDao<T extends IResource> extends BaseFhirD
CriteriaQuery<Tuple> cq = builder.createTupleQuery();
Root<ResourceTable> from = cq.from(ResourceTable.class);
cq.multiselect(from.get("myId").as(Long.class));
cq.where(builder.equal(from.get("myResourceType"), myResourceName));
Predicate typeEquals = builder.equal(from.get("myResourceType"), myResourceName);
Predicate notDeleted = builder.isNotNull(from.get("myDeleted"));
cq.where(builder.and(typeEquals, notDeleted));
TypedQuery<Tuple> query = myEntityManager.createQuery(cq);
for (Tuple next : query.getResultList()) {

View File

@ -59,11 +59,11 @@ import ca.uhn.fhir.model.dstu.composite.HumanNameDt;
import ca.uhn.fhir.model.dstu.composite.IdentifierDt;
import ca.uhn.fhir.model.dstu.composite.PeriodDt;
import ca.uhn.fhir.model.dstu.composite.QuantityDt;
import ca.uhn.fhir.model.dstu.valueset.RestSearchParameterType;
import ca.uhn.fhir.model.primitive.BaseDateTimeDt;
import ca.uhn.fhir.model.primitive.IntegerDt;
import ca.uhn.fhir.model.primitive.StringDt;
import ca.uhn.fhir.model.primitive.UriDt;
import ca.uhn.fhir.rest.method.RestSearchParameterTypeEnum;
class SearchParamExtractorDstu1 extends BaseSearchParamExtractor implements ISearchParamExtractor {
@ -77,7 +77,7 @@ class SearchParamExtractorDstu1 extends BaseSearchParamExtractor implements ISea
RuntimeResourceDefinition def = getContext().getResourceDefinition(theResource);
for (RuntimeSearchParam nextSpDef : def.getSearchParams()) {
if (nextSpDef.getParamType() != RestSearchParameterType.DATE) {
if (nextSpDef.getParamType() != RestSearchParameterTypeEnum.DATE) {
continue;
}
@ -134,7 +134,7 @@ class SearchParamExtractorDstu1 extends BaseSearchParamExtractor implements ISea
RuntimeResourceDefinition def = getContext().getResourceDefinition(theResource);
for (RuntimeSearchParam nextSpDef : def.getSearchParams()) {
if (nextSpDef.getParamType() != RestSearchParameterType.NUMBER) {
if (nextSpDef.getParamType() != RestSearchParameterTypeEnum.NUMBER) {
continue;
}
@ -231,7 +231,7 @@ class SearchParamExtractorDstu1 extends BaseSearchParamExtractor implements ISea
RuntimeResourceDefinition def = getContext().getResourceDefinition(theResource);
for (RuntimeSearchParam nextSpDef : def.getSearchParams()) {
if (nextSpDef.getParamType() != RestSearchParameterType.QUANTITY) {
if (nextSpDef.getParamType() != RestSearchParameterTypeEnum.QUANTITY) {
continue;
}
@ -281,7 +281,7 @@ class SearchParamExtractorDstu1 extends BaseSearchParamExtractor implements ISea
RuntimeResourceDefinition def = getContext().getResourceDefinition(theResource);
for (RuntimeSearchParam nextSpDef : def.getSearchParams()) {
if (nextSpDef.getParamType() != RestSearchParameterType.STRING) {
if (nextSpDef.getParamType() != RestSearchParameterTypeEnum.STRING) {
continue;
}
@ -369,7 +369,7 @@ class SearchParamExtractorDstu1 extends BaseSearchParamExtractor implements ISea
RuntimeResourceDefinition def = getContext().getResourceDefinition(theResource);
for (RuntimeSearchParam nextSpDef : def.getSearchParams()) {
if (nextSpDef.getParamType() != RestSearchParameterType.TOKEN) {
if (nextSpDef.getParamType() != RestSearchParameterTypeEnum.TOKEN) {
continue;
}

View File

@ -49,7 +49,6 @@ import ca.uhn.fhir.model.api.IDatatype;
import ca.uhn.fhir.model.api.IPrimitiveDatatype;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.base.composite.BaseHumanNameDt;
import ca.uhn.fhir.model.dstu.valueset.RestSearchParameterType;
import ca.uhn.fhir.model.dstu2.composite.AddressDt;
import ca.uhn.fhir.model.dstu2.composite.CodeableConceptDt;
import ca.uhn.fhir.model.dstu2.composite.CodingDt;
@ -65,6 +64,7 @@ import ca.uhn.fhir.model.primitive.BaseDateTimeDt;
import ca.uhn.fhir.model.primitive.IntegerDt;
import ca.uhn.fhir.model.primitive.StringDt;
import ca.uhn.fhir.model.primitive.UriDt;
import ca.uhn.fhir.rest.method.RestSearchParameterTypeEnum;
class SearchParamExtractorDstu2 extends BaseSearchParamExtractor implements ISearchParamExtractor {
@ -84,7 +84,7 @@ class SearchParamExtractorDstu2 extends BaseSearchParamExtractor implements ISea
RuntimeResourceDefinition def = getContext().getResourceDefinition(theResource);
for (RuntimeSearchParam nextSpDef : def.getSearchParams()) {
if (nextSpDef.getParamType() != RestSearchParameterType.DATE) {
if (nextSpDef.getParamType() != RestSearchParameterTypeEnum.DATE) {
continue;
}
@ -147,7 +147,7 @@ class SearchParamExtractorDstu2 extends BaseSearchParamExtractor implements ISea
RuntimeResourceDefinition def = getContext().getResourceDefinition(theResource);
for (RuntimeSearchParam nextSpDef : def.getSearchParams()) {
if (nextSpDef.getParamType() != RestSearchParameterType.NUMBER) {
if (nextSpDef.getParamType() != RestSearchParameterTypeEnum.NUMBER) {
continue;
}
@ -250,7 +250,7 @@ class SearchParamExtractorDstu2 extends BaseSearchParamExtractor implements ISea
RuntimeResourceDefinition def = getContext().getResourceDefinition(theResource);
for (RuntimeSearchParam nextSpDef : def.getSearchParams()) {
if (nextSpDef.getParamType() != RestSearchParameterType.QUANTITY) {
if (nextSpDef.getParamType() != RestSearchParameterTypeEnum.QUANTITY) {
continue;
}
@ -306,7 +306,7 @@ class SearchParamExtractorDstu2 extends BaseSearchParamExtractor implements ISea
RuntimeResourceDefinition def = getContext().getResourceDefinition(theResource);
for (RuntimeSearchParam nextSpDef : def.getSearchParams()) {
if (nextSpDef.getParamType() != RestSearchParameterType.STRING) {
if (nextSpDef.getParamType() != RestSearchParameterTypeEnum.STRING) {
continue;
}
@ -400,7 +400,7 @@ class SearchParamExtractorDstu2 extends BaseSearchParamExtractor implements ISea
RuntimeResourceDefinition def = getContext().getResourceDefinition(theResource);
for (RuntimeSearchParam nextSpDef : def.getSearchParams()) {
if (nextSpDef.getParamType() != RestSearchParameterType.TOKEN) {
if (nextSpDef.getParamType() != RestSearchParameterTypeEnum.TOKEN) {
continue;
}

View File

@ -1753,21 +1753,6 @@ public class FhirResourceDaoDstu2Test {
}
@Test
public void testSearchWithNoResults() {
IBundleProvider value = ourDeviceDao.search(new SearchParameterMap());
for (IResource next : value.getResources(0, value.size())) {
ourDeviceDao.delete(next.getId());
}
value = ourDeviceDao.search(new SearchParameterMap());
assertEquals(0, value.size());
List<IResource> res = value.getResources(0, 0);
assertTrue(res.isEmpty());
}
@Test
public void testSortByDate() {
Patient p = new Patient();
@ -2343,4 +2328,31 @@ public class FhirResourceDaoDstu2Test {
FhirSystemDaoDstu2Test.doDeleteEverything(ourSystemDao);
}
@Test
public void testSearchWithNoResults() {
Device dev = new Device();
dev.addIdentifier().setSystem("Foo");
ourDeviceDao.create(dev);
IBundleProvider value = ourDeviceDao.search(new SearchParameterMap());
ourLog.info("Initial size: " + value.size());
for (IResource next : value.getResources(0, value.size())) {
ourLog.info("Deleting: {}", next.getId());
ourDeviceDao.delete(next.getId());
}
value = ourDeviceDao.search(new SearchParameterMap());
if (value.size() > 0) {
ourLog.info("Found: " + (value.getResources(0, 1).get(0).getId()));
fail(ourFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(value.getResources(0, 1).get(0)));
}
assertEquals(0, value.size());
List<IResource> res = value.getResources(0, 0);
assertTrue(res.isEmpty());
}
}

View File

@ -8,7 +8,7 @@ import org.junit.Test;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.dstu.resource.Patient;
import ca.uhn.fhir.model.dstu.valueset.RestSearchParameterType;
import ca.uhn.fhir.rest.method.RestSearchParameterTypeEnum;
import com.google.common.collect.ImmutableSet;
import com.google.common.reflect.ClassPath;
@ -30,7 +30,7 @@ public class NameChanges {
RuntimeResourceDefinition def = ctx.getResourceDefinition((Class<? extends IResource>) Class.forName(classInfo.getName()));
for (RuntimeSearchParam nextParam : def.getSearchParams()) {
if (nextParam.getParamType() == RestSearchParameterType.COMPOSITE) {
if (nextParam.getParamType() == RestSearchParameterTypeEnum.COMPOSITE) {
continue;
}

View File

@ -26,9 +26,9 @@ import ca.uhn.fhir.model.api.Bundle;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.dstu.resource.Conformance;
import ca.uhn.fhir.model.dstu.resource.Patient;
import ca.uhn.fhir.model.dstu.valueset.RestSearchParameterType;
import ca.uhn.fhir.narrative.DefaultThymeleafNarrativeGenerator;
import ca.uhn.fhir.rest.annotation.Search;
import ca.uhn.fhir.rest.method.RestSearchParameterTypeEnum;
import ca.uhn.fhir.rest.param.StringAndListParam;
import ca.uhn.fhir.rest.param.StringOrListParam;
import ca.uhn.fhir.rest.param.StringParam;
@ -173,8 +173,8 @@ public class DynamicSearchTest {
@Override
public List<RuntimeSearchParam> getSearchParameters() {
ArrayList<RuntimeSearchParam> retVal = new ArrayList<RuntimeSearchParam>();
retVal.add(new RuntimeSearchParam("param1", "This is the first parameter", "Patient.param1", RestSearchParameterType.STRING));
retVal.add(new RuntimeSearchParam("param2", "This is the second parameter", "Patient.param2", RestSearchParameterType.DATE));
retVal.add(new RuntimeSearchParam("param1", "This is the first parameter", "Patient.param1", RestSearchParameterTypeEnum.STRING));
retVal.add(new RuntimeSearchParam("param2", "This is the second parameter", "Patient.param2", RestSearchParameterTypeEnum.DATE));
return retVal;
}

View File

@ -64,11 +64,14 @@
reference if the base matches the base for the server giving
the response.
</action>
<action type="fix" fix="131">
<action type="fix" fix="130">
Narrative generator incorrectly sets the Resource.text.status to 'generated' even if the
given resource type does not have a template (and therefore no narrative is actually generated).
Thanks to Bill de Beaubien for reporting!
</action>
<action type="fix">
Searching in JPA server with no search parameter returns deleted resources when it should exclude them.
</action>
</release>
<release version="0.9" date="2015-Mar-14">
<action type="add">