RED-3287: Improve RedactionLog Controller to allow incremental calls
This commit is contained in:
parent
b13c4623b4
commit
fabfffcf3d
@ -2,6 +2,7 @@ package com.iqser.red.service.peristence.v1.server.service;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -96,80 +97,44 @@ public class RedactionLogService {
|
||||
|
||||
public RedactionLog getFilteredRedactionLog(String dossierId, String fileId, FilteredRedactionLogRequest filteredRedactionLogRequest) {
|
||||
|
||||
if(filteredRedactionLogRequest.getSpecifiedDate() == null) {
|
||||
if (filteredRedactionLogRequest.getSpecifiedDate() == null) {
|
||||
filteredRedactionLogRequest.setSpecifiedDate(OffsetDateTime.MIN);
|
||||
}
|
||||
|
||||
var redactionLog = getRedactionLog(dossierId, fileId, filteredRedactionLogRequest.getExcludedTypes(), filteredRedactionLogRequest.isWithManualRedactions(), filteredRedactionLogRequest.isIncludeFalsePositives());
|
||||
var redactionLogEntries = redactionLog.getRedactionLogEntry();
|
||||
|
||||
List<RedactionLogEntry> filteredRedactionLogEntries = new ArrayList<>();
|
||||
RedactionLog filteredRedactionLog = new RedactionLog(redactionLog.getAnalysisVersion(), redactionLog.getAnalysisNumber(), filteredRedactionLogEntries, redactionLog.getLegalBasis(), redactionLog.getDictionaryVersion(), redactionLog.getDossierDictionaryVersion(), redactionLog.getRulesVersion(), redactionLog.getLegalBasisVersion());
|
||||
|
||||
for (var redactionLogEntry : redactionLog.getRedactionLogEntry()) {
|
||||
RedactionLogEntry frle = RedactionLogEntry.builder()
|
||||
.id(redactionLogEntry.getId())
|
||||
.type(redactionLogEntry.getType())
|
||||
.value(redactionLogEntry.getValue())
|
||||
.reason(redactionLogEntry.getReason())
|
||||
.matchedRule(redactionLogEntry.getMatchedRule())
|
||||
.rectangle(redactionLogEntry.isRectangle())
|
||||
.legalBasis(redactionLogEntry.getLegalBasis())
|
||||
.imported(redactionLogEntry.isImported())
|
||||
.redacted(redactionLogEntry.isRedacted())
|
||||
.isHint(redactionLogEntry.isHint())
|
||||
.isRecommendation(redactionLogEntry.isRecommendation())
|
||||
.isFalsePositive(redactionLogEntry.isFalsePositive())
|
||||
.section(redactionLogEntry.getSection())
|
||||
.color(redactionLogEntry.getColor())
|
||||
.positions(redactionLogEntry.getPositions())
|
||||
.sectionNumber(redactionLogEntry.getSectionNumber())
|
||||
.textBefore(redactionLogEntry.getTextBefore())
|
||||
.textAfter(redactionLogEntry.getTextAfter())
|
||||
.startOffset(redactionLogEntry.getStartOffset())
|
||||
.endOffset(redactionLogEntry.getEndOffset())
|
||||
.isImage(redactionLogEntry.isImage())
|
||||
.imageHasTransparency(redactionLogEntry.isImageHasTransparency())
|
||||
.isDictionaryEntry(redactionLogEntry.isDictionaryEntry())
|
||||
.isDossierDictionaryEntry(redactionLogEntry.isDossierDictionaryEntry())
|
||||
.excluded(redactionLogEntry.isExcluded())
|
||||
.engines(redactionLogEntry.getEngines())
|
||||
.reference(redactionLogEntry.getReference())
|
||||
.build();
|
||||
|
||||
var changes = redactionLogEntry.getChanges();
|
||||
List<Change> filteredChanges = new ArrayList<>();
|
||||
for (var change : changes) {
|
||||
Iterator<RedactionLogEntry> it = redactionLogEntries.iterator();
|
||||
while (it.hasNext()) {
|
||||
var redactionLogEntry = it.next();
|
||||
boolean isAfterSpecifiedDate = false;
|
||||
for (var change : redactionLogEntry.getChanges()) {
|
||||
if (change.getDateTime().isAfter(filteredRedactionLogRequest.getSpecifiedDate())) {
|
||||
filteredChanges.add(change);
|
||||
isAfterSpecifiedDate = true;
|
||||
}
|
||||
}
|
||||
frle.setChanges(filteredChanges);
|
||||
|
||||
var manualChanges = redactionLogEntry.getManualChanges();
|
||||
List<ManualChange> filteredManualChanges = new ArrayList<>();
|
||||
for (var manualChange: manualChanges){
|
||||
if(manualChange.getProcessedDate().isAfter(filteredRedactionLogRequest.getSpecifiedDate())) {
|
||||
filteredManualChanges.add(manualChange);
|
||||
for (var manualChange : redactionLogEntry.getManualChanges()) {
|
||||
if (manualChange.getProcessedDate().isAfter(filteredRedactionLogRequest.getSpecifiedDate())) {
|
||||
isAfterSpecifiedDate = true;
|
||||
}
|
||||
}
|
||||
frle.setManualChanges(filteredManualChanges);
|
||||
|
||||
var comments = redactionLogEntry.getComments();
|
||||
List<Comment> filteredComments = new ArrayList<>();
|
||||
if(comments != null) {
|
||||
if (comments != null) {
|
||||
for (var comment : comments) {
|
||||
if (comment.getSoftDeletedTime() != null && comment.getSoftDeletedTime().isAfter(filteredRedactionLogRequest.getSpecifiedDate()) || comment.getDate().isAfter(filteredRedactionLogRequest.getSpecifiedDate())) {
|
||||
filteredComments.add(comment);
|
||||
isAfterSpecifiedDate = true;
|
||||
}
|
||||
}
|
||||
frle.setComments(filteredComments);
|
||||
}
|
||||
|
||||
filteredRedactionLogEntries.add(frle);
|
||||
}
|
||||
filteredRedactionLog.setRedactionLogEntry(filteredRedactionLogEntries);
|
||||
if(!isAfterSpecifiedDate) {
|
||||
it.remove();
|
||||
}
|
||||
|
||||
return filteredRedactionLog;
|
||||
}
|
||||
|
||||
return redactionLog;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user