Merge remote-tracking branch 'remotes/origin/master' into im_20200728_term_multi_version_support

This commit is contained in:
ianmarshall 2020-09-09 17:38:24 -04:00
commit d00db11586
9 changed files with 61 additions and 30 deletions

View File

@ -40,9 +40,8 @@ public class HapiLocalizer {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(HapiLocalizer.class); private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(HapiLocalizer.class);
private static boolean ourFailOnMissingMessage; private static boolean ourFailOnMissingMessage;
private final Map<String, MessageFormat> myKeyToMessageFormat = new ConcurrentHashMap<>(); private final Map<String, MessageFormat> myKeyToMessageFormat = new ConcurrentHashMap<>();
private List<ResourceBundle> myBundle = new ArrayList<>(); private List<ResourceBundle> myBundle;
private final Map<String, String> myHardcodedMessages = new HashMap<>(); private final Map<String, String> myHardcodedMessages = new HashMap<>();
private String[] myBundleNames;
private Locale myLocale = Locale.getDefault(); private Locale myLocale = Locale.getDefault();
public HapiLocalizer() { public HapiLocalizer() {
@ -50,8 +49,7 @@ public class HapiLocalizer {
} }
public HapiLocalizer(String... theBundleNames) { public HapiLocalizer(String... theBundleNames) {
myBundleNames = theBundleNames; init(theBundleNames);
init();
addMessage("hapi.version", VersionUtil.getVersion()); addMessage("hapi.version", VersionUtil.getVersion());
} }
@ -159,8 +157,9 @@ public class HapiLocalizer {
return new MessageFormat(pattern.toString()); return new MessageFormat(pattern.toString());
} }
protected void init() { protected void init(String[] theBundleNames) {
for (String nextName : myBundleNames) { myBundle = new ArrayList<>();
for (String nextName : theBundleNames) {
myBundle.add(ResourceBundle.getBundle(nextName)); myBundle.add(ResourceBundle.getBundle(nextName));
} }
} }

View File

@ -50,6 +50,7 @@ public abstract class BaseColumnCalculatorTask extends BaseTableColumnTask {
protected static final Logger ourLog = LoggerFactory.getLogger(BaseColumnCalculatorTask.class); protected static final Logger ourLog = LoggerFactory.getLogger(BaseColumnCalculatorTask.class);
private int myBatchSize = 10000; private int myBatchSize = 10000;
private ThreadPoolExecutor myExecutor; private ThreadPoolExecutor myExecutor;
private String myPidColumnName;
/** /**
* Constructor * Constructor
@ -160,6 +161,10 @@ public abstract class BaseColumnCalculatorTask extends BaseTableColumnTask {
rejectedExecutionHandler); rejectedExecutionHandler);
} }
public void setPidColumnName(String thePidColumnName) {
myPidColumnName = thePidColumnName;
}
private Future<?> updateRows(List<Map<String, Object>> theRows) { private Future<?> updateRows(List<Map<String, Object>> theRows) {
Runnable task = () -> { Runnable task = () -> {
StopWatch sw = new StopWatch(); StopWatch sw = new StopWatch();
@ -193,8 +198,8 @@ public abstract class BaseColumnCalculatorTask extends BaseTableColumnTask {
sqlBuilder.append(nextNewValueEntry.getKey()).append(" = ?"); sqlBuilder.append(nextNewValueEntry.getKey()).append(" = ?");
arguments.add(nextNewValueEntry.getValue()); arguments.add(nextNewValueEntry.getValue());
} }
sqlBuilder.append(" WHERE SP_ID = ?"); sqlBuilder.append(" WHERE " + myPidColumnName + " = ?");
arguments.add((Number) nextRow.get("SP_ID")); arguments.add((Number) nextRow.get(myPidColumnName));
// Apply update SQL // Apply update SQL
newJdbcTemplate().update(sqlBuilder.toString(), arguments.toArray()); newJdbcTemplate().update(sqlBuilder.toString(), arguments.toArray());

View File

@ -46,6 +46,7 @@ public class CalculateHashesTask extends BaseColumnCalculatorTask {
public CalculateHashesTask(VersionEnum theRelease, String theVersion) { public CalculateHashesTask(VersionEnum theRelease, String theVersion) {
super(theRelease, theVersion); super(theRelease, theVersion);
setDescription("Calculate resource search parameter index hashes"); setDescription("Calculate resource search parameter index hashes");
setPidColumnName("SP_ID");
} }
@Override @Override

View File

@ -28,6 +28,7 @@ public class CalculateOrdinalDatesTask extends BaseColumnCalculatorTask {
super(theRelease, theVersion); super(theRelease, theVersion);
setDescription("Calculate SP_LOW_VALUE_DATE_ORDINAL and SP_HIGH_VALUE_DATE_ORDINAL based on existing SP_VALUE_LOW and SP_VALUE_HIGH date values in Date Search Params"); setDescription("Calculate SP_LOW_VALUE_DATE_ORDINAL and SP_HIGH_VALUE_DATE_ORDINAL based on existing SP_VALUE_LOW and SP_VALUE_HIGH date values in Date Search Params");
setWhereClause("(SP_VALUE_LOW_DATE_ORDINAL IS NULL AND SP_VALUE_LOW IS NOT NULL) OR (SP_VALUE_HIGH_DATE_ORDINAL IS NULL AND SP_VALUE_HIGH IS NOT NULL)"); setWhereClause("(SP_VALUE_LOW_DATE_ORDINAL IS NULL AND SP_VALUE_LOW IS NOT NULL) OR (SP_VALUE_HIGH_DATE_ORDINAL IS NULL AND SP_VALUE_HIGH IS NOT NULL)");
setPidColumnName("SP_ID");
} }
@Override @Override

View File

@ -6,6 +6,7 @@ import ca.uhn.fhir.jpa.model.entity.ModelConfig;
import ca.uhn.fhir.jpa.search.LuceneSearchMappingFactory; import ca.uhn.fhir.jpa.search.LuceneSearchMappingFactory;
import ca.uhn.fhir.jpa.util.CurrentThreadCaptureQueriesListener; import ca.uhn.fhir.jpa.util.CurrentThreadCaptureQueriesListener;
import ca.uhn.fhir.jpa.util.DerbyTenSevenHapiFhirDialect; import ca.uhn.fhir.jpa.util.DerbyTenSevenHapiFhirDialect;
import ca.uhn.fhir.jpa.validation.ValidationSettings;
import ca.uhn.fhir.rest.server.interceptor.RequestValidatingInterceptor; import ca.uhn.fhir.rest.server.interceptor.RequestValidatingInterceptor;
import ca.uhn.fhir.validation.IValidatorModule; import ca.uhn.fhir.validation.IValidatorModule;
import ca.uhn.fhir.validation.ResultSeverityEnum; import ca.uhn.fhir.validation.ResultSeverityEnum;
@ -15,6 +16,7 @@ import org.apache.commons.dbcp2.BasicDataSource;
import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.lang3.time.DateUtils;
import org.hibernate.dialect.PostgreSQL94Dialect; import org.hibernate.dialect.PostgreSQL94Dialect;
import org.hl7.fhir.dstu2.model.Subscription; import org.hl7.fhir.dstu2.model.Subscription;
import org.hl7.fhir.r5.utils.IResourceValidator;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -81,6 +83,15 @@ public class TestDstu2Config extends BaseJavaConfigDstu2 {
return daoConfig().getModelConfig(); return daoConfig().getModelConfig();
} }
@Override
@Bean
public ValidationSettings validationSettings() {
ValidationSettings retVal = super.validationSettings();
retVal.setLocalReferenceValidationDefaultPolicy(IResourceValidator.ReferenceValidationPolicy.CHECK_VALID);
return retVal;
}
@Bean(name = "myPersistenceDataSourceDstu1", destroyMethod = "close") @Bean(name = "myPersistenceDataSourceDstu1", destroyMethod = "close")
public DataSource dataSource() { public DataSource dataSource() {
BasicDataSource retVal = new BasicDataSource(); BasicDataSource retVal = new BasicDataSource();

View File

@ -7,6 +7,7 @@ import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider;
import ca.uhn.fhir.jpa.search.LuceneSearchMappingFactory; import ca.uhn.fhir.jpa.search.LuceneSearchMappingFactory;
import ca.uhn.fhir.jpa.util.CurrentThreadCaptureQueriesListener; import ca.uhn.fhir.jpa.util.CurrentThreadCaptureQueriesListener;
import ca.uhn.fhir.jpa.util.DerbyTenSevenHapiFhirDialect; import ca.uhn.fhir.jpa.util.DerbyTenSevenHapiFhirDialect;
import ca.uhn.fhir.jpa.validation.ValidationSettings;
import ca.uhn.fhir.rest.server.interceptor.RequestValidatingInterceptor; import ca.uhn.fhir.rest.server.interceptor.RequestValidatingInterceptor;
import ca.uhn.fhir.validation.ResultSeverityEnum; import ca.uhn.fhir.validation.ResultSeverityEnum;
import ca.uhn.fhirtest.interceptor.PublicSecurityInterceptor; import ca.uhn.fhirtest.interceptor.PublicSecurityInterceptor;
@ -15,6 +16,7 @@ import org.apache.commons.dbcp2.BasicDataSource;
import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.lang3.time.DateUtils;
import org.hibernate.dialect.PostgreSQL94Dialect; import org.hibernate.dialect.PostgreSQL94Dialect;
import org.hl7.fhir.dstu2.model.Subscription; import org.hl7.fhir.dstu2.model.Subscription;
import org.hl7.fhir.r5.utils.IResourceValidator;
import org.springframework.beans.factory.annotation.Autowire; import org.springframework.beans.factory.annotation.Autowire;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
@ -80,6 +82,17 @@ public class TestDstu3Config extends BaseJavaConfigDstu3 {
} }
@Override
@Bean
public ValidationSettings validationSettings() {
ValidationSettings retVal = super.validationSettings();
retVal.setLocalReferenceValidationDefaultPolicy(IResourceValidator.ReferenceValidationPolicy.CHECK_VALID);
return retVal;
}
@Override @Override
@Bean(autowire = Autowire.BY_TYPE) @Bean(autowire = Autowire.BY_TYPE)
public DatabaseBackedPagingProvider databaseBackedPagingProvider() { public DatabaseBackedPagingProvider databaseBackedPagingProvider() {

View File

@ -7,6 +7,7 @@ import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider;
import ca.uhn.fhir.jpa.search.LuceneSearchMappingFactory; import ca.uhn.fhir.jpa.search.LuceneSearchMappingFactory;
import ca.uhn.fhir.jpa.util.CurrentThreadCaptureQueriesListener; import ca.uhn.fhir.jpa.util.CurrentThreadCaptureQueriesListener;
import ca.uhn.fhir.jpa.util.DerbyTenSevenHapiFhirDialect; import ca.uhn.fhir.jpa.util.DerbyTenSevenHapiFhirDialect;
import ca.uhn.fhir.jpa.validation.ValidationSettings;
import ca.uhn.fhir.rest.client.interceptor.ThreadLocalCapturingInterceptor; import ca.uhn.fhir.rest.client.interceptor.ThreadLocalCapturingInterceptor;
import ca.uhn.fhir.rest.server.interceptor.RequestValidatingInterceptor; import ca.uhn.fhir.rest.server.interceptor.RequestValidatingInterceptor;
import ca.uhn.fhir.validation.ResultSeverityEnum; import ca.uhn.fhir.validation.ResultSeverityEnum;
@ -16,6 +17,7 @@ import org.apache.commons.dbcp2.BasicDataSource;
import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.lang3.time.DateUtils;
import org.hibernate.dialect.PostgreSQL94Dialect; import org.hibernate.dialect.PostgreSQL94Dialect;
import org.hl7.fhir.dstu2.model.Subscription; import org.hl7.fhir.dstu2.model.Subscription;
import org.hl7.fhir.r5.utils.IResourceValidator;
import org.springframework.beans.factory.annotation.Autowire; import org.springframework.beans.factory.annotation.Autowire;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
@ -81,6 +83,15 @@ public class TestR4Config extends BaseJavaConfigR4 {
} }
@Override
@Bean
public ValidationSettings validationSettings() {
ValidationSettings retVal = super.validationSettings();
retVal.setLocalReferenceValidationDefaultPolicy(IResourceValidator.ReferenceValidationPolicy.CHECK_VALID);
return retVal;
}
@Bean(name = "myPersistenceDataSourceR4", destroyMethod = "close") @Bean(name = "myPersistenceDataSourceR4", destroyMethod = "close")
public DataSource dataSource() { public DataSource dataSource() {
BasicDataSource retVal = new BasicDataSource(); BasicDataSource retVal = new BasicDataSource();

View File

@ -7,6 +7,7 @@ import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider;
import ca.uhn.fhir.jpa.search.LuceneSearchMappingFactory; import ca.uhn.fhir.jpa.search.LuceneSearchMappingFactory;
import ca.uhn.fhir.jpa.util.CurrentThreadCaptureQueriesListener; import ca.uhn.fhir.jpa.util.CurrentThreadCaptureQueriesListener;
import ca.uhn.fhir.jpa.util.DerbyTenSevenHapiFhirDialect; import ca.uhn.fhir.jpa.util.DerbyTenSevenHapiFhirDialect;
import ca.uhn.fhir.jpa.validation.ValidationSettings;
import ca.uhn.fhir.rest.server.interceptor.RequestValidatingInterceptor; import ca.uhn.fhir.rest.server.interceptor.RequestValidatingInterceptor;
import ca.uhn.fhir.validation.ResultSeverityEnum; import ca.uhn.fhir.validation.ResultSeverityEnum;
import ca.uhn.fhirtest.interceptor.PublicSecurityInterceptor; import ca.uhn.fhirtest.interceptor.PublicSecurityInterceptor;
@ -15,6 +16,7 @@ import org.apache.commons.dbcp2.BasicDataSource;
import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.lang3.time.DateUtils;
import org.hibernate.dialect.PostgreSQL94Dialect; import org.hibernate.dialect.PostgreSQL94Dialect;
import org.hl7.fhir.dstu2.model.Subscription; import org.hl7.fhir.dstu2.model.Subscription;
import org.hl7.fhir.r5.utils.IResourceValidator;
import org.springframework.beans.factory.annotation.Autowire; import org.springframework.beans.factory.annotation.Autowire;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
@ -79,6 +81,16 @@ public class TestR5Config extends BaseJavaConfigR5 {
return daoConfig().getModelConfig(); return daoConfig().getModelConfig();
} }
@Override
@Bean
public ValidationSettings validationSettings() {
ValidationSettings retVal = super.validationSettings();
retVal.setLocalReferenceValidationDefaultPolicy(IResourceValidator.ReferenceValidationPolicy.CHECK_VALID);
return retVal;
}
@Bean(name = "myPersistenceDataSourceR5", destroyMethod = "close") @Bean(name = "myPersistenceDataSourceR5", destroyMethod = "close")
public DataSource dataSource() { public DataSource dataSource() {

View File

@ -38,8 +38,6 @@ public class FhirInstanceValidator extends BaseValidatorBridge implements IInsta
private boolean assumeValidRestReferences; private boolean assumeValidRestReferences;
private List<String> myExtensionDomains = Collections.emptyList(); private List<String> myExtensionDomains = Collections.emptyList();
private IResourceValidator.IValidatorResourceFetcher validatorResourceFetcher; private IResourceValidator.IValidatorResourceFetcher validatorResourceFetcher;
private volatile FhirContext myDstu2Context;
private volatile FhirContext myHl7OrgDstu2Context;
/** /**
* Constructor * Constructor
@ -136,8 +134,6 @@ public class FhirInstanceValidator extends BaseValidatorBridge implements IInsta
/** /**
* Returns the {@link IValidationSupport validation support} in use by this validator. Default is an instance of * Returns the {@link IValidationSupport validation support} in use by this validator. Default is an instance of
* DefaultProfileValidationSupport if the no-arguments constructor for this object was used. * DefaultProfileValidationSupport if the no-arguments constructor for this object was used.
*
* @return
*/ */
public IValidationSupport getValidationSupport() { public IValidationSupport getValidationSupport() {
return myValidationSupport; return myValidationSupport;
@ -276,24 +272,6 @@ public class FhirInstanceValidator extends BaseValidatorBridge implements IInsta
return wrappedWorkerContext; return wrappedWorkerContext;
} }
private FhirContext getDstu2Context() {
FhirContext dstu2Context = myDstu2Context;
if (dstu2Context == null) {
dstu2Context = FhirContext.forDstu2();
myDstu2Context = dstu2Context;
}
return dstu2Context;
}
private FhirContext getHl7OrgDstu2Context() {
FhirContext hl7OrgDstu2Context = myHl7OrgDstu2Context;
if (hl7OrgDstu2Context == null) {
hl7OrgDstu2Context = FhirContext.forDstu2Hl7Org();
myHl7OrgDstu2Context = hl7OrgDstu2Context;
}
return hl7OrgDstu2Context;
}
public IResourceValidator.IValidatorResourceFetcher getValidatorResourceFetcher() { public IResourceValidator.IValidatorResourceFetcher getValidatorResourceFetcher() {
return validatorResourceFetcher; return validatorResourceFetcher;
} }