Post init provider registerer
This commit is contained in:
@@ -28,66 +28,66 @@ import org.springframework.context.annotation.Import;
|
|||||||
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
|
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
|
||||||
import org.springframework.web.servlet.DispatcherServlet;
|
import org.springframework.web.servlet.DispatcherServlet;
|
||||||
|
|
||||||
@ServletComponentScan(basePackageClasses = {RestfulServer.class})
|
@ServletComponentScan(basePackageClasses = { RestfulServer.class })
|
||||||
@SpringBootApplication(exclude = {ElasticsearchRestClientAutoConfiguration.class, ThymeleafAutoConfiguration.class})
|
@SpringBootApplication(exclude = { ElasticsearchRestClientAutoConfiguration.class, ThymeleafAutoConfiguration.class })
|
||||||
@Import({
|
@Import({
|
||||||
SubscriptionSubmitterConfig.class,
|
StarterCrR4Config.class,
|
||||||
SubscriptionProcessorConfig.class,
|
StarterCrDstu3Config.class,
|
||||||
SubscriptionChannelConfig.class,
|
SubscriptionSubmitterConfig.class,
|
||||||
WebsocketDispatcherConfig.class,
|
SubscriptionProcessorConfig.class,
|
||||||
MdmConfig.class,
|
SubscriptionChannelConfig.class,
|
||||||
JpaBatch2Config.class,
|
WebsocketDispatcherConfig.class,
|
||||||
Batch2JobsConfig.class,
|
MdmConfig.class,
|
||||||
StarterCrR4Config.class,
|
JpaBatch2Config.class,
|
||||||
StarterCrDstu3Config.class
|
Batch2JobsConfig.class
|
||||||
})
|
})
|
||||||
public class Application extends SpringBootServletInitializer {
|
public class Application extends SpringBootServletInitializer {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
SpringApplication.run(Application.class, args);
|
SpringApplication.run(Application.class, args);
|
||||||
|
|
||||||
//Server is now accessible at eg. http://localhost:8080/fhir/metadata
|
// Server is now accessible at eg. http://localhost:8080/fhir/metadata
|
||||||
//UI is now accessible at http://localhost:8080/
|
// UI is now accessible at http://localhost:8080/
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected SpringApplicationBuilder configure(
|
protected SpringApplicationBuilder configure(
|
||||||
SpringApplicationBuilder builder) {
|
SpringApplicationBuilder builder) {
|
||||||
return builder.sources(Application.class);
|
return builder.sources(Application.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
AutowireCapableBeanFactory beanFactory;
|
AutowireCapableBeanFactory beanFactory;
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@Conditional(OnEitherVersion.class)
|
@Conditional(OnEitherVersion.class)
|
||||||
public ServletRegistrationBean hapiServletRegistration(RestfulServer restfulServer) {
|
public ServletRegistrationBean hapiServletRegistration(RestfulServer restfulServer) {
|
||||||
ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean();
|
ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean();
|
||||||
beanFactory.autowireBean(restfulServer);
|
beanFactory.autowireBean(restfulServer);
|
||||||
servletRegistrationBean.setServlet(restfulServer);
|
servletRegistrationBean.setServlet(restfulServer);
|
||||||
servletRegistrationBean.addUrlMappings("/fhir/*");
|
servletRegistrationBean.addUrlMappings("/fhir/*");
|
||||||
servletRegistrationBean.setLoadOnStartup(1);
|
servletRegistrationBean.setLoadOnStartup(1);
|
||||||
|
|
||||||
return servletRegistrationBean;
|
return servletRegistrationBean;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public ServletRegistrationBean overlayRegistrationBean() {
|
public ServletRegistrationBean overlayRegistrationBean() {
|
||||||
|
|
||||||
AnnotationConfigWebApplicationContext annotationConfigWebApplicationContext = new AnnotationConfigWebApplicationContext();
|
AnnotationConfigWebApplicationContext annotationConfigWebApplicationContext = new AnnotationConfigWebApplicationContext();
|
||||||
annotationConfigWebApplicationContext.register(FhirTesterConfig.class);
|
annotationConfigWebApplicationContext.register(FhirTesterConfig.class);
|
||||||
|
|
||||||
DispatcherServlet dispatcherServlet = new DispatcherServlet(
|
DispatcherServlet dispatcherServlet = new DispatcherServlet(
|
||||||
annotationConfigWebApplicationContext);
|
annotationConfigWebApplicationContext);
|
||||||
dispatcherServlet.setContextClass(AnnotationConfigWebApplicationContext.class);
|
dispatcherServlet.setContextClass(AnnotationConfigWebApplicationContext.class);
|
||||||
dispatcherServlet.setContextConfigLocation(FhirTesterConfig.class.getName());
|
dispatcherServlet.setContextConfigLocation(FhirTesterConfig.class.getName());
|
||||||
|
|
||||||
ServletRegistrationBean registrationBean = new ServletRegistrationBean();
|
ServletRegistrationBean registrationBean = new ServletRegistrationBean();
|
||||||
registrationBean.setServlet(dispatcherServlet);
|
registrationBean.setServlet(dispatcherServlet);
|
||||||
registrationBean.addUrlMappings("/*");
|
registrationBean.addUrlMappings("/*");
|
||||||
registrationBean.setLoadOnStartup(1);
|
registrationBean.setLoadOnStartup(1);
|
||||||
return registrationBean;
|
return registrationBean;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,9 +14,11 @@ import ca.uhn.fhir.jpa.subscription.match.deliver.email.IEmailSender;
|
|||||||
import ca.uhn.fhir.rest.server.mail.IMailSvc;
|
import ca.uhn.fhir.rest.server.mail.IMailSvc;
|
||||||
import ca.uhn.fhir.rest.server.mail.MailConfig;
|
import ca.uhn.fhir.rest.server.mail.MailConfig;
|
||||||
import ca.uhn.fhir.rest.server.mail.MailSvc;
|
import ca.uhn.fhir.rest.server.mail.MailSvc;
|
||||||
|
import ca.uhn.fhir.rest.server.provider.ResourceProviderFactory;
|
||||||
|
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import org.hl7.fhir.r4.model.Bundle.BundleType;
|
import org.hl7.fhir.r4.model.Bundle.BundleType;
|
||||||
|
import org.springframework.beans.factory.FactoryBean;
|
||||||
import org.springframework.boot.env.YamlPropertySourceLoader;
|
import org.springframework.boot.env.YamlPropertySourceLoader;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
@@ -36,206 +38,221 @@ import java.util.stream.Collectors;
|
|||||||
@EnableTransactionManagement
|
@EnableTransactionManagement
|
||||||
public class FhirServerConfigCommon {
|
public class FhirServerConfigCommon {
|
||||||
|
|
||||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirServerConfigCommon.class);
|
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirServerConfigCommon.class);
|
||||||
|
|
||||||
|
public FhirServerConfigCommon(AppProperties appProperties) {
|
||||||
|
ourLog.info("Server configured to " + (appProperties.getAllow_contains_searches() ? "allow" : "deny")
|
||||||
|
+ " contains searches");
|
||||||
|
ourLog.info("Server configured to " + (appProperties.getAllow_multiple_delete() ? "allow" : "deny")
|
||||||
|
+ " multiple deletes");
|
||||||
|
ourLog.info("Server configured to " + (appProperties.getAllow_external_references() ? "allow" : "deny")
|
||||||
|
+ " external references");
|
||||||
|
ourLog.info("Server configured to " + (appProperties.getDao_scheduling_enabled() ? "enable" : "disable")
|
||||||
|
+ " DAO scheduling");
|
||||||
|
ourLog.info("Server configured to " + (appProperties.getDelete_expunge_enabled() ? "enable" : "disable")
|
||||||
|
+ " delete expunges");
|
||||||
|
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");
|
||||||
|
|
||||||
public FhirServerConfigCommon(AppProperties appProperties) {
|
if (appProperties.getSubscription().getEmail() != null) {
|
||||||
ourLog.info("Server configured to " + (appProperties.getAllow_contains_searches() ? "allow" : "deny") + " contains searches");
|
AppProperties.Subscription.Email email = appProperties.getSubscription().getEmail();
|
||||||
ourLog.info("Server configured to " + (appProperties.getAllow_multiple_delete() ? "allow" : "deny") + " multiple deletes");
|
ourLog.info(
|
||||||
ourLog.info("Server configured to " + (appProperties.getAllow_external_references() ? "allow" : "deny") + " external references");
|
"Server is configured to enable email with host '" + email.getHost() + "' and port " + email.getPort());
|
||||||
ourLog.info("Server configured to " + (appProperties.getDao_scheduling_enabled() ? "enable" : "disable") + " DAO scheduling");
|
ourLog.info("Server will use '" + email.getFrom() + "' as the from email address");
|
||||||
ourLog.info("Server configured to " + (appProperties.getDelete_expunge_enabled() ? "enable" : "disable") + " delete expunges");
|
|
||||||
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");
|
|
||||||
|
|
||||||
if (appProperties.getSubscription().getEmail() != null) {
|
if (!Strings.isNullOrEmpty(email.getUsername())) {
|
||||||
AppProperties.Subscription.Email email = appProperties.getSubscription().getEmail();
|
ourLog.info("Server is configured to use username '" + email.getUsername() + "' for email");
|
||||||
ourLog.info("Server is configured to enable email with host '" + email.getHost() + "' and port " + email.getPort());
|
}
|
||||||
ourLog.info("Server will use '" + email.getFrom() + "' as the from email address");
|
|
||||||
|
|
||||||
if (!Strings.isNullOrEmpty(email.getUsername())) {
|
if (!Strings.isNullOrEmpty(email.getPassword())) {
|
||||||
ourLog.info("Server is configured to use username '" + email.getUsername() + "' for email");
|
ourLog.info("Server is configured to use a password for email");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!Strings.isNullOrEmpty(email.getPassword())) {
|
if (appProperties.getSubscription().getResthook_enabled()) {
|
||||||
ourLog.info("Server is configured to use a password for email");
|
ourLog.info("REST-hook subscriptions enabled");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (appProperties.getSubscription().getResthook_enabled()) {
|
if (appProperties.getSubscription().getEmail() != null) {
|
||||||
ourLog.info("REST-hook subscriptions enabled");
|
ourLog.info("Email subscriptions enabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (appProperties.getSubscription().getEmail() != null) {
|
if (appProperties.getEnable_index_contained_resource() == Boolean.TRUE) {
|
||||||
ourLog.info("Email subscriptions enabled");
|
ourLog.info("Indexed on contained resource enabled");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (appProperties.getEnable_index_contained_resource() == Boolean.TRUE) {
|
/**
|
||||||
ourLog.info("Indexed on contained resource enabled");
|
* Configure FHIR properties around the the JPA server via this bean
|
||||||
}
|
*/
|
||||||
}
|
@Bean
|
||||||
|
public JpaStorageSettings jpaStorageSettings(AppProperties appProperties) {
|
||||||
|
JpaStorageSettings jpaStorageSettings = new JpaStorageSettings();
|
||||||
|
|
||||||
/**
|
jpaStorageSettings.setIndexMissingFields(
|
||||||
* Configure FHIR properties around the the JPA server via this bean
|
appProperties.getEnable_index_missing_fields() ? JpaStorageSettings.IndexEnabledEnum.ENABLED
|
||||||
*/
|
: JpaStorageSettings.IndexEnabledEnum.DISABLED);
|
||||||
@Bean
|
jpaStorageSettings
|
||||||
public JpaStorageSettings jpaStorageSettings(AppProperties appProperties) {
|
.setAutoCreatePlaceholderReferenceTargets(appProperties.getAuto_create_placeholder_reference_targets());
|
||||||
JpaStorageSettings jpaStorageSettings = new JpaStorageSettings();
|
jpaStorageSettings
|
||||||
|
.setEnforceReferentialIntegrityOnWrite(appProperties.getEnforce_referential_integrity_on_write());
|
||||||
|
jpaStorageSettings
|
||||||
|
.setEnforceReferentialIntegrityOnDelete(appProperties.getEnforce_referential_integrity_on_delete());
|
||||||
|
jpaStorageSettings.setAllowContainsSearches(appProperties.getAllow_contains_searches());
|
||||||
|
jpaStorageSettings.setAllowMultipleDelete(appProperties.getAllow_multiple_delete());
|
||||||
|
jpaStorageSettings.setAllowExternalReferences(appProperties.getAllow_external_references());
|
||||||
|
jpaStorageSettings.setSchedulingDisabled(!appProperties.getDao_scheduling_enabled());
|
||||||
|
jpaStorageSettings.setDeleteExpungeEnabled(appProperties.getDelete_expunge_enabled());
|
||||||
|
jpaStorageSettings.setExpungeEnabled(appProperties.getExpunge_enabled());
|
||||||
|
if (appProperties.getSubscription() != null && appProperties.getSubscription().getEmail() != null)
|
||||||
|
jpaStorageSettings.setEmailFromAddress(appProperties.getSubscription().getEmail().getFrom());
|
||||||
|
|
||||||
jpaStorageSettings.setIndexMissingFields(appProperties.getEnable_index_missing_fields() ? JpaStorageSettings.IndexEnabledEnum.ENABLED : JpaStorageSettings.IndexEnabledEnum.DISABLED);
|
Integer maxFetchSize = appProperties.getMax_page_size();
|
||||||
jpaStorageSettings.setAutoCreatePlaceholderReferenceTargets(appProperties.getAuto_create_placeholder_reference_targets());
|
jpaStorageSettings.setFetchSizeDefaultMaximum(maxFetchSize);
|
||||||
jpaStorageSettings.setEnforceReferentialIntegrityOnWrite(appProperties.getEnforce_referential_integrity_on_write());
|
ourLog.info("Server configured to have a maximum fetch size of "
|
||||||
jpaStorageSettings.setEnforceReferentialIntegrityOnDelete(appProperties.getEnforce_referential_integrity_on_delete());
|
+ (maxFetchSize == Integer.MAX_VALUE ? "'unlimited'" : maxFetchSize));
|
||||||
jpaStorageSettings.setAllowContainsSearches(appProperties.getAllow_contains_searches());
|
|
||||||
jpaStorageSettings.setAllowMultipleDelete(appProperties.getAllow_multiple_delete());
|
|
||||||
jpaStorageSettings.setAllowExternalReferences(appProperties.getAllow_external_references());
|
|
||||||
jpaStorageSettings.setSchedulingDisabled(!appProperties.getDao_scheduling_enabled());
|
|
||||||
jpaStorageSettings.setDeleteExpungeEnabled(appProperties.getDelete_expunge_enabled());
|
|
||||||
jpaStorageSettings.setExpungeEnabled(appProperties.getExpunge_enabled());
|
|
||||||
if(appProperties.getSubscription() != null && appProperties.getSubscription().getEmail() != null)
|
|
||||||
jpaStorageSettings.setEmailFromAddress(appProperties.getSubscription().getEmail().getFrom());
|
|
||||||
|
|
||||||
Integer maxFetchSize = appProperties.getMax_page_size();
|
Long reuseCachedSearchResultsMillis = appProperties.getReuse_cached_search_results_millis();
|
||||||
jpaStorageSettings.setFetchSizeDefaultMaximum(maxFetchSize);
|
jpaStorageSettings.setReuseCachedSearchResultsForMillis(reuseCachedSearchResultsMillis);
|
||||||
ourLog.info("Server configured to have a maximum fetch size of " + (maxFetchSize == Integer.MAX_VALUE ? "'unlimited'" : maxFetchSize));
|
ourLog.info("Server configured to cache search results for {} milliseconds", reuseCachedSearchResultsMillis);
|
||||||
|
|
||||||
Long reuseCachedSearchResultsMillis = appProperties.getReuse_cached_search_results_millis();
|
Long retainCachedSearchesMinutes = appProperties.getRetain_cached_searches_mins();
|
||||||
jpaStorageSettings.setReuseCachedSearchResultsForMillis(reuseCachedSearchResultsMillis);
|
jpaStorageSettings.setExpireSearchResultsAfterMillis(retainCachedSearchesMinutes * 60 * 1000);
|
||||||
ourLog.info("Server configured to cache search results for {} milliseconds", reuseCachedSearchResultsMillis);
|
|
||||||
|
|
||||||
|
if (appProperties.getSubscription() != null) {
|
||||||
|
// Subscriptions are enabled by channel type
|
||||||
|
if (appProperties.getSubscription().getResthook_enabled()) {
|
||||||
|
ourLog.info("Enabling REST-hook subscriptions");
|
||||||
|
jpaStorageSettings
|
||||||
|
.addSupportedSubscriptionType(org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelType.RESTHOOK);
|
||||||
|
}
|
||||||
|
if (appProperties.getSubscription().getEmail() != null) {
|
||||||
|
ourLog.info("Enabling email subscriptions");
|
||||||
|
jpaStorageSettings
|
||||||
|
.addSupportedSubscriptionType(org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelType.EMAIL);
|
||||||
|
}
|
||||||
|
if (appProperties.getSubscription().getWebsocket_enabled()) {
|
||||||
|
ourLog.info("Enabling websocket subscriptions");
|
||||||
|
jpaStorageSettings.addSupportedSubscriptionType(
|
||||||
|
org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelType.WEBSOCKET);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Long retainCachedSearchesMinutes = appProperties.getRetain_cached_searches_mins();
|
jpaStorageSettings.setFilterParameterEnabled(appProperties.getFilter_search_enabled());
|
||||||
jpaStorageSettings.setExpireSearchResultsAfterMillis(retainCachedSearchesMinutes * 60 * 1000);
|
jpaStorageSettings.setAdvancedHSearchIndexing(appProperties.getAdvanced_lucene_indexing());
|
||||||
|
jpaStorageSettings.setTreatBaseUrlsAsLocal(new HashSet<>(appProperties.getLocal_base_urls()));
|
||||||
|
|
||||||
if(appProperties.getSubscription() != null) {
|
if (appProperties.getLastn_enabled()) {
|
||||||
// Subscriptions are enabled by channel type
|
jpaStorageSettings.setLastNEnabled(true);
|
||||||
if (appProperties.getSubscription().getResthook_enabled()) {
|
}
|
||||||
ourLog.info("Enabling REST-hook subscriptions");
|
|
||||||
jpaStorageSettings.addSupportedSubscriptionType(org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelType.RESTHOOK);
|
|
||||||
}
|
|
||||||
if (appProperties.getSubscription().getEmail() != null) {
|
|
||||||
ourLog.info("Enabling email subscriptions");
|
|
||||||
jpaStorageSettings.addSupportedSubscriptionType(org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelType.EMAIL);
|
|
||||||
}
|
|
||||||
if (appProperties.getSubscription().getWebsocket_enabled()) {
|
|
||||||
ourLog.info("Enabling websocket subscriptions");
|
|
||||||
jpaStorageSettings.addSupportedSubscriptionType(org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelType.WEBSOCKET);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
jpaStorageSettings.setFilterParameterEnabled(appProperties.getFilter_search_enabled());
|
if (appProperties.getInline_resource_storage_below_size() != 0) {
|
||||||
jpaStorageSettings.setAdvancedHSearchIndexing(appProperties.getAdvanced_lucene_indexing());
|
jpaStorageSettings.setInlineResourceTextBelowSize(appProperties.getInline_resource_storage_below_size());
|
||||||
jpaStorageSettings.setTreatBaseUrlsAsLocal(new HashSet<>(appProperties.getLocal_base_urls()));
|
}
|
||||||
|
|
||||||
if (appProperties.getLastn_enabled()) {
|
jpaStorageSettings.setStoreResourceInHSearchIndex(appProperties.getStore_resource_in_lucene_index_enabled());
|
||||||
jpaStorageSettings.setLastNEnabled(true);
|
jpaStorageSettings.setNormalizedQuantitySearchLevel(appProperties.getNormalized_quantity_search_level());
|
||||||
}
|
jpaStorageSettings.setIndexOnContainedResources(appProperties.getEnable_index_contained_resource());
|
||||||
|
|
||||||
if(appProperties.getInline_resource_storage_below_size() != 0){
|
if (appProperties.getAllowed_bundle_types() != null) {
|
||||||
jpaStorageSettings.setInlineResourceTextBelowSize(appProperties.getInline_resource_storage_below_size());
|
jpaStorageSettings.setBundleTypesAllowedForStorage(
|
||||||
}
|
appProperties.getAllowed_bundle_types().stream().map(BundleType::toCode).collect(Collectors.toSet()));
|
||||||
|
}
|
||||||
|
|
||||||
jpaStorageSettings.setStoreResourceInHSearchIndex(appProperties.getStore_resource_in_lucene_index_enabled());
|
jpaStorageSettings
|
||||||
jpaStorageSettings.setNormalizedQuantitySearchLevel(appProperties.getNormalized_quantity_search_level());
|
.setDeferIndexingForCodesystemsOfSize(appProperties.getDefer_indexing_for_codesystems_of_size());
|
||||||
jpaStorageSettings.setIndexOnContainedResources(appProperties.getEnable_index_contained_resource());
|
|
||||||
|
|
||||||
|
if (appProperties.getClient_id_strategy() == JpaStorageSettings.ClientIdStrategyEnum.ANY) {
|
||||||
|
jpaStorageSettings.setResourceServerIdStrategy(JpaStorageSettings.IdStrategyEnum.UUID);
|
||||||
|
jpaStorageSettings.setResourceClientIdStrategy(appProperties.getClient_id_strategy());
|
||||||
|
}
|
||||||
|
// Parallel Batch GET execution settings
|
||||||
|
jpaStorageSettings.setBundleBatchPoolSize(appProperties.getBundle_batch_pool_size());
|
||||||
|
jpaStorageSettings.setBundleBatchPoolSize(appProperties.getBundle_batch_pool_max_size());
|
||||||
|
|
||||||
|
storageSettings(appProperties, jpaStorageSettings);
|
||||||
|
return jpaStorageSettings;
|
||||||
|
}
|
||||||
|
|
||||||
if (appProperties.getAllowed_bundle_types() != null) {
|
@Bean
|
||||||
jpaStorageSettings.setBundleTypesAllowedForStorage(appProperties.getAllowed_bundle_types().stream().map(BundleType::toCode).collect(Collectors.toSet()));
|
public YamlPropertySourceLoader yamlPropertySourceLoader() {
|
||||||
}
|
return new YamlPropertySourceLoader();
|
||||||
|
}
|
||||||
|
|
||||||
jpaStorageSettings.setDeferIndexingForCodesystemsOfSize(appProperties.getDefer_indexing_for_codesystems_of_size());
|
@Bean
|
||||||
|
public PartitionSettings partitionSettings(AppProperties appProperties) {
|
||||||
|
PartitionSettings retVal = new PartitionSettings();
|
||||||
|
|
||||||
|
// Partitioning
|
||||||
|
if (appProperties.getPartitioning() != null) {
|
||||||
|
retVal.setPartitioningEnabled(true);
|
||||||
|
retVal.setIncludePartitionInSearchHashes(
|
||||||
|
appProperties.getPartitioning().getPartitioning_include_in_search_hashes());
|
||||||
|
if (appProperties.getPartitioning().getAllow_references_across_partitions()) {
|
||||||
|
retVal.setAllowReferencesAcrossPartitions(CrossPartitionReferenceMode.ALLOWED_UNQUALIFIED);
|
||||||
|
} else {
|
||||||
|
retVal.setAllowReferencesAcrossPartitions(CrossPartitionReferenceMode.NOT_ALLOWED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (appProperties.getClient_id_strategy() == JpaStorageSettings.ClientIdStrategyEnum.ANY) {
|
return retVal;
|
||||||
jpaStorageSettings.setResourceServerIdStrategy(JpaStorageSettings.IdStrategyEnum.UUID);
|
}
|
||||||
jpaStorageSettings.setResourceClientIdStrategy(appProperties.getClient_id_strategy());
|
|
||||||
}
|
|
||||||
//Parallel Batch GET execution settings
|
|
||||||
jpaStorageSettings.setBundleBatchPoolSize(appProperties.getBundle_batch_pool_size());
|
|
||||||
jpaStorageSettings.setBundleBatchPoolSize(appProperties.getBundle_batch_pool_max_size());
|
|
||||||
|
|
||||||
storageSettings(appProperties, jpaStorageSettings);
|
@Primary
|
||||||
return jpaStorageSettings;
|
@Bean
|
||||||
}
|
public HibernatePropertiesProvider jpaStarterDialectProvider(
|
||||||
|
LocalContainerEntityManagerFactoryBean myEntityManagerFactory) {
|
||||||
|
return new JpaHibernatePropertiesProvider(myEntityManagerFactory);
|
||||||
|
}
|
||||||
|
|
||||||
@Bean
|
protected StorageSettings storageSettings(AppProperties appProperties, JpaStorageSettings jpaStorageSettings) {
|
||||||
public YamlPropertySourceLoader yamlPropertySourceLoader() {
|
jpaStorageSettings.setAllowContainsSearches(appProperties.getAllow_contains_searches());
|
||||||
return new YamlPropertySourceLoader();
|
jpaStorageSettings.setAllowExternalReferences(appProperties.getAllow_external_references());
|
||||||
}
|
jpaStorageSettings.setDefaultSearchParamsCanBeOverridden(appProperties.getAllow_override_default_search_params());
|
||||||
|
if (appProperties.getSubscription() != null && appProperties.getSubscription().getEmail() != null)
|
||||||
|
jpaStorageSettings.setEmailFromAddress(appProperties.getSubscription().getEmail().getFrom());
|
||||||
|
|
||||||
@Bean
|
jpaStorageSettings.setNormalizedQuantitySearchLevel(appProperties.getNormalized_quantity_search_level());
|
||||||
public PartitionSettings partitionSettings(AppProperties appProperties) {
|
|
||||||
PartitionSettings retVal = new PartitionSettings();
|
|
||||||
|
|
||||||
// Partitioning
|
jpaStorageSettings.setIndexOnContainedResources(appProperties.getEnable_index_contained_resource());
|
||||||
if (appProperties.getPartitioning() != null) {
|
jpaStorageSettings.setIndexIdentifierOfType(appProperties.getEnable_index_of_type());
|
||||||
retVal.setPartitioningEnabled(true);
|
return jpaStorageSettings;
|
||||||
retVal.setIncludePartitionInSearchHashes(appProperties.getPartitioning().getPartitioning_include_in_search_hashes());
|
}
|
||||||
if(appProperties.getPartitioning().getAllow_references_across_partitions()) {
|
|
||||||
retVal.setAllowReferencesAcrossPartitions(CrossPartitionReferenceMode.ALLOWED_UNQUALIFIED);
|
|
||||||
} else {
|
|
||||||
retVal.setAllowReferencesAcrossPartitions(CrossPartitionReferenceMode.NOT_ALLOWED);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return retVal;
|
@Lazy
|
||||||
}
|
@Bean
|
||||||
|
public IBinaryStorageSvc binaryStorageSvc(AppProperties appProperties) {
|
||||||
|
DatabaseBlobBinaryStorageSvcImpl binaryStorageSvc = new DatabaseBlobBinaryStorageSvcImpl();
|
||||||
|
|
||||||
|
if (appProperties.getMax_binary_size() != null) {
|
||||||
|
binaryStorageSvc.setMaximumBinarySize(appProperties.getMax_binary_size());
|
||||||
|
}
|
||||||
|
|
||||||
@Primary
|
return binaryStorageSvc;
|
||||||
@Bean
|
}
|
||||||
public HibernatePropertiesProvider jpaStarterDialectProvider(LocalContainerEntityManagerFactoryBean myEntityManagerFactory) {
|
|
||||||
return new JpaHibernatePropertiesProvider(myEntityManagerFactory);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public IEmailSender emailSender(AppProperties appProperties) {
|
||||||
|
if (appProperties.getSubscription() != null && appProperties.getSubscription().getEmail() != null) {
|
||||||
|
MailConfig mailConfig = new MailConfig();
|
||||||
|
|
||||||
protected StorageSettings storageSettings(AppProperties appProperties, JpaStorageSettings jpaStorageSettings) {
|
AppProperties.Subscription.Email email = appProperties.getSubscription().getEmail();
|
||||||
jpaStorageSettings.setAllowContainsSearches(appProperties.getAllow_contains_searches());
|
mailConfig.setSmtpHostname(email.getHost());
|
||||||
jpaStorageSettings.setAllowExternalReferences(appProperties.getAllow_external_references());
|
mailConfig.setSmtpPort(email.getPort());
|
||||||
jpaStorageSettings.setDefaultSearchParamsCanBeOverridden(appProperties.getAllow_override_default_search_params());
|
mailConfig.setSmtpUsername(email.getUsername());
|
||||||
if(appProperties.getSubscription() != null && appProperties.getSubscription().getEmail() != null)
|
mailConfig.setSmtpPassword(email.getPassword());
|
||||||
jpaStorageSettings.setEmailFromAddress(appProperties.getSubscription().getEmail().getFrom());
|
mailConfig.setSmtpUseStartTLS(email.getStartTlsEnable());
|
||||||
|
|
||||||
jpaStorageSettings.setNormalizedQuantitySearchLevel(appProperties.getNormalized_quantity_search_level());
|
IMailSvc mailSvc = new MailSvc(mailConfig);
|
||||||
|
IEmailSender emailSender = new EmailSenderImpl(mailSvc);
|
||||||
|
|
||||||
jpaStorageSettings.setIndexOnContainedResources(appProperties.getEnable_index_contained_resource());
|
return emailSender;
|
||||||
jpaStorageSettings.setIndexIdentifierOfType(appProperties.getEnable_index_of_type());
|
}
|
||||||
return jpaStorageSettings;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Lazy
|
return null;
|
||||||
@Bean
|
}
|
||||||
public IBinaryStorageSvc binaryStorageSvc(AppProperties appProperties) {
|
|
||||||
DatabaseBlobBinaryStorageSvcImpl binaryStorageSvc = new DatabaseBlobBinaryStorageSvcImpl();
|
|
||||||
|
|
||||||
if (appProperties.getMax_binary_size() != null) {
|
|
||||||
binaryStorageSvc.setMaximumBinarySize(appProperties.getMax_binary_size());
|
|
||||||
}
|
|
||||||
|
|
||||||
return binaryStorageSvc;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public IEmailSender emailSender(AppProperties appProperties) {
|
|
||||||
if (appProperties.getSubscription() != null && appProperties.getSubscription().getEmail() != null) {
|
|
||||||
MailConfig mailConfig = new MailConfig();
|
|
||||||
|
|
||||||
AppProperties.Subscription.Email email = appProperties.getSubscription().getEmail();
|
|
||||||
mailConfig.setSmtpHostname(email.getHost());
|
|
||||||
mailConfig.setSmtpPort(email.getPort());
|
|
||||||
mailConfig.setSmtpUsername(email.getUsername());
|
|
||||||
mailConfig.setSmtpPassword(email.getPassword());
|
|
||||||
mailConfig.setSmtpUseStartTLS(email.getStartTlsEnable());
|
|
||||||
|
|
||||||
IMailSvc mailSvc = new MailSvc(mailConfig);
|
|
||||||
IEmailSender emailSender = new EmailSenderImpl(mailSvc);
|
|
||||||
|
|
||||||
return emailSender;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,11 +15,14 @@ public class CrOperationProviderLoader {
|
|||||||
private final ResourceProviderFactory myResourceProviderFactory;
|
private final ResourceProviderFactory myResourceProviderFactory;
|
||||||
private final CrOperationProviderFactory myCrProviderFactory;
|
private final CrOperationProviderFactory myCrProviderFactory;
|
||||||
|
|
||||||
|
private final PostInitProviderRegisterer myPostInitProviderRegister;
|
||||||
|
|
||||||
public CrOperationProviderLoader(FhirContext theFhirContext, ResourceProviderFactory theResourceProviderFactory,
|
public CrOperationProviderLoader(FhirContext theFhirContext, ResourceProviderFactory theResourceProviderFactory,
|
||||||
CrOperationProviderFactory theCrProviderFactory) {
|
CrOperationProviderFactory theCrProviderFactory, PostInitProviderRegisterer thePostInitProviderRegister) {
|
||||||
myFhirContext = theFhirContext;
|
myFhirContext = theFhirContext;
|
||||||
myResourceProviderFactory = theResourceProviderFactory;
|
myResourceProviderFactory = theResourceProviderFactory;
|
||||||
myCrProviderFactory = theCrProviderFactory;
|
myCrProviderFactory = theCrProviderFactory;
|
||||||
|
myPostInitProviderRegister = thePostInitProviderRegister;
|
||||||
loadProvider();
|
loadProvider();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package ca.uhn.fhir.jpa.starter.cr;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.rest.server.RestfulServer;
|
||||||
|
import ca.uhn.fhir.rest.server.provider.IResourceProviderFactoryObserver;
|
||||||
|
import ca.uhn.fhir.rest.server.provider.ResourceProviderFactory;
|
||||||
|
|
||||||
|
public class PostInitProviderRegisterer {
|
||||||
|
public PostInitProviderRegisterer(RestfulServer restfulServer,
|
||||||
|
ResourceProviderFactory resourceProviderFactory) {
|
||||||
|
resourceProviderFactory.attach(new Observer(restfulServer));
|
||||||
|
}
|
||||||
|
|
||||||
|
private class Observer implements IResourceProviderFactoryObserver {
|
||||||
|
private RestfulServer restfulServer;
|
||||||
|
|
||||||
|
public Observer(RestfulServer restfulServer) {
|
||||||
|
this.restfulServer = restfulServer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update(Supplier<Object> theSupplier) {
|
||||||
|
if (theSupplier == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var provider = theSupplier.get();
|
||||||
|
if (provider == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.restfulServer.registerProvider(provider);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void remove(Supplier<Object> theSupplier) {
|
||||||
|
if (theSupplier == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var provider = theSupplier.get();
|
||||||
|
if (provider == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.restfulServer.unregisterProvider(provider);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -30,6 +30,13 @@ import org.springframework.context.annotation.Import;
|
|||||||
@Conditional({ OnDSTU3Condition.class, CrConfigCondition.class })
|
@Conditional({ OnDSTU3Condition.class, CrConfigCondition.class })
|
||||||
@Import({ CrDstu3Config.class })
|
@Import({ CrDstu3Config.class })
|
||||||
public class StarterCrDstu3Config {
|
public class StarterCrDstu3Config {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public PostInitProviderRegisterer postInitProviderRegisterer(RestfulServer theRestfulServer,
|
||||||
|
ResourceProviderFactory theResourceProviderFactory) {
|
||||||
|
return new PostInitProviderRegisterer(theRestfulServer, theResourceProviderFactory);
|
||||||
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public CrOperationProviderFactory crOperationProviderFactory() {
|
public CrOperationProviderFactory crOperationProviderFactory() {
|
||||||
return new CrOperationProviderFactory();
|
return new CrOperationProviderFactory();
|
||||||
@@ -38,8 +45,10 @@ public class StarterCrDstu3Config {
|
|||||||
@Bean
|
@Bean
|
||||||
public CrOperationProviderLoader crOperationProviderLoader(FhirContext theFhirContext,
|
public CrOperationProviderLoader crOperationProviderLoader(FhirContext theFhirContext,
|
||||||
ResourceProviderFactory theResourceProviderFactory,
|
ResourceProviderFactory theResourceProviderFactory,
|
||||||
CrOperationProviderFactory theCrlProviderFactory) {
|
CrOperationProviderFactory theCrOperationProviderFactory,
|
||||||
return new CrOperationProviderLoader(theFhirContext, theResourceProviderFactory, theCrlProviderFactory);
|
PostInitProviderRegisterer thePostInitProviderRegister) {
|
||||||
|
return new CrOperationProviderLoader(theFhirContext, theResourceProviderFactory, theCrOperationProviderFactory,
|
||||||
|
thePostInitProviderRegister);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package ca.uhn.fhir.jpa.starter.cr;
|
package ca.uhn.fhir.jpa.starter.cr;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.IHapiBootOrder;
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
import ca.uhn.fhir.cr.common.IRepositoryFactory;
|
import ca.uhn.fhir.cr.common.IRepositoryFactory;
|
||||||
import ca.uhn.fhir.cr.config.CrR4Config;
|
import ca.uhn.fhir.cr.config.CrR4Config;
|
||||||
@@ -30,6 +31,13 @@ import org.springframework.context.annotation.Import;
|
|||||||
@Conditional({ OnR4Condition.class, CrConfigCondition.class })
|
@Conditional({ OnR4Condition.class, CrConfigCondition.class })
|
||||||
@Import({ CrR4Config.class })
|
@Import({ CrR4Config.class })
|
||||||
public class StarterCrR4Config {
|
public class StarterCrR4Config {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public PostInitProviderRegisterer postInitProviderRegisterer(RestfulServer theRestfulServer,
|
||||||
|
ResourceProviderFactory theResourceProviderFactory) {
|
||||||
|
return new PostInitProviderRegisterer(theRestfulServer, theResourceProviderFactory);
|
||||||
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public CrOperationProviderFactory crOperationProviderFactory() {
|
public CrOperationProviderFactory crOperationProviderFactory() {
|
||||||
return new CrOperationProviderFactory();
|
return new CrOperationProviderFactory();
|
||||||
@@ -38,8 +46,10 @@ public class StarterCrR4Config {
|
|||||||
@Bean
|
@Bean
|
||||||
public CrOperationProviderLoader crOperationProviderLoader(FhirContext theFhirContext,
|
public CrOperationProviderLoader crOperationProviderLoader(FhirContext theFhirContext,
|
||||||
ResourceProviderFactory theResourceProviderFactory,
|
ResourceProviderFactory theResourceProviderFactory,
|
||||||
CrOperationProviderFactory theCrlProviderFactory) {
|
CrOperationProviderFactory theCrOperationProviderFactory,
|
||||||
return new CrOperationProviderLoader(theFhirContext, theResourceProviderFactory, theCrlProviderFactory);
|
PostInitProviderRegisterer thePostInitProviderRegister) {
|
||||||
|
return new CrOperationProviderLoader(theFhirContext, theResourceProviderFactory, theCrOperationProviderFactory,
|
||||||
|
thePostInitProviderRegister);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|||||||
Reference in New Issue
Block a user