From 498cfecf885595b7305dcb6002ecfaa63d97092e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kilian=20Sch=C3=BCttler?= Date: Fri, 2 Feb 2024 10:10:02 +0100 Subject: [PATCH] RED-7384:dont mgirate non-changing annotation Ids --- .../SaasAnnotationIdMigrationService.java | 33 +++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/migration/SaasAnnotationIdMigrationService.java b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/migration/SaasAnnotationIdMigrationService.java index f9fa0ec93..b6d08c9f7 100644 --- a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/migration/SaasAnnotationIdMigrationService.java +++ b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/migration/SaasAnnotationIdMigrationService.java @@ -33,6 +33,9 @@ public class SaasAnnotationIdMigrationService { public int updateManualAddRedaction(AnnotationEntityId oldAnnotationEntityId, AnnotationEntityId newAnnotationEntityId) { + if (oldAnnotationEntityId.equals(newAnnotationEntityId)) { + return 0; + } var oldEntry = manualRedactionRepository.findById(oldAnnotationEntityId); if (oldEntry.isPresent()) { @@ -41,8 +44,8 @@ public class SaasAnnotationIdMigrationService { newEntry.setFileStatus(fileRepository.findById(oldAnnotationEntityId.getFileId()).get()); newEntry.setId(newAnnotationEntityId); - manualRedactionRepository.save(newEntry); manualRedactionRepository.deleteById(oldAnnotationEntityId); + manualRedactionRepository.save(newEntry); return 1; } return 0; @@ -51,6 +54,9 @@ public class SaasAnnotationIdMigrationService { public int updateRemoveRedaction(AnnotationEntityId oldAnnotationEntityId, AnnotationEntityId newAnnotationEntityId) { + if (oldAnnotationEntityId.equals(newAnnotationEntityId)) { + return 0; + } var oldEntry = removeRedactionRepository.findById(oldAnnotationEntityId); if (oldEntry.isPresent()) { @@ -58,8 +64,8 @@ public class SaasAnnotationIdMigrationService { newEntry.setFileStatus(fileRepository.findById(oldAnnotationEntityId.getFileId()).get()); newEntry.setId(newAnnotationEntityId); - removeRedactionRepository.save(newEntry); removeRedactionRepository.deleteById(oldAnnotationEntityId); + removeRedactionRepository.save(newEntry); return 1; } return 0; @@ -68,6 +74,9 @@ public class SaasAnnotationIdMigrationService { public int updateForceRedaction(AnnotationEntityId oldAnnotationEntityId, AnnotationEntityId newAnnotationEntityId) { + if (oldAnnotationEntityId.equals(newAnnotationEntityId)) { + return 0; + } var oldEntry = forceRedactionRepository.findById(oldAnnotationEntityId); if (oldEntry.isPresent()) { @@ -75,8 +84,8 @@ public class SaasAnnotationIdMigrationService { newEntry.setFileStatus(fileRepository.findById(oldAnnotationEntityId.getFileId()).get()); newEntry.setId(newAnnotationEntityId); - forceRedactionRepository.save(newEntry); forceRedactionRepository.deleteById(oldAnnotationEntityId); + forceRedactionRepository.save(newEntry); return 1; } return 0; @@ -85,6 +94,9 @@ public class SaasAnnotationIdMigrationService { public int updateResizeRedaction(AnnotationEntityId oldAnnotationEntityId, AnnotationEntityId newAnnotationEntityId) { + if (oldAnnotationEntityId.equals(newAnnotationEntityId)) { + return 0; + } var oldEntry = resizeRedactionRepository.findById(oldAnnotationEntityId); if (oldEntry.isPresent()) { @@ -93,8 +105,8 @@ public class SaasAnnotationIdMigrationService { newEntry.setPositions(MagicConverter.convert(oldEntry.get().getPositions(), RectangleEntity.class)); newEntry.setFileStatus(fileRepository.findById(oldAnnotationEntityId.getFileId()).get()); - resizeRedactionRepository.save(newEntry); resizeRedactionRepository.deleteById(oldAnnotationEntityId); + resizeRedactionRepository.save(newEntry); return 1; } return 0; @@ -103,6 +115,9 @@ public class SaasAnnotationIdMigrationService { public int updateRecategorizationRedaction(AnnotationEntityId oldAnnotationEntityId, AnnotationEntityId newAnnotationEntityId) { + if (oldAnnotationEntityId.equals(newAnnotationEntityId)) { + return 0; + } var oldEntry = recategorizationRepository.findById(oldAnnotationEntityId); if (oldEntry.isPresent()) { @@ -110,8 +125,8 @@ public class SaasAnnotationIdMigrationService { newEntry.setId(newAnnotationEntityId); newEntry.setFileStatus(fileRepository.findById(oldAnnotationEntityId.getFileId()).get()); - recategorizationRepository.save(newEntry); recategorizationRepository.deleteById(oldAnnotationEntityId); + recategorizationRepository.save(newEntry); return 1; } return 0; @@ -120,6 +135,9 @@ public class SaasAnnotationIdMigrationService { public int updateLegalBasisChangeRedaction(AnnotationEntityId oldAnnotationEntityId, AnnotationEntityId newAnnotationEntityId) { + if (oldAnnotationEntityId.equals(newAnnotationEntityId)) { + return 0; + } var oldEntry = legalBasisChangeRepository.findById(oldAnnotationEntityId); if (oldEntry.isPresent()) { @@ -127,8 +145,8 @@ public class SaasAnnotationIdMigrationService { newEntry.setId(newAnnotationEntityId); newEntry.setFileStatus(fileRepository.findById(oldAnnotationEntityId.getFileId()).get()); - legalBasisChangeRepository.save(newEntry); legalBasisChangeRepository.deleteById(oldAnnotationEntityId); + legalBasisChangeRepository.save(newEntry); return 1; } return 0; @@ -137,6 +155,9 @@ public class SaasAnnotationIdMigrationService { public int updateCommentIds(String fileId, String key, String value) { + if (key.equals(value)) { + return 0; + } return commentRepository.saasMigrationUpdateAnnotationIds(fileId, key, value); }