Pull request #380: RED-3839: Bugfix with adding/removing manual redactions

Merge in RED/redaction-service from bugfix/RED-3839 to release/3.80.x

* commit '817f1b7ae194191d227444f7a58f45d11691500b':
  RED-3839: Bugfix with adding/removing manual redactions
This commit is contained in:
Philipp Schramm 2022-04-21 12:02:16 +02:00
commit cdcbf7601b

View File

@ -54,8 +54,25 @@ public class RedactionLogMergeService {
log.info("Merging Redaction log with manual redactions");
if (manualRedactions != null) {
Set<String> idsToRemove = manualRedactions.getIdsToRemove().stream().map(BaseAnnotation::getAnnotationId).collect(Collectors.toSet());
manualRedactions.getEntriesToAdd().removeIf(m -> idsToRemove.contains(m.getAnnotationId()));
Map<String, OffsetDateTime> idsToRemove = manualRedactions.getIdsToRemove()
.stream()
.collect(Collectors.toMap(BaseAnnotation::getAnnotationId, BaseAnnotation::getRequestDate));
List<ManualRedactionEntry> entriesToRemove = new ArrayList<>();
Set<String> removesToRemove = new HashSet<>();
manualRedactions.getEntriesToAdd().forEach(m -> {
if (idsToRemove.containsKey(m.getAnnotationId()) && idsToRemove.get(m.getAnnotationId()).isAfter(m.getRequestDate())) {
entriesToRemove.add(m);
} else if (idsToRemove.containsKey(m.getAnnotationId()) && idsToRemove.get(m.getAnnotationId()).isBefore(m.getRequestDate())) {
removesToRemove.add(m.getAnnotationId());
}
});
log.debug("Will remove these manual redactions {}", entriesToRemove);
log.debug("Will remove these id removals {}", removesToRemove);
manualRedactions.getIdsToRemove().removeIf(r -> removesToRemove.contains(r.getAnnotationId()));
manualRedactions.getEntriesToAdd().removeAll(entriesToRemove);
var manualRedactionLogEntries = addManualAddEntries(sectionGrid, manualRedactions.getEntriesToAdd(), manualRedactions.getComments(), colors, types);