RED-8480: adjusted propertyChanges in manual changes
(cherry picked from commit 8a4c754250e88fa1d5455c10138ef808478eed04)
This commit is contained in:
parent
abfb88755e
commit
e5c1126c7e
@ -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;
|
||||
|
||||
@ -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()
|
||||
|
||||
@ -113,16 +113,21 @@ 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()
|
||||
.userId(KeycloakSecurity.getUserId())
|
||||
.objectId(fileId)
|
||||
.category(AuditCategory.DOCUMENT.name())
|
||||
.message("Undo of manual resize redaction was done.")
|
||||
.details(Map.of(DOSSIER_ID, dossierId, FILE_ID, fileId, ANNOTATION_ID, annotationId))
|
||||
.build()));
|
||||
.userId(KeycloakSecurity.getUserId())
|
||||
.objectId(fileId)
|
||||
.category(AuditCategory.DOCUMENT.name())
|
||||
.message("Undo of manual resize redaction was done.")
|
||||
.details(Map.of(DOSSIER_ID,
|
||||
dossierId,
|
||||
FILE_ID,
|
||||
fileId,
|
||||
ANNOTATION_ID,
|
||||
annotationId))
|
||||
.build()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -143,17 +148,22 @@ public class ManualRedactionUndoService {
|
||||
.stream()
|
||||
.filter(manualRedactionWrapper -> manualRedactionWrapper.getItem() instanceof ManualLegalBasisChange)
|
||||
.map(ManualRedactionWrapperModel::getId)
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
if (!manualLegalBasisChanges.isEmpty()) {
|
||||
|
||||
deleteLegalBasisChange(dossierId, fileId, manualLegalBasisChanges);
|
||||
manualLegalBasisChanges.forEach(annotationId -> auditPersistenceService.audit(AuditRequest.builder()
|
||||
.userId(KeycloakSecurity.getUserId())
|
||||
.objectId(fileId)
|
||||
.category(AuditCategory.DOCUMENT.name())
|
||||
.message("Undo of legal basis change was done.")
|
||||
.details(Map.of(DOSSIER_ID, dossierId, FILE_ID, fileId, ANNOTATION_ID, annotationId))
|
||||
.build()));
|
||||
.userId(KeycloakSecurity.getUserId())
|
||||
.objectId(fileId)
|
||||
.category(AuditCategory.DOCUMENT.name())
|
||||
.message("Undo of legal basis change was done.")
|
||||
.details(Map.of(DOSSIER_ID,
|
||||
dossierId,
|
||||
FILE_ID,
|
||||
fileId,
|
||||
ANNOTATION_ID,
|
||||
annotationId))
|
||||
.build()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -169,21 +179,26 @@ 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()
|
||||
.userId(KeycloakSecurity.getUserId())
|
||||
.objectId(fileId)
|
||||
.category(AuditCategory.DOCUMENT.name())
|
||||
.message("Undo of manual image recategorization was done.")
|
||||
.details(Map.of(DOSSIER_ID, dossierId, FILE_ID, fileId, ANNOTATION_ID, annotationId))
|
||||
.build()));
|
||||
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 recategorization was done.")
|
||||
.details(Map.of(DOSSIER_ID,
|
||||
dossierId,
|
||||
FILE_ID,
|
||||
fileId,
|
||||
ANNOTATION_ID,
|
||||
annotationId))
|
||||
.build()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -198,10 +213,10 @@ public class ManualRedactionUndoService {
|
||||
String originalValue = getEntityLogEntry(entityLog, annotationId).getValue();
|
||||
manualRedactionDictionaryUpdateHandler.revertRemoveFromDictionary(originalValue, dossierId, fileId, recategorizationEntity.getTypeIdsOfDictionariesWithDelete());
|
||||
manualRedactionDictionaryUpdateHandler.revertAddToDictionary(originalValue,
|
||||
DictionaryEntryType.ENTRY,
|
||||
fileId,
|
||||
dossierId,
|
||||
recategorizationEntity.getTypeIdsOfDictionariesWithAdd());
|
||||
DictionaryEntryType.ENTRY,
|
||||
fileId,
|
||||
dossierId,
|
||||
recategorizationEntity.getTypeIdsOfDictionariesWithAdd());
|
||||
recategorizationPersistenceService.updateModifiedDictionaries(fileId, annotationId, Collections.emptySet(), Collections.emptySet());
|
||||
recategorizationPersistenceService.softDelete(fileId, annotationId, OffsetDateTime.now());
|
||||
}
|
||||
@ -215,17 +230,22 @@ public class ManualRedactionUndoService {
|
||||
.stream()
|
||||
.filter(manualRedactionWrapper -> manualRedactionWrapper.getItem() instanceof ManualForceRedaction)
|
||||
.map(ManualRedactionWrapperModel::getId)
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
if (!manualForceRedactions.isEmpty()) {
|
||||
|
||||
deleteForceRedaction(dossierId, fileId, manualForceRedactions);
|
||||
manualForceRedactions.forEach(annotationId -> auditPersistenceService.audit(AuditRequest.builder()
|
||||
.userId(KeycloakSecurity.getUserId())
|
||||
.objectId(fileId)
|
||||
.category(AuditCategory.DOCUMENT.name())
|
||||
.message("Undo of manual force redaction was done.")
|
||||
.details(Map.of(DOSSIER_ID, dossierId, FILE_ID, fileId, ANNOTATION_ID, annotationId))
|
||||
.build()));
|
||||
.userId(KeycloakSecurity.getUserId())
|
||||
.objectId(fileId)
|
||||
.category(AuditCategory.DOCUMENT.name())
|
||||
.message("Undo of manual force redaction was done.")
|
||||
.details(Map.of(DOSSIER_ID,
|
||||
dossierId,
|
||||
FILE_ID,
|
||||
fileId,
|
||||
ANNOTATION_ID,
|
||||
annotationId))
|
||||
.build()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -247,16 +267,16 @@ 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()
|
||||
.userId(KeycloakSecurity.getUserId())
|
||||
.objectId(fileId)
|
||||
.category(AuditCategory.DOCUMENT.name())
|
||||
.message("Undo of manual remove redaction was done.")
|
||||
.details(Map.of(DOSSIER_ID, dossierId, FILE_ID, fileId, ANNOTATION_ID, annotationId))
|
||||
.build()));
|
||||
.userId(KeycloakSecurity.getUserId())
|
||||
.objectId(fileId)
|
||||
.category(AuditCategory.DOCUMENT.name())
|
||||
.message("Undo of manual remove redaction was done.")
|
||||
.details(Map.of(DOSSIER_ID, dossierId, FILE_ID, fileId, ANNOTATION_ID, annotationId))
|
||||
.build()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -284,16 +304,21 @@ 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()
|
||||
.userId(KeycloakSecurity.getUserId())
|
||||
.objectId(fileId)
|
||||
.category(AuditCategory.DOCUMENT.name())
|
||||
.message("Undo of manual add redaction was done.")
|
||||
.details(Map.of(DOSSIER_ID, dossierId, FILE_ID, fileId, ANNOTATION_ID, annotationId))
|
||||
.build()));
|
||||
.userId(KeycloakSecurity.getUserId())
|
||||
.objectId(fileId)
|
||||
.category(AuditCategory.DOCUMENT.name())
|
||||
.message("Undo of manual add redaction was done.")
|
||||
.details(Map.of(DOSSIER_ID,
|
||||
dossierId,
|
||||
FILE_ID,
|
||||
fileId,
|
||||
ANNOTATION_ID,
|
||||
annotationId))
|
||||
.build()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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()
|
||||
|
||||
@ -8,4 +8,7 @@ databaseChangeLog:
|
||||
columns:
|
||||
- column:
|
||||
name: section
|
||||
type: VARCHAR(1024)
|
||||
type: VARCHAR(1024)
|
||||
- column:
|
||||
name: value
|
||||
type: VARCHAR(4000)
|
||||
@ -1827,7 +1827,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)
|
||||
@ -1846,7 +1846,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()
|
||||
@ -1963,4 +1962,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")));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user