Merge branch 'RED-9548' into 'master'

RED-9495 - Remove here for locally resized dictionary entry should remove the entry completly

Closes RED-9548

See merge request redactmanager/persistence-service!709
This commit is contained in:
Corina Olariu 2024-08-30 09:46:10 +02:00
commit 6957857b42
7 changed files with 59 additions and 14 deletions

View File

@ -36,6 +36,8 @@ public class ManualForceRedactionEntity implements IBaseAnnotation {
private OffsetDateTime softDeletedTime; private OffsetDateTime softDeletedTime;
@Column @Column
private int page; private int page;
@Column
private String basedOnDictAnnotationId;
@ManyToOne @ManyToOne
private FileEntity fileStatus; private FileEntity fileStatus;

View File

@ -137,6 +137,7 @@ public class ManualRedactionMapper {
for (ForceRedactionRequestModel forceRedactionRequestModel : forceRedactionRequests) { for (ForceRedactionRequestModel forceRedactionRequestModel : forceRedactionRequests) {
String uuid = UUID.randomUUID().toString();
EntityLogEntry entityLogEntry = entityLogMongoWrapperService.getEntityLogEntryById(dossierId, fileId, forceRedactionRequestModel.getAnnotationId()); EntityLogEntry entityLogEntry = entityLogMongoWrapperService.getEntityLogEntryById(dossierId, fileId, forceRedactionRequestModel.getAnnotationId());
ForceRedactionRequest request = ForceRedactionRequest.builder() ForceRedactionRequest request = ForceRedactionRequest.builder()
.annotationId(forceRedactionRequestModel.getAnnotationId()) .annotationId(forceRedactionRequestModel.getAnnotationId())
@ -146,7 +147,10 @@ public class ManualRedactionMapper {
.build(); .build();
if (!entityLogEntry.getEngines().contains(Engine.MANUAL) && !entityLogEntry.getEngines().contains(Engine.IMPORTED) && entryIsEntityType(entityLogEntry)) { if (!entityLogEntry.getEngines().contains(Engine.MANUAL) && !entityLogEntry.getEngines().contains(Engine.IMPORTED) && entryIsEntityType(entityLogEntry)) {
request.setBasedOnDictAnnotationId(forceRedactionRequestModel.getAnnotationId());
entityLogEntry.setId(uuid);
manualRedactionEntryConsumer.accept(entityLogEntry); manualRedactionEntryConsumer.accept(entityLogEntry);
request.setAnnotationId(uuid);
} }
requests.add(RequestEntryPair.<ForceRedactionRequest>builder().request(request).entityLogEntry(entityLogEntry).build()); requests.add(RequestEntryPair.<ForceRedactionRequest>builder().request(request).entityLogEntry(entityLogEntry).build());

View File

@ -219,3 +219,5 @@ databaseChangeLog:
file: db/changelog/tenant/132-add-based-on-dict-annotation-id-to-manual_changes.yaml file: db/changelog/tenant/132-add-based-on-dict-annotation-id-to-manual_changes.yaml
- include: - include:
file: db/changelog/tenant/133-add-technical-name-to-legal_basis.yaml file: db/changelog/tenant/133-add-technical-name-to-legal_basis.yaml
- include:
file: db/changelog/tenant/139-add-based-on-dict-annotation-id-to-manual_force_changes.yaml

View File

@ -0,0 +1,11 @@
databaseChangeLog:
- changeSet:
id: add-annotation-info-to-manual-force
author: colariu
changes:
- addColumn:
columns:
- column:
name: based_on_dict_annotation_id
type: VARCHAR(255)
tableName: manual_force_redaction

View File

@ -1735,21 +1735,27 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
when(entityLogService.getEntityLog(any(), any(), anyBoolean())).thenReturn(entityLog); when(entityLogService.getEntityLog(any(), any(), anyBoolean())).thenReturn(entityLog);
entityLogMongoService.upsertEntityLog(file.getDossierId(), file.getFileId(), entityLog); entityLogMongoService.upsertEntityLog(file.getDossierId(), file.getFileId(), entityLog);
manualRedactionClient.forceRedactionBulk(dossier.getId(), ManualRedactionResponse forceResponse = manualRedactionClient.forceRedactionBulk(dossier.getId(),
file.getId(), file.getId(),
Set.of(ForceRedactionRequestModel.builder().annotationId("forceRedactionAnnotation").comment("comment").legalBasis("1").build())); Set.of(ForceRedactionRequestModel.builder().annotationId("forceRedactionAnnotation").comment("comment").legalBasis("1").build()));
var allManualRedactions = manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), false, true); var allManualRedactions = manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), false, true);
assertEquals(allManualRedactions.getForceRedactions().size(), 1); assertEquals(allManualRedactions.getForceRedactions().size(), 1);
assertTrue(allManualRedactions.getForceRedactions() assertFalse(allManualRedactions.getForceRedactions()
.stream() .stream()
.anyMatch(entry -> entry.getAnnotationId().equals("forceRedactionAnnotation"))); .anyMatch(entry -> entry.getAnnotationId().equals("forceRedactionAnnotation")));
assertTrue(allManualRedactions.getForceRedactions()
.stream()
.anyMatch(entry -> entry.getAnnotationId().equals(forceResponse.getManualAddResponses().get(0).getAnnotationId())));
var unprocessedManualRedactions = manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), true, true); var unprocessedManualRedactions = manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), true, true);
assertEquals(unprocessedManualRedactions.getForceRedactions().size(), 1); assertEquals(unprocessedManualRedactions.getForceRedactions().size(), 1);
assertTrue(unprocessedManualRedactions.getForceRedactions() assertFalse(unprocessedManualRedactions.getForceRedactions()
.stream() .stream()
.anyMatch(entry -> entry.getAnnotationId().equals("forceRedactionAnnotation"))); .anyMatch(entry -> entry.getAnnotationId().equals("forceRedactionAnnotation")));
assertTrue(allManualRedactions.getForceRedactions()
.stream()
.anyMatch(entry -> entry.getAnnotationId().equals(forceResponse.getManualAddResponses().get(0).getAnnotationId())));
fileProcessingClient.analysisSuccessful(dossier.getId(), fileProcessingClient.analysisSuccessful(dossier.getId(),
file.getId(), file.getId(),
@ -1761,27 +1767,33 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
.dossierId(dossier.getId()) .dossierId(dossier.getId())
.build()); .build());
manualRedactionClient.forceRedactionBulk(dossier.getId(), ManualRedactionResponse forceResponse2 = manualRedactionClient.forceRedactionBulk(dossier.getId(),
file.getId(), file.getId(),
Set.of(ForceRedactionRequestModel.builder().annotationId("forceRedactionAnnotation2").comment("comment").legalBasis("1").build())); Set.of(ForceRedactionRequestModel.builder().annotationId("forceRedactionAnnotation2").comment("comment").legalBasis("1").build()));
allManualRedactions = manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), false, true); allManualRedactions = manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), false, true);
assertEquals(allManualRedactions.getForceRedactions().size(), 2); assertEquals(allManualRedactions.getForceRedactions().size(), 2);
assertTrue(allManualRedactions.getForceRedactions() assertFalse(allManualRedactions.getForceRedactions()
.stream() .stream()
.anyMatch(entry -> entry.getAnnotationId().equals("forceRedactionAnnotation"))); .anyMatch(entry -> entry.getAnnotationId().equals("forceRedactionAnnotation")));
assertTrue(allManualRedactions.getForceRedactions() assertTrue(allManualRedactions.getForceRedactions()
.stream() .stream()
.anyMatch(entry -> entry.getAnnotationId().equals("forceRedactionAnnotation"))); .anyMatch(entry -> entry.getAnnotationId().equals(forceResponse.getManualAddResponses().get(0).getAnnotationId())));
assertFalse(allManualRedactions.getForceRedactions()
.stream()
.anyMatch(entry -> entry.getAnnotationId().equals("forceRedactionAnnotation2")));
assertTrue(allManualRedactions.getForceRedactions()
.stream()
.anyMatch(entry -> entry.getAnnotationId().equals(forceResponse2.getManualAddResponses().get(0).getAnnotationId())));
unprocessedManualRedactions = manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), true, true); unprocessedManualRedactions = manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), true, true);
assertEquals(unprocessedManualRedactions.getForceRedactions().size(), 1); assertEquals(unprocessedManualRedactions.getForceRedactions().size(), 1);
assertTrue(unprocessedManualRedactions.getForceRedactions() assertFalse(unprocessedManualRedactions.getForceRedactions()
.stream()
.noneMatch(entry -> entry.getAnnotationId().equals("forceRedactionAnnotation")));
assertTrue(unprocessedManualRedactions.getForceRedactions()
.stream() .stream()
.anyMatch(entry -> entry.getAnnotationId().equals("forceRedactionAnnotation2"))); .anyMatch(entry -> entry.getAnnotationId().equals("forceRedactionAnnotation2")));
assertTrue(unprocessedManualRedactions.getForceRedactions()
.stream()
.anyMatch(entry -> entry.getAnnotationId().equals(forceResponse2.getManualAddResponses().get(0).getAnnotationId())));
fileProcessingClient.analysisSuccessful(dossier.getId(), fileProcessingClient.analysisSuccessful(dossier.getId(),
file.getId(), file.getId(),
@ -1795,12 +1807,18 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
allManualRedactions = manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), false, true); allManualRedactions = manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), false, true);
assertEquals(allManualRedactions.getForceRedactions().size(), 2); assertEquals(allManualRedactions.getForceRedactions().size(), 2);
assertTrue(allManualRedactions.getForceRedactions() assertFalse(allManualRedactions.getForceRedactions()
.stream() .stream()
.anyMatch(entry -> entry.getAnnotationId().equals("forceRedactionAnnotation"))); .anyMatch(entry -> entry.getAnnotationId().equals("forceRedactionAnnotation")));
assertTrue(allManualRedactions.getForceRedactions() assertTrue(allManualRedactions.getForceRedactions()
.stream()
.anyMatch(entry -> entry.getAnnotationId().equals(forceResponse.getManualAddResponses().get(0).getAnnotationId())));
assertFalse(allManualRedactions.getForceRedactions()
.stream() .stream()
.anyMatch(entry -> entry.getAnnotationId().equals("forceRedactionAnnotation2"))); .anyMatch(entry -> entry.getAnnotationId().equals("forceRedactionAnnotation2")));
assertTrue(allManualRedactions.getForceRedactions()
.stream()
.anyMatch(entry -> entry.getAnnotationId().equals(forceResponse2.getManualAddResponses().get(0).getAnnotationId())));
unprocessedManualRedactions = manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), true, true); unprocessedManualRedactions = manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), true, true);
assertTrue(unprocessedManualRedactions.getForceRedactions().isEmpty()); assertTrue(unprocessedManualRedactions.getForceRedactions().isEmpty());
@ -2751,13 +2769,19 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
.build())).getManualAddResponses() .build())).getManualAddResponses()
.get(0); .get(0);
assertEquals(response.getEntityLogEntry().getId(), "AnnotationId"); assertEquals(response.getEntityLogEntry().getId(), response.getAnnotationId());
assertEquals(response.getEntityLogEntry().getLegalBasis(), "legalBasis"); assertEquals(response.getEntityLogEntry().getLegalBasis(), "legalBasis");
assertEquals(response.getEntityLogEntry().getState(), EntryState.APPLIED); assertEquals(response.getEntityLogEntry().getState(), EntryState.APPLIED);
assertEquals(response.getEntityLogEntry().getManualChanges() assertEquals(response.getEntityLogEntry().getManualChanges()
.get(0).getManualRedactionType(), ManualRedactionType.FORCE); .get(0).getManualRedactionType(), ManualRedactionType.FORCE);
assertNull(response.getEntityLogEntry().getManualChanges() assertNull(response.getEntityLogEntry().getManualChanges()
.get(0).getProcessedDate()); .get(0).getProcessedDate());
var allManualRedactions = manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), false, true);
assertEquals(allManualRedactions.getForceRedactions().size(), 1);
assertTrue(allManualRedactions.getForceRedactions()
.stream()
.anyMatch(entry -> entry.getAnnotationId().equals(response.getAnnotationId())));
} }

View File

@ -16,5 +16,6 @@ public class ForceRedactionRequest {
private String legalBasis; private String legalBasis;
private String comment; private String comment;
private int page; private int page;
private String basedOnDictAnnotationId;
} }

View File

@ -14,6 +14,7 @@ import lombok.experimental.SuperBuilder;
public class ManualForceRedaction extends BaseAnnotation { public class ManualForceRedaction extends BaseAnnotation {
private String legalBasis; private String legalBasis;
private String basedOnDictAnnotationId;
@Override @Override