Merge branch 'RED-7384' into 'master'
RED-7384: migration fixes forward port Closes RED-7384 See merge request redactmanager/persistence-service!379
This commit is contained in:
commit
82ed6b0b05
@ -1,5 +1,6 @@
|
||||
package com.iqser.red.persistence.service.v1.external.api.impl.controller;
|
||||
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.migration.SaasMigrationStatusEntity;
|
||||
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.migration.SaasMigrationService;
|
||||
@ -18,6 +19,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.file.SaasMigrationStatus.*;
|
||||
|
||||
@ -47,10 +49,8 @@ public class MigrationStatusController implements MigrationStatusResource {
|
||||
|
||||
var filesInErrorState = saasMigrationStatusPersistenceService.findAllByStatus(ERROR);
|
||||
|
||||
Map<String, String> errorCauses = new HashMap<>();
|
||||
filesInErrorState.forEach(errorFile -> {
|
||||
errorCauses.put(errorFile.getFileId(), errorFile.getErrorCause());
|
||||
});
|
||||
var errorCauses = filesInErrorState.stream()
|
||||
.collect(Collectors.toMap(errorFile -> errorFile.getDossierId() + "/" + errorFile.getFileId(), SaasMigrationStatusEntity::getErrorCause));
|
||||
|
||||
return MigrationStatusResponse.builder().numberOfFilesToMigrate(numberOfFilesToMigrate).filesInStatus(filesInStatus).errorCauses(errorCauses).build();
|
||||
}
|
||||
|
||||
@ -92,14 +92,17 @@ public class SaasMigrationService implements TenantSyncService {
|
||||
.stream()
|
||||
.filter(dossier -> dossier.getHardDeletedTime() == null)
|
||||
.toList();
|
||||
|
||||
for (var dossier : dossiers) {
|
||||
var files = fileStatusPersistenceService.getStatusesForDossier(dossier.getId())
|
||||
.stream()
|
||||
.filter(file -> file.getHardDeletedTime() == null)
|
||||
.toList();
|
||||
|
||||
var migrationStati = saasMigrationStatusPersistenceService.findAll()
|
||||
.stream()
|
||||
.collect(Collectors.toMap(SaasMigrationStatusEntity::getFileId, SaasMigrationStatusEntity::getStatus));
|
||||
|
||||
for (var file : files) {
|
||||
if (notExistsOrError(file, migrationStati)) {
|
||||
// delete NER_ENTITIES since offsets depend on old document structure.
|
||||
|
||||
@ -24,10 +24,10 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.experimental.FieldDefaults;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE)
|
||||
@Slf4j
|
||||
public class EntityLogService {
|
||||
|
||||
FileManagementStorageService fileManagementStorageService;
|
||||
|
||||
@ -439,7 +439,7 @@ public class ManualRedactionService {
|
||||
.stream()
|
||||
.map(p -> MagicConverter.convert(p, RectangleEntity.class))
|
||||
.toList());
|
||||
manualRedactionEntryEntity.setRequestDate(file.getAdded());
|
||||
manualRedactionEntryEntity.setRequestDate(manualRedactionEntry.getRequestDate());
|
||||
manualRedactionEntryEntity.setFileStatus(file);
|
||||
return manualRedactionEntryEntity;
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ package com.iqser.red.service.persistence.management.v1.processor.service.manual
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -19,6 +20,7 @@ import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.entitymapped.ManualRecategorization;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.entitymapped.ManualRedactionEntry;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.entitymapped.ManualResizeRedaction;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.type.DictionaryEntryType;
|
||||
|
||||
@Service
|
||||
public class PendingDictionaryEntryFactory {
|
||||
@ -36,7 +38,8 @@ public class PendingDictionaryEntryFactory {
|
||||
.id(manualRedactionEntry.getAnnotationId())
|
||||
.value(manualRedactionEntry.getValue())
|
||||
.type(manualRedactionEntry.getType())
|
||||
.entryType(manualRedactionEntry.getDictionaryEntryType().toEntryType())
|
||||
.entryType(Optional.ofNullable(manualRedactionEntry.getDictionaryEntryType())
|
||||
.orElse(DictionaryEntryType.ENTRY).toEntryType())
|
||||
.state(EntryState.PENDING)
|
||||
.dictionaryEntry(manualRedactionEntry.isAddToDictionary())
|
||||
.dossierDictionaryEntry(manualRedactionEntry.isAddToDossierDictionary())
|
||||
|
||||
@ -185,3 +185,5 @@ databaseChangeLog:
|
||||
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
|
||||
- include:
|
||||
file: db/changelog/tenant/121-set-dictionary-entry-type-for-dictionary-adds-where-null.yaml
|
||||
|
||||
@ -0,0 +1,13 @@
|
||||
databaseChangeLog:
|
||||
- changeSet:
|
||||
id: set-dictionary-entry-type-for-dictionary-adds-where-null
|
||||
author: kilian
|
||||
|
||||
changes:
|
||||
- update:
|
||||
tableName: manual_redaction
|
||||
columns:
|
||||
- column:
|
||||
name: dictionary_entry_type
|
||||
value: 'ENTRY'
|
||||
where: "add_to_dictionary AND dictionary_entry_type IS NULL"
|
||||
@ -277,7 +277,7 @@ public class EntityLogMergeTest {
|
||||
.dictionaryEntry(true)
|
||||
.positions(positions)
|
||||
.build()),
|
||||
null,
|
||||
Collections.emptyList(),
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
@ -305,9 +305,11 @@ public class EntityLogMergeTest {
|
||||
.addToDossierDictionary(false)
|
||||
.fileId(fileId)
|
||||
.rectangle(false)
|
||||
.fileId("file")
|
||||
.requestDate(OffsetDateTime.now())
|
||||
.dictionaryEntryType(DictionaryEntryType.ENTRY)
|
||||
.type("manual")
|
||||
.user("User")
|
||||
.build(),
|
||||
ManualRedactionEntry.builder()
|
||||
.positions(List.of(new Rectangle(5f, 6f, 7f, 8f, 1)))
|
||||
@ -320,8 +322,10 @@ public class EntityLogMergeTest {
|
||||
.rectangle(true)
|
||||
.requestDate(OffsetDateTime.now())
|
||||
.type("manual")
|
||||
.user("User")
|
||||
.fileId("file")
|
||||
.build()))
|
||||
.idsToRemove(Set.of(IdRemoval.builder().annotationId(entryToRemoveId).requestDate(OffsetDateTime.now()).build()))
|
||||
.idsToRemove(Set.of(IdRemoval.builder().annotationId(entryToRemoveId).requestDate(OffsetDateTime.now()).user("user").fileId("file").build()))
|
||||
.resizeRedactions(Set.of(ManualResizeRedaction.builder()
|
||||
.fileId(fileId)
|
||||
.value("Random")
|
||||
@ -329,15 +333,26 @@ public class EntityLogMergeTest {
|
||||
.positions(positions)
|
||||
.requestDate(OffsetDateTime.now())
|
||||
.updateDictionary(false)
|
||||
.user("User")
|
||||
.fileId("file")
|
||||
.build()))
|
||||
.legalBasisChanges(Set.of(ManualLegalBasisChange.builder()
|
||||
.annotationId(entryLegalBasisId)
|
||||
.value("Random")
|
||||
.legalBasis("New legal basis")
|
||||
.user("User")
|
||||
.section("Section")
|
||||
.fileId("file")
|
||||
.requestDate(OffsetDateTime.now())
|
||||
.build()))
|
||||
.forceRedactions(Set.of(ManualForceRedaction.builder().annotationId(forceRedactionId).fileId(fileId).legalBasis("Force").requestDate(OffsetDateTime.now()).build()))
|
||||
.forceRedactions(Set.of(ManualForceRedaction.builder()
|
||||
.annotationId(forceRedactionId)
|
||||
.fileId(fileId)
|
||||
.legalBasis("Force")
|
||||
.requestDate(OffsetDateTime.now())
|
||||
.user("User")
|
||||
.fileId("file")
|
||||
.build()))
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@ -10,6 +10,7 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.NonNull;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
@Data
|
||||
@ -19,9 +20,13 @@ import lombok.experimental.SuperBuilder;
|
||||
@EqualsAndHashCode
|
||||
public abstract class BaseAnnotation {
|
||||
|
||||
@NonNull
|
||||
private String annotationId;
|
||||
@NonNull
|
||||
private String fileId;
|
||||
@NonNull
|
||||
private String user;
|
||||
@NonNull
|
||||
private OffsetDateTime requestDate;
|
||||
private OffsetDateTime processedDate;
|
||||
private OffsetDateTime softDeletedTime;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user