Merge branch 'RED-7384' into 'master'

RED-7384:dont mgirate non-changing annotation Ids

Closes RED-7384

See merge request redactmanager/persistence-service!330
This commit is contained in:
Kilian Schüttler 2024-02-02 10:10:02 +01:00
commit f7b80f2e61

View File

@ -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);
}