Merged the rel_5_3_0 branch into this Branch to pick up the MDM changes.
This commit is contained in:
@@ -23,6 +23,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
public class AppProperties {
|
||||
|
||||
private Boolean cql_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;
|
||||
@@ -31,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;
|
||||
@@ -97,6 +99,14 @@ public class AppProperties {
|
||||
this.cql_enabled = cql_enabled;
|
||||
}
|
||||
|
||||
public Boolean getMdm_enabled() {
|
||||
return mdm_enabled;
|
||||
}
|
||||
|
||||
public void setMdm_enabled(Boolean mdm_enabled) {
|
||||
this.mdm_enabled = mdm_enabled;
|
||||
}
|
||||
|
||||
public Cors getCors() {
|
||||
return cors;
|
||||
}
|
||||
@@ -244,7 +254,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,5 +1,6 @@
|
||||
package ca.uhn.fhir.jpa.starter;
|
||||
|
||||
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;
|
||||
@@ -23,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})
|
||||
@Import({SubscriptionSubmitterConfig.class, SubscriptionProcessorConfig.class, SubscriptionChannelConfig.class, WebsocketDispatcherConfig.class, MdmConfig.class})
|
||||
public class Application extends SpringBootServletInitializer {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
@@ -11,6 +11,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;
|
||||
@@ -365,6 +366,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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,16 @@
|
||||
package ca.uhn.fhir.jpa.starter;
|
||||
|
||||
import ca.uhn.fhir.jpa.search.HapiLuceneAnalysisConfigurer;
|
||||
import ca.uhn.fhir.jpa.search.elastic.ElasticsearchHibernatePropertiesBuilder;
|
||||
import org.hibernate.search.elasticsearch.cfg.ElasticsearchIndexStatus;
|
||||
import org.hibernate.search.elasticsearch.cfg.IndexSchemaManagementStrategy;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.elasticsearch.action.admin.indices.stats.IndexStats;
|
||||
import org.hibernate.search.backend.elasticsearch.index.IndexStatus;
|
||||
import org.hibernate.search.backend.lucene.cfg.LuceneBackendSettings;
|
||||
import org.hibernate.search.backend.lucene.cfg.LuceneIndexSettings;
|
||||
import org.hibernate.search.engine.cfg.BackendSettings;
|
||||
import org.hibernate.search.mapper.orm.automaticindexing.session.AutomaticIndexingSynchronizationStrategyNames;
|
||||
import org.hibernate.search.mapper.orm.cfg.HibernateOrmMapperSettings;
|
||||
import org.hibernate.search.mapper.orm.schema.management.SchemaManagementStrategyName;
|
||||
import org.springframework.core.env.CompositePropertySource;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
import org.springframework.core.env.EnumerablePropertySource;
|
||||
@@ -19,7 +27,6 @@ public class EnvironmentHelper {
|
||||
Properties properties = new Properties();
|
||||
|
||||
if (environment.getProperty("spring.jpa.properties", String.class) == null) {
|
||||
properties.put("hibernate.search.model_mapping", "ca.uhn.fhir.jpa.search.LuceneSearchMappingFactory");
|
||||
properties.put("hibernate.format_sql", "false");
|
||||
properties.put("hibernate.show_sql", "false");
|
||||
properties.put("hibernate.hbm2ddl.auto", "update");
|
||||
@@ -28,11 +35,18 @@ public class EnvironmentHelper {
|
||||
properties.put("hibernate.cache.use_second_level_cache", "false");
|
||||
properties.put("hibernate.cache.use_structured_entries", "false");
|
||||
properties.put("hibernate.cache.use_minimal_puts", "false");
|
||||
properties.put("hibernate.search.default.directory_provider", "filesystem");
|
||||
properties.put("hibernate.search.default.indexBase", "target/lucenefiles");
|
||||
properties.put("hibernate.search.lucene_version", "LUCENE_CURRENT");
|
||||
|
||||
properties.put(BackendSettings.backendKey(LuceneIndexSettings.DIRECTORY_TYPE), "local-filesystem");
|
||||
properties.put(BackendSettings.backendKey(LuceneIndexSettings.DIRECTORY_ROOT), "target/lucenefiles");
|
||||
properties.put(BackendSettings.backendKey(BackendSettings.TYPE), "lucene");
|
||||
properties.put(BackendSettings.backendKey(LuceneBackendSettings.ANALYSIS_CONFIGURER), HapiLuceneAnalysisConfigurer.class.getName());
|
||||
properties.put(BackendSettings.backendKey(LuceneBackendSettings.LUCENE_VERSION), "LUCENE_CURRENT");
|
||||
|
||||
//Set this value to true in the properties to enable lucene.
|
||||
properties.put(HibernateOrmMapperSettings.ENABLED, environment.getProperty("spring.jpa.properties.hibernate.search.enabled", "false"));
|
||||
|
||||
} else {
|
||||
Arrays.asList(environment.getProperty("spring.jpa.properties", String.class).split(" ")).stream().forEach(s ->
|
||||
Arrays.asList(environment.getProperty("spring.jpa.properties", String.class).split(" ")).stream().filter(s -> !StringUtils.isEmpty(s)).forEach(s ->
|
||||
{
|
||||
String[] values = s.split("=");
|
||||
properties.put(values[0], values[1]);
|
||||
@@ -42,9 +56,9 @@ public class EnvironmentHelper {
|
||||
if (environment.getProperty("elasticsearch.enabled", Boolean.class) != null
|
||||
&& environment.getProperty("elasticsearch.enabled", Boolean.class) == true ){
|
||||
ElasticsearchHibernatePropertiesBuilder builder = new ElasticsearchHibernatePropertiesBuilder();
|
||||
ElasticsearchIndexStatus requiredIndexStatus = environment.getProperty("elasticsearch.required_index_status", ElasticsearchIndexStatus.class);
|
||||
IndexStatus requiredIndexStatus = environment.getProperty("elasticsearch.required_index_status", IndexStatus.class);
|
||||
if (requiredIndexStatus == null) {
|
||||
builder.setRequiredIndexStatus(ElasticsearchIndexStatus.YELLOW);
|
||||
builder.setRequiredIndexStatus(IndexStatus.YELLOW);
|
||||
} else {
|
||||
builder.setRequiredIndexStatus(requiredIndexStatus);
|
||||
}
|
||||
@@ -52,18 +66,19 @@ public class EnvironmentHelper {
|
||||
builder.setRestUrl(getElasticsearchServerUrl(environment));
|
||||
builder.setUsername(getElasticsearchServerUsername(environment));
|
||||
builder.setPassword(getElasticsearchServerPassword(environment));
|
||||
IndexSchemaManagementStrategy indexSchemaManagementStrategy = environment.getProperty("elasticsearch.schema_management_strategy", IndexSchemaManagementStrategy.class);
|
||||
builder.setProtocol(getElasticsearchServerProtocol(environment));
|
||||
SchemaManagementStrategyName indexSchemaManagementStrategy = environment.getProperty("elasticsearch.schema_management_strategy", SchemaManagementStrategyName.class);
|
||||
if (indexSchemaManagementStrategy == null) {
|
||||
builder.setIndexSchemaManagementStrategy(IndexSchemaManagementStrategy.CREATE);
|
||||
builder.setIndexSchemaManagementStrategy(SchemaManagementStrategyName.CREATE);
|
||||
} else {
|
||||
builder.setIndexSchemaManagementStrategy(indexSchemaManagementStrategy);
|
||||
}
|
||||
// pretty_print_json_log: false
|
||||
Boolean refreshAfterWrite = environment.getProperty("elasticsearch.debug.refresh_after_write", Boolean.class);
|
||||
if (refreshAfterWrite == null) {
|
||||
builder.setDebugRefreshAfterWrite(false);
|
||||
if (refreshAfterWrite == null || refreshAfterWrite == false) {
|
||||
builder.setDebugIndexSyncStrategy(AutomaticIndexingSynchronizationStrategyNames.ASYNC);
|
||||
} else {
|
||||
builder.setDebugRefreshAfterWrite(refreshAfterWrite);
|
||||
builder.setDebugIndexSyncStrategy(AutomaticIndexingSynchronizationStrategyNames.READ_SYNC);
|
||||
}
|
||||
// pretty_print_json_log: false
|
||||
Boolean prettyPrintJsonLog = environment.getProperty("elasticsearch.debug.pretty_print_json_log", Boolean.class);
|
||||
@@ -74,7 +89,6 @@ public class EnvironmentHelper {
|
||||
}
|
||||
builder.apply(properties);
|
||||
}
|
||||
|
||||
return properties;
|
||||
}
|
||||
|
||||
@@ -82,7 +96,11 @@ public class EnvironmentHelper {
|
||||
return environment.getProperty("elasticsearch.rest_url", String.class);
|
||||
}
|
||||
|
||||
public static String getElasticsearchServerUsername(ConfigurableEnvironment environment) {
|
||||
public static String getElasticsearchServerProtocol(ConfigurableEnvironment environment) {
|
||||
return environment.getProperty("elasticsearch.protocol", String.class, "http");
|
||||
}
|
||||
|
||||
public static String getElasticsearchServerUsername(ConfigurableEnvironment environment) {
|
||||
return environment.getProperty("elasticsearch.username");
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package ca.uhn.fhir.jpa.starter;
|
||||
import ca.uhn.fhir.jpa.api.config.DaoConfig;
|
||||
import ca.uhn.fhir.jpa.binstore.DatabaseBlobBinaryStorageSvcImpl;
|
||||
import ca.uhn.fhir.jpa.binstore.IBinaryStorageSvc;
|
||||
import ca.uhn.fhir.jpa.config.HibernateDialectProvider;
|
||||
import ca.uhn.fhir.jpa.config.HibernatePropertiesProvider;
|
||||
import ca.uhn.fhir.jpa.model.config.PartitionSettings;
|
||||
import ca.uhn.fhir.jpa.model.entity.ModelConfig;
|
||||
import ca.uhn.fhir.jpa.subscription.channel.subscription.SubscriptionDeliveryHandlerFactory;
|
||||
@@ -132,10 +132,17 @@ public class FhirServerConfigCommon {
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
@Lazy
|
||||
public RepositoryValidationInterceptorFactory repositoryValidationInterceptorFactory() {
|
||||
return new RepositoryValidationInterceptorFactory();
|
||||
}
|
||||
|
||||
|
||||
@Primary
|
||||
@Bean
|
||||
public HibernateDialectProvider jpaStarterDialectProvider(LocalContainerEntityManagerFactoryBean myEntityManagerFactory) {
|
||||
return new JpaHibernateDialectProvider(myEntityManagerFactory);
|
||||
public HibernatePropertiesProvider jpaStarterDialectProvider(LocalContainerEntityManagerFactoryBean myEntityManagerFactory) {
|
||||
return new JpaHibernatePropertiesProvider(myEntityManagerFactory);
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -69,8 +69,14 @@ public class FhirServerConfigR4 extends BaseJavaConfigR4 {
|
||||
@Bean()
|
||||
public ElasticsearchSvcImpl elasticsearchSvc() {
|
||||
if (EnvironmentHelper.isElasticsearchEnabled(configurableEnvironment)) {
|
||||
String elasticsearchUrl = EnvironmentHelper.getElasticsearchServerUrl(configurableEnvironment);
|
||||
String elasticsearchHost = elasticsearchUrl.substring(elasticsearchUrl.indexOf("://")+3, elasticsearchUrl.lastIndexOf(":"));
|
||||
String elasticsearchUrl = EnvironmentHelper.getElasticsearchServerUrl(configurableEnvironment);
|
||||
String elasticsearchHost;
|
||||
if (elasticsearchUrl.startsWith("http")) {
|
||||
elasticsearchHost = elasticsearchUrl.substring(elasticsearchUrl.indexOf("://") + 3, elasticsearchUrl.lastIndexOf(":"));
|
||||
} else {
|
||||
elasticsearchHost = elasticsearchUrl.substring(0, elasticsearchUrl.indexOf(":"));
|
||||
}
|
||||
|
||||
String elasticsearchUsername = EnvironmentHelper.getElasticsearchServerUsername(configurableEnvironment);
|
||||
String elasticsearchPassword = EnvironmentHelper.getElasticsearchServerPassword(configurableEnvironment);
|
||||
int elasticsearchPort = Integer.parseInt(elasticsearchUrl.substring(elasticsearchUrl.lastIndexOf(":")+1));
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package ca.uhn.fhir.jpa.starter;
|
||||
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.jpa.config.HibernateDialectProvider;
|
||||
import ca.uhn.fhir.jpa.config.HibernatePropertiesProvider;
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.engine.jdbc.dialect.internal.StandardDialectResolver;
|
||||
import org.hibernate.engine.jdbc.dialect.spi.DatabaseMetaDataDialectResolutionInfoAdapter;
|
||||
@@ -10,11 +10,11 @@ import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class JpaHibernateDialectProvider extends HibernateDialectProvider {
|
||||
public class JpaHibernatePropertiesProvider extends HibernatePropertiesProvider {
|
||||
|
||||
private final Dialect dialect;
|
||||
|
||||
public JpaHibernateDialectProvider(LocalContainerEntityManagerFactoryBean myEntityManagerFactory) {
|
||||
public JpaHibernatePropertiesProvider(LocalContainerEntityManagerFactoryBean myEntityManagerFactory) {
|
||||
DataSource connection = myEntityManagerFactory.getDataSource();
|
||||
try {
|
||||
dialect = new StandardDialectResolver()
|
||||
@@ -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