RED-3880: Added logs in migration that deletes false_positives from redactionLog
This commit is contained in:
parent
c7dbcac966
commit
3a2058367f
@ -12,7 +12,9 @@ import com.iqser.red.service.persistence.management.v1.processor.service.persist
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.file.FileType;
|
||||
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
@Setter
|
||||
@Service
|
||||
public class DictionaryToEntityMigration2 extends Migration {
|
||||
@ -32,6 +34,7 @@ public class DictionaryToEntityMigration2 extends Migration {
|
||||
@Autowired
|
||||
private ObjectMapper objectMapper;
|
||||
|
||||
|
||||
public DictionaryToEntityMigration2() {
|
||||
|
||||
super(NAME, VERSION);
|
||||
@ -40,22 +43,31 @@ public class DictionaryToEntityMigration2 extends Migration {
|
||||
|
||||
@Override
|
||||
protected void migrate() {
|
||||
|
||||
log.info("in migrate of DictionaryToEntityMigration2");
|
||||
|
||||
var dossiers = dossierPersistenceService.findAllDossiers();
|
||||
log.info("dossiers are: {}", dossiers);
|
||||
dossiers.forEach(dossier -> {
|
||||
var files = fileStatusPersistenceService.getStatusesForDossier(dossier.getId());
|
||||
log.info("files in dossier {} are: {}", dossier.getId(), files);
|
||||
files.forEach(file -> {
|
||||
if(file.getDeleted() == null){
|
||||
log.info("Files is currently: {}", file);
|
||||
if (file.getDeleted() == null) {
|
||||
var redactionLog = fileManagementStorageService.getRedactionLog(dossier.getId(), file.getId());
|
||||
redactionLog.setAnalysisVersion(2);
|
||||
redactionLog.getRedactionLogEntry().removeIf(entry -> entry.getType().equals("false_positive"));
|
||||
var remIf = redactionLog.getRedactionLogEntry().removeIf(entry -> entry.getType().equals("false_positive"));
|
||||
log.info("remIf returned {}", remIf);
|
||||
redactionLog.getRedactionLogEntry().forEach(entry -> {
|
||||
if(entry.getType().startsWith("recommendation_")){
|
||||
if (entry.getType().startsWith("recommendation_")) {
|
||||
entry.setType(entry.getType().substring(15));
|
||||
entry.setRecommendation(true);
|
||||
log.info("removed _recommendation");
|
||||
}
|
||||
});
|
||||
try {
|
||||
fileManagementStorageService.storeObject(dossier.getId(), file.getId(), FileType.REDACTION_LOG, objectMapper.writeValueAsBytes(redactionLog));
|
||||
log.info("Stored dossierId: {} and fileId: {}", dossier.getId(), file.getId());
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException("Migration failed");
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user