Add repository validating interceptor, and update for EMPI->MDM rename
This commit is contained in:
@@ -23,7 +23,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
@EnableConfigurationProperties
|
||||
public class AppProperties {
|
||||
|
||||
private Boolean empi_enabled = false;
|
||||
private Boolean mdm_enabled = false;
|
||||
private Boolean allow_cascading_deletes = false;
|
||||
private Boolean allow_contains_searches = true;
|
||||
private Boolean allow_external_references = false;
|
||||
@@ -32,6 +32,7 @@ public class AppProperties {
|
||||
private Boolean allow_placeholder_references = true;
|
||||
private Boolean auto_create_placeholder_reference_targets = true;
|
||||
private Boolean enable_index_missing_fields = false;
|
||||
private Boolean enable_repository_validating_interceptor = false;
|
||||
private Boolean enforce_referential_integrity_on_delete = true;
|
||||
private Boolean enforce_referential_integrity_on_write = true;
|
||||
private Boolean etag_support_enabled = true;
|
||||
@@ -90,12 +91,12 @@ public class AppProperties {
|
||||
this.partitioning = partitioning;
|
||||
}
|
||||
|
||||
public Boolean getEmpi_enabled() {
|
||||
return empi_enabled;
|
||||
public Boolean getMdm_enabled() {
|
||||
return mdm_enabled;
|
||||
}
|
||||
|
||||
public void setEmpi_enabled(Boolean empi_enabled) {
|
||||
this.empi_enabled = empi_enabled;
|
||||
public void setMdm_enabled(Boolean mdm_enabled) {
|
||||
this.mdm_enabled = mdm_enabled;
|
||||
}
|
||||
|
||||
|
||||
@@ -246,7 +247,15 @@ public class AppProperties {
|
||||
this.enable_index_missing_fields = enable_index_missing_fields;
|
||||
}
|
||||
|
||||
public Boolean getEnforce_referential_integrity_on_delete() {
|
||||
public Boolean getEnable_repository_validating_interceptor() {
|
||||
return enable_repository_validating_interceptor;
|
||||
}
|
||||
|
||||
public void setEnable_repository_validating_interceptor(Boolean theEnable_repository_validating_interceptor) {
|
||||
enable_repository_validating_interceptor = theEnable_repository_validating_interceptor;
|
||||
}
|
||||
|
||||
public Boolean getEnforce_referential_integrity_on_delete() {
|
||||
return enforce_referential_integrity_on_delete;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package ca.uhn.fhir.jpa.starter;
|
||||
|
||||
import ca.uhn.fhir.jpa.empi.EmpiConfig;
|
||||
import ca.uhn.fhir.jpa.mdm.MdmConfig;
|
||||
import ca.uhn.fhir.jpa.starter.annotations.OnEitherVersion;
|
||||
import ca.uhn.fhir.jpa.subscription.channel.config.SubscriptionChannelConfig;
|
||||
import ca.uhn.fhir.jpa.subscription.match.config.SubscriptionProcessorConfig;
|
||||
@@ -24,7 +24,7 @@ import org.springframework.web.servlet.DispatcherServlet;
|
||||
@ServletComponentScan(basePackageClasses = {
|
||||
JpaRestfulServer.class})
|
||||
@SpringBootApplication(exclude = {ElasticsearchRestClientAutoConfiguration.class})
|
||||
@Import({SubscriptionSubmitterConfig.class, SubscriptionProcessorConfig.class, SubscriptionChannelConfig.class, WebsocketDispatcherConfig.class, EmpiConfig.class})
|
||||
@Import({SubscriptionSubmitterConfig.class, SubscriptionProcessorConfig.class, SubscriptionChannelConfig.class, WebsocketDispatcherConfig.class, MdmConfig.class})
|
||||
public class Application extends SpringBootServletInitializer {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
@@ -10,6 +10,7 @@ import ca.uhn.fhir.jpa.api.dao.IFhirSystemDao;
|
||||
import ca.uhn.fhir.jpa.binstore.BinaryStorageInterceptor;
|
||||
import ca.uhn.fhir.jpa.bulk.provider.BulkDataExportProvider;
|
||||
import ca.uhn.fhir.jpa.interceptor.CascadingDeleteInterceptor;
|
||||
import ca.uhn.fhir.jpa.interceptor.validation.RepositoryValidatingInterceptor;
|
||||
import ca.uhn.fhir.jpa.packages.IPackageInstallerSvc;
|
||||
import ca.uhn.fhir.jpa.packages.PackageInstallationSpec;
|
||||
import ca.uhn.fhir.jpa.partition.PartitionManagementProvider;
|
||||
@@ -362,6 +363,12 @@ public class BaseJpaRestfulServer extends RestfulServer {
|
||||
daoConfig.setLastNEnabled(true);
|
||||
}
|
||||
|
||||
// Repository Validating Interceptor
|
||||
if (Boolean.TRUE.equals(appProperties.getEnable_repository_validating_interceptor())) {
|
||||
RepositoryValidationInterceptorFactory repositoryValidationInterceptorFactory = myApplicationContext.getBean(RepositoryValidationInterceptorFactory.class);
|
||||
RepositoryValidatingInterceptor interceptor = repositoryValidationInterceptorFactory.build();
|
||||
interceptorService.registerInterceptor(interceptor);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -132,6 +132,13 @@ public class FhirServerConfigCommon {
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
@Lazy
|
||||
public RepositoryValidationInterceptorFactory repositoryValidationInterceptorFactory() {
|
||||
return new RepositoryValidationInterceptorFactory();
|
||||
}
|
||||
|
||||
|
||||
@Primary
|
||||
@Bean
|
||||
public HibernateDialectProvider jpaStarterDialectProvider(LocalContainerEntityManagerFactoryBean myEntityManagerFactory) {
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package ca.uhn.fhir.jpa.starter;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.jpa.interceptor.validation.IRepositoryValidatingRule;
|
||||
import ca.uhn.fhir.jpa.interceptor.validation.RepositoryValidatingInterceptor;
|
||||
import ca.uhn.fhir.jpa.interceptor.validation.RepositoryValidatingRuleBuilder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class can be customized to enable the {@link ca.uhn.fhir.jpa.interceptor.validation.RepositoryValidatingInterceptor}
|
||||
* on this server.
|
||||
*
|
||||
* The <code>enable_repository_validating_interceptor</code> property must be enabled in <code>application.yaml</code>
|
||||
* in order to use this class.
|
||||
*/
|
||||
public class RepositoryValidationInterceptorFactory {
|
||||
|
||||
@Autowired
|
||||
private ApplicationContext myApplicationContext;
|
||||
@Autowired
|
||||
private FhirContext myFhirContext;
|
||||
|
||||
public RepositoryValidatingInterceptor build() {
|
||||
RepositoryValidatingRuleBuilder ruleBuilder = myApplicationContext.getBean(RepositoryValidatingRuleBuilder.class);
|
||||
|
||||
// Customize the ruleBuilder here to have the rules you want! We will give a simple example
|
||||
// of enabling validation for all Patient resources
|
||||
ruleBuilder.forResourcesOfType("Patient").requireValidationToDeclaredProfiles();
|
||||
|
||||
// Do not customize below this line
|
||||
List<IRepositoryValidatingRule> rules = ruleBuilder.build();
|
||||
return new RepositoryValidatingInterceptor(myFhirContext, rules);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user