From 44419f2c6cccae453869443348bf4851867c7776 Mon Sep 17 00:00:00 2001 From: maverickstuder Date: Wed, 2 Oct 2024 14:28:04 +0200 Subject: [PATCH] RED-10104: add comments when automatic analysis enabled --- .../controller/ManualRedactionController.java | 3 +- .../tests/ManualRedactionTest.java | 157 +++++++++++------- 2 files changed, 100 insertions(+), 60 deletions(-) diff --git a/persistence-service-v1/persistence-service-external-api-impl-v1/src/main/java/com/iqser/red/persistence/service/v1/external/api/impl/controller/ManualRedactionController.java b/persistence-service-v1/persistence-service-external-api-impl-v1/src/main/java/com/iqser/red/persistence/service/v1/external/api/impl/controller/ManualRedactionController.java index 77c42054a..eed6bc81f 100644 --- a/persistence-service-v1/persistence-service-external-api-impl-v1/src/main/java/com/iqser/red/persistence/service/v1/external/api/impl/controller/ManualRedactionController.java +++ b/persistence-service-v1/persistence-service-external-api-impl-v1/src/main/java/com/iqser/red/persistence/service/v1/external/api/impl/controller/ManualRedactionController.java @@ -278,7 +278,7 @@ public class ManualRedactionController implements ManualRedactionResource { removeRedactionRequest.getPageNumbers(), removeRedactionRequest.getPosition()); removeRedactionRequestModels = entries.stream() - .map(entry -> RemoveRedactionRequestModel.builder().annotationId(entry.getId()).build()) + .map(entry -> RemoveRedactionRequestModel.builder().annotationId(entry.getId()).comment(removeRedactionRequest.getComment()).build()) .collect(Collectors.toSet()); } else { @@ -396,6 +396,7 @@ public class ManualRedactionController implements ManualRedactionResource { .legalBasis(recategorizationRequest.getLegalBasis()) .section(recategorizationRequest.getSection()) .value(entry.getValue()) + .comment(recategorizationRequest.getComment()) .build()) .collect(Collectors.toSet()); diff --git a/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/tests/ManualRedactionTest.java b/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/tests/ManualRedactionTest.java index bff43f39a..fbf067342 100644 --- a/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/tests/ManualRedactionTest.java +++ b/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/tests/ManualRedactionTest.java @@ -3292,7 +3292,6 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest { testRectangleRedactionsBulkLocal(dossierTemplate, dossier, file); } - private void testBulkLocal(DossierTemplateModel dossierTemplate, Dossier dossier, FileStatus file) { whenGetEntityLogInvocation(); @@ -3342,70 +3341,110 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest { String newLegal = "new Legal"; String otherSection = "other section"; - ManualRedactionResponse manualRedactionResponse = manualRedactionClient.recategorizeBulkLocal(dossier.getId(), - file.getId(), - RecategorizationBulkLocalRequestModel.builder() - .rectangle(false) - .type(newType.getType()) - .legalBasis(newLegal) - .section(otherSection) - .value("Luke Skywalker37") - .build(), - false); - assertEquals(manualRedactionResponse.getManualAnnotationResponses().size(), 1); - assertEquals(manualRedactionResponse.getManualAnnotationResponses() - .get(0).getEntityLogEntry().getType(), newType.getType()); - assertEquals(manualRedactionResponse.getManualAnnotationResponses() - .get(0).getEntityLogEntry().getLegalBasis(), newLegal); - assertEquals(manualRedactionResponse.getManualAnnotationResponses() - .get(0).getEntityLogEntry().getSection(), otherSection); + String comment1 = "Recategorizing Luke Skywalker37"; + ManualRedactionResponse manualRedactionResponse = manualRedactionClient.recategorizeBulkLocal( + dossier.getId(), + file.getId(), + RecategorizationBulkLocalRequestModel.builder() + .rectangle(false) + .type(newType.getType()) + .legalBasis(newLegal) + .section(otherSection) + .value("Luke Skywalker37") + .comment(comment1) + .build(), + false); + assertEquals(1, manualRedactionResponse.getManualAnnotationResponses().size()); + assertEquals(newType.getType(), manualRedactionResponse.getManualAnnotationResponses() + .get(0).getEntityLogEntry().getType()); + assertEquals(newLegal, manualRedactionResponse.getManualAnnotationResponses() + .get(0).getEntityLogEntry().getLegalBasis()); + assertEquals(otherSection, manualRedactionResponse.getManualAnnotationResponses() + .get(0).getEntityLogEntry().getSection()); + Long commentId1 = manualRedactionResponse.getManualAnnotationResponses() + .get(0).getCommentId(); + assertNotNull(commentId1); + Optional commentEntity1 = commentRepository.findById(commentId1); + assertTrue(commentEntity1.isPresent()); + assertEquals(comment1, commentEntity1.get().getText()); - manualRedactionResponse = manualRedactionClient.recategorizeBulkLocal(dossier.getId(), - file.getId(), - RecategorizationBulkLocalRequestModel.builder() - .rectangle(false) - .type(newType.getType()) - .legalBasis(newLegal) - .section(otherSection) - .value(darthVader) - .originLegalBases(Set.of(legal3)) - .build(), - false); - assertEquals(manualRedactionResponse.getManualAnnotationResponses().size(), 101); - assertEquals(manualRedactionResponse.getManualAnnotationResponses() - .get(1).getEntityLogEntry().getType(), newType.getType()); - assertEquals(manualRedactionResponse.getManualAnnotationResponses() - .get(29).getEntityLogEntry().getLegalBasis(), newLegal); - assertEquals(manualRedactionResponse.getManualAnnotationResponses() - .get(79).getEntityLogEntry().getSection(), otherSection); + String comment2 = "Recategorizing Darth Vader with Legal 3"; + manualRedactionResponse = manualRedactionClient.recategorizeBulkLocal( + dossier.getId(), + file.getId(), + RecategorizationBulkLocalRequestModel.builder() + .rectangle(false) + .type(newType.getType()) + .legalBasis(newLegal) + .section(otherSection) + .value(darthVader) + .originLegalBases(Set.of(legal3)) + .comment(comment2) + .build(), + false); + assertEquals(101, manualRedactionResponse.getManualAnnotationResponses().size()); + assertEquals(newType.getType(), manualRedactionResponse.getManualAnnotationResponses() + .get(1).getEntityLogEntry().getType()); + assertEquals(newLegal, manualRedactionResponse.getManualAnnotationResponses() + .get(29).getEntityLogEntry().getLegalBasis()); + assertEquals(otherSection, manualRedactionResponse.getManualAnnotationResponses() + .get(79).getEntityLogEntry().getSection()); + Long commentId2 = manualRedactionResponse.getManualAnnotationResponses() + .get(0).getCommentId(); + assertNotNull(commentId2); + Optional commentEntity2 = commentRepository.findById(commentId2); + assertTrue(commentEntity2.isPresent()); + assertEquals(comment2, commentEntity2.get().getText()); - manualRedactionResponse = manualRedactionClient.recategorizeBulkLocal(dossier.getId(), - file.getId(), - RecategorizationBulkLocalRequestModel.builder() - .rectangle(false) - .type(newType.getType()) - .legalBasis(newLegal) - .section(otherSection) - .value(darthVader) - .originTypes(Set.of(type2.getType())) - .build(), - false); - assertEquals(manualRedactionResponse.getManualAnnotationResponses().size(), 101); - assertEquals(manualRedactionResponse.getManualAnnotationResponses() - .get(0).getEntityLogEntry().getType(), newType.getType()); - assertEquals(manualRedactionResponse.getManualAnnotationResponses() - .get(36).getEntityLogEntry().getLegalBasis(), newLegal); - assertEquals(manualRedactionResponse.getManualAnnotationResponses() - .get(98).getEntityLogEntry().getSection(), otherSection); + String comment3 = "Recategorizing Darth Vader with type2"; + manualRedactionResponse = manualRedactionClient.recategorizeBulkLocal( + dossier.getId(), + file.getId(), + RecategorizationBulkLocalRequestModel.builder() + .rectangle(false) + .type(newType.getType()) + .legalBasis(newLegal) + .section(otherSection) + .value(darthVader) + .originTypes(Set.of(type2.getType())) + .comment(comment3) + .build(), + false); + assertEquals(101, manualRedactionResponse.getManualAnnotationResponses().size()); + assertEquals(newType.getType(), manualRedactionResponse.getManualAnnotationResponses() + .get(0).getEntityLogEntry().getType()); + assertEquals(newLegal, manualRedactionResponse.getManualAnnotationResponses() + .get(36).getEntityLogEntry().getLegalBasis()); + assertEquals(otherSection, manualRedactionResponse.getManualAnnotationResponses() + .get(98).getEntityLogEntry().getSection()); + Long commentId3 = manualRedactionResponse.getManualAnnotationResponses() + .get(0).getCommentId(); + assertNotNull(commentId3); + Optional commentEntity3 = commentRepository.findById(commentId3); + assertTrue(commentEntity3.isPresent()); + assertEquals(comment3, commentEntity3.get().getText()); - manualRedactionResponse = manualRedactionClient.removeRedactionBulkLocal(dossier.getId(), - file.getId(), - RemoveRedactionBulkLocalRequestModel.builder().rectangle(false).value(darthVader).build(), - false); - assertEquals(manualRedactionResponse.getManualAnnotationResponses().size(), 202); + String comment4 = "Removing all Darth Vader annotations"; + manualRedactionResponse = manualRedactionClient.removeRedactionBulkLocal( + dossier.getId(), + file.getId(), + RemoveRedactionBulkLocalRequestModel.builder() + .rectangle(false) + .value(darthVader) + .comment(comment4) + .build(), + false); + assertEquals(202, manualRedactionResponse.getManualAnnotationResponses().size()); + Long commentId4 = manualRedactionResponse.getManualAnnotationResponses() + .get(0).getCommentId(); + assertNotNull(commentId4); + Optional commentEntity4 = commentRepository.findById(commentId4); + assertTrue(commentEntity4.isPresent()); + assertEquals(comment4, commentEntity4.get().getText()); } + private void testRectangleRedactionsBulkLocal(DossierTemplateModel dossierTemplate, Dossier dossier, FileStatus file) { whenGetEntityLogInvocation();