Merge branch 'RED-8561-bp' into 'release/2.349.x'

RED-8561: added sql query to create entities for dossier dictionaries

See merge request redactmanager/persistence-service!377
This commit is contained in:
Kilian Schüttler 2024-03-07 16:25:19 +01:00
commit ba574e8d15
15 changed files with 993 additions and 671 deletions

View File

@ -60,9 +60,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;

View File

@ -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;

View File

@ -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;

View File

@ -5,11 +5,12 @@ import static com.iqser.red.service.persistence.management.v1.processor.utils.Ty
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
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 +50,7 @@ public class ManualRedactionMapper {
return addRedactionRequests.stream()
.map(addRedactionRequest -> toAddRedactionRequest(dossierId, dossier.getDossierTemplateId(), addRedactionRequest))
.collect(Collectors.toList());
.toList();
}
@ -115,7 +116,7 @@ public class ManualRedactionMapper {
.legalBasis(forceRedactionRequest.getLegalBasis())
.comment(forceRedactionRequest.getComment())
.build())
.collect(Collectors.toList());
.toList();
}
@ -130,7 +131,7 @@ public class ManualRedactionMapper {
.comment(legalBasisChangeRequest.getComment())
.value(legalBasisChangeRequest.getValue())
.build())
.collect(Collectors.toList());
.toList();
}
@ -156,6 +157,7 @@ public class ManualRedactionMapper {
.value(entityLogEntry.getValue())
.typeToRemove(entityLogEntry.getType())
.dossierTemplateTypeId(toTypeId(recategorizationRequest.getType(), dossierTemplateId))
.legalBasis(Optional.ofNullable(recategorizationRequest.getLegalBasis()).orElse(""))
.build();
requests.add(build);
}
@ -176,7 +178,7 @@ public class ManualRedactionMapper {
.updateDictionary(resizeRedactionRequest.getUpdateDictionary())
.addToAllDossiers(resizeRedactionRequest.isAddToAllDossiers())
.build())
.collect(Collectors.toList());
.toList();
}

View File

@ -4,16 +4,13 @@ import static com.knecon.fforesight.databasetenantcommons.providers.utils.MagicC
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import com.iqser.red.service.persistence.management.v1.processor.entity.annotations.ManualRedactionEntryEntity;
import com.iqser.red.service.persistence.management.v1.processor.model.ManualChangesQueryOptions;
import com.iqser.red.service.persistence.management.v1.processor.service.CommentService;
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.annotations.AddRedactionPersistenceService;
@ -22,7 +19,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;
@ -71,7 +68,7 @@ public class ManualRedactionProviderService {
if (!options.getExcludedClasses().contains(ManualRecategorization.class)) {
recategorizations = new HashSet<>(convert(recategorizationPersistenceService.findEntriesByFileIdAndOptions(fileId, options),
ManualRecategorization.class,
new ManualImageRecategorizationMapper()));
new ManualRecategorizationMapper()));
} else {
recategorizations = Collections.emptySet();
}

View File

@ -80,6 +80,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")
@ -99,14 +101,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());
}
var localManualRedactionEntryEntities = manualRedactionEntryEntities.stream()
@ -115,7 +118,8 @@ public class ManualRedactionService {
FileModel fileStatus = fileStatusService.getStatus(fileId);
if (!localManualRedactionEntryEntities.isEmpty() && fileStatus.isExcludedFromAutomaticAnalysis()) {
ManualRedactions manualRedactions = ManualRedactions.builder().entriesToAdd(convertEntriesToAdd(localManualRedactionEntryEntities)).build();
ManualRedactions manualRedactions = ManualRedactions.builder().entriesToAdd(convertEntriesToAdd(localManualRedactionEntryEntities))
.build();
entityLogMergeService.sendToAnalyseQueue(fileId, dossierEntity, fileStatusService.getStatus(fileId), manualRedactions);
} else {
reprocess(dossierId, fileId);
@ -128,7 +132,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());
}
@ -140,27 +146,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);
@ -181,11 +185,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);
@ -206,11 +211,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());
@ -226,28 +232,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);
@ -257,6 +266,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) {
@ -272,18 +289,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()
@ -292,7 +314,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);
@ -306,14 +329,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"));
}
@ -345,41 +374,47 @@ public class ManualRedactionService {
if (manualRedactions != null) {
manualRedactions.getEntriesToAdd().forEach(e -> {
if (e.getProcessedDate() == null) {
addRedactionPersistenceService.markAsProcessed(e);
}
});
manualRedactions.getEntriesToAdd()
.forEach(e -> {
if (e.getProcessedDate() == null) {
addRedactionPersistenceService.markAsProcessed(e);
}
});
manualRedactions.getIdsToRemove().forEach(e -> {
if (e.getProcessedDate() == null) {
removeRedactionPersistenceService.markAsProcessed(e);
}
});
manualRedactions.getIdsToRemove()
.forEach(e -> {
if (e.getProcessedDate() == null) {
removeRedactionPersistenceService.markAsProcessed(e);
}
});
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());
}
});
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());
}
});
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());
}
});
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());
}
});
}
}

View File

@ -29,21 +29,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));

View File

@ -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) {

View File

@ -181,3 +181,7 @@ 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
- include:
file: db/changelog/tenant/sql/205-add-dossier-dictionaries-as-entity.sql

View File

@ -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

View File

@ -0,0 +1,12 @@
INSERT INTO entity (id, add_to_dictionary_action, description, dossier_id, dossier_template_id, hex_color, is_case_insensitive, is_hint, is_recommendation,
label, rank, type, version, recommendation_hex_color, has_dictionary, system_managed, auto_hide_skipped, soft_deleted_time, skipped_hex_color,
dossier_dictionary_only)
SELECT (SELECT trim(trailing ':' from trim(trailing e.dossier_id from e.id))), TRUE, e.description, NULL, e.dossier_template_id, e.hex_color, e.is_case_insensitive, e.is_hint, e.is_recommendation,
e.label, e.rank, e.type, e.version, e.recommendation_hex_color, e.has_dictionary, e.system_managed, e.auto_hide_skipped, e.soft_deleted_time, e.skipped_hex_color,
TRUE
FROM entity e
WHERE (SELECT trim(trailing ':' from trim(trailing e.dossier_id from e.id))) IS NOT NULL AND (SELECT substr(e.id, POSITION(':' IN e.id) + POSITION(':' IN substr(e.id, POSITION(':' IN e.id) + 1)) + 1)) = '' IS FALSE;
UPDATE entity
SET dossier_dictionary_only = TRUE, add_to_dictionary_action = TRUE
WHERE starts_with(id, (SELECT trim(trailing ':' from trim(trailing dossier_id from id))));

View File

@ -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();
}

View File

@ -28,6 +28,7 @@ public class RecategorizationRequest implements ManualRequestWithAddToDictionary
boolean addToDictionary;
boolean addToAllDossiers;
private DictionaryEntryType dictionaryEntryType;
String legalBasis;
@Override

View File

@ -19,5 +19,6 @@ public class RecategorizationRequestModel {
String comment;
boolean addToDictionary;
boolean addToAllDossiers;
String legalBasis;
}