Merge branch 'master' into batch-empi-job

This commit is contained in:
Tadgh 2020-07-07 07:52:42 -07:00
commit 86f2761580
3 changed files with 35 additions and 26 deletions

View File

@ -70,14 +70,19 @@ public class HapiFhirHibernateJpaDialect extends HibernateJpaDialect {
if (theException instanceof ConstraintViolationException) {
String constraintName = ((ConstraintViolationException) theException).getConstraintName();
/*
* Note: Compare the constraint name in a case-insensitive way. Most DBs preserve the case, but Postgresql
* will return it as lowercase even though the definition is in caps.
*/
if (isNotBlank(constraintName)) {
if (constraintName.contains(ResourceHistoryTable.IDX_RESVER_ID_VER)) {
if (constraintName.toUpperCase().contains(ResourceHistoryTable.IDX_RESVER_ID_VER)) {
throw new ResourceVersionConflictException(messageToPrepend + myLocalizer.getMessage(HapiFhirHibernateJpaDialect.class, "resourceVersionConstraintFailure"));
}
if (constraintName.contains(ResourceIndexedCompositeStringUnique.IDX_IDXCMPSTRUNIQ_STRING)) {
if (constraintName.toUpperCase().contains(ResourceIndexedCompositeStringUnique.IDX_IDXCMPSTRUNIQ_STRING)) {
throw new ResourceVersionConflictException(messageToPrepend + myLocalizer.getMessage(HapiFhirHibernateJpaDialect.class, "resourceIndexedCompositeStringUniqueConstraintFailure"));
}
if (constraintName.contains(ForcedId.IDX_FORCEDID_TYPE_FID)) {
if (constraintName.toUpperCase().contains(ForcedId.IDX_FORCEDID_TYPE_FID)) {
throw new ResourceVersionConflictException(messageToPrepend + myLocalizer.getMessage(HapiFhirHibernateJpaDialect.class, "forcedIdConstraintFailure"));
}
}

View File

@ -242,8 +242,10 @@ public class EmpiStorageInterceptorIT extends BaseEmpiR4Test {
}
@Test
public void testChecksOnlyApplyToRelevantResourceTypes() {
public void testInterceptorHandlesNonEmpiResources() {
setPreventEidUpdates(true);
//Create some arbitrary resource.
SearchParameter fooSp = new SearchParameter();
fooSp.setCode("foo");
fooSp.addBase("Bundle");
@ -254,9 +256,7 @@ public class EmpiStorageInterceptorIT extends BaseEmpiR4Test {
fooSp.setStatus(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.ACTIVE);
myEmpiHelper.doCreateResource(fooSp, true);
fooSp.setXpathUsage(SearchParameter.XPathUsageType.PHONETIC);
myEmpiHelper.doUpdateResource(fooSp, true);
}
@ -278,7 +278,7 @@ public class EmpiStorageInterceptorIT extends BaseEmpiR4Test {
Patient p = new Patient();
EmpiHelperR4.OutcomeAndLogMessageWrapper messageWrapper = myEmpiHelper.createWithLatch(p);
p.setId(messageWrapper.getDaoMethodOutcome().getId());
addExternalEID(p, "zoop");
addExternalEID(p, "external eid");
myEmpiHelper.updateWithLatch(p);
setPreventEidUpdates(false);
}

View File

@ -38,7 +38,6 @@ import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamUri;
import ca.uhn.fhir.jpa.model.entity.SearchParamPresent;
import ca.uhn.fhir.util.VersionEnum;
import javax.persistence.Column;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
@ -105,26 +104,31 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks<VersionEnum> {
pkgVer.addIndex("20200610.8", "IDX_PACKVER").unique(true).withColumns("PACKAGE_ID", "VERSION_ID");
version.addIdGenerator("20200610.9", "SEQ_NPM_PACKVERRES");
Builder.BuilderAddTableByColumns pkgVerRes = version.addTableByColumns("20200610.10", "NPM_PACKAGE_VER_RES", "PID");
pkgVerRes.addColumn("PID").nonNullable().type(ColumnTypeEnum.LONG);
pkgVerRes.addColumn("PACKVER_PID").nonNullable().type(ColumnTypeEnum.LONG);
pkgVerRes.addColumn("BINARY_RES_ID").nonNullable().type(ColumnTypeEnum.LONG);
pkgVerRes.addColumn("FILE_DIR").nullable().type(ColumnTypeEnum.STRING, 200);
pkgVerRes.addColumn("FILE_NAME").nullable().type(ColumnTypeEnum.STRING, 200);
pkgVerRes.addColumn("RES_TYPE").nonNullable().type(ColumnTypeEnum.STRING, 40);
pkgVerRes.addColumn("CANONICAL_URL").nullable().type(ColumnTypeEnum.STRING, 200);
pkgVerRes.addColumn("CANONICAL_VERSION").nullable().type(ColumnTypeEnum.STRING, 200);
pkgVerRes.addColumn("FHIR_VERSION_ID").nonNullable().type(ColumnTypeEnum.STRING, 10);
pkgVerRes.addColumn("FHIR_VERSION").nonNullable().type(ColumnTypeEnum.STRING, 10);
pkgVerRes.addColumn("RES_SIZE_BYTES").nonNullable().type(ColumnTypeEnum.LONG);
pkgVerRes.addColumn("UPDATED_TIME").nonNullable().type(ColumnTypeEnum.DATE_TIMESTAMP);
pkgVerRes.addForeignKey("20200610.11", "FK_NPM_PACKVERRES_PACKVER").toColumn("PACKVER_PID").references("NPM_PACKAGE_VER", "PID");
pkgVerRes.addForeignKey("20200610.12", "FK_NPM_PKVR_RESID").toColumn("BINARY_RES_ID").references("HFJ_RESOURCE", "RES_ID");
pkgVerRes.addIndex("20200610.13", "IDX_PACKVERRES_URL").unique(false).withColumns("CANONICAL_URL");
Builder.BuilderAddTableByColumns pkgVerResAdd = version.addTableByColumns("20200610.10", "NPM_PACKAGE_VER_RES", "PID");
pkgVerResAdd.addColumn("PID").nonNullable().type(ColumnTypeEnum.LONG);
pkgVerResAdd.addColumn("PACKVER_PID").nonNullable().type(ColumnTypeEnum.LONG);
pkgVerResAdd.addColumn("BINARY_RES_ID").nonNullable().type(ColumnTypeEnum.LONG);
pkgVerResAdd.addColumn("FILE_DIR").nullable().type(ColumnTypeEnum.STRING, 200);
pkgVerResAdd.addColumn("FILE_NAME").nullable().type(ColumnTypeEnum.STRING, 200);
pkgVerResAdd.addColumn("RES_TYPE").nonNullable().type(ColumnTypeEnum.STRING, 40);
pkgVerResAdd.addColumn("CANONICAL_URL").nullable().type(ColumnTypeEnum.STRING, 200);
pkgVerResAdd.addColumn("CANONICAL_VERSION").nullable().type(ColumnTypeEnum.STRING, 200);
pkgVerResAdd.addColumn("FHIR_VERSION_ID").nonNullable().type(ColumnTypeEnum.STRING, 10);
pkgVerResAdd.addColumn("FHIR_VERSION").nonNullable().type(ColumnTypeEnum.STRING, 10);
pkgVerResAdd.addColumn("RES_SIZE_BYTES").nonNullable().type(ColumnTypeEnum.LONG);
pkgVerResAdd.addColumn("UPDATED_TIME").nonNullable().type(ColumnTypeEnum.DATE_TIMESTAMP);
pkgVerResAdd.addForeignKey("20200610.11", "FK_NPM_PACKVERRES_PACKVER").toColumn("PACKVER_PID").references("NPM_PACKAGE_VER", "PID");
pkgVerResAdd.addForeignKey("20200610.12", "FK_NPM_PKVR_RESID").toColumn("BINARY_RES_ID").references("HFJ_RESOURCE", "RES_ID");
pkgVerResAdd.addIndex("20200610.13", "IDX_PACKVERRES_URL").unique(false).withColumns("CANONICAL_URL");
pkgVerRes.modifyColumn("20200629.1", "PKG_DESC").nullable().withType(ColumnTypeEnum.STRING, 200);
pkgVerRes.modifyColumn("20200629.2", "DESC_UPPER").nullable().withType(ColumnTypeEnum.STRING, 200);
init510_20200610();
Builder.BuilderWithTableName pkgVerMod = version.onTable("NPM_PACKAGE_VER");
pkgVerMod.modifyColumn("20200629.1", "PKG_DESC").nullable().withType(ColumnTypeEnum.STRING, 200);
pkgVerMod.modifyColumn("20200629.2", "DESC_UPPER").nullable().withType(ColumnTypeEnum.STRING, 200);
}
protected void init510_20200610() {
}
private void init501() { //20200514 - present