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

- any force made to a dictionary entry will be unlinked and will create a new id to be used and will introduce 2 manual changes: local add and the manual change.
- unit tests updated
This commit is contained in:
corinaolariu 2024-08-28 11:11:46 +03:00
parent 98bd00a89c
commit 2ad5232e41
8 changed files with 45 additions and 6 deletions

View File

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

View File

@ -75,7 +75,10 @@ public class EntityLogMergeService {
@Observed(name = "EntityLogMergeService", contextualName = "merge-entity-log")
public EntityLog mergeEntityLog(ManualRedactions unprocessedManualRedactions, EntityLog entityLog, DossierEntity dossier, List<GroupAnnotationEntity> unprocessedGroupAnnotations) {
public EntityLog mergeEntityLog(ManualRedactions unprocessedManualRedactions,
EntityLog entityLog,
DossierEntity dossier,
List<GroupAnnotationEntity> unprocessedGroupAnnotations) {
final int analysisNumber = entityLog.getAnalysisNumber();
@ -302,6 +305,9 @@ public class EntityLogMergeService {
return mergeRecategorization(manualRecategorization, entityLogEntry, dossier, analysisNumber);
} else if (localChange instanceof ManualForceRedaction manualForceRedaction) {
mergeForceRedaction(manualForceRedaction, entityLogEntry, analysisNumber);
if (manualForceRedaction.getBasedOnDictAnnotationId() != null) {
trackLocalChangesBasedOnDictEntriesMap.put(manualForceRedaction.getAnnotationId(), manualForceRedaction.getBasedOnDictAnnotationId());
}
return null;
} else {
return null;

View File

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

View File

@ -228,4 +228,6 @@ databaseChangeLog:
- include:
file: db/changelog/tenant/137-add-area-position-table.yaml
- include:
file: db/changelog/tenant/138-add-page-range-table.yaml
file: db/changelog/tenant/138-add-page-range-table.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);
entityLogMongoService.upsertEntityLog(file.getDossierId(), file.getFileId(), entityLog);
manualRedactionClient.forceRedactionBulk(dossier.getId(),
ManualRedactionResponse forceResponse = manualRedactionClient.forceRedactionBulk(dossier.getId(),
file.getId(),
Set.of(ForceRedactionRequestModel.builder().annotationId("forceRedactionAnnotation").comment("comment").legalBasis("1").build()));
var allManualRedactions = manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), false, true);
assertEquals(allManualRedactions.getForceRedactions().size(), 1);
assertTrue(allManualRedactions.getForceRedactions()
assertFalse(allManualRedactions.getForceRedactions()
.stream()
.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);
assertEquals(unprocessedManualRedactions.getForceRedactions().size(), 1);
assertTrue(unprocessedManualRedactions.getForceRedactions()
assertFalse(unprocessedManualRedactions.getForceRedactions()
.stream()
.anyMatch(entry -> entry.getAnnotationId().equals("forceRedactionAnnotation")));
assertTrue(allManualRedactions.getForceRedactions()
.stream()
.anyMatch(entry -> entry.getAnnotationId().equals(forceResponse.getManualAddResponses().get(0).getAnnotationId())));
fileProcessingClient.analysisSuccessful(dossier.getId(),
file.getId(),
@ -2751,13 +2757,19 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
.build())).getManualAddResponses()
.get(0);
assertEquals(response.getEntityLogEntry().getId(), "AnnotationId");
assertEquals(response.getEntityLogEntry().getId(), response.getAnnotationId());
assertEquals(response.getEntityLogEntry().getLegalBasis(), "legalBasis");
assertEquals(response.getEntityLogEntry().getState(), EntryState.APPLIED);
assertEquals(response.getEntityLogEntry().getManualChanges()
.get(0).getManualRedactionType(), ManualRedactionType.FORCE);
assertNull(response.getEntityLogEntry().getManualChanges()
.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 comment;
private int page;
private String basedOnDictAnnotationId;
}

View File

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