migration fixes

This commit is contained in:
Efstratios Giannopoulos 2024-07-01 18:22:22 +03:00
parent 819ede9aa1
commit c6a6f26275
1 changed files with 8 additions and 1 deletions

View File

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