From 0be636c169344523b44587ebc94645523edf1823 Mon Sep 17 00:00:00 2001 From: Levi <78334846+muhammad-levi@users.noreply.github.com> Date: Tue, 5 Dec 2023 03:10:21 +0700 Subject: [PATCH] Affected Issue(s): #606 (#612) What this commit has achieved: 1. Externalized location of "mdm-rules.json" in the `AppProperties` 2. More info about the `ResourceLoader` interface is available at https://docs.spring.io/spring-framework/reference/core/resources.html#resources-resourceloader --- .../java/ca/uhn/fhir/jpa/starter/AppProperties.java | 11 ++++++++++- .../java/ca/uhn/fhir/jpa/starter/mdm/MdmConfig.java | 2 +- src/main/resources/application.yaml | 1 + 3 files changed, 12 insertions(+), 2 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 a724ef2..afd25e1 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java @@ -27,6 +27,7 @@ public class AppProperties { private Boolean ips_enabled = false; private Boolean openapi_enabled = false; private Boolean mdm_enabled = false; + private String mdm_rules_json_location = "mdm-rules.json"; private boolean advanced_lucene_indexing = false; private boolean enable_index_of_type = false; private Boolean allow_cascading_deletes = false; @@ -191,7 +192,15 @@ public class AppProperties { this.mdm_enabled = mdm_enabled; } - public Cors getCors() { + public String getMdm_rules_json_location() { + return mdm_rules_json_location; +} + +public void setMdm_rules_json_location(String mdm_rules_json_location) { + this.mdm_rules_json_location = mdm_rules_json_location; +} + +public Cors getCors() { return cors; } diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/mdm/MdmConfig.java b/src/main/java/ca/uhn/fhir/jpa/starter/mdm/MdmConfig.java index 48e8480..2e8a1f1 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/mdm/MdmConfig.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/mdm/MdmConfig.java @@ -28,7 +28,7 @@ public class MdmConfig { IMdmSettings mdmSettings(@Autowired MdmRuleValidator theMdmRuleValidator, AppProperties appProperties) throws IOException { DefaultResourceLoader resourceLoader = new DefaultResourceLoader(); - Resource resource = resourceLoader.getResource("mdm-rules.json"); + Resource resource = resourceLoader.getResource(appProperties.getMdm_rules_json_location()); String json = IOUtils.toString(resource.getInputStream(), StandardCharsets.UTF_8); return new MdmSettings(theMdmRuleValidator) .setEnabled(appProperties.getMdm_enabled()) diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index 49d12c8..469b701 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -137,6 +137,7 @@ hapi: # graphql_enabled: true narrative_enabled: false mdm_enabled: false + mdm_rules_json_location: "mdm-rules.json" # local_base_urls: # - https://hapi.fhir.org/baseR4 # partitioning: