diff --git a/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/DataRepositoryMigrationService.java b/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/DataRepositoryMigrationService.java index 12cc8a250..faa568173 100644 --- a/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/DataRepositoryMigrationService.java +++ b/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/DataRepositoryMigrationService.java @@ -51,10 +51,14 @@ public class DataRepositoryMigrationService { logger.debug("Migrate DataRepository " + page * PageSize + " of " + total); for (DataRepository item : items) { entityManager.detach(item); - if (item.getReference() == null || !item.getReference().contains(":")){ + if (item.getReference() == null || item.getReference().isBlank()){ logger.warn("Reference generated because is null DataRepository " + item.getId()); item.setReference(InternalReferenceSource + ":" + item.getId().toString().replace("-", "").toLowerCase(Locale.ROOT)); } + if (!item.getReference().contains(":")){ + logger.warn("Reference generated because is not contains ':' DataRepository " + item.getId() + " reference " + item.getReference()); + item.setReference(InternalReferenceSource + ":" + item.getId().toString().replace("-", "").toLowerCase(Locale.ROOT)); + } eu.old.eudat.models.data.datarepository.DataRepositoryModel model = new eu.old.eudat.models.data.datarepository.DataRepositoryModel().fromDataModel(item); String[] referenceParts = item.getReference().split(":", 2); 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 947a4d51c..8167773f1 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 @@ -1,5 +1,6 @@ package eu.old.eudat.migration; +import eu.old.eudat.data.entities.DMP; import org.opencdmp.commons.JsonHandlingService; import org.opencdmp.commons.XmlHandlingService; import org.opencdmp.commons.enums.*; @@ -194,7 +195,8 @@ public class DatasetMigrationService { private List getOrCreateDmpDescriptionTemplateEntity(Dataset item, UUID sectionId, UUID groupId, List dmpDescriptionTemplateEntities){ List itemDescriptionTemplates = dmpDescriptionTemplateEntities.stream().filter(x-> x.getDescriptionTemplateGroupId().equals(groupId) && x.getDmpId().equals(item.getDmp().getId()) && x.getSectionId().equals(sectionId)).toList(); if (itemDescriptionTemplates.isEmpty()) { - if (!item.getStatus().equals(Dataset.Status.DELETED.getValue())) logger.warn("Migrate Dataset " + item.getId() + " cannot found DmpDescriptionTemplateEntity for section " + item.getDmpSectionIndex()); + boolean isDeleted = item.getStatus().equals(Dataset.Status.CANCELED.getValue()) ||item.getStatus().equals(Dataset.Status.DELETED.getValue()) || item.getDmp().getStatus().equals(DMP.DMPStatus.DELETED.getValue()); + if (!isDeleted) logger.warn("Migrate Dataset " + item.getId() + " cannot found DmpDescriptionTemplateEntity for section " + item.getDmpSectionIndex()); if (dmpDescriptionTemplateEntities.stream().anyMatch(x -> x.getDmpId().equals(item.getDmp().getId()) && x.getSectionId().equals(sectionId))) { DmpDescriptionTemplateEntity dmpDescriptionTemplateEntity = new DmpDescriptionTemplateEntity(); dmpDescriptionTemplateEntity.setId(UUID.randomUUID()); @@ -203,7 +205,7 @@ public class DatasetMigrationService { dmpDescriptionTemplateEntity.setCreatedAt(item.getCreated() != null ? item.getCreated().toInstant() : Instant.now()); dmpDescriptionTemplateEntity.setUpdatedAt(item.getModified() != null ? item.getModified().toInstant() : Instant.now()); dmpDescriptionTemplateEntity.setSectionId(sectionId); - dmpDescriptionTemplateEntity.setIsActive(!item.getStatus().equals(Dataset.Status.DELETED.getValue()) ? IsActive.Active : IsActive.Inactive); + dmpDescriptionTemplateEntity.setIsActive(!isDeleted ? IsActive.Active : IsActive.Inactive); this.entityManager.persist(dmpDescriptionTemplateEntity); this.entityManager.flush(); itemDescriptionTemplates = List.of(dmpDescriptionTemplateEntity); diff --git a/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/ExternalDatasetMigrationService.java b/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/ExternalDatasetMigrationService.java index 82f496e36..bc9e07d38 100644 --- a/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/ExternalDatasetMigrationService.java +++ b/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/ExternalDatasetMigrationService.java @@ -40,10 +40,14 @@ public class ExternalDatasetMigrationService { logger.debug("Migrate ExternalDataset " + page * PageSize + " of " + total); for (ExternalDataset item : items) { entityManager.detach(item); - if (item.getReference() == null || !item.getReference().contains(":")){ + if (item.getReference() == null || item.getReference().isBlank()){ logger.warn("Reference generated because is null ExternalDataset " + item.getId()); item.setReference(InternalReferenceSource + ":" + item.getId().toString().replace("-", "").toLowerCase(Locale.ROOT)); } + if (!item.getReference().contains(":")){ + logger.warn("Reference generated because is not contains ':' ExternalDataset " + item.getId() + " reference " + item.getReference()); + item.setReference(InternalReferenceSource + ":" + item.getId().toString().replace("-", "").toLowerCase(Locale.ROOT)); + } eu.old.eudat.models.data.externaldataset.ExternalDatasetModel model = new eu.old.eudat.models.data.externaldataset.ExternalDatasetModel().fromDataModel(item); String[] referenceParts = item.getReference().split(":", 2); diff --git a/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/FunderMigrationService.java b/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/FunderMigrationService.java index cace49916..4f538f9b7 100644 --- a/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/FunderMigrationService.java +++ b/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/FunderMigrationService.java @@ -44,10 +44,14 @@ public class FunderMigrationService { logger.debug("Migrate Funder " + page * PageSize + " of " + total); for (Funder item : items) { entityManager.detach(item); - if (item.getReference() == null || !item.getReference().contains(":")){ + if (item.getReference() == null || item.getReference().isBlank()){ logger.warn("Reference generated because is null Funder " + item.getId()); item.setReference(InternalReferenceSource + ":" + item.getId().toString().replace("-", "").toLowerCase(Locale.ROOT)); } + if (!item.getReference().contains(":")){ + logger.warn("Reference generated because is not contains ':' Funder " + item.getId() + " reference " + item.getReference()); + item.setReference(InternalReferenceSource + ":" + item.getId().toString().replace("-", "").toLowerCase(Locale.ROOT)); + } eu.old.eudat.models.data.funder.Funder model = new eu.old.eudat.models.data.funder.Funder().fromDataModel(item); String[] referenceParts = item.getReference().split(":", 2); diff --git a/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/GrantMigrationService.java b/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/GrantMigrationService.java index 4bbbafa00..b98497c3e 100644 --- a/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/GrantMigrationService.java +++ b/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/GrantMigrationService.java @@ -51,10 +51,14 @@ GrantMigrationService { logger.debug("Migrate Grant " + page * PageSize + " of " + total); for (Grant item : items) { entityManager.detach(item); - if (item.getReference() == null || !item.getReference().contains(":")){ + if (item.getReference() == null || item.getReference().isBlank()){ logger.warn("Reference generated because is null Grant " + item.getId()); item.setReference(InternalReferenceSource + ":" + item.getId().toString().replace("-", "").toLowerCase(Locale.ROOT)); } + if (!item.getReference().contains(":")){ + logger.warn("Reference generated because is not contains ':' Grant " + item.getId() + " reference " + item.getReference()); + item.setReference(InternalReferenceSource + ":" + item.getId().toString().replace("-", "").toLowerCase(Locale.ROOT)); + } String[] referenceParts = item.getReference().split(":", 2); boolean isInternal = referenceParts[0].equals(InternalReferenceSource); diff --git a/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/OrganizationMigrationService.java b/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/OrganizationMigrationService.java index ecbf2aad2..6e15ee8fe 100644 --- a/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/OrganizationMigrationService.java +++ b/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/OrganizationMigrationService.java @@ -49,10 +49,14 @@ public class OrganizationMigrationService { logger.debug("Migrate Organisation " + page * PageSize + " of " + total); for (Organisation item : items) { entityManager.detach(item); - if (item.getReference() == null || !item.getReference().contains(":")){ + if (item.getReference() == null || item.getReference().isBlank()){ logger.warn("Reference generated because is null Organisation " + item.getId()); item.setReference(InternalReferenceSource + ":" + item.getId().toString().replace("-", "").toLowerCase(Locale.ROOT)); } + if (!item.getReference().contains(":")){ + logger.warn("Reference generated because is not contains ':' Organisation " + item.getId() + " reference " + item.getReference()); + item.setReference(InternalReferenceSource + ":" + item.getId().toString().replace("-", "").toLowerCase(Locale.ROOT)); + } eu.old.eudat.models.data.dmp.Organisation model = new eu.old.eudat.models.data.dmp.Organisation().fromDataModel(item); diff --git a/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/ProjectMigrationService.java b/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/ProjectMigrationService.java index 50eeabb4d..b747c8a0a 100644 --- a/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/ProjectMigrationService.java +++ b/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/ProjectMigrationService.java @@ -50,10 +50,14 @@ public class ProjectMigrationService { logger.debug("Migrate Project " + page * PageSize + " of " + total); for (Project item : items) { entityManager.detach(item); - if (item.getReference() == null || !item.getReference().contains(":")){ + if (item.getReference() == null || item.getReference().isBlank()){ logger.warn("Reference generated because is null Project " + item.getId()); item.setReference(InternalReferenceSource + ":" + item.getId().toString().replace("-", "").toLowerCase(Locale.ROOT)); } + if (!item.getReference().contains(":")){ + logger.warn("Reference generated because is not contains ':' Project " + item.getId() + " reference " + item.getReference()); + item.setReference(InternalReferenceSource + ":" + item.getId().toString().replace("-", "").toLowerCase(Locale.ROOT)); + } eu.old.eudat.models.data.project.Project model = new eu.old.eudat.models.data.project.Project().fromDataModel(item); String[] referenceParts = item.getReference().split(":", 2); diff --git a/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/RegistryMigrationService.java b/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/RegistryMigrationService.java index a45935d0d..2a67ab4fa 100644 --- a/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/RegistryMigrationService.java +++ b/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/RegistryMigrationService.java @@ -49,10 +49,14 @@ public class RegistryMigrationService { logger.debug("Migrate Registry " + page * PageSize + " of " + total); for (Registry item : items) { entityManager.detach(item); - if (item.getReference() == null || !item.getReference().contains(":")){ + if (item.getReference() == null || item.getReference().isBlank()){ logger.warn("Reference generated because is null Registry " + item.getId()); item.setReference(InternalReferenceSource + ":" + item.getId().toString().replace("-", "").toLowerCase(Locale.ROOT)); } + if (!item.getReference().contains(":")){ + logger.warn("Reference generated because is not contains ':' Registry " + item.getId() + " reference " + item.getReference()); + item.setReference(InternalReferenceSource + ":" + item.getId().toString().replace("-", "").toLowerCase(Locale.ROOT)); + } eu.old.eudat.models.data.registries.RegistryModel model = new eu.old.eudat.models.data.registries.RegistryModel().fromDataModel(item); String[] referenceParts = item.getReference().split(":", 2); diff --git a/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/ResearcherMigrationService.java b/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/ResearcherMigrationService.java index 9cc6e77c8..25fb2fd42 100644 --- a/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/ResearcherMigrationService.java +++ b/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/ResearcherMigrationService.java @@ -50,10 +50,14 @@ public class ResearcherMigrationService { logger.debug("Migrate Researcher " + page * PageSize + " of " + total); for (Researcher item : items) { entityManager.detach(item); - if (item.getReference() == null || !item.getReference().contains(":")){ + if (item.getReference() == null || item.getReference().isBlank()){ logger.warn("Reference generated because is null Researcher " + item.getId()); item.setReference(InternalReferenceSource + ":" + item.getId().toString().replace("-", "").toLowerCase(Locale.ROOT)); } + if (!item.getReference().contains(":")){ + logger.warn("Reference generated because is not contains ':' Researcher " + item.getId() + " reference " + item.getReference()); + item.setReference(InternalReferenceSource + ":" + item.getId().toString().replace("-", "").toLowerCase(Locale.ROOT)); + } eu.old.eudat.models.data.dmp.Researcher model = new eu.old.eudat.models.data.dmp.Researcher().fromDataModel(item); String[] referenceParts = item.getReference().split(":", 2); diff --git a/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/ServiceMigrationService.java b/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/ServiceMigrationService.java index f61cf1f7a..fb9c8563a 100644 --- a/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/ServiceMigrationService.java +++ b/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/ServiceMigrationService.java @@ -48,10 +48,14 @@ public class ServiceMigrationService { logger.debug("Migrate Service " + page * PageSize + " of " + total); for (eu.old.eudat.data.entities.Service item : items) { entityManager.detach(item); - if (item.getReference() == null || !item.getReference().contains(":")){ + if (item.getReference() == null || item.getReference().isBlank()){ logger.warn("Reference generated because is null Service " + item.getId()); item.setReference(InternalReferenceSource + ":" + item.getId().toString().replace("-", "").toLowerCase(Locale.ROOT)); } + if (!item.getReference().contains(":")){ + logger.warn("Reference generated because is not contains ':' Service " + item.getId() + " reference " + item.getReference()); + item.setReference(InternalReferenceSource + ":" + item.getId().toString().replace("-", "").toLowerCase(Locale.ROOT)); + } eu.old.eudat.models.data.services.ServiceModel model = new eu.old.eudat.models.data.services.ServiceModel().fromDataModel(item); String[] referenceParts = item.getReference().split(":", 2); diff --git a/dmp-migration-tool/web/src/main/java/eu/old/eudat/publicapi/migration/MigrationController.java b/dmp-migration-tool/web/src/main/java/eu/old/eudat/publicapi/migration/MigrationController.java index a67f48cf6..091efe744 100644 --- a/dmp-migration-tool/web/src/main/java/eu/old/eudat/publicapi/migration/MigrationController.java +++ b/dmp-migration-tool/web/src/main/java/eu/old/eudat/publicapi/migration/MigrationController.java @@ -175,6 +175,7 @@ public class MigrationController { public boolean step3() throws IOException, JAXBException, ParserConfigurationException, InstantiationException, IllegalAccessException, SAXException, NoSuchFieldException, InvalidApplicationException, TransformerException, URISyntaxException { //Description this.datasetMigrationService.migrate(); +// throw new InvalidApplicationException(""); this.datasetReferenceMigrationService.migrateDatasetReferences(); this.tagMigrationService.migrate();