Pull request #572: RED-5674 - 404 when overwriting existing dossier template

Merge in RED/persistence-service from bugfix/RED-5674 to master

* commit '6ebf9e0efcac025d61491e78c2b4f5bc14ac1ad7':
  RED-5674 - 404 when overwriting existing dossier template
This commit is contained in:
Corina Olariu 2022-12-05 14:24:37 +01:00
commit 14007e37b5

View File

@ -448,7 +448,12 @@ public class DossierTemplateImportService {
dictionaryPersistenceService.incrementVersion(typeId);
typeIdsAdded.add(typeId); // added to the list, since the type can not be deleted
});
Set<String> typesToRemove = currentTypes.stream().map(TypeEntity::getId).filter(t -> !typeIdsAdded.contains(t)).collect(Collectors.toSet());
Set<String> typesToRemove = currentTypes.stream()
.filter(t -> !t.isDeleted()) // remove the ones already soft deleted
.map(TypeEntity::getId)
.filter(t -> !typeIdsAdded.contains(t)) // exclude the type ids already added from the import
.filter(t -> !currentTypesIdSystemManaged.contains(t)) // exclude the types system managed
.collect(Collectors.toSet());
typesToRemove.forEach(dictionaryService::deleteType);
}