diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseSearchParamRegistry.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseSearchParamRegistry.java index 8608d26e428..068cc8873d8 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseSearchParamRegistry.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseSearchParamRegistry.java @@ -53,6 +53,16 @@ public abstract class BaseSearchParamRegistry implements ISearchParamRegistry { // nothing by default } + @Override + public RuntimeSearchParam getActiveSearchParam(String theResourceName, String theParamName) { + RuntimeSearchParam retVal = null; + Map params = getActiveSearchParams().get(theResourceName); + if (params != null) { + retVal = params.get(theParamName); + } + return retVal; + } + @Override public Map> getActiveSearchParams() { return myBuiltInSearchParams; diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/ISearchParamRegistry.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/ISearchParamRegistry.java index 324d26038e1..611ba169e05 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/ISearchParamRegistry.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/ISearchParamRegistry.java @@ -32,4 +32,9 @@ public interface ISearchParamRegistry { Map getActiveSearchParams(String theResourceName); + /** + * @return Returns {@literal null} if no match + */ + RuntimeSearchParam getActiveSearchParam(String theResourceName, String theParamName); + } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchBuilder.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchBuilder.java index 7cff1643bb2..e607c61083f 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchBuilder.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchBuilder.java @@ -41,7 +41,6 @@ import org.apache.commons.lang3.tuple.Pair; import org.hl7.fhir.instance.model.api.IAnyResource; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IIdType; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.support.TransactionCallback; @@ -96,7 +95,7 @@ public class SearchBuilder { private IFulltextSearchSvc mySearchDao; private Search mySearchEntity; private ISearchResultDao mySearchResultDao; - private ISearchParamRegistry mySerarchParamRegistry; + private ISearchParamRegistry mySearchParamRegistry; private IHapiTerminologySvc myTerminologySvc; @@ -111,7 +110,7 @@ public class SearchBuilder { myResourceIndexedSearchParamUriDao = theResourceIndexedSearchParamUriDao; myForcedIdDao = theForcedIdDao; myTerminologySvc = theTerminologySvc; - mySerarchParamRegistry = theSearchParamRegistry; + mySearchParamRegistry = theSearchParamRegistry; } private void addPredicateComposite(RuntimeSearchParam theParamDef, List theNextAnd) { @@ -1816,7 +1815,6 @@ public class SearchBuilder { doInitializeSearch(); // RuntimeResourceDefinition resourceDef = myContext.getResourceDefinition(myResourceType); - Map searchParams = mySerarchParamRegistry.getActiveSearchParams(myResourceName); for (Entry>> nextParamEntry : params.entrySet()) { String nextParamName = nextParamEntry.getKey(); @@ -1871,7 +1869,7 @@ public class SearchBuilder { } else { - RuntimeSearchParam nextParamDef = searchParams.get(nextParamName); + RuntimeSearchParam nextParamDef = mySearchParamRegistry.getActiveSearchParam(myResourceName, nextParamName); if (nextParamDef != null) { switch (nextParamDef.getParamType()) { case DATE: diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/SearchParamExtractorDstu3Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/SearchParamExtractorDstu3Test.java index 811c477e2cb..3e46a73cac5 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/SearchParamExtractorDstu3Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/SearchParamExtractorDstu3Test.java @@ -2,7 +2,6 @@ package ca.uhn.fhir.jpa.dao.dstu3; import static org.junit.Assert.assertEquals; -import java.util.Collection; import java.util.HashMap; import java.util.Map; import java.util.Set; @@ -63,6 +62,11 @@ public class SearchParamExtractorDstu3Test { public Map> getActiveSearchParams() { throw new UnsupportedOperationException(); } + + @Override + public RuntimeSearchParam getActiveSearchParam(String theResourceName, String theParamName) { + throw new UnsupportedOperationException(); + } }; SearchParamExtractorDstu3 extractor = new SearchParamExtractorDstu3(ourCtx, ourValidationSupport, searchParamRegistry);