Test fixes
This commit is contained in:
parent
622659cbb3
commit
ac0d8c0fe1
|
@ -213,9 +213,15 @@ public class TermCodeSystemStorageSvcImpl implements ITermCodeSystemStorageSvc {
|
|||
myCodeSystemDao.flush();
|
||||
});
|
||||
|
||||
List<TermCodeSystemVersion> codeSystemVersions = myCodeSystemVersionDao.findByCodeSystemPid(theCodeSystem.getPid());
|
||||
for (TermCodeSystemVersion next : codeSystemVersions) {
|
||||
deleteCodeSystemVersion(next.getPid());
|
||||
List<Long> codeSystemVersionPids = txTemplate.execute(t -> {
|
||||
List<TermCodeSystemVersion> codeSystemVersions = myCodeSystemVersionDao.findByCodeSystemPid(theCodeSystem.getPid());
|
||||
return codeSystemVersions
|
||||
.stream()
|
||||
.map(v -> v.getPid())
|
||||
.collect(Collectors.toList());
|
||||
});
|
||||
for (Long next : codeSystemVersionPids) {
|
||||
deleteCodeSystemVersion(next);
|
||||
}
|
||||
|
||||
txTemplate.executeWithoutResult(t -> {
|
||||
|
|
|
@ -64,7 +64,7 @@ public class TermDeferredStorageSvcImpl implements ITermDeferredStorageSvc {
|
|||
@Autowired
|
||||
protected PlatformTransactionManager myTransactionMgr;
|
||||
private boolean myProcessDeferred = true;
|
||||
private List<TermCodeSystem> myCodeSystemsToDelete = Collections.synchronizedList(new ArrayList<>());
|
||||
private List<TermCodeSystem> myDefferedCodeSystemsDeletions = Collections.synchronizedList(new ArrayList<>());
|
||||
private List<TermConcept> myDeferredConcepts = Collections.synchronizedList(new ArrayList<>());
|
||||
private List<ValueSet> myDeferredValueSets = Collections.synchronizedList(new ArrayList<>());
|
||||
private List<ConceptMap> myDeferredConceptMaps = Collections.synchronizedList(new ArrayList<>());
|
||||
|
@ -109,7 +109,7 @@ public class TermDeferredStorageSvcImpl implements ITermDeferredStorageSvc {
|
|||
public void deleteCodeSystem(TermCodeSystem theCodeSystem) {
|
||||
theCodeSystem.setCodeSystemUri("urn:uuid:" + UUID.randomUUID().toString());
|
||||
myCodeSystemDao.save(theCodeSystem);
|
||||
myCodeSystemsToDelete.add(theCodeSystem);
|
||||
myDefferedCodeSystemsDeletions.add(theCodeSystem);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -155,8 +155,11 @@ public class TermDeferredStorageSvcImpl implements ITermDeferredStorageSvc {
|
|||
ourLog.info("Saving {} deferred concept relationships...", count);
|
||||
while (relCount < count && myConceptLinksToSaveLater.size() > 0) {
|
||||
TermConceptParentChildLink next = myConceptLinksToSaveLater.remove(0);
|
||||
assert next.getChild() != null;
|
||||
assert next.getParent() != null;
|
||||
|
||||
if (!myConceptDao.findById(next.getChild().getId()).isPresent() || !myConceptDao.findById(next.getParent().getId()).isPresent()) {
|
||||
if ((next.getChild().getId() == null || !myConceptDao.findById(next.getChild().getId()).isPresent())
|
||||
|| (next.getParent().getId() == null || !myConceptDao.findById(next.getParent().getId()).isPresent())) {
|
||||
ourLog.warn("Not inserting link from child {} to parent {} because it appears to have been deleted", next.getParent().getCode(), next.getChild().getCode());
|
||||
continue;
|
||||
}
|
||||
|
@ -194,6 +197,7 @@ public class TermDeferredStorageSvcImpl implements ITermDeferredStorageSvc {
|
|||
myDeferredValueSets.clear();
|
||||
myDeferredConceptMaps.clear();
|
||||
myDeferredConcepts.clear();
|
||||
myDefferedCodeSystemsDeletions.clear();
|
||||
}
|
||||
|
||||
@Transactional(propagation = Propagation.NEVER)
|
||||
|
@ -243,10 +247,10 @@ public class TermDeferredStorageSvcImpl implements ITermDeferredStorageSvc {
|
|||
}
|
||||
|
||||
private void processDeferredCodeSystemDeletions() {
|
||||
for (TermCodeSystem next : myCodeSystemsToDelete) {
|
||||
for (TermCodeSystem next : myDefferedCodeSystemsDeletions) {
|
||||
myCodeSystemStorageSvc.deleteCodeSystem(next);
|
||||
}
|
||||
myCodeSystemsToDelete.clear();
|
||||
myDefferedCodeSystemsDeletions.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -277,7 +281,7 @@ public class TermDeferredStorageSvcImpl implements ITermDeferredStorageSvc {
|
|||
}
|
||||
|
||||
private boolean isDeferredCodeSystemDeletions() {
|
||||
return !myCodeSystemsToDelete.isEmpty();
|
||||
return !myDefferedCodeSystemsDeletions.isEmpty();
|
||||
}
|
||||
|
||||
private boolean isDeferredConcepts() {
|
||||
|
|
|
@ -68,7 +68,10 @@ public class FhirResourceDaoDstu3CodeSystemTest extends BaseJpaDstu3Test {
|
|||
});
|
||||
|
||||
// Delete the code system
|
||||
myCodeSystemDao.delete(id);
|
||||
runInTransaction(()->{
|
||||
myCodeSystemDao.delete(id);
|
||||
});
|
||||
myTerminologyDeferredStorageSvc.saveDeferred();
|
||||
runInTransaction(()->{
|
||||
assertEquals(0L, myConceptDao.count());
|
||||
});
|
||||
|
|
|
@ -114,10 +114,13 @@ public class ResourceProviderDstu3CodeSystemTest extends BaseResourceProviderDst
|
|||
// Create the code system
|
||||
CodeSystem cs = (CodeSystem) myFhirCtx.newJsonParser().parseResource(input);
|
||||
ourClient.update().resource(cs).execute();
|
||||
runInTransaction(() -> assertEquals(26, myConceptDao.count()));
|
||||
runInTransaction(() -> assertEquals(26L, myConceptDao.count()));
|
||||
|
||||
// Delete the code system
|
||||
ourClient.delete().resource(cs).execute();
|
||||
runInTransaction(() -> assertEquals(26L, myConceptDao.count()));
|
||||
|
||||
myTerminologyDeferredStorageSvc.saveDeferred();
|
||||
runInTransaction(() -> assertEquals(24L, myConceptDao.count()));
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue