Pull request #305: PortsFrom3.2.x

Merge in RED/persistence-service from portsFrom3.2.x to master

* commit '8ab286da9437ce774d9129c03c7d7b6b02331924':
  RED-3618: Fixed renalyse after removing hint, add also to priority queue on approve
  RED-3611: Use priority queue for user triggerd actions
This commit is contained in:
Dominique Eiflaender 2022-03-17 11:35:42 +01:00
commit 98bf21aced
13 changed files with 93 additions and 42 deletions

View File

@ -5,7 +5,6 @@ import com.iqser.red.service.persistence.management.v1.processor.entity.dossier.
import com.iqser.red.service.persistence.management.v1.processor.entity.dossier.FileEntity; import com.iqser.red.service.persistence.management.v1.processor.entity.dossier.FileEntity;
import com.iqser.red.service.persistence.management.v1.processor.exception.BadRequestException; import com.iqser.red.service.persistence.management.v1.processor.exception.BadRequestException;
import com.iqser.red.service.persistence.management.v1.processor.exception.NotFoundException; import com.iqser.red.service.persistence.management.v1.processor.exception.NotFoundException;
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.repository.DossierRepository;
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.repository.FileAttributesRepository; import com.iqser.red.service.persistence.management.v1.processor.service.persistence.repository.FileAttributesRepository;
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.repository.FileRepository; import com.iqser.red.service.persistence.management.v1.processor.service.persistence.repository.FileRepository;
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.file.ProcessingStatus; import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.file.ProcessingStatus;
@ -27,7 +26,6 @@ import java.util.stream.Collectors;
public class FileStatusPersistenceService { public class FileStatusPersistenceService {
private final FileRepository fileRepository; private final FileRepository fileRepository;
private final DossierRepository dossierRepository;
private final FileAttributesRepository fileAttributesRepository; private final FileAttributesRepository fileAttributesRepository;
private final FileAttributeConfigPersistenceService fileAttributeConfigPersistenceService; private final FileAttributeConfigPersistenceService fileAttributeConfigPersistenceService;
private final DossierPersistenceService dossierService; private final DossierPersistenceService dossierService;
@ -162,7 +160,7 @@ public class FileStatusPersistenceService {
var fileAttributeEntities = convertFileAttributes(dossierId, file, fileAttributes); var fileAttributeEntities = convertFileAttributes(dossierId, file, fileAttributes);
fileAttributesRepository.saveAllAndFlush(fileAttributeEntities); fileAttributesRepository.saveAllAndFlush(fileAttributeEntities);
fileRepository.updateLastAttributeChangeDate(fileId, OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS)); fileRepository.updateLastAttributeChangeDate(fileId,OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
}, () -> { }, () -> {
throw new NotFoundException("Unknown file=" + fileId); throw new NotFoundException("Unknown file=" + fileId);
@ -362,7 +360,7 @@ public class FileStatusPersistenceService {
@Transactional @Transactional
public void updateFileModificationDate(String fileId, OffsetDateTime fileManipulationDate){ public void updateFileModificationDate(String fileId, OffsetDateTime fileManipulationDate) {
fileRepository.updateFileModificationDate(fileId, fileManipulationDate); fileRepository.updateFileModificationDate(fileId, fileManipulationDate);
} }

View File

@ -12,6 +12,7 @@ import lombok.RequiredArgsConstructor;
public class MessagingConfiguration { public class MessagingConfiguration {
public static final String REDACTION_QUEUE = "redactionQueue"; public static final String REDACTION_QUEUE = "redactionQueue";
public static final String REDACTION_PRIORITY_QUEUE = "redactionPriorityQueue";
public static final String REDACTION_DQL = "redactionDQL"; public static final String REDACTION_DQL = "redactionDQL";
public static final String DOWNLOAD_QUEUE = "downloadQueue"; public static final String DOWNLOAD_QUEUE = "downloadQueue";
@ -106,6 +107,17 @@ public class MessagingConfiguration {
} }
@Bean
public Queue redactionPriorityQueue() {
return QueueBuilder.durable(REDACTION_PRIORITY_QUEUE)
.withArgument("x-dead-letter-exchange", "")
.withArgument("x-dead-letter-routing-key", REDACTION_DQL)
.maxPriority(2)
.build();
}
@Bean @Bean
public Queue ocrQueue() { public Queue ocrQueue() {

View File

@ -129,6 +129,7 @@ public class FileAttributesController implements FileAttributesResource {
@PathVariable(FILE_ID) String fileId, @RequestBody Map<String, String> fileAttributesMap) { @PathVariable(FILE_ID) String fileId, @RequestBody Map<String, String> fileAttributesMap) {
fileStatusPersistenceService.setFileAttributes(dossierId, fileId, fileAttributesMap); fileStatusPersistenceService.setFileAttributes(dossierId, fileId, fileAttributesMap);
fileStatusService.setStatusReprocess(dossierId, fileId, true);
indexingService.addToIndexingQueue(IndexMessageType.UPDATE, null, dossierId, fileId, 2); indexingService.addToIndexingQueue(IndexMessageType.UPDATE, null, dossierId, fileId, 2);
} }

View File

@ -43,7 +43,6 @@ public class ReanalysisController implements ReanalysisResource {
private final FileStatusService fileStatusService; private final FileStatusService fileStatusService;
private final DossierPersistenceService dossierPersistenceService; private final DossierPersistenceService dossierPersistenceService;
private final IndexingService indexingService; private final IndexingService indexingService;
private final ReanalysisRequiredStatusService reanalysisRequiredStatusService;
private final PDFTronRedactionClient pDFTronRedactionClient; private final PDFTronRedactionClient pDFTronRedactionClient;
@ -106,7 +105,7 @@ public class ReanalysisController implements ReanalysisResource {
throw new BadRequestException("The files differ in number of pages"); throw new BadRequestException("The files differ in number of pages");
} }
pDFTronRedactionClient.importRedactions(documentRequest); pDFTronRedactionClient.importRedactions(documentRequest);
fileStatusService.setStatusFullReprocess(documentRequest.getDossierId(), documentRequest.getFileId(), 1); fileStatusService.setStatusFullReprocess(documentRequest.getDossierId(), documentRequest.getFileId(), true);
} }
@ -118,7 +117,7 @@ public class ReanalysisController implements ReanalysisResource {
fileStatusService.updateFileModificationDate(textHighlightRequest.getFileId(), OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS)); fileStatusService.updateFileModificationDate(textHighlightRequest.getFileId(), OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
} }
if (textHighlightRequest.getOperation().equals(TextHighlightOperation.CONVERT)) { if (textHighlightRequest.getOperation().equals(TextHighlightOperation.CONVERT)) {
fileStatusService.setStatusFullReprocess(textHighlightRequest.getDossierId(), textHighlightRequest.getFileId(), 1); fileStatusService.setStatusFullReprocess(textHighlightRequest.getDossierId(), textHighlightRequest.getFileId(), true);
} }
return textHighlightResponse; return textHighlightResponse;
} }
@ -191,11 +190,11 @@ public class ReanalysisController implements ReanalysisResource {
if (force) { if (force) {
filesToReanalyse.forEach(file -> { filesToReanalyse.forEach(file -> {
fileStatusService.setStatusReprocess(dossierId, file.getId(), 2, true); fileStatusService.setStatusReprocess(dossierId, file.getId(), filesToReanalyse.size() == 1 ? true : false, true);
}); });
} else { } else {
filesToReanalyse.stream().filter(FileModel::isReanalysisRequired).forEach(file -> { filesToReanalyse.stream().filter(FileModel::isReanalysisRequired).forEach(file -> {
fileStatusService.setStatusReprocess(dossierId, file.getId(), 2, true); fileStatusService.setStatusReprocess(dossierId, file.getId(), filesToReanalyse.size() == 1 ? true : false, true);
}); });
} }

View File

@ -24,7 +24,7 @@ public class ExcludeFromAnalysisService {
if (!excluded) { if (!excluded) {
// if file has been re-enabled - process it // if file has been re-enabled - process it
fileStatusService.setStatusFullReprocess(dossierId, fileId, 2); fileStatusService.setStatusFullReprocess(dossierId, fileId, false);
} }
} }
@ -37,7 +37,7 @@ public class ExcludeFromAnalysisService {
if (!excludedFromAutomaticAnalysis) { if (!excludedFromAutomaticAnalysis) {
// if file has been re-enabled - process it // if file has been re-enabled - process it
fileStatusService.setStatusFullReprocess(dossierId, fileId, 2); fileStatusService.setStatusFullReprocess(dossierId, fileId, false);
} }
} }

View File

@ -89,7 +89,7 @@ public class FileService {
if (existingStatus != null) { if (existingStatus != null) {
// the file is already uploaded, just reanalyse it. // the file is already uploaded, just reanalyse it.
fileStatusService.overwriteFile(request.getDossierId(), fileId, request.getUploader(), request.getFilename(), request.getData().length); fileStatusService.overwriteFile(request.getDossierId(), fileId, request.getUploader(), request.getFilename());
} else { } else {
// the file is new, should create a new status for it. // the file is new, should create a new status for it.
log.info("File {} has no status yet, creating one and setting to unprocessed.", request.getFilename()); log.info("File {} has no status yet, creating one and setting to unprocessed.", request.getFilename());

View File

@ -37,8 +37,12 @@ public class FileStatusProcessingUpdateService {
if (settings.isNerServiceEnabled() && !fileManagementStorageService.nerEntitiesExists(dossierId, fileId)) { if (settings.isNerServiceEnabled() && !fileManagementStorageService.nerEntitiesExists(dossierId, fileId)) {
fileStatusService.addToNerQueue(dossierId, fileId); fileStatusService.addToNerQueue(dossierId, fileId);
} else { } else {
fileStatusService.setStatusAnalyse(dossierId, fileId, 1);
fileStatusService.addToAnalysisQueue(dossierId, fileId, 2, null); //TODO This might be also priority depending on what was the pervious call.
fileStatusService.setStatusAnalyse(dossierId, fileId, false);
//TODO This might be also priority depending on what was the pervious call.
fileStatusService.addToAnalysisQueue(dossierId, fileId, false, null);
} }
break; break;
@ -73,7 +77,7 @@ public class FileStatusProcessingUpdateService {
log.info("OCR Successful for dossier {} and file {}, Attempt to update status: {}", dossierId, fileId, retryContext.getRetryCount()); log.info("OCR Successful for dossier {} and file {}, Attempt to update status: {}", dossierId, fileId, retryContext.getRetryCount());
fileStatusService.updateLastOCRTime(fileId); fileStatusService.updateLastOCRTime(fileId);
fileStatusService.setStatusFullReprocess(dossierId, fileId, 2); fileStatusService.setStatusFullReprocess(dossierId, fileId, false);
return null; return null;
}); });

View File

@ -147,7 +147,7 @@ public class FileStatusService {
@Transactional @Transactional
public void setStatusReprocess(String dossierId, String fileId, int priority, Set<Integer> sectionsToReanalyse, public void setStatusReprocess(String dossierId, String fileId, boolean priority, Set<Integer> sectionsToReanalyse,
boolean triggeredManually) { boolean triggeredManually) {
log.info("Reprocessing file: {} from dossier {}", fileId, dossierId); log.info("Reprocessing file: {} from dossier {}", fileId, dossierId);
@ -182,7 +182,7 @@ public class FileStatusService {
@Transactional @Transactional
public void setStatusFullReprocess(String dossierId, String fileId, int priority) { public void setStatusFullReprocess(String dossierId, String fileId, boolean priority) {
FileEntity fileStatus = fileStatusPersistenceService.getStatus(fileId); FileEntity fileStatus = fileStatusPersistenceService.getStatus(fileId);
@ -202,7 +202,7 @@ public class FileStatusService {
@Transactional @Transactional
protected void addToAnalysisQueue(String dossierId, String fileId, int priority, Set<Integer> sectionsToReanalyse) { protected void addToAnalysisQueue(String dossierId, String fileId, boolean priority, Set<Integer> sectionsToReanalyse) {
var dossier = dossierPersistenceService.getAndValidateDossier(dossierId); var dossier = dossierPersistenceService.getAndValidateDossier(dossierId);
var fileStatus = fileStatusPersistenceService.getStatus(fileId); var fileStatus = fileStatusPersistenceService.getStatus(fileId);
@ -246,10 +246,11 @@ public class FileStatusService {
setStatusProcessing(fileId); setStatusProcessing(fileId);
try { try {
rabbitTemplate.convertAndSend(MessagingConfiguration.REDACTION_QUEUE, objectMapper.writeValueAsString(analyseRequest), message -> { if(priority){
message.getMessageProperties().setPriority(priority); rabbitTemplate.convertAndSend(MessagingConfiguration.REDACTION_PRIORITY_QUEUE, objectMapper.writeValueAsString(analyseRequest));
return message; } else {
}); rabbitTemplate.convertAndSend(MessagingConfiguration.REDACTION_QUEUE, objectMapper.writeValueAsString(analyseRequest));
}
} catch (JsonProcessingException e) { } catch (JsonProcessingException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
@ -283,14 +284,14 @@ public class FileStatusService {
@Transactional @Transactional
public void setStatusReprocess(String dossierId, String fileId, int priority) { public void setStatusReprocess(String dossierId, String fileId, boolean priority) {
setStatusReprocess(dossierId, fileId, priority, Sets.newHashSet(), false); setStatusReprocess(dossierId, fileId, priority, Sets.newHashSet(), false);
} }
@Transactional @Transactional
public void setStatusReprocess(String dossierId, String fileId, int priority, boolean triggeredManually) { public void setStatusReprocess(String dossierId, String fileId, boolean priority, boolean triggeredManually) {
setStatusReprocess(dossierId, fileId, priority, Sets.newHashSet(), triggeredManually); setStatusReprocess(dossierId, fileId, priority, Sets.newHashSet(), triggeredManually);
} }
@ -300,7 +301,7 @@ public class FileStatusService {
public void createStatus(String dossierId, String fileId, String uploader, String filename) { public void createStatus(String dossierId, String fileId, String uploader, String filename) {
fileStatusPersistenceService.createStatus(dossierId, fileId, filename, uploader); fileStatusPersistenceService.createStatus(dossierId, fileId, filename, uploader);
addToAnalysisQueue(dossierId, fileId, 1, Set.of()); addToAnalysisQueue(dossierId, fileId, false, Set.of());
} }
@ -432,11 +433,11 @@ public class FileStatusService {
@Transactional @Transactional
public void overwriteFile(String dossierId, String fileId, String uploader, String filename, int length) { public void overwriteFile(String dossierId, String fileId, String uploader, String filename) {
fileStatusPersistenceService.overwriteFile(fileId, uploader, filename); fileStatusPersistenceService.overwriteFile(fileId, uploader, filename);
wipeFileData(dossierId, fileId); wipeFileData(dossierId, fileId);
setStatusFullReprocess(dossierId, fileId, length); setStatusFullReprocess(dossierId, fileId, false);
} }
@ -518,7 +519,7 @@ public class FileStatusService {
@Transactional @Transactional
public void setStatusAnalyse(String dossierId, String fileId, int priority) { public void setStatusAnalyse(String dossierId, String fileId, boolean priority) {
FileEntity fileStatus = fileStatusPersistenceService.getStatus(fileId); FileEntity fileStatus = fileStatusPersistenceService.getStatus(fileId);

View File

@ -42,7 +42,7 @@ public class ImageMessageReceiver {
if(settings.isStoreImageFile()) { if(settings.isStoreImageFile()) {
fileManagementStorageService.storeObject(dossierId, fileId, FileType.IMAGE_INFO, in); fileManagementStorageService.storeObject(dossierId, fileId, FileType.IMAGE_INFO, in);
} }
fileStatusService.setStatusAnalyse(dossierId, fileId, 1); fileStatusService.setStatusAnalyse(dossierId, fileId, false);
} }

View File

@ -144,6 +144,14 @@ public class ManualRedactionService {
commentId = addComment(fileId, removeRedactionRequest.getAnnotationId(), removeRedactionRequest.getComment(), removeRedactionRequest.getUser()).getId(); commentId = addComment(fileId, removeRedactionRequest.getAnnotationId(), removeRedactionRequest.getComment(), removeRedactionRequest.getUser()).getId();
} }
if (!removeRedactionRequest.isRemoveFromDictionary()) {
Optional<RedactionLogEntry> redactionLogEntryOptional = redactionLog.getRedactionLogEntry()
.stream()
.filter(entry -> entry.getId().equals(removeRedactionRequest.getAnnotationId()))
.findFirst();
actionPerformed = actionPerformed || redactionLogEntryOptional.isPresent() && redactionLogEntryOptional.get().isHint();
}
actionPerformed = actionPerformed || handleRemoveFromDictionary(redactionLog, dossier, fileId, removeRedactionRequest.getAnnotationId(), removeRedactionRequest.getStatus(), removeRedactionRequest.isRemoveFromDictionary(), false); actionPerformed = actionPerformed || handleRemoveFromDictionary(redactionLog, dossier, fileId, removeRedactionRequest.getAnnotationId(), removeRedactionRequest.getStatus(), removeRedactionRequest.isRemoveFromDictionary(), false);
response.add(ManualAddResponse.builder() response.add(ManualAddResponse.builder()
@ -445,22 +453,25 @@ public class ManualRedactionService {
for (var annotationId : annotationIds) { for (var annotationId : annotationIds) {
IdRemovalEntity idRemoval = removeRedactionPersistenceService.findRemoveRedaction(fileId, annotationId); IdRemovalEntity idRemoval = removeRedactionPersistenceService.findRemoveRedaction(fileId, annotationId);
Optional<RedactionLogEntry> redactionLogEntryOptional = redactionLog.getRedactionLogEntry()
.stream()
.filter(entry -> entry.getId().equals(idRemoval.getId().getAnnotationId()))
.findFirst();
if (redactionLogEntryOptional.isEmpty()) {
throw new NotFoundException("Annotation does not exist in redaction log.");
}
if (idRemoval.isRemoveFromDictionary()) { if (idRemoval.isRemoveFromDictionary()) {
Optional<RedactionLogEntry> redactionLogEntryOptional = redactionLog.getRedactionLogEntry()
.stream()
.filter(entry -> entry.getId().equals(idRemoval.getId().getAnnotationId()))
.findFirst();
if (redactionLogEntryOptional.isEmpty()) {
throw new NotFoundException("Annotation does not exist in redaction log.");
}
var redactionLogEntry = redactionLogEntryOptional.get(); var redactionLogEntry = redactionLogEntryOptional.get();
if (annotationStatus == AnnotationStatus.APPROVED) { if (annotationStatus == AnnotationStatus.APPROVED) {
removeFromDictionary(buildTypeId(redactionLogEntry, dossier), redactionLogEntry.getValue(), dossierId, fileId, DictionaryEntryType.ENTRY); removeFromDictionary(buildTypeId(redactionLogEntry, dossier), redactionLogEntry.getValue(), dossierId, fileId, DictionaryEntryType.ENTRY);
approveStatusForRedactionsWithSameValue(dossier, false, true, redactionLogEntry.getValue()); approveStatusForRedactionsWithSameValue(dossier, false, true, redactionLogEntry.getValue());
reprocess(dossierId, fileId);
} else if (annotationStatus == AnnotationStatus.DECLINED) { } else if (annotationStatus == AnnotationStatus.DECLINED) {
@ -469,6 +480,8 @@ public class ManualRedactionService {
addToDictionary(buildTypeId(redactionLogEntry, dossier), redactionLogEntry.getValue(), dossierId, fileId, DictionaryEntryType.ENTRY); addToDictionary(buildTypeId(redactionLogEntry, dossier), redactionLogEntry.getValue(), dossierId, fileId, DictionaryEntryType.ENTRY);
} }
} }
} else if(redactionLogEntryOptional.isPresent() && redactionLogEntryOptional.get().isHint()){
reprocess(dossierId, fileId);
} }
removeRedactionPersistenceService.updateStatus(fileId, annotationId, annotationStatus); removeRedactionPersistenceService.updateStatus(fileId, annotationId, annotationStatus);
@ -560,7 +573,7 @@ public class ManualRedactionService {
if (manualRedactionEntry.isAddToDictionary() || manualRedactionEntry.isAddToDossierDictionary()) { if (manualRedactionEntry.isAddToDictionary() || manualRedactionEntry.isAddToDossierDictionary()) {
if (annotationStatus == AnnotationStatus.APPROVED) { if (annotationStatus == AnnotationStatus.APPROVED) {
addToDictionary(manualRedactionEntry.getTypeId(), manualRedactionEntry.getValue(), dossierId, fileId, manualRedactionEntry.getDictionaryEntryType()); addToDictionary(manualRedactionEntry.getTypeId(), manualRedactionEntry.getValue(), dossierId, fileId, manualRedactionEntry.getDictionaryEntryType());
reprocess(dossierId, fileId);
approveStatusForRedactionsWithSameValue(dossier, manualRedactionEntry.isAddToDictionary(), manualRedactionEntry.isAddToDossierDictionary(), manualRedactionEntry.getValue()); approveStatusForRedactionsWithSameValue(dossier, manualRedactionEntry.isAddToDictionary(), manualRedactionEntry.isAddToDossierDictionary(), manualRedactionEntry.getValue());
} else if (annotationStatus == AnnotationStatus.DECLINED) { } else if (annotationStatus == AnnotationStatus.DECLINED) {
@ -649,7 +662,7 @@ public class ManualRedactionService {
private void reprocess(String dossierId, String fileId) { private void reprocess(String dossierId, String fileId) {
fileStatusService.setStatusReprocess(dossierId, fileId, 2); fileStatusService.setStatusReprocess(dossierId, fileId, true);
} }

View File

@ -36,7 +36,7 @@ public class NerMessageReceiver {
String fileId = (String) entityResponse.get("fileId"); String fileId = (String) entityResponse.get("fileId");
log.info("Received NER Message from {} {}", dossierId, fileId); log.info("Received NER Message from {} {}", dossierId, fileId);
fileStatusService.setStatusAnalyse(dossierId, fileId, 1); fileStatusService.setStatusAnalyse(dossierId, fileId, false);
} }

View File

@ -63,10 +63,10 @@ public class AutomaticAnalysisScheduler {
if (next.isFullAnalysisRequired()) { if (next.isFullAnalysisRequired()) {
log.info("Queued file: {} for automatic full analysis! ", next.getFilename()); log.info("Queued file: {} for automatic full analysis! ", next.getFilename());
fileStatusService.setStatusFullReprocess(next.getDossierId(), next.getId(), 1); fileStatusService.setStatusFullReprocess(next.getDossierId(), next.getId(), false);
} else if (next.isReanalysisRequired()) { } else if (next.isReanalysisRequired()) {
log.info("Queued file: {} for automatic reanalysis! ", next.getFilename()); log.info("Queued file: {} for automatic reanalysis! ", next.getFilename());
fileStatusService.setStatusReprocess(next.getDossierId(), next.getId(), 1); fileStatusService.setStatusReprocess(next.getDossierId(), next.getId(), false);
} }
} }
} }

View File

@ -6,6 +6,8 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.iqser.red.service.peristence.v1.server.service.FileManagementStorageService;
import com.iqser.red.service.persistence.service.v1.api.model.annotations.*; import com.iqser.red.service.persistence.service.v1.api.model.annotations.*;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -17,6 +19,11 @@ import com.iqser.red.service.peristence.v1.server.integration.service.DossierTes
import com.iqser.red.service.peristence.v1.server.integration.service.FileTesterAndProvider; import com.iqser.red.service.peristence.v1.server.integration.service.FileTesterAndProvider;
import com.iqser.red.service.peristence.v1.server.integration.service.TypeProvider; import com.iqser.red.service.peristence.v1.server.integration.service.TypeProvider;
import com.iqser.red.service.peristence.v1.server.integration.utils.AbstractPersistenceServerServiceTest; import com.iqser.red.service.peristence.v1.server.integration.utils.AbstractPersistenceServerServiceTest;
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.file.FileType;
import com.iqser.red.service.redaction.v1.model.RedactionLog;
import com.iqser.red.service.redaction.v1.model.RedactionLogEntry;
import lombok.SneakyThrows;
public class ManualRedactionTest extends AbstractPersistenceServerServiceTest { public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
@ -38,8 +45,15 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
@Autowired @Autowired
private DictionaryClient dictionaryClient; private DictionaryClient dictionaryClient;
@Autowired
private FileManagementStorageService fileManagementStorageService;
@Autowired
private ObjectMapper objectMapper;
@Test @Test
@SneakyThrows
public void testManualRedaction() { public void testManualRedaction() {
var dossierTemplate = dossierTemplateTesterAndProvider.provideTestTemplate(); var dossierTemplate = dossierTemplateTesterAndProvider.provideTestTemplate();
@ -126,6 +140,11 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
.user("test") .user("test")
.removeFromDictionary(false) .removeFromDictionary(false)
.build())).get(0); .build())).get(0);
fileManagementStorageService.storeObject(dossier.getId(), file.getId(), FileType.REDACTION_LOG, objectMapper.writeValueAsBytes(new RedactionLog(1, 1,
List.of(RedactionLogEntry.builder().id(removeRedaction.getAnnotationId()).type("manual").value("value entry").build()),
null, 0, 0, 0, 0)));
manualRedactionClient.updateRemoveRedactionStatus(dossier.getId(), file.getId(), manualRedactionClient.updateRemoveRedactionStatus(dossier.getId(), file.getId(),
UpdateRedactionRequest.builder() UpdateRedactionRequest.builder()
.annotationIds(List.of(removeRedaction.getAnnotationId())) .annotationIds(List.of(removeRedaction.getAnnotationId()))
@ -148,6 +167,10 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
loadedRemoveRedaction = manualRedactionClient.getRemoveRedaction(file.getId(), addRedaction.getAnnotationId()); loadedRemoveRedaction = manualRedactionClient.getRemoveRedaction(file.getId(), addRedaction.getAnnotationId());
assertThat(loadedRemoveRedaction.getStatus()).isEqualTo(AnnotationStatus.DECLINED); assertThat(loadedRemoveRedaction.getStatus()).isEqualTo(AnnotationStatus.DECLINED);
fileManagementStorageService.storeObject(dossier.getId(), file.getId(), FileType.REDACTION_LOG, objectMapper.writeValueAsBytes(new RedactionLog(1, 1,
List.of(RedactionLogEntry.builder().id("annotationId").type("manual").value("value entry").build()),
null, 0, 0, 0, 0)));
var removeRedaction2 = manualRedactionClient.addRemoveRedaction(dossier.getId(), file.getId(), List.of(RemoveRedactionRequest.builder() var removeRedaction2 = manualRedactionClient.addRemoveRedaction(dossier.getId(), file.getId(), List.of(RemoveRedactionRequest.builder()
.annotationId("annotationId") .annotationId("annotationId")
.comment("comment") .comment("comment")