dmp migration changes
This commit is contained in:
parent
e47a370088
commit
9433beaaa6
|
@ -6,6 +6,7 @@ import eu.eudat.commons.enums.DmpVersionStatus;
|
||||||
import eu.eudat.commons.enums.IsActive;
|
import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.data.converters.enums.DmpAccessTypeConverter;
|
import eu.eudat.data.converters.enums.DmpAccessTypeConverter;
|
||||||
import eu.eudat.data.converters.enums.DmpStatusConverter;
|
import eu.eudat.data.converters.enums.DmpStatusConverter;
|
||||||
|
import eu.eudat.data.converters.enums.DmpVersionStatusConverter;
|
||||||
import eu.eudat.data.converters.enums.IsActiveConverter;
|
import eu.eudat.data.converters.enums.IsActiveConverter;
|
||||||
import eu.eudat.data.old.queryableentity.DataEntity;
|
import eu.eudat.data.old.queryableentity.DataEntity;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
|
@ -35,7 +36,7 @@ public class DmpEntity implements DataEntity<DmpEntity, UUID> {
|
||||||
public static final String _version = "version";
|
public static final String _version = "version";
|
||||||
|
|
||||||
@Column(name = "version_status", nullable = false)
|
@Column(name = "version_status", nullable = false)
|
||||||
@Convert(converter = DmpStatusConverter.class)
|
@Convert(converter = DmpVersionStatusConverter.class)
|
||||||
private DmpVersionStatus versionStatus;
|
private DmpVersionStatus versionStatus;
|
||||||
|
|
||||||
public static final String _versionStatus = "versionStatus";
|
public static final String _versionStatus = "versionStatus";
|
||||||
|
|
|
@ -1,51 +1,61 @@
|
||||||
ALTER TABLE public."DescriptionTemplate" RENAME "ID" TO id;
|
DO $$DECLARE
|
||||||
|
this_version CONSTANT varchar := '00.01.010';
|
||||||
|
BEGIN
|
||||||
|
PERFORM * FROM "DBVersion" WHERE version = this_version;
|
||||||
|
IF FOUND THEN RETURN; END IF;
|
||||||
|
|
||||||
ALTER TABLE public."DescriptionTemplate" RENAME "Label" TO label;
|
ALTER TABLE public."DescriptionTemplate" RENAME "ID" TO id;
|
||||||
|
|
||||||
ALTER TABLE public."DescriptionTemplate" RENAME "Definition" TO definition;
|
ALTER TABLE public."DescriptionTemplate" RENAME "Label" TO label;
|
||||||
|
|
||||||
ALTER TABLE public."DescriptionTemplate" RENAME "Status" TO status;
|
ALTER TABLE public."DescriptionTemplate" RENAME "Definition" TO definition;
|
||||||
|
|
||||||
ALTER TABLE public."DescriptionTemplate" RENAME "Created" TO created_at;
|
ALTER TABLE public."DescriptionTemplate" RENAME "Status" TO status;
|
||||||
|
|
||||||
ALTER TABLE public."DescriptionTemplate" RENAME "Modified" TO updated_at;
|
ALTER TABLE public."DescriptionTemplate" RENAME "Created" TO created_at;
|
||||||
|
|
||||||
ALTER TABLE public."DescriptionTemplate" RENAME "Description" TO description;
|
ALTER TABLE public."DescriptionTemplate" RENAME "Modified" TO updated_at;
|
||||||
|
|
||||||
ALTER TABLE public."DescriptionTemplate" RENAME "GroupId" TO group_id;
|
ALTER TABLE public."DescriptionTemplate" RENAME "Description" TO description;
|
||||||
|
|
||||||
ALTER TABLE public."DescriptionTemplate" RENAME "Version" TO version;
|
ALTER TABLE public."DescriptionTemplate" RENAME "GroupId" TO group_id;
|
||||||
|
|
||||||
ALTER TABLE public."DescriptionTemplate" RENAME "Language" TO "language";
|
ALTER TABLE public."DescriptionTemplate" RENAME "Version" TO version;
|
||||||
|
|
||||||
ALTER TABLE public."DescriptionTemplate" RENAME "Type" TO "type";
|
ALTER TABLE public."DescriptionTemplate" RENAME "Language" TO "language";
|
||||||
|
|
||||||
ALTER TABLE public."DescriptionTemplate" ALTER COLUMN created_at TYPE timestamp without time zone ;
|
ALTER TABLE public."DescriptionTemplate" RENAME "Type" TO "type";
|
||||||
|
|
||||||
ALTER TABLE public."DescriptionTemplate" ALTER COLUMN updated_at TYPE timestamp without time zone ;
|
ALTER TABLE public."DescriptionTemplate" ALTER COLUMN created_at TYPE timestamp without time zone ;
|
||||||
|
|
||||||
ALTER TABLE public."DescriptionTemplate" ALTER COLUMN group_id DROP DEFAULT;
|
ALTER TABLE public."DescriptionTemplate" ALTER COLUMN updated_at TYPE timestamp without time zone ;
|
||||||
|
|
||||||
ALTER TABLE public."DescriptionTemplate" ADD COLUMN is_active smallint;
|
ALTER TABLE public."DescriptionTemplate" ALTER COLUMN group_id DROP DEFAULT;
|
||||||
|
|
||||||
UPDATE public."DescriptionTemplate" SET is_active = 1;
|
ALTER TABLE public."DescriptionTemplate" ADD COLUMN is_active smallint;
|
||||||
|
|
||||||
UPDATE public."DescriptionTemplate" SET is_active = 0 where status = 99;
|
UPDATE public."DescriptionTemplate" SET is_active = 1;
|
||||||
UPDATE public."DescriptionTemplate" SET status = 0 where is_active = 0;
|
|
||||||
|
|
||||||
ALTER TABLE public."DescriptionTemplate" ALTER COLUMN is_active SET NOT NULL;
|
UPDATE public."DescriptionTemplate" SET is_active = 0 where status = 99;
|
||||||
|
UPDATE public."DescriptionTemplate" SET status = 0 where is_active = 0;
|
||||||
|
|
||||||
ALTER TABLE public."DescriptionTemplate" ADD COLUMN version_status smallint;
|
ALTER TABLE public."DescriptionTemplate" ALTER COLUMN is_active SET NOT NULL;
|
||||||
|
|
||||||
UPDATE public."DescriptionTemplate" SET version_status = 1;
|
ALTER TABLE public."DescriptionTemplate" ADD COLUMN version_status smallint;
|
||||||
|
|
||||||
UPDATE public."DescriptionTemplate" SET version_status = 0 where id in (
|
UPDATE public."DescriptionTemplate" SET version_status = 1;
|
||||||
|
|
||||||
|
UPDATE public."DescriptionTemplate" SET version_status = 0 where id in (
|
||||||
select dt.id from public."DescriptionTemplate" as dt
|
select dt.id from public."DescriptionTemplate" as dt
|
||||||
where dt.version =
|
where dt.version =
|
||||||
(
|
(
|
||||||
select Max(f.version)
|
select Max(f.version)
|
||||||
from public."DescriptionTemplate" as f where f.group_id=dt.group_id
|
from public."DescriptionTemplate" as f where f.group_id=dt.group_id
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
ALTER TABLE public."DescriptionTemplate" ALTER COLUMN version_status SET NOT NULL;
|
ALTER TABLE public."DescriptionTemplate" ALTER COLUMN version_status SET NOT NULL;
|
||||||
|
|
||||||
|
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.010', '2023-11-02 12:00:00.000000+02', now(), 'Aling DescriptionTemplate table.');
|
||||||
|
|
||||||
|
END$$;
|
|
@ -9,7 +9,7 @@ CREATE TABLE IF NOT EXISTS public."DmpDescriptionTemplate"
|
||||||
"id" uuid NOT NULL,
|
"id" uuid NOT NULL,
|
||||||
"dmp" uuid NOT NULL,
|
"dmp" uuid NOT NULL,
|
||||||
"description_template" uuid NOT NULL,
|
"description_template" uuid NOT NULL,
|
||||||
"data" text COLLATE pg_catalog."default" NOT NULL,
|
"section_id" uuid NOT NULL,
|
||||||
"created_at" timestamp without time zone NOT NULL DEFAULT now(),
|
"created_at" timestamp without time zone NOT NULL DEFAULT now(),
|
||||||
"updated_at" timestamp without time zone NOT NULL DEFAULT now(),
|
"updated_at" timestamp without time zone NOT NULL DEFAULT now(),
|
||||||
"is_active" smallint NOT NULL DEFAULT 1,
|
"is_active" smallint NOT NULL DEFAULT 1,
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class DatasetMigrationService {
|
||||||
|
|
||||||
public List<DatasetMigrationCollectedInfo> collectDatasetsInfo() throws JsonProcessingException {
|
public List<DatasetMigrationCollectedInfo> collectDatasetsInfo() throws JsonProcessingException {
|
||||||
List<DatasetMigrationCollectedInfo> collectedInfoList = new ArrayList<>();
|
List<DatasetMigrationCollectedInfo> collectedInfoList = new ArrayList<>();
|
||||||
List<DatasetWizardModel> datasets = getDatasets(0, 4);
|
List<DatasetWizardModel> datasets = getDatasets(0, Integer.MAX_VALUE);
|
||||||
for (DatasetWizardModel datasetWizardModel : datasets) {
|
for (DatasetWizardModel datasetWizardModel : datasets) {
|
||||||
DatasetMigrationCollectedInfo datasetMigrationCollectedInfo = new DatasetMigrationCollectedInfo();
|
DatasetMigrationCollectedInfo datasetMigrationCollectedInfo = new DatasetMigrationCollectedInfo();
|
||||||
|
|
||||||
|
|
|
@ -3,87 +3,199 @@ package eu.old.eudat.migration;
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import eu.eudat.commons.JsonHandlingService;
|
import eu.eudat.commons.JsonHandlingService;
|
||||||
import eu.eudat.commons.enums.DescriptionStatus;
|
import eu.eudat.commons.XmlHandlingService;
|
||||||
import eu.eudat.commons.enums.IsActive;
|
import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.data.DescriptionEntity;
|
import eu.eudat.commons.enums.ReferenceFieldDataType;
|
||||||
|
import eu.eudat.commons.enums.ReferenceSourceType;
|
||||||
|
import eu.eudat.commons.enums.ReferenceType;
|
||||||
|
import eu.eudat.commons.types.reference.FieldEntity;
|
||||||
|
import eu.eudat.data.DescriptionTemplateEntity;
|
||||||
|
import eu.eudat.data.DmpBlueprintEntity;
|
||||||
import eu.eudat.data.DmpDescriptionTemplateEntity;
|
import eu.eudat.data.DmpDescriptionTemplateEntity;
|
||||||
|
import eu.eudat.data.ReferenceEntity;
|
||||||
|
import eu.eudat.model.DmpBlueprint;
|
||||||
|
import eu.eudat.query.DescriptionTemplateQuery;
|
||||||
|
import eu.eudat.query.DmpBlueprintQuery;
|
||||||
|
import eu.old.eudat.data.dao.entities.DmpDatasetProfileDao;
|
||||||
|
import eu.old.eudat.data.dao.entities.ResearcherDao;
|
||||||
import eu.old.eudat.data.entities.DMPDatasetProfile;
|
import eu.old.eudat.data.entities.DMPDatasetProfile;
|
||||||
import eu.old.eudat.data.entities.Dataset;
|
import eu.old.eudat.data.entities.Researcher;
|
||||||
import eu.old.eudat.logic.services.operations.DatabaseRepository;
|
import eu.old.eudat.logic.services.operations.DatabaseRepository;
|
||||||
import eu.old.eudat.models.data.datasetwizard.DatasetWizardModel;
|
|
||||||
import eu.old.eudat.queryable.QueryableList;
|
import eu.old.eudat.queryable.QueryableList;
|
||||||
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
import jakarta.persistence.EntityManager;
|
import jakarta.persistence.EntityManager;
|
||||||
|
import jakarta.xml.bind.JAXBException;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
import eu.eudat.commons.types.dmpblueprint.DefinitionEntity;
|
||||||
|
|
||||||
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
import java.io.IOException;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class DmpDatasetProfileMigrationService {
|
public class DmpDatasetProfileMigrationService {
|
||||||
|
|
||||||
|
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpDatasetProfileMigrationService.class));
|
||||||
private final DatabaseRepository databaseRepository;
|
private final DatabaseRepository databaseRepository;
|
||||||
|
|
||||||
private final JsonHandlingService jsonHandlingService;
|
private final JsonHandlingService jsonHandlingService;
|
||||||
|
private final QueryFactory queryFactory;
|
||||||
|
private final XmlHandlingService xmlHandlingService;
|
||||||
|
private static final int PageSize = 500;
|
||||||
|
private static final boolean TestMode = false;
|
||||||
private final EntityManager entityManager;
|
private final EntityManager entityManager;
|
||||||
|
|
||||||
public DmpDatasetProfileMigrationService(DatabaseRepository databaseRepository, JsonHandlingService jsonHandlingService, EntityManager entityManager) {
|
public DmpDatasetProfileMigrationService(DatabaseRepository databaseRepository, JsonHandlingService jsonHandlingService, QueryFactory queryFactory, XmlHandlingService xmlHandlingService, EntityManager entityManager) {
|
||||||
this.databaseRepository = databaseRepository;
|
this.databaseRepository = databaseRepository;
|
||||||
this.jsonHandlingService = jsonHandlingService;
|
this.jsonHandlingService = jsonHandlingService;
|
||||||
|
this.queryFactory = queryFactory;
|
||||||
|
this.xmlHandlingService = xmlHandlingService;
|
||||||
this.entityManager = entityManager;
|
this.entityManager = entityManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public QueryableList<DMPDatasetProfile> dmpDatasetProfileQueryableList() {
|
public void migrate() throws IOException, JAXBException, ParserConfigurationException, InstantiationException, IllegalAccessException, SAXException {
|
||||||
return databaseRepository.getDmpDatasetProfileDao().asQueryable();
|
DmpDatasetProfileDao dmpDatasetProfileDao = databaseRepository.getDmpDatasetProfileDao();
|
||||||
|
long total = dmpDatasetProfileDao.asQueryable().count();
|
||||||
|
logger.debug("Migrate DmpDatasetProfile Total : " + total);
|
||||||
|
int page = 0;
|
||||||
|
|
||||||
|
List<DMPDatasetProfile> items;
|
||||||
|
do {
|
||||||
|
items = dmpDatasetProfileDao.asQueryable().orderBy((builder, root) -> builder.asc(root.get("ID"))).skip(page * PageSize).take(PageSize).toList();
|
||||||
|
if (items != null && !items.isEmpty()) {
|
||||||
|
logger.debug("Migrate DmpDatasetProfile " + page * PageSize + " of " + total);
|
||||||
|
|
||||||
|
List<DmpBlueprintEntity> dmpBlueprints = this.queryFactory.query(DmpBlueprintQuery.class).ids(items.stream().map(x-> x.getDmp().getProfile().getId()).distinct().toList()).collect();
|
||||||
|
Map<UUID, DefinitionEntity> dmpBlueprintsMap = new HashMap<>();
|
||||||
|
for (DmpBlueprintEntity dmpBlueprint : dmpBlueprints) {
|
||||||
|
DefinitionEntity definitionEntity = this.xmlHandlingService.fromXml(DefinitionEntity.class, dmpBlueprint.getDefinition());
|
||||||
|
dmpBlueprintsMap.put(dmpBlueprint.getId(), definitionEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<DMPDatasetProfile> getDatasets(Integer skip, Integer take) {
|
for (DMPDatasetProfile item : items) {
|
||||||
return dmpDatasetProfileQueryableList()
|
entityManager.detach(item);
|
||||||
// .orderBy((builder, root) -> builder.desc(root.get("created")))
|
|
||||||
.skip(skip)
|
DmpDatasetProfileData profileData = jsonHandlingService.fromJson(DmpDatasetProfileData.class, item.getData());
|
||||||
.take(take)
|
|
||||||
.toList();
|
if (profileData == null || profileData.dmpSectionIndex == null || profileData.dmpSectionIndex.isEmpty()){
|
||||||
|
logger.error("Migrate DmpDatasetProfile " + item.getId() + " failed no section info ");
|
||||||
|
throw new MyApplicationException();
|
||||||
|
}
|
||||||
|
DefinitionEntity definition = dmpBlueprintsMap.getOrDefault(item.getDmp().getProfile().getId(), null);
|
||||||
|
if (definition == null){
|
||||||
|
logger.error("Migrate DmpDatasetProfile " + item.getId() + " failed blueprint definition not found for blueprint " + item.getDmp().getProfile().getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<DmpDatasetProfileMigrationCollectedInfo> collectDatasetsInfo() throws JsonProcessingException {
|
for (int sectionIndex: profileData.dmpSectionIndex) {
|
||||||
List<DmpDatasetProfileMigrationCollectedInfo> collectedInfoList = new ArrayList<>();
|
if (definition == null || definition.getSections() == null || definition.getSections().size() < sectionIndex) {
|
||||||
List<DMPDatasetProfile> dmpDatasetProfiles = getDatasets(0, 4);
|
logger.error("Migrate DmpDatasetProfile " + item.getId() + " can nto found section id for section " + sectionIndex);
|
||||||
for (DMPDatasetProfile dmpDatasetProfile : dmpDatasetProfiles) {
|
throw new MyApplicationException();
|
||||||
DmpDatasetProfileMigrationCollectedInfo dmpDatasetProfileMigrationCollectedInfo = new DmpDatasetProfileMigrationCollectedInfo();
|
|
||||||
|
|
||||||
DmpDatasetProfileData data = jsonHandlingService.fromJson(DmpDatasetProfileData.class, dmpDatasetProfile.getData());
|
|
||||||
|
|
||||||
//Collect basic information
|
|
||||||
DmpDescriptionTemplateEntity dmpDescriptionTemplateEntity = new DmpDescriptionTemplateEntity();
|
|
||||||
dmpDescriptionTemplateEntity.setDescriptionTemplateId(dmpDatasetProfile.getDatasetprofile().getId());
|
|
||||||
dmpDescriptionTemplateEntity.setDmpId(dmpDatasetProfile.getDmp().getId());
|
|
||||||
dmpDescriptionTemplateEntity.setCreatedAt(Instant.now());
|
|
||||||
dmpDescriptionTemplateEntity.setUpdatedAt(Instant.now());
|
|
||||||
dmpDescriptionTemplateEntity.setSectionId(null); //TODO
|
|
||||||
dmpDescriptionTemplateEntity.setIsActive(IsActive.Active);
|
|
||||||
|
|
||||||
dmpDatasetProfileMigrationCollectedInfo.dmpDescriptionTemplateEntity = dmpDescriptionTemplateEntity;
|
|
||||||
|
|
||||||
collectedInfoList.add(dmpDatasetProfileMigrationCollectedInfo);
|
|
||||||
}
|
}
|
||||||
return collectedInfoList;
|
UUID sectionId = definition.getSections().get(sectionIndex).getId();
|
||||||
|
if (sectionId == null) {
|
||||||
|
logger.error("Migrate DmpDatasetProfile " + item.getId() + " can nto found section id for section " + sectionIndex);
|
||||||
|
throw new MyApplicationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String migrate() throws JsonProcessingException {
|
DmpDescriptionTemplateEntity data = new DmpDescriptionTemplateEntity();
|
||||||
for (DmpDatasetProfileMigrationCollectedInfo collectedInfo : collectDatasetsInfo()) {
|
data.setId(UUID.randomUUID());
|
||||||
// this.entityManager.persist(collectedInfo.dmpDescriptionTemplateEntity);
|
data.setDescriptionTemplateId(item.getDatasetprofile().getId());
|
||||||
|
data.setDmpId(item.getDmp().getId());
|
||||||
|
data.setCreatedAt(Instant.now());
|
||||||
|
data.setUpdatedAt(Instant.now());
|
||||||
|
data.setSectionId(sectionId);
|
||||||
|
data.setIsActive(IsActive.Active);
|
||||||
|
this.entityManager.persist(data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.entityManager.flush();
|
this.entityManager.flush();
|
||||||
return "Migrated dmps";
|
|
||||||
|
page++;
|
||||||
}
|
}
|
||||||
|
} while (items != null && !items.isEmpty() && !TestMode);
|
||||||
public static class DmpDatasetProfileMigrationCollectedInfo {
|
|
||||||
|
|
||||||
public DmpDescriptionTemplateEntity dmpDescriptionTemplateEntity;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
//
|
||||||
|
// public QueryableList<DMPDatasetProfile> dmpDatasetProfileQueryableList() {
|
||||||
|
// return databaseRepository.getDmpDatasetProfileDao().asQueryable();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public List<DMPDatasetProfile> getDatasets(Integer skip, Integer take) {
|
||||||
|
// return dmpDatasetProfileQueryableList()
|
||||||
|
//// .orderBy((builder, root) -> builder.desc(root.get("created")))
|
||||||
|
// .skip(skip)
|
||||||
|
// .take(take)
|
||||||
|
// .toList();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public List<DmpDatasetProfileMigrationCollectedInfo> collectDatasetsInfo() throws Exception {
|
||||||
|
// List<DmpDatasetProfileMigrationCollectedInfo> collectedInfoList = new ArrayList<>();
|
||||||
|
// List<DMPDatasetProfile> items = getDatasets(0, 4);
|
||||||
|
//
|
||||||
|
// List<DmpBlueprintEntity> dmpBlueprints = this.queryFactory.query(DmpBlueprintQuery.class).ids(items.stream().map(x-> x.getDmp().getProfile().getId()).distinct().toList()).collect();
|
||||||
|
// Map<UUID, DefinitionEntity> dmpBlueprintsMap = new HashMap<>();
|
||||||
|
// for (DmpBlueprintEntity dmpBlueprint : dmpBlueprints) {
|
||||||
|
// DefinitionEntity definitionEntity = this.xmlHandlingService.fromXml(DefinitionEntity.class, dmpBlueprint.getDefinition());
|
||||||
|
// dmpBlueprintsMap.put(dmpBlueprint.getId(), definitionEntity);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// for (DMPDatasetProfile item : items) {
|
||||||
|
// this.entityManager.detach(item);
|
||||||
|
//
|
||||||
|
// DmpDatasetProfileMigrationCollectedInfo dmpDatasetProfileMigrationCollectedInfo = new DmpDatasetProfileMigrationCollectedInfo();
|
||||||
|
//
|
||||||
|
// DmpDatasetProfileData profileData = jsonHandlingService.fromJson(DmpDatasetProfileData.class, item.getData());
|
||||||
|
//
|
||||||
|
// if (profileData == null || profileData.dmpSectionIndex == null || profileData.dmpSectionIndex.isEmpty()){
|
||||||
|
// throw new Exception();
|
||||||
|
// }
|
||||||
|
// DefinitionEntity definition = dmpBlueprintsMap.getOrDefault(item.getDmp().getProfile().getId(), null);
|
||||||
|
// if (definition == null){
|
||||||
|
// throw new Exception();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// for (int sectionIndex: profileData.dmpSectionIndex) {
|
||||||
|
// if ( definition.getSections().size() < sectionIndex) {
|
||||||
|
// throw new Exception();
|
||||||
|
// }
|
||||||
|
// UUID sectionId = definition.getSections().get(sectionIndex).getId();
|
||||||
|
//
|
||||||
|
// DmpDescriptionTemplateEntity data = new DmpDescriptionTemplateEntity();
|
||||||
|
// data.setDescriptionTemplateId(item.getDatasetprofile().getId());
|
||||||
|
// data.setDmpId(item.getDmp().getId());
|
||||||
|
// data.setCreatedAt(Instant.now());
|
||||||
|
// data.setUpdatedAt(Instant.now());
|
||||||
|
// data.setSectionId(sectionId); //TODO
|
||||||
|
// data.setIsActive(IsActive.Active);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// dmpDatasetProfileMigrationCollectedInfo.dmpDescriptionTemplateEntity = data;
|
||||||
|
//
|
||||||
|
// collectedInfoList.add(dmpDatasetProfileMigrationCollectedInfo);
|
||||||
|
// }
|
||||||
|
// return collectedInfoList;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public String migrate() throws JsonProcessingException {
|
||||||
|
// for (DmpDatasetProfileMigrationCollectedInfo collectedInfo : collectDatasetsInfo()) {
|
||||||
|
//// this.entityManager.persist(collectedInfo.dmpDescriptionTemplateEntity);
|
||||||
|
// }
|
||||||
|
// this.entityManager.flush();
|
||||||
|
// return "Migrated dmps";
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public static class DmpDatasetProfileMigrationCollectedInfo {
|
||||||
|
//
|
||||||
|
// public DmpDescriptionTemplateEntity dmpDescriptionTemplateEntity;
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
@JsonIgnoreProperties({"validationErrorModel"})
|
@JsonIgnoreProperties({"validationErrorModel"})
|
||||||
public static class DmpDatasetProfileData {
|
public static class DmpDatasetProfileData {
|
||||||
|
|
||||||
|
|
|
@ -9,27 +9,43 @@ import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.commons.types.dmp.DmpBlueprintValueEntity;
|
import eu.eudat.commons.types.dmp.DmpBlueprintValueEntity;
|
||||||
import eu.eudat.commons.types.dmp.DmpContactEntity;
|
import eu.eudat.commons.types.dmp.DmpContactEntity;
|
||||||
import eu.eudat.commons.types.dmp.DmpPropertiesEntity;
|
import eu.eudat.commons.types.dmp.DmpPropertiesEntity;
|
||||||
|
import eu.eudat.commons.types.dmpblueprint.DefinitionEntity;
|
||||||
|
import eu.eudat.data.DmpBlueprintEntity;
|
||||||
|
import eu.eudat.data.DmpDescriptionTemplateEntity;
|
||||||
import eu.eudat.data.DmpEntity;
|
import eu.eudat.data.DmpEntity;
|
||||||
|
import eu.eudat.query.DmpBlueprintQuery;
|
||||||
|
import eu.old.eudat.data.dao.entities.DMPDao;
|
||||||
|
import eu.old.eudat.data.dao.entities.DmpDatasetProfileDao;
|
||||||
import eu.old.eudat.data.entities.DMP;
|
import eu.old.eudat.data.entities.DMP;
|
||||||
|
import eu.old.eudat.data.entities.DMPDatasetProfile;
|
||||||
import eu.old.eudat.logic.services.operations.DatabaseRepository;
|
import eu.old.eudat.logic.services.operations.DatabaseRepository;
|
||||||
import eu.old.eudat.models.data.dmp.DataManagementPlan;
|
import eu.old.eudat.models.data.dmp.DataManagementPlan;
|
||||||
import eu.old.eudat.queryable.QueryableList;
|
import eu.old.eudat.queryable.QueryableList;
|
||||||
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
import jakarta.persistence.EntityManager;
|
import jakarta.persistence.EntityManager;
|
||||||
|
import jakarta.xml.bind.JAXBException;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
import java.util.List;
|
import java.io.IOException;
|
||||||
import java.util.UUID;
|
import java.time.Instant;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class DmpMigrationService {
|
public class DmpMigrationService {
|
||||||
|
|
||||||
|
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpMigrationService.class));
|
||||||
private final DatabaseRepository databaseRepository;
|
private final DatabaseRepository databaseRepository;
|
||||||
|
|
||||||
private final JsonHandlingService jsonHandlingService;
|
private final JsonHandlingService jsonHandlingService;
|
||||||
|
|
||||||
private final EntityManager entityManager;
|
private final EntityManager entityManager;
|
||||||
|
private static final int PageSize = 500;
|
||||||
|
private static final boolean TestMode = false;
|
||||||
|
|
||||||
public DmpMigrationService(DatabaseRepository databaseRepository, JsonHandlingService jsonHandlingService, EntityManager entityManager) {
|
public DmpMigrationService(DatabaseRepository databaseRepository, JsonHandlingService jsonHandlingService, EntityManager entityManager) {
|
||||||
this.databaseRepository = databaseRepository;
|
this.databaseRepository = databaseRepository;
|
||||||
|
@ -37,98 +53,189 @@ public class DmpMigrationService {
|
||||||
this.entityManager = entityManager;
|
this.entityManager = entityManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public QueryableList<DMP> dmpQueryableList() {
|
public void migrate() throws JsonProcessingException {
|
||||||
return databaseRepository.getDmpDao().asQueryable();
|
DMPDao dmpDao = databaseRepository.getDmpDao();
|
||||||
}
|
long total = dmpDao.asQueryable().count();
|
||||||
|
logger.debug("Migrate Dmp Total : " + total);
|
||||||
|
int page = 0;
|
||||||
|
|
||||||
public List<DataManagementPlan> getDmps(Integer skip, Integer take) {
|
List<DMP> items;
|
||||||
List<DMP> dmps = dmpQueryableList()
|
do {
|
||||||
.orderBy((builder, root) -> builder.desc(root.get("created")))
|
items = dmpDao.asQueryable().orderBy((builder, root) -> builder.asc(root.get("created"))).orderBy((builder, root) -> builder.asc(root.get("ID"))).skip(page * PageSize).take(PageSize).toList();
|
||||||
.skip(skip)
|
if (items != null && !items.isEmpty()) {
|
||||||
.take(take)
|
logger.debug("Migrate Dmp " + page * PageSize + " of " + total);
|
||||||
.toList();
|
|
||||||
|
|
||||||
return dmps.stream().map(x -> {
|
for (DMP item : items) {
|
||||||
DataManagementPlan dmp = new DataManagementPlan();
|
//entityManager.detach(item);
|
||||||
dmp.fromDataModel(x);
|
|
||||||
return dmp;
|
|
||||||
}).toList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<DmpMigrationCollectedInfo> collectDmpsInfo() throws JsonProcessingException {
|
DataManagementPlan model = new DataManagementPlan();
|
||||||
List<DmpMigrationCollectedInfo> collectedInfoList = new ArrayList<>();
|
model.fromDataModel(item);
|
||||||
List<DataManagementPlan> dmps = getDmps(0, 4);
|
|
||||||
for (DataManagementPlan dataManagementPlan : dmps) {
|
|
||||||
DmpMigrationCollectedInfo dmpMigrationCollectedInfo = new DmpMigrationCollectedInfo();
|
|
||||||
|
|
||||||
DmpPropertiesEntity dmpProperties = new DmpPropertiesEntity();
|
DmpPropertiesEntity dmpProperties = new DmpPropertiesEntity();
|
||||||
dmpProperties.setDmpBlueprintValues(new ArrayList<>());
|
dmpProperties.setDmpBlueprintValues(new ArrayList<>());
|
||||||
dmpProperties.setContacts(new ArrayList<>());
|
dmpProperties.setContacts(new ArrayList<>());
|
||||||
|
|
||||||
//Collect basic dmp information
|
DmpEntity data = new DmpEntity();
|
||||||
DmpEntity dmpEntity = new DmpEntity();
|
data.setId(model.getId());
|
||||||
dmpEntity.setId(dataManagementPlan.getId());
|
data.setLabel(model.getLabel());
|
||||||
dmpEntity.setLabel(dataManagementPlan.getLabel());
|
data.setDescription(model.getDescription());
|
||||||
dmpEntity.setDescription(dataManagementPlan.getDescription());
|
if (model.getCreator() != null)
|
||||||
if (dataManagementPlan.getCreator() != null)
|
data.setCreatorId(model.getCreator().getId());
|
||||||
dmpEntity.setCreatorId(dataManagementPlan.getCreator().getId());
|
data.setGroupId(model.getGroupId());
|
||||||
dmpEntity.setGroupId(dataManagementPlan.getGroupId());
|
data.setVersion((short) model.getVersion());
|
||||||
dmpEntity.setVersion((short) dataManagementPlan.getVersion());
|
data.setVersionStatus(DmpVersionStatus.of((short) model.getVersionStatus()));
|
||||||
dmpEntity.setVersionStatus(DmpVersionStatus.of((short) dataManagementPlan.getVersionStatus()));
|
if (model.getCreated() != null)
|
||||||
if (dataManagementPlan.getCreated() != null)
|
data.setCreatedAt(model.getCreated().toInstant());
|
||||||
dmpEntity.setCreatedAt(dataManagementPlan.getCreated().toInstant());
|
if (model.getModified() != null)
|
||||||
if (dataManagementPlan.getModified() != null)
|
data.setUpdatedAt(model.getModified().toInstant());
|
||||||
dmpEntity.setUpdatedAt(dataManagementPlan.getModified().toInstant());
|
if (model.getFinalized() != null)
|
||||||
if (dataManagementPlan.getFinalized() != null)
|
data.setFinalizedAt(model.getFinalized().toInstant());
|
||||||
dmpEntity.setFinalizedAt(dataManagementPlan.getFinalized().toInstant());
|
data.setBlueprintId(model.getProfile().getId());
|
||||||
dmpEntity.setBlueprintId(dataManagementPlan.getProfile().getId());
|
if (model.getExtraProperties() != null) {
|
||||||
if (dataManagementPlan.getExtraProperties() != null) {
|
if (model.getExtraProperties().containsKey("language") && model.getExtraProperties().get("language") != null)
|
||||||
if (dataManagementPlan.getExtraProperties().containsKey("language") && dataManagementPlan.getExtraProperties().get("language") != null)
|
data.setLanguage((String) model.getExtraProperties().get("language"));
|
||||||
dmpEntity.setLanguage((String) dataManagementPlan.getExtraProperties().get("language"));
|
if (model.getExtraProperties().containsKey("visible") && model.getExtraProperties().get("visible") != null)
|
||||||
if (dataManagementPlan.getExtraProperties().containsKey("visible") && dataManagementPlan.getExtraProperties().get("visible") != null)
|
data.setAccessType((boolean) model.getExtraProperties().get("visible") ? DmpAccessType.Public : DmpAccessType.Restricted);
|
||||||
dmpEntity.setAccessType((boolean) dataManagementPlan.getExtraProperties().get("visible") ? DmpAccessType.Public : DmpAccessType.Restricted);
|
if (model.getExtraProperties().containsKey("contact") && model.getExtraProperties().get("contact") != null) {
|
||||||
if (dataManagementPlan.getExtraProperties().containsKey("contact") && dataManagementPlan.getExtraProperties().get("contact") != null) {
|
|
||||||
DmpContactEntity contactEntity = new DmpContactEntity();
|
DmpContactEntity contactEntity = new DmpContactEntity();
|
||||||
contactEntity.setUserId((String) dataManagementPlan.getExtraProperties().get("contact"));
|
contactEntity.setUserId((String) model.getExtraProperties().get("contact"));
|
||||||
dmpProperties.getContacts().add(contactEntity);
|
dmpProperties.getContacts().add(contactEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (dataManagementPlan.getProperties() != null) {
|
if (model.getProperties() != null) {
|
||||||
dataManagementPlan.getProperties().forEach((key,val) -> {
|
model.getProperties().forEach((key,val) -> {
|
||||||
DmpBlueprintValueEntity valueEntity = new DmpBlueprintValueEntity();
|
DmpBlueprintValueEntity valueEntity = new DmpBlueprintValueEntity();
|
||||||
valueEntity.setFieldId(key);
|
valueEntity.setFieldId(key);
|
||||||
valueEntity.setValue((String) val);
|
valueEntity.setValue((String) val);
|
||||||
dmpProperties.getDmpBlueprintValues().add(valueEntity);
|
dmpProperties.getDmpBlueprintValues().add(valueEntity);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (dataManagementPlan.getStatus() == 99) {
|
if (model.getStatus() == 99) {
|
||||||
dmpEntity.setIsActive(IsActive.Inactive);
|
data.setIsActive(IsActive.Inactive);
|
||||||
|
data.setStatus(DmpStatus.Draft);
|
||||||
} else {
|
} else {
|
||||||
dmpEntity.setIsActive(IsActive.Active);
|
data.setIsActive(IsActive.Active);
|
||||||
dmpEntity.setStatus(DmpStatus.of((short) dataManagementPlan.getStatus()));
|
data.setStatus(DmpStatus.of((short) model.getStatus()));
|
||||||
}
|
}
|
||||||
dmpEntity.setProperties(jsonHandlingService.toJson(dmpProperties));
|
data.setProperties(jsonHandlingService.toJson(dmpProperties));
|
||||||
dmpMigrationCollectedInfo.dmpEntity = dmpEntity;
|
|
||||||
|
|
||||||
//Collect dmp Organization info
|
|
||||||
|
|
||||||
collectedInfoList.add(dmpMigrationCollectedInfo);
|
if (data.getAccessType() == null) {
|
||||||
|
logger.warn("AccessType not found set to default for dmp " + item.getId());
|
||||||
|
data.setAccessType(DmpAccessType.Restricted); //TODO
|
||||||
}
|
}
|
||||||
return collectedInfoList;
|
if (data.getLanguage() == null) {
|
||||||
|
logger.warn("Language not found set to default for dmp " + item.getId());
|
||||||
|
data.setLanguage(""); //TODO
|
||||||
|
}
|
||||||
|
if (data.getCreatorId() == null){
|
||||||
|
logger.warn("Migration skipped creator not found " + item.getId());
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String migrate() throws JsonProcessingException {
|
|
||||||
for (DmpMigrationCollectedInfo collectedInfo : collectDmpsInfo()) {
|
this.entityManager.persist(data);
|
||||||
this.entityManager.persist(collectedInfo.dmpEntity);
|
|
||||||
}
|
|
||||||
this.entityManager.flush();
|
this.entityManager.flush();
|
||||||
return "Migrated dmps";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class DmpMigrationCollectedInfo {
|
page++;
|
||||||
|
|
||||||
public DmpEntity dmpEntity;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
} while (items != null && !items.isEmpty() && !TestMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
// public QueryableList<DMP> dmpQueryableList() {
|
||||||
|
// return databaseRepository.getDmpDao().asQueryable();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public List<DataManagementPlan> getDmps(Integer skip, Integer take) {
|
||||||
|
// List<DMP> dmps = dmpQueryableList()
|
||||||
|
// .orderBy((builder, root) -> builder.desc(root.get("created")))
|
||||||
|
// .skip(skip)
|
||||||
|
// .take(take)
|
||||||
|
// .toList();
|
||||||
|
//
|
||||||
|
// return dmps.stream().map(x -> {
|
||||||
|
// DataManagementPlan dmp = new DataManagementPlan();
|
||||||
|
// dmp.fromDataModel(x);
|
||||||
|
// return dmp;
|
||||||
|
// }).toList();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// public List<DmpMigrationCollectedInfo> collectDmpsInfo() throws JsonProcessingException {
|
||||||
|
// List<DmpMigrationCollectedInfo> collectedInfoList = new ArrayList<>();
|
||||||
|
// List<DataManagementPlan> dmps = getDmps(0, Integer.MAX_VALUE);
|
||||||
|
// for (DataManagementPlan dataManagementPlan : dmps) {
|
||||||
|
// DmpMigrationCollectedInfo dmpMigrationCollectedInfo = new DmpMigrationCollectedInfo();
|
||||||
|
//
|
||||||
|
// DmpPropertiesEntity dmpProperties = new DmpPropertiesEntity();
|
||||||
|
// dmpProperties.setDmpBlueprintValues(new ArrayList<>());
|
||||||
|
// dmpProperties.setContacts(new ArrayList<>());
|
||||||
|
//
|
||||||
|
// //Collect basic dmp information
|
||||||
|
// DmpEntity dmpEntity = new DmpEntity();
|
||||||
|
// dmpEntity.setId(dataManagementPlan.getId());
|
||||||
|
// dmpEntity.setLabel(dataManagementPlan.getLabel());
|
||||||
|
// dmpEntity.setDescription(dataManagementPlan.getDescription());
|
||||||
|
// if (dataManagementPlan.getCreator() != null)
|
||||||
|
// dmpEntity.setCreatorId(dataManagementPlan.getCreator().getId());
|
||||||
|
// dmpEntity.setGroupId(dataManagementPlan.getGroupId());
|
||||||
|
// dmpEntity.setVersion((short) dataManagementPlan.getVersion());
|
||||||
|
// dmpEntity.setVersionStatus(DmpVersionStatus.of((short) dataManagementPlan.getVersionStatus()));
|
||||||
|
// if (dataManagementPlan.getCreated() != null)
|
||||||
|
// dmpEntity.setCreatedAt(dataManagementPlan.getCreated().toInstant());
|
||||||
|
// if (dataManagementPlan.getModified() != null)
|
||||||
|
// dmpEntity.setUpdatedAt(dataManagementPlan.getModified().toInstant());
|
||||||
|
// if (dataManagementPlan.getFinalized() != null)
|
||||||
|
// dmpEntity.setFinalizedAt(dataManagementPlan.getFinalized().toInstant());
|
||||||
|
// dmpEntity.setBlueprintId(dataManagementPlan.getProfile().getId());
|
||||||
|
// if (dataManagementPlan.getExtraProperties() != null) {
|
||||||
|
// if (dataManagementPlan.getExtraProperties().containsKey("language") && dataManagementPlan.getExtraProperties().get("language") != null)
|
||||||
|
// dmpEntity.setLanguage((String) dataManagementPlan.getExtraProperties().get("language"));
|
||||||
|
// if (dataManagementPlan.getExtraProperties().containsKey("visible") && dataManagementPlan.getExtraProperties().get("visible") != null)
|
||||||
|
// dmpEntity.setAccessType((boolean) dataManagementPlan.getExtraProperties().get("visible") ? DmpAccessType.Public : DmpAccessType.Restricted);
|
||||||
|
// if (dataManagementPlan.getExtraProperties().containsKey("contact") && dataManagementPlan.getExtraProperties().get("contact") != null) {
|
||||||
|
// DmpContactEntity contactEntity = new DmpContactEntity();
|
||||||
|
// contactEntity.setUserId((String) dataManagementPlan.getExtraProperties().get("contact"));
|
||||||
|
// dmpProperties.getContacts().add(contactEntity);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// if (dataManagementPlan.getProperties() != null) {
|
||||||
|
// dataManagementPlan.getProperties().forEach((key,val) -> {
|
||||||
|
// DmpBlueprintValueEntity valueEntity = new DmpBlueprintValueEntity();
|
||||||
|
// valueEntity.setFieldId(key);
|
||||||
|
// valueEntity.setValue((String) val);
|
||||||
|
// dmpProperties.getDmpBlueprintValues().add(valueEntity);
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// if (dataManagementPlan.getStatus() == 99) {
|
||||||
|
// dmpEntity.setIsActive(IsActive.Inactive);
|
||||||
|
// dmpEntity.setStatus(DmpStatus.Draft);
|
||||||
|
// } else {
|
||||||
|
// dmpEntity.setIsActive(IsActive.Active);
|
||||||
|
// dmpEntity.setStatus(DmpStatus.of((short) dataManagementPlan.getStatus()));
|
||||||
|
// }
|
||||||
|
// dmpEntity.setProperties(jsonHandlingService.toJson(dmpProperties));
|
||||||
|
// dmpMigrationCollectedInfo.dmpEntity = dmpEntity;
|
||||||
|
//
|
||||||
|
// //Collect dmp Organization info
|
||||||
|
//
|
||||||
|
// collectedInfoList.add(dmpMigrationCollectedInfo);
|
||||||
|
// }
|
||||||
|
// return collectedInfoList;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public String migrate() throws JsonProcessingException {
|
||||||
|
// for (DmpMigrationCollectedInfo collectedInfo : collectDmpsInfo()) {
|
||||||
|
// this.entityManager.persist(collectedInfo.dmpEntity);
|
||||||
|
// }
|
||||||
|
// this.entityManager.flush();
|
||||||
|
// return "Migrated dmps";
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public static class DmpMigrationCollectedInfo {
|
||||||
|
//
|
||||||
|
// public DmpEntity dmpEntity;
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,11 +3,16 @@ package eu.old.eudat.publicapi.migration;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import eu.old.eudat.migration.*;
|
import eu.old.eudat.migration.*;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
|
import jakarta.xml.bind.JAXBException;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
@Api(tags = "Migration")
|
@Api(tags = "Migration")
|
||||||
@RestController
|
@RestController
|
||||||
|
@ -56,10 +61,11 @@ public class MigrationController {
|
||||||
this.organizationMigrationService = organizationMigrationService;
|
this.organizationMigrationService = organizationMigrationService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("dmps/migrate")
|
@GetMapping("dmps")
|
||||||
@Transactional
|
@Transactional
|
||||||
public String migrateDmps() throws JsonProcessingException {
|
public boolean migrateDmps() throws JsonProcessingException {
|
||||||
return this.dmpMigrationService.migrate();
|
this.dmpMigrationService.migrate();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("datasets/migrate")
|
@GetMapping("datasets/migrate")
|
||||||
|
@ -68,19 +74,15 @@ public class MigrationController {
|
||||||
return this.datasetMigrationService.migrate();
|
return this.datasetMigrationService.migrate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("dmp-dataset-profiles/migrate")
|
@GetMapping("dmp-dataset-profiles")
|
||||||
@Transactional
|
@Transactional
|
||||||
public String migrateDmpDatasetProfiles() throws JsonProcessingException {
|
public boolean migrateDmpDatasetProfiles() throws IOException, JAXBException, ParserConfigurationException, InstantiationException, IllegalAccessException, SAXException {
|
||||||
return this.dmpDatasetProfileMigrationService.migrate();
|
this.dmpDatasetProfileMigrationService.migrate();
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("organizations/migrate")
|
|
||||||
@Transactional
|
|
||||||
public boolean migrateOrganizations() {
|
|
||||||
this.organizationMigrationService.migrate();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("references")
|
@GetMapping("references")
|
||||||
@Transactional
|
@Transactional
|
||||||
public boolean migrateReferences() {
|
public boolean migrateReferences() {
|
||||||
|
@ -96,6 +98,14 @@ public class MigrationController {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("organizations")
|
||||||
|
@Transactional
|
||||||
|
public boolean migrateOrganizations() {
|
||||||
|
this.organizationMigrationService.migrate();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("dataRepositories")
|
@GetMapping("dataRepositories")
|
||||||
@Transactional
|
@Transactional
|
||||||
public boolean migrateDataRepositories() {
|
public boolean migrateDataRepositories() {
|
||||||
|
|
Loading…
Reference in New Issue