reference migrate
This commit is contained in:
parent
1e92d86356
commit
e47a370088
|
@ -1,8 +1,13 @@
|
|||
package eu.old.eudat.migration;
|
||||
|
||||
import eu.eudat.commons.XmlHandlingService;
|
||||
import eu.eudat.commons.enums.IsActive;
|
||||
import eu.eudat.commons.enums.ReferenceFieldDataType;
|
||||
import eu.eudat.commons.enums.ReferenceSourceType;
|
||||
import eu.eudat.commons.enums.ReferenceType;
|
||||
import eu.eudat.commons.types.reference.DefinitionEntity;
|
||||
import eu.eudat.commons.types.reference.FieldEntity;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.data.ReferenceEntity;
|
||||
import eu.old.eudat.data.dao.entities.DataRepositoryDao;
|
||||
import eu.old.eudat.data.entities.DataRepository;
|
||||
|
@ -23,9 +28,13 @@ public class DataRepositoryMigrationService {
|
|||
private static final String InternalReferenceSource = "dmp";
|
||||
private final DatabaseRepository databaseRepository;
|
||||
private final EntityManager entityManager;
|
||||
public DataRepositoryMigrationService(DatabaseRepository databaseRepository, EntityManager entityManager) {
|
||||
private final ConventionService conventionService;
|
||||
private final XmlHandlingService xmlHandlingService;
|
||||
public DataRepositoryMigrationService(DatabaseRepository databaseRepository, EntityManager entityManager, ConventionService conventionService, XmlHandlingService xmlHandlingService) {
|
||||
this.databaseRepository = databaseRepository;
|
||||
this.entityManager = entityManager;
|
||||
this.conventionService = conventionService;
|
||||
this.xmlHandlingService = xmlHandlingService;
|
||||
}
|
||||
|
||||
public void migrate(){
|
||||
|
@ -50,6 +59,8 @@ public class DataRepositoryMigrationService {
|
|||
String[] referenceParts = item.getReference().split(":", 2);
|
||||
boolean isInternal = referenceParts[0].equals(InternalReferenceSource);
|
||||
|
||||
|
||||
|
||||
ReferenceEntity data = new ReferenceEntity();
|
||||
data.setId(item.getId());
|
||||
data.setLabel(item.getLabel());
|
||||
|
@ -61,6 +72,16 @@ public class DataRepositoryMigrationService {
|
|||
data.setReference(referenceParts[1]);
|
||||
data.setSource(isInternal? "Internal" : referenceParts[0]);
|
||||
data.setSourceType(isInternal? ReferenceSourceType.Internal : ReferenceSourceType.External);
|
||||
if (!this.conventionService.isNullOrEmpty(item.getUri())){
|
||||
DefinitionEntity definitionEntity = new DefinitionEntity();
|
||||
FieldEntity fieldEntity = new FieldEntity();
|
||||
fieldEntity.setCode("uri");
|
||||
fieldEntity.setDataType(ReferenceFieldDataType.Text);
|
||||
fieldEntity.setValue(item.getUri());
|
||||
definitionEntity.setFields(List.of(fieldEntity));
|
||||
data.setDefinition(this.xmlHandlingService.toXmlSafe(definitionEntity));
|
||||
}
|
||||
|
||||
this.entityManager.persist(data);
|
||||
}
|
||||
this.entityManager.flush();
|
||||
|
|
|
@ -54,6 +54,7 @@ public class ExternalDatasetMigrationService {
|
|||
ReferenceEntity data = new ReferenceEntity();
|
||||
data.setId(item.getId());
|
||||
data.setLabel(item.getLabel());
|
||||
data.setAbbreviation(item.getAbbreviation());
|
||||
data.setIsActive(IsActive.Active);
|
||||
data.setType(ReferenceType.Datasets);
|
||||
data.setCreatedAt(item.getCreated().toInstant());
|
||||
|
|
|
@ -54,7 +54,7 @@ public class FunderMigrationService {
|
|||
ReferenceEntity data = new ReferenceEntity();
|
||||
data.setId(item.getId());
|
||||
data.setLabel(item.getLabel());
|
||||
data.setIsActive(DMP.DMPStatus.fromInteger(item.getStatus()).equals(DMP.DMPStatus.DELETED) ? IsActive.Inactive : IsActive.Active);
|
||||
data.setIsActive(IsActive.Active);
|
||||
data.setType(ReferenceType.Funder);
|
||||
data.setCreatedAt(item.getCreated().toInstant());
|
||||
data.setUpdatedAt(item.getModified().toInstant());
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
package eu.old.eudat.migration;
|
||||
|
||||
import eu.eudat.commons.XmlHandlingService;
|
||||
import eu.eudat.commons.enums.IsActive;
|
||||
import eu.eudat.commons.enums.ReferenceFieldDataType;
|
||||
import eu.eudat.commons.enums.ReferenceSourceType;
|
||||
import eu.eudat.commons.enums.ReferenceType;
|
||||
import eu.eudat.commons.types.reference.DefinitionEntity;
|
||||
import eu.eudat.commons.types.reference.FieldEntity;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.data.ReferenceEntity;
|
||||
import eu.old.eudat.data.dao.entities.GrantDao;
|
||||
import eu.old.eudat.data.entities.DMP;
|
||||
import eu.old.eudat.data.entities.Grant;
|
||||
import eu.old.eudat.logic.services.operations.DatabaseRepository;
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
|
@ -13,6 +17,7 @@ import jakarta.persistence.EntityManager;
|
|||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
|
@ -24,9 +29,13 @@ public class GrantMigrationService {
|
|||
private static final String InternalReferenceSource = "dmp";
|
||||
private final DatabaseRepository databaseRepository;
|
||||
private final EntityManager entityManager;
|
||||
public GrantMigrationService(DatabaseRepository databaseRepository, EntityManager entityManager) {
|
||||
private final ConventionService conventionService;
|
||||
private final XmlHandlingService xmlHandlingService;
|
||||
public GrantMigrationService(DatabaseRepository databaseRepository, EntityManager entityManager, ConventionService conventionService, XmlHandlingService xmlHandlingService) {
|
||||
this.databaseRepository = databaseRepository;
|
||||
this.entityManager = entityManager;
|
||||
this.conventionService = conventionService;
|
||||
this.xmlHandlingService = xmlHandlingService;
|
||||
}
|
||||
|
||||
public void migrate(){
|
||||
|
@ -54,7 +63,8 @@ public class GrantMigrationService {
|
|||
data.setId(item.getId());
|
||||
data.setLabel(item.getLabel());
|
||||
data.setDescription(item.getDescription());
|
||||
data.setIsActive(DMP.DMPStatus.fromInteger(item.getStatus()).equals(DMP.DMPStatus.DELETED) ? IsActive.Inactive : IsActive.Active);
|
||||
data.setAbbreviation(item.getAbbreviation());
|
||||
data.setIsActive(IsActive.Active);
|
||||
data.setType(ReferenceType.Grants);
|
||||
data.setCreatedAt(item.getCreated().toInstant());
|
||||
data.setUpdatedAt(item.getModified().toInstant());
|
||||
|
@ -62,6 +72,37 @@ public class GrantMigrationService {
|
|||
data.setReference(referenceParts[1]);
|
||||
data.setSource(isInternal? "Internal" : referenceParts[0]);
|
||||
data.setSourceType(isInternal ? ReferenceSourceType.Internal : ReferenceSourceType.External);
|
||||
|
||||
DefinitionEntity definitionEntity = new DefinitionEntity();
|
||||
definitionEntity.setFields(new ArrayList<>());
|
||||
if (!this.conventionService.isNullOrEmpty(item.getUri())){
|
||||
FieldEntity fieldEntity = new FieldEntity();
|
||||
fieldEntity.setCode("uri");
|
||||
fieldEntity.setDataType(ReferenceFieldDataType.Text);
|
||||
fieldEntity.setValue(item.getUri());
|
||||
definitionEntity.getFields().add(fieldEntity);
|
||||
}
|
||||
|
||||
if (item.getStartdate() != null){
|
||||
FieldEntity fieldEntity = new FieldEntity();
|
||||
fieldEntity.setCode("startDate");
|
||||
fieldEntity.setDataType(ReferenceFieldDataType.Date);
|
||||
fieldEntity.setValue(item.getStartdate().toInstant().toString());
|
||||
definitionEntity.getFields().add(fieldEntity);
|
||||
}
|
||||
|
||||
if (item.getEnddate() != null){
|
||||
FieldEntity fieldEntity = new FieldEntity();
|
||||
fieldEntity.setCode("endDate");
|
||||
fieldEntity.setDataType(ReferenceFieldDataType.Date);
|
||||
fieldEntity.setValue(item.getEnddate().toInstant().toString());
|
||||
definitionEntity.getFields().add(fieldEntity);
|
||||
}
|
||||
|
||||
if (!definitionEntity.getFields().isEmpty()){
|
||||
data.setDefinition(this.xmlHandlingService.toXmlSafe(definitionEntity));
|
||||
}
|
||||
|
||||
this.entityManager.persist(data);
|
||||
}
|
||||
this.entityManager.flush();
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
package eu.old.eudat.migration;
|
||||
|
||||
import eu.eudat.commons.XmlHandlingService;
|
||||
import eu.eudat.commons.enums.IsActive;
|
||||
import eu.eudat.commons.enums.ReferenceFieldDataType;
|
||||
import eu.eudat.commons.enums.ReferenceSourceType;
|
||||
import eu.eudat.commons.enums.ReferenceType;
|
||||
import eu.eudat.commons.types.reference.DefinitionEntity;
|
||||
import eu.eudat.commons.types.reference.FieldEntity;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.data.ReferenceEntity;
|
||||
import eu.old.eudat.data.dao.entities.OrganisationDao;
|
||||
import eu.old.eudat.data.entities.DMP;
|
||||
import eu.old.eudat.data.entities.Organisation;
|
||||
import eu.old.eudat.logic.services.operations.DatabaseRepository;
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
|
@ -13,7 +17,6 @@ import jakarta.persistence.EntityManager;
|
|||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
|
@ -25,9 +28,13 @@ public class OrganizationMigrationService {
|
|||
private static final String InternalReferenceSource = "Internal";
|
||||
private final DatabaseRepository databaseRepository;
|
||||
private final EntityManager entityManager;
|
||||
public OrganizationMigrationService(DatabaseRepository databaseRepository, EntityManager entityManager) {
|
||||
private final ConventionService conventionService;
|
||||
private final XmlHandlingService xmlHandlingService;
|
||||
public OrganizationMigrationService(DatabaseRepository databaseRepository, EntityManager entityManager, ConventionService conventionService, XmlHandlingService xmlHandlingService) {
|
||||
this.databaseRepository = databaseRepository;
|
||||
this.entityManager = entityManager;
|
||||
this.conventionService = conventionService;
|
||||
this.xmlHandlingService = xmlHandlingService;
|
||||
}
|
||||
|
||||
public void migrate(){
|
||||
|
@ -56,7 +63,8 @@ public class OrganizationMigrationService {
|
|||
ReferenceEntity data = new ReferenceEntity();
|
||||
data.setId(item.getId());
|
||||
data.setLabel(item.getLabel());
|
||||
data.setIsActive(DMP.DMPStatus.fromInteger(item.getStatus()).equals(DMP.DMPStatus.DELETED) ? IsActive.Inactive : IsActive.Active);
|
||||
data.setAbbreviation(item.getAbbreviation());
|
||||
data.setIsActive(IsActive.Active);
|
||||
data.setType(ReferenceType.Organizations);
|
||||
data.setCreatedAt(item.getCreated().toInstant());
|
||||
data.setUpdatedAt(item.getModified().toInstant());
|
||||
|
@ -64,6 +72,15 @@ public class OrganizationMigrationService {
|
|||
data.setAbbreviation(item.getAbbreviation());
|
||||
data.setSource(isInternal? "Internal" : referenceParts[0]);
|
||||
data.setSourceType(isInternal? ReferenceSourceType.Internal : ReferenceSourceType.External);
|
||||
if (!this.conventionService.isNullOrEmpty(item.getUri())){
|
||||
DefinitionEntity definitionEntity = new DefinitionEntity();
|
||||
FieldEntity fieldEntity = new FieldEntity();
|
||||
fieldEntity.setCode("uri");
|
||||
fieldEntity.setDataType(ReferenceFieldDataType.Text);
|
||||
fieldEntity.setValue(item.getUri());
|
||||
definitionEntity.setFields(List.of(fieldEntity));
|
||||
data.setDefinition(this.xmlHandlingService.toXmlSafe(definitionEntity));
|
||||
}
|
||||
this.entityManager.persist(data);
|
||||
}
|
||||
this.entityManager.flush();
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
package eu.old.eudat.migration;
|
||||
|
||||
import eu.eudat.commons.XmlHandlingService;
|
||||
import eu.eudat.commons.enums.IsActive;
|
||||
import eu.eudat.commons.enums.ReferenceFieldDataType;
|
||||
import eu.eudat.commons.enums.ReferenceSourceType;
|
||||
import eu.eudat.commons.enums.ReferenceType;
|
||||
import eu.eudat.commons.types.reference.DefinitionEntity;
|
||||
import eu.eudat.commons.types.reference.FieldEntity;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.data.ReferenceEntity;
|
||||
import eu.old.eudat.data.dao.entities.ProjectDao;
|
||||
import eu.old.eudat.data.entities.DMP;
|
||||
import eu.old.eudat.data.entities.Project;
|
||||
import eu.old.eudat.logic.services.operations.DatabaseRepository;
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
|
@ -13,6 +17,7 @@ import jakarta.persistence.EntityManager;
|
|||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
|
@ -24,9 +29,13 @@ public class ProjectMigrationService {
|
|||
private static final String InternalReferenceSource = "dmp";
|
||||
private final DatabaseRepository databaseRepository;
|
||||
private final EntityManager entityManager;
|
||||
public ProjectMigrationService(DatabaseRepository databaseRepository, EntityManager entityManager) {
|
||||
private final ConventionService conventionService;
|
||||
private final XmlHandlingService xmlHandlingService;
|
||||
public ProjectMigrationService(DatabaseRepository databaseRepository, EntityManager entityManager, ConventionService conventionService, XmlHandlingService xmlHandlingService) {
|
||||
this.databaseRepository = databaseRepository;
|
||||
this.entityManager = entityManager;
|
||||
this.conventionService = conventionService;
|
||||
this.xmlHandlingService = xmlHandlingService;
|
||||
}
|
||||
|
||||
public void migrate(){
|
||||
|
@ -54,8 +63,9 @@ public class ProjectMigrationService {
|
|||
ReferenceEntity data = new ReferenceEntity();
|
||||
data.setId(item.getId());
|
||||
data.setLabel(item.getLabel());
|
||||
data.setAbbreviation(item.getAbbreviation());
|
||||
data.setDescription(item.getDescription());
|
||||
data.setIsActive(DMP.DMPStatus.fromInteger(item.getStatus()).equals(DMP.DMPStatus.DELETED) ? IsActive.Inactive : IsActive.Active);
|
||||
data.setIsActive(IsActive.Active);
|
||||
data.setType(ReferenceType.Project);
|
||||
data.setCreatedAt(item.getCreated().toInstant());
|
||||
data.setUpdatedAt(item.getModified().toInstant());
|
||||
|
@ -63,6 +73,36 @@ public class ProjectMigrationService {
|
|||
data.setReference(referenceParts[1]);
|
||||
data.setSource(isInternal? "Internal" : referenceParts[0]);
|
||||
data.setSourceType(Project.ProjectType.INTERNAL.getValue().equals(item.getType())? ReferenceSourceType.Internal : ReferenceSourceType.External);
|
||||
|
||||
DefinitionEntity definitionEntity = new DefinitionEntity();
|
||||
definitionEntity.setFields(new ArrayList<>());
|
||||
if (!this.conventionService.isNullOrEmpty(item.getUri())){
|
||||
FieldEntity fieldEntity = new FieldEntity();
|
||||
fieldEntity.setCode("uri");
|
||||
fieldEntity.setDataType(ReferenceFieldDataType.Text);
|
||||
fieldEntity.setValue(item.getUri());
|
||||
definitionEntity.getFields().add(fieldEntity);
|
||||
}
|
||||
|
||||
if (item.getStartdate() != null){
|
||||
FieldEntity fieldEntity = new FieldEntity();
|
||||
fieldEntity.setCode("startDate");
|
||||
fieldEntity.setDataType(ReferenceFieldDataType.Date);
|
||||
fieldEntity.setValue(item.getStartdate().toInstant().toString());
|
||||
definitionEntity.getFields().add(fieldEntity);
|
||||
}
|
||||
|
||||
if (item.getEnddate() != null){
|
||||
FieldEntity fieldEntity = new FieldEntity();
|
||||
fieldEntity.setCode("endDate");
|
||||
fieldEntity.setDataType(ReferenceFieldDataType.Date);
|
||||
fieldEntity.setValue(item.getEnddate().toInstant().toString());
|
||||
definitionEntity.getFields().add(fieldEntity);
|
||||
}
|
||||
|
||||
if (!definitionEntity.getFields().isEmpty()){
|
||||
data.setDefinition(this.xmlHandlingService.toXmlSafe(definitionEntity));
|
||||
}
|
||||
this.entityManager.persist(data);
|
||||
}
|
||||
this.entityManager.flush();
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
package eu.old.eudat.migration;
|
||||
|
||||
import eu.eudat.commons.XmlHandlingService;
|
||||
import eu.eudat.commons.enums.IsActive;
|
||||
import eu.eudat.commons.enums.ReferenceFieldDataType;
|
||||
import eu.eudat.commons.enums.ReferenceSourceType;
|
||||
import eu.eudat.commons.enums.ReferenceType;
|
||||
import eu.eudat.commons.types.reference.DefinitionEntity;
|
||||
import eu.eudat.commons.types.reference.FieldEntity;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.data.ReferenceEntity;
|
||||
import eu.old.eudat.data.dao.entities.RegistryDao;
|
||||
import eu.old.eudat.data.entities.DMP;
|
||||
import eu.old.eudat.data.entities.Registry;
|
||||
import eu.old.eudat.logic.services.operations.DatabaseRepository;
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
|
@ -24,9 +28,13 @@ public class RegistryMigrationService {
|
|||
private static final String InternalReferenceSource = "dmp";
|
||||
private final DatabaseRepository databaseRepository;
|
||||
private final EntityManager entityManager;
|
||||
public RegistryMigrationService(DatabaseRepository databaseRepository, EntityManager entityManager) {
|
||||
private final ConventionService conventionService;
|
||||
private final XmlHandlingService xmlHandlingService;
|
||||
public RegistryMigrationService(DatabaseRepository databaseRepository, EntityManager entityManager, ConventionService conventionService, XmlHandlingService xmlHandlingService) {
|
||||
this.databaseRepository = databaseRepository;
|
||||
this.entityManager = entityManager;
|
||||
this.conventionService = conventionService;
|
||||
this.xmlHandlingService = xmlHandlingService;
|
||||
}
|
||||
|
||||
public void migrate(){
|
||||
|
@ -54,7 +62,8 @@ public class RegistryMigrationService {
|
|||
ReferenceEntity data = new ReferenceEntity();
|
||||
data.setId(item.getId());
|
||||
data.setLabel(item.getLabel());
|
||||
data.setIsActive(DMP.DMPStatus.fromInteger(item.getStatus()).equals(DMP.DMPStatus.DELETED) ? IsActive.Inactive : IsActive.Active);
|
||||
data.setAbbreviation(item.getAbbreviation());
|
||||
data.setIsActive(IsActive.Active);
|
||||
data.setType(ReferenceType.Registries);
|
||||
data.setCreatedAt(item.getCreated().toInstant());
|
||||
data.setUpdatedAt(item.getModified().toInstant());
|
||||
|
@ -62,6 +71,15 @@ public class RegistryMigrationService {
|
|||
data.setReference(referenceParts[1]);
|
||||
data.setSource(isInternal? "Internal" : referenceParts[0]);
|
||||
data.setSourceType(isInternal? ReferenceSourceType.Internal : ReferenceSourceType.External);
|
||||
if (!this.conventionService.isNullOrEmpty(item.getUri())){
|
||||
DefinitionEntity definitionEntity = new DefinitionEntity();
|
||||
FieldEntity fieldEntity = new FieldEntity();
|
||||
fieldEntity.setCode("uri");
|
||||
fieldEntity.setDataType(ReferenceFieldDataType.Text);
|
||||
fieldEntity.setValue(item.getUri());
|
||||
definitionEntity.setFields(List.of(fieldEntity));
|
||||
data.setDefinition(this.xmlHandlingService.toXmlSafe(definitionEntity));
|
||||
}
|
||||
this.entityManager.persist(data);
|
||||
}
|
||||
this.entityManager.flush();
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
package eu.old.eudat.migration;
|
||||
|
||||
import eu.eudat.commons.XmlHandlingService;
|
||||
import eu.eudat.commons.enums.IsActive;
|
||||
import eu.eudat.commons.enums.ReferenceFieldDataType;
|
||||
import eu.eudat.commons.enums.ReferenceSourceType;
|
||||
import eu.eudat.commons.enums.ReferenceType;
|
||||
import eu.eudat.commons.types.reference.DefinitionEntity;
|
||||
import eu.eudat.commons.types.reference.FieldEntity;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.data.ReferenceEntity;
|
||||
import eu.old.eudat.data.dao.entities.OrganisationDao;
|
||||
import eu.old.eudat.data.dao.entities.ResearcherDao;
|
||||
import eu.old.eudat.data.entities.DMP;
|
||||
import eu.old.eudat.data.entities.Organisation;
|
||||
import eu.old.eudat.data.entities.Researcher;
|
||||
import eu.old.eudat.logic.services.operations.DatabaseRepository;
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
|
@ -15,6 +17,7 @@ import jakarta.persistence.EntityManager;
|
|||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
|
@ -26,9 +29,13 @@ public class ResearcherMigrationService {
|
|||
private static final String InternalReferenceSource = "dmp";
|
||||
private final DatabaseRepository databaseRepository;
|
||||
private final EntityManager entityManager;
|
||||
public ResearcherMigrationService(DatabaseRepository databaseRepository, EntityManager entityManager) {
|
||||
private final ConventionService conventionService;
|
||||
private final XmlHandlingService xmlHandlingService;
|
||||
public ResearcherMigrationService(DatabaseRepository databaseRepository, EntityManager entityManager, ConventionService conventionService, XmlHandlingService xmlHandlingService) {
|
||||
this.databaseRepository = databaseRepository;
|
||||
this.entityManager = entityManager;
|
||||
this.conventionService = conventionService;
|
||||
this.xmlHandlingService = xmlHandlingService;
|
||||
}
|
||||
|
||||
public void migrate(){
|
||||
|
@ -56,7 +63,7 @@ public class ResearcherMigrationService {
|
|||
ReferenceEntity data = new ReferenceEntity();
|
||||
data.setId(item.getId());
|
||||
data.setLabel(item.getLabel());
|
||||
data.setIsActive(DMP.DMPStatus.fromInteger(item.getStatus()).equals(DMP.DMPStatus.DELETED) ? IsActive.Inactive : IsActive.Active);
|
||||
data.setIsActive(IsActive.Active);
|
||||
data.setType(ReferenceType.Researcher);
|
||||
data.setCreatedAt(item.getCreated().toInstant());
|
||||
data.setUpdatedAt(item.getModified().toInstant());
|
||||
|
@ -64,6 +71,29 @@ public class ResearcherMigrationService {
|
|||
data.setReference(referenceParts[1]);
|
||||
data.setSource(isInternal? "Internal" : referenceParts[0]);
|
||||
data.setSourceType(isInternal? ReferenceSourceType.Internal : ReferenceSourceType.External);
|
||||
|
||||
DefinitionEntity definitionEntity = new DefinitionEntity();
|
||||
definitionEntity.setFields(new ArrayList<>());
|
||||
if (!this.conventionService.isNullOrEmpty(item.getUri())){
|
||||
FieldEntity fieldEntity = new FieldEntity();
|
||||
fieldEntity.setCode("uri");
|
||||
fieldEntity.setDataType(ReferenceFieldDataType.Text);
|
||||
fieldEntity.setValue(item.getUri());
|
||||
definitionEntity.getFields().add(fieldEntity);
|
||||
}
|
||||
if (!this.conventionService.isNullOrEmpty(item.getPrimaryEmail())){
|
||||
FieldEntity fieldEntity = new FieldEntity();
|
||||
fieldEntity.setCode("primaryEmail");
|
||||
fieldEntity.setDataType(ReferenceFieldDataType.Text);
|
||||
fieldEntity.setValue(item.getPrimaryEmail());
|
||||
definitionEntity.getFields().add(fieldEntity);
|
||||
}
|
||||
|
||||
|
||||
if (!definitionEntity.getFields().isEmpty()){
|
||||
data.setDefinition(this.xmlHandlingService.toXmlSafe(definitionEntity));
|
||||
}
|
||||
|
||||
this.entityManager.persist(data);
|
||||
}
|
||||
this.entityManager.flush();
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
package eu.old.eudat.migration;
|
||||
|
||||
import eu.eudat.commons.XmlHandlingService;
|
||||
import eu.eudat.commons.enums.IsActive;
|
||||
import eu.eudat.commons.enums.ReferenceFieldDataType;
|
||||
import eu.eudat.commons.enums.ReferenceSourceType;
|
||||
import eu.eudat.commons.enums.ReferenceType;
|
||||
import eu.eudat.commons.types.reference.DefinitionEntity;
|
||||
import eu.eudat.commons.types.reference.FieldEntity;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.data.ReferenceEntity;
|
||||
import eu.old.eudat.data.dao.entities.ServiceDao;
|
||||
import eu.old.eudat.data.entities.DMP;
|
||||
import eu.old.eudat.logic.services.operations.DatabaseRepository;
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
import jakarta.persistence.EntityManager;
|
||||
|
@ -23,9 +27,13 @@ public class ServiceMigrationService {
|
|||
private static final String InternalReferenceSource = "dmp";
|
||||
private final DatabaseRepository databaseRepository;
|
||||
private final EntityManager entityManager;
|
||||
public ServiceMigrationService(DatabaseRepository databaseRepository, EntityManager entityManager) {
|
||||
private final ConventionService conventionService;
|
||||
private final XmlHandlingService xmlHandlingService;
|
||||
public ServiceMigrationService(DatabaseRepository databaseRepository, EntityManager entityManager, ConventionService conventionService, XmlHandlingService xmlHandlingService) {
|
||||
this.databaseRepository = databaseRepository;
|
||||
this.entityManager = entityManager;
|
||||
this.conventionService = conventionService;
|
||||
this.xmlHandlingService = xmlHandlingService;
|
||||
}
|
||||
|
||||
public void migrate(){
|
||||
|
@ -53,8 +61,8 @@ public class ServiceMigrationService {
|
|||
ReferenceEntity data = new ReferenceEntity();
|
||||
data.setId(item.getId());
|
||||
data.setLabel(item.getLabel());
|
||||
data.setDescription(item.getLabel());
|
||||
data.setIsActive(DMP.DMPStatus.fromInteger(item.getStatus()).equals(DMP.DMPStatus.DELETED) ? IsActive.Inactive : IsActive.Active);
|
||||
data.setAbbreviation(item.getAbbreviation());
|
||||
data.setIsActive(IsActive.Active);
|
||||
data.setType(ReferenceType.Services);
|
||||
data.setCreatedAt(item.getCreated().toInstant());
|
||||
data.setUpdatedAt(item.getModified().toInstant());
|
||||
|
@ -62,6 +70,16 @@ public class ServiceMigrationService {
|
|||
data.setReference(referenceParts[1]);
|
||||
data.setSource(isInternal? "Internal" : referenceParts[0]);
|
||||
data.setSourceType(isInternal? ReferenceSourceType.Internal : ReferenceSourceType.External);
|
||||
if (!this.conventionService.isNullOrEmpty(item.getUri())){
|
||||
DefinitionEntity definitionEntity = new DefinitionEntity();
|
||||
FieldEntity fieldEntity = new FieldEntity();
|
||||
fieldEntity.setCode("uri");
|
||||
fieldEntity.setDataType(ReferenceFieldDataType.Text);
|
||||
fieldEntity.setValue(item.getUri());
|
||||
definitionEntity.setFields(List.of(fieldEntity));
|
||||
data.setDefinition(this.xmlHandlingService.toXmlSafe(definitionEntity));
|
||||
}
|
||||
|
||||
this.entityManager.persist(data);
|
||||
}
|
||||
this.entityManager.flush();
|
||||
|
|
Loading…
Reference in New Issue