RED-8242 - Set AREA entry type for unprocessed rectangle redactions

This commit is contained in:
Andrei Isvoran 2024-01-11 15:27:18 +01:00
parent e2b64b566b
commit 06570a33e8
2 changed files with 28 additions and 4 deletions

View File

@ -135,7 +135,7 @@ public class EntityLogMergeService {
.value(manualRedactionEntry.getValue())
.legalBasis(manualRedactionEntry.getLegalBasis())
.reason(manualRedactionEntry.getReason())
.entryType(isHint ? EntryType.HINT : EntryType.ENTITY)
.entryType(isHint ? EntryType.HINT : manualRedactionEntry.isRectangle() ? EntryType.AREA : EntryType.ENTITY)
.state(isHint ? EntryState.SKIPPED : EntryState.APPLIED)
.imported(false)
.matchedRule("")

View File

@ -108,12 +108,13 @@ public class EntityLogMergeTest {
String dossierTemplateId = "dossierTemplateId";
String entryToAddId = UUID.randomUUID().toString();
String rectangleToAddId = UUID.randomUUID().toString();
String entryToRemoveId = UUID.randomUUID().toString();
String entryToResizeId = UUID.randomUUID().toString();
String entryLegalBasisId = UUID.randomUUID().toString();
String forceRedactionId = UUID.randomUUID().toString();
ManualRedactions manualRedactions = provideManualRedactions(entryToAddId, entryToRemoveId, entryToResizeId, entryLegalBasisId, forceRedactionId, fileId);
ManualRedactions manualRedactions = provideManualRedactions(entryToAddId, entryToRemoveId, entryToResizeId, entryLegalBasisId, forceRedactionId, fileId, rectangleToAddId);
var entityLog = provideEntityLog(entryToRemoveId, entryToResizeId, entryLegalBasisId, forceRedactionId);
@ -187,6 +188,16 @@ public class EntityLogMergeTest {
assertEquals(forceRedactionEntryLogEntry.getManualChanges().get(0).getManualRedactionType(), ManualRedactionType.FORCE_REDACT);
assertEquals(forceRedactionEntryLogEntry.getChanges().get(0).getType(), ChangeType.CHANGED);
var optionalRectangleEntryLogEntry = response.getEntityLogEntry().stream().filter(entityLogEntry1 -> entityLogEntry1.getId().equals(rectangleToAddId)).findFirst();
assertTrue(optionalRectangleEntryLogEntry.isPresent());
var rectangleEntryLogEntry = optionalRectangleEntryLogEntry.get();
assertEquals(rectangleEntryLogEntry.getType(), "manual");
assertEquals(rectangleEntryLogEntry.getEntryType(), EntryType.AREA);
assertEquals(rectangleEntryLogEntry.getState(), EntryState.APPLIED);
assertEquals(rectangleEntryLogEntry.getValue(), "Test2");
assertEquals(rectangleEntryLogEntry.getReason(), "Rectangle");
assertEquals(rectangleEntryLogEntry.getManualChanges().get(0).getManualRedactionType(), ManualRedactionType.ADD_LOCALLY);
}
private EntityLog provideEntityLog(String entryToRemoveId, String entryToResizeId, String entryLegalBasisId, String forceRedactionId) {
@ -237,7 +248,7 @@ public class EntityLogMergeTest {
0);
}
private ManualRedactions provideManualRedactions(String entryToAddId, String entryToRemoveId, String entryToResizeId, String entryLegalBasisId, String forceRedactionId, String fileId) {
private ManualRedactions provideManualRedactions(String entryToAddId, String entryToRemoveId, String entryToResizeId, String entryLegalBasisId, String forceRedactionId, String fileId, String rectangleToAddId) {
List<Rectangle> positions = new ArrayList<>();
positions.add(new Rectangle(2, 2, 2, 2, 1));
@ -251,10 +262,23 @@ public class EntityLogMergeTest {
.addToDictionary(false)
.addToDossierDictionary(false)
.fileId(fileId)
.rectangle(false)
.requestDate(OffsetDateTime.now())
.dictionaryEntryType(DictionaryEntryType.ENTRY)
.type("manual")
.build()))
.build(),
ManualRedactionEntry.builder()
.positions(List.of(new Rectangle(5f, 6f, 7f, 8f, 1)))
.annotationId(rectangleToAddId)
.value("Test2")
.reason("Rectangle")
.addToDictionary(false)
.addToDossierDictionary(false)
.fileId(fileId)
.rectangle(true)
.requestDate(OffsetDateTime.now())
.type("manual")
.build()))
.idsToRemove(Set.of(
IdRemoval.builder()
.annotationId(entryToRemoveId)