RED-10027 - Add DM migration
This commit is contained in:
parent
4feee24d69
commit
e1f1f11037
@ -0,0 +1,78 @@
|
|||||||
|
package com.iqser.red.service.persistence.management.v1.processor.migration.migrations;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.iqser.red.service.persistence.management.v1.processor.migration.Migration;
|
||||||
|
import com.iqser.red.service.persistence.management.v1.processor.migration.StorageToMongoCopyService;
|
||||||
|
import com.iqser.red.service.persistence.management.v1.processor.service.FileStatusService;
|
||||||
|
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.DossierPersistenceService;
|
||||||
|
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.FileStatusPersistenceService;
|
||||||
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.file.WorkflowStatus;
|
||||||
|
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Setter
|
||||||
|
@Service
|
||||||
|
public class DocumineHeadlineDetectionMigration21 extends Migration {
|
||||||
|
|
||||||
|
private static final String NAME = "Reanalyse not approved Documine files after new headline detection";
|
||||||
|
private static final long VERSION = 21;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private FileStatusService fileStatusService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DossierPersistenceService dossierPersistenceService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private FileStatusPersistenceService fileStatusPersistenceService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private StorageToMongoCopyService storageToMongoCopyService;
|
||||||
|
|
||||||
|
@Value("${application.type}")
|
||||||
|
private String applicationType;
|
||||||
|
|
||||||
|
|
||||||
|
public DocumineHeadlineDetectionMigration21() {
|
||||||
|
|
||||||
|
super(NAME, VERSION);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void migrate() {
|
||||||
|
|
||||||
|
log.info("Starting migration DocumineHeadlineDetectionMigration21");
|
||||||
|
|
||||||
|
if (!applicationType.equalsIgnoreCase("DocuMine")) {
|
||||||
|
log.info("Skipping DocumineHeadlineDetectionMigration21 as application type is not DocuMine!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("Migration: Copying all files for all dossiers to mongodb");
|
||||||
|
storageToMongoCopyService.copyEntityLogs();
|
||||||
|
log.info("Migration: Finished Mongo db migration");
|
||||||
|
|
||||||
|
var dossiers = dossierPersistenceService.findAllDossiers();
|
||||||
|
dossiers.forEach(dossier -> {
|
||||||
|
if (dossier.getHardDeletedTime() == null) {
|
||||||
|
var files = fileStatusPersistenceService.getStatusesForDossier(dossier.getId());
|
||||||
|
log.info("Start migration of dossier {}", dossier.getId());
|
||||||
|
files.forEach(file -> {
|
||||||
|
if (file.getHardDeletedTime() == null && !file.getWorkflowStatus().equals(WorkflowStatus.APPROVED)) {
|
||||||
|
log.info("Set full reanalyse for file {}", file.getId());
|
||||||
|
fileStatusService.setStatusFullReprocess(dossier.getId(), file.getId(), false, true);
|
||||||
|
log.info("Finished migration of file {}", file.getId());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
log.info("Finished migration of dossier {}", dossier.getId());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user