fixed undo after reanalysis
This commit is contained in:
parent
a6da970902
commit
93844d8e76
@ -613,6 +613,7 @@ public class RedactionLogCreatorService {
|
||||
}
|
||||
|
||||
|
||||
Set<String> entriesToRemoveBecauseOfUndoActions = new HashSet<>();
|
||||
for (RedactionLogEntry entry : redactionLog.getRedactionLogEntry()) {
|
||||
|
||||
var reasonHolder = new PreviewReasonHolder(entry);
|
||||
@ -622,14 +623,66 @@ public class RedactionLogCreatorService {
|
||||
}
|
||||
|
||||
processRedactionLogEntry(manualRedactions, dossierTemplateId, entry, reasonHolder);
|
||||
var shouldRemove = postProcessRedactionLogEntryForDeletedManualRedactions(manualRedactions, entry);
|
||||
if (shouldRemove) {
|
||||
entriesToRemoveBecauseOfUndoActions.add(entry.getId());
|
||||
}
|
||||
}
|
||||
|
||||
redactionLog.setRedactionLogEntry(redactionLog.getRedactionLogEntry()
|
||||
.stream().filter(entry -> !entriesToRemoveBecauseOfUndoActions.contains(entry.getId())).collect(Collectors.toList()));
|
||||
|
||||
|
||||
handleAddToDictionary(redactionLog, manualRedactions, dossierTemplateId);
|
||||
|
||||
return redactionLog;
|
||||
}
|
||||
|
||||
private boolean postProcessRedactionLogEntryForDeletedManualRedactions(ManualRedactions manualRedactions, RedactionLogEntry entry) {
|
||||
if (entry.isManual()) {
|
||||
|
||||
if (entry.getManualRedactionType() == ManualRedactionType.ADD) {
|
||||
var manualRedactionExists = manualRedactions.getEntriesToAdd().stream().anyMatch(entryToAdd -> entryToAdd.getId().equalsIgnoreCase(entry.getId()));
|
||||
return !manualRedactionExists;
|
||||
}
|
||||
|
||||
if (entry.getManualRedactionType() == ManualRedactionType.FORCE_REDACT) {
|
||||
var forceRedactExists = manualRedactions.getForceRedacts().stream().anyMatch(entryToAdd -> entryToAdd.getId().equalsIgnoreCase(entry.getId()));
|
||||
if (!forceRedactExists) {
|
||||
entry.setRedacted(false);
|
||||
entry.setManual(false);
|
||||
entry.setStatus(null);
|
||||
}
|
||||
}
|
||||
|
||||
if (entry.getManualRedactionType() == ManualRedactionType.REMOVE) {
|
||||
var removeIdExists = manualRedactions.getIdsToRemove().stream().anyMatch(entryToAdd -> entryToAdd.getId().equalsIgnoreCase(entry.getId()));
|
||||
if (!removeIdExists) {
|
||||
entry.setRedacted(true);
|
||||
entry.setManual(false);
|
||||
entry.setStatus(null);
|
||||
}
|
||||
}
|
||||
|
||||
// Cannot undo Already Approved change because UI won't allow it for now
|
||||
if (Status.REQUESTED.equals(entry.getStatus())) {
|
||||
if (entry.getManualRedactionType() == ManualRedactionType.RECATEGORIZE) {
|
||||
entry.setManual(false);
|
||||
entry.setStatus(null);
|
||||
entry.setRecategorizationType(null);
|
||||
}
|
||||
if (entry.getManualRedactionType() == ManualRedactionType.LEGAL_BASIS_CHANGE) {
|
||||
entry.setManual(false);
|
||||
entry.setStatus(null);
|
||||
entry.setLegalBasisChangeValue(null);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private void handleAddToDictionary(RedactionLog redactionLog, ManualRedactions manualRedactions, String dossierTemplateId) {
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user