Merge branch 'master' into kbd-20201125-cql-initial-impl
This commit is contained in:
@@ -7,8 +7,10 @@ import ca.uhn.fhir.rest.api.EncodingEnum;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import org.hl7.fhir.r4.model.Bundle;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
@@ -56,12 +58,14 @@ public class AppProperties {
|
||||
private Boolean narrative_enabled = true;
|
||||
|
||||
private Validation validation = new Validation();
|
||||
private List<Tester> tester = ImmutableList.of(new Tester());
|
||||
private Map<String, Tester> tester = ImmutableMap.of("home", new Tester());
|
||||
private Logger logger = new Logger();
|
||||
private Subscription subscription = new Subscription();
|
||||
private Cors cors = null;
|
||||
private Partitioning partitioning = null;
|
||||
private List<ImplementationGuide> implementationGuides = null;
|
||||
private Map<String, ImplementationGuide> implementationGuides = null;
|
||||
|
||||
private Boolean lastn_enabled = false;
|
||||
|
||||
public Integer getDefer_indexing_for_codesystems_of_size() {
|
||||
return defer_indexing_for_codesystems_of_size;
|
||||
@@ -71,11 +75,11 @@ public class AppProperties {
|
||||
this.defer_indexing_for_codesystems_of_size = defer_indexing_for_codesystems_of_size;
|
||||
}
|
||||
|
||||
public List<ImplementationGuide> getImplementationGuides() {
|
||||
public Map<String, ImplementationGuide> getImplementationGuides() {
|
||||
return implementationGuides;
|
||||
}
|
||||
|
||||
public void setImplementationGuides(List<ImplementationGuide> implementationGuides) {
|
||||
public void setImplementationGuides(Map<String, ImplementationGuide> implementationGuides) {
|
||||
this.implementationGuides = implementationGuides;
|
||||
}
|
||||
|
||||
@@ -372,11 +376,11 @@ public class AppProperties {
|
||||
this.reuse_cached_search_results_millis = reuse_cached_search_results_millis;
|
||||
}
|
||||
|
||||
public List<Tester> getTester() {
|
||||
public Map<String, Tester> getTester() {
|
||||
return tester;
|
||||
}
|
||||
|
||||
public void setTester(List<Tester> tester) {
|
||||
public void setTester(Map<String, Tester> tester) {
|
||||
this.tester = tester;
|
||||
}
|
||||
|
||||
@@ -390,6 +394,14 @@ public class AppProperties {
|
||||
this.narrative_enabled = narrative_enabled;
|
||||
}
|
||||
|
||||
public Boolean getLastn_enabled() {
|
||||
return lastn_enabled;
|
||||
}
|
||||
|
||||
public void setLastn_enabled(Boolean lastn_enabled) {
|
||||
this.lastn_enabled = lastn_enabled;
|
||||
}
|
||||
|
||||
public static class Cors {
|
||||
private Boolean allow_Credentials = true;
|
||||
private List<String> allowed_origin = ImmutableList.of("*");
|
||||
@@ -456,7 +468,6 @@ public class AppProperties {
|
||||
|
||||
public static class Tester {
|
||||
|
||||
private String id = "home";
|
||||
private String name = "Local Tester";
|
||||
private String server_address = "http://localhost:8080/fhir";
|
||||
private Boolean refuse_to_fetch_third_party_urls = true;
|
||||
@@ -470,14 +481,6 @@ public class AppProperties {
|
||||
this.fhir_version = fhir_version;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@@ -42,10 +42,7 @@ import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.web.cors.CorsConfiguration;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class BaseJpaRestfulServer extends RestfulServer {
|
||||
@@ -357,15 +354,21 @@ public class BaseJpaRestfulServer extends RestfulServer {
|
||||
}
|
||||
|
||||
if (appProperties.getImplementationGuides() != null) {
|
||||
List<AppProperties.ImplementationGuide> guides = appProperties.getImplementationGuides();
|
||||
for (AppProperties.ImplementationGuide guide : guides) {
|
||||
Map<String, AppProperties.ImplementationGuide> guides = appProperties.getImplementationGuides();
|
||||
for (Map.Entry<String, AppProperties.ImplementationGuide> guide : guides.entrySet()) {
|
||||
packageInstallerSvc.install(new PackageInstallationSpec()
|
||||
.setPackageUrl(guide.getUrl())
|
||||
.setName(guide.getName())
|
||||
.setVersion(guide.getVersion())
|
||||
.setPackageUrl(guide.getValue().getUrl())
|
||||
.setName(guide.getValue().getName())
|
||||
.setVersion(guide.getValue().getVersion())
|
||||
.setInstallMode(PackageInstallationSpec.InstallModeEnum.STORE_AND_INSTALL));
|
||||
}
|
||||
}
|
||||
|
||||
if (appProperties.getLastn_enabled()) {
|
||||
daoConfig.setLastNEnabled(true);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package ca.uhn.fhir.jpa.starter;
|
||||
|
||||
import ca.uhn.fhir.jpa.search.elastic.ElasticsearchHibernatePropertiesBuilder;
|
||||
import org.hibernate.search.elasticsearch.cfg.ElasticsearchIndexStatus;
|
||||
import org.hibernate.search.elasticsearch.cfg.IndexSchemaManagementStrategy;
|
||||
import org.springframework.core.env.CompositePropertySource;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
import org.springframework.core.env.EnumerablePropertySource;
|
||||
@@ -35,9 +38,66 @@ public class EnvironmentHelper {
|
||||
properties.put(values[0], values[1]);
|
||||
});
|
||||
}
|
||||
|
||||
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);
|
||||
if (requiredIndexStatus == null) {
|
||||
builder.setRequiredIndexStatus(ElasticsearchIndexStatus.YELLOW);
|
||||
} else {
|
||||
builder.setRequiredIndexStatus(requiredIndexStatus);
|
||||
}
|
||||
|
||||
builder.setRestUrl(getElasticsearchServerUrl(environment));
|
||||
builder.setUsername(getElasticsearchServerUsername(environment));
|
||||
builder.setPassword(getElasticsearchServerPassword(environment));
|
||||
IndexSchemaManagementStrategy indexSchemaManagementStrategy = environment.getProperty("elasticsearch.schema_management_strategy", IndexSchemaManagementStrategy.class);
|
||||
if (indexSchemaManagementStrategy == null) {
|
||||
builder.setIndexSchemaManagementStrategy(IndexSchemaManagementStrategy.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);
|
||||
} else {
|
||||
builder.setDebugRefreshAfterWrite(refreshAfterWrite);
|
||||
}
|
||||
// pretty_print_json_log: false
|
||||
Boolean prettyPrintJsonLog = environment.getProperty("elasticsearch.debug.pretty_print_json_log", Boolean.class);
|
||||
if (prettyPrintJsonLog == null) {
|
||||
builder.setDebugPrettyPrintJsonLog(false);
|
||||
} else {
|
||||
builder.setDebugPrettyPrintJsonLog(prettyPrintJsonLog);
|
||||
}
|
||||
builder.apply(properties);
|
||||
}
|
||||
|
||||
return properties;
|
||||
}
|
||||
|
||||
public static String getElasticsearchServerUrl(ConfigurableEnvironment environment) {
|
||||
return environment.getProperty("elasticsearch.rest_url", String.class);
|
||||
}
|
||||
|
||||
public static String getElasticsearchServerUsername(ConfigurableEnvironment environment) {
|
||||
return environment.getProperty("elasticsearch.username");
|
||||
}
|
||||
|
||||
public static String getElasticsearchServerPassword(ConfigurableEnvironment environment) {
|
||||
return environment.getProperty("elasticsearch.password");
|
||||
}
|
||||
|
||||
public static Boolean isElasticsearchEnabled(ConfigurableEnvironment environment) {
|
||||
if (environment.getProperty("elasticsearch.enabled", Boolean.class) != null) {
|
||||
return environment.getProperty("elasticsearch.enabled", Boolean.class);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static Map<String, Object> getPropertiesStartingWith(ConfigurableEnvironment aEnv,
|
||||
String aKeyPrefix) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
|
||||
@@ -3,6 +3,7 @@ package ca.uhn.fhir.jpa.starter;
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.jpa.config.BaseJavaConfigDstu3;
|
||||
import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider;
|
||||
import ca.uhn.fhir.jpa.search.lastn.ElasticsearchSvcImpl;
|
||||
import ca.uhn.fhir.jpa.starter.annotations.OnDSTU3Condition;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.*;
|
||||
@@ -63,4 +64,18 @@ public class FhirServerConfigDstu3 extends BaseJavaConfigDstu3 {
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@Bean()
|
||||
public ElasticsearchSvcImpl elasticsearchSvc() {
|
||||
if (EnvironmentHelper.isElasticsearchEnabled(configurableEnvironment)) {
|
||||
String elasticsearchUrl = EnvironmentHelper.getElasticsearchServerUrl(configurableEnvironment);
|
||||
String elasticsearchHost = elasticsearchUrl.substring(elasticsearchUrl.indexOf("://")+3, elasticsearchUrl.lastIndexOf(":"));
|
||||
String elasticsearchUsername = EnvironmentHelper.getElasticsearchServerUsername(configurableEnvironment);
|
||||
String elasticsearchPassword = EnvironmentHelper.getElasticsearchServerPassword(configurableEnvironment);
|
||||
int elasticsearchPort = Integer.parseInt(elasticsearchUrl.substring(elasticsearchUrl.lastIndexOf(":")+1));
|
||||
return new ElasticsearchSvcImpl(elasticsearchHost, elasticsearchPort, elasticsearchUsername, elasticsearchPassword);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package ca.uhn.fhir.jpa.starter;
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.jpa.config.BaseJavaConfigR4;
|
||||
import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider;
|
||||
import ca.uhn.fhir.jpa.search.lastn.ElasticsearchSvcImpl;
|
||||
import ca.uhn.fhir.jpa.starter.annotations.OnR4Condition;
|
||||
import ca.uhn.fhir.jpa.starter.cql.StarterCqlR4Config;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -65,4 +66,18 @@ public class FhirServerConfigR4 extends BaseJavaConfigR4 {
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@Bean()
|
||||
public ElasticsearchSvcImpl elasticsearchSvc() {
|
||||
if (EnvironmentHelper.isElasticsearchEnabled(configurableEnvironment)) {
|
||||
String elasticsearchUrl = EnvironmentHelper.getElasticsearchServerUrl(configurableEnvironment);
|
||||
String elasticsearchHost = elasticsearchUrl.substring(elasticsearchUrl.indexOf("://")+3, elasticsearchUrl.lastIndexOf(":"));
|
||||
String elasticsearchUsername = EnvironmentHelper.getElasticsearchServerUsername(configurableEnvironment);
|
||||
String elasticsearchPassword = EnvironmentHelper.getElasticsearchServerPassword(configurableEnvironment);
|
||||
int elasticsearchPort = Integer.parseInt(elasticsearchUrl.substring(elasticsearchUrl.lastIndexOf(":")+1));
|
||||
return new ElasticsearchSvcImpl(elasticsearchHost, elasticsearchPort, elasticsearchUsername, elasticsearchPassword);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package ca.uhn.fhir.jpa.starter;
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.jpa.config.BaseJavaConfigR5;
|
||||
import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider;
|
||||
import ca.uhn.fhir.jpa.search.lastn.ElasticsearchSvcImpl;
|
||||
import ca.uhn.fhir.jpa.starter.annotations.OnR5Condition;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -66,4 +67,19 @@ public class FhirServerConfigR5 extends BaseJavaConfigR5 {
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@Bean()
|
||||
public ElasticsearchSvcImpl elasticsearchSvc() {
|
||||
if (EnvironmentHelper.isElasticsearchEnabled(configurableEnvironment)) {
|
||||
String elasticsearchUrl = EnvironmentHelper.getElasticsearchServerUrl(configurableEnvironment);
|
||||
String elasticsearchHost = elasticsearchUrl.substring(elasticsearchUrl.indexOf("://")+3, elasticsearchUrl.lastIndexOf(":"));
|
||||
String elasticsearchUsername = EnvironmentHelper.getElasticsearchServerUsername(configurableEnvironment);
|
||||
String elasticsearchPassword = EnvironmentHelper.getElasticsearchServerPassword(configurableEnvironment);
|
||||
int elasticsearchPort = Integer.parseInt(elasticsearchUrl.substring(elasticsearchUrl.lastIndexOf(":")+1));
|
||||
return new ElasticsearchSvcImpl(elasticsearchHost, elasticsearchPort, elasticsearchUsername, elasticsearchPassword);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -36,15 +36,15 @@ public class FhirTesterConfig {
|
||||
@Bean
|
||||
public TesterConfig testerConfig(AppProperties appProperties) {
|
||||
TesterConfig retVal = new TesterConfig();
|
||||
appProperties.getTester().stream().forEach(t -> {
|
||||
appProperties.getTester().entrySet().stream().forEach(t -> {
|
||||
retVal
|
||||
.addServer()
|
||||
.withId(t.getId())
|
||||
.withFhirVersion(t.getFhir_version())
|
||||
.withBaseUrl(t.getServer_address())
|
||||
.withName(t.getName());
|
||||
.withId(t.getKey())
|
||||
.withFhirVersion(t.getValue().getFhir_version())
|
||||
.withBaseUrl(t.getValue().getServer_address())
|
||||
.withName(t.getValue().getName());
|
||||
retVal.setRefuseToFetchThirdPartyUrls(
|
||||
t.getRefuse_to_fetch_third_party_urls());
|
||||
t.getValue().getRefuse_to_fetch_third_party_urls());
|
||||
|
||||
});
|
||||
return retVal;
|
||||
|
||||
Reference in New Issue
Block a user