hotfix: filter entities with empty value in redactionLog and entityLog

This commit is contained in:
Kilian Schuettler 2023-11-30 12:30:16 +01:00
parent 8ec233da93
commit 1ba3952e9b

View File

@ -90,11 +90,12 @@ public class EntityLogCreatorService {
Set<Integer> sectionsToReanalyseIds,
DictionaryVersion dictionaryVersion) {
previousEntityLog.setEntityLogEntry(previousEntityLog.getEntityLogEntry().stream().filter(entity -> !entity.getValue().isEmpty()).collect(Collectors.toList())); // fix broken entityLogs with empty entries
List<EntityLogEntry> newEntityLogEntries = createEntityLogEntries(document, analyzeRequest.getDossierTemplateId(), notFoundManualRedactionEntries);
Set<String> newEntityIds = newEntityLogEntries.stream().map(EntityLogEntry::getId).collect(Collectors.toSet());
List<EntityLogEntry> entriesFromReanalysedSections = previousEntityLog.getEntityLogEntry()
.stream()
.filter(entry -> !entry.getValue().isEmpty())
.filter(entry -> (newEntityIds.contains(entry.getId()) || sectionsToReanalyseIds.contains(entry.getContainingNodeId().get(0))) && !entry.getType()
.equals(ImportedRedactionService.IMPORTED_REDACTION_TYPE))
.toList();