Merge pull request #3 from lantanagroup/master

Using a configurable properties file
This commit is contained in:
James Agnew
2019-02-07 20:19:22 -05:00
committed by GitHub
6 changed files with 328 additions and 58 deletions

View File

@@ -1,10 +1,13 @@
package ca.uhn.fhir.jpa.demo; package ca.uhn.fhir.jpa.demo;
import java.lang.reflect.InvocationTargetException;
import java.sql.Driver;
import java.util.Properties; import java.util.Properties;
import javax.persistence.EntityManagerFactory; import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource; import javax.sql.DataSource;
import ca.uhn.fhir.context.ConfigurationException;
import ca.uhn.fhir.jpa.model.entity.ModelConfig; import ca.uhn.fhir.jpa.model.entity.ModelConfig;
import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider; import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider;
import ca.uhn.fhir.jpa.search.LuceneSearchMappingFactory; import ca.uhn.fhir.jpa.search.LuceneSearchMappingFactory;
@@ -40,7 +43,9 @@ public class FhirServerConfig extends BaseJavaConfigDstu3 {
@Bean() @Bean()
public DaoConfig daoConfig() { public DaoConfig daoConfig() {
DaoConfig retVal = new DaoConfig(); DaoConfig retVal = new DaoConfig();
retVal.setAllowMultipleDelete(true); retVal.setAllowMultipleDelete(HapiProperties.getAllowMultipleDelete());
retVal.setAllowExternalReferences(HapiProperties.getAllowExternalReferences());
retVal.setExpungeEnabled(HapiProperties.getExpungeEnabled());
// You can enable these if you want to support Subscriptions from your server // You can enable these if you want to support Subscriptions from your server
if (false) { if (false) {
@@ -66,8 +71,8 @@ public class FhirServerConfig extends BaseJavaConfigDstu3 {
@Override @Override
public DatabaseBackedPagingProvider databaseBackedPagingProvider() { public DatabaseBackedPagingProvider databaseBackedPagingProvider() {
DatabaseBackedPagingProvider pagingProvider = super.databaseBackedPagingProvider(); DatabaseBackedPagingProvider pagingProvider = super.databaseBackedPagingProvider();
pagingProvider.setDefaultPageSize(20); pagingProvider.setDefaultPageSize(HapiProperties.getDefaultPageSize());
pagingProvider.setMaximumPageSize(200); pagingProvider.setMaximumPageSize(HapiProperties.getMaximumPageSize());
return pagingProvider; return pagingProvider;
} }
@@ -78,12 +83,13 @@ public class FhirServerConfig extends BaseJavaConfigDstu3 {
* A URL to a remote database could also be placed here, along with login credentials and other properties supported by BasicDataSource. * A URL to a remote database could also be placed here, along with login credentials and other properties supported by BasicDataSource.
*/ */
@Bean(destroyMethod = "close") @Bean(destroyMethod = "close")
public BasicDataSource dataSource() { public BasicDataSource dataSource() throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
BasicDataSource retVal = new BasicDataSource(); BasicDataSource retVal = new BasicDataSource();
retVal.setDriver(new org.apache.derby.jdbc.EmbeddedDriver()); Driver driver = (Driver) Class.forName(HapiProperties.getDataSourceDriver()).getConstructor().newInstance();
retVal.setUrl("jdbc:derby:directory:target/jpaserver_derby_files;create=true"); retVal.setDriver(driver);
retVal.setUsername(""); retVal.setUrl(HapiProperties.getDataSourceUrl());
retVal.setPassword(""); retVal.setUsername(HapiProperties.getDataSourceUsername());
retVal.setPassword(HapiProperties.getDataSourcePassword());
return retVal; return retVal;
} }
@@ -91,28 +97,25 @@ public class FhirServerConfig extends BaseJavaConfigDstu3 {
@Bean() @Bean()
public LocalContainerEntityManagerFactoryBean entityManagerFactory() { public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
LocalContainerEntityManagerFactoryBean retVal = super.entityManagerFactory(); LocalContainerEntityManagerFactoryBean retVal = super.entityManagerFactory();
retVal.setPersistenceUnitName("HAPI_PU"); retVal.setPersistenceUnitName(HapiProperties.getPersistenceUnitName());
try {
retVal.setDataSource(dataSource()); retVal.setDataSource(dataSource());
} catch (Exception e) {
throw new ConfigurationException("Could not set the data source due to a configuration issue", e);
}
retVal.setJpaProperties(jpaProperties()); retVal.setJpaProperties(jpaProperties());
return retVal; return retVal;
} }
private Properties jpaProperties() { private Properties jpaProperties() {
Properties extraProperties = new Properties(); Properties extraProperties = HapiProperties.getProperties();
extraProperties.put("hibernate.dialect", DerbyTenSevenHapiFhirDialect.class.getName());
extraProperties.put("hibernate.format_sql", "false"); if (extraProperties == null) {
extraProperties.put("hibernate.show_sql", "false"); extraProperties = new Properties();
extraProperties.put("hibernate.hbm2ddl.auto", "update"); }
extraProperties.put("hibernate.jdbc.batch_size", "20");
extraProperties.put("hibernate.cache.use_query_cache", "false");
extraProperties.put("hibernate.cache.use_second_level_cache", "false");
extraProperties.put("hibernate.cache.use_structured_entries", "false");
extraProperties.put("hibernate.cache.use_minimal_puts", "false");
extraProperties.put("hibernate.search.model_mapping", LuceneSearchMappingFactory.class.getName());
extraProperties.put("hibernate.search.default.directory_provider", "filesystem");
extraProperties.put("hibernate.search.default.indexBase", "target/lucenefiles");
extraProperties.put("hibernate.search.lucene_version", "LUCENE_CURRENT");
// extraProperties.put("hibernate.search.default.worker.execution", "async");
return extraProperties; return extraProperties;
} }
@@ -121,11 +124,10 @@ public class FhirServerConfig extends BaseJavaConfigDstu3 {
*/ */
public IServerInterceptor loggingInterceptor() { public IServerInterceptor loggingInterceptor() {
LoggingInterceptor retVal = new LoggingInterceptor(); LoggingInterceptor retVal = new LoggingInterceptor();
retVal.setLoggerName("fhirtest.access"); retVal.setLoggerName(HapiProperties.getLoggerName());
retVal.setMessageFormat( retVal.setMessageFormat(HapiProperties.getLoggerFormat());
"Path[${servletPath}] Source[${requestHeader.x-forwarded-for}] Operation[${operationType} ${operationName} ${idOrResourceName}] UA[${requestHeader.user-agent}] Params[${requestParameters}] ResponseEncoding[${responseEncodingNoDefault}]"); retVal.setErrorMessageFormat(HapiProperties.getLoggerErrorFormat());
retVal.setLogExceptions(true); retVal.setLogExceptions(HapiProperties.getLoggerLogExceptions());
retVal.setErrorMessageFormat("ERROR - ${requestVerb} ${requestUrl}");
return retVal; return retVal;
} }
@@ -150,5 +152,4 @@ public class FhirServerConfig extends BaseJavaConfigDstu3 {
retVal.setEntityManagerFactory(entityManagerFactory); retVal.setEntityManagerFactory(entityManagerFactory);
return retVal; return retVal;
} }
} }

View File

@@ -4,7 +4,6 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
import ca.uhn.fhir.context.FhirVersionEnum;
import ca.uhn.fhir.to.FhirTesterMvcConfig; import ca.uhn.fhir.to.FhirTesterMvcConfig;
import ca.uhn.fhir.to.TesterConfig; import ca.uhn.fhir.to.TesterConfig;
@@ -40,10 +39,10 @@ public class FhirTesterConfig {
TesterConfig retVal = new TesterConfig(); TesterConfig retVal = new TesterConfig();
retVal retVal
.addServer() .addServer()
.withId("home") .withId(HapiProperties.getServerId())
.withFhirVersion(FhirVersionEnum.DSTU3) .withFhirVersion(HapiProperties.getFhirVersion())
.withBaseUrl("${serverBase}/baseDstu3") .withBaseUrl("${serverBase}" + HapiProperties.getServerBase())
.withName("Local Tester"); .withName(HapiProperties.getServerName());
return retVal; return retVal;
} }

View File

@@ -0,0 +1,210 @@
package ca.uhn.fhir.jpa.demo;
import ca.uhn.fhir.context.ConfigurationException;
import ca.uhn.fhir.context.FhirVersionEnum;
import ca.uhn.fhir.rest.api.EncodingEnum;
import ca.uhn.fhir.rest.server.ETagSupportEnum;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
public class HapiProperties {
public static final String SERVER_ADDRESS = "server_address";
public static final String DEFAULT_PRETTY_PRINT = "default_pretty_print";
public static final String MAX_PAGE_SIZE = "max_page_size";
public static final String DEFAULT_PAGE_SIZE = "default_page_size";
public static final String LOGGER_NAME = "logger.name";
public static final String LOGGER_FORMAT = "logger.format";
public static final String ALLOW_EXTERNAL_REFERENCES = "allow_external_references";
public static final String ALLOW_MULTIPLE_DELETE = "allow_multiple_delete";
public static final String DATASOURCE_PASSWORD = "datasource.password";
public static final String DATASOURCE_USERNAME = "datasource.username";
public static final String DATASOURCE_URL = "datasource.url";
public static final String DATASOURCE_DRIVER = "datasource.driver";
public static final String LOGGER_LOG_EXCEPTIONS = "logger.log_exceptions";
public static final String LOGGER_ERROR_FORMAT = "logger.error_format";
public static final String PERSISTENCE_UNIT_NAME = "persistence_unit_name";
public static final String SERVER_BASE = "server.base";
public static final String TEST_PORT = "test.port";
public static final String SERVER_NAME = "server.name";
public static final String SERVER_ID = "server.id";
private static Properties properties;
private static final String HAPI_PROPERTIES = "hapi.properties";
private static final String FHIR_VERSION = "fhir_version";
private static final String DEFAULT_ENCODING = "default_encoding";
private static final String ETAG_SUPPORT = "etag_support";
public static Properties getProperties() {
if (properties == null) {
// Load the configurable properties file
InputStream in = null;
try {
in = HapiProperties.class.getClassLoader().getResourceAsStream(HAPI_PROPERTIES);
HapiProperties.properties = new Properties();
HapiProperties.properties.load(in);
in.close();
} catch (Exception e) {
throw new ConfigurationException("Could not load HAPI properties", e);
}
}
return properties;
}
private static String getProperty(String propertyName) {
Properties properties = HapiProperties.getProperties();
if (properties != null) {
return properties.getProperty(propertyName);
}
return null;
}
private static String getProperty(String propertyName, String defaultValue) {
Properties properties = HapiProperties.getProperties();
if (properties != null) {
String value = properties.getProperty(propertyName);
if (value != null && value.length() > 0) {
return value;
}
}
return defaultValue;
}
private static Boolean getBooleanProperty(String propertyName, Boolean defaultValue) {
String value = HapiProperties.getProperty(propertyName);
if (value == null || value.length() == 0) {
return defaultValue;
}
return Boolean.parseBoolean(value);
}
private static Integer getIntegerProperty(String propertyName, Integer defaultValue) {
String value = HapiProperties.getProperty(propertyName);
if (value == null || value.length() == 0) {
return defaultValue;
}
return Integer.parseInt(value);
}
public static FhirVersionEnum getFhirVersion() {
String fhirVersionString = HapiProperties.getProperty(FHIR_VERSION);
if (fhirVersionString != null && fhirVersionString.length() > 0) {
return FhirVersionEnum.valueOf(fhirVersionString);
}
return FhirVersionEnum.DSTU3;
}
public static ETagSupportEnum getEtagSupport() {
String etagSupportString = HapiProperties.getProperty(ETAG_SUPPORT);
if (etagSupportString != null && etagSupportString.length() > 0) {
return ETagSupportEnum.valueOf(etagSupportString);
}
return ETagSupportEnum.ENABLED;
}
public static EncodingEnum getDefaultEncoding() {
String defaultEncodingString = HapiProperties.getProperty(DEFAULT_ENCODING);
if (defaultEncodingString != null && defaultEncodingString.length() > 0) {
return EncodingEnum.valueOf(defaultEncodingString);
}
return EncodingEnum.JSON;
}
public static Boolean getDefaultPrettyPrint() {
return HapiProperties.getBooleanProperty(DEFAULT_PRETTY_PRINT, true);
}
public static String getServerAddress() {
return HapiProperties.getProperty(SERVER_ADDRESS);
}
public static Integer getDefaultPageSize() {
return HapiProperties.getIntegerProperty(DEFAULT_PAGE_SIZE, 20);
}
public static Integer getMaximumPageSize() {
return HapiProperties.getIntegerProperty(MAX_PAGE_SIZE, 200);
}
public static String getPersistenceUnitName() {
return HapiProperties.getProperty(PERSISTENCE_UNIT_NAME, "HAPI_PU");
}
public static String getLoggerName() {
return HapiProperties.getProperty(LOGGER_NAME, "fhirtest.access");
}
public static String getLoggerFormat() {
return HapiProperties.getProperty(LOGGER_FORMAT, "Path[${servletPath}] Source[${requestHeader.x-forwarded-for}] Operation[${operationType} ${operationName} ${idOrResourceName}] UA[${requestHeader.user-agent}] Params[${requestParameters}] ResponseEncoding[${responseEncodingNoDefault}]");
}
public static String getLoggerErrorFormat() {
return HapiProperties.getProperty(LOGGER_ERROR_FORMAT, "ERROR - ${requestVerb} ${requestUrl}");
}
public static Boolean getLoggerLogExceptions() {
return HapiProperties.getBooleanProperty(LOGGER_LOG_EXCEPTIONS, true);
}
public static String getDataSourceDriver() {
return HapiProperties.getProperty(DATASOURCE_DRIVER, "org.apache.derby.jdbc.EmbeddedDriver");
}
public static String getDataSourceUrl() {
return HapiProperties.getProperty(DATASOURCE_URL, "jdbc:derby:directory:target/jpaserver_derby_files;create=true");
}
public static String getDataSourceUsername() {
return HapiProperties.getProperty(DATASOURCE_USERNAME);
}
public static String getDataSourcePassword() {
return HapiProperties.getProperty(DATASOURCE_PASSWORD);
}
public static Boolean getAllowMultipleDelete() {
return HapiProperties.getBooleanProperty(ALLOW_MULTIPLE_DELETE, true);
}
public static Boolean getAllowExternalReferences() {
return HapiProperties.getBooleanProperty(ALLOW_EXTERNAL_REFERENCES, true);
}
public static Boolean getExpungeEnabled() {
return HapiProperties.getBooleanProperty("expunge_enabled", true);
}
public static Integer getTestPort() {
return HapiProperties.getIntegerProperty(TEST_PORT, 0);
}
public static String getServerBase() {
return HapiProperties.getProperty(SERVER_BASE, "/baseDstu3");
}
public static String getServerName() {
return HapiProperties.getProperty(SERVER_NAME, "Local Tester");
}
public static String getServerId() {
return HapiProperties.getProperty(SERVER_ID, "home");
}
}

View File

@@ -10,11 +10,11 @@ import ca.uhn.fhir.jpa.provider.SubscriptionTriggeringProvider;
import ca.uhn.fhir.jpa.provider.dstu3.JpaConformanceProviderDstu3; import ca.uhn.fhir.jpa.provider.dstu3.JpaConformanceProviderDstu3;
import ca.uhn.fhir.jpa.provider.dstu3.JpaSystemProviderDstu3; import ca.uhn.fhir.jpa.provider.dstu3.JpaSystemProviderDstu3;
import ca.uhn.fhir.jpa.provider.dstu3.TerminologyUploaderProviderDstu3; import ca.uhn.fhir.jpa.provider.dstu3.TerminologyUploaderProviderDstu3;
import ca.uhn.fhir.jpa.provider.r4.JpaSystemProviderR4;
import ca.uhn.fhir.jpa.provider.r4.TerminologyUploaderProviderR4;
import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider; import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider;
import ca.uhn.fhir.model.dstu2.composite.MetaDt; import ca.uhn.fhir.model.dstu2.composite.MetaDt;
import ca.uhn.fhir.narrative.DefaultThymeleafNarrativeGenerator; import ca.uhn.fhir.narrative.DefaultThymeleafNarrativeGenerator;
import ca.uhn.fhir.rest.api.EncodingEnum;
import ca.uhn.fhir.rest.server.ETagSupportEnum;
import ca.uhn.fhir.rest.server.HardcodedServerAddressStrategy; import ca.uhn.fhir.rest.server.HardcodedServerAddressStrategy;
import ca.uhn.fhir.rest.server.IResourceProvider; import ca.uhn.fhir.rest.server.IResourceProvider;
import ca.uhn.fhir.rest.server.RestfulServer; import ca.uhn.fhir.rest.server.RestfulServer;
@@ -48,7 +48,7 @@ public class JpaServerDemo extends RestfulServer {
* *
* If you want to use DSTU1 instead, change the following line, and change the 2 occurrences of dstu2 in web.xml to dstu1 * If you want to use DSTU1 instead, change the following line, and change the 2 occurrences of dstu2 in web.xml to dstu1
*/ */
FhirVersionEnum fhirVersion = FhirVersionEnum.DSTU3; FhirVersionEnum fhirVersion = HapiProperties.getFhirVersion();
setFhirContext(new FhirContext(fhirVersion)); setFhirContext(new FhirContext(fhirVersion));
// Get the spring context from the web container (it's declared in web.xml) // Get the spring context from the web container (it's declared in web.xml)
@@ -64,6 +64,8 @@ public class JpaServerDemo extends RestfulServer {
resourceProviderBeanName = "myResourceProvidersDstu2"; resourceProviderBeanName = "myResourceProvidersDstu2";
} else if (fhirVersion == FhirVersionEnum.DSTU3) { } else if (fhirVersion == FhirVersionEnum.DSTU3) {
resourceProviderBeanName = "myResourceProvidersDstu3"; resourceProviderBeanName = "myResourceProvidersDstu3";
} else if (fhirVersion == FhirVersionEnum.R4) {
resourceProviderBeanName = "myResourceProviderR4";
} else { } else {
throw new IllegalStateException(); throw new IllegalStateException();
} }
@@ -79,6 +81,8 @@ public class JpaServerDemo extends RestfulServer {
systemProvider = myAppCtx.getBean("mySystemProviderDstu2", JpaSystemProviderDstu2.class); systemProvider = myAppCtx.getBean("mySystemProviderDstu2", JpaSystemProviderDstu2.class);
} else if (fhirVersion == FhirVersionEnum.DSTU3) { } else if (fhirVersion == FhirVersionEnum.DSTU3) {
systemProvider = myAppCtx.getBean("mySystemProviderDstu3", JpaSystemProviderDstu3.class); systemProvider = myAppCtx.getBean("mySystemProviderDstu3", JpaSystemProviderDstu3.class);
} else if (fhirVersion == FhirVersionEnum.R4) {
systemProvider = myAppCtx.getBean("mySystemProviderR4", JpaSystemProviderR4.class);
} else { } else {
throw new IllegalStateException(); throw new IllegalStateException();
} }
@@ -91,24 +95,27 @@ public class JpaServerDemo extends RestfulServer {
*/ */
if (fhirVersion == FhirVersionEnum.DSTU2) { if (fhirVersion == FhirVersionEnum.DSTU2) {
IFhirSystemDao<ca.uhn.fhir.model.dstu2.resource.Bundle, MetaDt> systemDao = myAppCtx.getBean("mySystemDaoDstu2", IFhirSystemDao.class); IFhirSystemDao<ca.uhn.fhir.model.dstu2.resource.Bundle, MetaDt> systemDao = myAppCtx.getBean("mySystemDaoDstu2", IFhirSystemDao.class);
JpaConformanceProviderDstu2 confProvider = new JpaConformanceProviderDstu2(this, systemDao, JpaConformanceProviderDstu2 confProvider = new JpaConformanceProviderDstu2(this, systemDao, myAppCtx.getBean(DaoConfig.class));
myAppCtx.getBean(DaoConfig.class)); confProvider.setImplementationDescription("HAPI FHIR DSTU2 Server");
confProvider.setImplementationDescription("Example Server");
setServerConformanceProvider(confProvider); setServerConformanceProvider(confProvider);
} else if (fhirVersion == FhirVersionEnum.DSTU3) { } else if (fhirVersion == FhirVersionEnum.DSTU3) {
IFhirSystemDao<Bundle, Meta> systemDao = myAppCtx.getBean("mySystemDaoDstu3", IFhirSystemDao.class); IFhirSystemDao<Bundle, Meta> systemDao = myAppCtx.getBean("mySystemDaoDstu3", IFhirSystemDao.class);
JpaConformanceProviderDstu3 confProvider = new JpaConformanceProviderDstu3(this, systemDao, JpaConformanceProviderDstu3 confProvider = new JpaConformanceProviderDstu3(this, systemDao, myAppCtx.getBean(DaoConfig.class));
myAppCtx.getBean(DaoConfig.class)); confProvider.setImplementationDescription("HAPI FHIR DSTU3 Server");
confProvider.setImplementationDescription("Example Server"); setServerConformanceProvider(confProvider);
} else if (fhirVersion == FhirVersionEnum.R4) {
IFhirSystemDao<Bundle, Meta> systemDao = myAppCtx.getBean("mySystemDaoR4", IFhirSystemDao.class);
JpaConformanceProviderDstu3 confProvider = new JpaConformanceProviderDstu3(this, systemDao, myAppCtx.getBean(DaoConfig.class));
confProvider.setImplementationDescription("HAPI FHIR R4 Server");
setServerConformanceProvider(confProvider); setServerConformanceProvider(confProvider);
} else { } else {
throw new IllegalStateException(); throw new IllegalStateException();
} }
/* /*
* Enable ETag Support (this is already the default) * ETag Support
*/ */
setETagSupport(ETagSupportEnum.ENABLED); setETagSupport(HapiProperties.getEtagSupport());
/* /*
* This server tries to dynamically generate narratives * This server tries to dynamically generate narratives
@@ -119,8 +126,12 @@ public class JpaServerDemo extends RestfulServer {
/* /*
* Default to JSON and pretty printing * Default to JSON and pretty printing
*/ */
setDefaultPrettyPrint(true); setDefaultPrettyPrint(HapiProperties.getDefaultPrettyPrint());
setDefaultResponseEncoding(EncodingEnum.JSON);
/*
* Default encoding
*/
setDefaultResponseEncoding(HapiProperties.getDefaultEncoding());
/* /*
* -- New in HAPI FHIR 1.5 -- * -- New in HAPI FHIR 1.5 --
@@ -145,8 +156,9 @@ public class JpaServerDemo extends RestfulServer {
* this doesn't always work. If you are setting links in your search bundles that * this doesn't always work. If you are setting links in your search bundles that
* just refer to "localhost", you might want to use a server address strategy: * just refer to "localhost", you might want to use a server address strategy:
*/ */
if (false) { // <-- DISABLED RIGHT NOW String serverAddress = HapiProperties.getServerAddress();
setServerAddressStrategy(new HardcodedServerAddressStrategy("http://mydomain.com/fhir/baseDstu3")); if (serverAddress != null && serverAddress.length() > 0) {
setServerAddressStrategy(new HardcodedServerAddressStrategy(serverAddress));
} }
/* /*
@@ -159,6 +171,8 @@ public class JpaServerDemo extends RestfulServer {
if (false) { // <-- DISABLED RIGHT NOW if (false) { // <-- DISABLED RIGHT NOW
if (fhirVersion == FhirVersionEnum.DSTU3) { if (fhirVersion == FhirVersionEnum.DSTU3) {
registerProvider(myAppCtx.getBean(TerminologyUploaderProviderDstu3.class)); registerProvider(myAppCtx.getBean(TerminologyUploaderProviderDstu3.class));
} else if (fhirVersion == FhirVersionEnum.R4) {
registerProvider(myAppCtx.getBean(TerminologyUploaderProviderR4.class));
} }
} }

View File

@@ -0,0 +1,35 @@
fhir_version=DSTU3
default_encoding=JSON
etag_support=ENABLED
server_address=http://mydomain.com/fhir/baseDstu3
default_page_size=20
max_page_size=200
allow_multiple_delete=true
allow_external_references=true
expunge_enabled=true
persistence_unit_name=HAPI_PU
logger.name=fhirtest.access
logger.format=Path[${servletPath}] Source[${requestHeader.x-forwarded-for}] Operation[${operationType} ${operationName} ${idOrResourceName}] UA[${requestHeader.user-agent}] Params[${requestParameters}] ResponseEncoding[${responseEncodingNoDefault}]
logger.error_format=ERROR - ${requestVerb} ${requestUrl}
logger.log_exceptions=true
datasource.driver=org.apache.derby.jdbc.EmbeddedDriver
datasource.url=jdbc:derby:directory:target/jpaserver_derby_files;create=true
datasource.username=
datasource.password=
server.base=/baseDstu3
server.name=Local Tester
server.id=home
test.port=
hibernate.dialect=ca.uhn.fhir.jpa.util.DerbyTenSevenHapiFhirDialect
hibernate.search.model_mapping=ca.uhn.fhir.jpa.search.LuceneSearchMappingFactory
hibernate.format_sql=false
hibernate.show_sql=false
hibernate.hbm2ddl.auto=update
hibernate.jdbc.batch_size=20
hibernate.cache.use_query_cache=false
hibernate.cache.use_second_level_cache=false
hibernate.cache.use_structured_entries=false
hibernate.cache.use_minimal_puts=false
hibernate.search.default.directory_provider=filesystem
hibernate.search.default.indexBase=target/lucenefiles
hibernate.search.lucene_version=LUCENE_CURRENT

View File

@@ -20,15 +20,29 @@ public class ExampleServerIT {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ExampleServerIT.class); private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ExampleServerIT.class);
private static IGenericClient ourClient; private static IGenericClient ourClient;
private static FhirContext ourCtx = FhirContext.forDstu3(); private static FhirContext ourCtx;
private static int ourPort; private static int ourPort;
private static Server ourServer; private static Server ourServer;
private static String ourServerBase; private static String ourServerBase;
static {
switch (HapiProperties.getFhirVersion()) {
case DSTU2:
ourCtx = FhirContext.forDstu2();
case R4:
ourCtx = FhirContext.forR4();
case DSTU3:
default:
ourCtx = FhirContext.forDstu3();
}
ourPort = HapiProperties.getTestPort();
}
@Test @Test
public void testCreateAndRead() throws IOException { public void testCreateAndRead() throws IOException {
ourLog.info("Base URL is: http://localhost:" + ourPort + "/baseDstu3"); ourLog.info("Base URL is: http://localhost:" + ourPort + HapiProperties.getServerBase());
String methodName = "testCreateResourceConditional"; String methodName = "testCreateResourceConditional";
Patient pt = new Patient(); Patient pt = new Patient();
@@ -72,16 +86,13 @@ public class ExampleServerIT {
ourCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER); ourCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER);
ourCtx.getRestfulClientFactory().setSocketTimeout(1200 * 1000); ourCtx.getRestfulClientFactory().setSocketTimeout(1200 * 1000);
ourServerBase = "http://localhost:" + ourPort + "/baseDstu3"; ourServerBase = "http://localhost:" + ourPort + HapiProperties.getServerBase();
ourClient = ourCtx.newRestfulGenericClient(ourServerBase); ourClient = ourCtx.newRestfulGenericClient(ourServerBase);
ourClient.registerInterceptor(new LoggingInterceptor(true)); ourClient.registerInterceptor(new LoggingInterceptor(true));
} }
public static void main(String[] theArgs) throws Exception { public static void main(String[] theArgs) throws Exception {
ourPort = 8080; ourPort = 8080;
beforeClass(); beforeClass();
} }
} }