Fix failing test with new filter logic

This commit is contained in:
jamesagnew 2018-08-11 14:01:53 -04:00
parent ea1f17762e
commit 8284734a07
2 changed files with 83 additions and 75 deletions

View File

@ -1,5 +1,24 @@
package ca.uhn.fhir.jpa.dao;
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;
import ca.uhn.fhir.model.api.Include;
import ca.uhn.fhir.rest.api.Constants;
import ca.uhn.fhir.rest.api.SortOrderEnum;
import ca.uhn.fhir.rest.api.SortSpec;
import ca.uhn.fhir.rest.param.DateParam;
import ca.uhn.fhir.rest.param.DateRangeParam;
import ca.uhn.fhir.util.ObjectUtil;
import ca.uhn.fhir.util.UrlUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Validate;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.util.*;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
/*
@ -21,20 +40,6 @@ import static org.apache.commons.lang3.StringUtils.isNotBlank;
* limitations under the License.
* #L%
*/
import java.util.*;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Validate;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.*;
import ca.uhn.fhir.rest.api.*;
import ca.uhn.fhir.rest.param.DateParam;
import ca.uhn.fhir.rest.param.DateRangeParam;
import ca.uhn.fhir.util.ObjectUtil;
import ca.uhn.fhir.util.UrlUtil;
public class SearchParameterMap extends LinkedHashMap<String, List<List<? extends IQueryParameterType>>> {
@ -158,10 +163,18 @@ public class SearchParameterMap extends LinkedHashMap<String, List<List<? extend
return myCount;
}
public void setCount(Integer theCount) {
myCount = theCount;
}
public EverythingModeEnum getEverythingMode() {
return myEverythingMode;
}
public void setEverythingMode(EverythingModeEnum theConsolidateMatches) {
myEverythingMode = theConsolidateMatches;
}
public Set<Include> getIncludes() {
if (myIncludes == null) {
myIncludes = new HashSet<Include>();
@ -169,6 +182,10 @@ public class SearchParameterMap extends LinkedHashMap<String, List<List<? extend
return myIncludes;
}
public void setIncludes(Set<Include> theIncludes) {
myIncludes = theIncludes;
}
/**
* Returns null if there is no last updated value
*/
@ -181,6 +198,10 @@ public class SearchParameterMap extends LinkedHashMap<String, List<List<? extend
return myLastUpdated;
}
public void setLastUpdated(DateRangeParam theLastUpdated) {
myLastUpdated = theLastUpdated;
}
/**
* Returns null if there is no last updated value, and removes the lastupdated
* value from this map
@ -199,6 +220,19 @@ public class SearchParameterMap extends LinkedHashMap<String, List<List<? extend
return myLoadSynchronousUpTo;
}
/**
* If set, tells the server to load these results synchronously, and not to load
* more than X results. Note that setting this to a value will also set
* {@link #setLoadSynchronous(boolean)} to true
*/
public SearchParameterMap setLoadSynchronousUpTo(Integer theLoadSynchronousUpTo) {
myLoadSynchronousUpTo = theLoadSynchronousUpTo;
if (myLoadSynchronousUpTo != null) {
setLoadSynchronous(true);
}
return this;
}
public Set<Include> getRevIncludes() {
if (myRevIncludes == null) {
myRevIncludes = new HashSet<>();
@ -206,10 +240,18 @@ public class SearchParameterMap extends LinkedHashMap<String, List<List<? extend
return myRevIncludes;
}
public void setRevIncludes(Set<Include> theRevIncludes) {
myRevIncludes = theRevIncludes;
}
public SortSpec getSort() {
return mySort;
}
public void setSort(SortSpec theSort) {
mySort = theSort;
}
/**
* This will only return true if all parameters have no modifier of any kind
*/
@ -234,22 +276,6 @@ public class SearchParameterMap extends LinkedHashMap<String, List<List<? extend
return myLoadSynchronous;
}
public void setCount(Integer theCount) {
myCount = theCount;
}
public void setEverythingMode(EverythingModeEnum theConsolidateMatches) {
myEverythingMode = theConsolidateMatches;
}
public void setIncludes(Set<Include> theIncludes) {
myIncludes = theIncludes;
}
public void setLastUpdated(DateRangeParam theLastUpdated) {
myLastUpdated = theLastUpdated;
}
/**
* If set, tells the server to load these results synchronously, and not to load
* more than X results
@ -259,27 +285,6 @@ public class SearchParameterMap extends LinkedHashMap<String, List<List<? extend
return this;
}
/**
* If set, tells the server to load these results synchronously, and not to load
* more than X results. Note that setting this to a value will also set
* {@link #setLoadSynchronous(boolean)} to true
*/
public SearchParameterMap setLoadSynchronousUpTo(Integer theLoadSynchronousUpTo) {
myLoadSynchronousUpTo = theLoadSynchronousUpTo;
if (myLoadSynchronousUpTo != null) {
setLoadSynchronous(true);
}
return this;
}
public void setRevIncludes(Set<Include> theRevIncludes) {
myRevIncludes = theRevIncludes;
}
public void setSort(SortSpec theSort) {
mySort = theSort;
}
public String toNormalizedQueryString(FhirContext theCtx) {
StringBuilder b = new StringBuilder();
@ -439,7 +444,10 @@ public class SearchParameterMap extends LinkedHashMap<String, List<List<? extend
/*
* Don't reorder! We rely on the ordinals
*/
ENCOUNTER_INSTANCE(false, true, true), ENCOUNTER_TYPE(false, true, false), PATIENT_INSTANCE(true, false, true), PATIENT_TYPE(true, false, false);
ENCOUNTER_INSTANCE(false, true, true),
ENCOUNTER_TYPE(false, true, false),
PATIENT_INSTANCE(true, false, true),
PATIENT_TYPE(true, false, false);
private final boolean myEncounter;
@ -447,7 +455,7 @@ public class SearchParameterMap extends LinkedHashMap<String, List<List<? extend
private final boolean myPatient;
private EverythingModeEnum(boolean thePatient, boolean theEncounter, boolean theInstance) {
EverythingModeEnum(boolean thePatient, boolean theEncounter, boolean theInstance) {
assert thePatient ^ theEncounter;
myPatient = thePatient;
myEncounter = theEncounter;

View File

@ -1503,7 +1503,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
ourLog.info(output);
List<IIdType> ids = toUnqualifiedVersionlessIds(myFhirCtx.newXmlParser().parseResource(Bundle.class, output));
ourLog.info(ids.toString());
assertThat(ids, containsInAnyOrder(pId, cId));
assertThat(ids, containsInAnyOrder(pId, cId, oId));
} finally {
response.close();
}
@ -1518,7 +1518,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
ourLog.info(output);
List<IIdType> ids = toUnqualifiedVersionlessIds(myFhirCtx.newXmlParser().parseResource(Bundle.class, output));
ourLog.info(ids.toString());
assertThat(ids, containsInAnyOrder(pId, cId));
assertThat(ids, containsInAnyOrder(pId, cId, oId));
} finally {
response.close();
}