diff --git a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/registry/BaseSearchParamRegistry.java b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/registry/BaseSearchParamRegistry.java index e7ba4cf9c05..90c3eaba50a 100644 --- a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/registry/BaseSearchParamRegistry.java +++ b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/registry/BaseSearchParamRegistry.java @@ -9,9 +9,9 @@ package ca.uhn.fhir.jpa.searchparam.registry; * 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. @@ -215,25 +215,9 @@ public abstract class BaseSearchParamRegistry implemen @PostConstruct public void postConstruct() { - Map> resourceNameToSearchParams = new HashMap<>(); - - Set resourceNames = myFhirContext.getResourceNames(); - - for (String resourceName : resourceNames) { - RuntimeResourceDefinition nextResDef = myFhirContext.getResourceDefinition(resourceName); - String nextResourceName = nextResDef.getName(); - HashMap nameToParam = new HashMap<>(); - resourceNameToSearchParams.put(nextResourceName, nameToParam); - - for (RuntimeSearchParam nextSp : nextResDef.getSearchParams()) { - nameToParam.put(nextSp.getName(), nextSp); - } - } - - myBuiltInSearchParams = Collections.unmodifiableMap(resourceNameToSearchParams); + myBuiltInSearchParams = createBuiltInSearchParamMap(myFhirContext); } - public int doRefresh(long theRefreshInterval) { if (System.currentTimeMillis() - theRefreshInterval > myLastRefresh) { StopWatch sw = new StopWatch(); @@ -380,4 +364,22 @@ public abstract class BaseSearchParamRegistry implemen requiresActiveSearchParams(); return Collections.unmodifiableMap(myActiveSearchParams); } + + public static Map> createBuiltInSearchParamMap(FhirContext theFhirContext) { + Map> resourceNameToSearchParams = new HashMap<>(); + + Set resourceNames = theFhirContext.getResourceNames(); + + for (String resourceName : resourceNames) { + RuntimeResourceDefinition nextResDef = theFhirContext.getResourceDefinition(resourceName); + String nextResourceName = nextResDef.getName(); + HashMap nameToParam = new HashMap<>(); + resourceNameToSearchParams.put(nextResourceName, nameToParam); + + for (RuntimeSearchParam nextSp : nextResDef.getSearchParams()) { + nameToParam.put(nextSp.getName(), nextSp); + } + } + return Collections.unmodifiableMap(resourceNameToSearchParams); + } }