Source:
private void expandValueSet(ValueSet theValueSetToExpand, IValueSetConceptAccumulator theValueSetCodeAccumulator, AtomicInteger theCodeCounter, VersionIndependentConcept theWantConceptOrNull) { Set<String> addedCodes = new HashSet<>(); StopWatch sw = new StopWatch(); String valueSetInfo = getValueSetInfo(theValueSetToExpand); ourLog.info("Working with {}", valueSetInfo); ourLog.debug("Handling includes"); for (ValueSet.ConceptSetComponent include : theValueSetToExpand.getCompose().getInclude()) { for (int i = 0; ; i++) { int queryIndex = i; Boolean shouldContinue = myTxTemplate.execute(t -> { boolean add = true; return expandValueSetHandleIncludeOrExclude(theValueSetCodeAccumulator, addedCodes, include, add, theCodeCounter, queryIndex, theWantConceptOrNull); }); if (!shouldContinue) { break; } } } if (Integer.valueOf(0).equals(theValueSetCodeAccumulator.getCapacityRemaining())) { String msg = myContext.getLocalizer().getMessage(BaseTermReadSvcImpl.class, "expansionTooLarge", myDaoConfig.getMaximumExpansionSize()); throw new ExpansionTooCostlyException(msg); } ourLog.debug("Handling excludes"); for (ValueSet.ConceptSetComponent exclude : theValueSetToExpand.getCompose().getExclude()) { for (int i = 0; ; i++) { int queryIndex = i; Boolean shouldContinue = myTxTemplate.execute(t -> { boolean add = false; return expandValueSetHandleIncludeOrExclude(theValueSetCodeAccumulator, addedCodes, exclude, add, theCodeCounter, queryIndex, null); }); if (!shouldContinue) { break; } } } if (theValueSetCodeAccumulator instanceof ValueSetConceptAccumulator) { myTxTemplate.execute(t -> ((ValueSetConceptAccumulator) theValueSetCodeAccumulator).removeGapsFromConceptOrder()); } ourLog.info("Done working with in {}ms", valueSetInfo, sw.getMillis()); }

Target:
private void expandValueSet(ValueSet theValueSetToExpand, IValueSetConceptAccumulator theValueSetCodeAccumulator, AtomicInteger theCodeCounter, VersionIndependentConcept theWantConceptOrNull) { Set<String> addedCodes = new HashSet<>(); StopWatch sw = new StopWatch(); String valueSetInfo = getValueSetInfo(theValueSetToExpand); ourLog.info("Working with {}", valueSetInfo); ourLog.debug("Handling includes"); for (ValueSet.ConceptSetComponent include : theValueSetToExpand.getCompose().getInclude()) { for (int i = 0; ; i++) { int queryIndex = i; Boolean shouldContinue = myTxTemplate.execute(t -> { boolean add = true; return expandValueSetHandleIncludeOrExclude(theValueSetCodeAccumulator, addedCodes, include, add, theCodeCounter, queryIndex, theWantConceptOrNull); }); if (!shouldContinue) { break; } } } if (theValueSetCodeAccumulator.getCapacityRemaining() != null && theValueSetCodeAccumulator.getCapacityRemaining() <= 0) { String msg = myContext.getLocalizer().getMessage(BaseTermReadSvcImpl.class, "expansionTooLarge", myDaoConfig.getMaximumExpansionSize()); throw new ExpansionTooCostlyException(msg); } ourLog.debug("Handling excludes"); for (ValueSet.ConceptSetComponent exclude : theValueSetToExpand.getCompose().getExclude()) { for (int i = 0; ; i++) { int queryIndex = i; Boolean shouldContinue = myTxTemplate.execute(t -> { boolean add = false; return expandValueSetHandleIncludeOrExclude(theValueSetCodeAccumulator, addedCodes, exclude, add, theCodeCounter, queryIndex, null); }); if (!shouldContinue) { break; } } } if (theValueSetCodeAccumulator instanceof ValueSetConceptAccumulator) { myTxTemplate.execute(t -> ((ValueSetConceptAccumulator) theValueSetCodeAccumulator).removeGapsFromConceptOrder()); } ourLog.info("Done working with in {}ms", valueSetInfo, sw.getMillis()); }