RED-7738 - Fix rollback issue and treat non-manual redaction removal in a Transactional block #172
@ -61,6 +61,7 @@ import com.iqser.red.service.persistence.service.v1.api.model.annotations.Remove
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.annotations.ResizeRedactionRequest;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.annotations.entitymapped.IdRemoval;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.annotations.entitymapped.ManualRedactionEntry;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.Dossier;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.file.ProcessingStatus;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.file.WorkflowStatus;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.type.DictionaryEntryType;
|
||||
@ -184,7 +185,6 @@ public class ManualRedactionService {
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public List<ManualAddResponse> addRemoveRedaction(String dossierId, String fileId, List<RemoveRedactionRequest> removeRedactionRequests) {
|
||||
|
||||
RedactionLog redactionLog = null;
|
||||
@ -200,46 +200,7 @@ public class ManualRedactionService {
|
||||
log.info("hard delete ManualRedactions for file {} and annotation {}", fileId, removeRedactionRequest.getAnnotationId());
|
||||
manualRedactionProviderService.hardDeleteManualRedactions(fileId, removeRedactionRequest.getAnnotationId());
|
||||
} else {
|
||||
|
||||
log.info("add removeRedaction for file {} and annotation {}", fileId, removeRedactionRequest.getAnnotationId());
|
||||
var idRemoval = convert(removeRedactionPersistenceService.insert(fileId, removeRedactionRequest), IdRemoval.class);
|
||||
|
||||
if (redactionLog == null) {
|
||||
redactionLog = fileManagementStorageService.getRedactionLog(dossier.getId(), fileId);
|
||||
}
|
||||
|
||||
Long commentId = null;
|
||||
if (removeRedactionRequest.getComment() != null) {
|
||||
commentId = addComment(fileId, removeRedactionRequest.getAnnotationId(), removeRedactionRequest.getComment(), removeRedactionRequest.getUser()).getId();
|
||||
}
|
||||
|
||||
if (!removeRedactionRequest.isRemoveFromDictionary() && AnnotationStatus.APPROVED.equals(removeRedactionRequest.getStatus())) {
|
||||
Optional<RedactionLogEntry> redactionLogEntryOptional = redactionLog.getRedactionLogEntry()
|
||||
.stream()
|
||||
.filter(entry -> entry.getId().equals(removeRedactionRequest.getAnnotationId()))
|
||||
.findFirst();
|
||||
var requiresAnalysis = redactionLogEntryOptional.isPresent() && redactionLogEntryOptional.get().isHint();
|
||||
actionPerformed = actionPerformed || requiresAnalysis;
|
||||
if (!requiresAnalysis && idRemoval.isApproved()) {
|
||||
removeRedactionPersistenceService.markAsProcessed(idRemoval);
|
||||
}
|
||||
}
|
||||
|
||||
var removedFromDictionary = handleRemoveFromDictionary(redactionLog,
|
||||
dossier,
|
||||
fileId,
|
||||
removeRedactionRequest.getAnnotationId(),
|
||||
removeRedactionRequest.getStatus(),
|
||||
removeRedactionRequest.isRemoveFromDictionary(),
|
||||
false);
|
||||
|
||||
if (!removedFromDictionary && idRemoval.isApproved()) {
|
||||
removeRedactionPersistenceService.markAsProcessed(idRemoval);
|
||||
}
|
||||
|
||||
actionPerformed = actionPerformed || removedFromDictionary;
|
||||
|
||||
response.add(ManualAddResponse.builder().annotationId(removeRedactionRequest.getAnnotationId()).commentId(commentId).build());
|
||||
actionPerformed = removeNonManualRedaction(redactionLog, fileId, removeRedactionRequest, dossier, actionPerformed, response);
|
||||
}
|
||||
}
|
||||
|
||||
@ -252,6 +213,55 @@ public class ManualRedactionService {
|
||||
return response;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
private boolean removeNonManualRedaction(RedactionLog redactionLog, String fileId, RemoveRedactionRequest removeRedactionRequest, DossierEntity dossier, boolean actionPerformed,
|
||||
List<ManualAddResponse> response) {
|
||||
|
||||
log.info("add removeRedaction for file {} and annotation {}", fileId, removeRedactionRequest.getAnnotationId());
|
||||
|
||||
Long commentId = null;
|
||||
String comment = removeRedactionRequest.getComment();
|
||||
if (comment != null) {
|
||||
commentId = addComment(fileId, removeRedactionRequest.getAnnotationId(), comment, removeRedactionRequest.getUser()).getId();
|
||||
}
|
||||
|
||||
var idRemoval = convert(removeRedactionPersistenceService.insert(fileId, removeRedactionRequest), IdRemoval.class);
|
||||
|
||||
if (redactionLog == null) {
|
||||
redactionLog = fileManagementStorageService.getRedactionLog(dossier.getId(), fileId);
|
||||
}
|
||||
|
||||
if (!removeRedactionRequest.isRemoveFromDictionary() && AnnotationStatus.APPROVED.equals(removeRedactionRequest.getStatus())) {
|
||||
Optional<RedactionLogEntry> redactionLogEntryOptional = redactionLog.getRedactionLogEntry()
|
||||
.stream()
|
||||
.filter(entry -> entry.getId().equals(removeRedactionRequest.getAnnotationId()))
|
||||
.findFirst();
|
||||
var requiresAnalysis = redactionLogEntryOptional.isPresent() && redactionLogEntryOptional.get().isHint();
|
||||
actionPerformed = actionPerformed || requiresAnalysis;
|
||||
if (!requiresAnalysis && idRemoval.isApproved()) {
|
||||
removeRedactionPersistenceService.markAsProcessed(idRemoval);
|
||||
}
|
||||
}
|
||||
|
||||
var removedFromDictionary = handleRemoveFromDictionary(redactionLog,
|
||||
dossier,
|
||||
fileId,
|
||||
removeRedactionRequest.getAnnotationId(),
|
||||
removeRedactionRequest.getStatus(),
|
||||
removeRedactionRequest.isRemoveFromDictionary(),
|
||||
false);
|
||||
|
||||
if (!removedFromDictionary && idRemoval.isApproved()) {
|
||||
removeRedactionPersistenceService.markAsProcessed(idRemoval);
|
||||
}
|
||||
|
||||
actionPerformed = actionPerformed || removedFromDictionary;
|
||||
|
||||
response.add(ManualAddResponse.builder().annotationId(removeRedactionRequest.getAnnotationId()).commentId(commentId).build());
|
||||
|
||||
return actionPerformed;
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public List<ManualAddResponse> addForceRedaction(String dossierId, String fileId, List<ForceRedactionRequest> forceRedactionRequests) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user