RED-7934: Do not delete manual redactions at remove redaction #217
@ -117,12 +117,6 @@ public class ManualRedactionService {
|
|||||||
log.info("add removeRedaction for file {} and annotation {}", fileId, removeRedactionRequest.getAnnotationId());
|
log.info("add removeRedaction for file {} and annotation {}", fileId, removeRedactionRequest.getAnnotationId());
|
||||||
removeRedactionPersistenceService.insert(fileId, removeRedactionRequest);
|
removeRedactionPersistenceService.insert(fileId, removeRedactionRequest);
|
||||||
|
|
||||||
if (manualAddToDictionaryRedactionsContains(manualRedactions, removeRedactionRequest.getAnnotationId())) {
|
|
||||||
log.info("hard delete ManualRedactions for file {} and annotation {}", fileId, removeRedactionRequest.getAnnotationId());
|
|
||||||
manualRedactionProviderService.hardDeleteManualRedactions(fileId, removeRedactionRequest.getAnnotationId());
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Long commentId = commentService.addCommentAndGetId(fileId,
|
Long commentId = commentService.addCommentAndGetId(fileId,
|
||||||
removeRedactionRequest.getAnnotationId(),
|
removeRedactionRequest.getAnnotationId(),
|
||||||
removeRedactionRequest.getComment(),
|
removeRedactionRequest.getComment(),
|
||||||
@ -288,12 +282,6 @@ public class ManualRedactionService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private boolean manualAddToDictionaryRedactionsContains(ManualRedactions manualRedactions, String annotationId) {
|
|
||||||
|
|
||||||
return manualRedactions.getEntriesToAdd().stream().anyMatch(m -> annotationId.equals(m.getAnnotationId()) && (m.isAddToDictionary() || m.isAddToDossierDictionary()));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private EntityLogEntry getEntityLogEntry(EntityLog entityLog, String annotationId) {
|
private EntityLogEntry getEntityLogEntry(EntityLog entityLog, String annotationId) {
|
||||||
|
|
||||||
return entityLog.getEntityLogEntry()
|
return entityLog.getEntityLogEntry()
|
||||||
|
|||||||
@ -1615,61 +1615,4 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
|||||||
assertTrue(unprocessedManualRedactions.getResizeRedactions().isEmpty());
|
assertTrue(unprocessedManualRedactions.getResizeRedactions().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testNonDictionaryRemoveManualRedactionEntityDoesNotRemoveAllManualRedactions() {
|
|
||||||
|
|
||||||
var dossierTemplate = dossierTemplateTesterAndProvider.provideTestTemplate();
|
|
||||||
var dossier = dossierTesterAndProvider.provideTestDossier(dossierTemplate);
|
|
||||||
var file = fileTesterAndProvider.testAndProvideFile(dossier);
|
|
||||||
String type = "manual";
|
|
||||||
String value = "Luke Skywalker";
|
|
||||||
var manualAddResponse = manualRedactionClient.addRedactionBulk(dossier.getId(),
|
|
||||||
file.getId(),
|
|
||||||
Set.of(AddRedactionRequestModel.builder()
|
|
||||||
.sourceId("sourceId")
|
|
||||||
.type(type)
|
|
||||||
.value(value)
|
|
||||||
.reason("Reason")
|
|
||||||
.positions(List.of(new Rectangle(new Point(0, 0), 100, 100, 0)))
|
|
||||||
.build())).get(0);
|
|
||||||
String annotationId = manualAddResponse.getAnnotationId();
|
|
||||||
var entityLog = new EntityLog(1,
|
|
||||||
1,
|
|
||||||
List.of(EntityLogEntry.builder().id(annotationId).type(type).value(value).entryType(EntryType.ENTITY).state(EntryState.APPLIED).dictionaryEntry(false).build()),
|
|
||||||
null,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0);
|
|
||||||
fileManagementStorageService.storeJSONObject(dossier.getId(), file.getId(), FileType.ENTITY_LOG, entityLog);
|
|
||||||
|
|
||||||
when(entityLogService.getEntityLog(Mockito.any(), Mockito.any())).thenReturn(entityLog);
|
|
||||||
|
|
||||||
assertEquals(1, manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), false).getEntriesToAdd().size());
|
|
||||||
assertEquals(annotationId,
|
|
||||||
manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), false).getEntriesToAdd().stream().findFirst().orElseThrow().getAnnotationId());
|
|
||||||
manualRedactionClient.legalBasisChangeBulk(dossier.getId(),
|
|
||||||
file.getId(),
|
|
||||||
Set.of(LegalBasisChangeRequestModel.builder().annotationId(annotationId).legalBasis("some legal basis").build()));
|
|
||||||
manualRedactionClient.forceRedactionBulk(dossier.getId(), file.getId(), Set.of(ForceRedactionRequestModel.builder().annotationId(annotationId).build()));
|
|
||||||
manualRedactionClient.recategorizeBulk(dossier.getId(), file.getId(), Set.of(RecategorizationRequestModel.builder().annotationId(annotationId).type("other type").build()));
|
|
||||||
manualRedactionClient.resizeRedactionBulk(dossier.getId(),
|
|
||||||
file.getId(),
|
|
||||||
Set.of(ResizeRedactionRequestModel.builder()
|
|
||||||
.annotationId(annotationId)
|
|
||||||
.value("Luke Skywalker and some more text")
|
|
||||||
.positions(List.of(new Rectangle(new Point(10, 10), 100, 100, 1)))
|
|
||||||
.build()));
|
|
||||||
manualRedactionClient.removeRedactionBulk(dossier.getId(), file.getId(), Set.of(RemoveRedactionRequestModel.builder().annotationId(annotationId).build()));
|
|
||||||
|
|
||||||
// Only AddToDictionaries will remove all manual redactions.
|
|
||||||
assertEquals(1, manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), false).getEntriesToAdd().size());
|
|
||||||
assertEquals(1, manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), false).getLegalBasisChanges().size());
|
|
||||||
assertEquals(1, manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), false).getForceRedactions().size());
|
|
||||||
assertEquals(1, manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), false).getRecategorizations().size());
|
|
||||||
assertEquals(1, manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), false).getResizeRedactions().size());
|
|
||||||
assertEquals(1, manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), false).getIdsToRemove().size());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user