Merge branch 'RED-8776-bp' into 'release/2.349.x'
RED-8776 - Add local redaction when making a manual change to a dict based redaction See merge request redactmanager/persistence-service!416
This commit is contained in:
commit
41085226cb
@ -237,7 +237,7 @@ public class ManualRedactionController implements ManualRedactionResource {
|
||||
accessControlService.verifyFileIsNotApproved(dossierId, fileId);
|
||||
accessControlService.verifyUserIsMemberOrApprover(dossierId);
|
||||
|
||||
List<ForceRedactionRequest> requests = manualRedactionMapper.toForceRedactionRequestList(forceRedactionRequests);
|
||||
List<ForceRedactionRequest> requests = manualRedactionMapper.toForceRedactionRequestList(dossierId, fileId, forceRedactionRequests);
|
||||
List<ManualAddResponse> responseList = manualRedactionService.addForceRedaction(dossierId, fileId, requests);
|
||||
|
||||
responseList.forEach(response -> auditPersistenceService.audit(AuditRequest.builder()
|
||||
@ -262,7 +262,7 @@ public class ManualRedactionController implements ManualRedactionResource {
|
||||
accessControlService.verifyFileIsNotApproved(dossierId, fileId);
|
||||
accessControlService.verifyUserIsMemberOrApprover(dossierId);
|
||||
|
||||
List<LegalBasisChangeRequest> requests = manualRedactionMapper.toLegalBasisChangeRequestList(legalBasisChangeRequests);
|
||||
List<LegalBasisChangeRequest> requests = manualRedactionMapper.toLegalBasisChangeRequestList(dossierId, fileId, legalBasisChangeRequests);
|
||||
|
||||
List<ManualAddResponse> responseList = manualRedactionService.addLegalBasisChange(dossierId, fileId, requests);
|
||||
|
||||
@ -319,7 +319,7 @@ public class ManualRedactionController implements ManualRedactionResource {
|
||||
accessControlService.verifyFileIsNotApproved(dossierId, fileId);
|
||||
accessControlService.verifyUserIsMemberOrApprover(dossierId);
|
||||
|
||||
List<ResizeRedactionRequest> requests = manualRedactionMapper.toResizeRedactionRequestList(resizeRedactionRequests);
|
||||
List<ResizeRedactionRequest> requests = manualRedactionMapper.toResizeRedactionRequestList(dossierId, fileId, resizeRedactionRequests, includeUnprocessed);
|
||||
List<ManualAddResponse> responseList = manualRedactionService.addResizeRedaction(dossierId, fileId, requests, includeUnprocessed);
|
||||
|
||||
responseList.forEach(response -> auditPersistenceService.audit(AuditRequest.builder()
|
||||
|
||||
@ -235,7 +235,8 @@ public class EntityLogMergeService {
|
||||
.build());
|
||||
|
||||
List<Change> changes = new ArrayList<>();
|
||||
changes.add(Change.builder().analysisNumber(entityLog.getAnalysisNumber()).dateTime(manualRedactionEntry.getRequestDate()).type(ChangeType.ADDED).build());
|
||||
changes.add(Change.builder().analysisNumber(entityLog.getAnalysisNumber()).dateTime(manualRedactionEntry.getRequestDate()).type(ChangeType.ADDED)
|
||||
.build());
|
||||
|
||||
boolean isHint = isHint(manualRedactionEntry.getType(), dossier);
|
||||
|
||||
@ -259,7 +260,7 @@ public class EntityLogMergeService {
|
||||
.excluded(false)
|
||||
.changes(changes)
|
||||
.manualChanges(manualChanges)
|
||||
.engines(Set.of(Engine.MANUAL))
|
||||
.engines(new HashSet<>(List.of(Engine.MANUAL)))
|
||||
.reference(new HashSet<>())
|
||||
.importedRedactionIntersections(new HashSet<>())
|
||||
.containingNodeId(Collections.emptyList())
|
||||
@ -283,7 +284,8 @@ public class EntityLogMergeService {
|
||||
|
||||
existingEntry.setState(EntryState.REMOVED);
|
||||
List<Change> falsePositiveChanges = new ArrayList<>();
|
||||
falsePositiveChanges.add(Change.builder().analysisNumber(entityLog.getAnalysisNumber()).dateTime(OffsetDateTime.now()).type(ChangeType.REMOVED).build());
|
||||
falsePositiveChanges.add(Change.builder().analysisNumber(entityLog.getAnalysisNumber()).dateTime(OffsetDateTime.now()).type(ChangeType.REMOVED)
|
||||
.build());
|
||||
if (existingEntry.getChanges() != null && !existingEntry.getChanges().isEmpty()) {
|
||||
existingEntry.getChanges().addAll(falsePositiveChanges);
|
||||
} else {
|
||||
@ -326,6 +328,12 @@ public class EntityLogMergeService {
|
||||
manualChange.propertyChanges(Map.of("value", manualResizeRedaction.getValue()));
|
||||
}
|
||||
entityLogEntry.getManualChanges().add(manualChange.build());
|
||||
|
||||
if ((entityLogEntry.isDictionaryEntry() || entityLogEntry.isDossierDictionaryEntry())
|
||||
&& !manualResizeRedaction.getUpdateDictionary()
|
||||
&& !manualResizeRedaction.isAddToAllDossiers()) {
|
||||
entityLogEntry.setState(EntryState.REMOVED);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -347,6 +355,9 @@ public class EntityLogMergeService {
|
||||
.userId(manualLegalBasisChange.getUser())
|
||||
.build());
|
||||
|
||||
if (entityLogEntry.isDictionaryEntry() || entityLogEntry.isDossierDictionaryEntry()) {
|
||||
entityLogEntry.setState(EntryState.REMOVED);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -452,6 +463,9 @@ public class EntityLogMergeService {
|
||||
}
|
||||
entityLogEntry.getManualChanges().add(forceRedactManualChange.build());
|
||||
|
||||
if (entityLogEntry.isDictionaryEntry() || entityLogEntry.isDossierDictionaryEntry()) {
|
||||
entityLogEntry.setState(EntryState.REMOVED);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -468,9 +482,11 @@ public class EntityLogMergeService {
|
||||
private void addChanges(List<Change> changes, ChangeType changeType, int analysisNumber, OffsetDateTime offsetDateTime) {
|
||||
|
||||
if (!changes.isEmpty()) {
|
||||
changes.add(Change.builder().analysisNumber(analysisNumber + 1).dateTime(offsetDateTime).type(changeType).build());
|
||||
changes.add(Change.builder().analysisNumber(analysisNumber + 1).dateTime(offsetDateTime).type(changeType)
|
||||
.build());
|
||||
} else {
|
||||
changes.add(Change.builder().analysisNumber(analysisNumber).dateTime(OffsetDateTime.now()).type(changeType).build());
|
||||
changes.add(Change.builder().analysisNumber(analysisNumber).dateTime(OffsetDateTime.now()).type(changeType)
|
||||
.build());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@ package com.iqser.red.service.persistence.management.v1.processor.service.manual
|
||||
|
||||
import static com.iqser.red.service.persistence.management.v1.processor.utils.TypeIdUtils.toTypeId;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@ -13,15 +14,19 @@ import org.springframework.stereotype.Service;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.exception.BadRequestException;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.exception.NotFoundException;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.EntityLogService;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.Engine;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.EntityLog;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.EntityLogEntry;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.EntryType;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.Position;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.AddRedactionRequest;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.ForceRedactionRequest;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.LegalBasisChangeRequest;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.RecategorizationRequest;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.Rectangle;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.RemoveRedactionRequest;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.ResizeRedactionRequest;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.entitymapped.ManualRedactionEntry;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.Dossier;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.type.DictionaryEntryType;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.manual.AddRedactionRequestModel;
|
||||
@ -43,6 +48,7 @@ import lombok.experimental.FieldDefaults;
|
||||
public class ManualRedactionMapper {
|
||||
|
||||
EntityLogService entityLogService;
|
||||
ManualRedactionService manualRedactionService;
|
||||
|
||||
|
||||
@Observed(name = "ManualRedactionMapper", contextualName = "to-add-redaction-request-list")
|
||||
@ -107,32 +113,58 @@ public class ManualRedactionMapper {
|
||||
}
|
||||
|
||||
|
||||
public List<ForceRedactionRequest> toForceRedactionRequestList(Set<ForceRedactionRequestModel> forceRedactionRequests) {
|
||||
public List<ForceRedactionRequest> toForceRedactionRequestList(String dossierId, String fileId, Set<ForceRedactionRequestModel> forceRedactionRequests) {
|
||||
|
||||
return forceRedactionRequests.stream()
|
||||
.map(forceRedactionRequest -> ForceRedactionRequest.builder()
|
||||
.annotationId(forceRedactionRequest.getAnnotationId())
|
||||
.user(KeycloakSecurity.getUserId())
|
||||
.legalBasis(forceRedactionRequest.getLegalBasis())
|
||||
.comment(forceRedactionRequest.getComment())
|
||||
.build())
|
||||
.toList();
|
||||
EntityLog entityLog = entityLogService.getEntityLog(dossierId, fileId, Collections.emptyList(), true);
|
||||
List<ForceRedactionRequest> requests = new ArrayList<>();
|
||||
|
||||
for (ForceRedactionRequestModel forceRedactionRequestModel : forceRedactionRequests) {
|
||||
|
||||
EntityLogEntry entityLogEntry = getEntityLogEntry(entityLog, forceRedactionRequestModel.getAnnotationId());
|
||||
ForceRedactionRequest forceRedactionRequest = ForceRedactionRequest.builder()
|
||||
.annotationId(forceRedactionRequestModel.getAnnotationId())
|
||||
.user(KeycloakSecurity.getUserId())
|
||||
.legalBasis(forceRedactionRequestModel.getLegalBasis())
|
||||
.comment(forceRedactionRequestModel.getComment())
|
||||
.build();
|
||||
|
||||
if (!entityLogEntry.getEngines().contains(Engine.MANUAL)) {
|
||||
addManualRedactionEntry(fileId, entityLogEntry);
|
||||
}
|
||||
|
||||
requests.add(forceRedactionRequest);
|
||||
}
|
||||
|
||||
return requests;
|
||||
}
|
||||
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
public List<LegalBasisChangeRequest> toLegalBasisChangeRequestList(Set<LegalBasisChangeRequestModel> legalBasisChangeRequests) {
|
||||
public List<LegalBasisChangeRequest> toLegalBasisChangeRequestList(String dossierId, String fileId, Set<LegalBasisChangeRequestModel> legalBasisChangeRequests) {
|
||||
|
||||
return legalBasisChangeRequests.stream()
|
||||
.map(legalBasisChangeRequest -> LegalBasisChangeRequest.builder()
|
||||
.annotationId(legalBasisChangeRequest.getAnnotationId())
|
||||
.user(KeycloakSecurity.getUserId())
|
||||
.section(legalBasisChangeRequest.getSection())
|
||||
.legalBasis(legalBasisChangeRequest.getLegalBasis())
|
||||
.comment(legalBasisChangeRequest.getComment())
|
||||
.value(legalBasisChangeRequest.getValue())
|
||||
.build())
|
||||
.toList();
|
||||
EntityLog entityLog = entityLogService.getEntityLog(dossierId, fileId, Collections.emptyList(), true);
|
||||
List<LegalBasisChangeRequest> requests = new ArrayList<>();
|
||||
|
||||
for (LegalBasisChangeRequestModel legalBasisChangeRequest : legalBasisChangeRequests) {
|
||||
|
||||
EntityLogEntry entityLogEntry = getEntityLogEntry(entityLog, legalBasisChangeRequest.getAnnotationId());
|
||||
LegalBasisChangeRequest request = LegalBasisChangeRequest.builder()
|
||||
.annotationId(legalBasisChangeRequest.getAnnotationId())
|
||||
.user(KeycloakSecurity.getUserId())
|
||||
.section(legalBasisChangeRequest.getSection())
|
||||
.legalBasis(legalBasisChangeRequest.getLegalBasis())
|
||||
.comment(legalBasisChangeRequest.getComment())
|
||||
.value(legalBasisChangeRequest.getValue())
|
||||
.build();
|
||||
|
||||
if (!entityLogEntry.getEngines().contains(Engine.MANUAL)) {
|
||||
addManualRedactionEntry(fileId, entityLogEntry);
|
||||
}
|
||||
|
||||
requests.add(request);
|
||||
}
|
||||
|
||||
return requests;
|
||||
}
|
||||
|
||||
|
||||
@ -144,9 +176,11 @@ public class ManualRedactionMapper {
|
||||
|
||||
EntityLog entityLog = entityLogService.getEntityLog(dossierId, fileId, Collections.emptyList(), includeUnprocessed);
|
||||
List<RecategorizationRequest> requests = new ArrayList<>();
|
||||
|
||||
for (RecategorizationRequestModel recategorizationRequest : recategorizationRequests) {
|
||||
|
||||
EntityLogEntry entityLogEntry = getEntityLogEntry(entityLog, recategorizationRequest.getAnnotationId());
|
||||
RecategorizationRequest build = RecategorizationRequest.builder()
|
||||
RecategorizationRequest request = RecategorizationRequest.builder()
|
||||
.annotationId(recategorizationRequest.getAnnotationId())
|
||||
.user(KeycloakSecurity.getUserId())
|
||||
.dossierTemplateId(dossierTemplateId)
|
||||
@ -162,26 +196,47 @@ public class ManualRedactionMapper {
|
||||
.orElse(""))
|
||||
.section(recategorizationRequest.getSection())
|
||||
.build();
|
||||
requests.add(build);
|
||||
|
||||
if (!entityLogEntry.getEngines().contains(Engine.MANUAL) && !recategorizationRequest.isAddToAllDossiers() && !recategorizationRequest.isAddToDictionary()) {
|
||||
addManualRedactionEntry(fileId, entityLogEntry);
|
||||
}
|
||||
|
||||
requests.add(request);
|
||||
}
|
||||
|
||||
return requests;
|
||||
}
|
||||
|
||||
|
||||
public List<ResizeRedactionRequest> toResizeRedactionRequestList(Set<ResizeRedactionRequestModel> resizeRedactionRequests) {
|
||||
public List<ResizeRedactionRequest> toResizeRedactionRequestList(String dossierId,
|
||||
String fileId,
|
||||
Set<ResizeRedactionRequestModel> resizeRedactionRequests,
|
||||
boolean includeUnprocessed) {
|
||||
|
||||
return resizeRedactionRequests.stream()
|
||||
.map(resizeRedactionRequest -> ResizeRedactionRequest.builder()
|
||||
.annotationId(resizeRedactionRequest.getAnnotationId())
|
||||
.user(KeycloakSecurity.getUserId())
|
||||
.positions(resizeRedactionRequest.getPositions())
|
||||
.value(resizeRedactionRequest.getValue() == null ? "" : StringCleaningUtility.cleanString(resizeRedactionRequest.getValue()))
|
||||
.comment(resizeRedactionRequest.getComment())
|
||||
.updateDictionary(resizeRedactionRequest.getUpdateDictionary())
|
||||
.addToAllDossiers(resizeRedactionRequest.isAddToAllDossiers())
|
||||
.build())
|
||||
.toList();
|
||||
EntityLog entityLog = entityLogService.getEntityLog(dossierId, fileId, Collections.emptyList(), includeUnprocessed);
|
||||
List<ResizeRedactionRequest> requests = new ArrayList<>();
|
||||
|
||||
for (ResizeRedactionRequestModel resizeRedactionRequest : resizeRedactionRequests) {
|
||||
|
||||
EntityLogEntry entityLogEntry = getEntityLogEntry(entityLog, resizeRedactionRequest.getAnnotationId());
|
||||
ResizeRedactionRequest request = ResizeRedactionRequest.builder()
|
||||
.annotationId(resizeRedactionRequest.getAnnotationId())
|
||||
.user(KeycloakSecurity.getUserId())
|
||||
.positions(resizeRedactionRequest.getPositions())
|
||||
.value(resizeRedactionRequest.getValue() == null ? "" : StringCleaningUtility.cleanString(resizeRedactionRequest.getValue()))
|
||||
.comment(resizeRedactionRequest.getComment())
|
||||
.updateDictionary(resizeRedactionRequest.getUpdateDictionary())
|
||||
.addToAllDossiers(resizeRedactionRequest.isAddToAllDossiers())
|
||||
.build();
|
||||
|
||||
if (!entityLogEntry.getEngines().contains(Engine.MANUAL) && !request.isAddToAllDossiers() && !request.getUpdateDictionary()) {
|
||||
addManualRedactionEntry(fileId, entityLogEntry);
|
||||
}
|
||||
|
||||
requests.add(request);
|
||||
}
|
||||
|
||||
return requests;
|
||||
}
|
||||
|
||||
|
||||
@ -206,4 +261,51 @@ public class ManualRedactionMapper {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void addManualRedactionEntry(String fileId, EntityLogEntry entityLogEntry) {
|
||||
|
||||
ManualRedactionEntry manualRedactionEntry = ManualRedactionEntry.builder()
|
||||
.value(entityLogEntry.getValue())
|
||||
.reason(entityLogEntry.getReason())
|
||||
.section(entityLogEntry.getSection())
|
||||
.annotationId(entityLogEntry.getId())
|
||||
.type(entityLogEntry.getType())
|
||||
.addToDossierDictionary(false)
|
||||
.addToDictionary(false)
|
||||
.positions(convertPositions(entityLogEntry.getPositions()))
|
||||
.rectangle(entityLogEntry.getEntryType() == EntryType.AREA)
|
||||
.user(KeycloakSecurity.getUserId())
|
||||
.legalBasis(entityLogEntry.getLegalBasis())
|
||||
.textAfter(entityLogEntry.getTextAfter())
|
||||
.textBefore(entityLogEntry.getTextBefore())
|
||||
.dictionaryEntryType(convertEntryType(entityLogEntry))
|
||||
.fileId(fileId)
|
||||
.requestDate(OffsetDateTime.now())
|
||||
.build();
|
||||
|
||||
manualRedactionService.addManualRedactionEntries(List.of(manualRedactionEntry), false);
|
||||
}
|
||||
|
||||
|
||||
private List<Rectangle> convertPositions(List<Position> positions) {
|
||||
|
||||
return positions.stream()
|
||||
.map(rectangle -> new Rectangle(rectangle.x(), rectangle.y(), rectangle.w(), rectangle.h(), rectangle.getPageNumber()))
|
||||
.toList();
|
||||
}
|
||||
|
||||
|
||||
private DictionaryEntryType convertEntryType(EntityLogEntry entityLogEntry) {
|
||||
|
||||
if (entityLogEntry.getEntryType().equals(EntryType.FALSE_POSITIVE)) {
|
||||
return DictionaryEntryType.FALSE_POSITIVE;
|
||||
}
|
||||
|
||||
if (entityLogEntry.getEntryType().equals(EntryType.FALSE_RECOMMENDATION)) {
|
||||
return DictionaryEntryType.FALSE_RECOMMENDATION;
|
||||
}
|
||||
|
||||
return DictionaryEntryType.ENTRY;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -120,7 +120,7 @@ public class EntityLogMergeTest {
|
||||
|
||||
ManualRedactions manualRedactions = provideManualRedactions(entryToAddId, entryToRemoveId, entryToResizeId, entryLegalBasisId, forceRedactionId, fileId, rectangleToAddId);
|
||||
|
||||
var entityLog = provideEntityLog(entryToRemoveId, entryToResizeId, entryLegalBasisId, forceRedactionId);
|
||||
var entityLog = provideEntityLog(entryToRemoveId, entryToResizeId, entryLegalBasisId, forceRedactionId, false);
|
||||
|
||||
when(manualRedactionProviderService.getManualRedactions(any(), any())).thenReturn(manualRedactions);
|
||||
when(fileStatusService.getStatus(fileId)).thenReturn(FileModel.builder().excluded(false).dossierStatusId(dossierTemplateId).id(fileId).build());
|
||||
@ -237,7 +237,7 @@ public class EntityLogMergeTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void testUnprocessedDictChangesAreDirectlyAfterOriginEntry() {
|
||||
public void testMergeEntityLogWithManualChangesOnDictRedaction() {
|
||||
|
||||
String fileId = "fileId";
|
||||
String dossierId = "dossierId";
|
||||
@ -250,6 +250,58 @@ public class EntityLogMergeTest {
|
||||
String entryLegalBasisId = UUID.randomUUID().toString();
|
||||
String forceRedactionId = UUID.randomUUID().toString();
|
||||
|
||||
ManualRedactions manualRedactions = provideManualRedactions(entryToAddId, entryToRemoveId, entryToResizeId, entryLegalBasisId, forceRedactionId, fileId, rectangleToAddId);
|
||||
|
||||
var entityLog = provideEntityLog(entryToRemoveId, entryToResizeId, entryLegalBasisId, forceRedactionId, true);
|
||||
|
||||
when(manualRedactionProviderService.getManualRedactions(any(), any())).thenReturn(manualRedactions);
|
||||
when(fileStatusService.getStatus(fileId)).thenReturn(FileModel.builder().excluded(false).dossierStatusId(dossierTemplateId).id(fileId).build());
|
||||
when(fileManagementStorageService.getEntityLog(dossierId, fileId)).thenReturn(entityLog);
|
||||
when(dossierService.getDossierById(dossierId)).thenReturn(DossierEntity.builder().dossierTemplateId(dossierTemplateId).build());
|
||||
when(dictionaryPersistenceService.getType(anyString())).thenReturn(TypeEntity.builder().isHint(false).build());
|
||||
when(fileStatusPersistenceService.getStatus(fileId)).thenReturn(FileEntity.builder().id(fileId).fileAttributes(Collections.emptyList()).build());
|
||||
when(fileStatusService.convertAttributes(any(), anyString())).thenReturn(Collections.emptyList());
|
||||
|
||||
EntityLog response = entityLogMergeService.mergeEntityLog(manualRedactions, entityLog, DossierEntity.builder().dossierTemplateId(dossierTemplateId).build());
|
||||
|
||||
assertNotNull(response);
|
||||
assertFalse(response.getEntityLogEntry().isEmpty());
|
||||
|
||||
var optionalResizeEntryLogEntry = response.getEntityLogEntry()
|
||||
.stream()
|
||||
.filter(entityLogEntry1 -> entityLogEntry1.getId().equals(entryToResizeId))
|
||||
.findFirst();
|
||||
assertTrue(optionalResizeEntryLogEntry.isPresent());
|
||||
assertEquals(optionalResizeEntryLogEntry.get().getEntryType(), EntryType.ENTITY);
|
||||
|
||||
var optionalLegalBasisEntryLogEntry = response.getEntityLogEntry()
|
||||
.stream()
|
||||
.filter(entityLogEntry1 -> entityLogEntry1.getId().equals(entryLegalBasisId))
|
||||
.findFirst();
|
||||
assertTrue(optionalLegalBasisEntryLogEntry.isPresent());
|
||||
assertEquals(optionalLegalBasisEntryLogEntry.get().getState(), EntryState.REMOVED);
|
||||
|
||||
var optionalForceRedactionEntryLogEntry = response.getEntityLogEntry()
|
||||
.stream()
|
||||
.filter(entityLogEntry1 -> entityLogEntry1.getId().equals(forceRedactionId))
|
||||
.findFirst();
|
||||
assertTrue(optionalForceRedactionEntryLogEntry.isPresent());
|
||||
assertEquals(optionalForceRedactionEntryLogEntry.get().getState(), EntryState.REMOVED);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testUnprocessedDictChangesAreDirectlyAfterOriginEntry() {
|
||||
|
||||
String fileId = "fileId";
|
||||
String dossierId = "dossierId";
|
||||
String dossierTemplateId = "dossierTemplateId";
|
||||
|
||||
String entryToRemoveId = UUID.randomUUID().toString();
|
||||
String entryToResizeId = UUID.randomUUID().toString();
|
||||
String entryLegalBasisId = UUID.randomUUID().toString();
|
||||
String forceRedactionId = UUID.randomUUID().toString();
|
||||
|
||||
|
||||
ManualRedactions manualRedactions = new ManualRedactions();
|
||||
List<Rectangle> positions = new ArrayList<>();
|
||||
@ -265,7 +317,7 @@ public class EntityLogMergeTest {
|
||||
.fileId("file")
|
||||
.build()));
|
||||
|
||||
var entityLog = provideEntityLog(entryToRemoveId, entryToResizeId, entryLegalBasisId, forceRedactionId);
|
||||
var entityLog = provideEntityLog(entryToRemoveId, entryToResizeId, entryLegalBasisId, forceRedactionId, false);
|
||||
|
||||
when(manualRedactionProviderService.getManualRedactions(any(), any())).thenReturn(manualRedactions);
|
||||
when(fileStatusService.getStatus(fileId)).thenReturn(FileModel.builder().excluded(false).dossierStatusId(dossierTemplateId).id(fileId).build());
|
||||
@ -284,7 +336,7 @@ public class EntityLogMergeTest {
|
||||
}
|
||||
|
||||
|
||||
private EntityLog provideEntityLog(String entryToRemoveId, String entryToResizeId, String entryLegalBasisId, String forceRedactionId) {
|
||||
private EntityLog provideEntityLog(String entryToRemoveId, String entryToResizeId, String entryLegalBasisId, String forceRedactionId, boolean dictEntry) {
|
||||
|
||||
List<Position> positions = new ArrayList<>();
|
||||
positions.add(new Position(1, 1, 1, 1, 1));
|
||||
@ -296,7 +348,7 @@ public class EntityLogMergeTest {
|
||||
.value("Luke Skywalker")
|
||||
.entryType(EntryType.ENTITY)
|
||||
.state(EntryState.APPLIED)
|
||||
.dictionaryEntry(true)
|
||||
.dictionaryEntry(dictEntry)
|
||||
.build(),
|
||||
EntityLogEntry.builder()
|
||||
.id(entryToResizeId)
|
||||
@ -304,7 +356,7 @@ public class EntityLogMergeTest {
|
||||
.value("Darth Vader")
|
||||
.entryType(EntryType.ENTITY)
|
||||
.state(EntryState.APPLIED)
|
||||
.dictionaryEntry(true)
|
||||
.dictionaryEntry(dictEntry)
|
||||
.positions(positions)
|
||||
.build(),
|
||||
EntityLogEntry.builder()
|
||||
@ -313,7 +365,7 @@ public class EntityLogMergeTest {
|
||||
.value("Darth Luke")
|
||||
.entryType(EntryType.ENTITY)
|
||||
.state(EntryState.APPLIED)
|
||||
.dictionaryEntry(true)
|
||||
.dictionaryEntry(dictEntry)
|
||||
.positions(positions)
|
||||
.build(),
|
||||
EntityLogEntry.builder()
|
||||
@ -322,10 +374,10 @@ public class EntityLogMergeTest {
|
||||
.value("Darth Luke")
|
||||
.entryType(EntryType.ENTITY)
|
||||
.state(EntryState.APPLIED)
|
||||
.dictionaryEntry(true)
|
||||
.dictionaryEntry(dictEntry)
|
||||
.positions(positions)
|
||||
.build()),
|
||||
null,
|
||||
Collections.emptyList(),
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
@ -381,6 +433,7 @@ public class EntityLogMergeTest {
|
||||
.positions(positions)
|
||||
.requestDate(OffsetDateTime.now())
|
||||
.updateDictionary(false)
|
||||
.addToAllDossiers(false)
|
||||
.user("User")
|
||||
.fileId("file")
|
||||
.build()))
|
||||
@ -402,7 +455,6 @@ public class EntityLogMergeTest {
|
||||
.fileId("file")
|
||||
.build()))
|
||||
.build();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -164,8 +164,10 @@ public class FileTest extends AbstractPersistenceServerServiceTest {
|
||||
reanalysisClient.toggleAutomaticAnalysis(dossier.getId(), file.getId(), true);
|
||||
|
||||
List<FileAttributeConfig> configs = new ArrayList<>();
|
||||
configs.add(FileAttributeConfig.builder().csvColumnHeader("Name").primaryAttribute(true).label("Name").build());
|
||||
configs.add(FileAttributeConfig.builder().csvColumnHeader("Attribute A").primaryAttribute(true).label("Attribute A").build());
|
||||
configs.add(FileAttributeConfig.builder().csvColumnHeader("Name").primaryAttribute(true).label("Name")
|
||||
.build());
|
||||
configs.add(FileAttributeConfig.builder().csvColumnHeader("Attribute A").primaryAttribute(true).label("Attribute A")
|
||||
.build());
|
||||
var loadedConfig = fileAttributeConfigClient.setFileAttributesConfig(dossier.getDossierTemplateId(), new FileAttributesConfig(configs));
|
||||
fileAttributeClient.setFileAttributes(dossier.getId(),
|
||||
file.getId(),
|
||||
@ -377,6 +379,20 @@ public class FileTest extends AbstractPersistenceServerServiceTest {
|
||||
.value("value entry")
|
||||
.state(EntryState.APPLIED)
|
||||
.entryType(EntryType.ENTITY)
|
||||
.build(),
|
||||
EntityLogEntry.builder()
|
||||
.id("forceRedactionAnnotation")
|
||||
.type(type.getType())
|
||||
.value("value entry 2")
|
||||
.state(EntryState.APPLIED)
|
||||
.entryType(EntryType.ENTITY)
|
||||
.build(),
|
||||
EntityLogEntry.builder()
|
||||
.id("legalBasisChangeAnnotation")
|
||||
.type(type.getType())
|
||||
.value("value entry 3")
|
||||
.state(EntryState.APPLIED)
|
||||
.entryType(EntryType.ENTITY)
|
||||
.build()),
|
||||
null,
|
||||
0,
|
||||
@ -401,21 +417,26 @@ public class FileTest extends AbstractPersistenceServerServiceTest {
|
||||
|
||||
manualRedactionClient.removeRedactionBulk(dossierId,
|
||||
fileId,
|
||||
Set.of(RemoveRedactionRequestModel.builder().annotationId(annotationId).comment("comment").removeFromDictionary(false).build()),
|
||||
Set.of(RemoveRedactionRequestModel.builder().annotationId(annotationId).comment("comment").removeFromDictionary(false)
|
||||
.build()),
|
||||
false);
|
||||
manualRedactionClient.forceRedactionBulk(dossierId,
|
||||
fileId,
|
||||
Set.of(ForceRedactionRequestModel.builder().annotationId("forceRedactionAnnotation").comment("comment").legalBasis("1").build()));
|
||||
Set.of(ForceRedactionRequestModel.builder().annotationId("forceRedactionAnnotation").comment("comment").legalBasis("1")
|
||||
.build()));
|
||||
manualRedactionClient.legalBasisChangeBulk(dossierId,
|
||||
fileId,
|
||||
Set.of(LegalBasisChangeRequestModel.builder()
|
||||
.annotationId("legalBasisChangeAnnotation")
|
||||
.comment("comment")
|
||||
.legalBasis("1")
|
||||
Set.of(LegalBasisChangeRequestModel.builder().annotationId("legalBasisChangeAnnotation").comment("comment").legalBasis("1")
|
||||
.build()));
|
||||
manualRedactionClient.recategorizeBulk(dossierId,
|
||||
fileId,
|
||||
Set.of(RecategorizationRequestModel.builder().annotationId(annotationId).comment("comment").type("new-type").legalBasis("").section("section").build()),
|
||||
Set.of(RecategorizationRequestModel.builder()
|
||||
.annotationId(annotationId)
|
||||
.comment("comment")
|
||||
.type("new-type")
|
||||
.legalBasis("")
|
||||
.section("section")
|
||||
.build()),
|
||||
false);
|
||||
|
||||
var loadedFile = fileClient.getFileStatus(dossierId, fileId);
|
||||
|
||||
@ -45,6 +45,7 @@ import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.EntityLogEntry;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.EntryState;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.EntryType;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.Position;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.AddRedactionRequest;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.ManualRedactions;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.Rectangle;
|
||||
@ -808,7 +809,7 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void MtestEnlargeResizeRedactionInDossierTemplateDictionaryWithAddToAllDossiers() {
|
||||
public void testEnlargeResizeRedactionInDossierTemplateDictionaryWithAddToAllDossiers() {
|
||||
|
||||
// preparíng prerequisites
|
||||
var dossierTemplate = dossierTemplateTesterAndProvider.provideTestTemplate();
|
||||
@ -879,7 +880,7 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
0);
|
||||
fileManagementStorageService.storeJSONObject(dossier1.getId(), file1.getId(), FileType.ENTITY_LOG, entityLog1);
|
||||
var redactionRequest1 = RedactionRequest.builder().dossierId(file1.getDossierId()).fileId(file1.getFileId()).dossierTemplateId(file1.getDossierTemplateId()).build();
|
||||
when(entityLogService.getEntityLog(file1.getDossierId(), file1.getFileId())).thenReturn(entityLog1);
|
||||
when(entityLogService.getEntityLog(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.anyBoolean())).thenReturn(entityLog1);
|
||||
|
||||
var entityLog2 = new EntityLog(1,
|
||||
1,
|
||||
@ -900,6 +901,7 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
var redactionRequest2 = RedactionRequest.builder().dossierId(file2.getDossierId()).fileId(file2.getFileId()).dossierTemplateId(file2.getDossierTemplateId()).build();
|
||||
when(entityLogService.getEntityLog(eq(file2.getDossierId()), eq(file2.getFileId()), any(), anyBoolean())).thenReturn(entityLog2);
|
||||
|
||||
|
||||
// resize redaction in dossier dict
|
||||
var resizeRedactionDosTemp = ResizeRedactionRequestModel.builder()
|
||||
.annotationId(addRedactions.get(1).getAnnotationId())
|
||||
@ -1546,6 +1548,38 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
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("forceRedactionAnnotation")
|
||||
.type(type.getType())
|
||||
.value("lukeSkywalker")
|
||||
.dictionaryEntry(true)
|
||||
.entryType(EntryType.ENTITY)
|
||||
.state(EntryState.APPLIED)
|
||||
.legalBasis("legal basis")
|
||||
.positions(List.of(new Position(1, 1, 1, 1, 1)))
|
||||
.build(),
|
||||
EntityLogEntry.builder()
|
||||
.id("forceRedactionAnnotation2")
|
||||
.type(type.getType())
|
||||
.value("lukeSkywalker")
|
||||
.dictionaryEntry(true)
|
||||
.entryType(EntryType.ENTITY)
|
||||
.state(EntryState.APPLIED)
|
||||
.legalBasis("legal basis")
|
||||
.positions(List.of(new Position(1, 1, 1, 1, 1)))
|
||||
.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);
|
||||
|
||||
manualRedactionClient.forceRedactionBulk(dossier.getId(),
|
||||
file.getId(),
|
||||
Set.of(ForceRedactionRequestModel.builder().annotationId("forceRedactionAnnotation").comment("comment").legalBasis("1").build()));
|
||||
@ -1618,6 +1652,7 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testUnprocessedManualRedactionsRecategorizations() {
|
||||
|
||||
@ -1766,7 +1801,8 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
0);
|
||||
fileManagementStorageService.storeJSONObject(dossier.getId(), file.getId(), FileType.ENTITY_LOG, entityLog);
|
||||
|
||||
when(entityLogService.getEntityLog(Mockito.any(), Mockito.any())).thenReturn(entityLog);
|
||||
when(entityLogService.getEntityLog(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.anyBoolean())).thenReturn(entityLog);
|
||||
|
||||
|
||||
manualRedactionClient.legalBasisChangeBulk(dossier.getId(),
|
||||
file.getId(),
|
||||
@ -1963,7 +1999,7 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
0);
|
||||
fileManagementStorageService.storeJSONObject(dossier.getId(), file.getId(), FileType.ENTITY_LOG, entityLog);
|
||||
|
||||
when(entityLogService.getEntityLog(Mockito.any(), Mockito.any())).thenReturn(entityLog);
|
||||
when(entityLogService.getEntityLog(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.anyBoolean())).thenReturn(entityLog);
|
||||
|
||||
manualRedactionClient.legalBasisChangeBulk(dossier.getId(),
|
||||
file.getId(),
|
||||
@ -1988,13 +2024,13 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
.anyMatch(entry -> entry.getLegalBasis().equals("legalBasis")));
|
||||
|
||||
var unprocessedManualRedactions = manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), true, false);
|
||||
assertEquals(unprocessedManualRedactions.buildAll().size(), 1);
|
||||
assertEquals(unprocessedManualRedactions.buildAll().size(), 2);
|
||||
assertTrue(unprocessedManualRedactions.getLegalBasisChanges()
|
||||
.stream()
|
||||
.anyMatch(entry -> entry.getLegalBasis().equals("legalBasis")));
|
||||
|
||||
var unprocessedManualRedactionsWithDict = manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), true, true);
|
||||
assertEquals(unprocessedManualRedactionsWithDict.buildAll().size(), 2);
|
||||
assertEquals(unprocessedManualRedactionsWithDict.buildAll().size(), 3);
|
||||
assertTrue(unprocessedManualRedactionsWithDict.getLegalBasisChanges()
|
||||
.stream()
|
||||
.anyMatch(entry -> entry.getLegalBasis().equals("legalBasis")));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user