diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/BaseHapiTerminologySvcImpl.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/BaseHapiTerminologySvcImpl.java index 35dbff47e18..c33a6c3bc57 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/BaseHapiTerminologySvcImpl.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/BaseHapiTerminologySvcImpl.java @@ -1862,7 +1862,7 @@ public abstract class BaseHapiTerminologySvcImpl implements IHapiTerminologySvc, TermValueSet refreshedValueSetToExpand = myValueSetDao.findById(valueSetToExpand.getId()).get(); return getValueSetFromResourceTable(refreshedValueSetToExpand.getResource()); }); - expandValueSet(valueSet, new ValueSetConceptAccumulator(valueSetToExpand, myValueSetConceptDao, myValueSetConceptDesignationDao)); + expandValueSet(valueSet, new ValueSetConceptAccumulator(valueSetToExpand, myValueSetDao, myValueSetConceptDao, myValueSetConceptDesignationDao)); // We are done with this ValueSet. txTemplate.execute(t -> { diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/ValueSetConceptAccumulator.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/ValueSetConceptAccumulator.java index 92bf64b6453..c63788f3cf7 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/ValueSetConceptAccumulator.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/ValueSetConceptAccumulator.java @@ -22,6 +22,7 @@ package ca.uhn.fhir.jpa.term; import ca.uhn.fhir.jpa.dao.data.ITermValueSetConceptDao; import ca.uhn.fhir.jpa.dao.data.ITermValueSetConceptDesignationDao; +import ca.uhn.fhir.jpa.dao.data.ITermValueSetDao; import ca.uhn.fhir.jpa.entity.TermConceptDesignation; import ca.uhn.fhir.jpa.entity.TermValueSet; import ca.uhn.fhir.jpa.entity.TermValueSetConcept; @@ -38,13 +39,15 @@ public class ValueSetConceptAccumulator implements IValueSetConceptAccumulator { private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ValueSetConceptAccumulator.class); private TermValueSet myTermValueSet; + private ITermValueSetDao myValueSetDao; private ITermValueSetConceptDao myValueSetConceptDao; private ITermValueSetConceptDesignationDao myValueSetConceptDesignationDao; private int myConceptsSaved; private int myDesignationsSaved; - public ValueSetConceptAccumulator(@Nonnull TermValueSet theTermValueSet, @Nonnull ITermValueSetConceptDao theValueSetConceptDao, @Nonnull ITermValueSetConceptDesignationDao theValueSetConceptDesignationDao) { + public ValueSetConceptAccumulator(@Nonnull TermValueSet theTermValueSet, @Nonnull ITermValueSetDao theValueSetDao, @Nonnull ITermValueSetConceptDao theValueSetConceptDao, @Nonnull ITermValueSetConceptDesignationDao theValueSetConceptDesignationDao) { myTermValueSet = theTermValueSet; + myValueSetDao = theValueSetDao; myValueSetConceptDao = theValueSetConceptDao; myValueSetConceptDesignationDao = theValueSetConceptDesignationDao; myConceptsSaved = 0; @@ -83,11 +86,13 @@ public class ValueSetConceptAccumulator implements IValueSetConceptAccumulator { } myValueSetConceptDao.deleteById(concept.getId()); myTermValueSet.decrementTotalConcepts(); + myValueSetDao.save(myTermValueSet); ourLog.info("Done excluding [{}|{}] from ValueSet[{}]", concept.getSystem(), concept.getCode(), myTermValueSet.getUrl()); ourLog.info("Flushing..."); myValueSetConceptDesignationDao.flush(); myValueSetConceptDao.flush(); + myValueSetDao.flush(); ourLog.info("Done flushing."); } } @@ -104,7 +109,7 @@ public class ValueSetConceptAccumulator implements IValueSetConceptAccumulator { concept.setDisplay(theDisplay); } myValueSetConceptDao.save(concept); - myTermValueSet.incrementTotalConcepts(); + myValueSetDao.save(myTermValueSet.incrementTotalConcepts()); if (myConceptsSaved++ % 250 == 0) { // TODO: DM 2019-08-23 - This message never appears in the log. Fix it! ourLog.info("Have pre-expanded {} concepts in ValueSet[{}]", myConceptsSaved, myTermValueSet.getUrl()); @@ -129,7 +134,7 @@ public class ValueSetConceptAccumulator implements IValueSetConceptAccumulator { } designation.setValue(theDesignation.getValue()); myValueSetConceptDesignationDao.save(designation); - myTermValueSet.incrementTotalConceptDesignations(); + myValueSetDao.save(myTermValueSet.incrementTotalConceptDesignations()); if (myDesignationsSaved++ % 250 == 0) { // TODO: DM 2019-08-23 - This message never appears in the log. Fix it! ourLog.info("Have pre-expanded {} designations for Concept[{}|{}] in ValueSet[{}]", myDesignationsSaved, theConcept.getSystem(), theConcept.getCode(), myTermValueSet.getUrl());