From c6a6f2627529c3a0921cbbd2fbcca06857dc077c Mon Sep 17 00:00:00 2001 From: sgiannopoulos Date: Mon, 1 Jul 2024 18:22:22 +0300 Subject: [PATCH] migration fixes --- .../eu/old/eudat/migration/DatasetMigrationService.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/DatasetMigrationService.java b/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/DatasetMigrationService.java index 78fbd6fb3..d7125f5e7 100644 --- a/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/DatasetMigrationService.java +++ b/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/DatasetMigrationService.java @@ -1090,7 +1090,13 @@ public class DatasetMigrationService { UUID existingTagId = savedTagIdsByName.getOrDefault(new TagKey(dataset, tag), null); if (existingTagId != null) return existingTagId; TagEntity tagEntity = new TagEntity(); - if (!existingTagIds.contains(UUID.fromString(tag.getId()))) tagEntity.setId(UUID.fromString(tag.getId())); + UUID tagId; + try{ + tagId = UUID.fromString(tag.getId()); + } catch (Exception e){ + tagId = UUID.randomUUID(); + } + if (!existingTagIds.contains(tagId)) tagEntity.setId(tagId); else tagEntity.setId(UUID.randomUUID()); tagEntity.setLabel(tag.getName()); tagEntity.setCreatedAt(Instant.now()); @@ -1098,6 +1104,7 @@ public class DatasetMigrationService { if (dataset.getCreator() != null) tagEntity.setCreatedById(dataset.getCreator().getId()); tagEntity.setIsActive(IsActive.Active); savedTagIdsByName.put(new TagKey(dataset, tag), tagEntity.getId()); + existingTagIds.add(tagEntity.getId()); this.entityManager.persist(tagEntity); this.entityManager.flush();