Skip to content

Commit

Permalink
issue #4023 - use FHIRPersistenceTransaction instead of ITransactionP…
Browse files Browse the repository at this point in the history
…rovider

Signed-off-by: Lee Surprenant <lmsurpre@merative.com>
  • Loading branch information
lmsurpre committed Oct 20, 2022
1 parent 770fd13 commit a18dfce
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 10 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ jobs:
)
jdbc_paths=(
fhir-persistence-jdbc
fhir-persistence-params
fhir-search/src/main
fhir-persistence/src/main
fhir-persistence-schema/src/main
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@

package org.linuxforhealth.fhir.path;

import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

Expand Down Expand Up @@ -339,8 +337,10 @@ public enum FHIRPathType {

private static final Map<java.lang.String, FHIRPathType> TYPE_NAME_MAP = buildTypeNameMap();
private static final Map<Class<?>, FHIRPathType> TYPE_MAP = buildTypeMap();
private static final Set<FHIRPathType> SYSTEM_TYPES = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(SYSTEM_BOOLEAN, SYSTEM_STRING, SYSTEM_INTEGER, SYSTEM_DECIMAL, SYSTEM_DATE, SYSTEM_DATE_TIME, SYSTEM_QUANTITY, SYSTEM_TIME)));
private static final Set<FHIRPathType> METAMODEL_TYPES = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(SYSTEM_TYPE_INFO, SYSTEM_CLASS_INFO, SYSTEM_TUPLE_TYPE_INFO, SYSTEM_LIST_TYPE_INFO, SYSTEM_SIMPLE_TYPE_INFO)));
private static final Set<FHIRPathType> SYSTEM_TYPES =
Set.of(SYSTEM_BOOLEAN, SYSTEM_STRING, SYSTEM_INTEGER, SYSTEM_DECIMAL, SYSTEM_DATE, SYSTEM_DATE_TIME, SYSTEM_QUANTITY, SYSTEM_TIME);
private static final Set<FHIRPathType> METAMODEL_TYPES =
Set.of(SYSTEM_TYPE_INFO, SYSTEM_CLASS_INFO, SYSTEM_TUPLE_TYPE_INFO, SYSTEM_LIST_TYPE_INFO, SYSTEM_SIMPLE_TYPE_INFO);
private static final Map<Class<?>, FHIRPathType> METAMODEL_TYPE_MAP = buildMetamodelTypeMap();
private static final Map<Class<?>, FHIRPathType> JAVA_TYPE_MAP = buildJavaTypeMap();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.linuxforhealth.fhir.model.spec.test.IExampleProcessor;
import org.linuxforhealth.fhir.model.visitor.ResourceFingerprintVisitor;
import org.linuxforhealth.fhir.persistence.FHIRPersistence;
import org.linuxforhealth.fhir.persistence.FHIRPersistenceTransaction;
import org.linuxforhealth.fhir.persistence.context.FHIRHistoryContext;
import org.linuxforhealth.fhir.persistence.context.FHIRPersistenceContext;
import org.linuxforhealth.fhir.persistence.context.FHIRPersistenceContextFactory;
Expand Down Expand Up @@ -187,11 +188,20 @@ public void process(String jsonFile, Resource resource) throws Exception {
context.setOriginalFingerprint(v.getSaltAndHash());

if (this.persistence == null) {
try (ITransaction tx = this.transactionProvider.getTransaction()) {
// ITestResourceOperation#process throws Exception, which precludes the
// use of forEach here...so going old-school keeps it simpler
for (ITestResourceOperation op: operations) {

// ITestResourceOperation#process throws Exception, which precludes the
// use of forEach here...so going old-school keeps it simpler
for (ITestResourceOperation op: operations) {
FHIRPersistenceTransaction tx = context.getPersistence().getTransaction();
tx.begin();
try {
op.process(context);
} catch (Throwable t) {
tx.setRollbackOnly();
throw t;
} finally {
// will do a commit, or rollback if tx.setRollbackOnly() has been set
tx.end();
}
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,11 +330,12 @@ private void validate(FHIRPathResourceNode resourceNode) {
constraints.addAll(ProfileSupport.getConstraints(profiles, resourceType));
}

// path (with array indices) -> Extension instance (which never have a url version suffix)
Map<String, Extension> pathToExtension = gatherInstanceExtensions(resourceNode);
// path (with no array indices) -> Extension URLs (with no version suffix)
Map<String, Set<String>> alreadyGeneratedExtensionConstraints = gatherExtensionConstraints(constraints);

// path (with array indices) -> Extension instance (which never have a url version suffix)
Map<String, Extension> pathToExtension = gatherInstanceExtensions(resourceNode);

// for each extension in the resource instance
for (Entry<String, Extension> entry : pathToExtension.entrySet()) {
String path = entry.getKey();
Expand Down

0 comments on commit a18dfce

Please sign in to comment.