From 77a98ca4380e4d97412bc9c506d7fd5dbac62176 Mon Sep 17 00:00:00 2001 From: jvi Date: Fri, 27 Nov 2020 14:49:53 +0100 Subject: [PATCH] Converted to named indicies in order to support easier environment configuration for both tester and IG setup --- .../uhn/fhir/jpa/starter/AppProperties.java | 20 +++++++------ .../jpa/starter/BaseJpaRestfulServer.java | 15 ++++------ .../fhir/jpa/starter/FhirTesterConfig.java | 12 ++++---- src/main/resources/application.yaml | 29 ++++++++++--------- 4 files changed, 39 insertions(+), 37 deletions(-) diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java b/src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java index 2835656..b5d7b8d 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java @@ -7,8 +7,10 @@ import ca.uhn.fhir.rest.api.EncodingEnum; import java.util.ArrayList; import java.util.List; +import java.util.Map; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import org.hl7.fhir.r4.model.Bundle; import org.springframework.boot.context.properties.ConfigurationProperties; @@ -54,12 +56,12 @@ public class AppProperties { private List allowed_bundle_types = null; private Validation validation = new Validation(); - private List tester = ImmutableList.of(new Tester()); + private Map tester = ImmutableMap.of("home", new Tester()); private Logger logger = new Logger(); private Subscription subscription = new Subscription(); private Cors cors = null; private Partitioning partitioning = null; - private List implementationGuides = null; + private Map implementationGuides = null; public Integer getDefer_indexing_for_codesystems_of_size() { return defer_indexing_for_codesystems_of_size; @@ -69,11 +71,11 @@ public class AppProperties { this.defer_indexing_for_codesystems_of_size = defer_indexing_for_codesystems_of_size; } - public List getImplementationGuides() { + public Map getImplementationGuides() { return implementationGuides; } - public void setImplementationGuides(List implementationGuides) { + public void setImplementationGuides(Map implementationGuides) { this.implementationGuides = implementationGuides; } @@ -363,11 +365,11 @@ public class AppProperties { this.reuse_cached_search_results_millis = reuse_cached_search_results_millis; } - public List getTester() { + public Map getTester() { return tester; } - public void setTester(List tester) { + public void setTester(Map tester) { this.tester = tester; } @@ -437,7 +439,7 @@ public class AppProperties { public static class Tester { - private String id = "home"; + //private String id = "home"; private String name = "Local Tester"; private String server_address = "http://localhost:8080/fhir"; private Boolean refuse_to_fetch_third_party_urls = true; @@ -451,14 +453,14 @@ public class AppProperties { this.fhir_version = fhir_version; } - public String getId() { +/* public String getId() { return id; } public void setId(String id) { this.id = id; } - +*/ public String getName() { return name; } diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/BaseJpaRestfulServer.java b/src/main/java/ca/uhn/fhir/jpa/starter/BaseJpaRestfulServer.java index 41743a3..18c4a87 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/BaseJpaRestfulServer.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/BaseJpaRestfulServer.java @@ -38,10 +38,7 @@ import org.springframework.http.HttpHeaders; import org.springframework.web.cors.CorsConfiguration; import javax.servlet.ServletException; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Optional; +import java.util.*; import java.util.stream.Collectors; public class BaseJpaRestfulServer extends RestfulServer { @@ -345,12 +342,12 @@ public class BaseJpaRestfulServer extends RestfulServer { } if (appProperties.getImplementationGuides() != null) { - List guides = appProperties.getImplementationGuides(); - for (AppProperties.ImplementationGuide guide : guides) { + Map guides = appProperties.getImplementationGuides(); + for (Map.Entry guide : guides.entrySet()) { packageInstallerSvc.install(new PackageInstallationSpec() - .setPackageUrl(guide.getUrl()) - .setName(guide.getName()) - .setVersion(guide.getVersion()) + .setPackageUrl(guide.getValue().getUrl()) + .setName(guide.getValue().getName()) + .setVersion(guide.getValue().getVersion()) .setInstallMode(PackageInstallationSpec.InstallModeEnum.STORE_AND_INSTALL)); } } diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/FhirTesterConfig.java b/src/main/java/ca/uhn/fhir/jpa/starter/FhirTesterConfig.java index 45a7808..7adf8bf 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/FhirTesterConfig.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/FhirTesterConfig.java @@ -36,15 +36,15 @@ public class FhirTesterConfig { @Bean public TesterConfig testerConfig(AppProperties appProperties) { TesterConfig retVal = new TesterConfig(); - appProperties.getTester().stream().forEach(t -> { + appProperties.getTester().entrySet().stream().forEach(t -> { retVal .addServer() - .withId(t.getId()) - .withFhirVersion(t.getFhir_version()) - .withBaseUrl(t.getServer_address()) - .withName(t.getName()); + .withId(t.getKey()) + .withFhirVersion(t.getValue().getFhir_version()) + .withBaseUrl(t.getValue().getServer_address()) + .withName(t.getValue().getName()); retVal.setRefuseToFetchThirdPartyUrls( - t.getRefuse_to_fetch_third_party_urls()); + t.getValue().getRefuse_to_fetch_third_party_urls()); }); return retVal; diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index abb95b2..3a964f1 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -1,6 +1,7 @@ spring: datasource: - url: 'jdbc:h2:file:./target/database/h2' + #url: 'jdbc:h2:file:./target/database/h2' + url: jdbc:h2:mem:test_mem username: sa password: null driverClassName: org.h2.Driver @@ -30,14 +31,16 @@ hapi: ### This is the FHIR version. Choose between, DSTU2, DSTU3, R4 or R5 fhir_version: R4 # defer_indexing_for_codesystems_of_size: 101 -# implementationguides: -# - -# url: https://build.fhir.org/ig/hl7dk/dk-medcom/branches/corrections/package.tgz -# name: dk.fhir.ig.medcom-core -# version: 0.8.0 -# - -# name: hl7.fhir.uv.ips -# version: 0.3.0 + implementationguides: + #example from registry (packages.fhir.org) + swiss: + name: swiss.mednet.fhir + version: 0.8.0 + #example not from registry + ips_0_3_0: + url: https://build.fhir.org/ig/HL7/fhir-ips/package.tgz + name: hl7.fhir.uv.ips + version: 1.0.0 #supported_resource_types: # - Patient @@ -86,14 +89,14 @@ hapi: # retain_cached_searches_mins: 60 # reuse_cached_search_results_millis: 60000 tester: - - - id: home + + home: name: Local Tester server_address: 'http://localhost:8080/fhir' refuse_to_fetch_third_party_urls: false fhir_version: R4 - - - id: global + + global: name: Global Tester server_address: "http://hapi.fhir.org/baseR4" refuse_to_fetch_third_party_urls: false