From 9cb9cdb0301aa75958944253efe402fa730da6f6 Mon Sep 17 00:00:00 2001 From: "k.triantafyllou" Date: Wed, 11 May 2022 11:29:26 +0300 Subject: [PATCH] Create templates and DMP mapping --- .../eudat/migration/DMPRoadmapMigration.java | 224 ++++++++++++++++- .../controllers/TemplateController.java | 16 +- .../eudat/migration/entities/ApiClient.java | 149 ++++++++++++ .../eu/eudat/migration/entities/Guidance.java | 71 ++++++ .../migration/entities/GuidanceGroup.java | 82 +++++++ .../migration/entities/Organization.java | 10 +- .../eu/eudat/migration/entities/Plan.java | 227 ++++++++++++++++++ .../eu/eudat/migration/entities/Question.java | 19 +- .../migration/entities/ResearchDomain.java | 85 +++++++ .../eu/eudat/migration/entities/Template.java | 41 +++- .../eu/eudat/migration/entities/Theme.java | 107 +++++++++ 11 files changed, 1008 insertions(+), 23 deletions(-) create mode 100644 dmp-backend/web/src/main/java/eu/eudat/migration/entities/ApiClient.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/migration/entities/Guidance.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/migration/entities/GuidanceGroup.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/migration/entities/Plan.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/migration/entities/ResearchDomain.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/migration/entities/Theme.java diff --git a/dmp-backend/web/src/main/java/eu/eudat/migration/DMPRoadmapMigration.java b/dmp-backend/web/src/main/java/eu/eudat/migration/DMPRoadmapMigration.java index dac238051..d6f60ac52 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/migration/DMPRoadmapMigration.java +++ b/dmp-backend/web/src/main/java/eu/eudat/migration/DMPRoadmapMigration.java @@ -1,25 +1,243 @@ package eu.eudat.migration; +import eu.eudat.logic.managers.AdminManager; +import eu.eudat.logic.managers.MetricsManager; +import eu.eudat.logic.services.ApiContext; import eu.eudat.migration.dao.TemplateRepository; +import eu.eudat.migration.entities.Question; +import eu.eudat.migration.entities.QuestionFormat; import eu.eudat.migration.entities.Template; +import eu.eudat.migration.entities.Theme; +import eu.eudat.models.data.admin.components.datasetprofile.Field; +import eu.eudat.models.data.admin.components.datasetprofile.FieldSet; +import eu.eudat.models.data.admin.components.datasetprofile.Page; +import eu.eudat.models.data.admin.components.datasetprofile.Section; +import eu.eudat.models.data.admin.composite.DatasetProfile; +import eu.eudat.models.data.components.commons.DefaultValue; +import eu.eudat.models.data.components.commons.Multiplicity; +import eu.eudat.models.data.components.commons.ViewStyle; +import eu.eudat.models.data.components.commons.Visibility; +import eu.eudat.types.MetricNames; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.CommandLineRunner; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.stereotype.Component; +import javax.transaction.Transactional; +import java.util.*; +import java.util.stream.Collectors; + @Component -@ConditionalOnProperty(prefix = "roadmap", name="database.url") +@ConditionalOnProperty(prefix = "roadmap", name = "database.url") public class DMPRoadmapMigration implements CommandLineRunner { private final TemplateRepository templateRepository; + private final ApiContext apiContext; + private final MetricsManager metricsManager; + /** Profiles */ + private final List datasetProfiles = new ArrayList<>(); + private final List profiles = new ArrayList<>(); + /** Metadata */ + private final Map groups = new HashMap<>(); @Autowired - public DMPRoadmapMigration(TemplateRepository templateRepository) { + public DMPRoadmapMigration(TemplateRepository templateRepository, ApiContext apiContext, MetricsManager metricsManager) { this.templateRepository = templateRepository; + this.apiContext = apiContext; + this.metricsManager = metricsManager; } @Override - public void run(String... args) throws Exception { + public void run(String... args) { + List