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();