001/*- 002 * #%L 003 * HAPI FHIR Storage api 004 * %% 005 * Copyright (C) 2014 - 2024 Smile CDR, Inc. 006 * %% 007 * Licensed under the Apache License, Version 2.0 (the "License"); 008 * you may not use this file except in compliance with the License. 009 * You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, software 014 * distributed under the License is distributed on an "AS IS" BASIS, 015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 016 * See the License for the specific language governing permissions and 017 * limitations under the License. 018 * #L% 019 */ 020package ca.uhn.fhir.jpa.validation; 021 022import jakarta.annotation.Nonnull; 023import org.hl7.fhir.r5.utils.validation.constants.ReferenceValidationPolicy; 024import org.thymeleaf.util.Validate; 025 026public class ValidationSettings { 027 028 private ReferenceValidationPolicy myLocalReferenceValidationDefaultPolicy = ReferenceValidationPolicy.IGNORE; 029 030 /** 031 * Supplies a default policy for validating local references. Default is {@literal IResourceValidator.ReferenceValidationPolicy.IGNORE}. 032 * <p> 033 * Note that this setting can have a measurable impact on validation performance, as it will cause reference targets 034 * to be resolved during validation. In other words, if a resource has a reference to (for example) "Patient/123", the 035 * resource with that ID will be loaded from the database during validation. 036 * </p> 037 * 038 * @since 5.1.0 039 */ 040 @Nonnull 041 public ReferenceValidationPolicy getLocalReferenceValidationDefaultPolicy() { 042 return myLocalReferenceValidationDefaultPolicy; 043 } 044 045 /** 046 * Supplies a default policy for validating local references. Default is {@literal IResourceValidator.ReferenceValidationPolicy.IGNORE}. 047 * <p> 048 * Note that this setting can have a measurable impact on validation performance, as it will cause reference targets 049 * to be resolved during validation. In other words, if a resource has a reference to (for example) "Patient/123", the 050 * resource with that ID will be loaded from the database during validation. 051 * </p> 052 * 053 * @since 5.1.0 054 */ 055 public void setLocalReferenceValidationDefaultPolicy( 056 @Nonnull ReferenceValidationPolicy theLocalReferenceValidationDefaultPolicy) { 057 Validate.notNull( 058 theLocalReferenceValidationDefaultPolicy, "theLocalReferenceValidationDefaultPolicy must not be null"); 059 myLocalReferenceValidationDefaultPolicy = theLocalReferenceValidationDefaultPolicy; 060 } 061}