RED-7782 - Endpoint for unprocessed changes
This commit is contained in:
parent
66a188d25a
commit
ac7b05049d
@ -13,6 +13,7 @@ import java.util.Set;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.AccessControlService;
|
||||
@ -105,9 +106,10 @@ public class ManualRedactionController implements ManualRedactionResource {
|
||||
|
||||
@Override
|
||||
@PreAuthorize("hasAuthority('" + READ_MANUAL_REDACTIONS + "')")
|
||||
public ManualRedactions getManualRedactions(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId) {
|
||||
public ManualRedactions getManualRedactions(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId,
|
||||
@RequestParam(value = "unprocessed", required = false, defaultValue = FALSE) boolean unprocessed) {
|
||||
|
||||
return manualRedactionService.getManualRedactions(fileId);
|
||||
return manualRedactionService.getManualRedactions(fileId, unprocessed);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.CommentResponse;
|
||||
@ -44,6 +45,8 @@ public interface ManualRedactionResource {
|
||||
String COMMENT_ID = "commentId";
|
||||
String COMMENT_ID_PATH_VARIABLE = "/{" + COMMENT_ID + "}";
|
||||
|
||||
String FALSE = "false";
|
||||
|
||||
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
@DeleteMapping(MANUAL_REDACTION_REST_PATH + "/bulk/undo" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE)
|
||||
@ -128,9 +131,10 @@ public interface ManualRedactionResource {
|
||||
|
||||
@ResponseStatus(value = HttpStatus.OK)
|
||||
@GetMapping(value = MANUAL_REDACTION_REST_PATH + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@Operation(summary = "Returns the manual redactions", description = "None")
|
||||
@Operation(summary = "Returns the manual redactions", description = "If the unprocessed flag is true then only the unprocessed manual redactions are returned. If the flag is false" +
|
||||
"all manual redactions are returned. Default value for the flag is false.")
|
||||
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})
|
||||
ManualRedactions getManualRedactions(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId);
|
||||
ManualRedactions getManualRedactions(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId, @RequestParam(value = "unprocessed", required = false, defaultValue = FALSE) boolean unprocessed);
|
||||
|
||||
|
||||
@ResponseStatus(value = HttpStatus.OK)
|
||||
|
||||
@ -50,25 +50,44 @@ public class ManualRedactionProviderService {
|
||||
private final LegalBasisChangePersistenceService legalBasisChangePersistenceService;
|
||||
private final ResizeRedactionPersistenceService resizeRedactionPersistenceService;
|
||||
|
||||
|
||||
@Transactional
|
||||
public ManualRedactions getManualRedactions(String fileId) {
|
||||
|
||||
Set<ManualRedactionEntry> entriesToAdd = convertEntriesToAdd(addRedactionPersistenceService.findAddRedactions(fileId, false));
|
||||
return getManualRedactions(fileId, false);
|
||||
}
|
||||
|
||||
Set<IdRemoval> removals = convert(removeRedactionPersistenceService.findRemoveRedactions(fileId, false), IdRemoval.class);
|
||||
@Transactional
|
||||
public ManualRedactions getManualRedactions(String fileId, boolean unprocessed) {
|
||||
|
||||
Set<ManualForceRedaction> forceRedactions = convert(forceRedactionPersistenceService.findForceRedactions(fileId, false), ManualForceRedaction.class);
|
||||
Set<ManualRedactionEntry> entriesToAdd;
|
||||
Set<IdRemoval> removals;
|
||||
Set<ManualForceRedaction> forceRedactions;
|
||||
Set<ManualRecategorization> recategorizations;
|
||||
Set<ManualLegalBasisChange> legalBasisChanges;
|
||||
Set<ManualResizeRedaction> resizeRedactions;
|
||||
|
||||
Set<ManualRecategorization> recategorizations = new HashSet<>(convert(recategorizationPersistenceService.findRecategorizations(fileId, false),
|
||||
ManualRecategorization.class,
|
||||
new ManualImageRecategorizationMapper()));
|
||||
|
||||
Set<ManualLegalBasisChange> legalBasisChanges = convert(legalBasisChangePersistenceService.findLegalBasisChanges(fileId, false), ManualLegalBasisChange.class);
|
||||
|
||||
Set<ManualResizeRedaction> resizeRedactions = new HashSet<>(convert(resizeRedactionPersistenceService.findResizeRedactions(fileId, false),
|
||||
ManualResizeRedaction.class,
|
||||
new ManualResizeRedactionMapper()));
|
||||
if (unprocessed) {
|
||||
entriesToAdd = convertEntriesToAdd(addRedactionPersistenceService.findUnprocessedRedactions(fileId));
|
||||
removals = convert(removeRedactionPersistenceService.findUnprocessedRemoveRedactions(fileId), IdRemoval.class);
|
||||
forceRedactions = convert(forceRedactionPersistenceService.findUnprocessedForceRedactions(fileId), ManualForceRedaction.class);
|
||||
recategorizations = new HashSet<>(convert(recategorizationPersistenceService.findUnprocessedRecategorizations(fileId),
|
||||
ManualRecategorization.class,
|
||||
new ManualImageRecategorizationMapper()));
|
||||
legalBasisChanges = convert(legalBasisChangePersistenceService.findUnprocessedLegalBasisChanges(fileId), ManualLegalBasisChange.class);
|
||||
resizeRedactions = new HashSet<>(convert(resizeRedactionPersistenceService.findUnprocessedResizeRedactions(fileId),
|
||||
ManualResizeRedaction.class,
|
||||
new ManualResizeRedactionMapper()));
|
||||
} else {
|
||||
entriesToAdd = convertEntriesToAdd(addRedactionPersistenceService.findAddRedactions(fileId, false));
|
||||
removals = convert(removeRedactionPersistenceService.findRemoveRedactions(fileId, false), IdRemoval.class);
|
||||
forceRedactions = convert(forceRedactionPersistenceService.findForceRedactions(fileId, false), ManualForceRedaction.class);
|
||||
recategorizations = new HashSet<>(convert(recategorizationPersistenceService.findRecategorizations(fileId, false),
|
||||
ManualRecategorization.class,
|
||||
new ManualImageRecategorizationMapper()));
|
||||
legalBasisChanges = convert(legalBasisChangePersistenceService.findLegalBasisChanges(fileId, false), ManualLegalBasisChange.class);
|
||||
resizeRedactions = new HashSet<>(convert(resizeRedactionPersistenceService.findResizeRedactions(fileId, false),
|
||||
ManualResizeRedaction.class,
|
||||
new ManualResizeRedactionMapper()));
|
||||
}
|
||||
|
||||
Map<String, List<CommentEntity>> commentEntities = commentPersistenceService.findCommentsByFileID(fileId, false);
|
||||
|
||||
|
||||
@ -304,9 +304,9 @@ public class ManualRedactionService {
|
||||
}
|
||||
|
||||
|
||||
public ManualRedactions getManualRedactions(String fileId) {
|
||||
public ManualRedactions getManualRedactions(String fileId, boolean unprocessed) {
|
||||
|
||||
return manualRedactionProviderService.getManualRedactions(fileId);
|
||||
return manualRedactionProviderService.getManualRedactions(fileId, unprocessed);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -41,10 +41,6 @@ public class AddRedactionPersistenceService {
|
||||
manualRedactionEntry.setTypeId(addRedactionRequest.getDossierTemplateTypeId());
|
||||
manualRedactionEntry.setDictionaryEntryType(addRedactionRequest.getDictionaryEntryType());
|
||||
|
||||
if (addRedactionRequest.getStatus() == AnnotationStatus.APPROVED && !(addRedactionRequest.isAddToDictionary())) {
|
||||
manualRedactionEntry.setProcessedDate(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
}
|
||||
|
||||
return manualRedactionRepository.saveAndFlush(manualRedactionEntry);
|
||||
|
||||
}
|
||||
@ -84,6 +80,11 @@ public class AddRedactionPersistenceService {
|
||||
return manualRedactionRepository.findAll();
|
||||
}
|
||||
|
||||
public List<ManualRedactionEntryEntity> findUnprocessedRedactions(String fileId) {
|
||||
|
||||
return manualRedactionRepository.findByFileIdAndUnprocessed(fileId);
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void hardDelete(String fileId, String annotationId) {
|
||||
|
||||
@ -77,6 +77,10 @@ public class ForceRedactionPersistenceService {
|
||||
return new HashSet<>(forceRedactionRepository.findByFileIdIncludeDeletions(fileId, includeDeletions));
|
||||
}
|
||||
|
||||
public Set<ManualForceRedactionEntity> findUnprocessedForceRedactions(String fileId) {
|
||||
|
||||
return new HashSet<>(forceRedactionRepository.findByFileIdAndUnprocessed(fileId));
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void markAsProcessed(String annotationId, String fileId) {
|
||||
|
||||
@ -2,6 +2,7 @@ package com.iqser.red.service.persistence.management.v1.processor.service.persis
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -38,10 +39,6 @@ public class LegalBasisChangePersistenceService {
|
||||
BeanUtils.copyProperties(legalBasisChangeRequest, manualLegalBasisChange);
|
||||
manualLegalBasisChange.setRequestDate(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
|
||||
if (legalBasisChangeRequest.getStatus() == AnnotationStatus.APPROVED) {
|
||||
manualLegalBasisChange.setProcessedDate(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
}
|
||||
|
||||
return legalBasisChangeRepository.saveAndFlush(manualLegalBasisChange);
|
||||
|
||||
}
|
||||
@ -91,8 +88,12 @@ public class LegalBasisChangePersistenceService {
|
||||
|
||||
public Set<ManualLegalBasisChangeEntity> findLegalBasisChanges(String fileId, boolean includeDeletions) {
|
||||
|
||||
return legalBasisChangeRepository.findByFileIdIncludeDeletions(fileId, includeDeletions).stream().collect(Collectors.toSet());
|
||||
return new HashSet<>(legalBasisChangeRepository.findByFileIdIncludeDeletions(fileId, includeDeletions));
|
||||
}
|
||||
|
||||
public Set<ManualLegalBasisChangeEntity> findUnprocessedLegalBasisChanges(String fileId) {
|
||||
|
||||
return new HashSet<>(legalBasisChangeRepository.findUnprocessedByFileId(fileId));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -97,7 +97,11 @@ public class RecategorizationPersistenceService {
|
||||
public List<ManualRecategorizationEntity> findRecategorizations(String fileId, boolean includeDeletions) {
|
||||
|
||||
return recategorizationRepository.findByFileIdIncludeDeletions(fileId, includeDeletions);
|
||||
}
|
||||
|
||||
public List<ManualRecategorizationEntity> findUnprocessedRecategorizations(String fileId) {
|
||||
|
||||
return recategorizationRepository.findUnprocessedByFileId(fileId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@ package com.iqser.red.service.persistence.management.v1.processor.service.persis
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
@ -50,7 +51,12 @@ public class RemoveRedactionPersistenceService {
|
||||
|
||||
public Set<IdRemovalEntity> findRemoveRedactions(String fileId, boolean includeDeletions) {
|
||||
|
||||
return removeRedactionRepository.findByFileIdIncludeDeletions(fileId, includeDeletions).stream().collect(Collectors.toSet());
|
||||
return new HashSet<>(removeRedactionRepository.findByFileIdIncludeDeletions(fileId, includeDeletions));
|
||||
}
|
||||
|
||||
public Set<IdRemovalEntity> findUnprocessedRemoveRedactions(String fileId) {
|
||||
|
||||
return new HashSet<>(removeRedactionRepository.findByFileIdAndUnprocessed(fileId));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -38,11 +38,6 @@ public class ResizeRedactionPersistenceService {
|
||||
manualResizeRedaction.setPositions(MagicConverter.convert(resizeRedactionRequest.getPositions(), RectangleEntity.class));
|
||||
manualResizeRedaction.setRequestDate(OffsetDateTime.now());
|
||||
|
||||
if (manualResizeRedaction.getStatus()
|
||||
.equals(AnnotationStatus.APPROVED) && (manualResizeRedaction.getUpdateDictionary() == null || !manualResizeRedaction.getUpdateDictionary())) {
|
||||
manualResizeRedaction.setProcessedDate(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
}
|
||||
|
||||
return resizeRedactionRepository.saveAndFlush(manualResizeRedaction);
|
||||
}
|
||||
|
||||
@ -98,6 +93,11 @@ public class ResizeRedactionPersistenceService {
|
||||
return resizeRedactionRepository.findByFileIdIncludeDeletions(fileId, includeDeletions);
|
||||
}
|
||||
|
||||
public List<ManualResizeRedactionEntity> findUnprocessedResizeRedactions(String fileId) {
|
||||
|
||||
return resizeRedactionRepository.findUnprocessedByFileId(fileId);
|
||||
}
|
||||
|
||||
|
||||
public List<ManualResizeRedactionEntity> findByAnnotationStatusAndValue(AnnotationStatus status, String value) {
|
||||
|
||||
|
||||
@ -32,6 +32,10 @@ public interface ForceRedactionRepository extends JpaRepository<ManualForceRedac
|
||||
List<ManualForceRedactionEntity> findByFileIdIncludeDeletions(String fileId, boolean includeDeletions);
|
||||
|
||||
|
||||
@Query("select mfr from ManualForceRedactionEntity mfr where mfr.id.fileId = :fileId and mfr.processedDate is null")
|
||||
List<ManualForceRedactionEntity> findByFileIdAndUnprocessed(String fileId);
|
||||
|
||||
|
||||
@Modifying
|
||||
@Query("update ManualForceRedactionEntity mfr set mfr.processedDate = :processedDate where mfr.id = :annotationEntityId")
|
||||
void markAsProcessed(AnnotationEntityId annotationEntityId, OffsetDateTime processedDate);
|
||||
|
||||
@ -32,6 +32,10 @@ public interface LegalBasisChangeRepository extends JpaRepository<ManualLegalBas
|
||||
List<ManualLegalBasisChangeEntity> findByFileIdIncludeDeletions(String fileId, boolean includeDeletions);
|
||||
|
||||
|
||||
@Query("select mlbc from ManualLegalBasisChangeEntity mlbc where mlbc.id.fileId = :fileId and mlbc.processedDate is null")
|
||||
List<ManualLegalBasisChangeEntity> findUnprocessedByFileId(String fileId);
|
||||
|
||||
|
||||
@Modifying
|
||||
@Query("update ManualLegalBasisChangeEntity mlbc set mlbc.processedDate = :processedDate where mlbc.id = :annotationEntityId")
|
||||
void markAsProcessed(AnnotationEntityId annotationEntityId, OffsetDateTime processedDate);
|
||||
|
||||
@ -38,6 +38,10 @@ public interface ManualRedactionRepository extends JpaRepository<ManualRedaction
|
||||
List<ManualRedactionEntryEntity> findByFileIdIncludeDeletions(String fileId, boolean includeDeletions);
|
||||
|
||||
|
||||
@Query("select m from ManualRedactionEntryEntity m where m.id.fileId = :fileId and m.processedDate is null")
|
||||
List<ManualRedactionEntryEntity> findByFileIdAndUnprocessed(String fileId);
|
||||
|
||||
|
||||
@Modifying
|
||||
@Query("update ManualRedactionEntryEntity m set m.status = :newStatus, m.processedDate = :processedDate where m.id.fileId in :fileIds and m.value = :filterValue and m.addToDictionary = true and m.status = :filterStatus ")
|
||||
void updateStatus(Set<String> fileIds, String filterValue, AnnotationStatus filterStatus, AnnotationStatus newStatus, OffsetDateTime processedDate);
|
||||
|
||||
@ -31,6 +31,9 @@ public interface RecategorizationRepository extends JpaRepository<ManualRecatego
|
||||
@Query("select mir from ManualRecategorizationEntity mir where mir.id.fileId = :fileId and (:includeDeletions = true or mir.softDeletedTime is null)")
|
||||
List<ManualRecategorizationEntity> findByFileIdIncludeDeletions(String fileId, boolean includeDeletions);
|
||||
|
||||
@Query("select mir from ManualRecategorizationEntity mir where mir.id.fileId = :fileId and mir.processedDate is null")
|
||||
List<ManualRecategorizationEntity> findUnprocessedByFileId(String fileId);
|
||||
|
||||
|
||||
@Modifying
|
||||
@Query("update ManualRecategorizationEntity mir set mir.processedDate = :processedDate where mir.id = :annotationEntityId")
|
||||
|
||||
@ -10,6 +10,7 @@ import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.annotations.AnnotationEntityId;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.annotations.IdRemovalEntity;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.annotations.ManualRedactionEntryEntity;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.AnnotationStatus;
|
||||
|
||||
public interface RemoveRedactionRepository extends JpaRepository<IdRemovalEntity, AnnotationEntityId>, AnnotationEntityRepository {
|
||||
@ -30,6 +31,9 @@ public interface RemoveRedactionRepository extends JpaRepository<IdRemovalEntity
|
||||
@Query("select idr from IdRemovalEntity idr where idr.id.fileId = :fileId and (:includeDeletions = true or idr.softDeletedTime is null)")
|
||||
List<IdRemovalEntity> findByFileIdIncludeDeletions(String fileId, boolean includeDeletions);
|
||||
|
||||
@Query("select idr from IdRemovalEntity idr where idr.id.fileId = :fileId and idr.processedDate is null")
|
||||
List<IdRemovalEntity> findByFileIdAndUnprocessed(String fileId);
|
||||
|
||||
|
||||
@Modifying
|
||||
@Query("update IdRemovalEntity idr set idr.processedDate = :processedDate where idr.id = :annotationEntityId")
|
||||
|
||||
@ -32,6 +32,10 @@ public interface ResizeRedactionRepository extends JpaRepository<ManualResizeRed
|
||||
List<ManualResizeRedactionEntity> findByFileIdIncludeDeletions(String fileId, boolean includeDeletions);
|
||||
|
||||
|
||||
@Query("select mrd from ManualResizeRedactionEntity mrd where mrd.id.fileId = :fileId and mrd.processedDate is null")
|
||||
List<ManualResizeRedactionEntity> findUnprocessedByFileId(String fileId);
|
||||
|
||||
|
||||
@Modifying
|
||||
@Query("update ManualResizeRedactionEntity m set m.textBefore = :textBefore, m.textAfter = :textAfter where m.id = :id")
|
||||
void updateSurroundingText(AnnotationEntityId id, String textBefore, String textAfter);
|
||||
|
||||
@ -2,6 +2,8 @@ package com.iqser.red.service.peristence.v1.server.integration.tests;
|
||||
|
||||
import static com.iqser.red.service.persistence.management.v1.processor.utils.TypeIdUtils.toTypeId;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -16,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.iqser.red.service.peristence.v1.server.integration.client.DictionaryClient;
|
||||
import com.iqser.red.service.peristence.v1.server.integration.client.FileClient;
|
||||
import com.iqser.red.service.peristence.v1.server.integration.client.FileProcessingClient;
|
||||
import com.iqser.red.service.peristence.v1.server.integration.client.InternalDictionaryClient;
|
||||
import com.iqser.red.service.peristence.v1.server.integration.client.ManualRedactionClient;
|
||||
import com.iqser.red.service.peristence.v1.server.integration.service.DossierTemplateTesterAndProvider;
|
||||
@ -30,7 +33,9 @@ import com.iqser.red.service.persistence.management.v1.processor.service.FileMan
|
||||
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.iqser.red.service.persistence.service.v1.api.shared.model.AnalyzeResult;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.Dictionary;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.MessageType;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.EntityLog;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.EntityLogEntry;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.EntryState;
|
||||
@ -39,6 +44,8 @@ import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations
|
||||
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.type.DictionaryEntryType;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.manual.AddRedactionRequestModel;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.manual.ForceRedactionRequestModel;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.manual.LegalBasisChangeRequestModel;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.manual.RecategorizationRequestModel;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.manual.RemoveRedactionRequestModel;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.manual.ResizeRedactionRequestModel;
|
||||
@ -92,6 +99,9 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
@Autowired
|
||||
private EntryPersistenceService entryPersistenceService;
|
||||
|
||||
@Autowired
|
||||
private FileProcessingClient fileProcessingClient;
|
||||
|
||||
|
||||
@Test
|
||||
public void testRemoveToDossierTemplateWithDossierDictionaryOnlyTrue() {
|
||||
@ -414,7 +424,7 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
.build();
|
||||
|
||||
var addRedactions = manualRedactionClient.addRedactionBulk(dossier1.getId(), file1.getId(), Set.of(redactionDos, redactionDosTempDict));
|
||||
var loadedRedactionsFile1 = manualRedactionClient.getManualRedactions(file1.getDossierId(), file1.getFileId());
|
||||
var loadedRedactionsFile1 = manualRedactionClient.getManualRedactions(file1.getDossierId(), file1.getFileId(), false);
|
||||
|
||||
var entityLog1 = new EntityLog(1,
|
||||
1,
|
||||
@ -473,7 +483,7 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
|
||||
manualRedactionClient.resizeRedactionBulk(dossier1.getId(), file1.getFileId(), Set.of(resizeRedactionDosAndAddToAllDos));
|
||||
|
||||
loadedRedactionsFile1 = manualRedactionClient.getManualRedactions(file1.getDossierId(), file1.getFileId());
|
||||
loadedRedactionsFile1 = manualRedactionClient.getManualRedactions(file1.getDossierId(), file1.getFileId(), false);
|
||||
|
||||
assertThat(loadedRedactionsFile1.getResizeRedactions()).hasSize(1);
|
||||
assertThat(loadedRedactionsFile1.getResizeRedactions().stream().toList().get(0).getValue()).isEqualTo("test redaction in dossier dictionary");
|
||||
@ -569,7 +579,7 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
.build();
|
||||
|
||||
var addRedactions = manualRedactionClient.addRedactionBulk(dossier1.getId(), file1.getId(), Set.of(redactionDos, redactionDosTempDict));
|
||||
var loadedRedactionsFile1 = manualRedactionClient.getManualRedactions(file1.getDossierId(), file1.getFileId());
|
||||
var loadedRedactionsFile1 = manualRedactionClient.getManualRedactions(file1.getDossierId(), file1.getFileId(), false);
|
||||
|
||||
var entityLog1 = new EntityLog(1,
|
||||
1,
|
||||
@ -628,7 +638,7 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
|
||||
manualRedactionClient.resizeRedactionBulk(dossier1.getId(), file1.getFileId(), Set.of(resizeRedactionDosAndAddToAllDos));
|
||||
|
||||
loadedRedactionsFile1 = manualRedactionClient.getManualRedactions(file1.getDossierId(), file1.getFileId());
|
||||
loadedRedactionsFile1 = manualRedactionClient.getManualRedactions(file1.getDossierId(), file1.getFileId(), false);
|
||||
|
||||
assertThat(loadedRedactionsFile1.getResizeRedactions()).hasSize(1);
|
||||
assertThat(loadedRedactionsFile1.getResizeRedactions().stream().toList().get(0).getValue()).isEqualTo("test redaction in dossier");
|
||||
@ -789,7 +799,7 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
|
||||
var resizeRedactions = manualRedactionClient.resizeRedactionBulk(dossier2.getId(), file2.getFileId(), Set.of(resizeRedactionDosTemp));
|
||||
|
||||
var loadedRedactionsFile2 = manualRedactionClient.getManualRedactions(file2.getDossierId(), file2.getFileId());
|
||||
var loadedRedactionsFile2 = manualRedactionClient.getManualRedactions(file2.getDossierId(), file2.getFileId(), false);
|
||||
|
||||
assertThat(loadedRedactionsFile2.getResizeRedactions()).hasSize(1);
|
||||
assertThat(loadedRedactionsFile2.getResizeRedactions().stream().toList().get(0).getValue()).isEqualTo("test redaction in dossier template dictionary");
|
||||
@ -943,7 +953,7 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
|
||||
var resizeRedactions = manualRedactionClient.resizeRedactionBulk(dossier2.getId(), file2.getFileId(), Set.of(resizeRedactionDosTemp));
|
||||
|
||||
var loadedRedactionsFile2 = manualRedactionClient.getManualRedactions(file2.getDossierId(), file2.getFileId());
|
||||
var loadedRedactionsFile2 = manualRedactionClient.getManualRedactions(file2.getDossierId(), file2.getFileId(), false);
|
||||
|
||||
assertThat(loadedRedactionsFile2.getResizeRedactions()).hasSize(1);
|
||||
assertThat(loadedRedactionsFile2.getResizeRedactions().stream().toList().get(0).getValue()).isEqualTo("test redaction in dossier template");
|
||||
@ -1137,4 +1147,332 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
assertThat(dossierDictionary2.getEntries()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnprocessedManualRedactionsAddRedaction() {
|
||||
|
||||
var dossierTemplate = dossierTemplateTesterAndProvider.provideTestTemplate();
|
||||
var dossier = dossierTesterAndProvider.provideTestDossier(dossierTemplate);
|
||||
var file = fileTesterAndProvider.testAndProvideFile(dossier);
|
||||
var type = typeProvider.testAndProvideType(dossierTemplate);
|
||||
|
||||
dictionaryClient.deleteEntries(type.getType(), type.getDossierTemplateId(), List.of("Luke Skywalker"), dossier.getId(), DictionaryEntryType.ENTRY);
|
||||
|
||||
manualRedactionClient.addRedactionBulk(dossier.getId(),
|
||||
file.getId(),
|
||||
Set.of(AddRedactionRequestModel.builder()
|
||||
.positions(List.of(Rectangle.builder().topLeftY(1).topLeftX(1).height(1).width(1).build()))
|
||||
.section("section test")
|
||||
.addToDictionary(false)
|
||||
.addToAllDossiers(false)
|
||||
.dictionaryEntryType(DictionaryEntryType.ENTRY)
|
||||
.type(type.getType())
|
||||
.reason("1")
|
||||
.value("Luke Skywalker")
|
||||
.legalBasis("1")
|
||||
.sourceId("SourceId")
|
||||
.build()));
|
||||
|
||||
var allManualRedactions = manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), false);
|
||||
assertEquals(allManualRedactions.getEntriesToAdd().size(), 1);
|
||||
assertTrue(allManualRedactions.getEntriesToAdd().stream().anyMatch(entry -> entry.getValue().equals("Luke Skywalker")));
|
||||
|
||||
var unprocessedManualRedactions = manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), true);
|
||||
assertEquals(unprocessedManualRedactions.getEntriesToAdd().size(), 1);
|
||||
assertTrue(unprocessedManualRedactions.getEntriesToAdd().stream().anyMatch(entry -> entry.getValue().equals("Luke Skywalker")));
|
||||
|
||||
fileProcessingClient.analysisSuccessful(dossier.getId(), file.getId(), AnalyzeResult.builder()
|
||||
.manualRedactions(allManualRedactions)
|
||||
.messageType(MessageType.ANALYSE).analysisVersion(0).fileId(file.getId()).dossierId(dossier.getId()).build());
|
||||
|
||||
manualRedactionClient.addRedactionBulk(dossier.getId(),
|
||||
file.getId(),
|
||||
Set.of(AddRedactionRequestModel.builder()
|
||||
.positions(List.of(Rectangle.builder().topLeftY(2).topLeftX(2).height(2).width(2).build()))
|
||||
.section("section test")
|
||||
.addToDictionary(false)
|
||||
.addToAllDossiers(false)
|
||||
.dictionaryEntryType(DictionaryEntryType.ENTRY)
|
||||
.type(type.getType())
|
||||
.reason("1")
|
||||
.value("Skywalker Luke")
|
||||
.legalBasis("1")
|
||||
.sourceId("SourceId")
|
||||
.build()));
|
||||
|
||||
allManualRedactions = manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), false);
|
||||
assertEquals(allManualRedactions.getEntriesToAdd().size(), 2);
|
||||
assertTrue(allManualRedactions.getEntriesToAdd().stream().anyMatch(entry -> entry.getValue().equals("Skywalker Luke")));
|
||||
assertTrue(allManualRedactions.getEntriesToAdd().stream().anyMatch(entry -> entry.getValue().equals("Luke Skywalker")));
|
||||
|
||||
unprocessedManualRedactions = manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), true);
|
||||
assertEquals(unprocessedManualRedactions.getEntriesToAdd().size(), 1);
|
||||
assertTrue(unprocessedManualRedactions.getEntriesToAdd().stream().anyMatch(entry -> entry.getValue().equals("Skywalker Luke")));
|
||||
assertTrue(unprocessedManualRedactions.getEntriesToAdd().stream().noneMatch(entry -> entry.getValue().equals("Luke Skywalker")));
|
||||
|
||||
fileProcessingClient.analysisSuccessful(dossier.getId(), file.getId(), AnalyzeResult.builder()
|
||||
.manualRedactions(allManualRedactions)
|
||||
.messageType(MessageType.ANALYSE).analysisVersion(1).fileId(file.getId()).dossierId(dossier.getId()).build());
|
||||
|
||||
allManualRedactions = manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), false);
|
||||
assertEquals(allManualRedactions.getEntriesToAdd().size(), 2);
|
||||
assertTrue(allManualRedactions.getEntriesToAdd().stream().anyMatch(entry -> entry.getValue().equals("Skywalker Luke")));
|
||||
assertTrue(allManualRedactions.getEntriesToAdd().stream().anyMatch(entry -> entry.getValue().equals("Luke Skywalker")));
|
||||
|
||||
unprocessedManualRedactions = manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), true);
|
||||
assertTrue(unprocessedManualRedactions.getEntriesToAdd().isEmpty());
|
||||
|
||||
dictionaryClient.addEntry(type.getType(), type.getDossierTemplateId(), List.of("Luke Skywalker"), false, dossier.getId(), DictionaryEntryType.ENTRY);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnprocessedManualRedactionsRemoveRedaction() {
|
||||
|
||||
var dossierTemplate = dossierTemplateTesterAndProvider.provideTestTemplate();
|
||||
var dossier = dossierTesterAndProvider.provideTestDossier(dossierTemplate);
|
||||
var file = fileTesterAndProvider.testAndProvideFile(dossier, "new_file");
|
||||
|
||||
var type = typeProvider.testAndProvideType(dossierTemplate, null, "type", false);
|
||||
|
||||
dictionaryClient.addEntry(type.getType(), type.getDossierTemplateId(), List.of("Anakin"), false, dossier.getId(), DictionaryEntryType.ENTRY);
|
||||
|
||||
var entityLog = new EntityLog(1,
|
||||
1,
|
||||
List.of(EntityLogEntry.builder().id("AnnotationId").type(type.getType()).value("Anakin").entryType(EntryType.ENTITY).state(EntryState.APPLIED).dictionaryEntry(false).build(),
|
||||
EntityLogEntry.builder().id("AnnotationId2").type(type.getType()).value("Anakin2").entryType(EntryType.ENTITY).state(EntryState.APPLIED).dictionaryEntry(false).build()),
|
||||
null,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0);
|
||||
fileManagementStorageService.storeJSONObject(dossier.getId(), file.getId(), FileType.ENTITY_LOG, entityLog);
|
||||
|
||||
when(entityLogService.getEntityLog(Mockito.any(), Mockito.any())).thenReturn(entityLog);
|
||||
|
||||
manualRedactionClient.removeRedactionBulk(dossier.getId(),
|
||||
file.getId(),
|
||||
Set.of(RemoveRedactionRequestModel.builder().annotationId("AnnotationId").removeFromDictionary(true).removeFromAllDossiers(true).build()));
|
||||
|
||||
var allManualRedactions = manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), false);
|
||||
assertEquals(allManualRedactions.getIdsToRemove().size(), 1);
|
||||
assertTrue(allManualRedactions.getIdsToRemove().stream().anyMatch(entry -> entry.getAnnotationId().equals("AnnotationId")));
|
||||
|
||||
var unprocessedManualRedactions = manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), true);
|
||||
assertEquals(unprocessedManualRedactions.getIdsToRemove().size(), 1);
|
||||
assertTrue(unprocessedManualRedactions.getIdsToRemove().stream().anyMatch(entry -> entry.getAnnotationId().equals("AnnotationId")));
|
||||
|
||||
fileProcessingClient.analysisSuccessful(dossier.getId(),
|
||||
file.getId(),
|
||||
AnalyzeResult.builder().manualRedactions(allManualRedactions).messageType(MessageType.ANALYSE).analysisVersion(0).fileId(file.getId()).dossierId(dossier.getId()).build());
|
||||
|
||||
manualRedactionClient.removeRedactionBulk(dossier.getId(),
|
||||
file.getId(),
|
||||
Set.of(RemoveRedactionRequestModel.builder().annotationId("AnnotationId2").removeFromDictionary(true).removeFromAllDossiers(true).build()));
|
||||
|
||||
allManualRedactions = manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), false);
|
||||
assertEquals(allManualRedactions.getIdsToRemove().size(), 2);
|
||||
assertTrue(allManualRedactions.getIdsToRemove().stream().anyMatch(entry -> entry.getAnnotationId().equals("AnnotationId")));
|
||||
assertTrue(allManualRedactions.getIdsToRemove().stream().anyMatch(entry -> entry.getAnnotationId().equals("AnnotationId2")));
|
||||
|
||||
unprocessedManualRedactions = manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), true);
|
||||
assertEquals(unprocessedManualRedactions.getIdsToRemove().size(), 1);
|
||||
assertTrue(unprocessedManualRedactions.getIdsToRemove().stream().noneMatch(entry -> entry.getAnnotationId().equals("AnnotationId")));
|
||||
assertTrue(unprocessedManualRedactions.getIdsToRemove().stream().anyMatch(entry -> entry.getAnnotationId().equals("AnnotationId2")));
|
||||
|
||||
fileProcessingClient.analysisSuccessful(dossier.getId(),
|
||||
file.getId(),
|
||||
AnalyzeResult.builder().manualRedactions(allManualRedactions).messageType(MessageType.ANALYSE).analysisVersion(1).fileId(file.getId()).dossierId(dossier.getId()).build());
|
||||
|
||||
allManualRedactions = manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), false);
|
||||
assertEquals(allManualRedactions.getIdsToRemove().size(), 2);
|
||||
assertTrue(allManualRedactions.getIdsToRemove().stream().anyMatch(entry -> entry.getAnnotationId().equals("AnnotationId")));
|
||||
assertTrue(allManualRedactions.getIdsToRemove().stream().anyMatch(entry -> entry.getAnnotationId().equals("AnnotationId2")));
|
||||
|
||||
unprocessedManualRedactions = manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), true);
|
||||
assertTrue(unprocessedManualRedactions.getIdsToRemove().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnprocessedManualRedactionsForceRedaction() {
|
||||
|
||||
var dossierTemplate = dossierTemplateTesterAndProvider.provideTestTemplate();
|
||||
var dossier = dossierTesterAndProvider.provideTestDossier(dossierTemplate);
|
||||
var file = fileTesterAndProvider.testAndProvideFile(dossier);
|
||||
|
||||
manualRedactionClient.forceRedactionBulk(dossier.getId(),
|
||||
file.getId(),
|
||||
Set.of(ForceRedactionRequestModel.builder().annotationId("forceRedactionAnnotation").comment("comment").legalBasis("1").build()));
|
||||
|
||||
var allManualRedactions = manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), false);
|
||||
assertEquals(allManualRedactions.getForceRedactions().size(), 1);
|
||||
assertTrue(allManualRedactions.getForceRedactions().stream().anyMatch(entry -> entry.getAnnotationId().equals("forceRedactionAnnotation")));
|
||||
|
||||
var unprocessedManualRedactions = manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), true);
|
||||
assertEquals(unprocessedManualRedactions.getForceRedactions().size(), 1);
|
||||
assertTrue(unprocessedManualRedactions.getForceRedactions().stream().anyMatch(entry -> entry.getAnnotationId().equals("forceRedactionAnnotation")));
|
||||
|
||||
fileProcessingClient.analysisSuccessful(dossier.getId(),
|
||||
file.getId(),
|
||||
AnalyzeResult.builder().manualRedactions(allManualRedactions).messageType(MessageType.ANALYSE).analysisVersion(0).fileId(file.getId()).dossierId(dossier.getId()).build());
|
||||
|
||||
manualRedactionClient.forceRedactionBulk(dossier.getId(),
|
||||
file.getId(),
|
||||
Set.of(ForceRedactionRequestModel.builder().annotationId("forceRedactionAnnotation2").comment("comment").legalBasis("1").build()));
|
||||
|
||||
allManualRedactions = manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), false);
|
||||
assertEquals(allManualRedactions.getForceRedactions().size(), 2);
|
||||
assertTrue(allManualRedactions.getForceRedactions().stream().anyMatch(entry -> entry.getAnnotationId().equals("forceRedactionAnnotation")));
|
||||
assertTrue(allManualRedactions.getForceRedactions().stream().anyMatch(entry -> entry.getAnnotationId().equals("forceRedactionAnnotation")));
|
||||
|
||||
unprocessedManualRedactions = manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), true);
|
||||
assertEquals(unprocessedManualRedactions.getForceRedactions().size(), 1);
|
||||
assertTrue(unprocessedManualRedactions.getForceRedactions().stream().noneMatch(entry -> entry.getAnnotationId().equals("forceRedactionAnnotation")));
|
||||
assertTrue(unprocessedManualRedactions.getForceRedactions().stream().anyMatch(entry -> entry.getAnnotationId().equals("forceRedactionAnnotation2")));
|
||||
|
||||
fileProcessingClient.analysisSuccessful(dossier.getId(),
|
||||
file.getId(),
|
||||
AnalyzeResult.builder().manualRedactions(allManualRedactions).messageType(MessageType.ANALYSE).analysisVersion(1).fileId(file.getId()).dossierId(dossier.getId()).build());
|
||||
|
||||
allManualRedactions = manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), false);
|
||||
assertEquals(allManualRedactions.getForceRedactions().size(), 2);
|
||||
assertTrue(allManualRedactions.getForceRedactions().stream().anyMatch(entry -> entry.getAnnotationId().equals("forceRedactionAnnotation")));
|
||||
assertTrue(allManualRedactions.getForceRedactions().stream().anyMatch(entry -> entry.getAnnotationId().equals("forceRedactionAnnotation2")));
|
||||
|
||||
unprocessedManualRedactions = manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), true);
|
||||
assertTrue(unprocessedManualRedactions.getForceRedactions().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnprocessedManualRedactionsRecategorizations() {
|
||||
|
||||
var dossierTemplate = dossierTemplateTesterAndProvider.provideTestTemplate();
|
||||
var dossier = dossierTesterAndProvider.provideTestDossier(dossierTemplate);
|
||||
var file = fileTesterAndProvider.testAndProvideFile(dossier);
|
||||
|
||||
var type = typeProvider.testAndProvideType(dossierTemplate, null, "type", false);
|
||||
|
||||
dictionaryClient.addEntry(type.getType(), type.getDossierTemplateId(), List.of("Darth Vader"), false, dossier.getId(), DictionaryEntryType.ENTRY);
|
||||
|
||||
var entityLog = new EntityLog(1,
|
||||
1,
|
||||
List.of(EntityLogEntry.builder().id("dv").type(type.getType()).value("Darth Vader").entryType(EntryType.ENTITY).state(EntryState.APPLIED).dictionaryEntry(false).build(),
|
||||
EntityLogEntry.builder().id("dv2").type(type.getType()).value("Vader Darth").entryType(EntryType.ENTITY).state(EntryState.APPLIED).dictionaryEntry(false).build()),
|
||||
null,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0);
|
||||
fileManagementStorageService.storeJSONObject(dossier.getId(), file.getId(), FileType.ENTITY_LOG, entityLog);
|
||||
|
||||
when(entityLogService.getEntityLog(Mockito.any(), Mockito.any())).thenReturn(entityLog);
|
||||
|
||||
manualRedactionClient.recategorizeBulk(dossier.getId(),
|
||||
file.getId(),
|
||||
Set.of(RecategorizationRequestModel.builder().annotationId("dv").build()));
|
||||
|
||||
var allManualRedactions = manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), false);
|
||||
assertEquals(allManualRedactions.getRecategorizations().size(), 1);
|
||||
assertTrue(allManualRedactions.getRecategorizations().stream().anyMatch(entry -> entry.getAnnotationId().equals("dv")));
|
||||
|
||||
var unprocessedManualRedactions = manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), true);
|
||||
assertEquals(unprocessedManualRedactions.getRecategorizations().size(), 1);
|
||||
assertTrue(unprocessedManualRedactions.getRecategorizations().stream().anyMatch(entry -> entry.getAnnotationId().equals("dv")));
|
||||
|
||||
fileProcessingClient.analysisSuccessful(dossier.getId(),
|
||||
file.getId(),
|
||||
AnalyzeResult.builder().manualRedactions(allManualRedactions).messageType(MessageType.ANALYSE).analysisVersion(0).fileId(file.getId()).dossierId(dossier.getId()).build());
|
||||
|
||||
manualRedactionClient.recategorizeBulk(dossier.getId(),
|
||||
file.getId(),
|
||||
Set.of(RecategorizationRequestModel.builder().annotationId("dv2").build()));
|
||||
|
||||
allManualRedactions = manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), false);
|
||||
assertEquals(allManualRedactions.getRecategorizations().size(), 2);
|
||||
assertTrue(allManualRedactions.getRecategorizations().stream().anyMatch(entry -> entry.getAnnotationId().equals("dv")));
|
||||
assertTrue(allManualRedactions.getRecategorizations().stream().anyMatch(entry -> entry.getAnnotationId().equals("dv2")));
|
||||
|
||||
unprocessedManualRedactions = manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), true);
|
||||
assertEquals(unprocessedManualRedactions.getRecategorizations().size(), 1);
|
||||
assertTrue(unprocessedManualRedactions.getRecategorizations().stream().noneMatch(entry -> entry.getAnnotationId().equals("dv")));
|
||||
assertTrue(unprocessedManualRedactions.getRecategorizations().stream().anyMatch(entry -> entry.getAnnotationId().equals("dv2")));
|
||||
|
||||
fileProcessingClient.analysisSuccessful(dossier.getId(),
|
||||
file.getId(),
|
||||
AnalyzeResult.builder().manualRedactions(allManualRedactions).messageType(MessageType.ANALYSE).analysisVersion(1).fileId(file.getId()).dossierId(dossier.getId()).build());
|
||||
|
||||
allManualRedactions = manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), false);
|
||||
assertEquals(allManualRedactions.getRecategorizations().size(), 2);
|
||||
assertTrue(allManualRedactions.getRecategorizations().stream().anyMatch(entry -> entry.getAnnotationId().equals("dv")));
|
||||
assertTrue(allManualRedactions.getRecategorizations().stream().anyMatch(entry -> entry.getAnnotationId().equals("dv2")));
|
||||
|
||||
unprocessedManualRedactions = manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), true);
|
||||
assertTrue(unprocessedManualRedactions.getRecategorizations().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnprocessedManualRedactionsLegalBasisChanges() {
|
||||
|
||||
var dossierTemplate = dossierTemplateTesterAndProvider.provideTestTemplate();
|
||||
var dossier = dossierTesterAndProvider.provideTestDossier(dossierTemplate);
|
||||
var file = fileTesterAndProvider.testAndProvideFile(dossier);
|
||||
|
||||
var type = typeProvider.testAndProvideType(dossierTemplate, null, "type", false);
|
||||
|
||||
dictionaryClient.addEntry(type.getType(), type.getDossierTemplateId(), List.of("Luke Skywalker"), false, dossier.getId(), DictionaryEntryType.ENTRY);
|
||||
|
||||
var entityLog = new EntityLog(1,
|
||||
1,
|
||||
List.of(EntityLogEntry.builder().id("AnnotationId").type(type.getType()).value("Luke Skywalker").entryType(EntryType.ENTITY).state(EntryState.APPLIED).dictionaryEntry(false).build(),
|
||||
EntityLogEntry.builder().id("AnnotationId2").type(type.getType()).value("Skywalker Luke").entryType(EntryType.ENTITY).state(EntryState.APPLIED).dictionaryEntry(false).build()),
|
||||
null,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0);
|
||||
fileManagementStorageService.storeJSONObject(dossier.getId(), file.getId(), FileType.ENTITY_LOG, entityLog);
|
||||
|
||||
when(entityLogService.getEntityLog(Mockito.any(), Mockito.any())).thenReturn(entityLog);
|
||||
|
||||
manualRedactionClient.legalBasisChangeBulk(dossier.getId(),
|
||||
file.getId(),
|
||||
Set.of(LegalBasisChangeRequestModel.builder().legalBasis("legalBasis").annotationId("AnnotationId").build()));
|
||||
|
||||
var allManualRedactions = manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), false);
|
||||
assertEquals(allManualRedactions.getLegalBasisChanges().size(), 1);
|
||||
assertTrue(allManualRedactions.getLegalBasisChanges().stream().anyMatch(entry -> entry.getLegalBasis().equals("legalBasis")));
|
||||
|
||||
var unprocessedManualRedactions = manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), true);
|
||||
assertEquals(unprocessedManualRedactions.getLegalBasisChanges().size(), 1);
|
||||
assertTrue(unprocessedManualRedactions.getLegalBasisChanges().stream().anyMatch(entry -> entry.getLegalBasis().equals("legalBasis")));
|
||||
|
||||
fileProcessingClient.analysisSuccessful(dossier.getId(),
|
||||
file.getId(),
|
||||
AnalyzeResult.builder().manualRedactions(allManualRedactions).messageType(MessageType.ANALYSE).analysisVersion(0).fileId(file.getId()).dossierId(dossier.getId()).build());
|
||||
|
||||
manualRedactionClient.legalBasisChangeBulk(dossier.getId(),
|
||||
file.getId(),
|
||||
Set.of(LegalBasisChangeRequestModel.builder().legalBasis("legalBasis2").annotationId("AnnotationId2").build()));
|
||||
|
||||
allManualRedactions = manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), false);
|
||||
assertEquals(allManualRedactions.getLegalBasisChanges().size(), 2);
|
||||
assertTrue(allManualRedactions.getLegalBasisChanges().stream().anyMatch(entry -> entry.getLegalBasis().equals("legalBasis")));
|
||||
assertTrue(allManualRedactions.getLegalBasisChanges().stream().anyMatch(entry -> entry.getLegalBasis().equals("legalBasis2")));
|
||||
|
||||
unprocessedManualRedactions = manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), true);
|
||||
assertEquals(unprocessedManualRedactions.getLegalBasisChanges().size(), 1);
|
||||
assertTrue(unprocessedManualRedactions.getLegalBasisChanges().stream().noneMatch(entry -> entry.getLegalBasis().equals("legalBasis")));
|
||||
assertTrue(unprocessedManualRedactions.getLegalBasisChanges().stream().anyMatch(entry -> entry.getLegalBasis().equals("legalBasis2")));
|
||||
|
||||
fileProcessingClient.analysisSuccessful(dossier.getId(),
|
||||
file.getId(),
|
||||
AnalyzeResult.builder().manualRedactions(allManualRedactions).messageType(MessageType.ANALYSE).analysisVersion(1).fileId(file.getId()).dossierId(dossier.getId()).build());
|
||||
|
||||
allManualRedactions = manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), false);
|
||||
assertEquals(allManualRedactions.getLegalBasisChanges().size(), 2);
|
||||
assertTrue(allManualRedactions.getLegalBasisChanges().stream().anyMatch(entry -> entry.getLegalBasis().equals("legalBasis")));
|
||||
assertTrue(allManualRedactions.getLegalBasisChanges().stream().anyMatch(entry -> entry.getLegalBasis().equals("legalBasis2")));
|
||||
|
||||
unprocessedManualRedactions = manualRedactionClient.getManualRedactions(dossier.getId(), file.getId(), true);
|
||||
assertTrue(unprocessedManualRedactions.getResizeRedactions().isEmpty());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user