Merge branch 'RED-10104' into 'master'
RED-10104: add comments when automatic analysis enabled Closes RED-10104 See merge request redactmanager/persistence-service!768
This commit is contained in:
commit
2ac82ab8e7
@ -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());
|
||||
|
||||
|
||||
@ -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<CommentEntity> 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<CommentEntity> 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<CommentEntity> 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<CommentEntity> commentEntity4 = commentRepository.findById(commentId4);
|
||||
assertTrue(commentEntity4.isPresent());
|
||||
assertEquals(comment4, commentEntity4.get().getText());
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void testRectangleRedactionsBulkLocal(DossierTemplateModel dossierTemplate, Dossier dossier, FileStatus file) {
|
||||
|
||||
whenGetEntityLogInvocation();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user