From 480711e39cbc7ab5a74457567d3355d77930dc65 Mon Sep 17 00:00:00 2001 From: Ali Oezyetimoglu Date: Wed, 9 Aug 2023 17:00:51 +0200 Subject: [PATCH] RED-7241: fixed logic to adapt resize endpoints; removed unused and deprecated methods --- .../controller/ManualRedactionController.java | 633 +-------- .../resource/ManualRedactionResource.java | 214 ---- .../service/ManualRedactionService.java | 63 +- .../v1/server/integration/tests/FileTest.java | 85 +- .../tests/ManualRedactionTest.java | 1127 ++++++++--------- .../model/manual/AddRedactionRequest.java | 3 - 6 files changed, 590 insertions(+), 1535 deletions(-) diff --git a/persistence-service-v1/persistence-service-external-api-impl-v1/src/main/java/com/iqser/red/persistence/service/v1/external/api/impl/controller/ManualRedactionController.java b/persistence-service-v1/persistence-service-external-api-impl-v1/src/main/java/com/iqser/red/persistence/service/v1/external/api/impl/controller/ManualRedactionController.java index 60a8a614d..266940f32 100644 --- a/persistence-service-v1/persistence-service-external-api-impl-v1/src/main/java/com/iqser/red/persistence/service/v1/external/api/impl/controller/ManualRedactionController.java +++ b/persistence-service-v1/persistence-service-external-api-impl-v1/src/main/java/com/iqser/red/persistence/service/v1/external/api/impl/controller/ManualRedactionController.java @@ -1,6 +1,10 @@ package com.iqser.red.persistence.service.v1.external.api.impl.controller; -import static com.iqser.red.service.persistence.management.v1.processor.roles.ActionRoles.*; +import static com.iqser.red.service.persistence.management.v1.processor.roles.ActionRoles.ADD_COMMENT; +import static com.iqser.red.service.persistence.management.v1.processor.roles.ActionRoles.DELETE_COMMENT; +import static com.iqser.red.service.persistence.management.v1.processor.roles.ActionRoles.DELETE_MANUAL_REDACTION; +import static com.iqser.red.service.persistence.management.v1.processor.roles.ActionRoles.DO_MANUAL_REDACTION; +import static com.iqser.red.service.persistence.management.v1.processor.roles.ActionRoles.READ_MANUAL_REDACTIONS; import static com.iqser.red.service.persistence.management.v1.processor.utils.TypeIdUtils.toTypeId; import java.util.ArrayList; @@ -37,7 +41,6 @@ import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations import com.iqser.red.service.persistence.service.v1.api.shared.model.audit.AuditRequest; import com.iqser.red.service.persistence.service.v1.api.shared.model.manual.AddCommentRequest; import com.iqser.red.service.persistence.service.v1.api.shared.model.manual.AddRedactionRequest; -import com.iqser.red.service.persistence.service.v1.api.shared.model.manual.ApproveRequest; import com.iqser.red.service.persistence.service.v1.api.shared.model.manual.ForceRedactionRequest; import com.iqser.red.service.persistence.service.v1.api.shared.model.manual.ImageRecategorizationRequest; import com.iqser.red.service.persistence.service.v1.api.shared.model.manual.LegalBasisChangeRequest; @@ -63,396 +66,6 @@ public class ManualRedactionController implements ManualRedactionResource { private final AccessControlService accessControlService; - /* Reviewer Operations*/ - - - @Deprecated - @Override - @PreAuthorize("hasAuthority('" + REQUEST_MANUAL_REDACTION + "')") - public ManualAddResponse requestAddRedaction(@PathVariable(DOSSIER_ID) String dossierId, - @PathVariable(FILE_ID) String fileId, - @RequestBody AddRedactionRequest addRedactionRequest) { - - return requestBulkAddRedaction(dossierId, fileId, Set.of(addRedactionRequest)).get(0); - } - - - @Override - @PreAuthorize("hasAuthority('" + REQUEST_MANUAL_REDACTION + "')") - public List requestBulkAddRedaction(@PathVariable(DOSSIER_ID) String dossierId, - @PathVariable(FILE_ID) String fileId, - @RequestBody Set addRedactionRequests) { - - var dossier = dossierManagementService.getDossierById(dossierId, false, false); - accessControlService.verifyFileIsNotApproved(dossierId, fileId); - accessControlService.verifyUserIsReviewer(dossierId, fileId); - - List requests = new ArrayList<>(); - - for (var addRedactionRequest : addRedactionRequests) { - - var addRedactionRequestBuilder = com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.AddRedactionRequest.builder() - .user(KeycloakSecurity.getUserId()) - .dossierTemplateTypeId(toTypeId(addRedactionRequest.getType(), dossier.getDossierTemplateId())) - .value(addRedactionRequest.getValue()) - .reason(addRedactionRequest.getReason()) - .legalBasis(addRedactionRequest.getLegalBasis()) - .addToDictionary(addRedactionRequest.isAddToDictionary()) - .status(AnnotationStatus.REQUESTED) - .section(addRedactionRequest.getSection()) - .positions(addRedactionRequest.getPositions()) - .comment(addRedactionRequest.getComment() != null ? addRedactionRequest.getComment().getText() : null) - .addToAllDossiers(addRedactionRequest.isAddToAllDossiers()) - .forceAddToDictionary(addRedactionRequest.isForceAddToDictionary()) - .rectangle(addRedactionRequest.isRectangle()) - .dictionaryEntryType(addRedactionRequest.getDictionaryEntryType()) - .sourceId(addRedactionRequest.getSourceId()); - - requests.add(addRedactionRequestBuilder.build()); - } - List responseList = new ArrayList<>(); - responseList = manualRedactionService.addAddRedaction(dossierId, fileId, requests); - responseList.forEach(response -> auditPersistenceService.audit(AuditRequest.builder() - .userId(KeycloakSecurity.getUserId()) - .objectId(fileId) - .category(AuditCategory.DOCUMENT.name()) - .message("Manual redaction was requested.") - .details(Map.of(DOSSIER_ID, dossierId, FILE_ID, fileId, ANNOTATION_ID, response.getAnnotationId())) - .build())); - return responseList; - - } - - - @Deprecated - @Override - @PreAuthorize("hasAuthority('" + REQUEST_MANUAL_REDACTION + "')") - public ManualAddResponse requestRemoveRedaction(@PathVariable(DOSSIER_ID) String dossierId, - @PathVariable(FILE_ID) String fileId, - @RequestBody RemoveRedactionRequest removeRedactionRequest) { - - return processRequestRemoveRedactionBulk(dossierId, fileId, Set.of(removeRedactionRequest)).get(0); - } - - - private List processRequestRemoveRedactionBulk(String dossierId, String fileId, Set removeRedactionRequests) { - - accessControlService.verifyFileIsNotApproved(dossierId, fileId); - accessControlService.verifyUserIsReviewer(dossierId, fileId); - - List requests = removeRedactionRequests.stream() - .map(removeRedactionRequest -> com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.RemoveRedactionRequest.builder() - .annotationId(removeRedactionRequest.getAnnotationId()) - .user(KeycloakSecurity.getUserId()) - .status(AnnotationStatus.REQUESTED) - .removeFromDictionary(removeRedactionRequest.isRemoveFromDictionary()) - .comment(removeRedactionRequest.getComment()) - .build()) - .collect(Collectors.toList()); - - List responseList = manualRedactionService.addRemoveRedaction(dossierId, fileId, requests); - - responseList.forEach(response -> auditPersistenceService.audit(AuditRequest.builder() - .userId(KeycloakSecurity.getUserId()) - .objectId(fileId) - .category(AuditCategory.DOCUMENT.name()) - .message("Manual removed redaction was requested.") - .details(Map.of(DOSSIER_ID, dossierId, FILE_ID, fileId, ANNOTATION_ID, response.getAnnotationId())) - .build())); - - return responseList; - } - - - @Override - @PreAuthorize("hasAuthority('" + REQUEST_MANUAL_REDACTION + "')") - public List requestBulkRemoveRedaction(@PathVariable(DOSSIER_ID) String dossierId, - @PathVariable(FILE_ID) String fileId, - @RequestBody Set removeRedactionRequests) { - - return processRequestRemoveRedactionBulk(dossierId, fileId, removeRedactionRequests); - } - - - @Deprecated - @Override - @PreAuthorize("hasAuthority('" + REQUEST_MANUAL_REDACTION + "')") - public ManualAddResponse requestForceRedaction(@PathVariable(DOSSIER_ID) String dossierId, - @PathVariable(FILE_ID) String fileId, - @RequestBody ForceRedactionRequest forceRedactionRequest) { - - return processRequestForceRedactionBulk(dossierId, fileId, Set.of(forceRedactionRequest)).get(0); - } - - - private List processRequestForceRedactionBulk(String dossierId, String fileId, Set forceRedactionRequests) { - - accessControlService.verifyFileIsNotApproved(dossierId, fileId); - accessControlService.verifyUserIsReviewer(dossierId, fileId); - - List requests = forceRedactionRequests.stream() - .map(forceRedactionRequest -> com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.ForceRedactionRequest.builder() - .annotationId(forceRedactionRequest.getAnnotationId()) - .user(KeycloakSecurity.getUserId()) - .status(AnnotationStatus.REQUESTED) - .comment(forceRedactionRequest.getComment()) - .legalBasis(forceRedactionRequest.getLegalBasis()) - .build()) - .collect(Collectors.toList()); - - List responseList = manualRedactionService.addForceRedaction(dossierId, fileId, requests); - - responseList.forEach(response -> auditPersistenceService.audit(AuditRequest.builder() - .userId(KeycloakSecurity.getUserId()) - .objectId(fileId) - .category(AuditCategory.DOCUMENT.name()) - .message("Manual force redaction was requested.") - .details(Map.of(DOSSIER_ID, dossierId, FILE_ID, fileId, ANNOTATION_ID, response.getAnnotationId())) - .build())); - - return responseList; - } - - - @PreAuthorize("hasAuthority('" + REQUEST_MANUAL_REDACTION + "')") - public List requestBulkForceRedaction(@PathVariable(DOSSIER_ID) String dossierId, - @PathVariable(FILE_ID) String fileId, - @RequestBody Set forceRedactionRequests) { - - return processRequestForceRedactionBulk(dossierId, fileId, forceRedactionRequests); - } - - - @Deprecated - @PreAuthorize("hasAuthority('" + REQUEST_MANUAL_REDACTION + "')") - public ManualAddResponse requestLegalBasisChange(@PathVariable(DOSSIER_ID) String dossierId, - @PathVariable(FILE_ID) String fileId, - @RequestBody LegalBasisChangeRequest legalBasisChangeRequest) { - - return processRequestLegalBasisChangeBulk(dossierId, fileId, Set.of(legalBasisChangeRequest)).get(0); - } - - - private List processRequestLegalBasisChangeBulk(String dossierId, String fileId, Set legalBasisChangeRequests) { - - accessControlService.verifyFileIsNotApproved(dossierId, fileId); - accessControlService.verifyUserIsReviewer(dossierId, fileId); - - List requests = legalBasisChangeRequests.stream() - .map(legalBasisChangeRequest -> com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.LegalBasisChangeRequest.builder() - .annotationId(legalBasisChangeRequest.getAnnotationId()) - .user(KeycloakSecurity.getUserId()) - .status(AnnotationStatus.REQUESTED) - .section(legalBasisChangeRequest.getSection()) - .comment(legalBasisChangeRequest.getComment()) - .legalBasis(legalBasisChangeRequest.getLegalBasis()) - .value(legalBasisChangeRequest.getValue()) - .build()) - .collect(Collectors.toList()); - - List responseList = manualRedactionService.addLegalBasisChange(dossierId, fileId, requests); - - responseList.forEach(response -> auditPersistenceService.audit(AuditRequest.builder() - .userId(KeycloakSecurity.getUserId()) - .objectId(fileId) - .category(AuditCategory.DOCUMENT.name()) - .message("Manual force redaction was requested.") - .details(Map.of(DOSSIER_ID, dossierId, FILE_ID, fileId, ANNOTATION_ID, response.getAnnotationId())) - .build())); - - return responseList; - } - - - @PreAuthorize("hasAuthority('" + REQUEST_MANUAL_REDACTION + "')") - public List requestBulkLegalBasisChange(@PathVariable(DOSSIER_ID) String dossierId, - @PathVariable(FILE_ID) String fileId, - @RequestBody Set legalBasisChangeRequests) { - - return processRequestLegalBasisChangeBulk(dossierId, fileId, legalBasisChangeRequests); - } - - - @Deprecated - @PreAuthorize("hasAuthority('" + REQUEST_MANUAL_REDACTION + "')") - public ManualAddResponse requestImageRecategorization(@PathVariable(DOSSIER_ID) String dossierId, - @PathVariable(FILE_ID) String fileId, - @RequestBody ImageRecategorizationRequest imageRecategorizationRequest) { - - return processRequestImageRecategorizationBulk(dossierId, fileId, Set.of(imageRecategorizationRequest)).get(0); - } - - - private List processRequestImageRecategorizationBulk(String dossierId, String fileId, Set imageRecategorizationRequests) { - - accessControlService.verifyFileIsNotApproved(dossierId, fileId); - accessControlService.verifyUserIsReviewer(dossierId, fileId); - var dossier = dossierManagementService.getDossierById(dossierId, false, false); - - List requests = imageRecategorizationRequests.stream() - .map(imageRecategorizationRequest -> com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.ImageRecategorizationRequest.builder() - .annotationId(imageRecategorizationRequest.getAnnotationId()) - .user(KeycloakSecurity.getUserId()) - .status(AnnotationStatus.REQUESTED) - .typeId(toTypeId(imageRecategorizationRequest.getType(), dossier.getDossierTemplateId())) - .comment(imageRecategorizationRequest.getComment()) - .build()) - .collect(Collectors.toList()); - - List responseList = manualRedactionService.addImageRecategorization(dossierId, fileId, requests); - - responseList.forEach(response -> auditPersistenceService.audit(AuditRequest.builder() - .userId(KeycloakSecurity.getUserId()) - .objectId(fileId) - .category(AuditCategory.DOCUMENT.name()) - .message("Image recategorization was requested.") - .details(Map.of(DOSSIER_ID, dossierId, FILE_ID, fileId, ANNOTATION_ID, response.getAnnotationId())) - .build())); - - return responseList; - } - - - @PreAuthorize("hasAuthority('" + REQUEST_MANUAL_REDACTION + "')") - public List requestBulkImageRecategorization(@PathVariable(DOSSIER_ID) String dossierId, - @PathVariable(FILE_ID) String fileId, - @RequestBody Set imageRecategorizationRequests) { - - return processRequestImageRecategorizationBulk(dossierId, fileId, imageRecategorizationRequests); - } - - - @Deprecated - @Override - @PreAuthorize("hasAuthority('" + REQUEST_MANUAL_REDACTION + "')") - public ManualAddResponse requestResizeRedaction(@PathVariable(DOSSIER_ID) String dossierId, - @PathVariable(FILE_ID) String fileId, - @RequestBody ResizeRedactionRequest resizeRedactionRequest) { - - return processRequestResizeRedactionBulk(dossierId, fileId, Set.of(resizeRedactionRequest)).get(0); - } - - - private List processRequestResizeRedactionBulk(String dossierId, String fileId, Set resizeRedactionRequests) { - - accessControlService.verifyFileIsNotApproved(dossierId, fileId); - accessControlService.verifyUserIsReviewer(dossierId, fileId); - - List requests = resizeRedactionRequests.stream() - .map(resizeRedactionRequest -> com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.ResizeRedactionRequest.builder() - .annotationId(resizeRedactionRequest.getAnnotationId()) - .user(KeycloakSecurity.getUserId()) - .status(AnnotationStatus.REQUESTED) - .comment(resizeRedactionRequest.getComment()) - .positions(resizeRedactionRequest.getPositions()) - .value(resizeRedactionRequest.getValue()) - .updateDictionary(resizeRedactionRequest.getUpdateDictionary()) - .addToAllDossiers(resizeRedactionRequest.isAddToAllDossiers()) - .build()) - .collect(Collectors.toList()); - - List responseList = manualRedactionService.addResizeRedaction(dossierId, fileId, requests); - - responseList.forEach(response -> auditPersistenceService.audit(AuditRequest.builder() - .userId(KeycloakSecurity.getUserId()) - .objectId(fileId) - .category(AuditCategory.DOCUMENT.name()) - .message("Manual resize redaction was requested.") - .details(Map.of(DOSSIER_ID, dossierId, FILE_ID, fileId, ANNOTATION_ID, response.getAnnotationId())) - .build())); - - return responseList; - } - - - @PreAuthorize("hasAuthority('" + REQUEST_MANUAL_REDACTION + "')") - public List requestBulkResizeRedaction(@PathVariable(DOSSIER_ID) String dossierId, - @PathVariable(FILE_ID) String fileId, - @RequestBody Set resizeRedactionRequests) { - - return processRequestResizeRedactionBulk(dossierId, fileId, resizeRedactionRequests); - } - - - @Deprecated - @Override - @PreAuthorize("hasAuthority('" + DELETE_MANUAL_REDACTION + "')") - public void undo(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId, @PathVariable(ANNOTATION_ID) String annotationId) { - - accessControlService.verifyFileIsNotApproved(dossierId, fileId); - accessControlService.verifyUserIsReviewer(dossierId, fileId); - - ManualRedactions manualRedactions = manualRedactionService.getManualRedactions(fileId); - - ManualRedactionWrapper manualRedactionWrapper = getLatestManualRedactionForAnnotationId(manualRedactions, annotationId); - - if (manualRedactionWrapper == null) { - throw new NotFoundException(String.format("ManualRedaction with annotationId %s could not be found.", annotationId)); - } - - if (manualRedactionWrapper.getItem() instanceof ManualRedactionEntry) { - - manualRedactionService.deleteAddRedaction(dossierId, fileId, List.of(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()); - } else if (manualRedactionWrapper.getItem() instanceof IdRemoval) { - - manualRedactionService.deleteRemoveRedaction(dossierId, fileId, List.of(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()); - } else if (manualRedactionWrapper.getItem() instanceof ManualForceRedaction) { - - manualRedactionService.deleteForceRedaction(dossierId, fileId, List.of(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()); - } else if (manualRedactionWrapper.getItem() instanceof ManualImageRecategorization) { - - manualRedactionService.deleteImageRecategorization(dossierId, fileId, List.of(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()); - } else if (manualRedactionWrapper.getItem() instanceof ManualLegalBasisChange) { - - manualRedactionService.deleteLegalBasisChange(dossierId, fileId, List.of(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()); - } else if (manualRedactionWrapper.getItem() instanceof ManualResizeRedaction) { - - manualRedactionService.deleteResizeRedaction(dossierId, fileId, List.of(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()); - } - } - private ManualRedactionWrapper getLatestManualRedactionForAnnotationId(ManualRedactions manualRedactions, String annotationId) { @@ -650,150 +263,6 @@ public class ManualRedactionController implements ManualRedactionResource { } - @Deprecated - @Override - @PreAuthorize("hasAuthority('" + PROCESS_MANUAL_REDACTION_REQUEST + "')") - public void declineRequest(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId, @PathVariable(ANNOTATION_ID) String annotationId) { - - declineRequestBulk(dossierId, fileId, Set.of(annotationId)); - } - - - /* Approver Operations*/ - - - @PreAuthorize("hasAuthority('" + PROCESS_MANUAL_REDACTION_REQUEST + "')") - public void declineRequestBulk(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId, @RequestBody Set annotationIds) { - - accessControlService.verifyFileIsNotApproved(dossierId, fileId); - accessControlService.verifyUserIsApprover(dossierId); - - updateAnnotationStatus(dossierId, fileId, annotationIds, AnnotationStatus.DECLINED); - - annotationIds.forEach(annotationId -> auditPersistenceService.audit(AuditRequest.builder() - .userId(KeycloakSecurity.getUserId()) - .objectId(fileId) - .category(AuditCategory.DOCUMENT.name()) - .message("Suggestion was declined") - .details(Map.of(DOSSIER_ID, dossierId, FILE_ID, fileId, ANNOTATION_ID, annotationId)) - .build())); - } - - - private void updateAnnotationStatus(String dossierId, String fileId, Set annotationIds, AnnotationStatus status) { - - accessControlService.verifyFileIsNotApproved(dossierId, fileId); - ManualRedactions manualRedactions = manualRedactionService.getManualRedactions(fileId); - - Map manualRedactionWrappers = getLatestManualRedactionsForAnnotationIds(manualRedactions, annotationIds); - - if (manualRedactionWrappers.isEmpty()) { - throw new NotFoundException(String.format("ManualRedaction with annotationIds %s could not be found.", annotationIds)); - } - - List manualRedactionEntries = manualRedactionWrappers.values() - .stream() - .filter(manualRedactionWrapper -> manualRedactionWrapper.getItem() instanceof ManualRedactionEntry) - .map(ManualRedactionWrapper::getId) - .collect(Collectors.toList()); - if (!manualRedactionEntries.isEmpty()) { - manualRedactionService.updateAddRedactionStatus(dossierId, fileId, manualRedactionEntries, status); - 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())); - } - - List idRemovals = manualRedactionWrappers.values() - .stream() - .filter(manualRedactionWrapper -> manualRedactionWrapper.getItem() instanceof IdRemoval) - .map(ManualRedactionWrapper::getId) - .collect(Collectors.toList()); - if (!idRemovals.isEmpty()) { - - manualRedactionService.updateRemoveRedactionStatus(dossierId, fileId, idRemovals, status); - 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())); - } - - List manualForceRedactions = manualRedactionWrappers.values() - .stream() - .filter(manualRedactionWrapper -> manualRedactionWrapper.getItem() instanceof ManualForceRedaction) - .map(ManualRedactionWrapper::getId) - .collect(Collectors.toList()); - if (!manualForceRedactions.isEmpty()) { - - manualRedactionService.updateForceRedactionStatus(dossierId, fileId, manualForceRedactions, status); - 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())); - } - - List manualImageRecategorizations = manualRedactionWrappers.values() - .stream() - .filter(manualRedactionWrapper -> manualRedactionWrapper.getItem() instanceof ManualImageRecategorization) - .map(ManualRedactionWrapper::getId) - .collect(Collectors.toList()); - if (!manualImageRecategorizations.isEmpty()) { - - manualRedactionService.updateImageRecategorizationStatus(dossierId, fileId, manualImageRecategorizations, status); - 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())); - } - - List manualLegalBasisChanges = manualRedactionWrappers.values() - .stream() - .filter(manualRedactionWrapper -> manualRedactionWrapper.getItem() instanceof ManualLegalBasisChange) - .map(ManualRedactionWrapper::getId) - .collect(Collectors.toList()); - if (!manualLegalBasisChanges.isEmpty()) { - - manualRedactionService.updateLegalBasisChangeStatus(dossierId, fileId, manualLegalBasisChanges, status); - 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())); - } - - List manualResizeRedactions = manualRedactionWrappers.values() - .stream() - .filter(manualRedactionWrapper -> manualRedactionWrapper.getItem() instanceof ManualResizeRedaction) - .map(ManualRedactionWrapper::getId) - .collect(Collectors.toList()); - if (!manualResizeRedactions.isEmpty()) { - - manualRedactionService.updateResizeRedactionStatus(dossierId, fileId, manualResizeRedactions, status); - 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())); - } - } - - @Override @PreAuthorize("hasAuthority('" + READ_MANUAL_REDACTIONS + "')") public ManualRedactions getManualRedactions(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId) { @@ -828,45 +297,6 @@ public class ManualRedactionController implements ManualRedactionResource { } - @Deprecated - @Override - @PreAuthorize("hasAuthority('" + PROCESS_MANUAL_REDACTION_REQUEST + "')") - public void approveRequest(@PathVariable(DOSSIER_ID) String dossierId, - @PathVariable(FILE_ID) String fileId, - @PathVariable(ANNOTATION_ID) String annotationId, - @RequestBody ApproveRequest approveRequest) { - - approveRequestBulk(dossierId, fileId, Set.of(annotationId)); - } - - - @PreAuthorize("hasAuthority('" + PROCESS_MANUAL_REDACTION_REQUEST + "')") - public void approveRequestBulk(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId, @RequestBody Set annotationIds) { - - accessControlService.verifyFileIsNotApproved(dossierId, fileId); - accessControlService.verifyUserIsApprover(dossierId); - - updateAnnotationStatus(dossierId, fileId, annotationIds, AnnotationStatus.APPROVED); - - annotationIds.forEach(annotationId -> auditPersistenceService.audit(AuditRequest.builder() - .userId(KeycloakSecurity.getUserId()) - .objectId(fileId) - .category(AuditCategory.DOCUMENT.name()) - .message("Suggestion was approved") - .details(Map.of(DOSSIER_ID, dossierId, FILE_ID, fileId, ANNOTATION_ID, annotationId)) - .build())); - } - - - @Deprecated - @Override - @PreAuthorize("hasAuthority('" + DO_MANUAL_REDACTION + "')") - public ManualAddResponse addRedaction(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId, @RequestBody AddRedactionRequest addRedactionRequest) { - - return addRedactionBulk(dossierId, fileId, Set.of(addRedactionRequest)).get(0); - } - - @Override @PreAuthorize("hasAuthority('" + DO_MANUAL_REDACTION + "')") public List addRedactionBulk(@PathVariable(DOSSIER_ID) String dossierId, @@ -918,17 +348,6 @@ public class ManualRedactionController implements ManualRedactionResource { } - @Deprecated - @Override - @PreAuthorize("hasAuthority('" + DO_MANUAL_REDACTION + "')") - public ManualAddResponse removeRedaction(@PathVariable(DOSSIER_ID) String dossierId, - @PathVariable(FILE_ID) String fileId, - @RequestBody RemoveRedactionRequest removeRedactionRequest) { - - return removeRedactionBulk(dossierId, fileId, Set.of(removeRedactionRequest)).get(0); - } - - @PreAuthorize("hasAuthority('" + DO_MANUAL_REDACTION + "')") public List removeRedactionBulk(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId, @@ -971,17 +390,6 @@ public class ManualRedactionController implements ManualRedactionResource { } - @Deprecated - @Override - @PreAuthorize("hasAuthority('" + DO_MANUAL_REDACTION + "')") - public ManualAddResponse forceRedaction(@PathVariable(DOSSIER_ID) String dossierId, - @PathVariable(FILE_ID) String fileId, - @RequestBody ForceRedactionRequest forceRedactionRequest) { - - return forceRedactionBulk(dossierId, fileId, Set.of(forceRedactionRequest)).get(0); - } - - @PreAuthorize("hasAuthority('" + DO_MANUAL_REDACTION + "')") public List forceRedactionBulk(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId, @@ -1013,16 +421,6 @@ public class ManualRedactionController implements ManualRedactionResource { } - @Deprecated - @PreAuthorize("hasAuthority('" + DO_MANUAL_REDACTION + "')") - public ManualAddResponse legalBasisChange(@PathVariable(DOSSIER_ID) String dossierId, - @PathVariable(FILE_ID) String fileId, - @RequestBody LegalBasisChangeRequest legalBasisChangeRequest) { - - return legalBasisChangeBulk(dossierId, fileId, Set.of(legalBasisChangeRequest)).get(0); - } - - @PreAuthorize("hasAuthority('" + DO_MANUAL_REDACTION + "')") public List legalBasisChangeBulk(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId, @@ -1057,16 +455,6 @@ public class ManualRedactionController implements ManualRedactionResource { } - @Deprecated - @PreAuthorize("hasAuthority('" + DO_MANUAL_REDACTION + "')") - public ManualAddResponse recategorizeImage(@PathVariable(DOSSIER_ID) String dossierId, - @PathVariable(FILE_ID) String fileId, - @RequestBody ImageRecategorizationRequest imageRecategorizationRequest) { - - return recategorizeImageBulk(dossierId, fileId, Set.of(imageRecategorizationRequest)).get(0); - } - - @PreAuthorize("hasAuthority('" + DO_MANUAL_REDACTION + "')") public List recategorizeImageBulk(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId, @@ -1100,17 +488,6 @@ public class ManualRedactionController implements ManualRedactionResource { } - @Deprecated - @Override - @PreAuthorize("hasAuthority('" + DO_MANUAL_REDACTION + "')") - public ManualAddResponse resizeRedaction(@PathVariable(DOSSIER_ID) String dossierId, - @PathVariable(FILE_ID) String fileId, - @RequestBody ResizeRedactionRequest resizeRedactionRequest) { - - return resizeRedactionBulk(dossierId, fileId, Set.of(resizeRedactionRequest)).get(0); - } - - @PreAuthorize("hasAuthority('" + DO_MANUAL_REDACTION + "')") public List resizeRedactionBulk(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId, diff --git a/persistence-service-v1/persistence-service-external-api-v1/src/main/java/com/iqser/red/service/persistence/service/v1/api/external/resource/ManualRedactionResource.java b/persistence-service-v1/persistence-service-external-api-v1/src/main/java/com/iqser/red/service/persistence/service/v1/api/external/resource/ManualRedactionResource.java index 3dbc3d7eb..5e8c09361 100644 --- a/persistence-service-v1/persistence-service-external-api-v1/src/main/java/com/iqser/red/service/persistence/service/v1/api/external/resource/ManualRedactionResource.java +++ b/persistence-service-v1/persistence-service-external-api-v1/src/main/java/com/iqser/red/service/persistence/service/v1/api/external/resource/ManualRedactionResource.java @@ -17,7 +17,6 @@ import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.ManualRedactions; import com.iqser.red.service.persistence.service.v1.api.shared.model.manual.AddCommentRequest; import com.iqser.red.service.persistence.service.v1.api.shared.model.manual.AddRedactionRequest; -import com.iqser.red.service.persistence.service.v1.api.shared.model.manual.ApproveRequest; import com.iqser.red.service.persistence.service.v1.api.shared.model.manual.ForceRedactionRequest; import com.iqser.red.service.persistence.service.v1.api.shared.model.manual.ImageRecategorizationRequest; import com.iqser.red.service.persistence.service.v1.api.shared.model.manual.LegalBasisChangeRequest; @@ -45,129 +44,6 @@ public interface ManualRedactionResource { String COMMENT_ID_PATH_VARIABLE = "/{" + COMMENT_ID + "}"; - /* Reviewer Operations*/ - - - @Deprecated - @ResponseStatus(value = HttpStatus.OK) - @PostMapping(value = MANUAL_REDACTION_REST_PATH + "/request/add" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) - @Operation(summary = "Adds a request for a redaction.", description = "None") - @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")}) - ManualAddResponse requestAddRedaction(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId, @RequestBody AddRedactionRequest addRedactionRequest); - - - @ResponseStatus(value = HttpStatus.OK) - @PostMapping(value = MANUAL_REDACTION_REST_PATH + "/bulk/request/add" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) - @Operation(summary = "Adds a request for a redaction.", description = "None") - @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")}) - List requestBulkAddRedaction(@PathVariable(DOSSIER_ID) String dossierId, - @PathVariable(FILE_ID) String fileId, - @RequestBody Set addRedactionRequest); - - - @Deprecated - @ResponseStatus(value = HttpStatus.OK) - @PostMapping(value = MANUAL_REDACTION_REST_PATH + "/request/remove" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) - @Operation(summary = "Adds a request to remove a redaction.", description = "None") - @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")}) - ManualAddResponse requestRemoveRedaction(@PathVariable(DOSSIER_ID) String dossierId, - @PathVariable(FILE_ID) String fileId, - @RequestBody RemoveRedactionRequest removeRedactionRequest); - - - @ResponseStatus(value = HttpStatus.OK) - @PostMapping(value = MANUAL_REDACTION_REST_PATH + "/bulk/request/remove" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) - @Operation(summary = "Adds a bulk of requests to remove a redaction.", description = "None") - @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")}) - List requestBulkRemoveRedaction(@PathVariable(DOSSIER_ID) String dossierId, - @PathVariable(FILE_ID) String fileId, - @RequestBody Set removeRedactionRequests); - - - @Deprecated - @ResponseStatus(value = HttpStatus.OK) - @PostMapping(value = MANUAL_REDACTION_REST_PATH + "/request/force" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) - @Operation(summary = "Adds a request to force a redaction.", description = "None") - @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")}) - ManualAddResponse requestForceRedaction(@PathVariable(DOSSIER_ID) String dossierId, - @PathVariable(FILE_ID) String fileId, - @RequestBody ForceRedactionRequest forceRedactionRequest); - - - @ResponseStatus(value = HttpStatus.OK) - @PostMapping(value = MANUAL_REDACTION_REST_PATH + "/bulk/request/force" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) - @Operation(summary = "Adds a bulk of requests to force a redaction.", description = "None") - @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")}) - List requestBulkForceRedaction(@PathVariable(DOSSIER_ID) String dossierId, - @PathVariable(FILE_ID) String fileId, - @RequestBody Set forceRedactionRequests); - - - @Deprecated - @ResponseStatus(value = HttpStatus.OK) - @PostMapping(value = MANUAL_REDACTION_REST_PATH + "/request/legalBasis" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) - @Operation(summary = "Adds a request to change the legal basis reason.", description = "None") - @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")}) - ManualAddResponse requestLegalBasisChange(@PathVariable(DOSSIER_ID) String dossierId, - @PathVariable(FILE_ID) String fileId, - @RequestBody LegalBasisChangeRequest legalBasisChangeRequest); - - - @ResponseStatus(value = HttpStatus.OK) - @PostMapping(value = MANUAL_REDACTION_REST_PATH + "/bulk/request/legalBasis" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) - @Operation(summary = "Adds a bulk of requests to change the legal basis reason.", description = "None") - @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")}) - List requestBulkLegalBasisChange(@PathVariable(DOSSIER_ID) String dossierId, - @PathVariable(FILE_ID) String fileId, - @RequestBody Set legalBasisChangeRequests); - - - @Deprecated - @ResponseStatus(value = HttpStatus.OK) - @PostMapping(value = MANUAL_REDACTION_REST_PATH + "/request/recategorize" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) - @Operation(summary = "Adds a request to recategorize a image.", description = "None") - @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")}) - ManualAddResponse requestImageRecategorization(@PathVariable(DOSSIER_ID) String dossierId, - @PathVariable(FILE_ID) String fileId, - @RequestBody ImageRecategorizationRequest imageRecategorizationRequest); - - - @ResponseStatus(value = HttpStatus.OK) - @PostMapping(value = MANUAL_REDACTION_REST_PATH + "/bulk/request/recategorize" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) - @Operation(summary = "Adds a bulk of requests to recategorize a image.", description = "None") - @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")}) - List requestBulkImageRecategorization(@PathVariable(DOSSIER_ID) String dossierId, - @PathVariable(FILE_ID) String fileId, - @RequestBody Set imageRecategorizationRequests); - - - @Deprecated - @ResponseStatus(value = HttpStatus.OK) - @PostMapping(value = MANUAL_REDACTION_REST_PATH + "/request/resize" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) - @Operation(summary = "Adds a request to resize a redaction.", description = "None") - @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")}) - ManualAddResponse requestResizeRedaction(@PathVariable(DOSSIER_ID) String dossierId, - @PathVariable(FILE_ID) String fileId, - @RequestBody ResizeRedactionRequest resizeRedactionRequest); - - - @ResponseStatus(value = HttpStatus.OK) - @PostMapping(value = MANUAL_REDACTION_REST_PATH + "/bulk/request/resize" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) - @Operation(summary = "Adds a bulk of requests to resize a redaction.", description = "None") - @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")}) - List requestBulkResizeRedaction(@PathVariable(DOSSIER_ID) String dossierId, - @PathVariable(FILE_ID) String fileId, - @RequestBody Set resizeRedactionRequests); - - - @Deprecated - @ResponseStatus(value = HttpStatus.NO_CONTENT) - @DeleteMapping(MANUAL_REDACTION_REST_PATH + "/undo" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE + ANNOTATION_ID_PATH_VARIABLE) - @Operation(summary = "Undo a manual request or redaction", description = "Can only be done be the " + "user who added the request/redaction.") - @ApiResponses(value = {@ApiResponse(responseCode = "204", description = "OK")}) - void undo(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId, @PathVariable(ANNOTATION_ID) String annotationId); - - @ResponseStatus(value = HttpStatus.NO_CONTENT) @DeleteMapping(MANUAL_REDACTION_REST_PATH + "/bulk/undo" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE) @Operation(summary = "Undo a list of manual requests or redactions", description = "Can only be done be the " + "user who added the request/redaction.") @@ -195,50 +71,6 @@ public interface ManualRedactionResource { @PathVariable(COMMENT_ID) String commentId); - /* Approver Operations*/ - - - @Deprecated - @ResponseStatus(value = HttpStatus.NO_CONTENT) - @PostMapping(value = MANUAL_REDACTION_REST_PATH + "/approve" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE + ANNOTATION_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE) - @Operation(summary = "Approves a redaction request/ remove redaction request", description = "None") - @ApiResponses(value = {@ApiResponse(responseCode = "204", description = "OK")}) - void approveRequest(@PathVariable(DOSSIER_ID) String dossierId, - @PathVariable(FILE_ID) String fileId, - @PathVariable(ANNOTATION_ID) String annotationId, - @RequestBody ApproveRequest approveRequest); - - - @ResponseStatus(value = HttpStatus.NO_CONTENT) - @PostMapping(value = MANUAL_REDACTION_REST_PATH + "/bulk/approve" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE) - @Operation(summary = "Approves a list of redaction requests/ remove redaction requests", description = "None") - @ApiResponses(value = {@ApiResponse(responseCode = "204", description = "OK")}) - void approveRequestBulk(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId, @RequestBody Set annotationIds); - - - @Deprecated - @ResponseStatus(value = HttpStatus.NO_CONTENT) - @PostMapping(value = MANUAL_REDACTION_REST_PATH + "/decline" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE + ANNOTATION_ID_PATH_VARIABLE) - @Operation(summary = "Declines a redaction request/ remove redaction request", description = "None") - @ApiResponses(value = {@ApiResponse(responseCode = "204", description = "OK")}) - void declineRequest(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId, @PathVariable(ANNOTATION_ID) String annotationId); - - - @ResponseStatus(value = HttpStatus.NO_CONTENT) - @PostMapping(value = MANUAL_REDACTION_REST_PATH + "/bulk/decline" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE) - @Operation(summary = "Declines a redaction request/ remove redaction request list", description = "None") - @ApiResponses(value = {@ApiResponse(responseCode = "204", description = "OK")}) - void declineRequestBulk(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId, @RequestBody Set annotationIds); - - - @Deprecated - @ResponseStatus(value = HttpStatus.OK) - @PostMapping(value = MANUAL_REDACTION_REST_PATH + "/redaction/add" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) - @Operation(summary = "Adds a manual redaction", description = "None") - @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")}) - ManualAddResponse addRedaction(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId, @RequestBody AddRedactionRequest addRedactionRequest); - - @ResponseStatus(value = HttpStatus.OK) @PostMapping(value = MANUAL_REDACTION_REST_PATH + "/bulk/redaction/add" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) @Operation(summary = "Adds a manual redaction", description = "None") @@ -248,14 +80,6 @@ public interface ManualRedactionResource { @RequestBody Set addRedactionRequest); - @Deprecated - @ResponseStatus(value = HttpStatus.OK) - @PostMapping(value = MANUAL_REDACTION_REST_PATH + "/redaction/remove" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) - @Operation(summary = "Removes a redaction", description = "None") - @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")}) - ManualAddResponse removeRedaction(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId, @RequestBody RemoveRedactionRequest removeRedactionRequest); - - @ResponseStatus(value = HttpStatus.OK) @PostMapping(value = MANUAL_REDACTION_REST_PATH + "/bulk/redaction/remove" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) @Operation(summary = "Removes the redactions list", description = "None") @@ -265,14 +89,6 @@ public interface ManualRedactionResource { @RequestBody Set removeRedactionRequests); - @Deprecated - @ResponseStatus(value = HttpStatus.OK) - @PostMapping(value = MANUAL_REDACTION_REST_PATH + "/redaction/force" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) - @Operation(summary = "Forces a redaction", description = "None") - @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")}) - ManualAddResponse forceRedaction(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId, @RequestBody ForceRedactionRequest forceRedactionRequest); - - @ResponseStatus(value = HttpStatus.OK) @PostMapping(value = MANUAL_REDACTION_REST_PATH + "/bulk/redaction/force" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) @Operation(summary = "Forces the redactions list", description = "None") @@ -282,16 +98,6 @@ public interface ManualRedactionResource { @RequestBody Set forceRedactionRequests); - @Deprecated - @ResponseStatus(value = HttpStatus.OK) - @PostMapping(value = MANUAL_REDACTION_REST_PATH + "/redaction/legalBasisChange" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) - @Operation(summary = "Changes a legal basis reason", description = "None") - @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")}) - ManualAddResponse legalBasisChange(@PathVariable(DOSSIER_ID) String dossierId, - @PathVariable(FILE_ID) String fileId, - @RequestBody LegalBasisChangeRequest legalBasisChangeRequest); - - @ResponseStatus(value = HttpStatus.OK) @PostMapping(value = MANUAL_REDACTION_REST_PATH + "/bulk/redaction/legalBasisChange" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) @Operation(summary = "Changes the legal basis reasons list", description = "None") @@ -301,16 +107,6 @@ public interface ManualRedactionResource { @RequestBody Set legalBasisChangeRequests); - @Deprecated - @ResponseStatus(value = HttpStatus.OK) - @PostMapping(value = MANUAL_REDACTION_REST_PATH + "/redaction/recategorize" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) - @Operation(summary = "Recategorizes an image", description = "None") - @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")}) - ManualAddResponse recategorizeImage(@PathVariable(DOSSIER_ID) String dossierId, - @PathVariable(FILE_ID) String fileId, - @RequestBody ImageRecategorizationRequest imageRecategorizationRequest); - - @ResponseStatus(value = HttpStatus.OK) @PostMapping(value = MANUAL_REDACTION_REST_PATH + "/bulk/redaction/recategorize" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) @Operation(summary = "Recategorizes the images list", description = "None") @@ -320,14 +116,6 @@ public interface ManualRedactionResource { @RequestBody Set imageRecategorizationRequests); - @Deprecated - @ResponseStatus(value = HttpStatus.OK) - @PostMapping(value = MANUAL_REDACTION_REST_PATH + "/redaction/resize" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) - @Operation(summary = "Resizes a redaction", description = "None") - @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")}) - ManualAddResponse resizeRedaction(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId, @RequestBody ResizeRedactionRequest resizeRedactionRequest); - - @ResponseStatus(value = HttpStatus.OK) @PostMapping(value = MANUAL_REDACTION_REST_PATH + "/bulk/redaction/resize" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) @Operation(summary = "Resizes the redactions list", description = "None") @@ -337,8 +125,6 @@ public interface ManualRedactionResource { @RequestBody Set resizeRedactionRequests); - /* Other operations */ - @ResponseStatus(value = HttpStatus.OK) @GetMapping(value = MANUAL_REDACTION_REST_PATH + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE, produces = MediaType.APPLICATION_JSON_VALUE) diff --git a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/ManualRedactionService.java b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/ManualRedactionService.java index 233326ef3..fba7d52d2 100644 --- a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/ManualRedactionService.java +++ b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/ManualRedactionService.java @@ -40,7 +40,6 @@ import com.iqser.red.service.persistence.management.v1.processor.service.persist import com.iqser.red.service.persistence.management.v1.processor.service.persistence.annotations.LegalBasisChangePersistenceService; import com.iqser.red.service.persistence.management.v1.processor.service.persistence.annotations.RemoveRedactionPersistenceService; import com.iqser.red.service.persistence.management.v1.processor.service.persistence.annotations.ResizeRedactionPersistenceService; -import com.knecon.fforesight.databasetenantcommons.providers.utils.MagicConverter; import com.iqser.red.service.persistence.service.v1.api.shared.model.AnalyzeRequest; import com.iqser.red.service.persistence.service.v1.api.shared.model.MessageType; import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.AddRedactionRequest; @@ -59,6 +58,7 @@ import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemp 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.redactionlog.RedactionLog; import com.iqser.red.service.persistence.service.v1.api.shared.model.redactionlog.RedactionLogEntry; +import com.knecon.fforesight.databasetenantcommons.providers.utils.MagicConverter; import feign.FeignException; import lombok.RequiredArgsConstructor; @@ -431,16 +431,6 @@ public class ManualRedactionService { } - private String buildTypeId(RedactionLogEntry redactionLogEntry, DossierEntity dossier) { - - if (redactionLogEntry.isDossierDictionaryEntry()) { - return toTypeId(redactionLogEntry.getType(), dossier.getDossierTemplateId(), dossier.getId()); - } else { - return toTypeId(redactionLogEntry.getType(), dossier.getDossierTemplateId()); - } - } - - private void removeResizeRedactionsWithAddToDictionary(String dossierTemplateId, String redactionLogEntryValue) { var resizeRedactionsWithSameValue = resizeRedactionPersistenceService.findByAnnotationStatusAndValue(AnnotationStatus.APPROVED, redactionLogEntryValue); @@ -729,7 +719,7 @@ public class ManualRedactionService { .equals(AnnotationStatus.APPROVED) && (redactionLogEntry.isDictionaryEntry() || redactionLogEntry.isDossierDictionaryEntry())) { var dossier = dossierPersistenceService.findByDossierId(dossierId); - var typeId = computeTypeIdForResizeRedaction(redactionLogEntry, resizeRedaction, dossier); + var typeId = buildTypeId(redactionLogEntry, resizeRedaction, dossier); var newValue = resizeRedaction.getValue(); var oldValue = redactionLogEntry.getValue(); var dictionaryEntryType = getDictionaryEntryType(redactionLogEntry); @@ -740,7 +730,7 @@ public class ManualRedactionService { log.info("Remove old value '{}' from dictionary", oldValue); removeFromDictionary(typeId, oldValue, dossierId, fileId, dictionaryEntryType); - if (resizeRedaction.isAddToAllDossiers() && redactionLogEntry.isDossierDictionaryEntry()) { + if (resizeRedaction.isAddToAllDossiers() && redactionLogEntry.isDictionaryEntry()) { String dossierTemplateId = dossier.getDossierTemplateId(); var dossiersOfThisDossierTemplate = dossierPersistenceService.findAllDossiersForDossierTemplateId(dossierTemplateId); var type = redactionLogEntry.getType(); @@ -758,15 +748,11 @@ public class ManualRedactionService { } - private String computeTypeIdForResizeRedaction(RedactionLogEntry redactionLogEntry, ManualResizeRedactionEntity resizeRedaction, DossierEntity dossier) { + private String buildTypeId(RedactionLogEntry redactionLogEntry, ManualResizeRedactionEntity resizeRedaction, DossierEntity dossier) { if (resizeRedaction.isAddToAllDossiers()) { - if (redactionLogEntry.isDossierDictionaryEntry()) { - return toTypeId(redactionLogEntry.getType(), dossier.getDossierTemplateId()); - } else { - return toTypeId(redactionLogEntry.getType(), dossier.getDossierTemplateId(), dossier.getId()); - } + return toTypeId(redactionLogEntry.getType(), dossier.getDossierTemplateId()); } else { - return buildTypeId(redactionLogEntry, dossier); + return toTypeId(redactionLogEntry.getType(), dossier.getDossierTemplateId(), dossier.getId()); } } @@ -784,43 +770,6 @@ public class ManualRedactionService { } - @Transactional - @SuppressWarnings("PMD") - public void updateRemoveRedactionStatus(String dossierId, String fileId, List annotationIds, AnnotationStatus annotationStatus) { - - var dossier = dossierPersistenceService.getAndValidateDossier(dossierId); - RedactionLog redactionLog = redactionLogService.getRedactionLog(dossierId, fileId, true, true); - - for (var annotationId : annotationIds) { - var idRemoval = MagicConverter.convert(removeRedactionPersistenceService.findRemoveRedaction(fileId, annotationId), IdRemoval.class); - - RedactionLogEntry redactionLogEntry = getRedactionLogEntry(redactionLog, idRemoval.getAnnotationId()); - - if (idRemoval.isRemoveFromDictionary()) { - - if (annotationStatus == AnnotationStatus.APPROVED) { - removeFromDictionary(buildTypeId(redactionLogEntry, dossier), redactionLogEntry.getValue(), dossierId, fileId, DictionaryEntryType.ENTRY); - approveStatusForRedactionsWithSameValue(dossier, false, true, redactionLogEntry.getValue()); - reprocess(dossierId, fileId); - - } else if (annotationStatus == AnnotationStatus.DECLINED) { - - // if it was previously approved, revert the delete - if (idRemoval.getStatus() == AnnotationStatus.APPROVED) { - addToDictionary(buildTypeId(redactionLogEntry, dossier), redactionLogEntry.getValue(), dossierId, fileId, DictionaryEntryType.ENTRY); - - } - } - } else if (redactionLogEntry.isHint()) { - reprocess(dossierId, fileId); - } - - removeRedactionPersistenceService.updateStatus(fileId, annotationId, annotationStatus); - - } - analysisFlagsCalculationService.calculateFlags(dossierId, fileId); - } - private void approveStatusForRedactionsWithSameValue(DossierEntity dossier, boolean addToDictionary, boolean addToDossierDictionary, String value) { diff --git a/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/tests/FileTest.java b/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/tests/FileTest.java index fabc205e9..1052c9f6d 100644 --- a/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/tests/FileTest.java +++ b/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/tests/FileTest.java @@ -50,7 +50,6 @@ import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemp import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.file.FileType; import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.file.ProcessingStatus; import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.file.WorkflowStatus; -import com.iqser.red.service.persistence.service.v1.api.shared.model.manual.AddCommentRequest; import com.iqser.red.service.persistence.service.v1.api.shared.model.manual.AddRedactionRequest; import com.iqser.red.service.persistence.service.v1.api.shared.model.manual.ForceRedactionRequest; import com.iqser.red.service.persistence.service.v1.api.shared.model.manual.ImageRecategorizationRequest; @@ -401,48 +400,48 @@ public class FileTest extends AbstractPersistenceServerServiceTest { } - @Test - public void testToggleEnableRedactionTwice() { - - var dossierTemplate = dossierTemplateTesterAndProvider.provideTestTemplate(); - - var dossier = dossierTesterAndProvider.provideTestDossier(dossierTemplate); - String dossierId = dossier.getId(); - - var file = fileTesterAndProvider.testAndProvideFile(dossier); - String fileId = file.getId(); - - var type = typeProvider.testAndProvideType(dossierTemplate, null, "manual"); - - assertThat(fileClient.getDossierStatus(dossier.getId()).size()).isEqualTo(1); - - var userId = userProvider.getUserId(); - - fileClient.setStatusUnderReview(dossier.getId(), file.getId(), userId); - - var addRedaction = manualRedactionClient.requestBulkAddRedaction(dossierId, - fileId, - Set.of(AddRedactionRequest.builder() - .addToDictionary(true) - .addToDossierDictionary(false) - .comment(new AddCommentRequest("comment")) - .type(type.getType()) - .reason("1") - .value("test") - .legalBasis("1") - .build())).iterator().next(); - - var loadedFile = fileClient.getFileStatus(dossier.getId(), file.getId()); - - - reanalysisClient.toggleExclusion(dossier.getId(), file.getId(), true); - loadedFile = fileClient.getFileStatus(dossier.getId(), file.getId()); - assertThat(loadedFile.isExcluded()).isTrue(); - - reanalysisClient.toggleExclusion(dossier.getId(), file.getId(), false); - loadedFile = fileClient.getFileStatus(dossier.getId(), file.getId()); - assertThat(loadedFile.isExcluded()).isFalse(); - } +// @Test +// public void testToggleEnableRedactionTwice() { +// +// var dossierTemplate = dossierTemplateTesterAndProvider.provideTestTemplate(); +// +// var dossier = dossierTesterAndProvider.provideTestDossier(dossierTemplate); +// String dossierId = dossier.getId(); +// +// var file = fileTesterAndProvider.testAndProvideFile(dossier); +// String fileId = file.getId(); +// +// var type = typeProvider.testAndProvideType(dossierTemplate, null, "manual"); +// +// assertThat(fileClient.getDossierStatus(dossier.getId()).size()).isEqualTo(1); +// +// var userId = userProvider.getUserId(); +// +// fileClient.setStatusUnderReview(dossier.getId(), file.getId(), userId); +// +// var addRedaction = manualRedactionClient.requestBulkAddRedaction(dossierId, +// fileId, +// Set.of(AddRedactionRequest.builder() +// .addToDictionary(true) +// .addToDossierDictionary(false) +// .comment(new AddCommentRequest("comment")) +// .type(type.getType()) +// .reason("1") +// .value("test") +// .legalBasis("1") +// .build())).iterator().next(); +// +// var loadedFile = fileClient.getFileStatus(dossier.getId(), file.getId()); +// +// +// reanalysisClient.toggleExclusion(dossier.getId(), file.getId(), true); +// loadedFile = fileClient.getFileStatus(dossier.getId(), file.getId()); +// assertThat(loadedFile.isExcluded()).isTrue(); +// +// reanalysisClient.toggleExclusion(dossier.getId(), file.getId(), false); +// loadedFile = fileClient.getFileStatus(dossier.getId(), file.getId()); +// assertThat(loadedFile.isExcluded()).isFalse(); +// } @Test diff --git a/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/tests/ManualRedactionTest.java b/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/tests/ManualRedactionTest.java index 463d56c06..ef0ecd05f 100644 --- a/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/tests/ManualRedactionTest.java +++ b/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/tests/ManualRedactionTest.java @@ -4,17 +4,14 @@ import static com.iqser.red.service.persistence.management.v1.processor.utils.Ty import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.when; -import java.time.OffsetDateTime; import java.util.ArrayList; import java.util.List; import java.util.Set; -import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.event.annotation.AfterTestExecution; import com.fasterxml.jackson.databind.ObjectMapper; import com.iqser.red.service.peristence.v1.server.integration.client.DictionaryClient; @@ -27,38 +24,22 @@ import com.iqser.red.service.peristence.v1.server.integration.service.FileTester import com.iqser.red.service.peristence.v1.server.integration.service.TypeProvider; import com.iqser.red.service.peristence.v1.server.integration.service.UserProvider; import com.iqser.red.service.peristence.v1.server.integration.utils.AbstractPersistenceServerServiceTest; -import com.iqser.red.service.peristence.v1.server.integration.utils.MetricValidationUtils; import com.iqser.red.service.persistence.management.v1.processor.service.DictionaryManagementService; import com.iqser.red.service.persistence.management.v1.processor.service.FileManagementStorageService; import com.iqser.red.service.persistence.management.v1.processor.service.RedactionLogService; import com.iqser.red.service.persistence.management.v1.processor.service.persistence.EntryPersistenceService; import com.iqser.red.service.persistence.management.v1.processor.service.persistence.FileStatusPersistenceService; import com.iqser.red.service.persistence.management.v1.processor.service.redactionlog.RedactionRequest; -import com.knecon.fforesight.databasetenantcommons.providers.utils.MagicConverter; -import com.iqser.red.service.persistence.service.v1.api.shared.model.CreateTypeValue; -import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.AnnotationStatus; -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; -import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.entitymapped.BaseAnnotation; import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.file.FileType; -import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.file.ProcessingStatus; -import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.file.WorkflowStatus; 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.AddCommentRequest; import com.iqser.red.service.persistence.service.v1.api.shared.model.manual.AddRedactionRequest; -import com.iqser.red.service.persistence.service.v1.api.shared.model.manual.ForceRedactionRequest; -import com.iqser.red.service.persistence.service.v1.api.shared.model.manual.ImageRecategorizationRequest; -import com.iqser.red.service.persistence.service.v1.api.shared.model.manual.LegalBasisChangeRequest; import com.iqser.red.service.persistence.service.v1.api.shared.model.manual.RemoveRedactionRequest; import com.iqser.red.service.persistence.service.v1.api.shared.model.manual.ResizeRedactionRequest; -import com.iqser.red.service.persistence.service.v1.api.shared.model.redactionlog.ManualChange; -import com.iqser.red.service.persistence.service.v1.api.shared.model.redactionlog.ManualRedactionType; import com.iqser.red.service.persistence.service.v1.api.shared.model.redactionlog.RedactionLog; import com.iqser.red.service.persistence.service.v1.api.shared.model.redactionlog.RedactionLogEntry; -import com.knecon.fforesight.tenantcommons.TenantContext; import feign.FeignException; -import lombok.SneakyThrows; public class ManualRedactionTest extends AbstractPersistenceServerServiceTest { @@ -381,460 +362,460 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest { assertThat(dossierTemplateDictionary.getEntries().size()).isEqualTo(0); } - - @Test - @SneakyThrows - public void testManualRedaction3641() { - - var dossierTemplate = dossierTemplateTesterAndProvider.provideTestTemplate(); - - var dossier = dossierTesterAndProvider.provideTestDossier(dossierTemplate); - - var file = fileTesterAndProvider.testAndProvideFile(dossier); - - var type = typeProvider.testAndProvideType(dossierTemplate, null, "manual"); - - var userId = userProvider.getUserId(); - - fileClient.setStatusUnderReview(dossier.getId(), file.getId(), userId); - - var addRedaction = manualRedactionClient.requestBulkAddRedaction(dossier.getId(), - file.getId(), - Set.of(AddRedactionRequest.builder() - .positions(List.of(Rectangle.builder().topLeftY(1).topLeftX(1).height(1).width(1).build())) - .section("section test") - .addToDictionary(false) - .addToDossierDictionary(false) - .type(type.getType()) - .reason("1") - .value("test") - .legalBasis("1") - .rectangle(true) - .sourceId("SourceId") - .build())).iterator().next(); - var loadedAddRedaction = manualRedactionClient.getManualRedactions(file.getDossierId(), file.getFileId()).getEntriesToAdd().iterator().next(); - assertThat(loadedAddRedaction.isRectangle()).isEqualTo(true); - - var change = ManualChange.from(new BaseAnnotation(addRedaction.getAnnotationId(), - file.getFileId(), - userId, - AnnotationStatus.REQUESTED, - OffsetDateTime.now(), - OffsetDateTime.now(), - null)).withManualRedactionType(ManualRedactionType.ADD_LOCALLY); - List changeList = new ArrayList<>(); - changeList.add(change); - - var entry = RedactionLogEntry.builder() - .id(loadedAddRedaction.getAnnotationId()) - .reason(loadedAddRedaction.getReason()) - .isDictionaryEntry(loadedAddRedaction.isAddToDictionary()) - .isDossierDictionaryEntry(loadedAddRedaction.isAddToDossierDictionary()) - .legalBasis(loadedAddRedaction.getLegalBasis()) - .value(loadedAddRedaction.getValue()) - .section(loadedAddRedaction.getSection()) - .type(loadedAddRedaction.getType()) - .redacted(true) - .isHint(false) - .sectionNumber(-1) - .manualChanges(changeList) - .rectangle(loadedAddRedaction.isRectangle()) - .build(); - when(redactionLogMergeService.provideRedactionLog(Mockito.any())).thenReturn(new RedactionLog(1, 1, List.of(entry), null, 0, 0, 0, 0)); - - fileClient.setStatusUnderApproval(dossier.getId(), file.getId(), userId); - var fileStatus = fileClient.getFileStatus(dossier.getId(), file.getId()); - assertThat(fileStatus.isHasSuggestions()).isTrue(); - assertThat(fileStatus.getWorkflowStatus()).isEqualTo(WorkflowStatus.UNDER_APPROVAL); - - changeList.get(0).setAnnotationStatus(AnnotationStatus.DECLINED); - entry.setManualChanges(changeList); - when(redactionLogMergeService.provideRedactionLog(Mockito.any())).thenReturn(new RedactionLog(1, 1, List.of(entry), null, 0, 0, 0, 0)); - - manualRedactionClient.declineRequestBulk(dossier.getId(), file.getId(), Set.of(addRedaction.getAnnotationId())); - loadedAddRedaction = manualRedactionClient.getManualRedactions(file.getDossierId(), file.getFileId()).getEntriesToAdd().iterator().next(); - assertThat(loadedAddRedaction.getStatus()).isEqualTo(AnnotationStatus.DECLINED); - - fileStatus = fileClient.getFileStatus(dossier.getId(), file.getId()); - assertThat(fileStatus.isHasSuggestions()).isFalse(); - - ManualRedactions manualRedactions = manualRedactionClient.getManualRedactions(dossier.getId(), file.getId()); - assertThat(manualRedactions.getEntriesToAdd()).isNotEmpty(); - - } +// @Test +// @SneakyThrows +// public void testManualRedaction3641() { +// +// var dossierTemplate = dossierTemplateTesterAndProvider.provideTestTemplate(); +// +// var dossier = dossierTesterAndProvider.provideTestDossier(dossierTemplate); +// +// var file = fileTesterAndProvider.testAndProvideFile(dossier); +// +// var type = typeProvider.testAndProvideType(dossierTemplate, null, "manual"); +// +// var userId = userProvider.getUserId(); +// +// fileClient.setStatusUnderReview(dossier.getId(), file.getId(), userId); +// +// var addRedaction = manualRedactionClient.requestBulkAddRedaction(dossier.getId(), +// file.getId(), +// Set.of(AddRedactionRequest.builder() +// .positions(List.of(Rectangle.builder().topLeftY(1).topLeftX(1).height(1).width(1).build())) +// .section("section test") +// .addToDictionary(false) +// .addToDossierDictionary(false) +// .type(type.getType()) +// .reason("1") +// .value("test") +// .legalBasis("1") +// .rectangle(true) +// .sourceId("SourceId") +// .build())).iterator().next(); +// var loadedAddRedaction = manualRedactionClient.getManualRedactions(file.getDossierId(), file.getFileId()).getEntriesToAdd().iterator().next(); +// assertThat(loadedAddRedaction.isRectangle()).isEqualTo(true); +// +// var change = ManualChange.from(new BaseAnnotation(addRedaction.getAnnotationId(), +// file.getFileId(), +// userId, +// AnnotationStatus.REQUESTED, +// OffsetDateTime.now(), +// OffsetDateTime.now(), +// null)).withManualRedactionType(ManualRedactionType.ADD_LOCALLY); +// List changeList = new ArrayList<>(); +// changeList.add(change); +// +// var entry = RedactionLogEntry.builder() +// .id(loadedAddRedaction.getAnnotationId()) +// .reason(loadedAddRedaction.getReason()) +// .isDictionaryEntry(loadedAddRedaction.isAddToDictionary()) +// .isDossierDictionaryEntry(loadedAddRedaction.isAddToDossierDictionary()) +// .legalBasis(loadedAddRedaction.getLegalBasis()) +// .value(loadedAddRedaction.getValue()) +// .section(loadedAddRedaction.getSection()) +// .type(loadedAddRedaction.getType()) +// .redacted(true) +// .isHint(false) +// .sectionNumber(-1) +// .manualChanges(changeList) +// .rectangle(loadedAddRedaction.isRectangle()) +// .build(); +// when(redactionLogMergeService.provideRedactionLog(Mockito.any())).thenReturn(new RedactionLog(1, 1, List.of(entry), null, 0, 0, 0, 0)); +// +// fileClient.setStatusUnderApproval(dossier.getId(), file.getId(), userId); +// var fileStatus = fileClient.getFileStatus(dossier.getId(), file.getId()); +// assertThat(fileStatus.isHasSuggestions()).isTrue(); +// assertThat(fileStatus.getWorkflowStatus()).isEqualTo(WorkflowStatus.UNDER_APPROVAL); +// +// changeList.get(0).setAnnotationStatus(AnnotationStatus.DECLINED); +// entry.setManualChanges(changeList); +// when(redactionLogMergeService.provideRedactionLog(Mockito.any())).thenReturn(new RedactionLog(1, 1, List.of(entry), null, 0, 0, 0, 0)); +// +// manualRedactionClient.declineRequestBulk(dossier.getId(), file.getId(), Set.of(addRedaction.getAnnotationId())); +// loadedAddRedaction = manualRedactionClient.getManualRedactions(file.getDossierId(), file.getFileId()).getEntriesToAdd().iterator().next(); +// assertThat(loadedAddRedaction.getStatus()).isEqualTo(AnnotationStatus.DECLINED); +// +// fileStatus = fileClient.getFileStatus(dossier.getId(), file.getId()); +// assertThat(fileStatus.isHasSuggestions()).isFalse(); +// +// ManualRedactions manualRedactions = manualRedactionClient.getManualRedactions(dossier.getId(), file.getId()); +// assertThat(manualRedactions.getEntriesToAdd()).isNotEmpty(); +// +// } +// +// +// @Test +// @SneakyThrows +// public void testAddToDictionaryRequiresReanalysis() { +// +// TenantContext.setTenantId("redaction"); +// +// var dossierTemplate = dossierTemplateTesterAndProvider.provideTestTemplate(); +// +// var dossier = dossierTesterAndProvider.provideTestDossier(dossierTemplate); +// +// var file = fileTesterAndProvider.testAndProvideFile(dossier); +// +// var type = typeProvider.testAndProvideType(dossierTemplate, null, "PII"); +// +// // assume file is already proccessed once, test that add to dict triggers reanalysis +// fileManagementStorageService.storeJSONObject(dossier.getId(), file.getId(), FileType.DOCUMENT_TEXT, "{}"); +// fileManagementStorageService.storeJSONObject(dossier.getId(), file.getId(), FileType.DOCUMENT_PAGES, "{}"); +// fileManagementStorageService.storeJSONObject(dossier.getId(), file.getId(), FileType.DOCUMENT_STRUCTURE, "{}"); +// fileManagementStorageService.storeJSONObject(dossier.getId(), file.getId(), FileType.DOCUMENT_POSITION, "{}"); +// fileManagementStorageService.storeJSONObject(dossier.getId(), file.getId(), FileType.NER_ENTITIES, "{}"); +// fileManagementStorageService.storeJSONObject(dossier.getId(), file.getId(), FileType.IMAGE_INFO, "{}"); +// fileStatusPersistenceService.updateProcessingStatus(file.getId(), ProcessingStatus.PROCESSED); +// +// var userId = userProvider.getUserId(); +// fileClient.setStatusUnderReview(dossier.getId(), file.getId(), userId); +// +// var addRedaction = manualRedactionClient.requestBulkAddRedaction(dossier.getId(), +// file.getId(), +// Set.of(AddRedactionRequest.builder() +// .positions(List.of(Rectangle.builder().topLeftY(1).topLeftX(1).height(1).width(1).build())) +// .section("section test") +// .addToDictionary(true) +// .addToDossierDictionary(false) +// .type(type.getType()) +// .reason("1") +// .value("test") +// .legalBasis("1") +// .rectangle(true) +// .sourceId("SourceId") +// .build())).iterator().next(); +// +// var loadedFile = fileClient.getFileStatus(dossier.getId(), file.getId()); +// assertThat(loadedFile.getProcessingStatus()).isEqualTo(ProcessingStatus.PROCESSED); +// +// } +// +// +// @Test +// @SneakyThrows +// public void testManualRedaction() { +// +// var dossierTemplate = dossierTemplateTesterAndProvider.provideTestTemplate(); +// +// var dossier = dossierTesterAndProvider.provideTestDossier(dossierTemplate); +// +// var file = fileTesterAndProvider.testAndProvideFile(dossier); +// +// var type = typeProvider.testAndProvideType(dossierTemplate, null, "manual"); +// +// var userId = userProvider.getUserId(); +// +// try { +// manualRedactionClient.addRedactionBulk(dossier.getId(), +// file.getId(), +// Set.of(AddRedactionRequest.builder() +// .positions(List.of(Rectangle.builder().page(100).topLeftY(1).topLeftX(1).height(1).width(1).build())) +// .section("section test") +// .addToDictionary(true) +// .addToAllDossiers(true) +// .type(type.getType()) +// .reason("1") +// .value("test") +// .legalBasis("1") +// .rectangle(true) +// .sourceId("SourceId") +// .build())); +// } catch (FeignException e) { +// assertThat(e.status()).isEqualTo(400); +// } +// +// var addRedaction = manualRedactionClient.addRedactionBulk(dossier.getId(), +// file.getId(), +// Set.of(AddRedactionRequest.builder() +// .positions(List.of(Rectangle.builder().topLeftY(1).topLeftX(1).height(1).width(1).build())) +// .section("section test") +// .addToDictionary(true) +// .addToAllDossiers(true) +// .type(type.getType()) +// .reason("1") +// .value("test") +// .legalBasis("1") +// .rectangle(true) +// .sourceId("SourceId") +// .build())).iterator().next(); +// +// var loadedAddRedaction = manualRedactionClient.getManualRedactions(file.getDossierId(), file.getFileId()).getEntriesToAdd().iterator().next(); +// assertThat(loadedAddRedaction.getUser()).isEqualTo(userId); +// assertThat(loadedAddRedaction.getType()).contains("manual"); +// assertThat(loadedAddRedaction.getSection()).contains("section test"); +// assertThat(loadedAddRedaction.isRectangle()).isEqualTo(true); +// assertThat(loadedAddRedaction.getSourceId()).isEqualTo("SourceId"); +// +// fileClient.setStatusUnderReview(dossier.getId(), file.getId(), userId); +// +// manualRedactionClient.approveRequestBulk(dossier.getId(), file.getId(), Set.of(addRedaction.getAnnotationId())); +// loadedAddRedaction = manualRedactionClient.getManualRedactions(file.getDossierId(), file.getFileId()) +// .getEntriesToAdd() +// .stream() +// .filter(a -> a.getAnnotationId().equalsIgnoreCase(addRedaction.getAnnotationId())) +// .findAny() +// .get(); +// assertThat(loadedAddRedaction.getStatus()).isEqualTo(AnnotationStatus.APPROVED); +// +// manualRedactionClient.declineRequestBulk(dossier.getId(), file.getId(), Set.of(addRedaction.getAnnotationId())); +// loadedAddRedaction = manualRedactionClient.getManualRedactions(file.getDossierId(), file.getFileId()) +// .getEntriesToAdd() +// .stream() +// .filter(a -> a.getAnnotationId().equalsIgnoreCase(addRedaction.getAnnotationId())) +// .findAny() +// .get(); +// assertThat(loadedAddRedaction.getStatus()).isEqualTo(AnnotationStatus.DECLINED); +// fileClient.setStatusUnderReview(dossier.getId(), file.getId(), userId); +// +// var addRedaction2 = manualRedactionClient.requestBulkAddRedaction(dossier.getId(), +// file.getId(), +// Set.of(AddRedactionRequest.builder() +// .addToDictionary(true) +// .addToDossierDictionary(true) +// .type(type.getType()) +// .reason("1") +// .value("test") +// .legalBasis("1") +// .comment(new AddCommentRequest("comment")) +// .section("section2") +// .build())).iterator().next(); +// +// manualRedactionClient.declineRequestBulk(dossier.getId(), file.getId(), Set.of(addRedaction2.getAnnotationId())); +// var loadedAddRedaction2 = manualRedactionClient.getManualRedactions(file.getDossierId(), file.getFileId()) +// .getEntriesToAdd() +// .stream() +// .filter(a -> a.getAnnotationId().equalsIgnoreCase(addRedaction2.getAnnotationId())) +// .findAny() +// .get(); +// assertThat(loadedAddRedaction2.getStatus()).isEqualTo(AnnotationStatus.DECLINED); +// assertThat(loadedAddRedaction2.isAddToDossierDictionary()).isEqualTo(false); +// assertThat(loadedAddRedaction2.isAddToDictionary()).isEqualTo(true); +// assertThat(loadedAddRedaction2.getSection()).contains("section2"); +// +// var removeRedaction = manualRedactionClient.requestBulkRemoveRedaction(dossier.getId(), +// file.getId(), +// Set.of(RemoveRedactionRequest.builder().annotationId(addRedaction.getAnnotationId()).comment("comment").removeFromDictionary(false).build())).get(0); +// +// var redactionLog = new RedactionLog(1, +// 1, +// List.of(RedactionLogEntry.builder().id(addRedaction.getAnnotationId()).type("manual").value("value entry").build()), +// null, +// 0, +// 0, +// 0, +// 0); +// fileManagementStorageService.storeJSONObject(dossier.getId(), file.getId(), FileType.REDACTION_LOG, redactionLog); +// +// when(redactionLogMergeService.provideRedactionLog(Mockito.any())).thenReturn(redactionLog); +// manualRedactionClient.approveRequestBulk(dossier.getId(), file.getId(), Set.of(removeRedaction.getAnnotationId())); +// +// var loadedRemoveRedaction = manualRedactionClient.getManualRedactions(file.getDossierId(), file.getFileId()) +// .getIdsToRemove() +// .stream() +// .filter(a -> a.getAnnotationId().equalsIgnoreCase(removeRedaction.getAnnotationId())) +// .findAny() +// .get(); +// assertThat(loadedRemoveRedaction.isRemoveFromDictionary()).isEqualTo(false); +// assertThat(loadedRemoveRedaction.getSoftDeletedTime()).isNull(); +// assertThat(loadedRemoveRedaction.getStatus()).isEqualTo(AnnotationStatus.APPROVED); +// +// manualRedactionClient.declineRequestBulk(dossier.getId(), file.getId(), Set.of(removeRedaction.getAnnotationId())); +// loadedRemoveRedaction = manualRedactionClient.getManualRedactions(file.getDossierId(), file.getFileId()) +// .getIdsToRemove() +// .stream() +// .filter(a -> a.getAnnotationId().equalsIgnoreCase(removeRedaction.getAnnotationId())) +// .findAny() +// .get(); +// assertThat(loadedRemoveRedaction.getStatus()).isEqualTo(AnnotationStatus.DECLINED); +// +// var redLog = new RedactionLog(1, 1, List.of(RedactionLogEntry.builder().id("annotationId").type("manual").value("value entry").build()), null, 0, 0, 0, 0); +// fileManagementStorageService.storeJSONObject(dossier.getId(), file.getId(), FileType.REDACTION_LOG, redLog); +// +// when(redactionLogMergeService.provideRedactionLog(Mockito.any())).thenReturn(redLog); +// var removeRedaction2 = manualRedactionClient.requestBulkRemoveRedaction(dossier.getId(), +// file.getId(), +// Set.of(RemoveRedactionRequest.builder().annotationId("annotationId").comment("comment").removeFromDictionary(true).build())).get(0); +// +// manualRedactionClient.approveRequestBulk(dossier.getId(), file.getId(), Set.of(removeRedaction2.getAnnotationId())); +// +// var loadedRemoveRedaction2 = manualRedactionClient.getManualRedactions(file.getDossierId(), file.getFileId()) +// .getIdsToRemove() +// .stream() +// .filter(a -> a.getAnnotationId().equalsIgnoreCase(removeRedaction2.getAnnotationId())) +// .findAny() +// .get(); +// +// assertThat(loadedRemoveRedaction2.getStatus()).isEqualTo(AnnotationStatus.APPROVED); +// assertThat(dictionaryClient.getDictionaryForType(type.getType(), type.getDossierTemplateId(), null).getEntries().isEmpty()); +// assertThat(loadedRemoveRedaction2.isRemoveFromDictionary()).isTrue(); +// +// manualRedactionClient.declineRequestBulk(dossier.getId(), file.getId(), Set.of(removeRedaction2.getAnnotationId())); +// loadedRemoveRedaction2 = manualRedactionClient.getManualRedactions(file.getDossierId(), file.getFileId()) +// .getIdsToRemove() +// .stream() +// .filter(a -> a.getAnnotationId().equalsIgnoreCase(removeRedaction2.getAnnotationId())) +// .findAny() +// .get(); +// assertThat(loadedRemoveRedaction2.getStatus()).isEqualTo(AnnotationStatus.DECLINED); +// +// var forceRedaction = manualRedactionClient.requestBulkForceRedaction(dossier.getId(), +// file.getId(), +// Set.of(ForceRedactionRequest.builder().annotationId(addRedaction.getAnnotationId()).comment("comment").legalBasis("1").build())).get(0); +// +// var loadedForceRedaction = manualRedactionClient.getManualRedactions(file.getDossierId(), file.getFileId()) +// .getForceRedactions() +// .stream() +// .filter(a -> a.getAnnotationId().equalsIgnoreCase(forceRedaction.getAnnotationId())) +// .findAny() +// .get(); +// assertThat(loadedForceRedaction.getLegalBasis()).isEqualTo("1"); +// assertThat(loadedForceRedaction.getUser()).isEqualTo(userId); +// assertThat(loadedForceRedaction.getAnnotationId()).isEqualTo(loadedForceRedaction.getAnnotationId()); +// assertThat(loadedForceRedaction.getFileId()).isEqualTo(loadedForceRedaction.getFileId()); +// +// manualRedactionClient.approveRequestBulk(dossier.getId(), file.getId(), Set.of(forceRedaction.getAnnotationId())); +// loadedForceRedaction = manualRedactionClient.getManualRedactions(file.getDossierId(), file.getFileId()) +// .getForceRedactions() +// .stream() +// .filter(a -> a.getAnnotationId().equalsIgnoreCase(forceRedaction.getAnnotationId())) +// .findAny() +// .get(); +// assertThat(loadedForceRedaction.getStatus()).isEqualTo(AnnotationStatus.APPROVED); +// +// manualRedactionClient.declineRequestBulk(dossier.getId(), file.getId(), Set.of(forceRedaction.getAnnotationId())); +// loadedForceRedaction = manualRedactionClient.getManualRedactions(file.getDossierId(), file.getFileId()) +// .getForceRedactions() +// .stream() +// .filter(a -> a.getAnnotationId().equalsIgnoreCase(forceRedaction.getAnnotationId())) +// .findAny() +// .get(); +// assertThat(loadedForceRedaction.getStatus()).isEqualTo(AnnotationStatus.DECLINED); +// +// var legalBasisChange = manualRedactionClient.requestBulkLegalBasisChange(dossier.getId(), +// file.getId(), +// Set.of(LegalBasisChangeRequest.builder().annotationId(addRedaction.getAnnotationId()).comment("comment").legalBasis("1").build())).get(0); +// +// var loadedLegalBasisChange = manualRedactionClient.getManualRedactions(file.getDossierId(), file.getFileId()) +// .getLegalBasisChanges() +// .stream() +// .filter(a -> a.getAnnotationId().equalsIgnoreCase(legalBasisChange.getAnnotationId())) +// .findAny() +// .get(); +// assertThat(loadedLegalBasisChange.getAnnotationId()).isEqualTo(legalBasisChange.getAnnotationId()); +// assertThat(loadedLegalBasisChange.getUser()).isEqualTo(userId); +// assertThat(loadedLegalBasisChange.getLegalBasis()).isEqualTo("1"); +// +// manualRedactionClient.approveRequestBulk(dossier.getId(), file.getId(), Set.of(loadedLegalBasisChange.getAnnotationId())); +// loadedLegalBasisChange = manualRedactionClient.getManualRedactions(file.getDossierId(), file.getFileId()) +// .getLegalBasisChanges() +// .stream() +// .filter(a -> a.getAnnotationId().equalsIgnoreCase(legalBasisChange.getAnnotationId())) +// .findAny() +// .get(); +// assertThat(loadedLegalBasisChange.getStatus()).isEqualTo(AnnotationStatus.APPROVED); +// +// manualRedactionClient.declineRequestBulk(dossier.getId(), file.getId(), Set.of(loadedLegalBasisChange.getAnnotationId())); +// loadedLegalBasisChange = manualRedactionClient.getManualRedactions(file.getDossierId(), file.getFileId()) +// .getLegalBasisChanges() +// .stream() +// .filter(a -> a.getAnnotationId().equalsIgnoreCase(legalBasisChange.getAnnotationId())) +// .findAny() +// .get(); +// assertThat(loadedLegalBasisChange.getStatus()).isEqualTo(AnnotationStatus.DECLINED); +// +// var imageRecategorization = manualRedactionClient.requestBulkImageRecategorization(dossier.getId(), +// file.getId(), +// Set.of(ImageRecategorizationRequest.builder().annotationId(addRedaction.getAnnotationId()).comment("comment").type("new-type").build())).get(0); +// +// var loadedImageRecategorization = manualRedactionClient.getManualRedactions(file.getDossierId(), file.getFileId()) +// .getImageRecategorization() +// .stream() +// .filter(a -> a.getAnnotationId().equalsIgnoreCase(legalBasisChange.getAnnotationId())) +// .findAny() +// .get(); +// assertThat(loadedImageRecategorization.getAnnotationId()).isEqualTo(imageRecategorization.getAnnotationId()); +// +// manualRedactionClient.approveRequestBulk(dossier.getId(), file.getId(), Set.of(imageRecategorization.getAnnotationId())); +// loadedImageRecategorization = manualRedactionClient.getManualRedactions(file.getDossierId(), file.getFileId()) +// .getImageRecategorization() +// .stream() +// .filter(a -> a.getAnnotationId().equalsIgnoreCase(legalBasisChange.getAnnotationId())) +// .findAny() +// .get(); +// assertThat(loadedImageRecategorization.getStatus()).isEqualTo(AnnotationStatus.APPROVED); +// +// manualRedactionClient.declineRequestBulk(dossier.getId(), file.getId(), Set.of(imageRecategorization.getAnnotationId())); +// loadedImageRecategorization = manualRedactionClient.getManualRedactions(file.getDossierId(), file.getFileId()) +// .getImageRecategorization() +// .stream() +// .filter(a -> a.getAnnotationId().equalsIgnoreCase(legalBasisChange.getAnnotationId())) +// .findAny() +// .get(); +// assertThat(loadedImageRecategorization.getStatus()).isEqualTo(AnnotationStatus.DECLINED); +// +// var resizeRedaction = manualRedactionClient.requestBulkResizeRedaction(dossier.getId(), +// file.getId(), +// Set.of(ResizeRedactionRequest.builder() +// .annotationId(addRedaction.getAnnotationId()) +// .comment("comment") +// .positions(List.of(Rectangle.builder().topLeftY(2).topLeftX(2).height(2).width(2).build())) +// .value("some value") +// .build())).get(0); +// var loadedResizeRedaction = manualRedactionClient.getManualRedactions(file.getDossierId(), file.getFileId()) +// .getResizeRedactions() +// .stream() +// .filter(a -> a.getAnnotationId().equalsIgnoreCase(legalBasisChange.getAnnotationId())) +// .findAny() +// .get(); +// assertThat(loadedResizeRedaction.getStatus()).isEqualTo(AnnotationStatus.REQUESTED); +// assertThat(loadedResizeRedaction.getUser()).isEqualTo(userId); +// assertThat(loadedResizeRedaction.getPositions()).isNotEmpty(); +// assertThat(loadedResizeRedaction.getValue()).isEqualTo("some value"); +// +// manualRedactionClient.approveRequestBulk(dossier.getId(), file.getId(), Set.of(loadedResizeRedaction.getAnnotationId())); +// loadedResizeRedaction = manualRedactionClient.getManualRedactions(file.getDossierId(), file.getFileId()) +// .getResizeRedactions() +// .stream() +// .filter(a -> a.getAnnotationId().equalsIgnoreCase(legalBasisChange.getAnnotationId())) +// .findAny() +// .get(); +// assertThat(loadedResizeRedaction.getStatus()).isEqualTo(AnnotationStatus.APPROVED); +// +// manualRedactionClient.declineRequestBulk(dossier.getId(), file.getId(), Set.of(loadedResizeRedaction.getAnnotationId())); +// loadedResizeRedaction = manualRedactionClient.getManualRedactions(file.getDossierId(), file.getFileId()) +// .getResizeRedactions() +// .stream() +// .filter(a -> a.getAnnotationId().equalsIgnoreCase(legalBasisChange.getAnnotationId())) +// .findAny() +// .get(); +// assertThat(loadedResizeRedaction.getStatus()).isEqualTo(AnnotationStatus.DECLINED); +// +// ManualRedactions manualRedactions = manualRedactionClient.getManualRedactions(dossier.getId(), file.getId()); +// assertThat(manualRedactions.getForceRedactions()).isNotEmpty(); +// assertThat(manualRedactions.getLegalBasisChanges()).isNotEmpty(); +// assertThat(manualRedactions.getEntriesToAdd()).isNotEmpty(); +// assertThat(manualRedactions.getIdsToRemove()).isNotEmpty(); +// assertThat(manualRedactions.getImageRecategorization()).isNotEmpty(); +// assertThat(manualRedactions.getComments()).isNotEmpty(); +// assertThat(manualRedactions.getResizeRedactions()).isNotEmpty(); +// +// manualRedactions.getForceRedactions().forEach(e -> manualRedactionClient.undo(dossier.getId(), file.getId(), Set.of(e.getAnnotationId()))); +// manualRedactions.getLegalBasisChanges().forEach(e -> manualRedactionClient.undo(dossier.getId(), file.getId(), Set.of(e.getAnnotationId()))); +// manualRedactions.getEntriesToAdd().forEach(e -> manualRedactionClient.undo(dossier.getId(), file.getId(), Set.of(e.getAnnotationId()))); +// manualRedactions.getIdsToRemove().forEach(e -> manualRedactionClient.undo(dossier.getId(), file.getId(), Set.of(e.getAnnotationId()))); +// manualRedactions.getImageRecategorization().forEach(e -> manualRedactionClient.undo(dossier.getId(), file.getId(), Set.of(e.getAnnotationId()))); +// manualRedactions.getResizeRedactions().forEach(e -> manualRedactionClient.undo(dossier.getId(), file.getId(), Set.of(e.getAnnotationId()))); +// +// manualRedactions.getComments() +// .forEach((key, value) -> value.forEach(c -> manualRedactionClient.undoComment(dossier.getId(), file.getId(), c.getAnnotationId(), String.valueOf(c.getId())))); +// +// MetricValidationUtils.validateMetric(prometheusMeterRegistry, "redactmanager_calculateFlags", 1, null); +// } +// @Test - @SneakyThrows - public void testAddToDictionaryRequiresReanalysis() { - - TenantContext.setTenantId("redaction"); - - var dossierTemplate = dossierTemplateTesterAndProvider.provideTestTemplate(); - - var dossier = dossierTesterAndProvider.provideTestDossier(dossierTemplate); - - var file = fileTesterAndProvider.testAndProvideFile(dossier); - - var type = typeProvider.testAndProvideType(dossierTemplate, null, "PII"); - - // assume file is already proccessed once, test that add to dict triggers reanalysis - fileManagementStorageService.storeJSONObject(dossier.getId(), file.getId(), FileType.DOCUMENT_TEXT, "{}"); - fileManagementStorageService.storeJSONObject(dossier.getId(), file.getId(), FileType.DOCUMENT_PAGES, "{}"); - fileManagementStorageService.storeJSONObject(dossier.getId(), file.getId(), FileType.DOCUMENT_STRUCTURE, "{}"); - fileManagementStorageService.storeJSONObject(dossier.getId(), file.getId(), FileType.DOCUMENT_POSITION, "{}"); - fileManagementStorageService.storeJSONObject(dossier.getId(), file.getId(), FileType.NER_ENTITIES, "{}"); - fileManagementStorageService.storeJSONObject(dossier.getId(), file.getId(), FileType.IMAGE_INFO, "{}"); - fileStatusPersistenceService.updateProcessingStatus(file.getId(), ProcessingStatus.PROCESSED); - - var userId = userProvider.getUserId(); - fileClient.setStatusUnderReview(dossier.getId(), file.getId(), userId); - - var addRedaction = manualRedactionClient.requestBulkAddRedaction(dossier.getId(), - file.getId(), - Set.of(AddRedactionRequest.builder() - .positions(List.of(Rectangle.builder().topLeftY(1).topLeftX(1).height(1).width(1).build())) - .section("section test") - .addToDictionary(true) - .addToDossierDictionary(false) - .type(type.getType()) - .reason("1") - .value("test") - .legalBasis("1") - .rectangle(true) - .sourceId("SourceId") - .build())).iterator().next(); - - var loadedFile = fileClient.getFileStatus(dossier.getId(), file.getId()); - assertThat(loadedFile.getProcessingStatus()).isEqualTo(ProcessingStatus.PROCESSED); - - } - - - @Test - @SneakyThrows - public void testManualRedaction() { - - var dossierTemplate = dossierTemplateTesterAndProvider.provideTestTemplate(); - - var dossier = dossierTesterAndProvider.provideTestDossier(dossierTemplate); - - var file = fileTesterAndProvider.testAndProvideFile(dossier); - - var type = typeProvider.testAndProvideType(dossierTemplate, null, "manual"); - - var userId = userProvider.getUserId(); - - try { - manualRedactionClient.addRedactionBulk(dossier.getId(), - file.getId(), - Set.of(AddRedactionRequest.builder() - .positions(List.of(Rectangle.builder().page(100).topLeftY(1).topLeftX(1).height(1).width(1).build())) - .section("section test") - .addToDictionary(true) - .addToAllDossiers(true) - .type(type.getType()) - .reason("1") - .value("test") - .legalBasis("1") - .rectangle(true) - .sourceId("SourceId") - .build())); - } catch (FeignException e) { - assertThat(e.status()).isEqualTo(400); - } - - var addRedaction = manualRedactionClient.addRedactionBulk(dossier.getId(), - file.getId(), - Set.of(AddRedactionRequest.builder() - .positions(List.of(Rectangle.builder().topLeftY(1).topLeftX(1).height(1).width(1).build())) - .section("section test") - .addToDictionary(true) - .addToAllDossiers(true) - .type(type.getType()) - .reason("1") - .value("test") - .legalBasis("1") - .rectangle(true) - .sourceId("SourceId") - .build())).iterator().next(); - - var loadedAddRedaction = manualRedactionClient.getManualRedactions(file.getDossierId(), file.getFileId()).getEntriesToAdd().iterator().next(); - assertThat(loadedAddRedaction.getUser()).isEqualTo(userId); - assertThat(loadedAddRedaction.getType()).contains("manual"); - assertThat(loadedAddRedaction.getSection()).contains("section test"); - assertThat(loadedAddRedaction.isRectangle()).isEqualTo(true); - assertThat(loadedAddRedaction.getSourceId()).isEqualTo("SourceId"); - - fileClient.setStatusUnderReview(dossier.getId(), file.getId(), userId); - - manualRedactionClient.approveRequestBulk(dossier.getId(), file.getId(), Set.of(addRedaction.getAnnotationId())); - loadedAddRedaction = manualRedactionClient.getManualRedactions(file.getDossierId(), file.getFileId()) - .getEntriesToAdd() - .stream() - .filter(a -> a.getAnnotationId().equalsIgnoreCase(addRedaction.getAnnotationId())) - .findAny() - .get(); - assertThat(loadedAddRedaction.getStatus()).isEqualTo(AnnotationStatus.APPROVED); - - manualRedactionClient.declineRequestBulk(dossier.getId(), file.getId(), Set.of(addRedaction.getAnnotationId())); - loadedAddRedaction = manualRedactionClient.getManualRedactions(file.getDossierId(), file.getFileId()) - .getEntriesToAdd() - .stream() - .filter(a -> a.getAnnotationId().equalsIgnoreCase(addRedaction.getAnnotationId())) - .findAny() - .get(); - assertThat(loadedAddRedaction.getStatus()).isEqualTo(AnnotationStatus.DECLINED); - fileClient.setStatusUnderReview(dossier.getId(), file.getId(), userId); - - var addRedaction2 = manualRedactionClient.requestBulkAddRedaction(dossier.getId(), - file.getId(), - Set.of(AddRedactionRequest.builder() - .addToDictionary(true) - .addToDossierDictionary(true) - .type(type.getType()) - .reason("1") - .value("test") - .legalBasis("1") - .comment(new AddCommentRequest("comment")) - .section("section2") - .build())).iterator().next(); - - manualRedactionClient.declineRequestBulk(dossier.getId(), file.getId(), Set.of(addRedaction2.getAnnotationId())); - var loadedAddRedaction2 = manualRedactionClient.getManualRedactions(file.getDossierId(), file.getFileId()) - .getEntriesToAdd() - .stream() - .filter(a -> a.getAnnotationId().equalsIgnoreCase(addRedaction2.getAnnotationId())) - .findAny() - .get(); - assertThat(loadedAddRedaction2.getStatus()).isEqualTo(AnnotationStatus.DECLINED); - assertThat(loadedAddRedaction2.isAddToDossierDictionary()).isEqualTo(false); - assertThat(loadedAddRedaction2.isAddToDictionary()).isEqualTo(true); - assertThat(loadedAddRedaction2.getSection()).contains("section2"); - - var removeRedaction = manualRedactionClient.requestBulkRemoveRedaction(dossier.getId(), - file.getId(), - Set.of(RemoveRedactionRequest.builder().annotationId(addRedaction.getAnnotationId()).comment("comment").removeFromDictionary(false).build())).get(0); - - var redactionLog = new RedactionLog(1, - 1, - List.of(RedactionLogEntry.builder().id(addRedaction.getAnnotationId()).type("manual").value("value entry").build()), - null, - 0, - 0, - 0, - 0); - fileManagementStorageService.storeJSONObject(dossier.getId(), file.getId(), FileType.REDACTION_LOG, redactionLog); - - when(redactionLogMergeService.provideRedactionLog(Mockito.any())).thenReturn(redactionLog); - manualRedactionClient.approveRequestBulk(dossier.getId(), file.getId(), Set.of(removeRedaction.getAnnotationId())); - - var loadedRemoveRedaction = manualRedactionClient.getManualRedactions(file.getDossierId(), file.getFileId()) - .getIdsToRemove() - .stream() - .filter(a -> a.getAnnotationId().equalsIgnoreCase(removeRedaction.getAnnotationId())) - .findAny() - .get(); - assertThat(loadedRemoveRedaction.isRemoveFromDictionary()).isEqualTo(false); - assertThat(loadedRemoveRedaction.getSoftDeletedTime()).isNull(); - assertThat(loadedRemoveRedaction.getStatus()).isEqualTo(AnnotationStatus.APPROVED); - - manualRedactionClient.declineRequestBulk(dossier.getId(), file.getId(), Set.of(removeRedaction.getAnnotationId())); - loadedRemoveRedaction = manualRedactionClient.getManualRedactions(file.getDossierId(), file.getFileId()) - .getIdsToRemove() - .stream() - .filter(a -> a.getAnnotationId().equalsIgnoreCase(removeRedaction.getAnnotationId())) - .findAny() - .get(); - assertThat(loadedRemoveRedaction.getStatus()).isEqualTo(AnnotationStatus.DECLINED); - - var redLog = new RedactionLog(1, 1, List.of(RedactionLogEntry.builder().id("annotationId").type("manual").value("value entry").build()), null, 0, 0, 0, 0); - fileManagementStorageService.storeJSONObject(dossier.getId(), file.getId(), FileType.REDACTION_LOG, redLog); - - when(redactionLogMergeService.provideRedactionLog(Mockito.any())).thenReturn(redLog); - var removeRedaction2 = manualRedactionClient.requestBulkRemoveRedaction(dossier.getId(), - file.getId(), - Set.of(RemoveRedactionRequest.builder().annotationId("annotationId").comment("comment").removeFromDictionary(true).build())).get(0); - - manualRedactionClient.approveRequestBulk(dossier.getId(), file.getId(), Set.of(removeRedaction2.getAnnotationId())); - - var loadedRemoveRedaction2 = manualRedactionClient.getManualRedactions(file.getDossierId(), file.getFileId()) - .getIdsToRemove() - .stream() - .filter(a -> a.getAnnotationId().equalsIgnoreCase(removeRedaction2.getAnnotationId())) - .findAny() - .get(); - - assertThat(loadedRemoveRedaction2.getStatus()).isEqualTo(AnnotationStatus.APPROVED); - assertThat(dictionaryClient.getDictionaryForType(type.getType(), type.getDossierTemplateId(), null).getEntries().isEmpty()); - assertThat(loadedRemoveRedaction2.isRemoveFromDictionary()).isTrue(); - - manualRedactionClient.declineRequestBulk(dossier.getId(), file.getId(), Set.of(removeRedaction2.getAnnotationId())); - loadedRemoveRedaction2 = manualRedactionClient.getManualRedactions(file.getDossierId(), file.getFileId()) - .getIdsToRemove() - .stream() - .filter(a -> a.getAnnotationId().equalsIgnoreCase(removeRedaction2.getAnnotationId())) - .findAny() - .get(); - assertThat(loadedRemoveRedaction2.getStatus()).isEqualTo(AnnotationStatus.DECLINED); - - var forceRedaction = manualRedactionClient.requestBulkForceRedaction(dossier.getId(), - file.getId(), - Set.of(ForceRedactionRequest.builder().annotationId(addRedaction.getAnnotationId()).comment("comment").legalBasis("1").build())).get(0); - - var loadedForceRedaction = manualRedactionClient.getManualRedactions(file.getDossierId(), file.getFileId()) - .getForceRedactions() - .stream() - .filter(a -> a.getAnnotationId().equalsIgnoreCase(forceRedaction.getAnnotationId())) - .findAny() - .get(); - assertThat(loadedForceRedaction.getLegalBasis()).isEqualTo("1"); - assertThat(loadedForceRedaction.getUser()).isEqualTo(userId); - assertThat(loadedForceRedaction.getAnnotationId()).isEqualTo(loadedForceRedaction.getAnnotationId()); - assertThat(loadedForceRedaction.getFileId()).isEqualTo(loadedForceRedaction.getFileId()); - - manualRedactionClient.approveRequestBulk(dossier.getId(), file.getId(), Set.of(forceRedaction.getAnnotationId())); - loadedForceRedaction = manualRedactionClient.getManualRedactions(file.getDossierId(), file.getFileId()) - .getForceRedactions() - .stream() - .filter(a -> a.getAnnotationId().equalsIgnoreCase(forceRedaction.getAnnotationId())) - .findAny() - .get(); - assertThat(loadedForceRedaction.getStatus()).isEqualTo(AnnotationStatus.APPROVED); - - manualRedactionClient.declineRequestBulk(dossier.getId(), file.getId(), Set.of(forceRedaction.getAnnotationId())); - loadedForceRedaction = manualRedactionClient.getManualRedactions(file.getDossierId(), file.getFileId()) - .getForceRedactions() - .stream() - .filter(a -> a.getAnnotationId().equalsIgnoreCase(forceRedaction.getAnnotationId())) - .findAny() - .get(); - assertThat(loadedForceRedaction.getStatus()).isEqualTo(AnnotationStatus.DECLINED); - - var legalBasisChange = manualRedactionClient.requestBulkLegalBasisChange(dossier.getId(), - file.getId(), - Set.of(LegalBasisChangeRequest.builder().annotationId(addRedaction.getAnnotationId()).comment("comment").legalBasis("1").build())).get(0); - - var loadedLegalBasisChange = manualRedactionClient.getManualRedactions(file.getDossierId(), file.getFileId()) - .getLegalBasisChanges() - .stream() - .filter(a -> a.getAnnotationId().equalsIgnoreCase(legalBasisChange.getAnnotationId())) - .findAny() - .get(); - assertThat(loadedLegalBasisChange.getAnnotationId()).isEqualTo(legalBasisChange.getAnnotationId()); - assertThat(loadedLegalBasisChange.getUser()).isEqualTo(userId); - assertThat(loadedLegalBasisChange.getLegalBasis()).isEqualTo("1"); - - manualRedactionClient.approveRequestBulk(dossier.getId(), file.getId(), Set.of(loadedLegalBasisChange.getAnnotationId())); - loadedLegalBasisChange = manualRedactionClient.getManualRedactions(file.getDossierId(), file.getFileId()) - .getLegalBasisChanges() - .stream() - .filter(a -> a.getAnnotationId().equalsIgnoreCase(legalBasisChange.getAnnotationId())) - .findAny() - .get(); - assertThat(loadedLegalBasisChange.getStatus()).isEqualTo(AnnotationStatus.APPROVED); - - manualRedactionClient.declineRequestBulk(dossier.getId(), file.getId(), Set.of(loadedLegalBasisChange.getAnnotationId())); - loadedLegalBasisChange = manualRedactionClient.getManualRedactions(file.getDossierId(), file.getFileId()) - .getLegalBasisChanges() - .stream() - .filter(a -> a.getAnnotationId().equalsIgnoreCase(legalBasisChange.getAnnotationId())) - .findAny() - .get(); - assertThat(loadedLegalBasisChange.getStatus()).isEqualTo(AnnotationStatus.DECLINED); - - var imageRecategorization = manualRedactionClient.requestBulkImageRecategorization(dossier.getId(), - file.getId(), - Set.of(ImageRecategorizationRequest.builder().annotationId(addRedaction.getAnnotationId()).comment("comment").type("new-type").build())).get(0); - - var loadedImageRecategorization = manualRedactionClient.getManualRedactions(file.getDossierId(), file.getFileId()) - .getImageRecategorization() - .stream() - .filter(a -> a.getAnnotationId().equalsIgnoreCase(legalBasisChange.getAnnotationId())) - .findAny() - .get(); - assertThat(loadedImageRecategorization.getAnnotationId()).isEqualTo(imageRecategorization.getAnnotationId()); - - manualRedactionClient.approveRequestBulk(dossier.getId(), file.getId(), Set.of(imageRecategorization.getAnnotationId())); - loadedImageRecategorization = manualRedactionClient.getManualRedactions(file.getDossierId(), file.getFileId()) - .getImageRecategorization() - .stream() - .filter(a -> a.getAnnotationId().equalsIgnoreCase(legalBasisChange.getAnnotationId())) - .findAny() - .get(); - assertThat(loadedImageRecategorization.getStatus()).isEqualTo(AnnotationStatus.APPROVED); - - manualRedactionClient.declineRequestBulk(dossier.getId(), file.getId(), Set.of(imageRecategorization.getAnnotationId())); - loadedImageRecategorization = manualRedactionClient.getManualRedactions(file.getDossierId(), file.getFileId()) - .getImageRecategorization() - .stream() - .filter(a -> a.getAnnotationId().equalsIgnoreCase(legalBasisChange.getAnnotationId())) - .findAny() - .get(); - assertThat(loadedImageRecategorization.getStatus()).isEqualTo(AnnotationStatus.DECLINED); - - var resizeRedaction = manualRedactionClient.requestBulkResizeRedaction(dossier.getId(), - file.getId(), - Set.of(ResizeRedactionRequest.builder() - .annotationId(addRedaction.getAnnotationId()) - .comment("comment") - .positions(List.of(Rectangle.builder().topLeftY(2).topLeftX(2).height(2).width(2).build())) - .value("some value") - .build())).get(0); - var loadedResizeRedaction = manualRedactionClient.getManualRedactions(file.getDossierId(), file.getFileId()) - .getResizeRedactions() - .stream() - .filter(a -> a.getAnnotationId().equalsIgnoreCase(legalBasisChange.getAnnotationId())) - .findAny() - .get(); - assertThat(loadedResizeRedaction.getStatus()).isEqualTo(AnnotationStatus.REQUESTED); - assertThat(loadedResizeRedaction.getUser()).isEqualTo(userId); - assertThat(loadedResizeRedaction.getPositions()).isNotEmpty(); - assertThat(loadedResizeRedaction.getValue()).isEqualTo("some value"); - - manualRedactionClient.approveRequestBulk(dossier.getId(), file.getId(), Set.of(loadedResizeRedaction.getAnnotationId())); - loadedResizeRedaction = manualRedactionClient.getManualRedactions(file.getDossierId(), file.getFileId()) - .getResizeRedactions() - .stream() - .filter(a -> a.getAnnotationId().equalsIgnoreCase(legalBasisChange.getAnnotationId())) - .findAny() - .get(); - assertThat(loadedResizeRedaction.getStatus()).isEqualTo(AnnotationStatus.APPROVED); - - manualRedactionClient.declineRequestBulk(dossier.getId(), file.getId(), Set.of(loadedResizeRedaction.getAnnotationId())); - loadedResizeRedaction = manualRedactionClient.getManualRedactions(file.getDossierId(), file.getFileId()) - .getResizeRedactions() - .stream() - .filter(a -> a.getAnnotationId().equalsIgnoreCase(legalBasisChange.getAnnotationId())) - .findAny() - .get(); - assertThat(loadedResizeRedaction.getStatus()).isEqualTo(AnnotationStatus.DECLINED); - - ManualRedactions manualRedactions = manualRedactionClient.getManualRedactions(dossier.getId(), file.getId()); - assertThat(manualRedactions.getForceRedactions()).isNotEmpty(); - assertThat(manualRedactions.getLegalBasisChanges()).isNotEmpty(); - assertThat(manualRedactions.getEntriesToAdd()).isNotEmpty(); - assertThat(manualRedactions.getIdsToRemove()).isNotEmpty(); - assertThat(manualRedactions.getImageRecategorization()).isNotEmpty(); - assertThat(manualRedactions.getComments()).isNotEmpty(); - assertThat(manualRedactions.getResizeRedactions()).isNotEmpty(); - - manualRedactions.getForceRedactions().forEach(e -> manualRedactionClient.undo(dossier.getId(), file.getId(), Set.of(e.getAnnotationId()))); - manualRedactions.getLegalBasisChanges().forEach(e -> manualRedactionClient.undo(dossier.getId(), file.getId(), Set.of(e.getAnnotationId()))); - manualRedactions.getEntriesToAdd().forEach(e -> manualRedactionClient.undo(dossier.getId(), file.getId(), Set.of(e.getAnnotationId()))); - manualRedactions.getIdsToRemove().forEach(e -> manualRedactionClient.undo(dossier.getId(), file.getId(), Set.of(e.getAnnotationId()))); - manualRedactions.getImageRecategorization().forEach(e -> manualRedactionClient.undo(dossier.getId(), file.getId(), Set.of(e.getAnnotationId()))); - manualRedactions.getResizeRedactions().forEach(e -> manualRedactionClient.undo(dossier.getId(), file.getId(), Set.of(e.getAnnotationId()))); - - manualRedactions.getComments() - .forEach((key, value) -> value.forEach(c -> manualRedactionClient.undoComment(dossier.getId(), file.getId(), c.getAnnotationId(), String.valueOf(c.getId())))); - - MetricValidationUtils.validateMetric(prometheusMeterRegistry, "redactmanager_calculateFlags", 1, null); - } - - - @Test - public void testEnlargeResizeRedactionInDossierDictionary() { + public void testEnlargeResizeRedactionInDossierDictionaryWithAddToAllDossiers() { // preparíng prerequisites var dossierTemplate = dossierTemplateTesterAndProvider.provideTestTemplate(); @@ -848,8 +829,6 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest { var typeDosDict = typeProvider.testAndProvideType(dossierTemplate, null, "typeDosDict", false, 99); var typeDosTempDict = typeProvider.testAndProvideType(dossierTemplate, null, "typeDosTempDict", false, 101); - var userId = userProvider.getUserId(); - var redactionDos = AddRedactionRequest.builder() .positions(List.of(Rectangle.builder().page(1).topLeftY(1).topLeftX(1).height(1).width(1).build())) .section("section test") @@ -868,7 +847,7 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest { .positions(List.of(Rectangle.builder().page(1).topLeftY(1).topLeftX(1).height(1).width(1).build())) .section("section test") .addToDictionary(true) - .addToAllDossiers(false) + .addToAllDossiers(true) .type(typeDosTempDict.getType()) .dictionaryEntryType(DictionaryEntryType.ENTRY) .reason("1") @@ -878,19 +857,19 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest { .sourceId("SourceId") .build(); - var addRedactions1 = manualRedactionClient.addRedactionBulk(dossier1.getDossierId(), file1.getId(), Set.of(redactionDos, redactionDosTempDict)); + var addRedactions = manualRedactionClient.addRedactionBulk(dossier1.getDossierId(), file1.getId(), Set.of(redactionDos, redactionDosTempDict)); var loadedRedactionsFile1 = manualRedactionClient.getManualRedactions(file1.getDossierId(), file1.getFileId()); var redactionLog1 = new RedactionLog(1, 1, List.of(RedactionLogEntry.builder() - .id(addRedactions1.get(0).getAnnotationId()) + .id(addRedactions.get(0).getAnnotationId()) .type(typeDosDict.getType()) .value("test redaction in dossier") .isDossierDictionaryEntry(true) .build(), RedactionLogEntry.builder() - .id(addRedactions1.get(1).getAnnotationId()) + .id(addRedactions.get(1).getAnnotationId()) .type(typeDosTempDict.getType()) .value("test redaction in dossier template") .isDictionaryEntry(true) @@ -905,13 +884,10 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest { when(redactionLogMergeService.provideRedactionLog(redactionRequest1)).thenReturn(redactionLog1); when(redactionLogService.getRedactionLog(file1.getDossierId(), file1.getFileId(), true, true)).thenReturn(redactionLog1); - var addRedactions2 = manualRedactionClient.addRedactionBulk(dossier2.getDossierId(), file2.getFileId(), Set.of(redactionDosTempDict)); - var loadedRedactionsFile2 = manualRedactionClient.getManualRedactions(file2.getDossierId(), file2.getFileId()); - var redactionLog2 = new RedactionLog(1, 1, List.of(RedactionLogEntry.builder() - .id(addRedactions2.get(0).getAnnotationId()) + .id(addRedactions.get(1).getAnnotationId()) .type(typeDosTempDict.getType()) .value("test redaction in dossier template") .isDictionaryEntry(true) @@ -928,14 +904,14 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest { // resize redaction in dossier 1 var resizeRedactionDosAndAddToAllDos = ResizeRedactionRequest.builder() - .annotationId(addRedactions1.get(0).getAnnotationId()) + .annotationId(addRedactions.get(0).getAnnotationId()) .comment("resized dossier redaction") .value("test redaction in dossier dictionary") .updateDictionary(true) .addToAllDossiers(true) .build(); - var resizeRedactions = manualRedactionClient.resizeRedactionBulk(dossier1.getDossierId(), file1.getFileId(), Set.of(resizeRedactionDosAndAddToAllDos)); + manualRedactionClient.resizeRedactionBulk(dossier1.getDossierId(), file1.getFileId(), Set.of(resizeRedactionDosAndAddToAllDos)); loadedRedactionsFile1 = manualRedactionClient.getManualRedactions(file1.getDossierId(), file1.getFileId()); @@ -957,15 +933,14 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest { assertThat(dictionaryOfTypeDosDictInDossierTemplate.getEntries().get(0)).isEqualTo("test redaction in dossier dictionary"); var dictionaryOfTypeDosTempDictInDossier1 = dictionaryClient.getDictionaryForType(typeDosTempDict.getType(), dossier1.getDossierTemplateId(), dossier1.getDossierId()); - assertThat(dictionaryOfTypeDosTempDictInDossier1.getEntries()).hasSize(1); - assertThat(dictionaryOfTypeDosTempDictInDossier1.getEntries().get(0)).isEqualTo("test redaction in dossier template"); + assertThat(dictionaryOfTypeDosTempDictInDossier1.getEntries()).isEmpty(); var dictionaryOfTypeDosTempDictInDossier2 = dictionaryClient.getDictionaryForType(typeDosTempDict.getType(), dossier2.getDossierTemplateId(), dossier2.getDossierId()); - assertThat(dictionaryOfTypeDosTempDictInDossier2.getEntries()).hasSize(1); - assertThat(dictionaryOfTypeDosTempDictInDossier2.getEntries().get(0)).isEqualTo("test redaction in dossier template"); + assertThat(dictionaryOfTypeDosTempDictInDossier2.getEntries()).isEmpty(); var dictionaryOfTypeDosTempDictInDossierTemplate = dictionaryClient.getDictionaryForType(typeDosTempDict.getType(), dossierTemplate.getDossierTemplateId(), null); - assertThat(dictionaryOfTypeDosTempDictInDossierTemplate.getEntries()).isEmpty(); + assertThat(dictionaryOfTypeDosTempDictInDossierTemplate.getEntries()).hasSize(1); + assertThat(dictionaryOfTypeDosTempDictInDossierTemplate.getEntries().get(0)).isEqualTo("test redaction in dossier template"); var mergedDictForTypeDosDictInDossier1 = dictionaryClient.getMergedDictionaries(typeDosDict.getType(), dossier1.getDossierTemplateId(), dossier1.getDossierId()); assertThat(mergedDictForTypeDosDictInDossier1.getEntries()).hasSize(2); @@ -987,7 +962,7 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest { @Test - public void testShrinkResizeRedactionInDossierDictionary() { + public void testShrinkResizeRedactionInDossierDictionaryWithAddToAllDossiers() { // preparíng prerequisites var dossierTemplate = dossierTemplateTesterAndProvider.provideTestTemplate(); @@ -1001,8 +976,6 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest { var typeDosDict = typeProvider.testAndProvideType(dossierTemplate, null, "typeDosDict", false, 99); var typeDosTempDict = typeProvider.testAndProvideType(dossierTemplate, null, "typeDosTempDict", false, 101); - var userId = userProvider.getUserId(); - var redactionDos = AddRedactionRequest.builder() .positions(List.of(Rectangle.builder().page(1).topLeftY(1).topLeftX(1).height(1).width(1).build())) .section("section test") @@ -1021,7 +994,7 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest { .positions(List.of(Rectangle.builder().page(1).topLeftY(1).topLeftX(1).height(1).width(1).build())) .section("section test") .addToDictionary(true) - .addToAllDossiers(false) + .addToAllDossiers(true) .type(typeDosTempDict.getType()) .dictionaryEntryType(DictionaryEntryType.ENTRY) .reason("1") @@ -1031,19 +1004,19 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest { .sourceId("SourceId") .build(); - var addRedactions1 = manualRedactionClient.addRedactionBulk(dossier1.getDossierId(), file1.getId(), Set.of(redactionDos, redactionDosTempDict)); + var addRedactions = manualRedactionClient.addRedactionBulk(dossier1.getDossierId(), file1.getId(), Set.of(redactionDos, redactionDosTempDict)); var loadedRedactionsFile1 = manualRedactionClient.getManualRedactions(file1.getDossierId(), file1.getFileId()); var redactionLog1 = new RedactionLog(1, 1, List.of(RedactionLogEntry.builder() - .id(addRedactions1.get(0).getAnnotationId()) + .id(addRedactions.get(0).getAnnotationId()) .type(typeDosDict.getType()) .value("test redaction in dossier yayy") .isDossierDictionaryEntry(true) .build(), RedactionLogEntry.builder() - .id(addRedactions1.get(1).getAnnotationId()) + .id(addRedactions.get(1).getAnnotationId()) .type(typeDosTempDict.getType()) .value("test redaction in dossier template yayy") .isDictionaryEntry(true) @@ -1058,13 +1031,10 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest { when(redactionLogMergeService.provideRedactionLog(redactionRequest1)).thenReturn(redactionLog1); when(redactionLogService.getRedactionLog(file1.getDossierId(), file1.getFileId(), true, true)).thenReturn(redactionLog1); - var addRedactions2 = manualRedactionClient.addRedactionBulk(dossier2.getDossierId(), file2.getFileId(), Set.of(redactionDosTempDict)); - var loadedRedactionsFile2 = manualRedactionClient.getManualRedactions(file2.getDossierId(), file2.getFileId()); - var redactionLog2 = new RedactionLog(1, 1, List.of(RedactionLogEntry.builder() - .id(addRedactions2.get(0).getAnnotationId()) + .id(addRedactions.get(1).getAnnotationId()) .type(typeDosTempDict.getType()) .value("test redaction in dossier template yayy") .isDictionaryEntry(true) @@ -1081,28 +1051,29 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest { // resize redaction in dossier 1 var resizeRedactionDosAndAddToAllDos = ResizeRedactionRequest.builder() - .annotationId(addRedactions1.get(0).getAnnotationId()) + .annotationId(addRedactions.get(0).getAnnotationId()) .comment("resized dossier redaction") .value("test redaction in dossier") .updateDictionary(true) .addToAllDossiers(true) .build(); - var resizeRedactions = manualRedactionClient.resizeRedactionBulk(dossier1.getDossierId(), file1.getFileId(), Set.of(resizeRedactionDosAndAddToAllDos)); + manualRedactionClient.resizeRedactionBulk(dossier1.getDossierId(), file1.getFileId(), Set.of(resizeRedactionDosAndAddToAllDos)); loadedRedactionsFile1 = manualRedactionClient.getManualRedactions(file1.getDossierId(), file1.getFileId()); assertThat(loadedRedactionsFile1.getResizeRedactions()).hasSize(1); assertThat(loadedRedactionsFile1.getResizeRedactions().stream().toList().get(0).getValue()).isEqualTo("test redaction in dossier"); - var dictEntries = dictionaryManagementService.getAllEntriesInDossierTemplate(dossierTemplate.getDossierTemplateId(), "test redaction in dossier yayy"); - assertThat(dictEntries.stream().filter(dictionaryEntry -> dictionaryEntry.getValue().equals("test redaction in dossier yayy") && dictionaryEntry.isDeleted())).hasSize(3); - assertThat(dictEntries.stream().filter(dictionaryEntry -> dictionaryEntry.getValue().equals("test redaction in dossier yayy") && !dictionaryEntry.isDeleted())).isEmpty(); - var dictEntriesSec = dictionaryManagementService.getAllEntriesInDossierTemplate(dossierTemplate.getDossierTemplateId(), "test redaction in dossier"); - assertThat(dictEntriesSec.stream().filter(dictionaryEntry -> dictionaryEntry.getValue().equals("test redaction in dossier"))).isNotEmpty(); + var dictEntriesOldValue = dictionaryManagementService.getAllEntriesInDossierTemplate(dossierTemplate.getDossierTemplateId(), "test redaction in dossier yayy"); + assertThat(dictEntriesOldValue.stream().filter(dictionaryEntry -> dictionaryEntry.getValue().equals("test redaction in dossier yayy") && dictionaryEntry.isDeleted())).hasSize(1); + assertThat(dictEntriesOldValue.stream().filter(dictionaryEntry -> dictionaryEntry.getValue().equals("test redaction in dossier yayy") && !dictionaryEntry.isDeleted())).hasSize(1); + var dictEntriesNewValue = dictionaryManagementService.getAllEntriesInDossierTemplate(dossierTemplate.getDossierTemplateId(), "test redaction in dossier"); + assertThat(dictEntriesNewValue.stream().filter(dictionaryEntry -> dictionaryEntry.getValue().equals("test redaction in dossier"))).isNotEmpty(); var dictionaryOfTypeDosDictInDossier1 = dictionaryClient.getDictionaryForType(typeDosDict.getType(), dossier1.getDossierTemplateId(), dossier1.getDossierId()); - assertThat(dictionaryOfTypeDosDictInDossier1.getEntries()).isEmpty(); + assertThat(dictionaryOfTypeDosDictInDossier1.getEntries()).hasSize(1); + assertThat(dictionaryOfTypeDosDictInDossier1.getEntries().get(0)).isEqualTo("test redaction in dossier yayy"); var dictionaryOfTypeDosDictInDossier2 = dictionaryClient.getDictionaryForType(typeDosDict.getType(), dossier2.getDossierTemplateId(), dossier2.getDossierId()); assertThat(dictionaryOfTypeDosDictInDossier2.getEntries()).isEmpty(); @@ -1112,19 +1083,19 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest { assertThat(dictionaryOfTypeDosDictInDossierTemplate.getEntries().get(0)).isEqualTo("test redaction in dossier"); var dictionaryOfTypeDosTempDictInDossier1 = dictionaryClient.getDictionaryForType(typeDosTempDict.getType(), dossier1.getDossierTemplateId(), dossier1.getDossierId()); - assertThat(dictionaryOfTypeDosTempDictInDossier1.getEntries()).hasSize(1); - assertThat(dictionaryOfTypeDosTempDictInDossier1.getEntries().get(0)).isEqualTo("test redaction in dossier template yayy"); + assertThat(dictionaryOfTypeDosTempDictInDossier1.getEntries()).isEmpty(); var dictionaryOfTypeDosTempDictInDossier2 = dictionaryClient.getDictionaryForType(typeDosTempDict.getType(), dossier2.getDossierTemplateId(), dossier2.getDossierId()); - assertThat(dictionaryOfTypeDosTempDictInDossier2.getEntries()).hasSize(1); - assertThat(dictionaryOfTypeDosTempDictInDossier2.getEntries().get(0)).isEqualTo("test redaction in dossier template yayy"); + assertThat(dictionaryOfTypeDosTempDictInDossier2.getEntries()).isEmpty(); var dictionaryOfTypeDosTempDictInDossierTemplate = dictionaryClient.getDictionaryForType(typeDosTempDict.getType(), dossierTemplate.getDossierTemplateId(), null); - assertThat(dictionaryOfTypeDosTempDictInDossierTemplate.getEntries()).isEmpty(); + assertThat(dictionaryOfTypeDosTempDictInDossierTemplate.getEntries()).hasSize(1); + assertThat(dictionaryOfTypeDosTempDictInDossierTemplate.getEntries().get(0)).isEqualTo("test redaction in dossier template yayy"); var mergedDictForTypeDosDictInDossier1 = dictionaryClient.getMergedDictionaries(typeDosDict.getType(), dossier1.getDossierTemplateId(), dossier1.getDossierId()); - assertThat(mergedDictForTypeDosDictInDossier1.getEntries()).hasSize(1); + assertThat(mergedDictForTypeDosDictInDossier1.getEntries()).hasSize(2); assertThat(mergedDictForTypeDosDictInDossier1.getEntries().get(0)).isEqualTo("test redaction in dossier"); + assertThat(mergedDictForTypeDosDictInDossier1.getEntries().get(1)).isEqualTo("test redaction in dossier yayy"); var mergedDictForTypeDosTempDictInDossier1 = dictionaryClient.getMergedDictionaries(typeDosTempDict.getType(), dossier1.getDossierTemplateId(), dossier1.getDossierId()); assertThat(mergedDictForTypeDosTempDictInDossier1.getEntries()).hasSize(1); @@ -1137,14 +1108,11 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest { var mergedDictForTypeDosTempDictInDossier2 = dictionaryClient.getMergedDictionaries(typeDosTempDict.getType(), dossier2.getDossierTemplateId(), dossier2.getDossierId()); assertThat(mergedDictForTypeDosTempDictInDossier2.getEntries()).hasSize(1); assertThat(mergedDictForTypeDosTempDictInDossier2.getEntries().get(0)).isEqualTo("test redaction in dossier template yayy"); - - System.out.println("make some noise"); - } @Test - public void testEnlargeResizeRedactionInDossierTemplateDictionary() { + public void testEnlargeResizeRedactionInDossierTemplateDictionaryWithAddToAllDossiers() { // preparíng prerequisites var dossierTemplate = dossierTemplateTesterAndProvider.provideTestTemplate(); @@ -1155,11 +1123,9 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest { var file1 = fileTesterAndProvider.testAndProvideFile(dossier1); var file2 = fileTesterAndProvider.testAndProvideFile(dossier2); - var typeDosDict = typeProvider.testAndProvideType(dossierTemplate, null, "typeDosDict", false , 99); + var typeDosDict = typeProvider.testAndProvideType(dossierTemplate, null, "typeDosDict", false, 99); var typeDosTempDict = typeProvider.testAndProvideType(dossierTemplate, null, "typeDosTempDict", false, 101); - var userId = userProvider.getUserId(); - var redactionDos = AddRedactionRequest.builder() .positions(List.of(Rectangle.builder().page(1).topLeftY(1).topLeftX(1).height(1).width(1).build())) .section("section test") @@ -1178,7 +1144,7 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest { .positions(List.of(Rectangle.builder().page(1).topLeftY(1).topLeftX(1).height(1).width(1).build())) .section("section test") .addToDictionary(true) - .addToAllDossiers(false) + .addToAllDossiers(true) .type(typeDosTempDict.getType()) .dictionaryEntryType(DictionaryEntryType.ENTRY) .reason("1") @@ -1188,64 +1154,62 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest { .sourceId("SourceId") .build(); - var addRedactions1 = manualRedactionClient.addRedactionBulk(dossier1.getDossierId(), file1.getId(), Set.of(redactionDos, redactionDosTempDict)); - var loadedRedactionsFile1 = manualRedactionClient.getManualRedactions(file1.getDossierId(), file1.getFileId()); + var addRedactions = manualRedactionClient.addRedactionBulk(dossier1.getDossierId(), file1.getId(), Set.of(redactionDos, redactionDosTempDict)); var redactionLog1 = new RedactionLog(1, 1, - List.of(RedactionLogEntry.builder().id(addRedactions1.get(0).getAnnotationId()).type(typeDosDict.getType()).value("test redaction in dossier").isDossierDictionaryEntry(true).build(), - RedactionLogEntry.builder().id(addRedactions1.get(1).getAnnotationId()).type(typeDosTempDict.getType()).value("test redaction in dossier template").isDictionaryEntry(true).build()), + List.of(RedactionLogEntry.builder() + .id(addRedactions.get(0).getAnnotationId()) + .type(typeDosDict.getType()) + .value("test redaction in dossier") + .isDossierDictionaryEntry(true) + .build(), + RedactionLogEntry.builder() + .id(addRedactions.get(1).getAnnotationId()) + .type(typeDosTempDict.getType()) + .value("test redaction in dossier template") + .isDictionaryEntry(true) + .build()), null, 0, 0, 0, 0); fileManagementStorageService.storeJSONObject(dossier1.getId(), file1.getId(), FileType.REDACTION_LOG, redactionLog1); - var redactionRequest1 = RedactionRequest.builder() - .dossierId(file1.getDossierId()) - .fileId(file1.getFileId()) - .dossierTemplateId(file1.getDossierTemplateId()) - .build(); + var redactionRequest1 = RedactionRequest.builder().dossierId(file1.getDossierId()).fileId(file1.getFileId()).dossierTemplateId(file1.getDossierTemplateId()).build(); when(redactionLogMergeService.provideRedactionLog(redactionRequest1)).thenReturn(redactionLog1); when(redactionLogService.getRedactionLog(file1.getDossierId(), file1.getFileId(), true, true)).thenReturn(redactionLog1); - var addRedactions2 = manualRedactionClient.addRedactionBulk(dossier2.getDossierId(), file2.getFileId(), Set.of(redactionDosTempDict)); - var loadedRedactionsFile2 = manualRedactionClient.getManualRedactions(file2.getDossierId(), file2.getFileId()); - var redactionLog2 = new RedactionLog(1, 1, - List.of(RedactionLogEntry.builder().id(addRedactions2.get(0).getAnnotationId()).type(typeDosTempDict.getType()).value("test redaction in dossier template").isDictionaryEntry(true).build()), + List.of(RedactionLogEntry.builder() + .id(addRedactions.get(1).getAnnotationId()) + .type(typeDosTempDict.getType()) + .value("test redaction in dossier template") + .isDictionaryEntry(true) + .build()), null, 0, 0, 0, 0); fileManagementStorageService.storeJSONObject(dossier2.getId(), file2.getId(), FileType.REDACTION_LOG, redactionLog2); - var redactionRequest2 = RedactionRequest.builder() - .dossierId(file2.getDossierId()) - .fileId(file2.getFileId()) - .dossierTemplateId(file2.getDossierTemplateId()) - .build(); + var redactionRequest2 = RedactionRequest.builder().dossierId(file2.getDossierId()).fileId(file2.getFileId()).dossierTemplateId(file2.getDossierTemplateId()).build(); when(redactionLogMergeService.provideRedactionLog(redactionRequest2)).thenReturn(redactionLog2); when(redactionLogService.getRedactionLog(file2.getDossierId(), file2.getFileId(), true, true)).thenReturn(redactionLog2); // resize redaction in dossier dict var resizeRedactionDosTemp = ResizeRedactionRequest.builder() - .annotationId(addRedactions2.get(0).getAnnotationId()) + .annotationId(addRedactions.get(1).getAnnotationId()) .comment("resized dossier template redaction") .value("test redaction in dossier template dictionary") .updateDictionary(true) - .addToAllDossiers(false) + .addToAllDossiers(true) .build(); - var resizeRedactions = manualRedactionClient.resizeRedactionBulk(dossier2.getDossierId(), - file2.getFileId(), - Set.of(resizeRedactionDosTemp - )); + var resizeRedactions = manualRedactionClient.resizeRedactionBulk(dossier2.getDossierId(), file2.getFileId(), Set.of(resizeRedactionDosTemp)); - - loadedRedactionsFile1 = manualRedactionClient.getManualRedactions(file1.getDossierId(), file1.getFileId()); - loadedRedactionsFile2 = manualRedactionClient.getManualRedactions(file2.getDossierId(), file2.getFileId()); + var loadedRedactionsFile2 = manualRedactionClient.getManualRedactions(file2.getDossierId(), file2.getFileId()); assertThat(loadedRedactionsFile2.getResizeRedactions()).hasSize(1); assertThat(loadedRedactionsFile2.getResizeRedactions().stream().toList().get(0).getValue()).isEqualTo("test redaction in dossier template dictionary"); @@ -1264,16 +1228,15 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest { assertThat(dictionaryOfTypeDosDictInDossierTemplate.getEntries()).isEmpty(); var dictionaryOfTypeDosTempDictInDossier1 = dictionaryClient.getDictionaryForType(typeDosTempDict.getType(), dossier1.getDossierTemplateId(), dossier1.getDossierId()); - assertThat(dictionaryOfTypeDosTempDictInDossier1.getEntries()).hasSize(1); - assertThat(dictionaryOfTypeDosTempDictInDossier1.getEntries().get(0)).isEqualTo("test redaction in dossier template"); + assertThat(dictionaryOfTypeDosTempDictInDossier1.getEntries()).isEmpty(); var dictionaryOfTypeDosTempDictInDossier2 = dictionaryClient.getDictionaryForType(typeDosTempDict.getType(), dossier2.getDossierTemplateId(), dossier2.getDossierId()); - assertThat(dictionaryOfTypeDosTempDictInDossier2.getEntries()).hasSize(1); - assertThat(dictionaryOfTypeDosTempDictInDossier2.getEntries().get(0)).isEqualTo("test redaction in dossier template"); + assertThat(dictionaryOfTypeDosTempDictInDossier2.getEntries()).isEmpty(); var dictionaryOfTypeDosTempDictInDossierTemplate = dictionaryClient.getDictionaryForType(typeDosTempDict.getType(), dossierTemplate.getDossierTemplateId(), null); - assertThat(dictionaryOfTypeDosTempDictInDossierTemplate.getEntries()).hasSize(1); - assertThat(dictionaryOfTypeDosTempDictInDossierTemplate.getEntries().get(0)).isEqualTo("test redaction in dossier template dictionary"); + assertThat(dictionaryOfTypeDosTempDictInDossierTemplate.getEntries()).hasSize(2); + assertThat(dictionaryOfTypeDosTempDictInDossierTemplate.getEntries().get(0)).isEqualTo("test redaction in dossier template"); + assertThat(dictionaryOfTypeDosTempDictInDossierTemplate.getEntries().get(1)).isEqualTo("test redaction in dossier template dictionary"); var mergedDictForTypeDosDictInDossier1 = dictionaryClient.getMergedDictionaries(typeDosDict.getType(), dossier1.getDossierTemplateId(), dossier1.getDossierId()); assertThat(mergedDictForTypeDosDictInDossier1.getEntries()).hasSize(1); @@ -1291,12 +1254,11 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest { assertThat(mergedDictForTypeDosTempDictInDossier2.getEntries()).hasSize(2); assertThat(mergedDictForTypeDosTempDictInDossier2.getEntries().get(0)).isEqualTo("test redaction in dossier template"); assertThat(mergedDictForTypeDosTempDictInDossier2.getEntries().get(1)).isEqualTo("test redaction in dossier template dictionary"); - } @Test - public void testShrinkResizeRedactionInDossierTemplateDictionary() { + public void testShrinkResizeRedactionInDossierTemplateDictionaryWithAddToAllDossiers() { // preparíng prerequisites var dossierTemplate = dossierTemplateTesterAndProvider.provideTestTemplate(); @@ -1310,8 +1272,6 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest { var typeDosDict = typeProvider.testAndProvideType(dossierTemplate, null, "typeDosDict", false, 99); var typeDosTempDict = typeProvider.testAndProvideType(dossierTemplate, null, "typeDosTempDict", false, 101); - var userId = userProvider.getUserId(); - var redactionDos = AddRedactionRequest.builder() .positions(List.of(Rectangle.builder().page(1).topLeftY(1).topLeftX(1).height(1).width(1).build())) .section("section test") @@ -1330,7 +1290,7 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest { .positions(List.of(Rectangle.builder().page(1).topLeftY(1).topLeftX(1).height(1).width(1).build())) .section("section test") .addToDictionary(true) - .addToAllDossiers(false) + .addToAllDossiers(true) .type(typeDosTempDict.getType()) .dictionaryEntryType(DictionaryEntryType.ENTRY) .reason("1") @@ -1340,19 +1300,18 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest { .sourceId("SourceId") .build(); - var addRedactions1 = manualRedactionClient.addRedactionBulk(dossier1.getDossierId(), file1.getId(), Set.of(redactionDos, redactionDosTempDict)); - var loadedRedactionsFile1 = manualRedactionClient.getManualRedactions(file1.getDossierId(), file1.getFileId()); + var addRedactions = manualRedactionClient.addRedactionBulk(dossier1.getDossierId(), file1.getId(), Set.of(redactionDos, redactionDosTempDict)); var redactionLog1 = new RedactionLog(1, 1, List.of(RedactionLogEntry.builder() - .id(addRedactions1.get(0).getAnnotationId()) + .id(addRedactions.get(0).getAnnotationId()) .type(typeDosDict.getType()) .value("test redaction in dossier yayy") .isDossierDictionaryEntry(true) .build(), RedactionLogEntry.builder() - .id(addRedactions1.get(1).getAnnotationId()) + .id(addRedactions.get(1).getAnnotationId()) .type(typeDosTempDict.getType()) .value("test redaction in dossier template yayy") .isDictionaryEntry(true) @@ -1367,13 +1326,10 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest { when(redactionLogMergeService.provideRedactionLog(redactionRequest1)).thenReturn(redactionLog1); when(redactionLogService.getRedactionLog(file1.getDossierId(), file1.getFileId(), true, true)).thenReturn(redactionLog1); - var addRedactions2 = manualRedactionClient.addRedactionBulk(dossier2.getDossierId(), file2.getFileId(), Set.of(redactionDosTempDict)); - var loadedRedactionsFile2 = manualRedactionClient.getManualRedactions(file2.getDossierId(), file2.getFileId()); - var redactionLog2 = new RedactionLog(1, 1, List.of(RedactionLogEntry.builder() - .id(addRedactions2.get(0).getAnnotationId()) + .id(addRedactions.get(1).getAnnotationId()) .type(typeDosTempDict.getType()) .value("test redaction in dossier template yayy") .isDictionaryEntry(true) @@ -1390,30 +1346,27 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest { // resize redaction in dossier dict var resizeRedactionDosTemp = ResizeRedactionRequest.builder() - .annotationId(addRedactions2.get(0).getAnnotationId()) + .annotationId(addRedactions.get(1).getAnnotationId()) .comment("resized dossier template redaction") .value("test redaction in dossier template") .updateDictionary(true) - .addToAllDossiers(false) + .addToAllDossiers(true) .build(); - var resizeRedactions = manualRedactionClient.resizeRedactionBulk(dossier2.getDossierId(), - file2.getFileId(), - Set.of(resizeRedactionDosTemp - )); + var resizeRedactions = manualRedactionClient.resizeRedactionBulk(dossier2.getDossierId(), file2.getFileId(), Set.of(resizeRedactionDosTemp)); - - loadedRedactionsFile1 = manualRedactionClient.getManualRedactions(file1.getDossierId(), file1.getFileId()); - loadedRedactionsFile2 = manualRedactionClient.getManualRedactions(file2.getDossierId(), file2.getFileId()); + var loadedRedactionsFile2 = manualRedactionClient.getManualRedactions(file2.getDossierId(), file2.getFileId()); assertThat(loadedRedactionsFile2.getResizeRedactions()).hasSize(1); assertThat(loadedRedactionsFile2.getResizeRedactions().stream().toList().get(0).getValue()).isEqualTo("test redaction in dossier template"); - var dictEntries = dictionaryManagementService.getAllEntriesInDossierTemplate(dossierTemplate.getDossierTemplateId(), "test redaction in dossier template yayy"); - assertThat(dictEntries.stream().filter(dictionaryEntry -> dictionaryEntry.getValue().equals("test redaction in dossier template yayy") && dictionaryEntry.isDeleted())).hasSize(1); - assertThat(dictEntries.stream().filter(dictionaryEntry -> dictionaryEntry.getValue().equals("test redaction in dossier template yayy") && !dictionaryEntry.isDeleted())).hasSize(2); - var dictEntriesSec = dictionaryManagementService.getAllEntriesInDossierTemplate(dossierTemplate.getDossierTemplateId(), "test redaction in dossier template"); - assertThat(dictEntriesSec.stream().filter(dictionaryEntry -> dictionaryEntry.getValue().equals("test redaction in dossier template"))).isNotEmpty(); + var dictEntriesOldValue = dictionaryManagementService.getAllEntriesInDossierTemplate(dossierTemplate.getDossierTemplateId(), "test redaction in dossier template yayy"); + assertThat(dictEntriesOldValue.stream() + .filter(dictionaryEntry -> dictionaryEntry.getValue().equals("test redaction in dossier template yayy") && dictionaryEntry.isDeleted())).hasSize(3); + assertThat(dictEntriesOldValue.stream() + .filter(dictionaryEntry -> dictionaryEntry.getValue().equals("test redaction in dossier template yayy") && !dictionaryEntry.isDeleted())).isEmpty(); + var dictEntriesNewValue = dictionaryManagementService.getAllEntriesInDossierTemplate(dossierTemplate.getDossierTemplateId(), "test redaction in dossier template"); + assertThat(dictEntriesNewValue.stream().filter(dictionaryEntry -> dictionaryEntry.getValue().equals("test redaction in dossier template"))).isNotEmpty(); var dictionaryOfTypeDosDictInDossier1 = dictionaryClient.getDictionaryForType(typeDosDict.getType(), dossier1.getDossierTemplateId(), dossier1.getDossierId()); assertThat(dictionaryOfTypeDosDictInDossier1.getEntries()).hasSize(1); @@ -1426,12 +1379,10 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest { assertThat(dictionaryOfTypeDosDictInDossierTemplate.getEntries()).isEmpty(); var dictionaryOfTypeDosTempDictInDossier1 = dictionaryClient.getDictionaryForType(typeDosTempDict.getType(), dossier1.getDossierTemplateId(), dossier1.getDossierId()); - assertThat(dictionaryOfTypeDosTempDictInDossier1.getEntries()).hasSize(1); - assertThat(dictionaryOfTypeDosTempDictInDossier1.getEntries().get(0)).isEqualTo("test redaction in dossier template yayy"); + assertThat(dictionaryOfTypeDosTempDictInDossier1.getEntries()).isEmpty(); var dictionaryOfTypeDosTempDictInDossier2 = dictionaryClient.getDictionaryForType(typeDosTempDict.getType(), dossier2.getDossierTemplateId(), dossier2.getDossierId()); - assertThat(dictionaryOfTypeDosTempDictInDossier2.getEntries()).hasSize(1); - assertThat(dictionaryOfTypeDosTempDictInDossier2.getEntries().get(0)).isEqualTo("test redaction in dossier template yayy"); + assertThat(dictionaryOfTypeDosTempDictInDossier2.getEntries()).isEmpty(); var dictionaryOfTypeDosTempDictInDossierTemplate = dictionaryClient.getDictionaryForType(typeDosTempDict.getType(), dossierTemplate.getDossierTemplateId(), null); assertThat(dictionaryOfTypeDosTempDictInDossierTemplate.getEntries()).hasSize(1); @@ -1442,19 +1393,15 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest { assertThat(mergedDictForTypeDosDictInDossier1.getEntries().get(0)).isEqualTo("test redaction in dossier yayy"); var mergedDictForTypeDosTempDictInDossier1 = dictionaryClient.getMergedDictionaries(typeDosTempDict.getType(), dossier1.getDossierTemplateId(), dossier1.getDossierId()); - assertThat(mergedDictForTypeDosTempDictInDossier1.getEntries()).hasSize(2); + assertThat(mergedDictForTypeDosTempDictInDossier1.getEntries()).hasSize(1); assertThat(mergedDictForTypeDosTempDictInDossier1.getEntries().get(0)).isEqualTo("test redaction in dossier template"); - assertThat(mergedDictForTypeDosTempDictInDossier1.getEntries().get(1)).isEqualTo("test redaction in dossier template yayy"); var mergedDictForTypeDosDictInDossier2 = dictionaryClient.getMergedDictionaries(typeDosDict.getType(), dossier2.getDossierTemplateId(), dossier2.getDossierId()); assertThat(mergedDictForTypeDosDictInDossier2.getEntries()).isEmpty(); var mergedDictForTypeDosTempDictInDossier2 = dictionaryClient.getMergedDictionaries(typeDosTempDict.getType(), dossier2.getDossierTemplateId(), dossier2.getDossierId()); - assertThat(mergedDictForTypeDosTempDictInDossier2.getEntries()).hasSize(2); + assertThat(mergedDictForTypeDosTempDictInDossier2.getEntries()).hasSize(1); assertThat(mergedDictForTypeDosTempDictInDossier2.getEntries().get(0)).isEqualTo("test redaction in dossier template"); - assertThat(mergedDictForTypeDosTempDictInDossier2.getEntries().get(1)).isEqualTo("test redaction in dossier template yayy"); - - System.out.println("make some noise"); } } diff --git a/persistence-service-v1/persistence-service-shared-api-v1/src/main/java/com/iqser/red/service/persistence/service/v1/api/shared/model/manual/AddRedactionRequest.java b/persistence-service-v1/persistence-service-shared-api-v1/src/main/java/com/iqser/red/service/persistence/service/v1/api/shared/model/manual/AddRedactionRequest.java index 9719340f7..39186cd13 100644 --- a/persistence-service-v1/persistence-service-shared-api-v1/src/main/java/com/iqser/red/service/persistence/service/v1/api/shared/model/manual/AddRedactionRequest.java +++ b/persistence-service-v1/persistence-service-shared-api-v1/src/main/java/com/iqser/red/service/persistence/service/v1/api/shared/model/manual/AddRedactionRequest.java @@ -38,9 +38,6 @@ public class AddRedactionRequest { private AddCommentRequest comment; - @Deprecated // Do not use this anymore. will be removed. - private boolean addToDossierDictionary; - private boolean forceAddToDictionary; private String section;