Resolve RED-8480 "2" #354
@ -59,9 +59,9 @@ import lombok.extern.slf4j.Slf4j;
|
||||
@FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE)
|
||||
public class ManualRedactionController implements ManualRedactionResource {
|
||||
|
||||
final static String FILE_ID = "fileId";
|
||||
final static String DOSSIER_ID = "dossierId";
|
||||
final static String ANNOTATION_ID = "annotationId";
|
||||
static final String FILE_ID = "fileId";
|
||||
static final String DOSSIER_ID = "dossierId";
|
||||
static final String ANNOTATION_ID = "annotationId";
|
||||
ManualRedactionService manualRedactionService;
|
||||
ManualRedactionUndoService manualRedactionUndoService;
|
||||
DossierManagementService dossierManagementService;
|
||||
|
||||
@ -47,6 +47,8 @@ public class ManualRecategorizationEntity implements IBaseAnnotation {
|
||||
private boolean addToDictionary;
|
||||
@Column
|
||||
private boolean addToAllDossiers;
|
||||
@Column(length = 4000)
|
||||
private String legalBasis;
|
||||
|
||||
@ManyToOne
|
||||
private FileEntity fileStatus;
|
||||
|
||||
@ -44,7 +44,7 @@ public class ManualRedactionEntryEntity implements IBaseAnnotation {
|
||||
private String value;
|
||||
@Column(length = 4000)
|
||||
private String reason;
|
||||
@Column
|
||||
@Column(length = 4000)
|
||||
private String legalBasis;
|
||||
@Column
|
||||
private String section;
|
||||
|
||||
@ -6,10 +6,10 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.iqser.red.service.persistence.management.v1.processor.exception.BadRequestException;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.exception.NotFoundException;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.EntityLogService;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.EntityLog;
|
||||
@ -49,7 +49,7 @@ public class ManualRedactionMapper {
|
||||
|
||||
return addRedactionRequests.stream()
|
||||
.map(addRedactionRequest -> toAddRedactionRequest(dossierId, dossier.getDossierTemplateId(), addRedactionRequest))
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
}
|
||||
|
||||
|
||||
@ -115,7 +115,7 @@ public class ManualRedactionMapper {
|
||||
.legalBasis(forceRedactionRequest.getLegalBasis())
|
||||
.comment(forceRedactionRequest.getComment())
|
||||
.build())
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
}
|
||||
|
||||
|
||||
@ -130,7 +130,7 @@ public class ManualRedactionMapper {
|
||||
.comment(legalBasisChangeRequest.getComment())
|
||||
.value(legalBasisChangeRequest.getValue())
|
||||
.build())
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
}
|
||||
|
||||
|
||||
@ -156,6 +156,7 @@ public class ManualRedactionMapper {
|
||||
.value(entityLogEntry.getValue())
|
||||
.typeToRemove(entityLogEntry.getType())
|
||||
.dossierTemplateTypeId(toTypeId(recategorizationRequest.getType(), dossierTemplateId))
|
||||
.legalBasis(recategorizationRequest.getLegalBasis())
|
||||
.build();
|
||||
requests.add(build);
|
||||
}
|
||||
@ -176,7 +177,7 @@ public class ManualRedactionMapper {
|
||||
.updateDictionary(resizeRedactionRequest.getUpdateDictionary())
|
||||
.addToAllDossiers(resizeRedactionRequest.isAddToAllDossiers())
|
||||
.build())
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -20,7 +20,7 @@ import com.iqser.red.service.persistence.management.v1.processor.service.persist
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.annotations.RecategorizationPersistenceService;
|
||||
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.iqser.red.service.persistence.management.v1.processor.utils.ManualImageRecategorizationMapper;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.utils.ManualRecategorizationMapper;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.utils.ManualRedactionMapper;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.utils.ManualResizeRedactionMapper;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.ManualRedactions;
|
||||
@ -70,7 +70,7 @@ public class ManualRedactionProviderService {
|
||||
forceRedactions = convert(forceRedactionPersistenceService.findUnprocessedForceRedactions(fileId), ManualForceRedaction.class);
|
||||
recategorizations = new HashSet<>(convert(recategorizationPersistenceService.findUnprocessedRecategorizations(fileId),
|
||||
ManualRecategorization.class,
|
||||
new ManualImageRecategorizationMapper()));
|
||||
new ManualRecategorizationMapper()));
|
||||
legalBasisChanges = convert(legalBasisChangePersistenceService.findUnprocessedLegalBasisChanges(fileId), ManualLegalBasisChange.class);
|
||||
resizeRedactions = new HashSet<>(convert(resizeRedactionPersistenceService.findUnprocessedResizeRedactions(fileId),
|
||||
ManualResizeRedaction.class,
|
||||
@ -81,7 +81,7 @@ public class ManualRedactionProviderService {
|
||||
forceRedactions = convert(forceRedactionPersistenceService.findForceRedactions(fileId, false), ManualForceRedaction.class);
|
||||
recategorizations = new HashSet<>(convert(recategorizationPersistenceService.findRecategorizations(fileId, false),
|
||||
ManualRecategorization.class,
|
||||
new ManualImageRecategorizationMapper()));
|
||||
new ManualRecategorizationMapper()));
|
||||
legalBasisChanges = convert(legalBasisChangePersistenceService.findLegalBasisChanges(fileId, false), ManualLegalBasisChange.class);
|
||||
resizeRedactions = new HashSet<>(convert(resizeRedactionPersistenceService.findResizeRedactions(fileId, false),
|
||||
ManualResizeRedaction.class,
|
||||
|
||||
@ -75,6 +75,8 @@ public class ManualRedactionService {
|
||||
EntityLogMergeService entityLogMergeService;
|
||||
FileStatusPersistenceService fileStatusPersistenceService;
|
||||
|
||||
private static final int MAX_LEGAL_BASIS_LENGTH = 4000;
|
||||
|
||||
|
||||
@Transactional
|
||||
@Observed(name = "ManualRedactionService", contextualName = "add-manual-redaction")
|
||||
@ -94,14 +96,15 @@ public class ManualRedactionService {
|
||||
manualRedactionEntryEntities.add(addRedactionPersistenceService.insert(fileId, annotationId, addRedactionRequest));
|
||||
|
||||
Set<String> typeIdsOfModifiedDictionaries = manualRedactionDictionaryUpdateHandler.handleAddToDictionaryAndReturnModifiedTypeIds(fileId,
|
||||
addRedactionRequest.getValue(),
|
||||
addRedactionRequest);
|
||||
addRedactionRequest.getValue(),
|
||||
addRedactionRequest);
|
||||
|
||||
addRedactionPersistenceService.updateModifiedDictionaries(fileId, annotationId, !typeIdsOfModifiedDictionaries.isEmpty(), typeIdsOfModifiedDictionaries);
|
||||
|
||||
Long commentId = commentService.addCommentAndGetId(fileId, annotationId, addRedactionRequest.getComment(), addRedactionRequest.getUser());
|
||||
|
||||
response.add(ManualAddResponse.builder().annotationId(annotationId).commentId(commentId).build());
|
||||
response.add(ManualAddResponse.builder().annotationId(annotationId).commentId(commentId)
|
||||
.build());
|
||||
}
|
||||
|
||||
manualRedactionEntryEntities = manualRedactionEntryEntities.stream()
|
||||
@ -110,7 +113,8 @@ public class ManualRedactionService {
|
||||
|
||||
FileModel fileStatus = fileStatusService.getStatus(fileId);
|
||||
if (!manualRedactionEntryEntities.isEmpty() && fileStatus.isExcludedFromAutomaticAnalysis()) {
|
||||
ManualRedactions manualRedactions = ManualRedactions.builder().entriesToAdd(convertEntriesToAdd(manualRedactionEntryEntities)).build();
|
||||
ManualRedactions manualRedactions = ManualRedactions.builder().entriesToAdd(convertEntriesToAdd(manualRedactionEntryEntities))
|
||||
.build();
|
||||
entityLogMergeService.sendToAnalyseQueue(fileId, dossierEntity, fileStatusService.getStatus(fileId), manualRedactions);
|
||||
} else {
|
||||
reprocess(dossierId, fileId);
|
||||
@ -123,7 +127,9 @@ public class ManualRedactionService {
|
||||
|
||||
private Set<ManualRedactionEntry> convertEntriesToAdd(List<ManualRedactionEntryEntity> source) {
|
||||
|
||||
return source.stream().map(entry -> convert(entry, ManualRedactionEntry.class, new ManualRedactionMapper())).collect(Collectors.toSet());
|
||||
return source.stream()
|
||||
.map(entry -> convert(entry, ManualRedactionEntry.class, new ManualRedactionMapper()))
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
|
||||
@ -135,27 +141,25 @@ public class ManualRedactionService {
|
||||
//validate removing from dossier template dictionary
|
||||
for (RemoveRedactionRequest removeRedactionRequest : removeRedactionRequests) {
|
||||
manualRedactionDictionaryUpdateHandler.validateDictionariesForDelete(removeRedactionRequest,
|
||||
removeRedactionRequest.getTypeToRemove(),
|
||||
removeRedactionRequest.getDossierTemplateId());
|
||||
removeRedactionRequest.getTypeToRemove(),
|
||||
removeRedactionRequest.getDossierTemplateId());
|
||||
|
||||
log.info("add removeRedaction for file {} and annotation {}", fileId, removeRedactionRequest.getAnnotationId());
|
||||
removeRedactionPersistenceService.insert(fileId, removeRedactionRequest);
|
||||
|
||||
Long commentId = commentService.addCommentAndGetId(fileId,
|
||||
removeRedactionRequest.getAnnotationId(),
|
||||
removeRedactionRequest.getComment(),
|
||||
removeRedactionRequest.getUser());
|
||||
removeRedactionRequest.getAnnotationId(),
|
||||
removeRedactionRequest.getComment(),
|
||||
removeRedactionRequest.getUser());
|
||||
|
||||
Set<String> typeIdsOfModifiedDictionaries = manualRedactionDictionaryUpdateHandler.handleRemoveFromDictionaryAndReturnModifiedTypeIds(fileId, removeRedactionRequest);
|
||||
|
||||
boolean removedFromDictionary = !typeIdsOfModifiedDictionaries.isEmpty();
|
||||
|
||||
removeRedactionPersistenceService.updateModifiedDictionaries(fileId,
|
||||
removeRedactionRequest.getAnnotationId(),
|
||||
removedFromDictionary,
|
||||
typeIdsOfModifiedDictionaries);
|
||||
removeRedactionPersistenceService.updateModifiedDictionaries(fileId, removeRedactionRequest.getAnnotationId(), removedFromDictionary, typeIdsOfModifiedDictionaries);
|
||||
|
||||
response.add(ManualAddResponse.builder().annotationId(removeRedactionRequest.getAnnotationId()).commentId(commentId).build());
|
||||
response.add(ManualAddResponse.builder().annotationId(removeRedactionRequest.getAnnotationId()).commentId(commentId)
|
||||
.build());
|
||||
}
|
||||
|
||||
reprocess(dossierId, fileId);
|
||||
@ -176,11 +180,12 @@ public class ManualRedactionService {
|
||||
forceRedactionPersistenceService.insert(fileId, forceRedactionRequest);
|
||||
|
||||
Long commentId = commentService.addCommentAndGetId(fileId,
|
||||
forceRedactionRequest.getAnnotationId(),
|
||||
forceRedactionRequest.getComment(),
|
||||
forceRedactionRequest.getUser());
|
||||
forceRedactionRequest.getAnnotationId(),
|
||||
forceRedactionRequest.getComment(),
|
||||
forceRedactionRequest.getUser());
|
||||
|
||||
response.add(ManualAddResponse.builder().annotationId(forceRedactionRequest.getAnnotationId()).commentId(commentId).build());
|
||||
response.add(ManualAddResponse.builder().annotationId(forceRedactionRequest.getAnnotationId()).commentId(commentId)
|
||||
.build());
|
||||
}
|
||||
|
||||
reprocess(dossierId, fileId);
|
||||
@ -201,11 +206,12 @@ public class ManualRedactionService {
|
||||
legalBasisChangePersistenceService.insert(fileId, legalBasisChangeRequest);
|
||||
|
||||
Long commentId = commentService.addCommentAndGetId(fileId,
|
||||
legalBasisChangeRequest.getAnnotationId(),
|
||||
legalBasisChangeRequest.getComment(),
|
||||
legalBasisChangeRequest.getUser());
|
||||
legalBasisChangeRequest.getAnnotationId(),
|
||||
legalBasisChangeRequest.getComment(),
|
||||
legalBasisChangeRequest.getUser());
|
||||
|
||||
response.add(ManualAddResponse.builder().annotationId(legalBasisChangeRequest.getAnnotationId()).commentId(commentId).build());
|
||||
response.add(ManualAddResponse.builder().annotationId(legalBasisChangeRequest.getAnnotationId()).commentId(commentId)
|
||||
.build());
|
||||
}
|
||||
reprocess(dossierId, fileId);
|
||||
fileStatusPersistenceService.setLastManualChangeDate(fileId, OffsetDateTime.now());
|
||||
@ -221,28 +227,31 @@ public class ManualRedactionService {
|
||||
for (var recategorizationRequest : recategorizationRequests) {
|
||||
manualRedactionDictionaryUpdateHandler.validateDictionariesForAdd(recategorizationRequest, recategorizationRequest.getValue());
|
||||
manualRedactionDictionaryUpdateHandler.validateDictionariesForDelete(recategorizationRequest,
|
||||
recategorizationRequest.getTypeToRemove(),
|
||||
recategorizationRequest.getDossierTemplateId());
|
||||
recategorizationRequest.getTypeToRemove(),
|
||||
recategorizationRequest.getDossierTemplateId());
|
||||
|
||||
checkLegalBasisLength(recategorizationRequest.getLegalBasis());
|
||||
|
||||
recategorizationPersistenceService.insert(fileId, recategorizationRequest);
|
||||
|
||||
Set<String> typeIdsOfDictionariesWithAdd = manualRedactionDictionaryUpdateHandler.handleAddToDictionaryAndReturnModifiedTypeIds(fileId,
|
||||
recategorizationRequest.getValue(),
|
||||
recategorizationRequest);
|
||||
recategorizationRequest.getValue(),
|
||||
recategorizationRequest);
|
||||
Set<String> typeIdsOfDictionariesWithDelete = manualRedactionDictionaryUpdateHandler.handleRemoveFromDictionaryAndReturnModifiedTypeIds(fileId,
|
||||
recategorizationRequest);
|
||||
recategorizationRequest);
|
||||
|
||||
recategorizationPersistenceService.updateModifiedDictionaries(fileId,
|
||||
recategorizationRequest.getAnnotationId(),
|
||||
typeIdsOfDictionariesWithAdd,
|
||||
typeIdsOfDictionariesWithDelete);
|
||||
recategorizationRequest.getAnnotationId(),
|
||||
typeIdsOfDictionariesWithAdd,
|
||||
typeIdsOfDictionariesWithDelete);
|
||||
|
||||
Long commentId = commentService.addCommentAndGetId(fileId,
|
||||
recategorizationRequest.getAnnotationId(),
|
||||
recategorizationRequest.getComment(),
|
||||
recategorizationRequest.getUser());
|
||||
recategorizationRequest.getAnnotationId(),
|
||||
recategorizationRequest.getComment(),
|
||||
recategorizationRequest.getUser());
|
||||
|
||||
response.add(ManualAddResponse.builder().annotationId(recategorizationRequest.getAnnotationId()).commentId(commentId).build());
|
||||
response.add(ManualAddResponse.builder().annotationId(recategorizationRequest.getAnnotationId()).commentId(commentId)
|
||||
.build());
|
||||
}
|
||||
reprocess(dossierId, fileId);
|
||||
|
||||
@ -252,6 +261,14 @@ public class ManualRedactionService {
|
||||
}
|
||||
|
||||
|
||||
private void checkLegalBasisLength(String legalBasis) {
|
||||
|
||||
if (legalBasis.length() > MAX_LEGAL_BASIS_LENGTH) {
|
||||
throw new BadRequestException(String.format("The legal basis is too long (%s), max length %s", legalBasis.length(), MAX_LEGAL_BASIS_LENGTH));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
@Observed(name = "ManualRedactionService", contextualName = "add-manual-redaction")
|
||||
public List<ManualAddResponse> addResizeRedaction(String dossierId, String fileId, List<ResizeRedactionRequest> resizeRedactionRequests, boolean includeUnprocessed) {
|
||||
@ -267,18 +284,23 @@ public class ManualRedactionService {
|
||||
|
||||
if (resizeRedactionRequest.getComment() != null) {
|
||||
Long commentId = commentService.addCommentAndGetId(fileId,
|
||||
resizeRedactionRequest.getAnnotationId(),
|
||||
resizeRedactionRequest.getComment(),
|
||||
resizeRedactionRequest.getUser());
|
||||
response.add(ManualAddResponse.builder().annotationId(resizeRedactionRequest.getAnnotationId()).commentId(commentId).build());
|
||||
resizeRedactionRequest.getAnnotationId(),
|
||||
resizeRedactionRequest.getComment(),
|
||||
resizeRedactionRequest.getUser());
|
||||
response.add(ManualAddResponse.builder().annotationId(resizeRedactionRequest.getAnnotationId()).commentId(commentId)
|
||||
.build());
|
||||
}
|
||||
|
||||
Set<String> typeIdsOfModifiedDictionaries = manualRedactionDictionaryUpdateHandler.updateDictionaryForResizeRedactions(dossierId,
|
||||
fileId,
|
||||
resizeRedaction,
|
||||
getEntityLogEntry(entityLog, resizeRedaction.getId().getAnnotationId()));
|
||||
fileId,
|
||||
resizeRedaction,
|
||||
getEntityLogEntry(entityLog,
|
||||
resizeRedaction.getId()
|
||||
.getAnnotationId()));
|
||||
|
||||
resizeRedactionPersistenceService.updateModifiedDictionaries(resizeRedaction.getId().getFileId(), resizeRedaction.getId().getAnnotationId(), typeIdsOfModifiedDictionaries);
|
||||
resizeRedactionPersistenceService.updateModifiedDictionaries(resizeRedaction.getId().getFileId(),
|
||||
resizeRedaction.getId().getAnnotationId(),
|
||||
typeIdsOfModifiedDictionaries);
|
||||
}
|
||||
|
||||
manualResizeRedactionEntities = manualResizeRedactionEntities.stream()
|
||||
@ -287,7 +309,8 @@ public class ManualRedactionService {
|
||||
|
||||
FileModel fileStatus = fileStatusService.getStatus(fileId);
|
||||
if (!manualResizeRedactionEntities.isEmpty() && fileStatus.isExcludedFromAutomaticAnalysis()) {
|
||||
ManualRedactions manualRedactions = ManualRedactions.builder().resizeRedactions(convertResizeRedactions(manualResizeRedactionEntities)).build();
|
||||
ManualRedactions manualRedactions = ManualRedactions.builder().resizeRedactions(convertResizeRedactions(manualResizeRedactionEntities))
|
||||
.build();
|
||||
entityLogMergeService.sendToAnalyseQueue(fileId, dossierPersistenceService.getAndValidateDossier(dossierId), fileStatusService.getStatus(fileId), manualRedactions);
|
||||
} else {
|
||||
reprocess(dossierId, fileId);
|
||||
@ -301,14 +324,20 @@ public class ManualRedactionService {
|
||||
|
||||
private Set<ManualResizeRedaction> convertResizeRedactions(List<ManualResizeRedactionEntity> source) {
|
||||
|
||||
return source.stream().map(entry -> convert(entry, ManualResizeRedaction.class, new ManualResizeRedactionMapper())).collect(Collectors.toSet());
|
||||
return source.stream()
|
||||
.map(entry -> convert(entry, ManualResizeRedaction.class, new ManualResizeRedactionMapper()))
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
|
||||
private void validatePositions(String fileId, AddRedactionRequest addRedactionRequest) {
|
||||
|
||||
var numberOfPages = fileStatusService.getStatus(fileId).getNumberOfPages();
|
||||
addRedactionRequest.getPositions().stream().filter(p -> p.getPage() > numberOfPages).findAny().ifPresent(p -> new BadRequestException("Invalid page found in the request"));
|
||||
addRedactionRequest.getPositions()
|
||||
.stream()
|
||||
.filter(p -> p.getPage() > numberOfPages)
|
||||
.findAny()
|
||||
.ifPresent(p -> new BadRequestException("Invalid page found in the request"));
|
||||
}
|
||||
|
||||
|
||||
@ -340,46 +369,52 @@ public class ManualRedactionService {
|
||||
if (manualRedactions != null) {
|
||||
|
||||
if (manualRedactions.getEntriesToAdd() != null) {
|
||||
manualRedactions.getEntriesToAdd().forEach(e -> {
|
||||
if (e.getProcessedDate() == null) {
|
||||
addRedactionPersistenceService.markAsProcessed(e);
|
||||
}
|
||||
});
|
||||
manualRedactions.getEntriesToAdd()
|
||||
.forEach(e -> {
|
||||
if (e.getProcessedDate() == null) {
|
||||
addRedactionPersistenceService.markAsProcessed(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (manualRedactions.getIdsToRemove() != null) {
|
||||
manualRedactions.getIdsToRemove().forEach(e -> {
|
||||
if (e.getProcessedDate() == null) {
|
||||
removeRedactionPersistenceService.markAsProcessed(e);
|
||||
}
|
||||
});
|
||||
manualRedactions.getIdsToRemove()
|
||||
.forEach(e -> {
|
||||
if (e.getProcessedDate() == null) {
|
||||
removeRedactionPersistenceService.markAsProcessed(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (manualRedactions.getForceRedactions() != null) {
|
||||
manualRedactions.getForceRedactions().forEach(e -> {
|
||||
if (e.getProcessedDate() == null) {
|
||||
forceRedactionPersistenceService.markAsProcessed(e.getAnnotationId(), e.getFileId());
|
||||
}
|
||||
});
|
||||
manualRedactions.getForceRedactions()
|
||||
.forEach(e -> {
|
||||
if (e.getProcessedDate() == null) {
|
||||
forceRedactionPersistenceService.markAsProcessed(e.getAnnotationId(), e.getFileId());
|
||||
}
|
||||
});
|
||||
}
|
||||
if (manualRedactions.getRecategorizations() != null) {
|
||||
manualRedactions.getRecategorizations().forEach(e -> {
|
||||
if (e.getProcessedDate() == null) {
|
||||
recategorizationPersistenceService.markAsProcessed(e.getAnnotationId(), e.getFileId());
|
||||
}
|
||||
});
|
||||
manualRedactions.getRecategorizations()
|
||||
.forEach(e -> {
|
||||
if (e.getProcessedDate() == null) {
|
||||
recategorizationPersistenceService.markAsProcessed(e.getAnnotationId(), e.getFileId());
|
||||
}
|
||||
});
|
||||
}
|
||||
if (manualRedactions.getResizeRedactions() != null) {
|
||||
manualRedactions.getResizeRedactions().forEach(e -> {
|
||||
if (e.getProcessedDate() == null) {
|
||||
resizeRedactionPersistenceService.markAsProcessed(e.getAnnotationId(), e.getFileId());
|
||||
}
|
||||
});
|
||||
manualRedactions.getResizeRedactions()
|
||||
.forEach(e -> {
|
||||
if (e.getProcessedDate() == null) {
|
||||
resizeRedactionPersistenceService.markAsProcessed(e.getAnnotationId(), e.getFileId());
|
||||
}
|
||||
});
|
||||
}
|
||||
if (manualRedactions.getLegalBasisChanges() != null) {
|
||||
manualRedactions.getLegalBasisChanges().forEach(e -> {
|
||||
if (e.getProcessedDate() == null) {
|
||||
legalBasisChangePersistenceService.markAsProcessed(e.getAnnotationId(), e.getFileId());
|
||||
}
|
||||
});
|
||||
manualRedactions.getLegalBasisChanges()
|
||||
.forEach(e -> {
|
||||
if (e.getProcessedDate() == null) {
|
||||
legalBasisChangePersistenceService.markAsProcessed(e.getAnnotationId(), e.getFileId());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,21 +28,18 @@ public class RecategorizationPersistenceService {
|
||||
|
||||
public void insert(String fileId, RecategorizationRequest recategorizationRequest) {
|
||||
|
||||
ManualRecategorizationEntity manualImageRecategorization = new ManualRecategorizationEntity();
|
||||
manualImageRecategorization.setId(new AnnotationEntityId(recategorizationRequest.getAnnotationId(), fileId));
|
||||
BeanUtils.copyProperties(recategorizationRequest, manualImageRecategorization);
|
||||
manualImageRecategorization.setRequestDate(OffsetDateTime.now());
|
||||
manualImageRecategorization.setTypeId(recategorizationRequest.getDossierTemplateTypeId());
|
||||
recategorizationRepository.saveAndFlush(manualImageRecategorization);
|
||||
ManualRecategorizationEntity manualRecategorization = new ManualRecategorizationEntity();
|
||||
manualRecategorization.setId(new AnnotationEntityId(recategorizationRequest.getAnnotationId(), fileId));
|
||||
BeanUtils.copyProperties(recategorizationRequest, manualRecategorization);
|
||||
manualRecategorization.setRequestDate(OffsetDateTime.now());
|
||||
manualRecategorization.setTypeId(recategorizationRequest.getDossierTemplateTypeId());
|
||||
recategorizationRepository.saveAndFlush(manualRecategorization);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Transactional
|
||||
public void updateModifiedDictionaries(String fileId,
|
||||
String annotationId, Set<String> typeIdsOfDictionaryWithAdd,
|
||||
Set<String> typeIdsOfDictionaryWithDelete) {
|
||||
public void updateModifiedDictionaries(String fileId, String annotationId, Set<String> typeIdsOfDictionaryWithAdd, Set<String> typeIdsOfDictionaryWithDelete) {
|
||||
|
||||
ManualRecategorizationEntity addRedaction = recategorizationRepository.findById(new AnnotationEntityId(annotationId, fileId))
|
||||
.orElseThrow(() -> new NotFoundException("Unknown file/annotation combination: " + fileId + "/" + annotationId));
|
||||
|
||||
@ -5,7 +5,7 @@ import java.util.function.BiConsumer;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.annotations.ManualRecategorizationEntity;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.entitymapped.ManualRecategorization;
|
||||
|
||||
public class ManualImageRecategorizationMapper implements BiConsumer<ManualRecategorizationEntity, ManualRecategorization> {
|
||||
public class ManualRecategorizationMapper implements BiConsumer<ManualRecategorizationEntity, ManualRecategorization> {
|
||||
|
||||
@Override
|
||||
public void accept(ManualRecategorizationEntity manualRecategorizationEntity, ManualRecategorization manualRedactionEntry) {
|
||||
@ -181,3 +181,5 @@ databaseChangeLog:
|
||||
file: db/changelog/tenant/118-delete-unapproved-manual-changes-and-drop-column-status.yaml
|
||||
- include:
|
||||
file: db/changelog/tenant/119-set-add-to-all-dossiers-correctly-in-manual-redaction-table.yaml
|
||||
- include:
|
||||
file: db/changelog/tenant/120-add-legal-basis-change-to-manual-recategorization.yaml
|
||||
|
||||
@ -0,0 +1,18 @@
|
||||
databaseChangeLog:
|
||||
- changeSet:
|
||||
id: add-legal-basis-change-to-manual-recategorization
|
||||
author: ali
|
||||
changes:
|
||||
- addColumn:
|
||||
tableName: manual_recategorization
|
||||
columns:
|
||||
- column:
|
||||
name: legal_basis
|
||||
type: VARCHAR(4000)
|
||||
defaultValue: ''
|
||||
constraints:
|
||||
nullable: false
|
||||
- modifyDataType:
|
||||
columnName: legal_basis
|
||||
newDataType: VARCHAR(4000)
|
||||
tableName: manual_redaction
|
||||
@ -416,7 +416,7 @@ public class FileTest extends AbstractPersistenceServerServiceTest {
|
||||
.build()));
|
||||
manualRedactionClient.recategorizeBulk(dossierId,
|
||||
fileId,
|
||||
Set.of(RecategorizationRequestModel.builder().annotationId(annotationId).comment("comment").type("new-type")
|
||||
Set.of(RecategorizationRequestModel.builder().annotationId(annotationId).comment("comment").type("new-type").legalBasis("")
|
||||
.build()),
|
||||
false);
|
||||
|
||||
@ -424,22 +424,22 @@ public class FileTest extends AbstractPersistenceServerServiceTest {
|
||||
|
||||
fileManagementClient.deleteFile(dossier.getId(), file.getId());
|
||||
var softDeletedFiles = fileClient.getSoftDeletedDossierStatus(dossier.getId());
|
||||
assertThat(softDeletedFiles.size()).isEqualTo(1);
|
||||
assertThat(softDeletedFiles).hasSize(1);
|
||||
var activeFiles = fileClient.getDossierStatus(dossier.getId());
|
||||
assertThat(activeFiles.size()).isEqualTo(0);
|
||||
assertThat(activeFiles).isEmpty();
|
||||
|
||||
fileManagementClient.restoreFiles(dossier.getId(), Sets.newHashSet(file.getId()));
|
||||
softDeletedFiles = fileClient.getSoftDeletedDossierStatus(dossier.getId());
|
||||
assertThat(softDeletedFiles.size()).isEqualTo(0);
|
||||
assertThat(softDeletedFiles).isEmpty();
|
||||
activeFiles = fileClient.getDossierStatus(dossier.getId());
|
||||
assertThat(activeFiles.size()).isEqualTo(1);
|
||||
assertThat(activeFiles).hasSize(1);
|
||||
|
||||
fileManagementClient.hardDeleteFiles(dossier.getId(), List.of(file.getId()));
|
||||
softDeletedFiles = fileClient.getSoftDeletedDossierStatus(dossier.getId());
|
||||
assertThat(softDeletedFiles.size()).isEqualTo(0);
|
||||
assertThat(softDeletedFiles).isEmpty();
|
||||
|
||||
activeFiles = fileClient.getDossierStatus(dossier.getId());
|
||||
assertThat(activeFiles.size()).isEqualTo(0);
|
||||
assertThat(activeFiles).isEmpty();
|
||||
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -28,6 +28,7 @@ public class RecategorizationRequest implements ManualRequestWithAddToDictionary
|
||||
boolean addToDictionary;
|
||||
boolean addToAllDossiers;
|
||||
private DictionaryEntryType dictionaryEntryType;
|
||||
String legalBasis;
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
@ -14,5 +14,6 @@ import lombok.experimental.SuperBuilder;
|
||||
public class ManualRecategorization extends BaseAnnotation {
|
||||
|
||||
private String type;
|
||||
private String legalBasis;
|
||||
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.NonNull;
|
||||
import lombok.experimental.FieldDefaults;
|
||||
|
||||
@Data
|
||||
@ -19,5 +20,7 @@ public class RecategorizationRequestModel {
|
||||
String comment;
|
||||
boolean addToDictionary;
|
||||
boolean addToAllDossiers;
|
||||
@NonNull
|
||||
String legalBasis;
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user