Added partition interceptor

This commit is contained in:
jvi
2020-09-09 11:30:01 +02:00
parent de9a029947
commit ec878a9205
5 changed files with 23 additions and 5 deletions

View File

@@ -6,7 +6,9 @@ import ca.uhn.fhir.empi.rules.config.EmpiSettings;
import ca.uhn.fhir.jpa.starter.AppProperties;
import com.google.common.base.Charsets;
import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.Resource;
@@ -18,10 +20,11 @@ import java.io.IOException;
* in 5.1.0 picks this up even if EMPI is disabled currently.
*/
@Configuration
@Conditional(EmpiConfigCondition.class)
public class EmpiConfig {
@Bean
IEmpiSettings empiSettings(EmpiRuleValidator theEmpiRuleValidator, AppProperties appProperties) throws IOException {
IEmpiSettings empiSettings(@Autowired EmpiRuleValidator theEmpiRuleValidator, AppProperties appProperties) throws IOException {
DefaultResourceLoader resourceLoader = new DefaultResourceLoader();
Resource resource = resourceLoader.getResource("empi-rules.json");
String json = IOUtils.toString(resource.getInputStream(), Charsets.UTF_8);

View File

@@ -0,0 +1,13 @@
package ca.uhn.fhir.jpa.empi;
import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;
public class EmpiConfigCondition implements Condition {
@Override
public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata metadata) {
String property = conditionContext.getEnvironment().getProperty("hapi.fhir.empi_enabled");
return Boolean.parseBoolean(property);
}
}

View File

@@ -36,9 +36,9 @@ public class AppProperties {
private Boolean expunge_enabled = true;
private Boolean fhirpath_interceptor_enabled = false;
private Boolean filter_search_enabled = true;
private Boolean graphql_enabled = true;
private Boolean binary_storage_enabled = true;
private Boolean bulk_export_enabled = true;
private Boolean graphql_enabled = false;
private Boolean binary_storage_enabled = false;
private Boolean bulk_export_enabled = false;
private Boolean default_pretty_print = true;
private Integer default_page_size = 20;
private Integer max_binary_size = null;

View File

@@ -1,5 +1,6 @@
package ca.uhn.fhir.jpa.starter;
import ca.uhn.fhir.jpa.empi.EmpiConfig;
import ca.uhn.fhir.jpa.subscription.channel.config.SubscriptionChannelConfig;
import ca.uhn.fhir.jpa.subscription.match.config.SubscriptionProcessorConfig;
import ca.uhn.fhir.jpa.subscription.match.config.WebsocketDispatcherConfig;
@@ -21,7 +22,7 @@ import org.springframework.web.servlet.DispatcherServlet;
@ServletComponentScan(basePackageClasses = {
JpaRestfulServer.class}, basePackages = "ca.uhn.fhir.jpa.starter")
@SpringBootApplication(exclude = ElasticsearchRestClientAutoConfiguration.class)
@Import({SubscriptionSubmitterConfig.class, SubscriptionProcessorConfig.class, SubscriptionChannelConfig.class,WebsocketDispatcherConfig.class })
@Import({SubscriptionSubmitterConfig.class, SubscriptionProcessorConfig.class, SubscriptionChannelConfig.class, WebsocketDispatcherConfig.class, EmpiConfig.class})
public class Application extends SpringBootServletInitializer {
public static void main(String[] args) {

View File

@@ -102,5 +102,6 @@ public class MultitenantServerR4IT {
String ourServerBase = "http://localhost:" + port + "/hapi-fhir-jpaserver/fhir/";
ourClient = ourCtx.newRestfulGenericClient(ourServerBase);
ourClient.registerInterceptor(new LoggingInterceptor(true));
ourClient.registerInterceptor(ourClientTenantInterceptor);
}
}