Refactoring the registry a bit
@@ -215,25 +215,9 @@ public abstract class BaseSearchParamRegistry<SP extends IBaseResource> implemen
@PostConstruct
public void postConstruct() {
- Map<String, Map<String, RuntimeSearchParam>> resourceNameToSearchParams = new HashMap<>();
-
- Set<String> resourceNames = myFhirContext.getResourceNames();
-
- for (String resourceName : resourceNames) {
- RuntimeResourceDefinition nextResDef = myFhirContext.getResourceDefinition(resourceName);
- String nextResourceName = nextResDef.getName();
- HashMap<String, RuntimeSearchParam> nameToParam = new HashMap<>();
- resourceNameToSearchParams.put(nextResourceName, nameToParam);
-
- for (RuntimeSearchParam nextSp : nextResDef.getSearchParams()) {
- nameToParam.put(nextSp.getName(), nextSp);
- }
+ myBuiltInSearchParams = createBuiltInSearchParamMap(myFhirContext);
}
- myBuiltInSearchParams = Collections.unmodifiableMap(resourceNameToSearchParams);
- }
-
-
public int doRefresh(long theRefreshInterval) {
if (System.currentTimeMillis() - theRefreshInterval > myLastRefresh) {
StopWatch sw = new StopWatch();
@@ -380,4 +364,22 @@ public abstract class BaseSearchParamRegistry<SP extends IBaseResource> implemen
requiresActiveSearchParams();
return Collections.unmodifiableMap(myActiveSearchParams);
}
+
+ public static Map<String, Map<String, RuntimeSearchParam>> createBuiltInSearchParamMap(FhirContext theFhirContext) {
+ Map<String, Map<String, RuntimeSearchParam>> resourceNameToSearchParams = new HashMap<>();
+
+ Set<String> resourceNames = theFhirContext.getResourceNames();
+
+ for (String resourceName : resourceNames) {
+ RuntimeResourceDefinition nextResDef = theFhirContext.getResourceDefinition(resourceName);
+ String nextResourceName = nextResDef.getName();
+ HashMap<String, RuntimeSearchParam> nameToParam = new HashMap<>();
+ resourceNameToSearchParams.put(nextResourceName, nameToParam);
+
+ for (RuntimeSearchParam nextSp : nextResDef.getSearchParams()) {
+ nameToParam.put(nextSp.getName(), nextSp);
+ }
+ }
+ return Collections.unmodifiableMap(resourceNameToSearchParams);
+ }
}
