From f94f2fde65dd04716252ea05472696da4c2e1eab Mon Sep 17 00:00:00 2001 From: Tadgh Date: Thu, 30 Apr 2020 11:32:22 -0700 Subject: [PATCH] Add delegating setters and getters to DaoConfig (#1825) --- .../ca/uhn/fhir/jpa/api/config/DaoConfig.java | 38 +++++++++++++++++++ .../fhir/jpa/model/entity/ModelConfig.java | 9 +++-- 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/hapi-fhir-jpaserver-api/src/main/java/ca/uhn/fhir/jpa/api/config/DaoConfig.java b/hapi-fhir-jpaserver-api/src/main/java/ca/uhn/fhir/jpa/api/config/DaoConfig.java index b79ca0c13d5..d2807f4cc35 100644 --- a/hapi-fhir-jpaserver-api/src/main/java/ca/uhn/fhir/jpa/api/config/DaoConfig.java +++ b/hapi-fhir-jpaserver-api/src/main/java/ca/uhn/fhir/jpa/api/config/DaoConfig.java @@ -3,6 +3,7 @@ package ca.uhn.fhir.jpa.api.config; import ca.uhn.fhir.jpa.api.model.WarmCacheEntry; import ca.uhn.fhir.jpa.model.entity.ModelConfig; import ca.uhn.fhir.jpa.model.entity.ResourceEncodingEnum; +import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamDate; import ca.uhn.fhir.jpa.searchparam.SearchParamConstants; import ca.uhn.fhir.rest.api.SearchTotalModeEnum; import com.google.common.annotations.VisibleForTesting; @@ -932,6 +933,43 @@ public class DaoConfig { myModelConfig.setAllowExternalReferences(theAllowExternalReferences); } + /** + *

+ * Should searches use the integer field {@code SP_VALUE_LOW_DATE_ORDINAL} and {@code SP_VALUE_HIGH_DATE_ORDINAL} in + * {@link ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamDate} when resolving searches where all predicates are using + * precision of {@link ca.uhn.fhir.model.api.TemporalPrecisionEnum#DAY}. + * + * For example, if enabled, the search of {@code Observation?date=2020-02-25} will cause the date to be collapsed down to an + * ordinal {@code 20200225}. It would then be compared against {@link ResourceIndexedSearchParamDate#getValueLowDateOrdinal()} + * and {@link ResourceIndexedSearchParamDate#getValueHighDateOrdinal()} + *

+ * Default is {@literal true} beginning in HAPI FHIR 5.0 + *

+ * + * @since 5.0 + */ + public void setUseOrdinalDatesForDayPrecisionSearches(boolean theUseOrdinalDates) { + myModelConfig.setUseOrdinalDatesForDayPrecisionSearches(theUseOrdinalDates); + } + + /** + *

+ * Should searches use the integer field {@code SP_VALUE_LOW_DATE_ORDINAL} and {@code SP_VALUE_HIGH_DATE_ORDINAL} in + * {@link ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamDate} when resolving searches where all predicates are using + * precision of {@link ca.uhn.fhir.model.api.TemporalPrecisionEnum#DAY}. + * + * For example, if enabled, the search of {@code Observation?date=2020-02-25} will cause the date to be collapsed down to an + * integer representing the ordinal date {@code 20200225}. It would then be compared against {@link ResourceIndexedSearchParamDate#getValueLowDateOrdinal()} + * and {@link ResourceIndexedSearchParamDate#getValueHighDateOrdinal()} + *

+ * Default is {@literal true} beginning in HAPI FHIR 5.0 + *

+ * + * @since 5.0 + */ + public boolean getUseOrdinalDatesForDayPrecisionSearches() { + return myModelConfig.getUseOrdinalDatesForDayPrecisionSearches(); + } /** * @see #setAllowInlineMatchUrlReferences(boolean) */ diff --git a/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/ModelConfig.java b/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/ModelConfig.java index f7616f58f1b..7aa6deb8ced 100644 --- a/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/ModelConfig.java +++ b/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/ModelConfig.java @@ -381,10 +381,10 @@ public class ModelConfig { * ordinal {@code 20200225}. It would then be compared against {@link ResourceIndexedSearchParamDate#getValueLowDateOrdinal()} * and {@link ResourceIndexedSearchParamDate#getValueHighDateOrdinal()} *

- * Default is {@literal true} beginning in HAPI FHIR 4.3. + * Default is {@literal true} beginning in HAPI FHIR 5.0 *

* - * @since 4.3 + * @since 5.0 */ public void setUseOrdinalDatesForDayPrecisionSearches(boolean theUseOrdinalDates) { myUseOrdinalDatesForDayPrecisionSearches = theUseOrdinalDates; @@ -400,14 +400,15 @@ public class ModelConfig { * integer representing the ordinal date {@code 20200225}. It would then be compared against {@link ResourceIndexedSearchParamDate#getValueLowDateOrdinal()} * and {@link ResourceIndexedSearchParamDate#getValueHighDateOrdinal()} *

- * Default is {@literal true} beginning in HAPI FHIR 4.3. + * Default is {@literal true} beginning in HAPI FHIR 5.0 *

* - * @since 4.3 + * @since 5.0 */ public boolean getUseOrdinalDatesForDayPrecisionSearches() { return myUseOrdinalDatesForDayPrecisionSearches; } + private static void validateTreatBaseUrlsAsLocal(String theUrl) { Validate.notBlank(theUrl, "Base URL must not be null or empty");