From 3d81c7fc16af50b3c5d524b7b6c674d2ae5a870e Mon Sep 17 00:00:00 2001 From: Kilian Schuettler Date: Thu, 11 Jan 2024 19:04:32 +0100 Subject: [PATCH] RED-7384: fix migration issues --- .../migration/LegacyRedactionLogMergeService.java | 11 ++++++----- .../RedactionLogToEntityLogMigrationService.java | 13 +------------ 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/migration/LegacyRedactionLogMergeService.java b/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/migration/LegacyRedactionLogMergeService.java index 7098e491..1858d3eb 100644 --- a/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/migration/LegacyRedactionLogMergeService.java +++ b/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/migration/LegacyRedactionLogMergeService.java @@ -12,6 +12,7 @@ import org.springframework.stereotype.Service; import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.AnnotationStatus; import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.ManualRedactions; +import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.entitymapped.BaseAnnotation; import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.entitymapped.IdRemoval; import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.entitymapped.ManualForceRedaction; import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.entitymapped.ManualLegalBasisChange; @@ -91,31 +92,31 @@ public class LegacyRedactionLogMergeService { List manualRedactionWrappers = new ArrayList<>(); - manualRedactions.getRecategorizations().forEach(item -> { + manualRedactions.getRecategorizations().stream().filter(BaseAnnotation::isApproved).forEach(item -> { if (item.getSoftDeletedTime() == null) { manualRedactionWrappers.add(new ManualRedactionWrapper(item.getAnnotationId(), item.getRequestDate(), item)); } }); - manualRedactions.getIdsToRemove().forEach(item -> { + manualRedactions.getIdsToRemove().stream().filter(BaseAnnotation::isApproved).forEach(item -> { if (item.getSoftDeletedTime() == null) { manualRedactionWrappers.add(new ManualRedactionWrapper(item.getAnnotationId(), item.getRequestDate(), item)); } }); - manualRedactions.getForceRedactions().forEach(item -> { + manualRedactions.getForceRedactions().stream().filter(BaseAnnotation::isApproved).forEach(item -> { if (item.getSoftDeletedTime() == null) { manualRedactionWrappers.add(new ManualRedactionWrapper(item.getAnnotationId(), item.getRequestDate(), item)); } }); - manualRedactions.getLegalBasisChanges().forEach(item -> { + manualRedactions.getLegalBasisChanges().stream().filter(BaseAnnotation::isApproved).forEach(item -> { if (item.getSoftDeletedTime() == null) { manualRedactionWrappers.add(new ManualRedactionWrapper(item.getAnnotationId(), item.getRequestDate(), item)); } }); - manualRedactions.getResizeRedactions().forEach(item -> { + manualRedactions.getResizeRedactions().stream().filter(BaseAnnotation::isApproved).forEach(item -> { if (item.getSoftDeletedTime() == null) { manualRedactionWrappers.add(new ManualRedactionWrapper(item.getAnnotationId(), item.getRequestDate(), item)); } diff --git a/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/migration/RedactionLogToEntityLogMigrationService.java b/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/migration/RedactionLogToEntityLogMigrationService.java index c22db8bf..cf4be6d3 100644 --- a/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/migration/RedactionLogToEntityLogMigrationService.java +++ b/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/migration/RedactionLogToEntityLogMigrationService.java @@ -87,12 +87,7 @@ public class RedactionLogToEntityLogMigrationService { private static long getNumberOfApprovedEntries(RedactionLog redactionLog) { - return redactionLog.getRedactionLogEntry() - .stream() - .filter(redactionLogEntry -> redactionLogEntry.getManualChanges() == null || redactionLogEntry.getManualChanges() - .stream() - .allMatch(manualChange -> manualChange.getAnnotationStatus().equals(AnnotationStatus.APPROVED))) - .count(); + return redactionLog.getRedactionLogEntry().size(); } @@ -117,9 +112,6 @@ public class RedactionLogToEntityLogMigrationService { List redactionLogImages = redactionLog.getRedactionLogEntry() .stream() .filter(RedactionLogEntry::isImage) - .filter(redactionLogEntry -> redactionLogEntry.getManualChanges() == null || redactionLogEntry.getManualChanges() - .stream() - .allMatch(manualChange -> manualChange.getAnnotationStatus().equals(AnnotationStatus.APPROVED))) .toList(); List migrationEntities = new LinkedList<>(); @@ -182,9 +174,6 @@ public class RedactionLogToEntityLogMigrationService { List entitiesToMigrate = redactionLog.getRedactionLogEntry() .stream() .filter(redactionLogEntry -> !redactionLogEntry.isImage()) - .filter(redactionLogEntry -> redactionLogEntry.getManualChanges() == null || redactionLogEntry.getManualChanges() - .stream() - .allMatch(manualChange -> manualChange.getAnnotationStatus().equals(AnnotationStatus.APPROVED))) .map(MigrationEntity::fromRedactionLogEntry) .peek(migrationEntity -> { if (migrationEntity.getRedactionLogEntry().lastChangeIsRemoved()) { -- 2.47.2