From 656afc2045ecf2a816654ff0824d9722bab8d90a Mon Sep 17 00:00:00 2001 From: sgiannopoulos Date: Thu, 29 Feb 2024 12:38:57 +0200 Subject: [PATCH] migration changes --- ...rence_ReferenceType_SupportiveMaterial.sql | 2 +- .../migration/DatasetMigrationService.java | 1 + ... => DatasetReferenceMigrationService.java} | 7 +- .../StorageFileMigrationService.java | 1 - .../migration/MigrationController.java | 65 +++++++++---------- 5 files changed, 36 insertions(+), 40 deletions(-) rename dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/{ReferenceMigrationService.java => DatasetReferenceMigrationService.java} (96%) diff --git a/dmp-db-scema/updates/00.01.000_Add_Reference_ReferenceType_SupportiveMaterial.sql b/dmp-db-scema/updates/00.01.000_Add_Reference_ReferenceType_SupportiveMaterial.sql index 4d1f78d72..1e203cfcd 100644 --- a/dmp-db-scema/updates/00.01.000_Add_Reference_ReferenceType_SupportiveMaterial.sql +++ b/dmp-db-scema/updates/00.01.000_Add_Reference_ReferenceType_SupportiveMaterial.sql @@ -21,7 +21,7 @@ BEGIN CREATE TABLE public."Reference" ( id uuid NOT NULL, - label character varying(250) COLLATE pg_catalog."default" NOT NULL, + label character varying(500) COLLATE pg_catalog."default" NOT NULL, description text COLLATE pg_catalog."default", abbreviation character varying(50) COLLATE pg_catalog."default", source character varying(1024) COLLATE pg_catalog."default", 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 8b3f2e3f1..2b96de823 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 @@ -970,6 +970,7 @@ public class DatasetMigrationService { if (this.conventionService.isNullOrEmpty(data.getReference())) { data.setReference(data.getId().toString().replace("-", "").toLowerCase(Locale.ROOT)); data.setSourceType(ReferenceSourceType.Internal); + data.setSource("Internal"); if (dataset.getCreator() != null) data.setCreatedById(dataset.getCreator().getId()); logger.warn("Migrate Dataset " + dataset.getId() + " " + dataset.getLabel() + " reference auto created as internal " + referenceTypeDataEntity.getReferenceTypeId() + " for value " + this.jsonHandlingService.toJsonSafe(item)); } diff --git a/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/ReferenceMigrationService.java b/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/DatasetReferenceMigrationService.java similarity index 96% rename from dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/ReferenceMigrationService.java rename to dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/DatasetReferenceMigrationService.java index 56cad43dd..292109958 100644 --- a/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/ReferenceMigrationService.java +++ b/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/DatasetReferenceMigrationService.java @@ -2,11 +2,9 @@ package eu.old.eudat.migration; import eu.eudat.commons.enums.IsActive; import eu.eudat.data.DescriptionReferenceEntity; -import eu.eudat.data.DmpReferenceEntity; import eu.old.eudat.data.dao.entities.*; import eu.old.eudat.data.entities.*; import eu.old.eudat.logic.services.operations.DatabaseRepository; -import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.logging.LoggerService; import jakarta.persistence.EntityManager; import org.slf4j.LoggerFactory; @@ -17,15 +15,14 @@ import java.util.List; import java.util.UUID; @Service -public class ReferenceMigrationService { +public class DatasetReferenceMigrationService { private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpDatasetProfileMigrationService.class)); private final DatabaseRepository databaseRepository; private static final int PageSize = 500; - private static final boolean TestMode = false; private final EntityManager entityManager; - public ReferenceMigrationService(DatabaseRepository databaseRepository, EntityManager entityManager) { + public DatasetReferenceMigrationService(DatabaseRepository databaseRepository, EntityManager entityManager) { this.databaseRepository = databaseRepository; this.entityManager = entityManager; } diff --git a/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/StorageFileMigrationService.java b/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/StorageFileMigrationService.java index bdff209c7..632063ef2 100644 --- a/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/StorageFileMigrationService.java +++ b/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/StorageFileMigrationService.java @@ -93,7 +93,6 @@ public class StorageFileMigrationService { page++; } } while (items != null && !items.isEmpty()); - throw new MyApplicationException(""); // for (File file : filesToDelete){ // try{ // file.delete(); 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 a99917fd8..729837f3a 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 @@ -1,6 +1,5 @@ package eu.old.eudat.publicapi.migration; -import com.fasterxml.jackson.core.JsonProcessingException; import eu.old.eudat.migration.*; import io.swagger.annotations.Api; import jakarta.xml.bind.JAXBException; @@ -36,7 +35,7 @@ public class MigrationController { private final TagMigrationService tagMigrationService; private final DmpDatasetProfileMigrationService dmpDatasetProfileMigrationService; private final OrganizationMigrationService organizationMigrationService; - private final ReferenceMigrationService referenceMigrationService; + private final DatasetReferenceMigrationService datasetReferenceMigrationService; private final UserContactInfoMigrationService userContactInfoMigrationService; private final DmpUserMigrationService dmpUserMigrationService; private final UserMigrationService userMigrationService; @@ -58,7 +57,7 @@ public class MigrationController { ResearcherMigrationService researcherMigrationService, ServiceMigrationService serviceMigrationService, TagMigrationService tagMigrationService, OrganizationMigrationService organizationMigrationService, - ReferenceMigrationService referenceMigrationService, + DatasetReferenceMigrationService datasetReferenceMigrationService, UserContactInfoMigrationService userContactInfoMigrationService, DmpUserMigrationService dmpUserMigrationService, UserMigrationService userMigrationService, @@ -77,7 +76,7 @@ public class MigrationController { this.serviceMigrationService = serviceMigrationService; this.tagMigrationService = tagMigrationService; this.organizationMigrationService = organizationMigrationService; - this.referenceMigrationService = referenceMigrationService; + this.datasetReferenceMigrationService = datasetReferenceMigrationService; this.userContactInfoMigrationService = userContactInfoMigrationService; this.dmpUserMigrationService = dmpUserMigrationService; this.userMigrationService = userMigrationService; @@ -90,39 +89,39 @@ public class MigrationController { @GetMapping("all") @Transactional public boolean migrateAll() throws IOException, JAXBException, ParserConfigurationException, InstantiationException, IllegalAccessException, SAXException, NoSuchFieldException, InvalidApplicationException, TransformerException, URISyntaxException { -// //Reference -// this.dataRepositoryMigrationService.migrate(); -// this.externalDatasetMigrationService.migrate(); -// this.funderMigrationService.migrate(); -// this.grantMigrationService.migrate(); -// this.organizationMigrationService.migrate(); -// this.projectMigrationService.migrate(); -// this.registryMigrationService.migrate(); -// this.researcherMigrationService.migrate(); -// this.serviceMigrationService.migrate(); -// -// //User -// this.userContactInfoMigrationService.migrate(); -// this.userMigrationService.migrate(); -// -// //XML recreate -// this.dmpBlueprintXmlMigrationService.migrate(); -// this.descriptionTemplateXmlMigrationService.migrate(); -// -// //Dmp -// this.dmpMigrationService.migrate(); -// this.dmpDatasetProfileMigrationService.migrate(); -// this.dmpUserMigrationService.migrate(); + //Reference + this.dataRepositoryMigrationService.migrate(); + this.externalDatasetMigrationService.migrate(); + this.funderMigrationService.migrate(); + this.grantMigrationService.migrate(); + this.organizationMigrationService.migrate(); + this.projectMigrationService.migrate(); + this.registryMigrationService.migrate(); + this.researcherMigrationService.migrate(); + this.serviceMigrationService.migrate(); + + //User + this.userContactInfoMigrationService.migrate(); + this.userMigrationService.migrate(); + + //XML recreate + this.dmpBlueprintXmlMigrationService.migrate(); + this.descriptionTemplateXmlMigrationService.migrate(); + + //Dmp + this.dmpMigrationService.migrate(); + this.dmpDatasetProfileMigrationService.migrate(); + this.dmpUserMigrationService.migrate(); //Description - this.datasetMigrationService.migrate(); //TODO -// this.referenceMigrationService.migrateDatasetReferences(); -// this.tagMigrationService.migrate(); + this.datasetMigrationService.migrate(); + this.datasetReferenceMigrationService.migrateDatasetReferences(); + this.tagMigrationService.migrate(); -// this.storageFileMigrationService.migrate(); + this.storageFileMigrationService.migrate(); - throw new RuntimeException(""); - //return true; + //throw new RuntimeException(""); + return true; } // @GetMapping("dmp-blueprints-xml")