Pull request #405: RED-3791 - redaction log merge of duplicate annotations

Merge in RED/redaction-service from RED-3791 to master

* commit 'ec8d3183dc119e3eddd45a653ca88a2666073f51':
  RED-3791 - redaction log merge of duplicate annotations
This commit is contained in:
Timo Bejan 2022-06-14 18:25:35 +02:00
commit 2301849815

View File

@ -76,10 +76,17 @@ public class RedactionLogMergeService {
Set<Integer> excludedPages, List<Type> types, Colors colors) { Set<Integer> excludedPages, List<Type> types, Colors colors) {
var skippedImportedRedactions = new HashSet<>(); var skippedImportedRedactions = new HashSet<>();
var validSourceIds = new HashSet<>();
log.info("Merging Redaction log with manual redactions"); log.info("Merging Redaction log with manual redactions");
if (manualRedactions != null) { if (manualRedactions != null) {
// entries that have been added to dictionaries
validSourceIds.addAll(manualRedactions.getEntriesToAdd().stream()
.filter(entry -> entry.getSourceId() != null)
.filter(entry -> entry.isAddToDictionary() || entry.isAddToDossierDictionary())
.filter(entry -> entry.getStatus() == AnnotationStatus.APPROVED)
.filter(entry -> entry.getProcessedDate() != null)
.map(ManualRedactionEntry::getSourceId).collect(Collectors.toList()));
var manualRedactionLogEntries = addManualAddEntries(sectionGrid, manualRedactions.getEntriesToAdd(), manualRedactions.getComments(), colors, types); var manualRedactionLogEntries = addManualAddEntries(sectionGrid, manualRedactions.getEntriesToAdd(), manualRedactions.getComments(), colors, types);
@ -112,6 +119,11 @@ public class RedactionLogMergeService {
Set<String> processedIds = new HashSet<>(); Set<String> processedIds = new HashSet<>();
redactionLog.getRedactionLogEntry().removeIf(entry -> { redactionLog.getRedactionLogEntry().removeIf(entry -> {
if(validSourceIds.contains(entry.getId())){
return true;
}
if (entry.getImportedRedactionIntersections() != null) { if (entry.getImportedRedactionIntersections() != null) {
entry.getImportedRedactionIntersections().removeAll(skippedImportedRedactions); entry.getImportedRedactionIntersections().removeAll(skippedImportedRedactions);
if (!entry.getImportedRedactionIntersections().isEmpty() && (!entry.isImage() || entry.isImage() && !(entry.getType().equals("image") || entry.getType().equals("ocr")))) { if (!entry.getImportedRedactionIntersections().isEmpty() && (!entry.isImage() || entry.isImage() && !(entry.getType().equals("image") || entry.getType().equals("ocr")))) {