From 9d8fc4d2e59d7af4166113325f3e663d77024a09 Mon Sep 17 00:00:00 2001 From: "Gerlach, Winfried" Date: Wed, 12 Jul 2023 17:53:58 +0200 Subject: [PATCH] #563 Add configuration for auto-versioning references --- .../java/ca/uhn/fhir/jpa/starter/AppProperties.java | 11 +++++++++-- .../jpa/starter/common/FhirServerConfigCommon.java | 7 ++++--- .../uhn/fhir/jpa/starter/common/FhirTesterConfig.java | 2 +- src/main/resources/application.yaml | 2 ++ 4 files changed, 16 insertions(+), 6 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 50e501c..3ed7679 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java @@ -11,9 +11,11 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties import org.springframework.context.annotation.Configuration; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.Set; @ConfigurationProperties(prefix = "hapi.fhir") @Configuration @@ -32,6 +34,7 @@ public class AppProperties { private Boolean allow_multiple_delete = false; private Boolean allow_override_default_search_params = true; private Boolean auto_create_placeholder_reference_targets = false; + private final Set auto_version_reference_at_paths = new HashSet<>(); private Boolean dao_scheduling_enabled = true; private Boolean delete_expunge_enabled = false; private Boolean enable_index_missing_fields = false; @@ -84,7 +87,7 @@ public class AppProperties { private Integer bundle_batch_pool_size = 20; private Integer bundle_batch_pool_max_size = 100; - private final List local_base_urls = new ArrayList<>(); + private final Set local_base_urls = new HashSet<>(); private final List custom_interceptor_classes = new ArrayList<>(); @@ -306,6 +309,10 @@ public class AppProperties { this.auto_create_placeholder_reference_targets = auto_create_placeholder_reference_targets; } + public Set getAuto_version_reference_at_paths() { + return auto_version_reference_at_paths; + } + public Integer getDefault_page_size() { return default_page_size; } @@ -570,7 +577,7 @@ public class AppProperties { this.bundle_batch_pool_max_size = bundle_batch_pool_max_size; } - public List getLocal_base_urls() { + public Set getLocal_base_urls() { return local_base_urls; } diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/common/FhirServerConfigCommon.java b/src/main/java/ca/uhn/fhir/jpa/starter/common/FhirServerConfigCommon.java index 12d7a8a..6a93161 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/common/FhirServerConfigCommon.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/common/FhirServerConfigCommon.java @@ -25,7 +25,6 @@ import org.springframework.context.annotation.Primary; import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; import org.springframework.transaction.annotation.EnableTransactionManagement; -import java.util.HashSet; import java.util.stream.Collectors; /** @@ -47,6 +46,7 @@ public class FhirServerConfigCommon { ourLog.info("Server configured to " + (appProperties.getExpunge_enabled() ? "enable" : "disable") + " expunges"); ourLog.info("Server configured to " + (appProperties.getAllow_override_default_search_params() ? "allow" : "deny") + " overriding default search params"); ourLog.info("Server configured to " + (appProperties.getAuto_create_placeholder_reference_targets() ? "allow" : "disable") + " auto-creating placeholder references"); + ourLog.info("Server configured to auto-version references at paths {}", appProperties.getAuto_version_reference_at_paths()); if (appProperties.getSubscription().getEmail() != null) { AppProperties.Subscription.Email email = appProperties.getSubscription().getEmail(); @@ -84,6 +84,7 @@ public class FhirServerConfigCommon { jpaStorageSettings.setIndexMissingFields(appProperties.getEnable_index_missing_fields() ? StorageSettings.IndexEnabledEnum.ENABLED : StorageSettings.IndexEnabledEnum.DISABLED); jpaStorageSettings.setAutoCreatePlaceholderReferenceTargets(appProperties.getAuto_create_placeholder_reference_targets()); + jpaStorageSettings.setAutoVersionReferenceAtPaths(appProperties.getAuto_version_reference_at_paths()); jpaStorageSettings.setEnforceReferentialIntegrityOnWrite(appProperties.getEnforce_referential_integrity_on_write()); jpaStorageSettings.setEnforceReferentialIntegrityOnDelete(appProperties.getEnforce_referential_integrity_on_delete()); jpaStorageSettings.setAllowContainsSearches(appProperties.getAllow_contains_searches()); @@ -125,9 +126,9 @@ public class FhirServerConfigCommon { jpaStorageSettings.setFilterParameterEnabled(appProperties.getFilter_search_enabled()); jpaStorageSettings.setAdvancedHSearchIndexing(appProperties.getAdvanced_lucene_indexing()); - jpaStorageSettings.setTreatBaseUrlsAsLocal(new HashSet<>(appProperties.getLocal_base_urls())); + jpaStorageSettings.setTreatBaseUrlsAsLocal(appProperties.getLocal_base_urls()); - if (appProperties.getLastn_enabled()) { + if (appProperties.getLastn_enabled()) { jpaStorageSettings.setLastNEnabled(true); } diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/common/FhirTesterConfig.java b/src/main/java/ca/uhn/fhir/jpa/starter/common/FhirTesterConfig.java index cb28659..2bc9aa2 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/common/FhirTesterConfig.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/common/FhirTesterConfig.java @@ -26,7 +26,7 @@ public class FhirTesterConfig { * server, as well as one public server. If you are creating a project to * deploy somewhere else, you might choose to only put your own server's * address here. - * + *

* Note the use of the ${serverBase} variable below. This will be replaced with * the base URL as reported by the server itself. Often for a simple Tomcat * (or other container) installation, this will end up being something diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index 9b1e118..cd2dbb0 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -99,6 +99,8 @@ hapi: # allow_multiple_delete: true # allow_override_default_search_params: true # auto_create_placeholder_reference_targets: false + ### tells the server to automatically append the current version of the target to references at these paths + # auto_version_reference_at_paths: Device.patient, Device.location, Device.parent, DeviceMetric.parent, DeviceMetric.source, Observation.device, Observation.subject # cr_enabled: true # ips_enabled: false # default_encoding: JSON