RED-8480: adjusted propertyChanges in manual changes

This commit is contained in:
Ali Oezyetimoglu 2024-03-15 16:26:39 +01:00
parent 3fde378ade
commit 8a4c754250
6 changed files with 122 additions and 16 deletions

View File

@ -51,6 +51,8 @@ public class ManualRecategorizationEntity implements IBaseAnnotation {
private String legalBasis;
@Column(length = 1024)
private String section;
@Column
private String value;
@ManyToOne
private FileEntity fileStatus;

View File

@ -280,6 +280,7 @@ public class EntityLogMergeService {
}
@Deprecated(forRemoval = true)
private void mergeLegalBasisChanges(ManualLegalBasisChange manualLegalBasisChange, List<EntityLogEntry> entityLogEntries, int analysisNumber) {
var entity = entityLogEntries.stream()
@ -305,6 +306,7 @@ public class EntityLogMergeService {
}
@Deprecated(forRemoval = true)
private Map<String, String> getPropertyChanges(ManualLegalBasisChange manualLegalBasisChange) {
Map<String, String> propertyChanges = new HashMap<>();
@ -339,12 +341,31 @@ public class EntityLogMergeService {
.requestedDate(recategorization.getRequestDate())
.processedDate(recategorization.getProcessedDate())
.userId(recategorization.getUser())
.propertyChanges(Map.of("type", recategorization.getType()))
.propertyChanges(getPropertyChanges(recategorization))
.build());
});
}
private Map<String, String> getPropertyChanges(ManualRecategorization recategorization) {
Map<String, String> propertyChanges = new HashMap<>();
if (!Strings.isNullOrEmpty(recategorization.getType())) {
propertyChanges.put("type", recategorization.getType());
}
if (!Strings.isNullOrEmpty(recategorization.getLegalBasis())) {
propertyChanges.put("legalBasis", recategorization.getLegalBasis());
}
if (!Strings.isNullOrEmpty(recategorization.getValue())) {
propertyChanges.put("value", recategorization.getValue());
}
if (!Strings.isNullOrEmpty(recategorization.getSection())) {
propertyChanges.put("section", recategorization.getSection());
}
return propertyChanges;
}
private void mergeForceRedactions(ManualForceRedaction forceRedaction, List<EntityLogEntry> entityLogEntries, int analysisNumber) {
var entity = entityLogEntries.stream()

View File

@ -113,7 +113,7 @@ public class ManualRedactionUndoService {
.stream()
.filter(manualRedactionWrapper -> manualRedactionWrapper.getItem() instanceof ManualResizeRedaction)
.map(ManualRedactionWrapperModel::getId)
.collect(Collectors.toList());
.toList();
if (!manualResizeRedactions.isEmpty()) {
deleteResizeRedaction(dossierId, fileId, manualResizeRedactions);
manualResizeRedactions.forEach(annotationId -> auditPersistenceService.audit(AuditRequest.builder()
@ -148,7 +148,7 @@ public class ManualRedactionUndoService {
.stream()
.filter(manualRedactionWrapper -> manualRedactionWrapper.getItem() instanceof ManualLegalBasisChange)
.map(ManualRedactionWrapperModel::getId)
.collect(Collectors.toList());
.toList();
if (!manualLegalBasisChanges.isEmpty()) {
deleteLegalBasisChange(dossierId, fileId, manualLegalBasisChanges);
@ -179,19 +179,19 @@ public class ManualRedactionUndoService {
private void undoRecategorization(String dossierId, String fileId, Map<String, ManualRedactionWrapperModel> manualRedactionWrappers, boolean includeUnprocessed) {
List<String> manualImageRecategorizations = manualRedactionWrappers.values()
List<String> manualRecategorizations = manualRedactionWrappers.values()
.stream()
.filter(manualRedactionWrapper -> manualRedactionWrapper.getItem() instanceof ManualRecategorization)
.map(ManualRedactionWrapperModel::getId)
.collect(Collectors.toList());
if (!manualImageRecategorizations.isEmpty()) {
.toList();
if (!manualRecategorizations.isEmpty()) {
deleteRecategorization(dossierId, fileId, manualImageRecategorizations, includeUnprocessed);
manualImageRecategorizations.forEach(annotationId -> auditPersistenceService.audit(AuditRequest.builder()
deleteRecategorization(dossierId, fileId, manualRecategorizations, includeUnprocessed);
manualRecategorizations.forEach(annotationId -> auditPersistenceService.audit(AuditRequest.builder()
.userId(KeycloakSecurity.getUserId())
.objectId(fileId)
.category(AuditCategory.DOCUMENT.name())
.message("Undo of manual image recategorization was done.")
.message("Undo of manual recategorization was done.")
.details(Map.of(DOSSIER_ID,
dossierId,
FILE_ID,
@ -230,7 +230,7 @@ public class ManualRedactionUndoService {
.stream()
.filter(manualRedactionWrapper -> manualRedactionWrapper.getItem() instanceof ManualForceRedaction)
.map(ManualRedactionWrapperModel::getId)
.collect(Collectors.toList());
.toList();
if (!manualForceRedactions.isEmpty()) {
deleteForceRedaction(dossierId, fileId, manualForceRedactions);
@ -267,7 +267,7 @@ public class ManualRedactionUndoService {
.stream()
.filter(manualRedactionWrapper -> manualRedactionWrapper.getItem() instanceof IdRemoval)
.map(ManualRedactionWrapperModel::getId)
.collect(Collectors.toList());
.toList();
if (!idRemovals.isEmpty()) {
deleteRemoveRedaction(dossierId, fileId, idRemovals);
idRemovals.forEach(annotationId -> auditPersistenceService.audit(AuditRequest.builder()
@ -304,7 +304,7 @@ public class ManualRedactionUndoService {
.stream()
.filter(manualRedactionWrapper -> manualRedactionWrapper.getItem() instanceof ManualRedactionEntry)
.map(ManualRedactionWrapperModel::getId)
.collect(Collectors.toList());
.toList();
if (!manualRedactionEntries.isEmpty()) {
deleteAddRedaction(dossierId, fileId, manualRedactionEntries);
manualRedactionEntries.forEach(annotationId -> auditPersistenceService.audit(AuditRequest.builder()

View File

@ -167,7 +167,14 @@ public class PendingDictionaryEntryFactory {
.requestedDate(manualChange.getRequestDate())
.processedDate(manualChange.getProcessedDate())
.userId(manualChange.getUser())
.propertyChanges(Map.of("type", manualChange.getType()))
.propertyChanges(Map.of("type",
manualChange.getType(),
"legalBasis",
manualChange.getLegalBasis(),
"value",
manualChange.getValue(),
"section",
manualChange.getSection()))
.build());
return EntityLogEntry.builder()

View File

@ -8,4 +8,7 @@ databaseChangeLog:
columns:
- column:
name: section
type: VARCHAR(1024)
type: VARCHAR(1024)
- column:
name: value
type: VARCHAR(4000)

View File

@ -1934,7 +1934,7 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
EntityLogEntry.builder()
.id("annotationId2")
.type(type.getType())
.value("Johannesbrotkernmehl")
.value("Johannisbrotkernmehl")
.dictionaryEntry(true)
.entryType(EntryType.ENTITY)
.state(EntryState.APPLIED)
@ -1953,7 +1953,6 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
0,
0);
fileManagementStorageService.storeJSONObject(dossier.getId(), file.getId(), FileType.ENTITY_LOG, entityLog);
fileManagementStorageService.storeJSONObject(dossier.getId(), file.getId(), FileType.ENTITY_LOG, entityLog);
when(entityLogService.getEntityLog(Mockito.any(), Mockito.any(), any(), anyBoolean())).thenReturn(entityLog);
var recatModel = RecategorizationRequestModel.builder()
@ -1994,4 +1993,78 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
}
@Test
public void testPropertyChangesForLegalBasisInManualRecategorization() {
var dossierTemplate = dossierTemplateTesterAndProvider.provideTestTemplate();
var dossier = dossierTesterAndProvider.provideTestDossier(dossierTemplate);
var file = fileTesterAndProvider.testAndProvideFile(dossier);
var type = typeProvider.testAndProvideType(dossierTemplate, null, "type", false);
var entityLog = new EntityLog(1,
1,
List.of(EntityLogEntry.builder()
.id("annotationId")
.type(type.getType())
.value("lukeSkywalker")
.dictionaryEntry(true)
.entryType(EntryType.ENTITY)
.state(EntryState.APPLIED)
.legalBasis("lb1")
.section("section")
.build(),
EntityLogEntry.builder()
.id("annotationId2")
.type(type.getType())
.value("Johannisbrotkernmehl")
.dictionaryEntry(true)
.entryType(EntryType.ENTITY)
.state(EntryState.APPLIED)
.build(),
EntityLogEntry.builder()
.id("annotationId3")
.type(type.getType())
.value("Baustelle")
.dictionaryEntry(true)
.entryType(EntryType.ENTITY)
.state(EntryState.APPLIED)
.build()),
null,
0,
0,
0,
0);
fileManagementStorageService.storeJSONObject(dossier.getId(), file.getId(), FileType.ENTITY_LOG, entityLog);
when(entityLogService.getEntityLog(Mockito.any(), Mockito.any(), any(), anyBoolean())).thenReturn(entityLog);
var recatModel = RecategorizationRequestModel.builder()
.type(type.getType())
.annotationId("annotationId")
.addToDictionary(false)
.addToAllDossiers(false)
.legalBasis("lb2")
.section("section")
.value("lukeSkywalker")
.build();
manualRedactionClient.recategorizeBulk(dossier.getId(), file.getId(), Set.of(recatModel), false);
var allManualRedactions = manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), false, true);
assertEquals(1, allManualRedactions.getRecategorizations().size());
assertTrue(allManualRedactions.getRecategorizations()
.stream()
.anyMatch(entry -> entry.getAnnotationId().equals("annotationId")));
assertTrue(allManualRedactions.getRecategorizations()
.stream()
.anyMatch(entry -> entry.getLegalBasis().equals("lb2")));
assertTrue(allManualRedactions.getRecategorizations()
.stream()
.anyMatch(entry -> entry.getSection().equals("section")));
assertTrue(allManualRedactions.getRecategorizations()
.stream()
.anyMatch(entry -> entry.getValue().equals("lukeSkywalker")));
}
}