Merge branch 'dmp-refactoring' of https://code-repo.d4science.org/MaDgiK-CITE/argos into dmp-refactoring
This commit is contained in:
commit
a3c7fc13a8
|
@ -51,12 +51,12 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.opencdmp</groupId>
|
<groupId>org.opencdmp</groupId>
|
||||||
<artifactId>repositorydepositbase</artifactId>
|
<artifactId>repositorydepositbase</artifactId>
|
||||||
<version>2.0.15</version>
|
<version>2.0.16</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.opencdmp</groupId>
|
<groupId>org.opencdmp</groupId>
|
||||||
<artifactId>common-models</artifactId>
|
<artifactId>common-models</artifactId>
|
||||||
<version>0.0.18</version>
|
<version>0.0.19</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>gr.cite</groupId>
|
<groupId>gr.cite</groupId>
|
||||||
|
@ -66,7 +66,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.opencdmp</groupId>
|
<groupId>org.opencdmp</groupId>
|
||||||
<artifactId>file-transformer-base</artifactId>
|
<artifactId>file-transformer-base</artifactId>
|
||||||
<version>0.0.23</version>
|
<version>0.0.24</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>gr.cite</groupId>
|
<groupId>gr.cite</groupId>
|
||||||
|
|
|
@ -5,8 +5,8 @@ import gr.cite.tools.data.query.QueryFactory;
|
||||||
import gr.cite.tools.exception.MyApplicationException;
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
import gr.cite.tools.logging.LoggerService;
|
import gr.cite.tools.logging.LoggerService;
|
||||||
import org.opencdmp.authorization.AuthorizationFlags;
|
import org.opencdmp.authorization.AuthorizationFlags;
|
||||||
import org.opencdmp.commonmodels.enums.DmpUserRole;
|
import org.opencdmp.commonmodels.enums.PlanUserRole;
|
||||||
import org.opencdmp.commonmodels.models.DmpUserModel;
|
import org.opencdmp.commonmodels.models.PlanUserModel;
|
||||||
import org.opencdmp.commonmodels.models.UserModel;
|
import org.opencdmp.commonmodels.models.UserModel;
|
||||||
import org.opencdmp.commons.enums.IsActive;
|
import org.opencdmp.commons.enums.IsActive;
|
||||||
import org.opencdmp.convention.ConventionService;
|
import org.opencdmp.convention.ConventionService;
|
||||||
|
@ -24,7 +24,7 @@ import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
public class PlanUserCommonModelBuilder extends BaseCommonModelBuilder<DmpUserModel, PlanUserEntity> {
|
public class PlanUserCommonModelBuilder extends BaseCommonModelBuilder<PlanUserModel, PlanUserEntity> {
|
||||||
|
|
||||||
private final BuilderFactory builderFactory;
|
private final BuilderFactory builderFactory;
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ public class PlanUserCommonModelBuilder extends BaseCommonModelBuilder<DmpUserMo
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<CommonModelBuilderItemResponse<DmpUserModel, PlanUserEntity>> buildInternal(List<PlanUserEntity> data) throws MyApplicationException {
|
protected List<CommonModelBuilderItemResponse<PlanUserModel, PlanUserEntity>> buildInternal(List<PlanUserEntity> data) throws MyApplicationException {
|
||||||
this.logger.debug("building for {} items ", Optional.ofNullable(data).map(List::size).orElse(0));
|
this.logger.debug("building for {} items ", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
if (data == null)
|
if (data == null)
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
|
@ -55,14 +55,14 @@ public class PlanUserCommonModelBuilder extends BaseCommonModelBuilder<DmpUserMo
|
||||||
|
|
||||||
Map<UUID, UserModel> userItemsMap = this.collectUsers(data);
|
Map<UUID, UserModel> userItemsMap = this.collectUsers(data);
|
||||||
|
|
||||||
List<CommonModelBuilderItemResponse<DmpUserModel, PlanUserEntity>> models = new ArrayList<>();
|
List<CommonModelBuilderItemResponse<PlanUserModel, PlanUserEntity>> models = new ArrayList<>();
|
||||||
for (PlanUserEntity d : data) {
|
for (PlanUserEntity d : data) {
|
||||||
DmpUserModel m = new DmpUserModel();
|
PlanUserModel m = new PlanUserModel();
|
||||||
switch (d.getRole()){
|
switch (d.getRole()){
|
||||||
case Viewer -> m.setRole(DmpUserRole.Viewer);
|
case Viewer -> m.setRole(PlanUserRole.Viewer);
|
||||||
case Owner -> m.setRole(DmpUserRole.Owner);
|
case Owner -> m.setRole(PlanUserRole.Owner);
|
||||||
case DescriptionContributor -> m.setRole(DmpUserRole.DescriptionContributor);
|
case DescriptionContributor -> m.setRole(PlanUserRole.DescriptionContributor);
|
||||||
case Reviewer -> m.setRole(DmpUserRole.Reviewer);
|
case Reviewer -> m.setRole(PlanUserRole.Reviewer);
|
||||||
default -> throw new MyApplicationException("unrecognized type " + d.getRole().getValue());
|
default -> throw new MyApplicationException("unrecognized type " + d.getRole().getValue());
|
||||||
}
|
}
|
||||||
if (userItemsMap != null && userItemsMap.containsKey(d.getUserId())) m.setUser(userItemsMap.get(d.getUserId()));
|
if (userItemsMap != null && userItemsMap.containsKey(d.getUserId())) m.setUser(userItemsMap.get(d.getUserId()));
|
||||||
|
|
|
@ -9,7 +9,7 @@ import org.opencdmp.authorization.AuthorizationFlags;
|
||||||
import org.opencdmp.commonmodels.enums.DescriptionStatus;
|
import org.opencdmp.commonmodels.enums.DescriptionStatus;
|
||||||
import org.opencdmp.commonmodels.models.description.DescriptionModel;
|
import org.opencdmp.commonmodels.models.description.DescriptionModel;
|
||||||
import org.opencdmp.commonmodels.models.descriptiotemplate.DescriptionTemplateModel;
|
import org.opencdmp.commonmodels.models.descriptiotemplate.DescriptionTemplateModel;
|
||||||
import org.opencdmp.commonmodels.models.dmp.DmpModel;
|
import org.opencdmp.commonmodels.models.plan.PlanModel;
|
||||||
import org.opencdmp.commons.JsonHandlingService;
|
import org.opencdmp.commons.JsonHandlingService;
|
||||||
import org.opencdmp.commons.XmlHandlingService;
|
import org.opencdmp.commons.XmlHandlingService;
|
||||||
import org.opencdmp.commons.types.description.PropertyDefinitionEntity;
|
import org.opencdmp.commons.types.description.PropertyDefinitionEntity;
|
||||||
|
@ -87,7 +87,7 @@ public class DescriptionCommonModelBuilder extends BaseCommonModelBuilder<Descri
|
||||||
if (data == null || data.isEmpty()) return new ArrayList<>();
|
if (data == null || data.isEmpty()) return new ArrayList<>();
|
||||||
|
|
||||||
Map<UUID, DescriptionTemplateModel> descriptionTemplates = this.collectDescriptionTemplates(data);
|
Map<UUID, DescriptionTemplateModel> descriptionTemplates = this.collectDescriptionTemplates(data);
|
||||||
Map<UUID, DmpModel> plans = this.collectPlans(data);
|
Map<UUID, PlanModel> plans = this.collectPlans(data);
|
||||||
|
|
||||||
Map<UUID, DefinitionEntity> definitionEntityMap = this.collectDescriptionTemplateDefinitions(data);
|
Map<UUID, DefinitionEntity> definitionEntityMap = this.collectDescriptionTemplateDefinitions(data);
|
||||||
Map<UUID, UUID> planDescriptionTemplateSections = this.collectPlanDescriptionTemplateSections(data);
|
Map<UUID, UUID> planDescriptionTemplateSections = this.collectPlanDescriptionTemplateSections(data);
|
||||||
|
@ -106,7 +106,7 @@ public class DescriptionCommonModelBuilder extends BaseCommonModelBuilder<Descri
|
||||||
}
|
}
|
||||||
m.setCreatedAt(d.getCreatedAt());
|
m.setCreatedAt(d.getCreatedAt());
|
||||||
m.setDescription(d.getDescription());
|
m.setDescription(d.getDescription());
|
||||||
if (plans != null && d.getPlanId() != null && plans.containsKey(d.getPlanId())) m.setDmp(plans.get(d.getPlanId()));
|
if (plans != null && d.getPlanId() != null && plans.containsKey(d.getPlanId())) m.setPlan(plans.get(d.getPlanId()));
|
||||||
if (planDescriptionTemplateSections != null && d.getPlanDescriptionTemplateId() != null && planDescriptionTemplateSections.containsKey(d.getPlanDescriptionTemplateId())) m.setSectionId(planDescriptionTemplateSections.get(d.getPlanDescriptionTemplateId()));
|
if (planDescriptionTemplateSections != null && d.getPlanDescriptionTemplateId() != null && planDescriptionTemplateSections.containsKey(d.getPlanDescriptionTemplateId())) m.setSectionId(planDescriptionTemplateSections.get(d.getPlanDescriptionTemplateId()));
|
||||||
if (descriptionTemplates != null && d.getDescriptionTemplateId() != null && descriptionTemplates.containsKey(d.getDescriptionTemplateId())) m.setDescriptionTemplate(descriptionTemplates.get(d.getDescriptionTemplateId()));
|
if (descriptionTemplates != null && d.getDescriptionTemplateId() != null && descriptionTemplates.containsKey(d.getDescriptionTemplateId())) m.setDescriptionTemplate(descriptionTemplates.get(d.getDescriptionTemplateId()));
|
||||||
if (d.getProperties() != null){
|
if (d.getProperties() != null){
|
||||||
|
@ -155,12 +155,12 @@ public class DescriptionCommonModelBuilder extends BaseCommonModelBuilder<Descri
|
||||||
return itemMap;
|
return itemMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<UUID, DmpModel> collectPlans(List<DescriptionEntity> data) throws MyApplicationException {
|
private Map<UUID, PlanModel> collectPlans(List<DescriptionEntity> data) throws MyApplicationException {
|
||||||
if (data.isEmpty())
|
if (data.isEmpty())
|
||||||
return null;
|
return null;
|
||||||
this.logger.debug("checking related - {}", DmpModel.class.getSimpleName());
|
this.logger.debug("checking related - {}", PlanModel.class.getSimpleName());
|
||||||
|
|
||||||
Map<UUID, DmpModel> itemMap;
|
Map<UUID, PlanModel> itemMap;
|
||||||
PlanQuery q = this.queryFactory.query(PlanQuery.class).authorize(this.authorize).disableTracking().ids(data.stream().map(DescriptionEntity::getPlanId).distinct().collect(Collectors.toList()));
|
PlanQuery q = this.queryFactory.query(PlanQuery.class).authorize(this.authorize).disableTracking().ids(data.stream().map(DescriptionEntity::getPlanId).distinct().collect(Collectors.toList()));
|
||||||
itemMap = this.builderFactory.builder(PlanCommonModelBuilder.class).setRepositoryId(this.repositoryId).useSharedStorage(this.useSharedStorage).setDisableDescriptions(true).authorize(this.authorize).asForeignKey(q, PlanEntity::getId);
|
itemMap = this.builderFactory.builder(PlanCommonModelBuilder.class).setRepositoryId(this.repositoryId).useSharedStorage(this.useSharedStorage).setDisableDescriptions(true).authorize(this.authorize).asForeignKey(q, PlanEntity::getId);
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ public abstract class BaseFieldDataCommonModelBuilder<Model extends BaseFieldDat
|
||||||
case SELECT -> m.setFieldType(FieldType.SELECT);
|
case SELECT -> m.setFieldType(FieldType.SELECT);
|
||||||
case BOOLEAN_DECISION -> m.setFieldType(FieldType.BOOLEAN_DECISION);
|
case BOOLEAN_DECISION -> m.setFieldType(FieldType.BOOLEAN_DECISION);
|
||||||
case RADIO_BOX -> m.setFieldType(FieldType.RADIO_BOX);
|
case RADIO_BOX -> m.setFieldType(FieldType.RADIO_BOX);
|
||||||
case INTERNAL_ENTRIES_PLANS -> m.setFieldType(FieldType.INTERNAL_ENTRIES_DMPS);
|
case INTERNAL_ENTRIES_PLANS -> m.setFieldType(FieldType.INTERNAL_ENTRIES_PlANS);
|
||||||
case INTERNAL_ENTRIES_DESCRIPTIONS -> m.setFieldType(FieldType.INTERNAL_ENTRIES_DESCRIPTIONS);
|
case INTERNAL_ENTRIES_DESCRIPTIONS -> m.setFieldType(FieldType.INTERNAL_ENTRIES_DESCRIPTIONS);
|
||||||
case CHECK_BOX -> m.setFieldType(FieldType.CHECK_BOX);
|
case CHECK_BOX -> m.setFieldType(FieldType.CHECK_BOX);
|
||||||
case FREE_TEXT -> m.setFieldType(FieldType.FREE_TEXT);
|
case FREE_TEXT -> m.setFieldType(FieldType.FREE_TEXT);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package org.opencdmp.model.builder.commonmodels.plan;
|
package org.opencdmp.model.builder.commonmodels.plan;
|
||||||
|
|
||||||
import org.opencdmp.authorization.AuthorizationFlags;
|
import org.opencdmp.authorization.AuthorizationFlags;
|
||||||
import org.opencdmp.commonmodels.models.dmp.DmpBlueprintValueModel;
|
import org.opencdmp.commonmodels.models.plan.PlanBlueprintValueModel;
|
||||||
import org.opencdmp.commons.enums.PlanBlueprintExtraFieldDataType;
|
import org.opencdmp.commons.enums.PlanBlueprintExtraFieldDataType;
|
||||||
import org.opencdmp.commons.enums.PlanBlueprintFieldCategory;
|
import org.opencdmp.commons.enums.PlanBlueprintFieldCategory;
|
||||||
import org.opencdmp.commons.types.plan.PlanBlueprintValueEntity;
|
import org.opencdmp.commons.types.plan.PlanBlueprintValueEntity;
|
||||||
|
@ -26,7 +26,7 @@ import java.util.Optional;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
public class PlanBlueprintValueCommonModelBuilder extends BaseCommonModelBuilder<DmpBlueprintValueModel, PlanBlueprintValueEntity> {
|
public class PlanBlueprintValueCommonModelBuilder extends BaseCommonModelBuilder<PlanBlueprintValueModel, PlanBlueprintValueEntity> {
|
||||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
private DefinitionEntity definition;
|
private DefinitionEntity definition;
|
||||||
|
|
||||||
|
@ -48,17 +48,17 @@ public class PlanBlueprintValueCommonModelBuilder extends BaseCommonModelBuilder
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<CommonModelBuilderItemResponse<DmpBlueprintValueModel, PlanBlueprintValueEntity>> buildInternal(List<PlanBlueprintValueEntity> data) throws MyApplicationException {
|
protected List<CommonModelBuilderItemResponse<PlanBlueprintValueModel, PlanBlueprintValueEntity>> buildInternal(List<PlanBlueprintValueEntity> data) throws MyApplicationException {
|
||||||
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
if (data == null || data.isEmpty()) return new ArrayList<>();
|
if (data == null || data.isEmpty()) return new ArrayList<>();
|
||||||
|
|
||||||
List<CommonModelBuilderItemResponse<DmpBlueprintValueModel, PlanBlueprintValueEntity>> models = new ArrayList<>();
|
List<CommonModelBuilderItemResponse<PlanBlueprintValueModel, PlanBlueprintValueEntity>> models = new ArrayList<>();
|
||||||
for (PlanBlueprintValueEntity d : data) {
|
for (PlanBlueprintValueEntity d : data) {
|
||||||
FieldEntity fieldEntity = this.definition != null ? this.definition.getFieldById(d.getFieldId()).stream().findFirst().orElse(null) : null;
|
FieldEntity fieldEntity = this.definition != null ? this.definition.getFieldById(d.getFieldId()).stream().findFirst().orElse(null) : null;
|
||||||
|
|
||||||
if (fieldEntity != null && fieldEntity.getCategory().equals(PlanBlueprintFieldCategory.Extra)) {
|
if (fieldEntity != null && fieldEntity.getCategory().equals(PlanBlueprintFieldCategory.Extra)) {
|
||||||
ExtraFieldEntity extraFieldEntity = (ExtraFieldEntity) fieldEntity;
|
ExtraFieldEntity extraFieldEntity = (ExtraFieldEntity) fieldEntity;
|
||||||
DmpBlueprintValueModel m = new DmpBlueprintValueModel();
|
PlanBlueprintValueModel m = new PlanBlueprintValueModel();
|
||||||
m.setFieldId(d.getFieldId());
|
m.setFieldId(d.getFieldId());
|
||||||
if (extraFieldEntity != null && PlanBlueprintExtraFieldDataType.isDateType(extraFieldEntity.getType())){
|
if (extraFieldEntity != null && PlanBlueprintExtraFieldDataType.isDateType(extraFieldEntity.getType())){
|
||||||
m.setDateValue(d.getDateValue());
|
m.setDateValue(d.getDateValue());
|
||||||
|
|
|
@ -7,16 +7,16 @@ import gr.cite.tools.exception.MyApplicationException;
|
||||||
import gr.cite.tools.fieldset.BaseFieldSet;
|
import gr.cite.tools.fieldset.BaseFieldSet;
|
||||||
import gr.cite.tools.logging.LoggerService;
|
import gr.cite.tools.logging.LoggerService;
|
||||||
import org.opencdmp.authorization.AuthorizationFlags;
|
import org.opencdmp.authorization.AuthorizationFlags;
|
||||||
import org.opencdmp.commonmodels.enums.DmpAccessType;
|
import org.opencdmp.commonmodels.enums.PlanAccessType;
|
||||||
import org.opencdmp.commonmodels.enums.DmpStatus;
|
import org.opencdmp.commonmodels.enums.PlanStatus;
|
||||||
import org.opencdmp.commonmodels.models.DmpUserModel;
|
import org.opencdmp.commonmodels.models.PlanUserModel;
|
||||||
import org.opencdmp.commonmodels.models.EntityDoiModel;
|
import org.opencdmp.commonmodels.models.EntityDoiModel;
|
||||||
import org.opencdmp.commonmodels.models.FileEnvelopeModel;
|
import org.opencdmp.commonmodels.models.FileEnvelopeModel;
|
||||||
import org.opencdmp.commonmodels.models.UserModel;
|
import org.opencdmp.commonmodels.models.UserModel;
|
||||||
import org.opencdmp.commonmodels.models.description.DescriptionModel;
|
import org.opencdmp.commonmodels.models.description.DescriptionModel;
|
||||||
import org.opencdmp.commonmodels.models.dmp.DmpModel;
|
import org.opencdmp.commonmodels.models.plan.PlanModel;
|
||||||
import org.opencdmp.commonmodels.models.dmpblueprint.DmpBlueprintModel;
|
import org.opencdmp.commonmodels.models.planblueprint.PlanBlueprintModel;
|
||||||
import org.opencdmp.commonmodels.models.dmpreference.DmpReferenceModel;
|
import org.opencdmp.commonmodels.models.planreference.PlanReferenceModel;
|
||||||
import org.opencdmp.commons.JsonHandlingService;
|
import org.opencdmp.commons.JsonHandlingService;
|
||||||
import org.opencdmp.commons.XmlHandlingService;
|
import org.opencdmp.commons.XmlHandlingService;
|
||||||
import org.opencdmp.commons.enums.IsActive;
|
import org.opencdmp.commons.enums.IsActive;
|
||||||
|
@ -46,7 +46,7 @@ import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
public class PlanCommonModelBuilder extends BaseCommonModelBuilder<DmpModel, PlanEntity> {
|
public class PlanCommonModelBuilder extends BaseCommonModelBuilder<PlanModel, PlanEntity> {
|
||||||
|
|
||||||
private final QueryFactory queryFactory;
|
private final QueryFactory queryFactory;
|
||||||
|
|
||||||
|
@ -103,22 +103,22 @@ public class PlanCommonModelBuilder extends BaseCommonModelBuilder<DmpModel, Pla
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<CommonModelBuilderItemResponse<DmpModel, PlanEntity>> buildInternal(List<PlanEntity> data) throws MyApplicationException {
|
protected List<CommonModelBuilderItemResponse<PlanModel, PlanEntity>> buildInternal(List<PlanEntity> data) throws MyApplicationException {
|
||||||
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
if (data == null || data.isEmpty()) return new ArrayList<>();
|
if (data == null || data.isEmpty()) return new ArrayList<>();
|
||||||
|
|
||||||
List<CommonModelBuilderItemResponse<DmpModel, PlanEntity>> models = new ArrayList<>();
|
List<CommonModelBuilderItemResponse<PlanModel, PlanEntity>> models = new ArrayList<>();
|
||||||
|
|
||||||
Map<UUID, List<DmpReferenceModel>> planReferencesMap = this.collectPlanReferences(data);
|
Map<UUID, List<PlanReferenceModel>> planReferencesMap = this.collectPlanReferences(data);
|
||||||
Map<UUID, List<DmpUserModel>> planUsersMap = this.collectPlanUsers(data);
|
Map<UUID, List<PlanUserModel>> planUsersMap = this.collectPlanUsers(data);
|
||||||
Map<UUID, List<DescriptionModel>> descriptionsMap = this.disableDescriptions ? null : this.collectPlanDescriptions(data);
|
Map<UUID, List<DescriptionModel>> descriptionsMap = this.disableDescriptions ? null : this.collectPlanDescriptions(data);
|
||||||
Map<UUID, List<EntityDoiModel>> entityDois = this.collectPlanEntityDois(data);
|
Map<UUID, List<EntityDoiModel>> entityDois = this.collectPlanEntityDois(data);
|
||||||
Map<UUID, UserModel> creators = this.collectCreators(data);
|
Map<UUID, UserModel> creators = this.collectCreators(data);
|
||||||
Map<UUID, DmpBlueprintModel> planBlueprints = this.collectPlanBlueprints(data);
|
Map<UUID, PlanBlueprintModel> planBlueprints = this.collectPlanBlueprints(data);
|
||||||
Map<UUID, DefinitionEntity> definitionEntityMap = this.collectPlanBlueprintDefinitions(data);
|
Map<UUID, DefinitionEntity> definitionEntityMap = this.collectPlanBlueprintDefinitions(data);
|
||||||
|
|
||||||
for (PlanEntity d : data) {
|
for (PlanEntity d : data) {
|
||||||
DmpModel m = new DmpModel();
|
PlanModel m = new PlanModel();
|
||||||
m.setId(d.getId());
|
m.setId(d.getId());
|
||||||
m.setLabel(d.getLabel());
|
m.setLabel(d.getLabel());
|
||||||
m.setVersion(d.getVersion());
|
m.setVersion(d.getVersion());
|
||||||
|
@ -127,13 +127,13 @@ public class PlanCommonModelBuilder extends BaseCommonModelBuilder<DmpModel, Pla
|
||||||
m.setCreatedAt(d.getCreatedAt());
|
m.setCreatedAt(d.getCreatedAt());
|
||||||
m.setLanguage(d.getLanguage());
|
m.setLanguage(d.getLanguage());
|
||||||
switch (d.getStatus()){
|
switch (d.getStatus()){
|
||||||
case Finalized -> m.setStatus(DmpStatus.Finalized);
|
case Finalized -> m.setStatus(PlanStatus.Finalized);
|
||||||
case Draft -> m.setStatus(DmpStatus.Draft);
|
case Draft -> m.setStatus(PlanStatus.Draft);
|
||||||
default -> throw new MyApplicationException("unrecognized type " + d.getStatus());
|
default -> throw new MyApplicationException("unrecognized type " + d.getStatus());
|
||||||
}
|
}
|
||||||
if (entityDois != null && !entityDois.isEmpty() && entityDois.containsKey(d.getId())) m.setEntityDois(entityDois.get(d.getId()));
|
if (entityDois != null && !entityDois.isEmpty() && entityDois.containsKey(d.getId())) m.setEntityDois(entityDois.get(d.getId()));
|
||||||
if (creators != null && !creators.isEmpty() && d.getCreatorId() != null && creators.containsKey(d.getCreatorId())) m.setCreator(creators.get(d.getCreatorId()));
|
if (creators != null && !creators.isEmpty() && d.getCreatorId() != null && creators.containsKey(d.getCreatorId())) m.setCreator(creators.get(d.getCreatorId()));
|
||||||
if (planBlueprints != null && !planBlueprints.isEmpty() && d.getBlueprintId() != null && planBlueprints.containsKey(d.getBlueprintId())) m.setDmpBlueprint(planBlueprints.get(d.getBlueprintId()));
|
if (planBlueprints != null && !planBlueprints.isEmpty() && d.getBlueprintId() != null && planBlueprints.containsKey(d.getBlueprintId())) m.setPlanBlueprint(planBlueprints.get(d.getBlueprintId()));
|
||||||
if (d.getProperties() != null){
|
if (d.getProperties() != null){
|
||||||
//TODO Update with the new logic of property definition
|
//TODO Update with the new logic of property definition
|
||||||
PlanPropertiesEntity propertyDefinition = this.jsonHandlingService.fromJsonSafe(PlanPropertiesEntity.class, d.getProperties());
|
PlanPropertiesEntity propertyDefinition = this.jsonHandlingService.fromJsonSafe(PlanPropertiesEntity.class, d.getProperties());
|
||||||
|
@ -145,8 +145,8 @@ public class PlanCommonModelBuilder extends BaseCommonModelBuilder<DmpModel, Pla
|
||||||
m.setRdaJsonFile(this.rdaJsonFile);
|
m.setRdaJsonFile(this.rdaJsonFile);
|
||||||
if (d.getVersion() > (short)1) m.setPreviousDOI(this.getPreviousDOI(d.getGroupId(), d.getId()));
|
if (d.getVersion() > (short)1) m.setPreviousDOI(this.getPreviousDOI(d.getGroupId(), d.getId()));
|
||||||
switch (d.getAccessType()){
|
switch (d.getAccessType()){
|
||||||
case Public -> m.setAccessType(DmpAccessType.Public);
|
case Public -> m.setAccessType(PlanAccessType.Public);
|
||||||
case Restricted -> m.setAccessType(DmpAccessType.Restricted);
|
case Restricted -> m.setAccessType(PlanAccessType.Restricted);
|
||||||
case null -> m.setAccessType(null);
|
case null -> m.setAccessType(null);
|
||||||
default -> throw new MyApplicationException("unrecognized type " + d.getAccessType());
|
default -> throw new MyApplicationException("unrecognized type " + d.getAccessType());
|
||||||
}
|
}
|
||||||
|
@ -179,20 +179,20 @@ public class PlanCommonModelBuilder extends BaseCommonModelBuilder<DmpModel, Pla
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<UUID, List<DmpUserModel>> collectPlanUsers(List<PlanEntity> data) throws MyApplicationException {
|
private Map<UUID, List<PlanUserModel>> collectPlanUsers(List<PlanEntity> data) throws MyApplicationException {
|
||||||
this.logger.debug("checking related - {}", PlanUser.class.getSimpleName());
|
this.logger.debug("checking related - {}", PlanUser.class.getSimpleName());
|
||||||
|
|
||||||
Map<UUID, List<DmpUserModel>> itemMap;
|
Map<UUID, List<PlanUserModel>> itemMap;
|
||||||
PlanUserQuery query = this.queryFactory.query(PlanUserQuery.class).disableTracking().isActives(IsActive.Active).authorize(this.authorize).planIds(data.stream().map(PlanEntity::getId).distinct().collect(Collectors.toList()));
|
PlanUserQuery query = this.queryFactory.query(PlanUserQuery.class).disableTracking().isActives(IsActive.Active).authorize(this.authorize).planIds(data.stream().map(PlanEntity::getId).distinct().collect(Collectors.toList()));
|
||||||
itemMap = this.builderFactory.builder(PlanUserCommonModelBuilder.class).authorize(this.authorize).asMasterKey(query, PlanUserEntity::getPlanId);
|
itemMap = this.builderFactory.builder(PlanUserCommonModelBuilder.class).authorize(this.authorize).asMasterKey(query, PlanUserEntity::getPlanId);
|
||||||
|
|
||||||
return itemMap;
|
return itemMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<UUID, List<DmpReferenceModel>> collectPlanReferences(List<PlanEntity> data) throws MyApplicationException {
|
private Map<UUID, List<PlanReferenceModel>> collectPlanReferences(List<PlanEntity> data) throws MyApplicationException {
|
||||||
this.logger.debug("checking related - {}", PlanReference.class.getSimpleName());
|
this.logger.debug("checking related - {}", PlanReference.class.getSimpleName());
|
||||||
|
|
||||||
Map<UUID, List<DmpReferenceModel>> itemMap;
|
Map<UUID, List<PlanReferenceModel>> itemMap;
|
||||||
PlanReferenceQuery query = this.queryFactory.query(PlanReferenceQuery.class).disableTracking().isActives(IsActive.Active).authorize(this.authorize).planIds(data.stream().map(PlanEntity::getId).distinct().collect(Collectors.toList()));
|
PlanReferenceQuery query = this.queryFactory.query(PlanReferenceQuery.class).disableTracking().isActives(IsActive.Active).authorize(this.authorize).planIds(data.stream().map(PlanEntity::getId).distinct().collect(Collectors.toList()));
|
||||||
itemMap = this.builderFactory.builder(PlanReferenceCommonModelBuilder.class).authorize(this.authorize).asMasterKey(query, PlanReferenceEntity::getPlanId);
|
itemMap = this.builderFactory.builder(PlanReferenceCommonModelBuilder.class).authorize(this.authorize).asMasterKey(query, PlanReferenceEntity::getPlanId);
|
||||||
|
|
||||||
|
@ -232,12 +232,12 @@ public class PlanCommonModelBuilder extends BaseCommonModelBuilder<DmpModel, Pla
|
||||||
return itemMap;
|
return itemMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<UUID, DmpBlueprintModel> collectPlanBlueprints(List<PlanEntity> data) throws MyApplicationException {
|
private Map<UUID, PlanBlueprintModel> collectPlanBlueprints(List<PlanEntity> data) throws MyApplicationException {
|
||||||
if (data.isEmpty())
|
if (data.isEmpty())
|
||||||
return null;
|
return null;
|
||||||
this.logger.debug("checking related - {}", DmpBlueprintModel.class.getSimpleName());
|
this.logger.debug("checking related - {}", PlanBlueprintModel.class.getSimpleName());
|
||||||
|
|
||||||
Map<UUID, DmpBlueprintModel> itemMap;
|
Map<UUID, PlanBlueprintModel> itemMap;
|
||||||
PlanBlueprintQuery q = this.queryFactory.query(PlanBlueprintQuery.class).isActive(IsActive.Active).authorize(this.authorize).ids(data.stream().filter(x-> x.getBlueprintId() != null).map(PlanEntity::getBlueprintId).distinct().collect(Collectors.toList()));
|
PlanBlueprintQuery q = this.queryFactory.query(PlanBlueprintQuery.class).isActive(IsActive.Active).authorize(this.authorize).ids(data.stream().filter(x-> x.getBlueprintId() != null).map(PlanEntity::getBlueprintId).distinct().collect(Collectors.toList()));
|
||||||
itemMap = this.builderFactory.builder(PlanBlueprintCommonModelBuilder.class).authorize(this.authorize).asForeignKey(q, PlanBlueprintEntity::getId);
|
itemMap = this.builderFactory.builder(PlanBlueprintCommonModelBuilder.class).authorize(this.authorize).asForeignKey(q, PlanBlueprintEntity::getId);
|
||||||
return itemMap;
|
return itemMap;
|
||||||
|
|
|
@ -5,7 +5,7 @@ import gr.cite.tools.data.query.QueryFactory;
|
||||||
import gr.cite.tools.exception.MyApplicationException;
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
import gr.cite.tools.logging.LoggerService;
|
import gr.cite.tools.logging.LoggerService;
|
||||||
import org.opencdmp.authorization.AuthorizationFlags;
|
import org.opencdmp.authorization.AuthorizationFlags;
|
||||||
import org.opencdmp.commonmodels.models.dmp.DmpContactModel;
|
import org.opencdmp.commonmodels.models.plan.PlanContactModel;
|
||||||
import org.opencdmp.commons.types.plan.PlanContactEntity;
|
import org.opencdmp.commons.types.plan.PlanContactEntity;
|
||||||
import org.opencdmp.convention.ConventionService;
|
import org.opencdmp.convention.ConventionService;
|
||||||
import org.opencdmp.model.builder.commonmodels.BaseCommonModelBuilder;
|
import org.opencdmp.model.builder.commonmodels.BaseCommonModelBuilder;
|
||||||
|
@ -20,7 +20,7 @@ import java.util.*;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
public class PlanContactCommonModelBuilder extends BaseCommonModelBuilder<DmpContactModel, PlanContactEntity> {
|
public class PlanContactCommonModelBuilder extends BaseCommonModelBuilder<PlanContactModel, PlanContactEntity> {
|
||||||
|
|
||||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
private final BuilderFactory builderFactory;
|
private final BuilderFactory builderFactory;
|
||||||
|
@ -41,13 +41,13 @@ public class PlanContactCommonModelBuilder extends BaseCommonModelBuilder<DmpCon
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<CommonModelBuilderItemResponse<DmpContactModel, PlanContactEntity>> buildInternal(List<PlanContactEntity> data) throws MyApplicationException {
|
protected List<CommonModelBuilderItemResponse<PlanContactModel, PlanContactEntity>> buildInternal(List<PlanContactEntity> data) throws MyApplicationException {
|
||||||
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
if (data == null || data.isEmpty()) return new ArrayList<>();
|
if (data == null || data.isEmpty()) return new ArrayList<>();
|
||||||
|
|
||||||
List<CommonModelBuilderItemResponse<DmpContactModel, PlanContactEntity>> models = new ArrayList<>();
|
List<CommonModelBuilderItemResponse<PlanContactModel, PlanContactEntity>> models = new ArrayList<>();
|
||||||
for (PlanContactEntity d : data) {
|
for (PlanContactEntity d : data) {
|
||||||
DmpContactModel m = new DmpContactModel();
|
PlanContactModel m = new PlanContactModel();
|
||||||
m.setEmail(d.getEmail());
|
m.setEmail(d.getEmail());
|
||||||
m.setFirstName(d.getFirstName());
|
m.setFirstName(d.getFirstName());
|
||||||
m.setLastName(d.getLastName());
|
m.setLastName(d.getLastName());
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package org.opencdmp.model.builder.commonmodels.plan;
|
package org.opencdmp.model.builder.commonmodels.plan;
|
||||||
|
|
||||||
import org.opencdmp.authorization.AuthorizationFlags;
|
import org.opencdmp.authorization.AuthorizationFlags;
|
||||||
import org.opencdmp.commonmodels.models.dmp.DmpPropertiesModel;
|
import org.opencdmp.commonmodels.models.plan.PlanPropertiesModel;
|
||||||
import org.opencdmp.commons.types.plan.PlanPropertiesEntity;
|
import org.opencdmp.commons.types.plan.PlanPropertiesEntity;
|
||||||
import org.opencdmp.commons.types.planblueprint.DefinitionEntity;
|
import org.opencdmp.commons.types.planblueprint.DefinitionEntity;
|
||||||
import org.opencdmp.convention.ConventionService;
|
import org.opencdmp.convention.ConventionService;
|
||||||
|
@ -23,7 +23,7 @@ import java.util.Optional;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
public class PlanPropertiesCommonModelBuilder extends BaseCommonModelBuilder<DmpPropertiesModel, PlanPropertiesEntity> {
|
public class PlanPropertiesCommonModelBuilder extends BaseCommonModelBuilder<PlanPropertiesModel, PlanPropertiesEntity> {
|
||||||
private final BuilderFactory builderFactory;
|
private final BuilderFactory builderFactory;
|
||||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
private DefinitionEntity definition;
|
private DefinitionEntity definition;
|
||||||
|
@ -46,14 +46,14 @@ public class PlanPropertiesCommonModelBuilder extends BaseCommonModelBuilder<Dmp
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<CommonModelBuilderItemResponse<DmpPropertiesModel, PlanPropertiesEntity>> buildInternal(List<PlanPropertiesEntity> data) throws MyApplicationException {
|
protected List<CommonModelBuilderItemResponse<PlanPropertiesModel, PlanPropertiesEntity>> buildInternal(List<PlanPropertiesEntity> data) throws MyApplicationException {
|
||||||
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
if (data == null || data.isEmpty()) return new ArrayList<>();
|
if (data == null || data.isEmpty()) return new ArrayList<>();
|
||||||
|
|
||||||
List<CommonModelBuilderItemResponse<DmpPropertiesModel, PlanPropertiesEntity>> models = new ArrayList<>();
|
List<CommonModelBuilderItemResponse<PlanPropertiesModel, PlanPropertiesEntity>> models = new ArrayList<>();
|
||||||
for (PlanPropertiesEntity d : data) {
|
for (PlanPropertiesEntity d : data) {
|
||||||
DmpPropertiesModel m = new DmpPropertiesModel();
|
PlanPropertiesModel m = new PlanPropertiesModel();
|
||||||
if (d.getPlanBlueprintValues() != null) m.setDmpBlueprintValues(this.builderFactory.builder(PlanBlueprintValueCommonModelBuilder.class).withDefinition(definition).authorize(this.authorize).build(d.getPlanBlueprintValues()));
|
if (d.getPlanBlueprintValues() != null) m.setPlanBlueprintValues(this.builderFactory.builder(PlanBlueprintValueCommonModelBuilder.class).withDefinition(definition).authorize(this.authorize).build(d.getPlanBlueprintValues()));
|
||||||
if (d.getContacts() != null) m.setContacts(this.builderFactory.builder(PlanContactCommonModelBuilder.class).authorize(this.authorize).build(d.getContacts()));
|
if (d.getContacts() != null) m.setContacts(this.builderFactory.builder(PlanContactCommonModelBuilder.class).authorize(this.authorize).build(d.getContacts()));
|
||||||
|
|
||||||
models.add(new CommonModelBuilderItemResponse<>(m, d));
|
models.add(new CommonModelBuilderItemResponse<>(m, d));
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package org.opencdmp.model.builder.commonmodels.planblueprint;
|
package org.opencdmp.model.builder.commonmodels.planblueprint;
|
||||||
|
|
||||||
import org.opencdmp.authorization.AuthorizationFlags;
|
import org.opencdmp.authorization.AuthorizationFlags;
|
||||||
import org.opencdmp.commonmodels.models.dmpblueprint.DefinitionModel;
|
import org.opencdmp.commonmodels.models.planblueprint.DefinitionModel;
|
||||||
import org.opencdmp.commons.types.planblueprint.DefinitionEntity;
|
import org.opencdmp.commons.types.planblueprint.DefinitionEntity;
|
||||||
import org.opencdmp.convention.ConventionService;
|
import org.opencdmp.convention.ConventionService;
|
||||||
import org.opencdmp.model.builder.commonmodels.BaseCommonModelBuilder;
|
import org.opencdmp.model.builder.commonmodels.BaseCommonModelBuilder;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package org.opencdmp.model.builder.commonmodels.planblueprint;
|
package org.opencdmp.model.builder.commonmodels.planblueprint;
|
||||||
|
|
||||||
import org.opencdmp.commonmodels.enums.DmpBlueprintExtraFieldDataType;
|
import org.opencdmp.commonmodels.enums.PlanBlueprintExtraFieldDataType;
|
||||||
import org.opencdmp.commonmodels.models.dmpblueprint.ExtraFieldModel;
|
import org.opencdmp.commonmodels.models.planblueprint.ExtraFieldModel;
|
||||||
import org.opencdmp.commons.types.planblueprint.ExtraFieldEntity;
|
import org.opencdmp.commons.types.planblueprint.ExtraFieldEntity;
|
||||||
import org.opencdmp.convention.ConventionService;
|
import org.opencdmp.convention.ConventionService;
|
||||||
import gr.cite.tools.exception.MyApplicationException;
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
@ -26,10 +26,10 @@ public class ExtraFieldCommonModelBuilder extends FieldCommonModelBuilder<ExtraF
|
||||||
|
|
||||||
protected ExtraFieldModel buildChild(ExtraFieldEntity data, ExtraFieldModel model) {
|
protected ExtraFieldModel buildChild(ExtraFieldEntity data, ExtraFieldModel model) {
|
||||||
switch (data.getType()){
|
switch (data.getType()){
|
||||||
case Date -> model.setDataType(DmpBlueprintExtraFieldDataType.Date);
|
case Date -> model.setDataType(PlanBlueprintExtraFieldDataType.Date);
|
||||||
case Number -> model.setDataType(DmpBlueprintExtraFieldDataType.Number);
|
case Number -> model.setDataType(PlanBlueprintExtraFieldDataType.Number);
|
||||||
case RichTex -> model.setDataType(DmpBlueprintExtraFieldDataType.RichTex);
|
case RichTex -> model.setDataType(PlanBlueprintExtraFieldDataType.RichTex);
|
||||||
case Text -> model.setDataType(DmpBlueprintExtraFieldDataType.Text);
|
case Text -> model.setDataType(PlanBlueprintExtraFieldDataType.Text);
|
||||||
default -> throw new MyApplicationException("unrecognized type " + data.getType());
|
default -> throw new MyApplicationException("unrecognized type " + data.getType());
|
||||||
}
|
}
|
||||||
return model;
|
return model;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package org.opencdmp.model.builder.commonmodels.planblueprint;
|
package org.opencdmp.model.builder.commonmodels.planblueprint;
|
||||||
|
|
||||||
import org.opencdmp.authorization.AuthorizationFlags;
|
import org.opencdmp.authorization.AuthorizationFlags;
|
||||||
import org.opencdmp.commonmodels.enums.DmpBlueprintFieldCategory;
|
import org.opencdmp.commonmodels.enums.PlanBlueprintFieldCategory;
|
||||||
import org.opencdmp.commonmodels.models.dmpblueprint.FieldModel;
|
import org.opencdmp.commonmodels.models.planblueprint.FieldModel;
|
||||||
import org.opencdmp.commons.types.planblueprint.FieldEntity;
|
import org.opencdmp.commons.types.planblueprint.FieldEntity;
|
||||||
import org.opencdmp.convention.ConventionService;
|
import org.opencdmp.convention.ConventionService;
|
||||||
import org.opencdmp.model.builder.commonmodels.BaseCommonModelBuilder;
|
import org.opencdmp.model.builder.commonmodels.BaseCommonModelBuilder;
|
||||||
|
@ -51,9 +51,9 @@ public abstract class FieldCommonModelBuilder<Model extends FieldModel, Entity e
|
||||||
m.setId(d.getId());
|
m.setId(d.getId());
|
||||||
m.setDescription(d.getDescription());
|
m.setDescription(d.getDescription());
|
||||||
switch (d.getCategory()){
|
switch (d.getCategory()){
|
||||||
case System -> m.setCategory(DmpBlueprintFieldCategory.System);
|
case System -> m.setCategory(PlanBlueprintFieldCategory.System);
|
||||||
case Extra -> m.setCategory(DmpBlueprintFieldCategory.Extra);
|
case Extra -> m.setCategory(PlanBlueprintFieldCategory.Extra);
|
||||||
case ReferenceType -> m.setCategory(DmpBlueprintFieldCategory.ReferenceType);
|
case ReferenceType -> m.setCategory(PlanBlueprintFieldCategory.ReferenceType);
|
||||||
default -> throw new MyApplicationException("unrecognized type " + d.getCategory());
|
default -> throw new MyApplicationException("unrecognized type " + d.getCategory());
|
||||||
}
|
}
|
||||||
m.setPlaceholder(d.getPlaceholder());
|
m.setPlaceholder(d.getPlaceholder());
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package org.opencdmp.model.builder.commonmodels.planblueprint;
|
package org.opencdmp.model.builder.commonmodels.planblueprint;
|
||||||
|
|
||||||
import org.opencdmp.authorization.AuthorizationFlags;
|
import org.opencdmp.authorization.AuthorizationFlags;
|
||||||
import org.opencdmp.commonmodels.enums.DmpBlueprintStatus;
|
import org.opencdmp.commonmodels.enums.PlanBlueprintStatus;
|
||||||
import org.opencdmp.commonmodels.models.dmpblueprint.DmpBlueprintModel;
|
import org.opencdmp.commonmodels.models.planblueprint.PlanBlueprintModel;
|
||||||
import org.opencdmp.commons.XmlHandlingService;
|
import org.opencdmp.commons.XmlHandlingService;
|
||||||
import org.opencdmp.commons.types.planblueprint.DefinitionEntity;
|
import org.opencdmp.commons.types.planblueprint.DefinitionEntity;
|
||||||
import org.opencdmp.convention.ConventionService;
|
import org.opencdmp.convention.ConventionService;
|
||||||
|
@ -25,7 +25,7 @@ import java.util.Optional;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
public class PlanBlueprintCommonModelBuilder extends BaseCommonModelBuilder<DmpBlueprintModel, PlanBlueprintEntity> {
|
public class PlanBlueprintCommonModelBuilder extends BaseCommonModelBuilder<PlanBlueprintModel, PlanBlueprintEntity> {
|
||||||
|
|
||||||
private final BuilderFactory builderFactory;
|
private final BuilderFactory builderFactory;
|
||||||
private final XmlHandlingService xmlHandlingService;
|
private final XmlHandlingService xmlHandlingService;
|
||||||
|
@ -44,21 +44,21 @@ public class PlanBlueprintCommonModelBuilder extends BaseCommonModelBuilder<DmpB
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
protected List<CommonModelBuilderItemResponse<DmpBlueprintModel, PlanBlueprintEntity>> buildInternal(List<PlanBlueprintEntity> data) throws MyApplicationException {
|
protected List<CommonModelBuilderItemResponse<PlanBlueprintModel, PlanBlueprintEntity>> buildInternal(List<PlanBlueprintEntity> data) throws MyApplicationException {
|
||||||
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
if (data == null || data.isEmpty()) return new ArrayList<>();
|
if (data == null || data.isEmpty()) return new ArrayList<>();
|
||||||
|
|
||||||
List<CommonModelBuilderItemResponse<DmpBlueprintModel, PlanBlueprintEntity>> models = new ArrayList<>();
|
List<CommonModelBuilderItemResponse<PlanBlueprintModel, PlanBlueprintEntity>> models = new ArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
for (PlanBlueprintEntity d : data) {
|
for (PlanBlueprintEntity d : data) {
|
||||||
DmpBlueprintModel m = new DmpBlueprintModel();
|
PlanBlueprintModel m = new PlanBlueprintModel();
|
||||||
m.setId(d.getId());
|
m.setId(d.getId());
|
||||||
m.setLabel(d.getLabel());
|
m.setLabel(d.getLabel());
|
||||||
m.setGroupId(d.getGroupId());
|
m.setGroupId(d.getGroupId());
|
||||||
switch (d.getStatus()){
|
switch (d.getStatus()){
|
||||||
case Finalized -> m.setStatus(DmpBlueprintStatus.Finalized);
|
case Finalized -> m.setStatus(PlanBlueprintStatus.Finalized);
|
||||||
case Draft -> m.setStatus(DmpBlueprintStatus.Draft);
|
case Draft -> m.setStatus(PlanBlueprintStatus.Draft);
|
||||||
default -> throw new MyApplicationException("unrecognized type " + d.getStatus());
|
default -> throw new MyApplicationException("unrecognized type " + d.getStatus());
|
||||||
}
|
}
|
||||||
if (d.getDefinition() != null){
|
if (d.getDefinition() != null){
|
||||||
|
|
|
@ -2,7 +2,7 @@ package org.opencdmp.model.builder.commonmodels.planblueprint;
|
||||||
|
|
||||||
import gr.cite.tools.data.builder.BuilderFactory;
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
import gr.cite.tools.data.query.QueryFactory;
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
import org.opencdmp.commonmodels.models.dmpblueprint.ReferenceTypeFieldModel;
|
import org.opencdmp.commonmodels.models.planblueprint.ReferenceTypeFieldModel;
|
||||||
import org.opencdmp.commons.types.planblueprint.ReferenceTypeFieldEntity;
|
import org.opencdmp.commons.types.planblueprint.ReferenceTypeFieldEntity;
|
||||||
import org.opencdmp.convention.ConventionService;
|
import org.opencdmp.convention.ConventionService;
|
||||||
import org.opencdmp.model.builder.commonmodels.ReferenceTypeCommonModelBuilder;
|
import org.opencdmp.model.builder.commonmodels.ReferenceTypeCommonModelBuilder;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package org.opencdmp.model.builder.commonmodels.planblueprint;
|
package org.opencdmp.model.builder.commonmodels.planblueprint;
|
||||||
|
|
||||||
import org.opencdmp.authorization.AuthorizationFlags;
|
import org.opencdmp.authorization.AuthorizationFlags;
|
||||||
import org.opencdmp.commonmodels.models.dmpblueprint.SectionModel;
|
import org.opencdmp.commonmodels.models.planblueprint.SectionModel;
|
||||||
import org.opencdmp.commons.enums.PlanBlueprintFieldCategory;
|
import org.opencdmp.commons.enums.PlanBlueprintFieldCategory;
|
||||||
import org.opencdmp.commons.types.planblueprint.ExtraFieldEntity;
|
import org.opencdmp.commons.types.planblueprint.ExtraFieldEntity;
|
||||||
import org.opencdmp.commons.types.planblueprint.ReferenceTypeFieldEntity;
|
import org.opencdmp.commons.types.planblueprint.ReferenceTypeFieldEntity;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package org.opencdmp.model.builder.commonmodels.planblueprint;
|
package org.opencdmp.model.builder.commonmodels.planblueprint;
|
||||||
|
|
||||||
import org.opencdmp.commonmodels.enums.DmpBlueprintSystemFieldType;
|
import org.opencdmp.commonmodels.enums.PlanBlueprintSystemFieldType;
|
||||||
import org.opencdmp.commonmodels.models.dmpblueprint.SystemFieldModel;
|
import org.opencdmp.commonmodels.models.planblueprint.SystemFieldModel;
|
||||||
import org.opencdmp.commons.types.planblueprint.SystemFieldEntity;
|
import org.opencdmp.commons.types.planblueprint.SystemFieldEntity;
|
||||||
import org.opencdmp.convention.ConventionService;
|
import org.opencdmp.convention.ConventionService;
|
||||||
import gr.cite.tools.exception.MyApplicationException;
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
@ -26,12 +26,12 @@ public class SystemFieldCommonModelBuilder extends FieldCommonModelBuilder<Syste
|
||||||
|
|
||||||
protected SystemFieldModel buildChild(SystemFieldEntity data, SystemFieldModel model) {
|
protected SystemFieldModel buildChild(SystemFieldEntity data, SystemFieldModel model) {
|
||||||
switch (data.getType()){
|
switch (data.getType()){
|
||||||
case AccessRights -> model.setSystemFieldType(DmpBlueprintSystemFieldType.AccessRights);
|
case AccessRights -> model.setSystemFieldType(PlanBlueprintSystemFieldType.AccessRights);
|
||||||
case Contact -> model.setSystemFieldType(DmpBlueprintSystemFieldType.Contact);
|
case Contact -> model.setSystemFieldType(PlanBlueprintSystemFieldType.Contact);
|
||||||
case Description -> model.setSystemFieldType(DmpBlueprintSystemFieldType.Description);
|
case Description -> model.setSystemFieldType(PlanBlueprintSystemFieldType.Description);
|
||||||
case Language -> model.setSystemFieldType(DmpBlueprintSystemFieldType.Language);
|
case Language -> model.setSystemFieldType(PlanBlueprintSystemFieldType.Language);
|
||||||
case Title -> model.setSystemFieldType(DmpBlueprintSystemFieldType.Title);
|
case Title -> model.setSystemFieldType(PlanBlueprintSystemFieldType.Title);
|
||||||
case User -> model.setSystemFieldType(DmpBlueprintSystemFieldType.User);
|
case User -> model.setSystemFieldType(PlanBlueprintSystemFieldType.User);
|
||||||
default -> throw new MyApplicationException("unrecognized type " + data.getType());
|
default -> throw new MyApplicationException("unrecognized type " + data.getType());
|
||||||
}
|
}
|
||||||
return model;
|
return model;
|
||||||
|
|
|
@ -5,7 +5,7 @@ import gr.cite.tools.data.query.QueryFactory;
|
||||||
import gr.cite.tools.exception.MyApplicationException;
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
import gr.cite.tools.logging.LoggerService;
|
import gr.cite.tools.logging.LoggerService;
|
||||||
import org.opencdmp.authorization.AuthorizationFlags;
|
import org.opencdmp.authorization.AuthorizationFlags;
|
||||||
import org.opencdmp.commonmodels.models.dmpreference.DmpReferenceModel;
|
import org.opencdmp.commonmodels.models.planreference.PlanReferenceModel;
|
||||||
import org.opencdmp.commonmodels.models.reference.ReferenceModel;
|
import org.opencdmp.commonmodels.models.reference.ReferenceModel;
|
||||||
import org.opencdmp.commons.JsonHandlingService;
|
import org.opencdmp.commons.JsonHandlingService;
|
||||||
import org.opencdmp.commons.types.planreference.PlanReferenceDataEntity;
|
import org.opencdmp.commons.types.planreference.PlanReferenceDataEntity;
|
||||||
|
@ -27,7 +27,7 @@ import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
public class PlanReferenceCommonModelBuilder extends BaseCommonModelBuilder<DmpReferenceModel, PlanReferenceEntity> {
|
public class PlanReferenceCommonModelBuilder extends BaseCommonModelBuilder<PlanReferenceModel, PlanReferenceEntity> {
|
||||||
|
|
||||||
private final BuilderFactory builderFactory;
|
private final BuilderFactory builderFactory;
|
||||||
private final QueryFactory queryFactory;
|
private final QueryFactory queryFactory;
|
||||||
|
@ -50,14 +50,14 @@ public class PlanReferenceCommonModelBuilder extends BaseCommonModelBuilder<DmpR
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<CommonModelBuilderItemResponse<DmpReferenceModel, PlanReferenceEntity>> buildInternal(List<PlanReferenceEntity> data) throws MyApplicationException {
|
protected List<CommonModelBuilderItemResponse<PlanReferenceModel, PlanReferenceEntity>> buildInternal(List<PlanReferenceEntity> data) throws MyApplicationException {
|
||||||
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
if (data == null || data.isEmpty()) return new ArrayList<>();
|
if (data == null || data.isEmpty()) return new ArrayList<>();
|
||||||
|
|
||||||
Map<UUID, ReferenceModel> referenceModelMap = this.collectReferences(data);
|
Map<UUID, ReferenceModel> referenceModelMap = this.collectReferences(data);
|
||||||
List<CommonModelBuilderItemResponse<DmpReferenceModel, PlanReferenceEntity>> models = new ArrayList<>();
|
List<CommonModelBuilderItemResponse<PlanReferenceModel, PlanReferenceEntity>> models = new ArrayList<>();
|
||||||
for (PlanReferenceEntity d : data) {
|
for (PlanReferenceEntity d : data) {
|
||||||
DmpReferenceModel m = new DmpReferenceModel();
|
PlanReferenceModel m = new PlanReferenceModel();
|
||||||
m.setId(d.getId());
|
m.setId(d.getId());
|
||||||
if (d.getData() != null){
|
if (d.getData() != null){
|
||||||
PlanReferenceDataEntity definition = this.jsonHandlingService.fromJsonSafe(PlanReferenceDataEntity.class, d.getData());
|
PlanReferenceDataEntity definition = this.jsonHandlingService.fromJsonSafe(PlanReferenceDataEntity.class, d.getData());
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package org.opencdmp.model.builder.commonmodels.planreference;
|
package org.opencdmp.model.builder.commonmodels.planreference;
|
||||||
|
|
||||||
import org.opencdmp.authorization.AuthorizationFlags;
|
import org.opencdmp.authorization.AuthorizationFlags;
|
||||||
import org.opencdmp.commonmodels.models.dmpreference.DmpReferenceDataModel;
|
import org.opencdmp.commonmodels.models.planreference.PlanReferenceDataModel;
|
||||||
import org.opencdmp.commons.types.planreference.PlanReferenceDataEntity;
|
import org.opencdmp.commons.types.planreference.PlanReferenceDataEntity;
|
||||||
import org.opencdmp.convention.ConventionService;
|
import org.opencdmp.convention.ConventionService;
|
||||||
import org.opencdmp.model.builder.commonmodels.BaseCommonModelBuilder;
|
import org.opencdmp.model.builder.commonmodels.BaseCommonModelBuilder;
|
||||||
|
@ -22,7 +22,7 @@ import java.util.Optional;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
public class PlanReferenceDataCommonModelBuilder extends BaseCommonModelBuilder<DmpReferenceDataModel, PlanReferenceDataEntity> {
|
public class PlanReferenceDataCommonModelBuilder extends BaseCommonModelBuilder<PlanReferenceDataModel, PlanReferenceDataEntity> {
|
||||||
|
|
||||||
private final BuilderFactory builderFactory;
|
private final BuilderFactory builderFactory;
|
||||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
@ -40,13 +40,13 @@ public class PlanReferenceDataCommonModelBuilder extends BaseCommonModelBuilder<
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<CommonModelBuilderItemResponse<DmpReferenceDataModel, PlanReferenceDataEntity>> buildInternal(List<PlanReferenceDataEntity> data) throws MyApplicationException {
|
protected List<CommonModelBuilderItemResponse<PlanReferenceDataModel, PlanReferenceDataEntity>> buildInternal(List<PlanReferenceDataEntity> data) throws MyApplicationException {
|
||||||
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
if (data == null || data.isEmpty()) return new ArrayList<>();
|
if (data == null || data.isEmpty()) return new ArrayList<>();
|
||||||
|
|
||||||
List<CommonModelBuilderItemResponse<DmpReferenceDataModel, PlanReferenceDataEntity>> models = new ArrayList<>();
|
List<CommonModelBuilderItemResponse<PlanReferenceDataModel, PlanReferenceDataEntity>> models = new ArrayList<>();
|
||||||
for (PlanReferenceDataEntity d : data) {
|
for (PlanReferenceDataEntity d : data) {
|
||||||
DmpReferenceDataModel m = new DmpReferenceDataModel();
|
PlanReferenceDataModel m = new PlanReferenceDataModel();
|
||||||
m.setBlueprintFieldId(d.getBlueprintFieldId());
|
m.setBlueprintFieldId(d.getBlueprintFieldId());
|
||||||
models.add(new CommonModelBuilderItemResponse<>(m, d));
|
models.add(new CommonModelBuilderItemResponse<>(m, d));
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ package org.opencdmp.service.deposit;
|
||||||
|
|
||||||
import gr.cite.tools.logging.LoggerService;
|
import gr.cite.tools.logging.LoggerService;
|
||||||
import gr.cite.tools.logging.MapLogEntry;
|
import gr.cite.tools.logging.MapLogEntry;
|
||||||
import org.opencdmp.commonmodels.models.dmp.DmpModel;
|
import org.opencdmp.commonmodels.models.plan.PlanModel;
|
||||||
import org.opencdmp.depositbase.repository.DepositClient;
|
import org.opencdmp.depositbase.repository.DepositClient;
|
||||||
import org.opencdmp.depositbase.repository.DepositConfiguration;
|
import org.opencdmp.depositbase.repository.DepositConfiguration;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -21,9 +21,9 @@ public class DepositClientImpl implements DepositClient {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String deposit(DmpModel dmpDepositModel, String repositoryAccessToken) throws Exception {
|
public String deposit(PlanModel planDepositModel, String repositoryAccessToken) throws Exception {
|
||||||
logger.debug(new MapLogEntry("deposit").And("dmpDepositModel", dmpDepositModel));
|
logger.debug(new MapLogEntry("deposit").And("planDepositModel", planDepositModel));
|
||||||
return this.depositClient.post().uri("", uriBuilder -> uriBuilder.queryParam("authToken", repositoryAccessToken).build()).bodyValue(dmpDepositModel).exchangeToMono(mono -> mono.statusCode().isError() ? mono.createException().flatMap(Mono::error) : mono.bodyToMono(String.class)).block();
|
return this.depositClient.post().uri("", uriBuilder -> uriBuilder.queryParam("authToken", repositoryAccessToken).build()).bodyValue(planDepositModel).exchangeToMono(mono -> mono.statusCode().isError() ? mono.createException().flatMap(Mono::error) : mono.bodyToMono(String.class)).block();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -17,7 +17,7 @@ import org.opencdmp.authorization.AuthorizationFlags;
|
||||||
import org.opencdmp.authorization.Permission;
|
import org.opencdmp.authorization.Permission;
|
||||||
import org.opencdmp.authorization.authorizationcontentresolver.AuthorizationContentResolver;
|
import org.opencdmp.authorization.authorizationcontentresolver.AuthorizationContentResolver;
|
||||||
import org.opencdmp.commonmodels.models.FileEnvelopeModel;
|
import org.opencdmp.commonmodels.models.FileEnvelopeModel;
|
||||||
import org.opencdmp.commonmodels.models.dmp.DmpModel;
|
import org.opencdmp.commonmodels.models.plan.PlanModel;
|
||||||
import org.opencdmp.commons.JsonHandlingService;
|
import org.opencdmp.commons.JsonHandlingService;
|
||||||
import org.opencdmp.commons.enums.IsActive;
|
import org.opencdmp.commons.enums.IsActive;
|
||||||
import org.opencdmp.commons.enums.StorageType;
|
import org.opencdmp.commons.enums.StorageType;
|
||||||
|
@ -311,7 +311,7 @@ public class DepositServiceImpl implements DepositService {
|
||||||
}
|
}
|
||||||
|
|
||||||
//GK: Fifth Transform them to the DepositModel
|
//GK: Fifth Transform them to the DepositModel
|
||||||
DmpModel depositModel = this.builderFactory.builder(PlanCommonModelBuilder.class).useSharedStorage(depositClient.getConfiguration().isUseSharedStorage()).authorize(AuthorizationFlags.AllExceptPublic)
|
PlanModel depositModel = this.builderFactory.builder(PlanCommonModelBuilder.class).useSharedStorage(depositClient.getConfiguration().isUseSharedStorage()).authorize(AuthorizationFlags.AllExceptPublic)
|
||||||
.setRepositoryId(planDepositModel.getRepositoryId()).setPdfFile(pdfEnvelope).setRdaJsonFile(jsonEnvelope).build(planEntity);
|
.setRepositoryId(planDepositModel.getRepositoryId()).setPdfFile(pdfEnvelope).setRdaJsonFile(jsonEnvelope).build(planEntity);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1187,7 +1187,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
||||||
case SELECT -> fieldType = FieldType.SELECT;
|
case SELECT -> fieldType = FieldType.SELECT;
|
||||||
case BOOLEAN_DECISION -> fieldType = FieldType.BOOLEAN_DECISION;
|
case BOOLEAN_DECISION -> fieldType = FieldType.BOOLEAN_DECISION;
|
||||||
case RADIO_BOX -> fieldType = FieldType.RADIO_BOX;
|
case RADIO_BOX -> fieldType = FieldType.RADIO_BOX;
|
||||||
case INTERNAL_ENTRIES_DMPS -> fieldType = FieldType.INTERNAL_ENTRIES_PLANS;
|
case INTERNAL_ENTRIES_PlANS -> fieldType = FieldType.INTERNAL_ENTRIES_PLANS;
|
||||||
case INTERNAL_ENTRIES_DESCRIPTIONS -> fieldType = FieldType.INTERNAL_ENTRIES_DESCRIPTIONS;
|
case INTERNAL_ENTRIES_DESCRIPTIONS -> fieldType = FieldType.INTERNAL_ENTRIES_DESCRIPTIONS;
|
||||||
case CHECK_BOX -> fieldType = FieldType.CHECK_BOX;
|
case CHECK_BOX -> fieldType = FieldType.CHECK_BOX;
|
||||||
case FREE_TEXT -> fieldType = FieldType.FREE_TEXT;
|
case FREE_TEXT -> fieldType = FieldType.FREE_TEXT;
|
||||||
|
|
|
@ -4,13 +4,13 @@ import gr.cite.tools.logging.LoggerService;
|
||||||
import gr.cite.tools.logging.MapLogEntry;
|
import gr.cite.tools.logging.MapLogEntry;
|
||||||
import org.opencdmp.commonmodels.models.FileEnvelopeModel;
|
import org.opencdmp.commonmodels.models.FileEnvelopeModel;
|
||||||
import org.opencdmp.commonmodels.models.description.DescriptionModel;
|
import org.opencdmp.commonmodels.models.description.DescriptionModel;
|
||||||
import org.opencdmp.commonmodels.models.dmp.DmpModel;
|
import org.opencdmp.commonmodels.models.plan.PlanModel;
|
||||||
import org.opencdmp.filetransformerbase.interfaces.FileTransformerClient;
|
import org.opencdmp.filetransformerbase.interfaces.FileTransformerClient;
|
||||||
import org.opencdmp.filetransformerbase.interfaces.FileTransformerConfiguration;
|
import org.opencdmp.filetransformerbase.interfaces.FileTransformerConfiguration;
|
||||||
import org.opencdmp.filetransformerbase.models.misc.DescriptionImportModel;
|
import org.opencdmp.filetransformerbase.models.misc.DescriptionImportModel;
|
||||||
import org.opencdmp.filetransformerbase.models.misc.DmpImportModel;
|
import org.opencdmp.filetransformerbase.models.misc.PlanImportModel;
|
||||||
import org.opencdmp.filetransformerbase.models.misc.PreprocessingDescriptionModel;
|
import org.opencdmp.filetransformerbase.models.misc.PreprocessingDescriptionModel;
|
||||||
import org.opencdmp.filetransformerbase.models.misc.PreprocessingDmpModel;
|
import org.opencdmp.filetransformerbase.models.misc.PreprocessingPlanModel;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.core.ParameterizedTypeReference;
|
import org.springframework.core.ParameterizedTypeReference;
|
||||||
import org.springframework.web.reactive.function.client.WebClient;
|
import org.springframework.web.reactive.function.client.WebClient;
|
||||||
|
@ -27,17 +27,17 @@ public class FileTransformerRepository implements FileTransformerClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FileEnvelopeModel exportDmp(DmpModel dmpModel, String format) {
|
public FileEnvelopeModel exportPlan(PlanModel planModel, String format) {
|
||||||
logger.debug(new MapLogEntry("exportDmp").And("format", format).And("dmpModel", dmpModel));
|
logger.debug(new MapLogEntry("exportPlan").And("format", format).And("planModel", planModel));
|
||||||
return this.transformerClient.post().uri("/export/dmp", uriBuilder -> uriBuilder.queryParam("format", format).build()).bodyValue(dmpModel)
|
return this.transformerClient.post().uri("/export/plan", uriBuilder -> uriBuilder.queryParam("format", format).build()).bodyValue(planModel)
|
||||||
.exchangeToMono(mono -> mono.statusCode().isError() ? mono.createException().flatMap(Mono::error) : mono.bodyToMono(FileEnvelopeModel.class)).block();
|
.exchangeToMono(mono -> mono.statusCode().isError() ? mono.createException().flatMap(Mono::error) : mono.bodyToMono(FileEnvelopeModel.class)).block();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DmpModel importDmp(DmpImportModel dmpImportModel) {
|
public PlanModel importPlan(PlanImportModel planImportModel) {
|
||||||
logger.debug(new MapLogEntry("importDmp").And("fileEnvelope", dmpImportModel.getFile()));
|
logger.debug(new MapLogEntry("importPlan").And("fileEnvelope", planImportModel.getFile()));
|
||||||
return this.transformerClient.post().uri("/import/dmp").bodyValue(dmpImportModel)
|
return this.transformerClient.post().uri("/import/plan").bodyValue(planImportModel)
|
||||||
.exchangeToMono(mono -> mono.statusCode().isError() ? mono.createException().flatMap(Mono::error) : mono.bodyToMono(DmpModel.class)).block();
|
.exchangeToMono(mono -> mono.statusCode().isError() ? mono.createException().flatMap(Mono::error) : mono.bodyToMono(PlanModel.class)).block();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -62,10 +62,10 @@ public class FileTransformerRepository implements FileTransformerClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PreprocessingDmpModel preprocessingDmp(FileEnvelopeModel fileEnvelopeModel) {
|
public PreprocessingPlanModel preprocessingPlan(FileEnvelopeModel fileEnvelopeModel) {
|
||||||
logger.debug(new MapLogEntry("preprocessingDmp").And("fileEnvelope", fileEnvelopeModel));
|
logger.debug(new MapLogEntry("preprocessingPlan").And("fileEnvelope", fileEnvelopeModel));
|
||||||
return this.transformerClient.post().uri("/preprocessing/dmp").bodyValue(fileEnvelopeModel)
|
return this.transformerClient.post().uri("/preprocessing/plan").bodyValue(fileEnvelopeModel)
|
||||||
.exchangeToMono(mono -> mono.statusCode().isError() ? mono.createException().flatMap(Mono::error) : mono.bodyToMono(PreprocessingDmpModel.class)).block();
|
.exchangeToMono(mono -> mono.statusCode().isError() ? mono.createException().flatMap(Mono::error) : mono.bodyToMono(PreprocessingPlanModel.class)).block();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package org.opencdmp.service.filetransformer;
|
package org.opencdmp.service.filetransformer;
|
||||||
|
|
||||||
import jakarta.xml.bind.JAXBException;
|
import jakarta.xml.bind.JAXBException;
|
||||||
import org.opencdmp.commonmodels.models.dmp.DmpModel;
|
import org.opencdmp.commonmodels.models.plan.PlanModel;
|
||||||
import org.opencdmp.filetransformerbase.models.misc.PreprocessingDmpModel;
|
import org.opencdmp.filetransformerbase.models.misc.PreprocessingPlanModel;
|
||||||
import org.opencdmp.model.file.RepositoryFileFormat;
|
import org.opencdmp.model.file.RepositoryFileFormat;
|
||||||
import org.opencdmp.model.persist.PlanCommonModelConfig;
|
import org.opencdmp.model.persist.PlanCommonModelConfig;
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ public interface FileTransformerService {
|
||||||
|
|
||||||
org.opencdmp.model.file.FileEnvelope exportDescription(UUID descriptionId, String repositoryId, String format) throws InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, InvalidApplicationException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException;
|
org.opencdmp.model.file.FileEnvelope exportDescription(UUID descriptionId, String repositoryId, String format) throws InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, InvalidApplicationException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException;
|
||||||
|
|
||||||
DmpModel importPlan(PlanCommonModelConfig planCommonModelConfig) throws InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, InvalidApplicationException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException, IOException, JAXBException;
|
PlanModel importPlan(PlanCommonModelConfig planCommonModelConfig) throws InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, InvalidApplicationException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException, IOException, JAXBException;
|
||||||
|
|
||||||
PreprocessingDmpModel preprocessingPlan(UUID fileId, String repositoryId) throws InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, InvalidApplicationException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException, IOException;
|
PreprocessingPlanModel preprocessingPlan(UUID fileId, String repositoryId) throws InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, InvalidApplicationException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException, IOException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,8 @@ import org.opencdmp.authorization.Permission;
|
||||||
import org.opencdmp.commonmodels.models.FileEnvelopeModel;
|
import org.opencdmp.commonmodels.models.FileEnvelopeModel;
|
||||||
import org.opencdmp.commonmodels.models.description.DescriptionModel;
|
import org.opencdmp.commonmodels.models.description.DescriptionModel;
|
||||||
import org.opencdmp.commonmodels.models.descriptiotemplate.DescriptionTemplateModel;
|
import org.opencdmp.commonmodels.models.descriptiotemplate.DescriptionTemplateModel;
|
||||||
import org.opencdmp.commonmodels.models.dmp.DmpModel;
|
import org.opencdmp.commonmodels.models.plan.PlanModel;
|
||||||
import org.opencdmp.commonmodels.models.dmpblueprint.DmpBlueprintModel;
|
import org.opencdmp.commonmodels.models.planblueprint.PlanBlueprintModel;
|
||||||
import org.opencdmp.commons.JsonHandlingService;
|
import org.opencdmp.commons.JsonHandlingService;
|
||||||
import org.opencdmp.commons.enums.IsActive;
|
import org.opencdmp.commons.enums.IsActive;
|
||||||
import org.opencdmp.commons.enums.StorageType;
|
import org.opencdmp.commons.enums.StorageType;
|
||||||
|
@ -36,8 +36,8 @@ import org.opencdmp.data.TenantConfigurationEntity;
|
||||||
import org.opencdmp.event.TenantConfigurationTouchedEvent;
|
import org.opencdmp.event.TenantConfigurationTouchedEvent;
|
||||||
import org.opencdmp.filetransformerbase.interfaces.FileTransformerConfiguration;
|
import org.opencdmp.filetransformerbase.interfaces.FileTransformerConfiguration;
|
||||||
import org.opencdmp.filetransformerbase.models.misc.DescriptionImportModel;
|
import org.opencdmp.filetransformerbase.models.misc.DescriptionImportModel;
|
||||||
import org.opencdmp.filetransformerbase.models.misc.DmpImportModel;
|
import org.opencdmp.filetransformerbase.models.misc.PlanImportModel;
|
||||||
import org.opencdmp.filetransformerbase.models.misc.PreprocessingDmpModel;
|
import org.opencdmp.filetransformerbase.models.misc.PreprocessingPlanModel;
|
||||||
import org.opencdmp.model.StorageFile;
|
import org.opencdmp.model.StorageFile;
|
||||||
import org.opencdmp.model.builder.commonmodels.description.DescriptionCommonModelBuilder;
|
import org.opencdmp.model.builder.commonmodels.description.DescriptionCommonModelBuilder;
|
||||||
import org.opencdmp.model.builder.commonmodels.descriptiontemplate.DescriptionTemplateCommonModelBuilder;
|
import org.opencdmp.model.builder.commonmodels.descriptiontemplate.DescriptionTemplateCommonModelBuilder;
|
||||||
|
@ -259,10 +259,10 @@ public class FileTransformerServiceImpl implements FileTransformerService {
|
||||||
if (repository == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{format, FileTransformerRepository.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
if (repository == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{format, FileTransformerRepository.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
//GK: Second get the Target Data Management Plan
|
//GK: Second get the Target Data Management Plan
|
||||||
PlanQuery query = this.queryFactory.query(PlanQuery.class).disableTracking().authorize(AuthorizationFlags.All).ids(planId);
|
PlanQuery query = this.queryFactory.query(PlanQuery.class).disableTracking().authorize(AuthorizationFlags.All).ids(planId);
|
||||||
DmpModel dmpFileTransformerModel = this.builderFactory.builder(PlanCommonModelBuilder.class).useSharedStorage(repository.getConfiguration().isUseSharedStorage()).setRepositoryId(repository.getConfiguration().getFileTransformerId()).authorize(AuthorizationFlags.AllExceptPublic).build(query.first());
|
PlanModel planFileTransformerModel = this.builderFactory.builder(PlanCommonModelBuilder.class).useSharedStorage(repository.getConfiguration().isUseSharedStorage()).setRepositoryId(repository.getConfiguration().getFileTransformerId()).authorize(AuthorizationFlags.AllExceptPublic).build(query.first());
|
||||||
if (dmpFileTransformerModel == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{planId, Plan.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
if (planFileTransformerModel == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{planId, Plan.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
FileEnvelopeModel fileEnvelope = repository.exportDmp(dmpFileTransformerModel, format);
|
FileEnvelopeModel fileEnvelope = repository.exportPlan(planFileTransformerModel, format);
|
||||||
org.opencdmp.model.file.FileEnvelope result = new org.opencdmp.model.file.FileEnvelope();
|
org.opencdmp.model.file.FileEnvelope result = new org.opencdmp.model.file.FileEnvelope();
|
||||||
|
|
||||||
byte[] data = repository.getConfiguration().isUseSharedStorage() ? this.storageFileService.readByFileRefAsBytesSafe(fileEnvelope.getFileRef(), StorageType.Transformer) : fileEnvelope.getFile();
|
byte[] data = repository.getConfiguration().isUseSharedStorage() ? this.storageFileService.readByFileRefAsBytesSafe(fileEnvelope.getFileRef(), StorageType.Transformer) : fileEnvelope.getFile();
|
||||||
|
@ -313,7 +313,7 @@ public class FileTransformerServiceImpl implements FileTransformerService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DmpModel importPlan(PlanCommonModelConfig planCommonModelConfig) throws InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, InvalidApplicationException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException, IOException, JAXBException {
|
public PlanModel importPlan(PlanCommonModelConfig planCommonModelConfig) throws InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, InvalidApplicationException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException, IOException, JAXBException {
|
||||||
this.authorizationService.authorizeForce(Permission.NewPlan);
|
this.authorizationService.authorizeForce(Permission.NewPlan);
|
||||||
|
|
||||||
StorageFileEntity tempFile = this.queryFactory.query(StorageFileQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).ids(planCommonModelConfig.getFileId()).first();
|
StorageFileEntity tempFile = this.queryFactory.query(StorageFileQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).ids(planCommonModelConfig.getFileId()).first();
|
||||||
|
@ -325,11 +325,11 @@ public class FileTransformerServiceImpl implements FileTransformerService {
|
||||||
if (repository == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{planCommonModelConfig.getRepositoryId(), FileTransformerRepository.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
if (repository == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{planCommonModelConfig.getRepositoryId(), FileTransformerRepository.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
PlanBlueprintQuery planBlueprintQuery = this.queryFactory.query(PlanBlueprintQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).ids(planCommonModelConfig.getBlueprintId());
|
PlanBlueprintQuery planBlueprintQuery = this.queryFactory.query(PlanBlueprintQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).ids(planCommonModelConfig.getBlueprintId());
|
||||||
DmpBlueprintModel dmpBlueprintModel = this.builderFactory.builder(PlanBlueprintCommonModelBuilder.class).authorize(AuthorizationFlags.AllExceptPublic).build(planBlueprintQuery.first());
|
PlanBlueprintModel planBlueprintModel = this.builderFactory.builder(PlanBlueprintCommonModelBuilder.class).authorize(AuthorizationFlags.AllExceptPublic).build(planBlueprintQuery.first());
|
||||||
if (dmpBlueprintModel == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{planCommonModelConfig.getBlueprintId(), PlanBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
if (planBlueprintModel == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{planCommonModelConfig.getBlueprintId(), PlanBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
DmpImportModel dmpImportModel = new DmpImportModel();
|
PlanImportModel planImportModel = new PlanImportModel();
|
||||||
dmpImportModel.setBlueprintModel(dmpBlueprintModel);
|
planImportModel.setBlueprintModel(planBlueprintModel);
|
||||||
|
|
||||||
if (!this.conventionService.isListNullOrEmpty(planCommonModelConfig.getDescriptions())){
|
if (!this.conventionService.isListNullOrEmpty(planCommonModelConfig.getDescriptions())){
|
||||||
List<DescriptionTemplateEntity> descriptionTemplateEntities = this.queryFactory.query(DescriptionTemplateQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).ids(planCommonModelConfig.getDescriptions().stream().map(x -> x.getTemplateId()).distinct().collect(Collectors.toList())).collect();
|
List<DescriptionTemplateEntity> descriptionTemplateEntities = this.queryFactory.query(DescriptionTemplateQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).ids(planCommonModelConfig.getDescriptions().stream().map(x -> x.getTemplateId()).distinct().collect(Collectors.toList())).collect();
|
||||||
|
@ -351,7 +351,7 @@ public class FileTransformerServiceImpl implements FileTransformerService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dmpImportModel.setDescriptions(descriptionImportModels);
|
planImportModel.setDescriptions(descriptionImportModels);
|
||||||
}
|
}
|
||||||
|
|
||||||
String originalFileName = tempFile.getName() + (tempFile.getExtension().startsWith(".") ? "" : ".") + tempFile.getExtension();
|
String originalFileName = tempFile.getName() + (tempFile.getExtension().startsWith(".") ? "" : ".") + tempFile.getExtension();
|
||||||
|
@ -374,13 +374,13 @@ public class FileTransformerServiceImpl implements FileTransformerService {
|
||||||
fileEnvelope.setFileRef(storageFile.getFileRef());
|
fileEnvelope.setFileRef(storageFile.getFileRef());
|
||||||
}
|
}
|
||||||
|
|
||||||
dmpImportModel.setFile(fileEnvelope);
|
planImportModel.setFile(fileEnvelope);
|
||||||
|
|
||||||
return repository.importDmp(dmpImportModel);
|
return repository.importPlan(planImportModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PreprocessingDmpModel preprocessingPlan(UUID fileId, String repositoryId) throws InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, InvalidApplicationException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException, IOException {
|
public PreprocessingPlanModel preprocessingPlan(UUID fileId, String repositoryId) throws InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, InvalidApplicationException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException, IOException {
|
||||||
this.authorizationService.authorizeForce(Permission.NewPlan);
|
this.authorizationService.authorizeForce(Permission.NewPlan);
|
||||||
|
|
||||||
StorageFileEntity tempFile = this.queryFactory.query(StorageFileQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).ids(fileId).first();
|
StorageFileEntity tempFile = this.queryFactory.query(StorageFileQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).ids(fileId).first();
|
||||||
|
@ -411,7 +411,7 @@ public class FileTransformerServiceImpl implements FileTransformerService {
|
||||||
fileEnvelope.setFileRef(storageFile.getFileRef());
|
fileEnvelope.setFileRef(storageFile.getFileRef());
|
||||||
}
|
}
|
||||||
|
|
||||||
return repository.preprocessingDmp(fileEnvelope);
|
return repository.preprocessingPlan(fileEnvelope);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import gr.cite.tools.exception.MyValidationException;
|
||||||
import gr.cite.tools.fieldset.FieldSet;
|
import gr.cite.tools.fieldset.FieldSet;
|
||||||
import jakarta.xml.bind.JAXBException;
|
import jakarta.xml.bind.JAXBException;
|
||||||
import org.opencdmp.commons.types.plan.importexport.PlanImportExport;
|
import org.opencdmp.commons.types.plan.importexport.PlanImportExport;
|
||||||
import org.opencdmp.filetransformerbase.models.misc.PreprocessingDmpModel;
|
import org.opencdmp.filetransformerbase.models.misc.PreprocessingPlanModel;
|
||||||
import org.opencdmp.model.PlanUser;
|
import org.opencdmp.model.PlanUser;
|
||||||
import org.opencdmp.model.PlanValidationResult;
|
import org.opencdmp.model.PlanValidationResult;
|
||||||
import org.opencdmp.model.plan.Plan;
|
import org.opencdmp.model.plan.Plan;
|
||||||
|
@ -61,5 +61,5 @@ public interface PlanService {
|
||||||
|
|
||||||
Plan importJson(PlanCommonModelConfig planCommonModelConfig, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, InvalidApplicationException, IOException, InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException, ParserConfigurationException, TransformerException, InstantiationException, IllegalAccessException, SAXException;
|
Plan importJson(PlanCommonModelConfig planCommonModelConfig, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, InvalidApplicationException, IOException, InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException, ParserConfigurationException, TransformerException, InstantiationException, IllegalAccessException, SAXException;
|
||||||
|
|
||||||
PreprocessingDmpModel preprocessingPlan(UUID fileId, String repositoryId) throws InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, InvalidApplicationException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException, IOException;
|
PreprocessingPlanModel preprocessingPlan(UUID fileId, String repositoryId) throws InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, InvalidApplicationException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException, IOException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,19 +21,19 @@ import org.jetbrains.annotations.NotNull;
|
||||||
import org.opencdmp.authorization.AuthorizationFlags;
|
import org.opencdmp.authorization.AuthorizationFlags;
|
||||||
import org.opencdmp.authorization.Permission;
|
import org.opencdmp.authorization.Permission;
|
||||||
import org.opencdmp.authorization.authorizationcontentresolver.AuthorizationContentResolver;
|
import org.opencdmp.authorization.authorizationcontentresolver.AuthorizationContentResolver;
|
||||||
import org.opencdmp.commonmodels.models.DmpUserModel;
|
import org.opencdmp.commonmodels.models.PlanUserModel;
|
||||||
import org.opencdmp.commonmodels.models.UserModel;
|
import org.opencdmp.commonmodels.models.UserModel;
|
||||||
import org.opencdmp.commonmodels.models.description.DescriptionModel;
|
import org.opencdmp.commonmodels.models.description.DescriptionModel;
|
||||||
import org.opencdmp.commonmodels.models.dmp.DmpBlueprintValueModel;
|
import org.opencdmp.commonmodels.models.plan.PlanBlueprintValueModel;
|
||||||
import org.opencdmp.commonmodels.models.dmp.DmpContactModel;
|
import org.opencdmp.commonmodels.models.plan.PlanContactModel;
|
||||||
import org.opencdmp.commonmodels.models.dmp.DmpModel;
|
import org.opencdmp.commonmodels.models.plan.PlanModel;
|
||||||
import org.opencdmp.commonmodels.models.dmp.DmpPropertiesModel;
|
import org.opencdmp.commonmodels.models.plan.PlanPropertiesModel;
|
||||||
import org.opencdmp.commonmodels.models.dmpblueprint.ExtraFieldModel;
|
import org.opencdmp.commonmodels.models.planblueprint.ExtraFieldModel;
|
||||||
import org.opencdmp.commonmodels.models.dmpblueprint.FieldModel;
|
import org.opencdmp.commonmodels.models.planblueprint.FieldModel;
|
||||||
import org.opencdmp.commonmodels.models.dmpblueprint.ReferenceTypeFieldModel;
|
import org.opencdmp.commonmodels.models.planblueprint.ReferenceTypeFieldModel;
|
||||||
import org.opencdmp.commonmodels.models.dmpblueprint.SectionModel;
|
import org.opencdmp.commonmodels.models.planblueprint.SectionModel;
|
||||||
import org.opencdmp.commonmodels.models.dmpdescriptiontemplate.DmpDescriptionTemplateModel;
|
import org.opencdmp.commonmodels.models.plandescriptiontemplate.PlanDescriptionTemplateModel;
|
||||||
import org.opencdmp.commonmodels.models.dmpreference.DmpReferenceModel;
|
import org.opencdmp.commonmodels.models.planreference.PlanReferenceModel;
|
||||||
import org.opencdmp.commonmodels.models.reference.ReferenceModel;
|
import org.opencdmp.commonmodels.models.reference.ReferenceModel;
|
||||||
import org.opencdmp.commons.JsonHandlingService;
|
import org.opencdmp.commons.JsonHandlingService;
|
||||||
import org.opencdmp.commons.XmlHandlingService;
|
import org.opencdmp.commons.XmlHandlingService;
|
||||||
|
@ -64,7 +64,7 @@ import org.opencdmp.data.*;
|
||||||
import org.opencdmp.errorcode.ErrorThesaurusProperties;
|
import org.opencdmp.errorcode.ErrorThesaurusProperties;
|
||||||
import org.opencdmp.event.PlanTouchedEvent;
|
import org.opencdmp.event.PlanTouchedEvent;
|
||||||
import org.opencdmp.event.EventBroker;
|
import org.opencdmp.event.EventBroker;
|
||||||
import org.opencdmp.filetransformerbase.models.misc.PreprocessingDmpModel;
|
import org.opencdmp.filetransformerbase.models.misc.PreprocessingPlanModel;
|
||||||
import org.opencdmp.integrationevent.outbox.annotationentityremoval.AnnotationEntityRemovalIntegrationEventHandler;
|
import org.opencdmp.integrationevent.outbox.annotationentityremoval.AnnotationEntityRemovalIntegrationEventHandler;
|
||||||
import org.opencdmp.integrationevent.outbox.annotationentitytouch.AnnotationEntityTouchedIntegrationEventHandler;
|
import org.opencdmp.integrationevent.outbox.annotationentitytouch.AnnotationEntityTouchedIntegrationEventHandler;
|
||||||
import org.opencdmp.integrationevent.outbox.notification.NotifyIntegrationEvent;
|
import org.opencdmp.integrationevent.outbox.notification.NotifyIntegrationEvent;
|
||||||
|
@ -931,7 +931,7 @@ public class PlanServiceImpl implements PlanService {
|
||||||
if (persist.getPlanBlueprintValues() != null && !persist.getPlanBlueprintValues().isEmpty()){
|
if (persist.getPlanBlueprintValues() != null && !persist.getPlanBlueprintValues().isEmpty()){
|
||||||
data.setPlanBlueprintValues(new ArrayList<>());
|
data.setPlanBlueprintValues(new ArrayList<>());
|
||||||
for (PlanBlueprintValuePersist fieldValuePersist: persist.getPlanBlueprintValues().values()) {
|
for (PlanBlueprintValuePersist fieldValuePersist: persist.getPlanBlueprintValues().values()) {
|
||||||
if (!this.conventionService.isNullOrEmpty(fieldValuePersist.getFieldValue()) || fieldValuePersist.getDateValue() != null || fieldValuePersist.getNumberValue() != null) data.getPlanBlueprintValues().add(this.buildDmpBlueprintValueEntity(fieldValuePersist, definition));
|
if (!this.conventionService.isNullOrEmpty(fieldValuePersist.getFieldValue()) || fieldValuePersist.getDateValue() != null || fieldValuePersist.getNumberValue() != null) data.getPlanBlueprintValues().add(this.buildPlanBlueprintValueEntity(fieldValuePersist, definition));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
|
@ -947,7 +947,7 @@ public class PlanServiceImpl implements PlanService {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
private @NotNull PlanBlueprintValueEntity buildDmpBlueprintValueEntity(PlanBlueprintValuePersist persist, org.opencdmp.commons.types.planblueprint.DefinitionEntity definition){
|
private @NotNull PlanBlueprintValueEntity buildPlanBlueprintValueEntity(PlanBlueprintValuePersist persist, org.opencdmp.commons.types.planblueprint.DefinitionEntity definition){
|
||||||
PlanBlueprintValueEntity data = new PlanBlueprintValueEntity();
|
PlanBlueprintValueEntity data = new PlanBlueprintValueEntity();
|
||||||
if (persist == null || definition == null) return data;
|
if (persist == null || definition == null) return data;
|
||||||
|
|
||||||
|
@ -1266,11 +1266,11 @@ public class PlanServiceImpl implements PlanService {
|
||||||
persist.setAccessType(data.getAccessType());
|
persist.setAccessType(data.getAccessType());
|
||||||
persist.setLanguage(data.getLanguage());
|
persist.setLanguage(data.getLanguage());
|
||||||
|
|
||||||
List<PlanUserEntity> dmpUserEntities = this.queryFactory.query(PlanUserQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).planIds(data.getId()).isActives(IsActive.Active).collect();
|
List<PlanUserEntity> planUserEntities = this.queryFactory.query(PlanUserQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).planIds(data.getId()).isActives(IsActive.Active).collect();
|
||||||
|
|
||||||
if (!this.conventionService.isListNullOrEmpty(dmpUserEntities)){
|
if (!this.conventionService.isListNullOrEmpty(planUserEntities)){
|
||||||
persist.setUsers(new ArrayList<>());
|
persist.setUsers(new ArrayList<>());
|
||||||
for (PlanUserEntity user: dmpUserEntities) {
|
for (PlanUserEntity user: planUserEntities) {
|
||||||
persist.getUsers().add(this.buildPlanUserPersist(user));
|
persist.getUsers().add(this.buildPlanUserPersist(user));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1279,10 +1279,10 @@ public class PlanServiceImpl implements PlanService {
|
||||||
|
|
||||||
org.opencdmp.commons.types.planblueprint.DefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(org.opencdmp.commons.types.planblueprint.DefinitionEntity.class, planBlueprintEntity.getDefinition());
|
org.opencdmp.commons.types.planblueprint.DefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(org.opencdmp.commons.types.planblueprint.DefinitionEntity.class, planBlueprintEntity.getDefinition());
|
||||||
|
|
||||||
List<PlanDescriptionTemplateEntity> dmpDescriptionTemplateEntities = this.queryFactory.query(PlanDescriptionTemplateQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).planIds(data.getId()).isActive(IsActive.Active).collect();
|
List<PlanDescriptionTemplateEntity> planDescriptionTemplateEntities = this.queryFactory.query(PlanDescriptionTemplateQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).planIds(data.getId()).isActive(IsActive.Active).collect();
|
||||||
if (!this.conventionService.isListNullOrEmpty(dmpDescriptionTemplateEntities)){
|
if (!this.conventionService.isListNullOrEmpty(planDescriptionTemplateEntities)){
|
||||||
persist.setDescriptionTemplates(new ArrayList<>());
|
persist.setDescriptionTemplates(new ArrayList<>());
|
||||||
for (PlanDescriptionTemplateEntity descriptionTemplateEntity: dmpDescriptionTemplateEntities) {
|
for (PlanDescriptionTemplateEntity descriptionTemplateEntity: planDescriptionTemplateEntities) {
|
||||||
persist.getDescriptionTemplates().add(this.buildPlanDescriptionTemplatePersists(descriptionTemplateEntity));
|
persist.getDescriptionTemplates().add(this.buildPlanDescriptionTemplatePersists(descriptionTemplateEntity));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2053,14 +2053,14 @@ public class PlanServiceImpl implements PlanService {
|
||||||
|
|
||||||
|
|
||||||
//region Import RDA JSON
|
//region Import RDA JSON
|
||||||
public PreprocessingDmpModel preprocessingPlan(UUID fileId, String repositoryId) throws InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, InvalidApplicationException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException, IOException {
|
public PreprocessingPlanModel preprocessingPlan(UUID fileId, String repositoryId) throws InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, InvalidApplicationException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException, IOException {
|
||||||
return this.fileTransformerService.preprocessingPlan(fileId, repositoryId);
|
return this.fileTransformerService.preprocessingPlan(fileId, repositoryId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Plan importJson(PlanCommonModelConfig planCommonModelConfig, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, InvalidApplicationException, IOException, InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException, ParserConfigurationException, TransformerException, InstantiationException, IllegalAccessException, SAXException {
|
public Plan importJson(PlanCommonModelConfig planCommonModelConfig, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, InvalidApplicationException, IOException, InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException, ParserConfigurationException, TransformerException, InstantiationException, IllegalAccessException, SAXException {
|
||||||
logger.debug(new MapLogEntry("import data").And("file id", planCommonModelConfig.getFileId()).And("label", planCommonModelConfig.getLabel()).And("fields", fields));
|
logger.debug(new MapLogEntry("import data").And("file id", planCommonModelConfig.getFileId()).And("label", planCommonModelConfig.getLabel()).And("fields", fields));
|
||||||
|
|
||||||
DmpModel model = this.fileTransformerService.importPlan(planCommonModelConfig);
|
PlanModel model = this.fileTransformerService.importPlan(planCommonModelConfig);
|
||||||
if (model == null) throw new MyNotFoundException("Plan Import Error");
|
if (model == null) throw new MyNotFoundException("Plan Import Error");
|
||||||
|
|
||||||
PlanPersist persist = new PlanPersist();
|
PlanPersist persist = new PlanPersist();
|
||||||
|
@ -2093,10 +2093,10 @@ public class PlanServiceImpl implements PlanService {
|
||||||
return plan;
|
return plan;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<PlanDescriptionTemplatePersist> commonModelPlanDescriptionTemplatesToPersist(DmpModel commonModel){
|
private List<PlanDescriptionTemplatePersist> commonModelPlanDescriptionTemplatesToPersist(PlanModel commonModel){
|
||||||
if (!this.conventionService.isListNullOrEmpty(commonModel.getDescriptionTemplates())) {
|
if (!this.conventionService.isListNullOrEmpty(commonModel.getDescriptionTemplates())) {
|
||||||
List<PlanDescriptionTemplatePersist> descriptionTemplates = new ArrayList<>();
|
List<PlanDescriptionTemplatePersist> descriptionTemplates = new ArrayList<>();
|
||||||
for (DmpDescriptionTemplateModel descriptionTemplate : commonModel.getDescriptionTemplates()) {
|
for (PlanDescriptionTemplateModel descriptionTemplate : commonModel.getDescriptionTemplates()) {
|
||||||
descriptionTemplates.add(this.commonModelPlanDescriptionTemplateToPersist(descriptionTemplate));
|
descriptionTemplates.add(this.commonModelPlanDescriptionTemplateToPersist(descriptionTemplate));
|
||||||
}
|
}
|
||||||
return descriptionTemplates.stream().filter(Objects::nonNull).toList();
|
return descriptionTemplates.stream().filter(Objects::nonNull).toList();
|
||||||
|
@ -2104,7 +2104,7 @@ public class PlanServiceImpl implements PlanService {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private PlanDescriptionTemplatePersist commonModelPlanDescriptionTemplateToPersist(DmpDescriptionTemplateModel commonModel) {
|
private PlanDescriptionTemplatePersist commonModelPlanDescriptionTemplateToPersist(PlanDescriptionTemplateModel commonModel) {
|
||||||
if (commonModel == null)
|
if (commonModel == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
@ -2116,21 +2116,21 @@ public class PlanServiceImpl implements PlanService {
|
||||||
return persist;
|
return persist;
|
||||||
}
|
}
|
||||||
|
|
||||||
private UUID commonModelPlanBlueprintToPersist(DmpModel planXml) throws JAXBException, InvalidApplicationException, ParserConfigurationException, IOException, TransformerException, InstantiationException, IllegalAccessException, SAXException {
|
private UUID commonModelPlanBlueprintToPersist(PlanModel planXml) throws JAXBException, InvalidApplicationException, ParserConfigurationException, IOException, TransformerException, InstantiationException, IllegalAccessException, SAXException {
|
||||||
if (planXml.getDmpBlueprint() != null){
|
if (planXml.getPlanBlueprint() != null){
|
||||||
PlanBlueprintEntity planBlueprintEntity = this.queryFactory.query(PlanBlueprintQuery.class).disableTracking().ids(planXml.getDmpBlueprint().getId()).first();
|
PlanBlueprintEntity planBlueprintEntity = this.queryFactory.query(PlanBlueprintQuery.class).disableTracking().ids(planXml.getPlanBlueprint().getId()).first();
|
||||||
if (planBlueprintEntity == null) planBlueprintEntity = this.queryFactory.query(PlanBlueprintQuery.class).disableTracking().groupIds(planXml.getDmpBlueprint().getGroupId()).versionStatuses(PlanBlueprintVersionStatus.Current).isActive(IsActive.Active).statuses(PlanBlueprintStatus.Finalized).first();
|
if (planBlueprintEntity == null) planBlueprintEntity = this.queryFactory.query(PlanBlueprintQuery.class).disableTracking().groupIds(planXml.getPlanBlueprint().getGroupId()).versionStatuses(PlanBlueprintVersionStatus.Current).isActive(IsActive.Active).statuses(PlanBlueprintStatus.Finalized).first();
|
||||||
if (planBlueprintEntity != null){
|
if (planBlueprintEntity != null){
|
||||||
return planBlueprintEntity.getId();
|
return planBlueprintEntity.getId();
|
||||||
} else {
|
} else {
|
||||||
PlanBlueprint persisted = this.planBlueprintService.importCommonModel(planXml.getDmpBlueprint(), new BaseFieldSet().ensure(PlanBlueprint._label).ensure(PlanBlueprint._hash));
|
PlanBlueprint persisted = this.planBlueprintService.importCommonModel(planXml.getPlanBlueprint(), new BaseFieldSet().ensure(PlanBlueprint._label).ensure(PlanBlueprint._hash));
|
||||||
return persisted.getId();
|
return persisted.getId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private PlanPropertiesPersist commonModelPlanPropertiesToPersist(DmpModel commonModel) {
|
private PlanPropertiesPersist commonModelPlanPropertiesToPersist(PlanModel commonModel) {
|
||||||
if (commonModel == null || commonModel.getProperties() == null) return null;
|
if (commonModel == null || commonModel.getProperties() == null) return null;
|
||||||
|
|
||||||
PlanPropertiesPersist persist = new PlanPropertiesPersist();
|
PlanPropertiesPersist persist = new PlanPropertiesPersist();
|
||||||
|
@ -2140,10 +2140,10 @@ public class PlanServiceImpl implements PlanService {
|
||||||
return persist;
|
return persist;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<PlanContactPersist> commonModelToPlanContactPersist(DmpPropertiesModel commonModel){
|
private List<PlanContactPersist> commonModelToPlanContactPersist(PlanPropertiesModel commonModel){
|
||||||
if (!this.conventionService.isListNullOrEmpty(commonModel.getContacts())) {
|
if (!this.conventionService.isListNullOrEmpty(commonModel.getContacts())) {
|
||||||
List<PlanContactPersist> contacts = new ArrayList<>();
|
List<PlanContactPersist> contacts = new ArrayList<>();
|
||||||
for (DmpContactModel contact : commonModel.getContacts()) {
|
for (PlanContactModel contact : commonModel.getContacts()) {
|
||||||
contacts.add(this.commonModelPlanContactToPersist(contact));
|
contacts.add(this.commonModelPlanContactToPersist(contact));
|
||||||
}
|
}
|
||||||
return contacts;
|
return contacts;
|
||||||
|
@ -2151,27 +2151,27 @@ public class PlanServiceImpl implements PlanService {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<UUID, PlanBlueprintValuePersist> commonModelToPlanBlueprintValuePersist(DmpModel commonModel){
|
private Map<UUID, PlanBlueprintValuePersist> commonModelToPlanBlueprintValuePersist(PlanModel commonModel){
|
||||||
if (commonModel.getDmpBlueprint() != null && commonModel.getDmpBlueprint().getDefinition() != null && !this.conventionService.isListNullOrEmpty(commonModel.getDmpBlueprint().getDefinition().getSections())) {
|
if (commonModel.getPlanBlueprint() != null && commonModel.getPlanBlueprint().getDefinition() != null && !this.conventionService.isListNullOrEmpty(commonModel.getPlanBlueprint().getDefinition().getSections())) {
|
||||||
Map<UUID, PlanBlueprintValuePersist> planBlueprintValues = new HashMap<>();
|
Map<UUID, PlanBlueprintValuePersist> planBlueprintValues = new HashMap<>();
|
||||||
List<SectionModel> sections = commonModel.getDmpBlueprint().getDefinition().getSections();
|
List<SectionModel> sections = commonModel.getPlanBlueprint().getDefinition().getSections();
|
||||||
if (!this.conventionService.isListNullOrEmpty(sections)){
|
if (!this.conventionService.isListNullOrEmpty(sections)){
|
||||||
for (SectionModel section : sections) {
|
for (SectionModel section : sections) {
|
||||||
if (!this.conventionService.isListNullOrEmpty(section.getFields())){
|
if (!this.conventionService.isListNullOrEmpty(section.getFields())){
|
||||||
for (FieldModel field : section.getFields()) {
|
for (FieldModel field : section.getFields()) {
|
||||||
// reference
|
// reference
|
||||||
if (field.getCategory().equals(org.opencdmp.commonmodels.enums.DmpBlueprintFieldCategory.ReferenceType)){
|
if (field.getCategory().equals(org.opencdmp.commonmodels.enums.PlanBlueprintFieldCategory.ReferenceType)){
|
||||||
ReferenceTypeFieldModel referenceField = (ReferenceTypeFieldModel) field;
|
ReferenceTypeFieldModel referenceField = (ReferenceTypeFieldModel) field;
|
||||||
List<DmpReferenceModel> dmpReferencesByField = commonModel.getReferences().stream().filter(x -> x.getData() != null && x.getData().getBlueprintFieldId().equals(referenceField.getId())).collect(Collectors.toList());
|
List<PlanReferenceModel> planReferencesByField = commonModel.getReferences().stream().filter(x -> x.getData() != null && x.getData().getBlueprintFieldId().equals(referenceField.getId())).collect(Collectors.toList());
|
||||||
if (!this.conventionService.isListNullOrEmpty(dmpReferencesByField)){
|
if (!this.conventionService.isListNullOrEmpty(planReferencesByField)){
|
||||||
planBlueprintValues.put(referenceField.getId(), this.commonModelPlanReferenceFieldToPlanBlueprintValuePersist(referenceField, dmpReferencesByField));
|
planBlueprintValues.put(referenceField.getId(), this.commonModelPlanReferenceFieldToPlanBlueprintValuePersist(referenceField, planReferencesByField));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// custom fields
|
// custom fields
|
||||||
if (field.getCategory().equals(org.opencdmp.commonmodels.enums.DmpBlueprintFieldCategory.Extra) && commonModel.getProperties() != null && !this.conventionService.isListNullOrEmpty(commonModel.getProperties().getDmpBlueprintValues())){
|
if (field.getCategory().equals(org.opencdmp.commonmodels.enums.PlanBlueprintFieldCategory.Extra) && commonModel.getProperties() != null && !this.conventionService.isListNullOrEmpty(commonModel.getProperties().getPlanBlueprintValues())){
|
||||||
DmpBlueprintValueModel dmpBlueprintValueModel = commonModel.getProperties().getDmpBlueprintValues().stream().filter(x -> x.getFieldId().equals(field.getId())).findFirst().orElse(null);
|
PlanBlueprintValueModel planBlueprintValueModel = commonModel.getProperties().getPlanBlueprintValues().stream().filter(x -> x.getFieldId().equals(field.getId())).findFirst().orElse(null);
|
||||||
ExtraFieldModel extraFieldModel = (ExtraFieldModel) field;
|
ExtraFieldModel extraFieldModel = (ExtraFieldModel) field;
|
||||||
if (dmpBlueprintValueModel != null) planBlueprintValues.put(dmpBlueprintValueModel.getFieldId(), this.commonModelPlanBlueprintValueToPersist(dmpBlueprintValueModel, extraFieldModel));
|
if (planBlueprintValueModel != null) planBlueprintValues.put(planBlueprintValueModel.getFieldId(), this.commonModelPlanBlueprintValueToPersist(planBlueprintValueModel, extraFieldModel));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2183,7 +2183,7 @@ public class PlanServiceImpl implements PlanService {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private PlanBlueprintValuePersist commonModelPlanReferenceFieldToPlanBlueprintValuePersist(ReferenceTypeFieldModel model, List<DmpReferenceModel> planReferences) {
|
private PlanBlueprintValuePersist commonModelPlanReferenceFieldToPlanBlueprintValuePersist(ReferenceTypeFieldModel model, List<PlanReferenceModel> planReferences) {
|
||||||
if (model == null || this.conventionService.isListNullOrEmpty(planReferences) || model.getReferenceType() == null)
|
if (model == null || this.conventionService.isListNullOrEmpty(planReferences) || model.getReferenceType() == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
@ -2196,7 +2196,7 @@ public class PlanServiceImpl implements PlanService {
|
||||||
persist.setFieldId(model.getId());
|
persist.setFieldId(model.getId());
|
||||||
if (model.getMultipleSelect()){
|
if (model.getMultipleSelect()){
|
||||||
List<ReferencePersist> references = new ArrayList<>();
|
List<ReferencePersist> references = new ArrayList<>();
|
||||||
for (DmpReferenceModel planReference : planReferences) {
|
for (PlanReferenceModel planReference : planReferences) {
|
||||||
references.add(this.commonPlanReferenceToReferencePersist(planReference.getReference(), referenceTypeEntity));
|
references.add(this.commonPlanReferenceToReferencePersist(planReference.getReference(), referenceTypeEntity));
|
||||||
}
|
}
|
||||||
persist.setReferences(references);
|
persist.setReferences(references);
|
||||||
|
@ -2239,7 +2239,7 @@ public class PlanServiceImpl implements PlanService {
|
||||||
return persist;
|
return persist;
|
||||||
}
|
}
|
||||||
|
|
||||||
private PlanBlueprintValuePersist commonModelPlanBlueprintValueToPersist(DmpBlueprintValueModel commonModel, ExtraFieldModel extraFieldModel) {
|
private PlanBlueprintValuePersist commonModelPlanBlueprintValueToPersist(PlanBlueprintValueModel commonModel, ExtraFieldModel extraFieldModel) {
|
||||||
if (commonModel == null || extraFieldModel == null)
|
if (commonModel == null || extraFieldModel == null)
|
||||||
return null;
|
return null;
|
||||||
PlanBlueprintValuePersist persist = new PlanBlueprintValuePersist();
|
PlanBlueprintValuePersist persist = new PlanBlueprintValuePersist();
|
||||||
|
@ -2255,22 +2255,22 @@ public class PlanServiceImpl implements PlanService {
|
||||||
return persist;
|
return persist;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<PlanUserPersist> commonModelToPlanUsersPersist(DmpModel commonModel){
|
private List<PlanUserPersist> commonModelToPlanUsersPersist(PlanModel commonModel){
|
||||||
if (!this.conventionService.isListNullOrEmpty(commonModel.getUsers())) {
|
if (!this.conventionService.isListNullOrEmpty(commonModel.getUsers())) {
|
||||||
List<UserEntity> users = this.queryFactory.query(UserQuery.class).disableTracking().ids(commonModel.getUsers().stream().map(DmpUserModel::getUser).filter(Objects::nonNull).map(UserModel::getId).filter(Objects::nonNull).distinct().toList()).isActive(IsActive.Active).collect();
|
List<UserEntity> users = this.queryFactory.query(UserQuery.class).disableTracking().ids(commonModel.getUsers().stream().map(PlanUserModel::getUser).filter(Objects::nonNull).map(UserModel::getId).filter(Objects::nonNull).distinct().toList()).isActive(IsActive.Active).collect();
|
||||||
List<UUID> userIds = users == null ? new ArrayList<>() : users.stream().map(UserEntity::getId).collect(Collectors.toList());
|
List<UUID> userIds = users == null ? new ArrayList<>() : users.stream().map(UserEntity::getId).collect(Collectors.toList());
|
||||||
|
|
||||||
List<PlanUserPersist> dmpUsers = new ArrayList<>();
|
List<PlanUserPersist> planUsers = new ArrayList<>();
|
||||||
for (DmpUserModel user : commonModel.getUsers()) {
|
for (PlanUserModel user : commonModel.getUsers()) {
|
||||||
dmpUsers.add(this.commonModelPlanUserToPersist(user, userIds));
|
planUsers.add(this.commonModelPlanUserToPersist(user, userIds));
|
||||||
}
|
}
|
||||||
return dmpUsers;
|
return planUsers;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private PlanUserPersist commonModelPlanUserToPersist(DmpUserModel commonModel, List<UUID> userIds) {
|
private PlanUserPersist commonModelPlanUserToPersist(PlanUserModel commonModel, List<UUID> userIds) {
|
||||||
if (commonModel == null)
|
if (commonModel == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
@ -2293,7 +2293,7 @@ public class PlanServiceImpl implements PlanService {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private PlanContactPersist commonModelPlanContactToPersist(DmpContactModel commonModel) {
|
private PlanContactPersist commonModelPlanContactToPersist(PlanContactModel commonModel) {
|
||||||
if (commonModel == null)
|
if (commonModel == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ import gr.cite.tools.exception.MyNotFoundException;
|
||||||
import gr.cite.tools.exception.MyValidationException;
|
import gr.cite.tools.exception.MyValidationException;
|
||||||
import gr.cite.tools.fieldset.FieldSet;
|
import gr.cite.tools.fieldset.FieldSet;
|
||||||
import jakarta.xml.bind.JAXBException;
|
import jakarta.xml.bind.JAXBException;
|
||||||
import org.opencdmp.commonmodels.models.dmpblueprint.DmpBlueprintModel;
|
import org.opencdmp.commonmodels.models.planblueprint.PlanBlueprintModel;
|
||||||
import org.opencdmp.commons.enums.PlanBlueprintSystemFieldType;
|
import org.opencdmp.commons.enums.PlanBlueprintSystemFieldType;
|
||||||
import org.opencdmp.commons.types.planblueprint.importexport.BlueprintImportExport;
|
import org.opencdmp.commons.types.planblueprint.importexport.BlueprintImportExport;
|
||||||
import org.opencdmp.data.PlanBlueprintEntity;
|
import org.opencdmp.data.PlanBlueprintEntity;
|
||||||
|
@ -43,5 +43,5 @@ public interface PlanBlueprintService {
|
||||||
PlanBlueprint importXml(BlueprintImportExport planBlueprintDefinition, UUID groupId, String label, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, TransformerException, InvalidApplicationException, IOException, InstantiationException, IllegalAccessException, SAXException;
|
PlanBlueprint importXml(BlueprintImportExport planBlueprintDefinition, UUID groupId, String label, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, TransformerException, InvalidApplicationException, IOException, InstantiationException, IllegalAccessException, SAXException;
|
||||||
|
|
||||||
PlanBlueprint importXml(byte[] bytes, UUID groupId, String label, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, TransformerException, InvalidApplicationException, IOException, InstantiationException, IllegalAccessException, SAXException;
|
PlanBlueprint importXml(byte[] bytes, UUID groupId, String label, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, TransformerException, InvalidApplicationException, IOException, InstantiationException, IllegalAccessException, SAXException;
|
||||||
PlanBlueprint importCommonModel(DmpBlueprintModel planBlueprintModel, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, TransformerException, InvalidApplicationException, IOException, InstantiationException, IllegalAccessException, SAXException;
|
PlanBlueprint importCommonModel(PlanBlueprintModel planBlueprintModel, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, TransformerException, InvalidApplicationException, IOException, InstantiationException, IllegalAccessException, SAXException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ import jakarta.xml.bind.JAXBException;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.opencdmp.authorization.AuthorizationFlags;
|
import org.opencdmp.authorization.AuthorizationFlags;
|
||||||
import org.opencdmp.authorization.Permission;
|
import org.opencdmp.authorization.Permission;
|
||||||
import org.opencdmp.commonmodels.models.dmpblueprint.*;
|
import org.opencdmp.commonmodels.models.planblueprint.*;
|
||||||
import org.opencdmp.commons.XmlHandlingService;
|
import org.opencdmp.commons.XmlHandlingService;
|
||||||
import org.opencdmp.commons.enums.*;
|
import org.opencdmp.commons.enums.*;
|
||||||
import org.opencdmp.commons.scope.tenant.TenantScope;
|
import org.opencdmp.commons.scope.tenant.TenantScope;
|
||||||
|
@ -809,7 +809,7 @@ public class PlanBlueprintServiceImpl implements PlanBlueprintService {
|
||||||
//region Import Common Model
|
//region Import Common Model
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PlanBlueprint importCommonModel(DmpBlueprintModel planBlueprintModel, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, TransformerException, InvalidApplicationException, IOException, InstantiationException, IllegalAccessException, SAXException {
|
public PlanBlueprint importCommonModel(PlanBlueprintModel planBlueprintModel, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, TransformerException, InvalidApplicationException, IOException, InstantiationException, IllegalAccessException, SAXException {
|
||||||
logger.debug(new MapLogEntry("import data").And("planBlueprintModel", planBlueprintModel).And("fields", fields));
|
logger.debug(new MapLogEntry("import data").And("planBlueprintModel", planBlueprintModel).And("fields", fields));
|
||||||
|
|
||||||
this.authorizationService.authorizeForce(Permission.ImportPlanBlueprint);
|
this.authorizationService.authorizeForce(Permission.ImportPlanBlueprint);
|
||||||
|
@ -872,13 +872,13 @@ public class PlanBlueprintServiceImpl implements PlanBlueprintService {
|
||||||
persist.setHasTemplates(commonModel.getHasTemplates());
|
persist.setHasTemplates(commonModel.getHasTemplates());
|
||||||
List<FieldPersist> planBlueprintFieldModels = new LinkedList<>();
|
List<FieldPersist> planBlueprintFieldModels = new LinkedList<>();
|
||||||
if (!this.conventionService.isListNullOrEmpty(commonModel.getFields())) {
|
if (!this.conventionService.isListNullOrEmpty(commonModel.getFields())) {
|
||||||
for (SystemFieldModel systemField : commonModel.getFields().stream().filter(x-> org.opencdmp.commonmodels.enums.DmpBlueprintFieldCategory.System.equals(x.getCategory())).map(x-> (SystemFieldModel)x).toList()) {
|
for (SystemFieldModel systemField : commonModel.getFields().stream().filter(x-> org.opencdmp.commonmodels.enums.PlanBlueprintFieldCategory.System.equals(x.getCategory())).map(x-> (SystemFieldModel)x).toList()) {
|
||||||
planBlueprintFieldModels.add(this.commonModelSystemFieldToPersist(systemField));
|
planBlueprintFieldModels.add(this.commonModelSystemFieldToPersist(systemField));
|
||||||
}
|
}
|
||||||
for (ReferenceTypeFieldModel referenceField : commonModel.getFields().stream().filter(x-> org.opencdmp.commonmodels.enums.DmpBlueprintFieldCategory.ReferenceType.equals(x.getCategory())).map(x-> (ReferenceTypeFieldModel)x).toList()) {
|
for (ReferenceTypeFieldModel referenceField : commonModel.getFields().stream().filter(x-> org.opencdmp.commonmodels.enums.PlanBlueprintFieldCategory.ReferenceType.equals(x.getCategory())).map(x-> (ReferenceTypeFieldModel)x).toList()) {
|
||||||
planBlueprintFieldModels.add(this.commonModelReferenceFieldToPersist(referenceField));
|
planBlueprintFieldModels.add(this.commonModelReferenceFieldToPersist(referenceField));
|
||||||
}
|
}
|
||||||
for (ExtraFieldModel extraField : commonModel.getFields().stream().filter(x-> org.opencdmp.commonmodels.enums.DmpBlueprintFieldCategory.Extra.equals(x.getCategory())).map(x-> (ExtraFieldModel)x).toList()) {
|
for (ExtraFieldModel extraField : commonModel.getFields().stream().filter(x-> org.opencdmp.commonmodels.enums.PlanBlueprintFieldCategory.Extra.equals(x.getCategory())).map(x-> (ExtraFieldModel)x).toList()) {
|
||||||
planBlueprintFieldModels.add(this.commonExtraFieldToPersist(extraField));
|
planBlueprintFieldModels.add(this.commonExtraFieldToPersist(extraField));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ import org.opencdmp.controllers.swagger.annotation.OperationWithTenantHeader;
|
||||||
import org.opencdmp.controllers.swagger.annotation.Swagger400;
|
import org.opencdmp.controllers.swagger.annotation.Swagger400;
|
||||||
import org.opencdmp.controllers.swagger.annotation.Swagger404;
|
import org.opencdmp.controllers.swagger.annotation.Swagger404;
|
||||||
import org.opencdmp.controllers.swagger.annotation.SwaggerCommonErrorResponses;
|
import org.opencdmp.controllers.swagger.annotation.SwaggerCommonErrorResponses;
|
||||||
import org.opencdmp.filetransformerbase.models.misc.PreprocessingDmpModel;
|
import org.opencdmp.filetransformerbase.models.misc.PreprocessingPlanModel;
|
||||||
import org.opencdmp.model.DescriptionsToBeFinalized;
|
import org.opencdmp.model.DescriptionsToBeFinalized;
|
||||||
import org.opencdmp.model.PlanUser;
|
import org.opencdmp.model.PlanUser;
|
||||||
import org.opencdmp.model.PlanValidationResult;
|
import org.opencdmp.model.PlanValidationResult;
|
||||||
|
@ -499,17 +499,17 @@ public class PlanController {
|
||||||
@OperationWithTenantHeader(summary = "Preprocess a plan from a json file", description = "",
|
@OperationWithTenantHeader(summary = "Preprocess a plan from a json file", description = "",
|
||||||
responses = @ApiResponse(description = "OK", responseCode = "200", content = @Content(
|
responses = @ApiResponse(description = "OK", responseCode = "200", content = @Content(
|
||||||
schema = @Schema(
|
schema = @Schema(
|
||||||
implementation = PreprocessingDmpModel.class
|
implementation = PreprocessingPlanModel.class
|
||||||
))
|
))
|
||||||
))
|
))
|
||||||
@Transactional
|
@Transactional
|
||||||
public PreprocessingDmpModel preprocessing(
|
public PreprocessingPlanModel preprocessing(
|
||||||
@RequestParam("fileId") UUID fileId,
|
@RequestParam("fileId") UUID fileId,
|
||||||
@RequestParam("repositoryId") String repositoryId
|
@RequestParam("repositoryId") String repositoryId
|
||||||
) throws InvalidAlgorithmParameterException, JAXBException, NoSuchPaddingException, IllegalBlockSizeException, InvalidApplicationException, IOException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException {
|
) throws InvalidAlgorithmParameterException, JAXBException, NoSuchPaddingException, IllegalBlockSizeException, InvalidApplicationException, IOException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException {
|
||||||
logger.debug(new MapLogEntry("preprocessing plan" + Plan.class.getSimpleName()).And("transformerId", repositoryId).And("fileId", fileId));
|
logger.debug(new MapLogEntry("preprocessing plan" + Plan.class.getSimpleName()).And("transformerId", repositoryId).And("fileId", fileId));
|
||||||
|
|
||||||
PreprocessingDmpModel model = this.planService.preprocessingPlan(fileId, repositoryId);
|
PreprocessingPlanModel model = this.planService.preprocessingPlan(fileId, repositoryId);
|
||||||
|
|
||||||
this.auditService.track(AuditableAction.Plan_Import, Map.ofEntries(
|
this.auditService.track(AuditableAction.Plan_Import, Map.ofEntries(
|
||||||
new AbstractMap.SimpleEntry<String, Object>("transformerId", repositoryId),
|
new AbstractMap.SimpleEntry<String, Object>("transformerId", repositoryId),
|
||||||
|
|
|
@ -14,7 +14,7 @@ import java.util.UUID;
|
||||||
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "\"DmpBlueprint\"")
|
@Table(name = "\"PlanBlueprint\"")
|
||||||
public class DMPProfile implements DataEntity<DMPProfile, UUID> {
|
public class DMPProfile implements DataEntity<DMPProfile, UUID> {
|
||||||
|
|
||||||
public enum Status {
|
public enum Status {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package eu.old.eudat.migration;
|
package eu.old.eudat.migration;
|
||||||
|
|
||||||
import eu.old.eudat.data.entities.DMP;
|
import eu.old.eudat.data.entities.DMP;
|
||||||
import eu.old.eudat.elastic.entities.Tag;
|
|
||||||
import org.opencdmp.commons.JsonHandlingService;
|
import org.opencdmp.commons.JsonHandlingService;
|
||||||
import org.opencdmp.commons.XmlHandlingService;
|
import org.opencdmp.commons.XmlHandlingService;
|
||||||
import org.opencdmp.commons.enums.*;
|
import org.opencdmp.commons.enums.*;
|
||||||
|
@ -9,12 +8,12 @@ import org.opencdmp.commons.types.description.*;
|
||||||
import org.opencdmp.commons.types.descriptionreference.DescriptionReferenceDataEntity;
|
import org.opencdmp.commons.types.descriptionreference.DescriptionReferenceDataEntity;
|
||||||
import org.opencdmp.commons.types.descriptiontemplate.FieldSetEntity;
|
import org.opencdmp.commons.types.descriptiontemplate.FieldSetEntity;
|
||||||
import org.opencdmp.commons.types.descriptiontemplate.fielddata.ReferenceTypeDataEntity;
|
import org.opencdmp.commons.types.descriptiontemplate.fielddata.ReferenceTypeDataEntity;
|
||||||
import org.opencdmp.commons.types.dmpblueprint.DefinitionEntity;
|
import org.opencdmp.commons.types.planblueprint.DefinitionEntity;
|
||||||
import org.opencdmp.commons.types.externalfetcher.ExternalFetcherApiSourceConfigurationEntity;
|
import org.opencdmp.commons.types.externalfetcher.ExternalFetcherApiSourceConfigurationEntity;
|
||||||
import org.opencdmp.commons.types.referencetype.ReferenceTypeDefinitionEntity;
|
import org.opencdmp.commons.types.referencetype.ReferenceTypeDefinitionEntity;
|
||||||
import org.opencdmp.convention.ConventionService;
|
import org.opencdmp.convention.ConventionService;
|
||||||
import org.opencdmp.data.*;
|
import org.opencdmp.data.*;
|
||||||
import org.opencdmp.model.dmp.Dmp;
|
import org.opencdmp.model.plan.Plan;
|
||||||
import org.opencdmp.model.reference.Reference;
|
import org.opencdmp.model.reference.Reference;
|
||||||
import org.opencdmp.model.referencetype.ReferenceType;
|
import org.opencdmp.model.referencetype.ReferenceType;
|
||||||
import org.opencdmp.query.*;
|
import org.opencdmp.query.*;
|
||||||
|
@ -48,7 +47,7 @@ import java.util.stream.Stream;
|
||||||
@Service
|
@Service
|
||||||
public class DatasetMigrationService {
|
public class DatasetMigrationService {
|
||||||
|
|
||||||
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpDatasetProfileMigrationService.class));
|
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DatasetMigrationService.class));
|
||||||
private final DatabaseRepository databaseRepository;
|
private final DatabaseRepository databaseRepository;
|
||||||
private final JsonHandlingService jsonHandlingService;
|
private final JsonHandlingService jsonHandlingService;
|
||||||
private final QueryFactory queryFactory;
|
private final QueryFactory queryFactory;
|
||||||
|
@ -96,11 +95,11 @@ public class DatasetMigrationService {
|
||||||
if (items != null && !items.isEmpty()) {
|
if (items != null && !items.isEmpty()) {
|
||||||
logger.debug("Migrate Dataset " + page * PageSize + " of " + total);
|
logger.debug("Migrate Dataset " + page * PageSize + " of " + total);
|
||||||
|
|
||||||
List<DmpBlueprintEntity> dmpBlueprints = this.queryFactory.query(DmpBlueprintQuery.class).ids(items.stream().map(x-> x.getDmp().getProfile().getId()).distinct().toList()).collect();
|
List<PlanBlueprintEntity> planBlueprints = this.queryFactory.query(PlanBlueprintQuery.class).ids(items.stream().map(x-> x.getDmp().getProfile().getId()).distinct().toList()).collect();
|
||||||
Map<UUID, DefinitionEntity> dmpBlueprintsMap = new HashMap<>();
|
Map<UUID, DefinitionEntity> planBlueprintsMap = new HashMap<>();
|
||||||
for (DmpBlueprintEntity dmpBlueprint : dmpBlueprints) {
|
for (PlanBlueprintEntity planBlueprint : planBlueprints) {
|
||||||
DefinitionEntity definitionEntity = this.xmlHandlingService.fromXml(DefinitionEntity.class, dmpBlueprint.getDefinition());
|
DefinitionEntity definitionEntity = this.xmlHandlingService.fromXml(DefinitionEntity.class, planBlueprint.getDefinition());
|
||||||
dmpBlueprintsMap.put(dmpBlueprint.getId(), definitionEntity);
|
planBlueprintsMap.put(planBlueprint.getId(), definitionEntity);
|
||||||
}
|
}
|
||||||
List<UUID> changeTemplateToH2020 = Stream.of("0c82f2ce-5ff7-4ca9-a500-9f3062adf550",
|
List<UUID> changeTemplateToH2020 = Stream.of("0c82f2ce-5ff7-4ca9-a500-9f3062adf550",
|
||||||
"7acd3b36-e598-459c-8170-87c51ac80efb",
|
"7acd3b36-e598-459c-8170-87c51ac80efb",
|
||||||
|
@ -118,8 +117,8 @@ public class DatasetMigrationService {
|
||||||
UUID horizon2020UUID = UUID.fromString("6ddde24b-e7a0-477f-a2cd-0a8fad915dc8");
|
UUID horizon2020UUID = UUID.fromString("6ddde24b-e7a0-477f-a2cd-0a8fad915dc8");
|
||||||
UUID horizonGroupId = UUID.fromString("3689bcce-405a-4d55-9854-669597b79c0a");
|
UUID horizonGroupId = UUID.fromString("3689bcce-405a-4d55-9854-669597b79c0a");
|
||||||
|
|
||||||
List<DmpDescriptionTemplateEntity> dmpDescriptionTemplateEntities = this.queryFactory.query(DmpDescriptionTemplateQuery.class).dmpIds(items.stream().map(x-> x.getDmp().getId()).distinct().toList()).collect();
|
List<PlanDescriptionTemplateEntity> planDescriptionTemplateEntities = this.queryFactory.query(PlanDescriptionTemplateQuery.class).planIds(items.stream().map(x-> x.getDmp().getId()).distinct().toList()).collect();
|
||||||
Map<UUID, UUID> creatorsByDmp = this.queryFactory.query(DmpQuery.class).ids(items.stream().map(x-> x.getDmp().getId()).distinct().toList()).collectAs(new BaseFieldSet().ensure(Dmp._id).ensure(Dmp._creator)).stream().collect(Collectors.toMap(DmpEntity::getId, DmpEntity::getCreatorId));
|
Map<UUID, UUID> creatorsByPlan = this.queryFactory.query(PlanQuery.class).ids(items.stream().map(x-> x.getDmp().getId()).distinct().toList()).collectAs(new BaseFieldSet().ensure(Plan._id).ensure(Plan._creator)).stream().collect(Collectors.toMap(PlanEntity::getId, PlanEntity::getCreatorId));
|
||||||
|
|
||||||
List<UUID> profileIds = new ArrayList<>(items.stream().map(x -> x.getProfile().getId()).distinct().toList());
|
List<UUID> profileIds = new ArrayList<>(items.stream().map(x -> x.getProfile().getId()).distinct().toList());
|
||||||
profileIds.add(horizon2020UUID);
|
profileIds.add(horizon2020UUID);
|
||||||
|
@ -137,7 +136,7 @@ public class DatasetMigrationService {
|
||||||
profileGroupId = horizonGroupId;
|
profileGroupId = horizonGroupId;
|
||||||
}
|
}
|
||||||
|
|
||||||
DefinitionEntity definition = dmpBlueprintsMap.getOrDefault(item.getDmp().getProfile().getId(), null);
|
DefinitionEntity definition = planBlueprintsMap.getOrDefault(item.getDmp().getProfile().getId(), null);
|
||||||
|
|
||||||
if (definition == null || definition.getSections() == null || definition.getSections().size() <= item.getDmpSectionIndex()) {
|
if (definition == null || definition.getSections() == null || definition.getSections().size() <= item.getDmpSectionIndex()) {
|
||||||
throw new MyApplicationException("Migrate Dataset " + item.getId() + " cannot found section id for section " + item.getDmpSectionIndex());
|
throw new MyApplicationException("Migrate Dataset " + item.getId() + " cannot found section id for section " + item.getDmpSectionIndex());
|
||||||
|
@ -147,10 +146,10 @@ public class DatasetMigrationService {
|
||||||
throw new MyApplicationException("Migrate Dataset " + item.getId() + " cannot found section id for section " + item.getDmpSectionIndex());
|
throw new MyApplicationException("Migrate Dataset " + item.getId() + " cannot found section id for section " + item.getDmpSectionIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
List<DmpDescriptionTemplateEntity> itemDescriptionTemplates = this.getOrCreateDmpDescriptionTemplateEntity(item, sectionId, profileGroupId, dmpDescriptionTemplateEntities);
|
List<PlanDescriptionTemplateEntity> itemDescriptionTemplates = this.getOrCreatePlanDescriptionTemplateEntity(item, sectionId, profileGroupId, planDescriptionTemplateEntities);
|
||||||
|
|
||||||
if (itemDescriptionTemplates.size() > 1) {
|
if (itemDescriptionTemplates.size() > 1) {
|
||||||
throw new MyApplicationException("Migrate Dataset " + item.getId() + " multiple DmpDescriptionTemplateEntity for section " + item.getDmpSectionIndex());
|
throw new MyApplicationException("Migrate Dataset " + item.getId() + " multiple PlanDescriptionTemplateEntity for section " + item.getDmpSectionIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
DescriptionEntity data = new DescriptionEntity();
|
DescriptionEntity data = new DescriptionEntity();
|
||||||
|
@ -159,11 +158,11 @@ public class DatasetMigrationService {
|
||||||
if (item.getCreator() != null) {
|
if (item.getCreator() != null) {
|
||||||
data.setCreatedById(item.getCreator().getId());
|
data.setCreatedById(item.getCreator().getId());
|
||||||
} else {
|
} else {
|
||||||
data.setCreatedById(creatorsByDmp.getOrDefault(item.getDmp().getId(), null));
|
data.setCreatedById(creatorsByPlan.getOrDefault(item.getDmp().getId(), null));
|
||||||
}
|
}
|
||||||
data.setDmpId(item.getDmp().getId());
|
data.setPlanId(item.getDmp().getId());
|
||||||
data.setLabel(item.getLabel());
|
data.setLabel(item.getLabel());
|
||||||
data.setDmpDescriptionTemplateId(itemDescriptionTemplates.getFirst().getId());
|
data.setPlanDescriptionTemplateId(itemDescriptionTemplates.getFirst().getId());
|
||||||
data.setDescriptionTemplateId(profileId);
|
data.setDescriptionTemplateId(profileId);
|
||||||
data.setCreatedAt(item.getCreated() != null ? item.getCreated().toInstant() : Instant.now());
|
data.setCreatedAt(item.getCreated() != null ? item.getCreated().toInstant() : Instant.now());
|
||||||
data.setUpdatedAt(item.getModified() != null ? item.getModified().toInstant() : Instant.now());
|
data.setUpdatedAt(item.getModified() != null ? item.getModified().toInstant() : Instant.now());
|
||||||
|
@ -196,16 +195,16 @@ public class DatasetMigrationService {
|
||||||
} while (items != null && !items.isEmpty() && !TestMode);
|
} while (items != null && !items.isEmpty() && !TestMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<DmpDescriptionTemplateEntity> getOrCreateDmpDescriptionTemplateEntity(Dataset item, UUID sectionId, UUID groupId, List<DmpDescriptionTemplateEntity> dmpDescriptionTemplateEntities){
|
private List<PlanDescriptionTemplateEntity> getOrCreatePlanDescriptionTemplateEntity(Dataset item, UUID sectionId, UUID groupId, List<PlanDescriptionTemplateEntity> dmpDescriptionTemplateEntities){
|
||||||
List<DmpDescriptionTemplateEntity> itemDescriptionTemplates = dmpDescriptionTemplateEntities.stream().filter(x-> x.getDescriptionTemplateGroupId().equals(groupId) && x.getDmpId().equals(item.getDmp().getId()) && x.getSectionId().equals(sectionId)).toList();
|
List<PlanDescriptionTemplateEntity> itemDescriptionTemplates = dmpDescriptionTemplateEntities.stream().filter(x-> x.getDescriptionTemplateGroupId().equals(groupId) && x.getPlanId().equals(item.getDmp().getId()) && x.getSectionId().equals(sectionId)).toList();
|
||||||
if (itemDescriptionTemplates.isEmpty()) {
|
if (itemDescriptionTemplates.isEmpty()) {
|
||||||
boolean isDeleted = item.getStatus().equals(Dataset.Status.CANCELED.getValue()) ||item.getStatus().equals(Dataset.Status.DELETED.getValue()) || item.getDmp().getStatus().equals(DMP.DMPStatus.DELETED.getValue());
|
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 (!isDeleted) logger.warn("Migrate Dataset " + item.getId() + " cannot found PlanDescriptionTemplateEntity for section " + item.getDmpSectionIndex());
|
||||||
if (dmpDescriptionTemplateEntities.stream().anyMatch(x -> x.getDmpId().equals(item.getDmp().getId()) && x.getSectionId().equals(sectionId))) {
|
if (dmpDescriptionTemplateEntities.stream().anyMatch(x -> x.getPlanId().equals(item.getDmp().getId()) && x.getSectionId().equals(sectionId))) {
|
||||||
DmpDescriptionTemplateEntity dmpDescriptionTemplateEntity = new DmpDescriptionTemplateEntity();
|
PlanDescriptionTemplateEntity dmpDescriptionTemplateEntity = new PlanDescriptionTemplateEntity();
|
||||||
dmpDescriptionTemplateEntity.setId(UUID.randomUUID());
|
dmpDescriptionTemplateEntity.setId(UUID.randomUUID());
|
||||||
dmpDescriptionTemplateEntity.setDescriptionTemplateGroupId(groupId);
|
dmpDescriptionTemplateEntity.setDescriptionTemplateGroupId(groupId);
|
||||||
dmpDescriptionTemplateEntity.setDmpId(item.getDmp().getId());
|
dmpDescriptionTemplateEntity.setPlanId(item.getDmp().getId());
|
||||||
dmpDescriptionTemplateEntity.setCreatedAt(item.getCreated() != null ? item.getCreated().toInstant() : Instant.now());
|
dmpDescriptionTemplateEntity.setCreatedAt(item.getCreated() != null ? item.getCreated().toInstant() : Instant.now());
|
||||||
dmpDescriptionTemplateEntity.setUpdatedAt(item.getModified() != null ? item.getModified().toInstant() : Instant.now());
|
dmpDescriptionTemplateEntity.setUpdatedAt(item.getModified() != null ? item.getModified().toInstant() : Instant.now());
|
||||||
dmpDescriptionTemplateEntity.setSectionId(sectionId);
|
dmpDescriptionTemplateEntity.setSectionId(sectionId);
|
||||||
|
@ -214,7 +213,7 @@ public class DatasetMigrationService {
|
||||||
this.entityManager.flush();
|
this.entityManager.flush();
|
||||||
itemDescriptionTemplates = List.of(dmpDescriptionTemplateEntity);
|
itemDescriptionTemplates = List.of(dmpDescriptionTemplateEntity);
|
||||||
} else {
|
} else {
|
||||||
throw new MyApplicationException("Migrate Dataset " + item.getId() + " " + item.getLabel() + " cannot found DmpDescriptionTemplateEntity for section " + item.getDmpSectionIndex());
|
throw new MyApplicationException("Migrate Dataset " + item.getId() + " " + item.getLabel() + " cannot found PlanDescriptionTemplateEntity for section " + item.getDmpSectionIndex());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return itemDescriptionTemplates;
|
return itemDescriptionTemplates;
|
||||||
|
@ -327,10 +326,10 @@ public class DatasetMigrationService {
|
||||||
keyParts = newKey.split("_");
|
keyParts = newKey.split("_");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String fieldSetId = "";
|
String fieldSetId;
|
||||||
String groupId = "";
|
String groupId;
|
||||||
int ordinal = Integer.MIN_VALUE;
|
int ordinal = Integer.MIN_VALUE;
|
||||||
String fieldId = "";
|
String fieldId;
|
||||||
|
|
||||||
if (keyParts.length == 4) {
|
if (keyParts.length == 4) {
|
||||||
fieldSetId = keyParts[0].trim();
|
fieldSetId = keyParts[0].trim();
|
||||||
|
@ -405,7 +404,7 @@ public class DatasetMigrationService {
|
||||||
propertyDefinitionEntity.getFieldSets().put(currentFieldSet.getId().trim(), propertyDefinitionFieldSetEntity);
|
propertyDefinitionEntity.getFieldSets().put(currentFieldSet.getId().trim(), propertyDefinitionFieldSetEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertyDefinitionFieldSetItemEntity propertyDefinitionFieldSetItemEntity = null;
|
PropertyDefinitionFieldSetItemEntity propertyDefinitionFieldSetItemEntity;
|
||||||
if (this.conventionService.isListNullOrEmpty(propertyDefinitionFieldSetEntity.getItems())){
|
if (this.conventionService.isListNullOrEmpty(propertyDefinitionFieldSetEntity.getItems())){
|
||||||
propertyDefinitionFieldSetItemEntity = new PropertyDefinitionFieldSetItemEntity();
|
propertyDefinitionFieldSetItemEntity = new PropertyDefinitionFieldSetItemEntity();
|
||||||
propertyDefinitionFieldSetItemEntity.setFields(new HashMap<>());
|
propertyDefinitionFieldSetItemEntity.setFields(new HashMap<>());
|
||||||
|
@ -427,7 +426,7 @@ public class DatasetMigrationService {
|
||||||
propertyDefinitionEntity.getFieldSets().put(currentFieldSet.getId().trim(), propertyDefinitionFieldSetEntity);
|
propertyDefinitionEntity.getFieldSets().put(currentFieldSet.getId().trim(), propertyDefinitionFieldSetEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertyDefinitionFieldSetItemEntity propertyDefinitionFieldSetItemEntity = null;
|
PropertyDefinitionFieldSetItemEntity propertyDefinitionFieldSetItemEntity;
|
||||||
if (this.conventionService.isListNullOrEmpty(propertyDefinitionFieldSetEntity.getItems())){
|
if (this.conventionService.isListNullOrEmpty(propertyDefinitionFieldSetEntity.getItems())){
|
||||||
propertyDefinitionFieldSetItemEntity = new PropertyDefinitionFieldSetItemEntity();
|
propertyDefinitionFieldSetItemEntity = new PropertyDefinitionFieldSetItemEntity();
|
||||||
propertyDefinitionFieldSetItemEntity.setFields(new HashMap<>());
|
propertyDefinitionFieldSetItemEntity.setFields(new HashMap<>());
|
||||||
|
@ -509,7 +508,7 @@ public class DatasetMigrationService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case INTERNAL_ENTRIES_DMPS -> throw new MyApplicationException("Found INTERNAL_ENTRIES_DMPS into description");
|
case INTERNAL_ENTRIES_PLANS -> throw new MyApplicationException("Found INTERNAL_ENTRIES_DMPS into description");
|
||||||
case INTERNAL_ENTRIES_DESCRIPTIONS -> throw new MyApplicationException("Found INTERNAL_ENTRIES_DMPS into description");
|
case INTERNAL_ENTRIES_DESCRIPTIONS -> throw new MyApplicationException("Found INTERNAL_ENTRIES_DMPS into description");
|
||||||
case VALIDATION -> throw new MyApplicationException("Found VALIDATION into description");
|
case VALIDATION -> throw new MyApplicationException("Found VALIDATION into description");
|
||||||
case REFERENCE_TYPES -> {
|
case REFERENCE_TYPES -> {
|
||||||
|
@ -603,7 +602,7 @@ public class DatasetMigrationService {
|
||||||
if (this.conventionService.isListNullOrEmpty(referenceTypeDefinition.getSources())) throw new MyApplicationException("Could not find reference source for reference : " + this.jsonHandlingService.toJsonSafe(textValue));
|
if (this.conventionService.isListNullOrEmpty(referenceTypeDefinition.getSources())) throw new MyApplicationException("Could not find reference source for reference : " + this.jsonHandlingService.toJsonSafe(textValue));
|
||||||
//if (referenceTypeDefinition.getSources().size() > 1) throw new MyApplicationException("Multiple reference source for reference : " + this.jsonHandlingService.toJsonSafe(textValue));
|
//if (referenceTypeDefinition.getSources().size() > 1) throw new MyApplicationException("Multiple reference source for reference : " + this.jsonHandlingService.toJsonSafe(textValue));
|
||||||
String source = referenceTypeDefinition.getSources().getFirst().getKey();
|
String source = referenceTypeDefinition.getSources().getFirst().getKey();
|
||||||
String[] parts = null;
|
String[] parts;
|
||||||
if (textValue.startsWith("[\"")){
|
if (textValue.startsWith("[\"")){
|
||||||
parts = migrationTools.tryParseJsonAsObjectString(String[].class, textValue);
|
parts = migrationTools.tryParseJsonAsObjectString(String[].class, textValue);
|
||||||
} else{
|
} else{
|
||||||
|
@ -623,7 +622,7 @@ public class DatasetMigrationService {
|
||||||
items.add(ref);
|
items.add(ref);
|
||||||
}
|
}
|
||||||
if (items.isEmpty()) break;
|
if (items.isEmpty()) break;
|
||||||
references = items.toArray(new Map[items.size()]);
|
references = items.toArray(new Map[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -686,7 +685,7 @@ public class DatasetMigrationService {
|
||||||
items.add(ref);
|
items.add(ref);
|
||||||
}
|
}
|
||||||
if (items.isEmpty()) break;
|
if (items.isEmpty()) break;
|
||||||
references = items.toArray(new Map[items.size()]);
|
references = items.toArray(new Map[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (references == null && (ReferenceTypeIds.Datasets.equals(referenceTypeDataEntity.getReferenceTypeId())
|
if (references == null && (ReferenceTypeIds.Datasets.equals(referenceTypeDataEntity.getReferenceTypeId())
|
||||||
|
@ -697,7 +696,7 @@ public class DatasetMigrationService {
|
||||||
if (textValue.equals("[\".\"]")){
|
if (textValue.equals("[\".\"]")){
|
||||||
break;
|
break;
|
||||||
} else if (!textValue.contains("{")) {
|
} else if (!textValue.contains("{")) {
|
||||||
String[] parts = null;
|
String[] parts;
|
||||||
if (textValue.startsWith("[\"")){
|
if (textValue.startsWith("[\"")){
|
||||||
parts = migrationTools.tryParseJsonAsObjectString(String[].class, textValue);
|
parts = migrationTools.tryParseJsonAsObjectString(String[].class, textValue);
|
||||||
} else{
|
} else{
|
||||||
|
@ -719,7 +718,7 @@ public class DatasetMigrationService {
|
||||||
items.add(ref);
|
items.add(ref);
|
||||||
}
|
}
|
||||||
if (items.isEmpty()) break;
|
if (items.isEmpty()) break;
|
||||||
references = items.toArray(new Map[items.size()]);
|
references = items.toArray(new Map[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ import java.util.UUID;
|
||||||
@Service
|
@Service
|
||||||
public class DatasetReferenceMigrationService {
|
public class DatasetReferenceMigrationService {
|
||||||
|
|
||||||
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpDatasetProfileMigrationService.class));
|
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DatasetReferenceMigrationService.class));
|
||||||
private final DatabaseRepository databaseRepository;
|
private final DatabaseRepository databaseRepository;
|
||||||
private static final int PageSize = 500;
|
private static final int PageSize = 500;
|
||||||
private final EntityManager entityManager;
|
private final EntityManager entityManager;
|
||||||
|
|
|
@ -304,7 +304,7 @@ public class DescriptionTemplateXmlMigrationService {
|
||||||
if (renderStyle.equals("internalDmpEntities")){
|
if (renderStyle.equals("internalDmpEntities")){
|
||||||
switch (((InternalDmpEntitiesData<?>)persist).getType()){
|
switch (((InternalDmpEntitiesData<?>)persist).getType()){
|
||||||
case "dmps":
|
case "dmps":
|
||||||
return this.buildLabelAndMultiplicityDataEntity(persist.getLabel(), ((DMPsAutoCompleteData)persist).getMultiAutoComplete(),FieldType.INTERNAL_ENTRIES_DMPS);
|
return this.buildLabelAndMultiplicityDataEntity(persist.getLabel(), ((DMPsAutoCompleteData)persist).getMultiAutoComplete(),FieldType.INTERNAL_ENTRIES_PLANS);
|
||||||
case "datasets":
|
case "datasets":
|
||||||
return this.buildLabelAndMultiplicityDataEntity(persist.getLabel(), ((DatasetsAutoCompleteData)persist).getMultiAutoComplete(),FieldType.INTERNAL_ENTRIES_DESCRIPTIONS);
|
return this.buildLabelAndMultiplicityDataEntity(persist.getLabel(), ((DatasetsAutoCompleteData)persist).getMultiAutoComplete(),FieldType.INTERNAL_ENTRIES_DESCRIPTIONS);
|
||||||
case "researchers":
|
case "researchers":
|
||||||
|
@ -439,7 +439,7 @@ public class DescriptionTemplateXmlMigrationService {
|
||||||
case UPLOAD -> throw new NotSupportedException("Upload validator not supported");
|
case UPLOAD -> throw new NotSupportedException("Upload validator not supported");
|
||||||
case TAGS -> throw new NotSupportedException("Tags validator not supported");
|
case TAGS -> throw new NotSupportedException("Tags validator not supported");
|
||||||
|
|
||||||
case INTERNAL_ENTRIES_DMPS -> throw new NotSupportedException("INTERNAL_ENTRIES_DMPS validator not supported for description template " + descriptionTemplateId);
|
case INTERNAL_ENTRIES_PLANS -> throw new NotSupportedException("INTERNAL_ENTRIES_PLANS validator not supported for description template " + descriptionTemplateId);
|
||||||
case INTERNAL_ENTRIES_DESCRIPTIONS -> throw new NotSupportedException("INTERNAL_ENTRIES_DESCRIPTIONS validator not supported for description template " + descriptionTemplateId);
|
case INTERNAL_ENTRIES_DESCRIPTIONS -> throw new NotSupportedException("INTERNAL_ENTRIES_DESCRIPTIONS validator not supported for description template " + descriptionTemplateId);
|
||||||
case REFERENCE_TYPES -> throw new NotSupportedException("REFERENCE_TYPES validator not supported for description template " + descriptionTemplateId);
|
case REFERENCE_TYPES -> throw new NotSupportedException("REFERENCE_TYPES validator not supported for description template " + descriptionTemplateId);
|
||||||
default -> throw new MyApplicationException("unrecognized type " + fieldType);
|
default -> throw new MyApplicationException("unrecognized type " + fieldType);
|
||||||
|
@ -493,7 +493,7 @@ public class DescriptionTemplateXmlMigrationService {
|
||||||
case UPLOAD -> throw new NotSupportedException("Upload validator not supported");
|
case UPLOAD -> throw new NotSupportedException("Upload validator not supported");
|
||||||
case TAGS -> throw new NotSupportedException("Tags validator not supported");
|
case TAGS -> throw new NotSupportedException("Tags validator not supported");
|
||||||
|
|
||||||
case INTERNAL_ENTRIES_DMPS -> throw new NotSupportedException("INTERNAL_ENTRIES_DMPS validator not supported");
|
case INTERNAL_ENTRIES_PLANS -> throw new NotSupportedException("INTERNAL_ENTRIES_PLANS validator not supported");
|
||||||
case INTERNAL_ENTRIES_DESCRIPTIONS -> throw new NotSupportedException("INTERNAL_ENTRIES_DESCRIPTIONS validator not supported");
|
case INTERNAL_ENTRIES_DESCRIPTIONS -> throw new NotSupportedException("INTERNAL_ENTRIES_DESCRIPTIONS validator not supported");
|
||||||
case REFERENCE_TYPES -> throw new NotSupportedException("REFERENCE_TYPES validator not supported");
|
case REFERENCE_TYPES -> throw new NotSupportedException("REFERENCE_TYPES validator not supported");
|
||||||
default -> throw new MyApplicationException("unrecognized type " + fieldType);
|
default -> throw new MyApplicationException("unrecognized type " + fieldType);
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
package eu.old.eudat.migration;
|
package eu.old.eudat.migration;
|
||||||
|
|
||||||
import org.opencdmp.commons.enums.IsActive;
|
import org.opencdmp.commons.enums.IsActive;
|
||||||
import org.opencdmp.commons.enums.ReferenceFieldDataType;
|
|
||||||
import org.opencdmp.commons.enums.ReferenceSourceType;
|
import org.opencdmp.commons.enums.ReferenceSourceType;
|
||||||
import org.opencdmp.commons.types.reference.DefinitionEntity;
|
|
||||||
import org.opencdmp.commons.types.reference.FieldEntity;
|
|
||||||
import org.opencdmp.data.ReferenceEntity;
|
import org.opencdmp.data.ReferenceEntity;
|
||||||
import eu.old.eudat.data.dao.entities.FunderDao;
|
import eu.old.eudat.data.dao.entities.FunderDao;
|
||||||
import eu.old.eudat.data.entities.Funder;
|
import eu.old.eudat.data.entities.Funder;
|
||||||
|
@ -14,7 +11,6 @@ import jakarta.persistence.EntityManager;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
package eu.old.eudat.migration;
|
package eu.old.eudat.migration;
|
||||||
|
|
||||||
import org.opencdmp.commons.XmlHandlingService;
|
import org.opencdmp.commons.XmlHandlingService;
|
||||||
import org.opencdmp.commons.enums.DmpBlueprintExtraFieldDataType;
|
import org.opencdmp.commons.enums.PlanBlueprintExtraFieldDataType;
|
||||||
import org.opencdmp.commons.enums.DmpBlueprintFieldCategory;
|
import org.opencdmp.commons.enums.PlanBlueprintFieldCategory;
|
||||||
import org.opencdmp.commons.enums.DmpBlueprintSystemFieldType;
|
import org.opencdmp.commons.enums.PlanBlueprintSystemFieldType;
|
||||||
import org.opencdmp.commons.types.dmpblueprint.*;
|
import org.opencdmp.commons.types.planblueprint.*;
|
||||||
import org.opencdmp.convention.ConventionService;
|
import org.opencdmp.convention.ConventionService;
|
||||||
import org.opencdmp.data.DescriptionTemplateEntity;
|
import org.opencdmp.data.DescriptionTemplateEntity;
|
||||||
import org.opencdmp.data.DmpBlueprintEntity;
|
import org.opencdmp.data.PlanBlueprintEntity;
|
||||||
import org.opencdmp.model.dmpblueprint.DmpBlueprint;
|
import org.opencdmp.model.planblueprint.PlanBlueprint;
|
||||||
import org.opencdmp.query.DescriptionTemplateQuery;
|
import org.opencdmp.query.DescriptionTemplateQuery;
|
||||||
import org.opencdmp.query.DmpBlueprintQuery;
|
import org.opencdmp.query.PlanBlueprintQuery;
|
||||||
import eu.old.eudat.logic.utilities.builders.XmlBuilder;
|
import eu.old.eudat.logic.utilities.builders.XmlBuilder;
|
||||||
import eu.old.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.*;
|
import eu.old.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.*;
|
||||||
import eu.old.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.FieldCategory;
|
import eu.old.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.FieldCategory;
|
||||||
|
@ -36,9 +36,9 @@ import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class DmpBlueprintXmlMigrationService {
|
public class PlanBlueprintXmlMigrationService {
|
||||||
|
|
||||||
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpBlueprintXmlMigrationService.class));
|
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PlanBlueprintXmlMigrationService.class));
|
||||||
private final EntityManager entityManager;
|
private final EntityManager entityManager;
|
||||||
private final ConventionService conventionService;
|
private final ConventionService conventionService;
|
||||||
private final XmlHandlingService xmlHandlingService;
|
private final XmlHandlingService xmlHandlingService;
|
||||||
|
@ -47,7 +47,7 @@ public class DmpBlueprintXmlMigrationService {
|
||||||
private static final int PageSize = 500;
|
private static final int PageSize = 500;
|
||||||
private static final boolean TestMode = false;
|
private static final boolean TestMode = false;
|
||||||
|
|
||||||
public DmpBlueprintXmlMigrationService(EntityManager entityManager, ConventionService conventionService, XmlHandlingService xmlHandlingService, QueryFactory queryFactory) {
|
public PlanBlueprintXmlMigrationService(EntityManager entityManager, ConventionService conventionService, XmlHandlingService xmlHandlingService, QueryFactory queryFactory) {
|
||||||
this.entityManager = entityManager;
|
this.entityManager = entityManager;
|
||||||
this.conventionService = conventionService;
|
this.conventionService = conventionService;
|
||||||
this.xmlHandlingService = xmlHandlingService;
|
this.xmlHandlingService = xmlHandlingService;
|
||||||
|
@ -55,31 +55,31 @@ public class DmpBlueprintXmlMigrationService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void migrate() throws IOException, NoSuchFieldException, IllegalAccessException, JAXBException, ParserConfigurationException, InstantiationException, SAXException, InvalidApplicationException, TransformerException {
|
public void migrate() throws IOException, NoSuchFieldException, IllegalAccessException, JAXBException, ParserConfigurationException, InstantiationException, SAXException, InvalidApplicationException, TransformerException {
|
||||||
long total = this.queryFactory.query(DmpBlueprintQuery.class).count();
|
long total = this.queryFactory.query(PlanBlueprintQuery.class).count();
|
||||||
logger.debug("Migrate DmpBlueprint Total : " + total);
|
logger.debug("Migrate PlanBlueprint Total : " + total);
|
||||||
int page = 0;
|
int page = 0;
|
||||||
|
|
||||||
List<DmpBlueprintEntity> items;
|
List<PlanBlueprintEntity> items;
|
||||||
List<DescriptionTemplateEntity> descriptionTemplateEntities = this.queryFactory.query(DescriptionTemplateQuery.class).collectAs(new BaseFieldSet().ensure(org.opencdmp.model.descriptiontemplate.DescriptionTemplate._id).ensure(org.opencdmp.model.descriptiontemplate.DescriptionTemplate._groupId));
|
List<DescriptionTemplateEntity> descriptionTemplateEntities = this.queryFactory.query(DescriptionTemplateQuery.class).collectAs(new BaseFieldSet().ensure(org.opencdmp.model.descriptiontemplate.DescriptionTemplate._id).ensure(org.opencdmp.model.descriptiontemplate.DescriptionTemplate._groupId));
|
||||||
Map<UUID, UUID> descriptionTemplateGroupMap = new HashMap<>();
|
Map<UUID, UUID> descriptionTemplateGroupMap = new HashMap<>();
|
||||||
for (DescriptionTemplateEntity descriptionTemplateEntity: descriptionTemplateEntities) {
|
for (DescriptionTemplateEntity descriptionTemplateEntity: descriptionTemplateEntities) {
|
||||||
descriptionTemplateGroupMap.put(descriptionTemplateEntity.getId(), descriptionTemplateEntity.getGroupId());
|
descriptionTemplateGroupMap.put(descriptionTemplateEntity.getId(), descriptionTemplateEntity.getGroupId());
|
||||||
}
|
}
|
||||||
do {
|
do {
|
||||||
DmpBlueprintQuery query = this.queryFactory.query(DmpBlueprintQuery.class);
|
PlanBlueprintQuery query = this.queryFactory.query(PlanBlueprintQuery.class);
|
||||||
query.setOrder(new Ordering().addDescending(DmpBlueprint._createdAt));
|
query.setOrder(new Ordering().addDescending(PlanBlueprint._createdAt));
|
||||||
query.setPage(new Paging(page * PageSize, PageSize));
|
query.setPage(new Paging(page * PageSize, PageSize));
|
||||||
items = query.collect();
|
items = query.collect();
|
||||||
|
|
||||||
if (items != null && !items.isEmpty()) {
|
if (items != null && !items.isEmpty()) {
|
||||||
|
|
||||||
logger.debug("Migrate DmpBlueprint " + page * PageSize + " of " + total);
|
logger.debug("Migrate PlanBlueprint " + page * PageSize + " of " + total);
|
||||||
|
|
||||||
for (DmpBlueprintEntity item : items) {
|
for (PlanBlueprintEntity item : items) {
|
||||||
if (this.conventionService.isNullOrEmpty(item.getDefinition())) continue;
|
if (this.conventionService.isNullOrEmpty(item.getDefinition())) continue;
|
||||||
Document document = XmlBuilder.fromXml(item.getDefinition());
|
Document document = XmlBuilder.fromXml(item.getDefinition());
|
||||||
if (document == null){
|
if (document == null){
|
||||||
logger.error("Migrate DmpBlueprint " + item.getId() + " failed read xml");
|
logger.error("Migrate PlanBlueprint " + item.getId() + " failed read xml");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,8 +94,8 @@ public class DmpBlueprintXmlMigrationService {
|
||||||
} while (items != null && !items.isEmpty() && !TestMode);
|
} while (items != null && !items.isEmpty() && !TestMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
private @NotNull org.opencdmp.commons.types.dmpblueprint.DefinitionEntity buildDefinitionEntity(DataManagementPlanBlueprint dataManagementPlanBlueprint, Map<UUID, UUID> descriptionTemplateGroupMap ) {
|
private @NotNull org.opencdmp.commons.types.planblueprint.DefinitionEntity buildDefinitionEntity(DataManagementPlanBlueprint dataManagementPlanBlueprint, Map<UUID, UUID> descriptionTemplateGroupMap ) {
|
||||||
org.opencdmp.commons.types.dmpblueprint.DefinitionEntity data = new DefinitionEntity();
|
org.opencdmp.commons.types.planblueprint.DefinitionEntity data = new DefinitionEntity();
|
||||||
if (dataManagementPlanBlueprint == null)
|
if (dataManagementPlanBlueprint == null)
|
||||||
return data;
|
return data;
|
||||||
if (!this.conventionService.isListNullOrEmpty(dataManagementPlanBlueprint.getSections())) {
|
if (!this.conventionService.isListNullOrEmpty(dataManagementPlanBlueprint.getSections())) {
|
||||||
|
@ -135,13 +135,13 @@ public class DmpBlueprintXmlMigrationService {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
private @NotNull org.opencdmp.commons.types.dmpblueprint.DescriptionTemplateEntity buildDescriptionTemplateEntity(DescriptionTemplate itm, Map<UUID, UUID> descriptionTemplateGroupMap ) {
|
private @NotNull org.opencdmp.commons.types.planblueprint.DescriptionTemplateEntity buildDescriptionTemplateEntity(DescriptionTemplate itm, Map<UUID, UUID> descriptionTemplateGroupMap ) {
|
||||||
org.opencdmp.commons.types.dmpblueprint.DescriptionTemplateEntity data = new org.opencdmp.commons.types.dmpblueprint.DescriptionTemplateEntity();
|
org.opencdmp.commons.types.planblueprint.DescriptionTemplateEntity data = new org.opencdmp.commons.types.planblueprint.DescriptionTemplateEntity();
|
||||||
if (itm == null)
|
if (itm == null)
|
||||||
return data;
|
return data;
|
||||||
UUID groupId = descriptionTemplateGroupMap.getOrDefault(itm.getDescriptionTemplateId(), null);
|
UUID groupId = descriptionTemplateGroupMap.getOrDefault(itm.getDescriptionTemplateId(), null);
|
||||||
if (groupId == null){
|
if (groupId == null){
|
||||||
logger.error("Migrate DmpBlueprint, DescriptionTemplate " + itm.getDescriptionTemplateId() + " group not found");
|
logger.error("Migrate PlanBlueprint, DescriptionTemplate " + itm.getDescriptionTemplateId() + " group not found");
|
||||||
data.setDescriptionTemplateGroupId(itm.getDescriptionTemplateId());
|
data.setDescriptionTemplateGroupId(itm.getDescriptionTemplateId());
|
||||||
} else {
|
} else {
|
||||||
data.setDescriptionTemplateGroupId(groupId);
|
data.setDescriptionTemplateGroupId(groupId);
|
||||||
|
@ -154,7 +154,7 @@ public class DmpBlueprintXmlMigrationService {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private @NotNull org.opencdmp.commons.types.dmpblueprint.FieldEntity buildFieldEntity(FieldModel itm) {
|
private @NotNull org.opencdmp.commons.types.planblueprint.FieldEntity buildFieldEntity(FieldModel itm) {
|
||||||
if (itm == null)
|
if (itm == null)
|
||||||
return new ExtraFieldEntity();
|
return new ExtraFieldEntity();
|
||||||
FieldEntity data;
|
FieldEntity data;
|
||||||
|
@ -163,26 +163,26 @@ public class DmpBlueprintXmlMigrationService {
|
||||||
ExtraField extraField = itm.toExtraField();
|
ExtraField extraField = itm.toExtraField();
|
||||||
|
|
||||||
switch (extraField.getType()){
|
switch (extraField.getType()){
|
||||||
case TEXT -> dataTyped.setType(DmpBlueprintExtraFieldDataType.Text);
|
case TEXT -> dataTyped.setType(PlanBlueprintExtraFieldDataType.Text);
|
||||||
case DATE -> dataTyped.setType(DmpBlueprintExtraFieldDataType.Date);
|
case DATE -> dataTyped.setType(PlanBlueprintExtraFieldDataType.Date);
|
||||||
case NUMBER -> dataTyped.setType(DmpBlueprintExtraFieldDataType.Number);
|
case NUMBER -> dataTyped.setType(PlanBlueprintExtraFieldDataType.Number);
|
||||||
case RICH_TEXT -> dataTyped.setType(DmpBlueprintExtraFieldDataType.RichTex);
|
case RICH_TEXT -> dataTyped.setType(PlanBlueprintExtraFieldDataType.RichTex);
|
||||||
default -> throw new MyApplicationException("Type not found " + extraField.getType());
|
default -> throw new MyApplicationException("Type not found " + extraField.getType());
|
||||||
}
|
}
|
||||||
dataTyped.setRequired(extraField.getRequired());
|
dataTyped.setRequired(extraField.getRequired());
|
||||||
data = dataTyped;
|
data = dataTyped;
|
||||||
data.setCategory(DmpBlueprintFieldCategory.Extra);
|
data.setCategory(PlanBlueprintFieldCategory.Extra);
|
||||||
} else {
|
} else {
|
||||||
SystemFieldEntity dataTyped = new SystemFieldEntity();
|
SystemFieldEntity dataTyped = new SystemFieldEntity();
|
||||||
ReferenceTypeFieldEntity referenceTypeFieldEntity = new ReferenceTypeFieldEntity();
|
ReferenceTypeFieldEntity referenceTypeFieldEntity = new ReferenceTypeFieldEntity();
|
||||||
SystemField systemField = itm.toSystemField();
|
SystemField systemField = itm.toSystemField();
|
||||||
|
|
||||||
switch (systemField.getType()){
|
switch (systemField.getType()){
|
||||||
case TEXT -> dataTyped.setType(DmpBlueprintSystemFieldType.Title);
|
case TEXT -> dataTyped.setType(PlanBlueprintSystemFieldType.Title);
|
||||||
case HTML_TEXT -> dataTyped.setType(DmpBlueprintSystemFieldType.Description);
|
case HTML_TEXT -> dataTyped.setType(PlanBlueprintSystemFieldType.Description);
|
||||||
case ACCESS_RIGHTS -> dataTyped.setType(DmpBlueprintSystemFieldType.AccessRights);
|
case ACCESS_RIGHTS -> dataTyped.setType(PlanBlueprintSystemFieldType.AccessRights);
|
||||||
case CONTACT -> dataTyped.setType(DmpBlueprintSystemFieldType.Contact);
|
case CONTACT -> dataTyped.setType(PlanBlueprintSystemFieldType.Contact);
|
||||||
case LANGUAGE -> dataTyped.setType(DmpBlueprintSystemFieldType.Language);
|
case LANGUAGE -> dataTyped.setType(PlanBlueprintSystemFieldType.Language);
|
||||||
case FUNDER -> {
|
case FUNDER -> {
|
||||||
referenceTypeFieldEntity.setReferenceTypeId(ReferenceTypeIds.Funder);
|
referenceTypeFieldEntity.setReferenceTypeId(ReferenceTypeIds.Funder);
|
||||||
referenceTypeFieldEntity.setMultipleSelect(false);
|
referenceTypeFieldEntity.setMultipleSelect(false);
|
||||||
|
@ -219,11 +219,11 @@ public class DmpBlueprintXmlMigrationService {
|
||||||
|
|
||||||
if (referenceTypeFieldEntity.getReferenceTypeId() == null){
|
if (referenceTypeFieldEntity.getReferenceTypeId() == null){
|
||||||
data = dataTyped;
|
data = dataTyped;
|
||||||
data.setCategory(DmpBlueprintFieldCategory.System);
|
data.setCategory(PlanBlueprintFieldCategory.System);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
data = referenceTypeFieldEntity;
|
data = referenceTypeFieldEntity;
|
||||||
data.setCategory(DmpBlueprintFieldCategory.ReferenceType);
|
data.setCategory(PlanBlueprintFieldCategory.ReferenceType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
data.setId(itm.getId());
|
data.setId(itm.getId());
|
|
@ -5,10 +5,10 @@ import eu.old.eudat.data.entities.DMP;
|
||||||
import org.opencdmp.commons.JsonHandlingService;
|
import org.opencdmp.commons.JsonHandlingService;
|
||||||
import org.opencdmp.commons.XmlHandlingService;
|
import org.opencdmp.commons.XmlHandlingService;
|
||||||
import org.opencdmp.commons.enums.IsActive;
|
import org.opencdmp.commons.enums.IsActive;
|
||||||
import org.opencdmp.data.DmpBlueprintEntity;
|
import org.opencdmp.data.PlanBlueprintEntity;
|
||||||
import org.opencdmp.data.DmpDescriptionTemplateEntity;
|
import org.opencdmp.data.PlanDescriptionTemplateEntity;
|
||||||
import org.opencdmp.query.DmpBlueprintQuery;
|
import org.opencdmp.query.PlanBlueprintQuery;
|
||||||
import org.opencdmp.query.DmpDescriptionTemplateQuery;
|
import org.opencdmp.query.PlanDescriptionTemplateQuery;
|
||||||
import eu.old.eudat.data.dao.entities.DmpDatasetProfileDao;
|
import eu.old.eudat.data.dao.entities.DmpDatasetProfileDao;
|
||||||
import eu.old.eudat.data.entities.DMPDatasetProfile;
|
import eu.old.eudat.data.entities.DMPDatasetProfile;
|
||||||
import eu.old.eudat.logic.services.operations.DatabaseRepository;
|
import eu.old.eudat.logic.services.operations.DatabaseRepository;
|
||||||
|
@ -25,18 +25,17 @@ import jakarta.xml.bind.JAXBException;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
import org.opencdmp.commons.types.dmpblueprint.DefinitionEntity;
|
import org.opencdmp.commons.types.planblueprint.DefinitionEntity;
|
||||||
|
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.security.SecureRandom;
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class DmpDatasetProfileMigrationService {
|
public class PlanDatasetProfileMigrationService {
|
||||||
|
|
||||||
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpDatasetProfileMigrationService.class));
|
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PlanDatasetProfileMigrationService.class));
|
||||||
private final DatabaseRepository databaseRepository;
|
private final DatabaseRepository databaseRepository;
|
||||||
|
|
||||||
private final JsonHandlingService jsonHandlingService;
|
private final JsonHandlingService jsonHandlingService;
|
||||||
|
@ -46,7 +45,7 @@ public class DmpDatasetProfileMigrationService {
|
||||||
private static final boolean TestMode = false;
|
private static final boolean TestMode = false;
|
||||||
private final EntityManager entityManager;
|
private final EntityManager entityManager;
|
||||||
|
|
||||||
public DmpDatasetProfileMigrationService(DatabaseRepository databaseRepository, JsonHandlingService jsonHandlingService, QueryFactory queryFactory, XmlHandlingService xmlHandlingService, EntityManager entityManager) {
|
public PlanDatasetProfileMigrationService(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.queryFactory = queryFactory;
|
||||||
|
@ -57,18 +56,18 @@ public class DmpDatasetProfileMigrationService {
|
||||||
public void migrate() throws IOException, JAXBException, ParserConfigurationException, InstantiationException, IllegalAccessException, SAXException {
|
public void migrate() throws IOException, JAXBException, ParserConfigurationException, InstantiationException, IllegalAccessException, SAXException {
|
||||||
DmpDatasetProfileDao dmpDatasetProfileDao = databaseRepository.getDmpDatasetProfileDao();
|
DmpDatasetProfileDao dmpDatasetProfileDao = databaseRepository.getDmpDatasetProfileDao();
|
||||||
long total = dmpDatasetProfileDao.asQueryable().count();
|
long total = dmpDatasetProfileDao.asQueryable().count();
|
||||||
logger.debug("Migrate DmpDatasetProfile Total : " + total);
|
logger.debug("Migrate PlanDatasetProfile Total : " + total);
|
||||||
int page = 0;
|
int page = 0;
|
||||||
|
|
||||||
List<DMPDatasetProfile> items;
|
List<DMPDatasetProfile> items;
|
||||||
do {
|
do {
|
||||||
items = dmpDatasetProfileDao.asQueryable().orderBy((builder, root) -> builder.asc(root.get("ID"))).skip(page * PageSize).take(PageSize).toList();
|
items = dmpDatasetProfileDao.asQueryable().orderBy((builder, root) -> builder.asc(root.get("ID"))).skip(page * PageSize).take(PageSize).toList();
|
||||||
if (items != null && !items.isEmpty()) {
|
if (items != null && !items.isEmpty()) {
|
||||||
logger.debug("Migrate DmpDatasetProfile " + page * PageSize + " of " + total);
|
logger.debug("Migrate PlanDatasetProfile " + page * PageSize + " of " + total);
|
||||||
|
|
||||||
List<DmpBlueprintEntity> dmpBlueprints = this.queryFactory.query(DmpBlueprintQuery.class).ids(items.stream().map(x-> x.getDmp().getProfile().getId()).distinct().toList()).collect();
|
List<PlanBlueprintEntity> dmpBlueprints = this.queryFactory.query(PlanBlueprintQuery.class).ids(items.stream().map(x-> x.getDmp().getProfile().getId()).distinct().toList()).collect();
|
||||||
Map<UUID, DefinitionEntity> dmpBlueprintsMap = new HashMap<>();
|
Map<UUID, DefinitionEntity> dmpBlueprintsMap = new HashMap<>();
|
||||||
for (DmpBlueprintEntity dmpBlueprint : dmpBlueprints) {
|
for (PlanBlueprintEntity dmpBlueprint : dmpBlueprints) {
|
||||||
DefinitionEntity definitionEntity = this.xmlHandlingService.fromXml(DefinitionEntity.class, dmpBlueprint.getDefinition());
|
DefinitionEntity definitionEntity = this.xmlHandlingService.fromXml(DefinitionEntity.class, dmpBlueprint.getDefinition());
|
||||||
dmpBlueprintsMap.put(dmpBlueprint.getId(), definitionEntity);
|
dmpBlueprintsMap.put(dmpBlueprint.getId(), definitionEntity);
|
||||||
}
|
}
|
||||||
|
@ -76,35 +75,35 @@ public class DmpDatasetProfileMigrationService {
|
||||||
for (DMPDatasetProfile item : items) {
|
for (DMPDatasetProfile item : items) {
|
||||||
entityManager.detach(item);
|
entityManager.detach(item);
|
||||||
|
|
||||||
DmpDatasetProfileData profileData = jsonHandlingService.fromJson(DmpDatasetProfileData.class, item.getData());
|
PlanDatasetProfileData profileData = jsonHandlingService.fromJson(PlanDatasetProfileData.class, item.getData());
|
||||||
|
|
||||||
if (profileData == null || profileData.dmpSectionIndex == null || profileData.dmpSectionIndex.isEmpty()){
|
if (profileData == null || profileData.dmpSectionIndex == null || profileData.dmpSectionIndex.isEmpty()){
|
||||||
if (profileData != null && item.getDmp() != null && item.getDmp().getProfile() != null && item.getDmp().getProfile().getId() != null && item.getDmp().getProfile().getId().equals(UUID.fromString("86635178-36a6-484f-9057-a934e4eeecd5"))){
|
if (profileData != null && item.getDmp() != null && item.getDmp().getProfile() != null && item.getDmp().getProfile().getId() != null && item.getDmp().getProfile().getId().equals(UUID.fromString("86635178-36a6-484f-9057-a934e4eeecd5"))){
|
||||||
profileData.dmpSectionIndex = new ArrayList<>();
|
profileData.dmpSectionIndex = new ArrayList<>();
|
||||||
profileData.dmpSectionIndex.add(3);
|
profileData.dmpSectionIndex.add(3);
|
||||||
logger.warn("Migrate DmpDatasetProfile " + item.getId() + " failed no section info set to 3");
|
logger.warn("Migrate PlanDatasetProfile " + item.getId() + " failed no section info set to 3");
|
||||||
} else {
|
} else {
|
||||||
throw new MyApplicationException("Migrate DmpDatasetProfile " + item.getId() + " failed no section info ");
|
throw new MyApplicationException("Migrate PlanDatasetProfile " + item.getId() + " failed no section info ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DefinitionEntity definition = dmpBlueprintsMap.getOrDefault(item.getDmp().getProfile().getId(), null);
|
DefinitionEntity definition = dmpBlueprintsMap.getOrDefault(item.getDmp().getProfile().getId(), null);
|
||||||
if (definition == null){
|
if (definition == null){
|
||||||
throw new MyApplicationException("Migrate DmpDatasetProfile " + item.getId() + " failed blueprint definition not found for blueprint " + item.getDmp().getProfile().getId());
|
throw new MyApplicationException("Migrate PlanDatasetProfile " + item.getId() + " failed blueprint definition not found for blueprint " + item.getDmp().getProfile().getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int sectionIndex: profileData.dmpSectionIndex) {
|
for (int sectionIndex: profileData.dmpSectionIndex) {
|
||||||
if (definition.getSections() == null || definition.getSections().size() <= sectionIndex) {
|
if (definition.getSections() == null || definition.getSections().size() <= sectionIndex) {
|
||||||
throw new MyApplicationException("Migrate DmpDatasetProfile " + item.getId() + " cannot found section id for section " + sectionIndex);
|
throw new MyApplicationException("Migrate PlanDatasetProfile " + item.getId() + " cannot found section id for section " + sectionIndex);
|
||||||
}
|
}
|
||||||
UUID sectionId = definition.getSections().get(sectionIndex).getId();
|
UUID sectionId = definition.getSections().get(sectionIndex).getId();
|
||||||
if (sectionId == null) {
|
if (sectionId == null) {
|
||||||
throw new MyApplicationException("Migrate DmpDatasetProfile " + item.getId() + " cannot found section id for section " + sectionIndex);
|
throw new MyApplicationException("Migrate PlanDatasetProfile " + item.getId() + " cannot found section id for section " + sectionIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
DmpDescriptionTemplateEntity data = new DmpDescriptionTemplateEntity();
|
PlanDescriptionTemplateEntity data = new PlanDescriptionTemplateEntity();
|
||||||
data.setId(UUID.randomUUID());
|
data.setId(UUID.randomUUID());
|
||||||
data.setDescriptionTemplateGroupId(item.getDatasetprofile().getGroupId());
|
data.setDescriptionTemplateGroupId(item.getDatasetprofile().getGroupId());
|
||||||
data.setDmpId(getDmp(item).getId());
|
data.setPlanId(getPlan(item).getId());
|
||||||
data.setCreatedAt(item.getDmp().getCreated() != null ? item.getDmp().getCreated().toInstant() : Instant.now());
|
data.setCreatedAt(item.getDmp().getCreated() != null ? item.getDmp().getCreated().toInstant() : Instant.now());
|
||||||
data.setUpdatedAt(item.getDmp().getModified() != null ? item.getDmp().getModified().toInstant() : Instant.now());
|
data.setUpdatedAt(item.getDmp().getModified() != null ? item.getDmp().getModified().toInstant() : Instant.now());
|
||||||
data.setSectionId(sectionId);
|
data.setSectionId(sectionId);
|
||||||
|
@ -121,37 +120,37 @@ public class DmpDatasetProfileMigrationService {
|
||||||
removeDuplicates();
|
removeDuplicates();
|
||||||
}
|
}
|
||||||
|
|
||||||
private DMP getDmp(DMPDatasetProfile item) {
|
private DMP getPlan(DMPDatasetProfile item) {
|
||||||
return item.getDmp();
|
return item.getDmp();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeDuplicates() {
|
private void removeDuplicates() {
|
||||||
logger.debug("Checking for duplicates on DmpDescriptionTemplate table after migration");
|
logger.debug("Checking for duplicates on PlanDescriptionTemplate table after migration");
|
||||||
|
|
||||||
DmpDescriptionTemplateQuery dmpDescriptionTemplateQuery = this.queryFactory.query(DmpDescriptionTemplateQuery.class);
|
PlanDescriptionTemplateQuery dmpDescriptionTemplateQuery = this.queryFactory.query(PlanDescriptionTemplateQuery.class);
|
||||||
long total = dmpDescriptionTemplateQuery.count();
|
long total = dmpDescriptionTemplateQuery.count();
|
||||||
logger.debug("Record count to check: {}", total);
|
logger.debug("Record count to check: {}", total);
|
||||||
|
|
||||||
CriteriaBuilder b = this.entityManager.getCriteriaBuilder();
|
CriteriaBuilder b = this.entityManager.getCriteriaBuilder();
|
||||||
CriteriaQuery<Tuple> criteria = b.createQuery(Tuple.class);
|
CriteriaQuery<Tuple> criteria = b.createQuery(Tuple.class);
|
||||||
Root<DmpDescriptionTemplateEntity> root = criteria.from(DmpDescriptionTemplateEntity.class);
|
Root<PlanDescriptionTemplateEntity> root = criteria.from(PlanDescriptionTemplateEntity.class);
|
||||||
criteria.groupBy(Arrays.asList(root.get(DmpDescriptionTemplateEntity._dmpId), root.get(DmpDescriptionTemplateEntity._descriptionTemplateGroupId), root.get(DmpDescriptionTemplateEntity._sectionId)));
|
criteria.groupBy(Arrays.asList(root.get(PlanDescriptionTemplateEntity._planId), root.get(PlanDescriptionTemplateEntity._descriptionTemplateGroupId), root.get(PlanDescriptionTemplateEntity._sectionId)));
|
||||||
criteria.multiselect(root.get(DmpDescriptionTemplateEntity._dmpId), root.get(DmpDescriptionTemplateEntity._descriptionTemplateGroupId), root.get(DmpDescriptionTemplateEntity._sectionId), b.count(root));
|
criteria.multiselect(root.get(PlanDescriptionTemplateEntity._planId), root.get(PlanDescriptionTemplateEntity._descriptionTemplateGroupId), root.get(PlanDescriptionTemplateEntity._sectionId), b.count(root));
|
||||||
List<Tuple> resultList = this.entityManager.createQuery(criteria).getResultList();
|
List<Tuple> resultList = this.entityManager.createQuery(criteria).getResultList();
|
||||||
|
|
||||||
List<Tuple> duplicatesList = resultList.stream().filter(x -> (long) x.get(3) > 1).toList();
|
List<Tuple> duplicatesList = resultList.stream().filter(x -> (long) x.get(3) > 1).toList();
|
||||||
CriteriaDelete<DmpDescriptionTemplateEntity> delete = b.createCriteriaDelete(DmpDescriptionTemplateEntity.class);
|
CriteriaDelete<PlanDescriptionTemplateEntity> delete = b.createCriteriaDelete(PlanDescriptionTemplateEntity.class);
|
||||||
Root<DmpDescriptionTemplateEntity> root1 = delete.from(DmpDescriptionTemplateEntity.class);
|
Root<PlanDescriptionTemplateEntity> root1 = delete.from(PlanDescriptionTemplateEntity.class);
|
||||||
for (Tuple duplicate : duplicatesList) {
|
for (Tuple duplicate : duplicatesList) {
|
||||||
List<DmpDescriptionTemplateEntity> duplicateEntities = dmpDescriptionTemplateQuery
|
List<PlanDescriptionTemplateEntity> duplicateEntities = dmpDescriptionTemplateQuery
|
||||||
.dmpIds((UUID) duplicate.get(0))
|
.planIds((UUID) duplicate.get(0))
|
||||||
.descriptionTemplateGroupIds((UUID) duplicate.get(1))
|
.descriptionTemplateGroupIds((UUID) duplicate.get(1))
|
||||||
.sectionIds((UUID) duplicate.get(2))
|
.sectionIds((UUID) duplicate.get(2))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
List<UUID> toDelete = new ArrayList<>(duplicateEntities.stream().map(DmpDescriptionTemplateEntity::getId).toList());
|
List<UUID> toDelete = new ArrayList<>(duplicateEntities.stream().map(PlanDescriptionTemplateEntity::getId).toList());
|
||||||
toDelete.remove(0);
|
toDelete.removeFirst();
|
||||||
delete.where(root1.get(DmpDescriptionTemplateEntity._id).in(toDelete));
|
delete.where(root1.get(PlanDescriptionTemplateEntity._id).in(toDelete));
|
||||||
this.entityManager.createQuery(delete).executeUpdate();
|
this.entityManager.createQuery(delete).executeUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,7 +158,7 @@ public class DmpDatasetProfileMigrationService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonIgnoreProperties({"validationErrorModel"})
|
@JsonIgnoreProperties({"validationErrorModel"})
|
||||||
public static class DmpDatasetProfileData {
|
public static class PlanDatasetProfileData {
|
||||||
|
|
||||||
private List<Integer> dmpSectionIndex;
|
private List<Integer> dmpSectionIndex;
|
||||||
|
|
||||||
|
@ -170,7 +169,6 @@ public class DmpDatasetProfileMigrationService {
|
||||||
public void setDmpSectionIndex(List<Integer> dmpSectionIndex) {
|
public void setDmpSectionIndex(List<Integer> dmpSectionIndex) {
|
||||||
this.dmpSectionIndex = dmpSectionIndex;
|
this.dmpSectionIndex = dmpSectionIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -2,25 +2,22 @@ package eu.old.eudat.migration;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import eu.old.eudat.data.dao.entities.UserInfoDao;
|
import eu.old.eudat.data.dao.entities.UserInfoDao;
|
||||||
import org.opencdmp.commonmodels.models.dmp.DmpModel;
|
|
||||||
import org.opencdmp.commonmodels.models.dmpblueprint.SectionModel;
|
|
||||||
import org.opencdmp.commons.JsonHandlingService;
|
import org.opencdmp.commons.JsonHandlingService;
|
||||||
import org.opencdmp.commons.XmlHandlingService;
|
import org.opencdmp.commons.XmlHandlingService;
|
||||||
import org.opencdmp.commons.enums.*;
|
import org.opencdmp.commons.enums.*;
|
||||||
import org.opencdmp.commons.types.dmp.DmpBlueprintValueEntity;
|
import org.opencdmp.commons.types.plan.PlanBlueprintValueEntity;
|
||||||
import org.opencdmp.commons.types.dmp.DmpContactEntity;
|
import org.opencdmp.commons.types.plan.PlanContactEntity;
|
||||||
import org.opencdmp.commons.types.dmp.DmpPropertiesEntity;
|
import org.opencdmp.commons.types.plan.PlanPropertiesEntity;
|
||||||
import org.opencdmp.commons.types.dmpblueprint.ExtraFieldEntity;
|
import org.opencdmp.commons.types.planblueprint.ExtraFieldEntity;
|
||||||
import org.opencdmp.commons.types.dmpblueprint.ReferenceTypeFieldEntity;
|
import org.opencdmp.commons.types.planblueprint.ReferenceTypeFieldEntity;
|
||||||
import org.opencdmp.commons.types.dmpblueprint.SectionEntity;
|
import org.opencdmp.commons.types.planblueprint.SectionEntity;
|
||||||
import org.opencdmp.commons.types.dmpreference.DmpReferenceDataEntity;
|
import org.opencdmp.commons.types.planreference.PlanReferenceDataEntity;
|
||||||
import org.opencdmp.commons.types.reference.DefinitionEntity;
|
import org.opencdmp.commons.types.reference.DefinitionEntity;
|
||||||
import org.opencdmp.commons.types.reference.FieldEntity;
|
import org.opencdmp.commons.types.reference.FieldEntity;
|
||||||
import org.opencdmp.convention.ConventionService;
|
import org.opencdmp.convention.ConventionService;
|
||||||
import org.opencdmp.data.*;
|
import org.opencdmp.data.*;
|
||||||
import org.opencdmp.model.dmp.DmpBlueprintValue;
|
import org.opencdmp.model.planblueprint.PlanBlueprint;
|
||||||
import org.opencdmp.model.dmpblueprint.DmpBlueprint;
|
import org.opencdmp.query.PlanBlueprintQuery;
|
||||||
import org.opencdmp.query.DmpBlueprintQuery;
|
|
||||||
import eu.old.eudat.data.dao.entities.DMPDao;
|
import eu.old.eudat.data.dao.entities.DMPDao;
|
||||||
import eu.old.eudat.data.entities.*;
|
import eu.old.eudat.data.entities.*;
|
||||||
import eu.old.eudat.logic.services.operations.DatabaseRepository;
|
import eu.old.eudat.logic.services.operations.DatabaseRepository;
|
||||||
|
@ -46,9 +43,9 @@ import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class DmpMigrationService {
|
public class PlanMigrationService {
|
||||||
|
|
||||||
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpMigrationService.class));
|
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PlanMigrationService.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;
|
||||||
|
@ -60,7 +57,7 @@ public class DmpMigrationService {
|
||||||
private static final int PageSize = 500;
|
private static final int PageSize = 500;
|
||||||
private static final boolean TestMode = false;
|
private static final boolean TestMode = false;
|
||||||
|
|
||||||
public DmpMigrationService(DatabaseRepository databaseRepository, JsonHandlingService jsonHandlingService, EntityManager entityManager, ConventionService conventionService, XmlHandlingService xmlHandlingService, Environment environment, QueryFactory queryFactory) {
|
public PlanMigrationService(DatabaseRepository databaseRepository, JsonHandlingService jsonHandlingService, EntityManager entityManager, ConventionService conventionService, XmlHandlingService xmlHandlingService, Environment environment, QueryFactory queryFactory) {
|
||||||
this.databaseRepository = databaseRepository;
|
this.databaseRepository = databaseRepository;
|
||||||
this.jsonHandlingService = jsonHandlingService;
|
this.jsonHandlingService = jsonHandlingService;
|
||||||
this.entityManager = entityManager;
|
this.entityManager = entityManager;
|
||||||
|
@ -74,7 +71,7 @@ public class DmpMigrationService {
|
||||||
UserInfoDao userInfoDao = databaseRepository.getUserInfoDao();
|
UserInfoDao userInfoDao = databaseRepository.getUserInfoDao();
|
||||||
DMPDao dmpDao = databaseRepository.getDmpDao();
|
DMPDao dmpDao = databaseRepository.getDmpDao();
|
||||||
long total = dmpDao.asQueryable().count();
|
long total = dmpDao.asQueryable().count();
|
||||||
logger.debug("Migrate Dmp Total : " + total);
|
logger.debug("Migrate Plan Total : " + total);
|
||||||
int page = 0;
|
int page = 0;
|
||||||
|
|
||||||
Map<String, UUID> licenseIdByName = new HashMap<>();
|
Map<String, UUID> licenseIdByName = new HashMap<>();
|
||||||
|
@ -82,54 +79,54 @@ public class DmpMigrationService {
|
||||||
do {
|
do {
|
||||||
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();
|
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();
|
||||||
List<DMP> finalItems = items;
|
List<DMP> finalItems = items;
|
||||||
List<DMP> groupDmps = dmpDao.asQueryable().where((builder, root) -> root.get("groupId").in(finalItems.stream().map(DMP::getGroupId).distinct().collect(Collectors.toList()))).toList();
|
List<DMP> groupPlans = dmpDao.asQueryable().where((builder, root) -> root.get("groupId").in(finalItems.stream().map(DMP::getGroupId).distinct().collect(Collectors.toList()))).toList();
|
||||||
Map<UUID, List<DMP>> groupDmpMap = new HashMap<>();
|
Map<UUID, List<DMP>> groupPlanMap = new HashMap<>();
|
||||||
for (DMP dmp: groupDmps) {
|
for (DMP dmp: groupPlans) {
|
||||||
if (!groupDmpMap.containsKey(dmp.getGroupId())) groupDmpMap.put(dmp.getGroupId(), new ArrayList<>());
|
if (!groupPlanMap.containsKey(dmp.getGroupId())) groupPlanMap.put(dmp.getGroupId(), new ArrayList<>());
|
||||||
groupDmpMap.get(dmp.getGroupId()).add(dmp);
|
groupPlanMap.get(dmp.getGroupId()).add(dmp);
|
||||||
}
|
}
|
||||||
Map<UUID, UserInfo> oldUsers = userInfoDao.asQueryable().toList().stream().collect(Collectors.toMap(UserInfo::getId, x-> x));
|
Map<UUID, UserInfo> oldUsers = userInfoDao.asQueryable().toList().stream().collect(Collectors.toMap(UserInfo::getId, x-> x));
|
||||||
|
|
||||||
if (items != null && !items.isEmpty()) {
|
if (items != null && !items.isEmpty()) {
|
||||||
|
|
||||||
logger.debug("Migrate Dmp " + page * PageSize + " of " + total);
|
logger.debug("Migrate Plan " + page * PageSize + " of " + total);
|
||||||
List<DmpBlueprintEntity> dmpBlueprintEntities = this.queryFactory.query(DmpBlueprintQuery.class).ids(items.stream().filter(x-> x.getProfile() != null).map(x-> x.getProfile().getId()).distinct().collect(Collectors.toList())).collectAs(new BaseFieldSet().ensure(DmpBlueprint._definition).ensure(DmpBlueprint._id));
|
List<PlanBlueprintEntity> dmpBlueprintEntities = this.queryFactory.query(PlanBlueprintQuery.class).ids(items.stream().filter(x-> x.getProfile() != null).map(x-> x.getProfile().getId()).distinct().collect(Collectors.toList())).collectAs(new BaseFieldSet().ensure(PlanBlueprint._definition).ensure(PlanBlueprint._id));
|
||||||
Map<UUID, org.opencdmp.commons.types.dmpblueprint.DefinitionEntity> blueprintDefinitionMap = new HashMap<>();
|
Map<UUID, org.opencdmp.commons.types.planblueprint.DefinitionEntity> blueprintDefinitionMap = new HashMap<>();
|
||||||
Map<UUID, List<ReferenceTypeFieldEntity>> referenceTypeFieldsByDmpBlueprintId = new HashMap<>();
|
Map<UUID, List<ReferenceTypeFieldEntity>> referenceTypeFieldsByPlanBlueprintId = new HashMap<>();
|
||||||
for (DmpBlueprintEntity dmpBlueprintEntity : dmpBlueprintEntities) {
|
for (PlanBlueprintEntity dmpBlueprintEntity : dmpBlueprintEntities) {
|
||||||
org.opencdmp.commons.types.dmpblueprint.DefinitionEntity definition = this.xmlHandlingService.fromXml(org.opencdmp.commons.types.dmpblueprint.DefinitionEntity.class, dmpBlueprintEntity.getDefinition());
|
org.opencdmp.commons.types.planblueprint.DefinitionEntity definition = this.xmlHandlingService.fromXml(org.opencdmp.commons.types.planblueprint.DefinitionEntity.class, dmpBlueprintEntity.getDefinition());
|
||||||
blueprintDefinitionMap.put(dmpBlueprintEntity.getId(), definition);
|
blueprintDefinitionMap.put(dmpBlueprintEntity.getId(), definition);
|
||||||
List<ReferenceTypeFieldEntity> referenceTypeFieldEntities = definition.getSections().stream().filter(x-> x.getFields() != null).map(SectionEntity::getFields).flatMap(List::stream).filter(x-> x.getCategory().equals(DmpBlueprintFieldCategory.ReferenceType)).map(x-> (ReferenceTypeFieldEntity)x)
|
List<ReferenceTypeFieldEntity> referenceTypeFieldEntities = definition.getSections().stream().filter(x-> x.getFields() != null).map(SectionEntity::getFields).flatMap(List::stream).filter(x-> x.getCategory().equals(PlanBlueprintFieldCategory.ReferenceType)).map(x-> (ReferenceTypeFieldEntity)x)
|
||||||
.filter(x-> x.getReferenceTypeId().equals(ReferenceTypeIds.License) || x.getReferenceTypeId().equals(ReferenceTypeIds.Project) || x.getReferenceTypeId().equals(ReferenceTypeIds.Researcher)
|
.filter(x-> x.getReferenceTypeId().equals(ReferenceTypeIds.License) || x.getReferenceTypeId().equals(ReferenceTypeIds.Project) || x.getReferenceTypeId().equals(ReferenceTypeIds.Researcher)
|
||||||
|| x.getReferenceTypeId().equals(ReferenceTypeIds.Grants) || x.getReferenceTypeId().equals(ReferenceTypeIds.Organizations) || x.getReferenceTypeId().equals(ReferenceTypeIds.Funder))
|
|| x.getReferenceTypeId().equals(ReferenceTypeIds.Grants) || x.getReferenceTypeId().equals(ReferenceTypeIds.Organizations) || x.getReferenceTypeId().equals(ReferenceTypeIds.Funder))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
referenceTypeFieldsByDmpBlueprintId.put(dmpBlueprintEntity.getId() , referenceTypeFieldEntities);
|
referenceTypeFieldsByPlanBlueprintId.put(dmpBlueprintEntity.getId() , referenceTypeFieldEntities);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (DMP item : items) {
|
for (DMP item : items) {
|
||||||
//entityManager.detach(item);
|
//entityManager.detach(item);
|
||||||
org.opencdmp.commons.types.dmpblueprint.DefinitionEntity definitionEntity = blueprintDefinitionMap.get(item.getProfile().getId());
|
org.opencdmp.commons.types.planblueprint.DefinitionEntity definitionEntity = blueprintDefinitionMap.get(item.getProfile().getId());
|
||||||
DataManagementPlan model = new DataManagementPlan();
|
DataManagementPlan model = new DataManagementPlan();
|
||||||
model.fromDataModel(item);
|
model.fromDataModel(item);
|
||||||
List<DMP> itemGroupDmps = groupDmpMap.get(item.getGroupId());
|
List<DMP> itemGroupPlans = groupPlanMap.get(item.getGroupId());
|
||||||
DMP currentVersionDmp = itemGroupDmps.stream().filter(x-> DmpStatus.Finalized.getValue().equals(x.getStatus())).max(Comparator.comparing(DMP::getVersion)).orElse(null);
|
DMP currentVersionPlan = itemGroupPlans.stream().filter(x-> PlanStatus.Finalized.getValue().equals(x.getStatus())).max(Comparator.comparing(DMP::getVersion)).orElse(null);
|
||||||
|
|
||||||
DmpPropertiesEntity dmpProperties = new DmpPropertiesEntity();
|
PlanPropertiesEntity dmpProperties = new PlanPropertiesEntity();
|
||||||
dmpProperties.setDmpBlueprintValues(new ArrayList<>());
|
dmpProperties.setPlanBlueprintValues(new ArrayList<>());
|
||||||
dmpProperties.setContacts(new ArrayList<>());
|
dmpProperties.setContacts(new ArrayList<>());
|
||||||
|
|
||||||
DmpEntity data = new DmpEntity();
|
PlanEntity data = new PlanEntity();
|
||||||
data.setId(model.getId());
|
data.setId(model.getId());
|
||||||
data.setLabel(model.getLabel());
|
data.setLabel(model.getLabel());
|
||||||
data.setDescription(model.getDescription());
|
data.setDescription(model.getDescription());
|
||||||
if (model.getCreator() != null && model.getCreator().getId() != null) {
|
if (model.getCreator() != null && model.getCreator().getId() != null) {
|
||||||
data.setCreatorId(model.getCreator().getId());
|
data.setCreatorId(model.getCreator().getId());
|
||||||
} else {
|
} else {
|
||||||
for (DMP groupDmp: itemGroupDmps) {
|
for (DMP groupPlan: itemGroupPlans) {
|
||||||
DataManagementPlan groupDmpModel = new DataManagementPlan();
|
DataManagementPlan groupPlanModel = new DataManagementPlan();
|
||||||
groupDmpModel.fromDataModel(groupDmp);
|
groupPlanModel.fromDataModel(groupPlan);
|
||||||
if (groupDmpModel.getCreator() != null) {
|
if (groupPlanModel.getCreator() != null) {
|
||||||
data.setCreatorId(groupDmpModel.getCreator().getId());
|
data.setCreatorId(groupPlanModel.getCreator().getId());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -139,14 +136,14 @@ public class DmpMigrationService {
|
||||||
}
|
}
|
||||||
data.setGroupId(model.getGroupId());
|
data.setGroupId(model.getGroupId());
|
||||||
data.setVersion((short) model.getVersion());
|
data.setVersion((short) model.getVersion());
|
||||||
if (currentVersionDmp != null && currentVersionDmp.getId().equals(item.getId())){
|
if (currentVersionPlan != null && currentVersionPlan.getId().equals(item.getId())){
|
||||||
data.setVersionStatus(DmpVersionStatus.Current);
|
data.setVersionStatus(PlanVersionStatus.Current);
|
||||||
} else {
|
} else {
|
||||||
if (DmpStatus.Finalized.getValue().equals(item.getStatus())){
|
if (PlanStatus.Finalized.getValue().equals(item.getStatus())){
|
||||||
if (currentVersionDmp == null) throw new MyApplicationException("Found Finalized Dmp out of the group ");
|
if (currentVersionPlan == null) throw new MyApplicationException("Found Finalized Plan out of the group ");
|
||||||
data.setVersionStatus(DmpVersionStatus.Previous);
|
data.setVersionStatus(PlanVersionStatus.Previous);
|
||||||
} else {
|
} else {
|
||||||
data.setVersionStatus(DmpVersionStatus.NotFinalized);
|
data.setVersionStatus(PlanVersionStatus.NotFinalized);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (model.getCreated() != null)
|
if (model.getCreated() != null)
|
||||||
|
@ -160,16 +157,16 @@ public class DmpMigrationService {
|
||||||
if (model.getExtraProperties().containsKey("language") && model.getExtraProperties().get("language") != null)
|
if (model.getExtraProperties().containsKey("language") && model.getExtraProperties().get("language") != null)
|
||||||
data.setLanguage((String) model.getExtraProperties().get("language"));
|
data.setLanguage((String) model.getExtraProperties().get("language"));
|
||||||
if (model.getExtraProperties().containsKey("visible") && model.getExtraProperties().get("visible") != null)
|
if (model.getExtraProperties().containsKey("visible") && model.getExtraProperties().get("visible") != null)
|
||||||
data.setAccessType((boolean) model.getExtraProperties().get("visible") ? DmpAccessType.Public : DmpAccessType.Restricted);
|
data.setAccessType((boolean) model.getExtraProperties().get("visible") ? PlanAccessType.Public : PlanAccessType.Restricted);
|
||||||
if (model.getExtraProperties().containsKey("contact") && model.getExtraProperties().get("contact") != null) {
|
if (model.getExtraProperties().containsKey("contact") && model.getExtraProperties().get("contact") != null) {
|
||||||
UserInfo userInfo = oldUsers.getOrDefault(UUID.fromString((String)model.getExtraProperties().get("contact")), null);
|
UserInfo userInfo = oldUsers.getOrDefault(UUID.fromString((String)model.getExtraProperties().get("contact")), null);
|
||||||
if (userInfo != null) {
|
if (userInfo != null) {
|
||||||
DmpContactEntity contactEntity = new DmpContactEntity();
|
PlanContactEntity contactEntity = new PlanContactEntity();
|
||||||
contactEntity.setEmail(userInfo.getEmail());
|
contactEntity.setEmail(userInfo.getEmail());
|
||||||
contactEntity.setFirstName(userInfo.getName());
|
contactEntity.setFirstName(userInfo.getName());
|
||||||
dmpProperties.getContacts().add(contactEntity);
|
dmpProperties.getContacts().add(contactEntity);
|
||||||
} else {
|
} else {
|
||||||
throw new MyApplicationException("Contact not found " + UUID.fromString((String)model.getExtraProperties().get("contact")) + " Dmp " + item.getId());
|
throw new MyApplicationException("Contact not found " + UUID.fromString((String)model.getExtraProperties().get("contact")) + " Plan " + item.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -183,10 +180,10 @@ public class DmpMigrationService {
|
||||||
}
|
}
|
||||||
if (model.getProperties() != null) {
|
if (model.getProperties() != null) {
|
||||||
model.getProperties().forEach((key,val) -> {
|
model.getProperties().forEach((key,val) -> {
|
||||||
DmpBlueprintValueEntity valueEntity = new DmpBlueprintValueEntity();
|
PlanBlueprintValueEntity valueEntity = new PlanBlueprintValueEntity();
|
||||||
valueEntity.setFieldId(UUID.fromString(key));
|
valueEntity.setFieldId(UUID.fromString(key));
|
||||||
org.opencdmp.commons.types.dmpblueprint.FieldEntity fieldEntity = this.getFieldOfId(definitionEntity, valueEntity.getFieldId());
|
org.opencdmp.commons.types.planblueprint.FieldEntity fieldEntity = this.getFieldOfId(definitionEntity, valueEntity.getFieldId());
|
||||||
if (fieldEntity != null && val != null && fieldEntity.getCategory().equals(DmpBlueprintFieldCategory.Extra)){
|
if (fieldEntity != null && val != null && fieldEntity.getCategory().equals(PlanBlueprintFieldCategory.Extra)){
|
||||||
ExtraFieldEntity extraFieldEntity = (ExtraFieldEntity) fieldEntity;
|
ExtraFieldEntity extraFieldEntity = (ExtraFieldEntity) fieldEntity;
|
||||||
switch (extraFieldEntity.getType()){
|
switch (extraFieldEntity.getType()){
|
||||||
case Date -> {
|
case Date -> {
|
||||||
|
@ -204,23 +201,23 @@ public class DmpMigrationService {
|
||||||
} else {
|
} else {
|
||||||
valueEntity.setValue((String) val);
|
valueEntity.setValue((String) val);
|
||||||
}
|
}
|
||||||
dmpProperties.getDmpBlueprintValues().add(valueEntity);
|
dmpProperties.getPlanBlueprintValues().add(valueEntity);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (model.getStatus() == 99) {
|
if (model.getStatus() == 99) {
|
||||||
data.setIsActive(IsActive.Inactive);
|
data.setIsActive(IsActive.Inactive);
|
||||||
data.setStatus(DmpStatus.Draft);
|
data.setStatus(PlanStatus.Draft);
|
||||||
} else {
|
} else {
|
||||||
data.setIsActive(IsActive.Active);
|
data.setIsActive(IsActive.Active);
|
||||||
data.setStatus(DmpStatus.of((short) model.getStatus()));
|
data.setStatus(PlanStatus.of((short) model.getStatus()));
|
||||||
}
|
}
|
||||||
data.setProperties(jsonHandlingService.toJson(dmpProperties));
|
data.setProperties(jsonHandlingService.toJson(dmpProperties));
|
||||||
|
|
||||||
if (data.getAccessType() == null && item.getStatus().equals(DmpStatus.Finalized.getValue())) {
|
if (data.getAccessType() == null && item.getStatus().equals(PlanStatus.Finalized.getValue())) {
|
||||||
logger.warn("AccessType not found set to default for dmp " + item.getId());
|
logger.warn("AccessType not found set to default for dmp " + item.getId());
|
||||||
data.setAccessType(item.isPublic() ? DmpAccessType.Public : DmpAccessType.Restricted);
|
data.setAccessType(item.isPublic() ? PlanAccessType.Public : PlanAccessType.Restricted);
|
||||||
}
|
}
|
||||||
if ((data.getLanguage() == null || data.getLanguage().isBlank()) && item.getStatus().equals(DmpStatus.Finalized.getValue())) {
|
if ((data.getLanguage() == null || data.getLanguage().isBlank()) && item.getStatus().equals(PlanStatus.Finalized.getValue())) {
|
||||||
logger.warn("Language not found set to default for dmp " + item.getId());
|
logger.warn("Language not found set to default for dmp " + item.getId());
|
||||||
data.setLanguage("en");
|
data.setLanguage("en");
|
||||||
}
|
}
|
||||||
|
@ -231,13 +228,13 @@ public class DmpMigrationService {
|
||||||
this.entityManager.persist(data);
|
this.entityManager.persist(data);
|
||||||
this.entityManager.flush();
|
this.entityManager.flush();
|
||||||
|
|
||||||
boolean shouldCreateOwner = item.getUsers() == null || item.getUsers().stream().noneMatch(x-> x.getUser() != null && data.getCreatorId().equals(x.getUser().getId()) && DmpUserRole.Owner.getValue().equals(x.getRole().shortValue()));
|
boolean shouldCreateOwner = item.getUsers() == null || item.getUsers().stream().noneMatch(x-> x.getUser() != null && data.getCreatorId().equals(x.getUser().getId()) && PlanUserRole.Owner.getValue().equals(x.getRole().shortValue()));
|
||||||
if (shouldCreateOwner) {
|
if (shouldCreateOwner) {
|
||||||
DmpUserEntity dmpUserEntity = new DmpUserEntity();
|
PlanUserEntity dmpUserEntity = new PlanUserEntity();
|
||||||
dmpUserEntity.setId(UUID.randomUUID());
|
dmpUserEntity.setId(UUID.randomUUID());
|
||||||
dmpUserEntity.setDmpId(data.getId());
|
dmpUserEntity.setPlanId(data.getId());
|
||||||
dmpUserEntity.setUserId(data.getCreatorId());
|
dmpUserEntity.setUserId(data.getCreatorId());
|
||||||
dmpUserEntity.setRole(DmpUserRole.Owner);
|
dmpUserEntity.setRole(PlanUserRole.Owner);
|
||||||
dmpUserEntity.setCreatedAt(data.getCreatedAt());
|
dmpUserEntity.setCreatedAt(data.getCreatedAt());
|
||||||
dmpUserEntity.setUpdatedAt(data.getCreatedAt());
|
dmpUserEntity.setUpdatedAt(data.getCreatedAt());
|
||||||
dmpUserEntity.setIsActive(IsActive.Active);
|
dmpUserEntity.setIsActive(IsActive.Active);
|
||||||
|
@ -245,11 +242,11 @@ public class DmpMigrationService {
|
||||||
this.entityManager.flush();
|
this.entityManager.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
licenseIdByName = this.migrateLicense(item, model, licenseIdByName, referenceTypeFieldsByDmpBlueprintId.getOrDefault(data.getBlueprintId(), null));
|
licenseIdByName = this.migrateLicense(item, model, licenseIdByName, referenceTypeFieldsByPlanBlueprintId.getOrDefault(data.getBlueprintId(), null));
|
||||||
this.migrateOrganizations(item, referenceTypeFieldsByDmpBlueprintId.getOrDefault(data.getBlueprintId(), null));
|
this.migrateOrganizations(item, referenceTypeFieldsByPlanBlueprintId.getOrDefault(data.getBlueprintId(), null));
|
||||||
this.migrateResearchers(item, referenceTypeFieldsByDmpBlueprintId.getOrDefault(data.getBlueprintId(), null));
|
this.migrateResearchers(item, referenceTypeFieldsByPlanBlueprintId.getOrDefault(data.getBlueprintId(), null));
|
||||||
this.migrateProjects(item, referenceTypeFieldsByDmpBlueprintId.getOrDefault(data.getBlueprintId(), null));
|
this.migrateProjects(item, referenceTypeFieldsByPlanBlueprintId.getOrDefault(data.getBlueprintId(), null));
|
||||||
this.migrateGrantAndFunder(item, referenceTypeFieldsByDmpBlueprintId.getOrDefault(data.getBlueprintId(), null));
|
this.migrateGrantAndFunder(item, referenceTypeFieldsByPlanBlueprintId.getOrDefault(data.getBlueprintId(), null));
|
||||||
}
|
}
|
||||||
|
|
||||||
page++;
|
page++;
|
||||||
|
@ -257,11 +254,11 @@ public class DmpMigrationService {
|
||||||
} while (items != null && !items.isEmpty() && !TestMode);
|
} while (items != null && !items.isEmpty() && !TestMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
private org.opencdmp.commons.types.dmpblueprint.FieldEntity getFieldOfId(org.opencdmp.commons.types.dmpblueprint.DefinitionEntity definition, UUID fieldId){
|
private org.opencdmp.commons.types.planblueprint.FieldEntity getFieldOfId(org.opencdmp.commons.types.planblueprint.DefinitionEntity definition, UUID fieldId){
|
||||||
if (definition == null || definition.getSections() == null) return null;
|
if (definition == null || definition.getSections() == null) return null;
|
||||||
for (SectionEntity sectionModel : definition.getSections()){
|
for (SectionEntity sectionModel : definition.getSections()){
|
||||||
if (sectionModel.getFields() != null){
|
if (sectionModel.getFields() != null){
|
||||||
org.opencdmp.commons.types.dmpblueprint.FieldEntity fieldModel = sectionModel.getFields().stream().filter(x-> x.getId().equals(fieldId)).findFirst().orElse(null);
|
org.opencdmp.commons.types.planblueprint.FieldEntity fieldModel = sectionModel.getFields().stream().filter(x-> x.getId().equals(fieldId)).findFirst().orElse(null);
|
||||||
if (fieldModel != null) return fieldModel;
|
if (fieldModel != null) return fieldModel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -281,13 +278,13 @@ public class DmpMigrationService {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Organisation organisation : organisations) {
|
for (Organisation organisation : organisations) {
|
||||||
DmpReferenceEntity data = new DmpReferenceEntity();
|
PlanReferenceEntity data = new PlanReferenceEntity();
|
||||||
data.setId(UUID.randomUUID());
|
data.setId(UUID.randomUUID());
|
||||||
data.setDmpId(item.getId());
|
data.setPlanId(item.getId());
|
||||||
data.setReferenceId(organisation.getId());
|
data.setReferenceId(organisation.getId());
|
||||||
data.setCreatedAt(item.getCreated() != null ? item.getCreated().toInstant() : Instant.now());
|
data.setCreatedAt(item.getCreated() != null ? item.getCreated().toInstant() : Instant.now());
|
||||||
data.setUpdatedAt(item.getModified() != null ? item.getModified().toInstant() : Instant.now());
|
data.setUpdatedAt(item.getModified() != null ? item.getModified().toInstant() : Instant.now());
|
||||||
data.setData(this.jsonHandlingService.toJsonSafe(this.buildDmpReferenceDataEntity(referenceTypeFieldEntity)));
|
data.setData(this.jsonHandlingService.toJsonSafe(this.buildPlanReferenceDataEntity(referenceTypeFieldEntity)));
|
||||||
data.setIsActive(IsActive.Active);
|
data.setIsActive(IsActive.Active);
|
||||||
this.entityManager.persist(data);
|
this.entityManager.persist(data);
|
||||||
}
|
}
|
||||||
|
@ -304,14 +301,14 @@ public class DmpMigrationService {
|
||||||
throw new MyApplicationException("Migration failed Project field not found " + item.getId());
|
throw new MyApplicationException("Migration failed Project field not found " + item.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
DmpReferenceEntity data = new DmpReferenceEntity();
|
PlanReferenceEntity data = new PlanReferenceEntity();
|
||||||
data.setId(UUID.randomUUID());
|
data.setId(UUID.randomUUID());
|
||||||
data.setDmpId(item.getId());
|
data.setPlanId(item.getId());
|
||||||
data.setReferenceId(project.getId());
|
data.setReferenceId(project.getId());
|
||||||
data.setCreatedAt(item.getCreated() != null ? item.getCreated().toInstant() : Instant.now());
|
data.setCreatedAt(item.getCreated() != null ? item.getCreated().toInstant() : Instant.now());
|
||||||
data.setUpdatedAt(item.getModified() != null ? item.getModified().toInstant() : Instant.now());
|
data.setUpdatedAt(item.getModified() != null ? item.getModified().toInstant() : Instant.now());
|
||||||
data.setIsActive(IsActive.Active);
|
data.setIsActive(IsActive.Active);
|
||||||
data.setData(this.jsonHandlingService.toJsonSafe(this.buildDmpReferenceDataEntity(referenceTypeFieldEntity)));
|
data.setData(this.jsonHandlingService.toJsonSafe(this.buildPlanReferenceDataEntity(referenceTypeFieldEntity)));
|
||||||
this.entityManager.persist(data);
|
this.entityManager.persist(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -327,13 +324,13 @@ public class DmpMigrationService {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Researcher researcher : researchers) {
|
for (Researcher researcher : researchers) {
|
||||||
DmpReferenceEntity data = new DmpReferenceEntity();
|
PlanReferenceEntity data = new PlanReferenceEntity();
|
||||||
data.setId(UUID.randomUUID());
|
data.setId(UUID.randomUUID());
|
||||||
data.setDmpId(item.getId());
|
data.setPlanId(item.getId());
|
||||||
data.setReferenceId(researcher.getId());
|
data.setReferenceId(researcher.getId());
|
||||||
data.setCreatedAt(item.getCreated() != null ? item.getCreated().toInstant() : Instant.now());
|
data.setCreatedAt(item.getCreated() != null ? item.getCreated().toInstant() : Instant.now());
|
||||||
data.setUpdatedAt(item.getModified() != null ? item.getModified().toInstant() : Instant.now());
|
data.setUpdatedAt(item.getModified() != null ? item.getModified().toInstant() : Instant.now());
|
||||||
data.setData(this.jsonHandlingService.toJsonSafe(this.buildDmpReferenceDataEntity(referenceTypeFieldEntity)));
|
data.setData(this.jsonHandlingService.toJsonSafe(this.buildPlanReferenceDataEntity(referenceTypeFieldEntity)));
|
||||||
data.setIsActive(IsActive.Active);
|
data.setIsActive(IsActive.Active);
|
||||||
this.entityManager.persist(data);
|
this.entityManager.persist(data);
|
||||||
}
|
}
|
||||||
|
@ -351,13 +348,13 @@ public class DmpMigrationService {
|
||||||
throw new MyApplicationException("Migration failed Grant field not found " + item.getId());
|
throw new MyApplicationException("Migration failed Grant field not found " + item.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
DmpReferenceEntity data = new DmpReferenceEntity();
|
PlanReferenceEntity data = new PlanReferenceEntity();
|
||||||
data.setId(UUID.randomUUID());
|
data.setId(UUID.randomUUID());
|
||||||
data.setDmpId(item.getId());
|
data.setPlanId(item.getId());
|
||||||
data.setReferenceId(grant.getId());
|
data.setReferenceId(grant.getId());
|
||||||
data.setCreatedAt(item.getCreated() != null ? item.getCreated().toInstant() : Instant.now());
|
data.setCreatedAt(item.getCreated() != null ? item.getCreated().toInstant() : Instant.now());
|
||||||
data.setUpdatedAt(item.getModified() != null ? item.getModified().toInstant() : Instant.now());
|
data.setUpdatedAt(item.getModified() != null ? item.getModified().toInstant() : Instant.now());
|
||||||
data.setData(this.jsonHandlingService.toJsonSafe(this.buildDmpReferenceDataEntity(referenceTypeFieldEntity)));
|
data.setData(this.jsonHandlingService.toJsonSafe(this.buildPlanReferenceDataEntity(referenceTypeFieldEntity)));
|
||||||
data.setIsActive(IsActive.Active);
|
data.setIsActive(IsActive.Active);
|
||||||
this.entityManager.persist(data);
|
this.entityManager.persist(data);
|
||||||
if (grant.getFunder() != null){
|
if (grant.getFunder() != null){
|
||||||
|
@ -365,13 +362,13 @@ public class DmpMigrationService {
|
||||||
if (funderField == null) {
|
if (funderField == null) {
|
||||||
throw new MyApplicationException("Migration failed Funder field not found " + item.getId());
|
throw new MyApplicationException("Migration failed Funder field not found " + item.getId());
|
||||||
}
|
}
|
||||||
DmpReferenceEntity founder = new DmpReferenceEntity();
|
PlanReferenceEntity founder = new PlanReferenceEntity();
|
||||||
founder.setId(UUID.randomUUID());
|
founder.setId(UUID.randomUUID());
|
||||||
founder.setDmpId(item.getId());
|
founder.setPlanId(item.getId());
|
||||||
founder.setReferenceId(grant.getFunder().getId());
|
founder.setReferenceId(grant.getFunder().getId());
|
||||||
founder.setCreatedAt(item.getCreated() != null ? item.getCreated().toInstant() : Instant.now());
|
founder.setCreatedAt(item.getCreated() != null ? item.getCreated().toInstant() : Instant.now());
|
||||||
founder.setUpdatedAt(item.getModified() != null ? item.getModified().toInstant() : Instant.now());
|
founder.setUpdatedAt(item.getModified() != null ? item.getModified().toInstant() : Instant.now());
|
||||||
founder.setData(this.jsonHandlingService.toJsonSafe(this.buildDmpReferenceDataEntity(funderField)));
|
founder.setData(this.jsonHandlingService.toJsonSafe(this.buildPlanReferenceDataEntity(funderField)));
|
||||||
founder.setIsActive(IsActive.Active);
|
founder.setIsActive(IsActive.Active);
|
||||||
this.entityManager.persist(founder);
|
this.entityManager.persist(founder);
|
||||||
}
|
}
|
||||||
|
@ -456,13 +453,13 @@ public class DmpMigrationService {
|
||||||
licenseIdByName.put(licensePid, referenceEntity.getId());
|
licenseIdByName.put(licensePid, referenceEntity.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
DmpReferenceEntity dmpReferenceEntity = new DmpReferenceEntity();
|
PlanReferenceEntity dmpReferenceEntity = new PlanReferenceEntity();
|
||||||
dmpReferenceEntity.setId(UUID.randomUUID());
|
dmpReferenceEntity.setId(UUID.randomUUID());
|
||||||
dmpReferenceEntity.setDmpId(item.getId());
|
dmpReferenceEntity.setPlanId(item.getId());
|
||||||
dmpReferenceEntity.setReferenceId(licenseIdByName.get(licensePid));
|
dmpReferenceEntity.setReferenceId(licenseIdByName.get(licensePid));
|
||||||
dmpReferenceEntity.setCreatedAt(Instant.now());
|
dmpReferenceEntity.setCreatedAt(Instant.now());
|
||||||
dmpReferenceEntity.setUpdatedAt(Instant.now());
|
dmpReferenceEntity.setUpdatedAt(Instant.now());
|
||||||
dmpReferenceEntity.setData(this.jsonHandlingService.toJsonSafe(this.buildDmpReferenceDataEntity(referenceTypeFieldEntity)));
|
dmpReferenceEntity.setData(this.jsonHandlingService.toJsonSafe(this.buildPlanReferenceDataEntity(referenceTypeFieldEntity)));
|
||||||
dmpReferenceEntity.setIsActive(IsActive.Active);
|
dmpReferenceEntity.setIsActive(IsActive.Active);
|
||||||
|
|
||||||
if (!licenseExists) entityManager.persist(referenceEntity);
|
if (!licenseExists) entityManager.persist(referenceEntity);
|
||||||
|
@ -473,8 +470,8 @@ public class DmpMigrationService {
|
||||||
return licenseIdByName;
|
return licenseIdByName;
|
||||||
}
|
}
|
||||||
|
|
||||||
private DmpReferenceDataEntity buildDmpReferenceDataEntity(ReferenceTypeFieldEntity referenceTypeFieldEntity){
|
private PlanReferenceDataEntity buildPlanReferenceDataEntity(ReferenceTypeFieldEntity referenceTypeFieldEntity){
|
||||||
DmpReferenceDataEntity data = new DmpReferenceDataEntity();
|
PlanReferenceDataEntity data = new PlanReferenceDataEntity();
|
||||||
data.setBlueprintFieldId(referenceTypeFieldEntity.getId());
|
data.setBlueprintFieldId(referenceTypeFieldEntity.getId());
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
|
@ -1,8 +1,8 @@
|
||||||
package eu.old.eudat.migration;
|
package eu.old.eudat.migration;
|
||||||
|
|
||||||
import org.opencdmp.commons.enums.DmpUserRole;
|
import org.opencdmp.commons.enums.PlanUserRole;
|
||||||
import org.opencdmp.commons.enums.IsActive;
|
import org.opencdmp.commons.enums.IsActive;
|
||||||
import org.opencdmp.data.DmpUserEntity;
|
import org.opencdmp.data.PlanUserEntity;
|
||||||
import eu.old.eudat.data.dao.entities.UserDmpDao;
|
import eu.old.eudat.data.dao.entities.UserDmpDao;
|
||||||
import eu.old.eudat.data.entities.UserDMP;
|
import eu.old.eudat.data.entities.UserDMP;
|
||||||
import eu.old.eudat.logic.services.operations.DatabaseRepository;
|
import eu.old.eudat.logic.services.operations.DatabaseRepository;
|
||||||
|
@ -15,9 +15,9 @@ import java.time.Instant;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class DmpUserMigrationService {
|
public class PlanUserMigrationService {
|
||||||
|
|
||||||
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpUserMigrationService.class));
|
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PlanUserMigrationService.class));
|
||||||
|
|
||||||
private final DatabaseRepository databaseRepository;
|
private final DatabaseRepository databaseRepository;
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ public class DmpUserMigrationService {
|
||||||
|
|
||||||
private static final boolean TestMode = false;
|
private static final boolean TestMode = false;
|
||||||
|
|
||||||
public DmpUserMigrationService(DatabaseRepository databaseRepository, EntityManager entityManager) {
|
public PlanUserMigrationService(DatabaseRepository databaseRepository, EntityManager entityManager) {
|
||||||
this.databaseRepository = databaseRepository;
|
this.databaseRepository = databaseRepository;
|
||||||
this.entityManager = entityManager;
|
this.entityManager = entityManager;
|
||||||
}
|
}
|
||||||
|
@ -46,11 +46,11 @@ public class DmpUserMigrationService {
|
||||||
for (UserDMP item : items) {
|
for (UserDMP item : items) {
|
||||||
//entityManager.detach(item);
|
//entityManager.detach(item);
|
||||||
|
|
||||||
DmpUserEntity data = new DmpUserEntity();
|
PlanUserEntity data = new PlanUserEntity();
|
||||||
data.setId(item.getId());
|
data.setId(item.getId());
|
||||||
data.setDmpId(item.getDmp().getId());
|
data.setPlanId(item.getDmp().getId());
|
||||||
data.setUserId(item.getUser().getId());
|
data.setUserId(item.getUser().getId());
|
||||||
data.setRole(DmpUserRole.of(item.getRole().shortValue()));
|
data.setRole(PlanUserRole.of(item.getRole().shortValue()));
|
||||||
data.setCreatedAt(item.getDmp().getCreated() != null ? item.getDmp().getCreated().toInstant() : Instant.now());
|
data.setCreatedAt(item.getDmp().getCreated() != null ? item.getDmp().getCreated().toInstant() : Instant.now());
|
||||||
data.setUpdatedAt(item.getDmp().getModified() != null ? item.getDmp().getModified().toInstant() : Instant.now());
|
data.setUpdatedAt(item.getDmp().getModified() != null ? item.getDmp().getModified().toInstant() : Instant.now());
|
||||||
data.setIsActive(IsActive.Active);
|
data.setIsActive(IsActive.Active);
|
|
@ -26,7 +26,7 @@ import java.net.URISyntaxException;
|
||||||
public class MigrationController {
|
public class MigrationController {
|
||||||
|
|
||||||
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(MigrationController.class));
|
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(MigrationController.class));
|
||||||
private final DmpMigrationService dmpMigrationService;
|
private final PlanMigrationService planMigrationService;
|
||||||
private final DataRepositoryMigrationService dataRepositoryMigrationService;
|
private final DataRepositoryMigrationService dataRepositoryMigrationService;
|
||||||
private final ExternalDatasetMigrationService externalDatasetMigrationService;
|
private final ExternalDatasetMigrationService externalDatasetMigrationService;
|
||||||
private final FunderMigrationService funderMigrationService;
|
private final FunderMigrationService funderMigrationService;
|
||||||
|
@ -37,21 +37,21 @@ public class MigrationController {
|
||||||
private final ServiceMigrationService serviceMigrationService;
|
private final ServiceMigrationService serviceMigrationService;
|
||||||
private final DatasetMigrationService datasetMigrationService;
|
private final DatasetMigrationService datasetMigrationService;
|
||||||
private final TagMigrationService tagMigrationService;
|
private final TagMigrationService tagMigrationService;
|
||||||
private final DmpDatasetProfileMigrationService dmpDatasetProfileMigrationService;
|
private final PlanDatasetProfileMigrationService planDatasetProfileMigrationService;
|
||||||
private final OrganizationMigrationService organizationMigrationService;
|
private final OrganizationMigrationService organizationMigrationService;
|
||||||
private final DatasetReferenceMigrationService datasetReferenceMigrationService;
|
private final DatasetReferenceMigrationService datasetReferenceMigrationService;
|
||||||
private final UserContactInfoMigrationService userContactInfoMigrationService;
|
private final UserContactInfoMigrationService userContactInfoMigrationService;
|
||||||
private final DmpUserMigrationService dmpUserMigrationService;
|
private final PlanUserMigrationService planUserMigrationService;
|
||||||
private final UserMigrationService userMigrationService;
|
private final UserMigrationService userMigrationService;
|
||||||
private final DmpBlueprintXmlMigrationService dmpBlueprintXmlMigrationService;
|
private final PlanBlueprintXmlMigrationService planBlueprintXmlMigrationService;
|
||||||
private final DescriptionTemplateXmlMigrationService descriptionTemplateXmlMigrationService;
|
private final DescriptionTemplateXmlMigrationService descriptionTemplateXmlMigrationService;
|
||||||
private final DescriptionTemplateXmlCleanInvalidReferenceTypesService descriptionTemplateXmlCleanInvalidReferenceTypesService;
|
private final DescriptionTemplateXmlCleanInvalidReferenceTypesService descriptionTemplateXmlCleanInvalidReferenceTypesService;
|
||||||
private final StorageFileMigrationService storageFileMigrationService;
|
private final StorageFileMigrationService storageFileMigrationService;
|
||||||
|
|
||||||
public MigrationController(
|
public MigrationController(
|
||||||
DmpMigrationService dmpMigrationService,
|
PlanMigrationService planMigrationService,
|
||||||
DatasetMigrationService datasetMigrationService,
|
DatasetMigrationService datasetMigrationService,
|
||||||
DmpDatasetProfileMigrationService dmpDatasetProfileMigrationService,
|
PlanDatasetProfileMigrationService planDatasetProfileMigrationService,
|
||||||
DataRepositoryMigrationService dataRepositoryMigrationService,
|
DataRepositoryMigrationService dataRepositoryMigrationService,
|
||||||
ExternalDatasetMigrationService externalDatasetMigrationService,
|
ExternalDatasetMigrationService externalDatasetMigrationService,
|
||||||
FunderMigrationService funderMigrationService,
|
FunderMigrationService funderMigrationService,
|
||||||
|
@ -63,13 +63,13 @@ public class MigrationController {
|
||||||
OrganizationMigrationService organizationMigrationService,
|
OrganizationMigrationService organizationMigrationService,
|
||||||
DatasetReferenceMigrationService datasetReferenceMigrationService,
|
DatasetReferenceMigrationService datasetReferenceMigrationService,
|
||||||
UserContactInfoMigrationService userContactInfoMigrationService,
|
UserContactInfoMigrationService userContactInfoMigrationService,
|
||||||
DmpUserMigrationService dmpUserMigrationService,
|
PlanUserMigrationService planUserMigrationService,
|
||||||
UserMigrationService userMigrationService,
|
UserMigrationService userMigrationService,
|
||||||
DmpBlueprintXmlMigrationService dmpBlueprintXmlMigrationService,
|
PlanBlueprintXmlMigrationService planBlueprintXmlMigrationService,
|
||||||
DescriptionTemplateXmlMigrationService descriptionTemplateXmlMigrationService, DescriptionTemplateXmlCleanInvalidReferenceTypesService descriptionTemplateXmlCleanInvalidReferenceTypesService, StorageFileMigrationService storageFileMigrationService) {
|
DescriptionTemplateXmlMigrationService descriptionTemplateXmlMigrationService, DescriptionTemplateXmlCleanInvalidReferenceTypesService descriptionTemplateXmlCleanInvalidReferenceTypesService, StorageFileMigrationService storageFileMigrationService) {
|
||||||
this.dmpMigrationService = dmpMigrationService;
|
this.planMigrationService = planMigrationService;
|
||||||
this.datasetMigrationService = datasetMigrationService;
|
this.datasetMigrationService = datasetMigrationService;
|
||||||
this.dmpDatasetProfileMigrationService = dmpDatasetProfileMigrationService;
|
this.planDatasetProfileMigrationService = planDatasetProfileMigrationService;
|
||||||
this.dataRepositoryMigrationService = dataRepositoryMigrationService;
|
this.dataRepositoryMigrationService = dataRepositoryMigrationService;
|
||||||
this.externalDatasetMigrationService = externalDatasetMigrationService;
|
this.externalDatasetMigrationService = externalDatasetMigrationService;
|
||||||
this.funderMigrationService = funderMigrationService;
|
this.funderMigrationService = funderMigrationService;
|
||||||
|
@ -82,9 +82,9 @@ public class MigrationController {
|
||||||
this.organizationMigrationService = organizationMigrationService;
|
this.organizationMigrationService = organizationMigrationService;
|
||||||
this.datasetReferenceMigrationService = datasetReferenceMigrationService;
|
this.datasetReferenceMigrationService = datasetReferenceMigrationService;
|
||||||
this.userContactInfoMigrationService = userContactInfoMigrationService;
|
this.userContactInfoMigrationService = userContactInfoMigrationService;
|
||||||
this.dmpUserMigrationService = dmpUserMigrationService;
|
this.planUserMigrationService = planUserMigrationService;
|
||||||
this.userMigrationService = userMigrationService;
|
this.userMigrationService = userMigrationService;
|
||||||
this.dmpBlueprintXmlMigrationService = dmpBlueprintXmlMigrationService;
|
this.planBlueprintXmlMigrationService = planBlueprintXmlMigrationService;
|
||||||
this.descriptionTemplateXmlMigrationService = descriptionTemplateXmlMigrationService;
|
this.descriptionTemplateXmlMigrationService = descriptionTemplateXmlMigrationService;
|
||||||
this.descriptionTemplateXmlCleanInvalidReferenceTypesService = descriptionTemplateXmlCleanInvalidReferenceTypesService;
|
this.descriptionTemplateXmlCleanInvalidReferenceTypesService = descriptionTemplateXmlCleanInvalidReferenceTypesService;
|
||||||
this.storageFileMigrationService = storageFileMigrationService;
|
this.storageFileMigrationService = storageFileMigrationService;
|
||||||
|
@ -149,7 +149,7 @@ public class MigrationController {
|
||||||
this.userMigrationService.migrate();
|
this.userMigrationService.migrate();
|
||||||
|
|
||||||
//XML recreate
|
//XML recreate
|
||||||
this.dmpBlueprintXmlMigrationService.migrate();
|
this.planBlueprintXmlMigrationService.migrate();
|
||||||
this.descriptionTemplateXmlMigrationService.migrate();
|
this.descriptionTemplateXmlMigrationService.migrate();
|
||||||
|
|
||||||
logger.info("Completed!!!");
|
logger.info("Completed!!!");
|
||||||
|
@ -161,9 +161,9 @@ public class MigrationController {
|
||||||
@Transactional
|
@Transactional
|
||||||
public boolean step2() throws IOException, JAXBException, ParserConfigurationException, InstantiationException, IllegalAccessException, SAXException, NoSuchFieldException, InvalidApplicationException, TransformerException, URISyntaxException {
|
public boolean step2() throws IOException, JAXBException, ParserConfigurationException, InstantiationException, IllegalAccessException, SAXException, NoSuchFieldException, InvalidApplicationException, TransformerException, URISyntaxException {
|
||||||
//Dmp
|
//Dmp
|
||||||
this.dmpMigrationService.migrate();
|
this.planMigrationService.migrate();
|
||||||
this.dmpDatasetProfileMigrationService.migrate();
|
this.planDatasetProfileMigrationService.migrate();
|
||||||
this.dmpUserMigrationService.migrate();
|
this.planUserMigrationService.migrate();
|
||||||
|
|
||||||
logger.info("Completed!!!");
|
logger.info("Completed!!!");
|
||||||
|
|
||||||
|
@ -190,7 +190,7 @@ public class MigrationController {
|
||||||
@GetMapping("dmp-blueprints-xml")
|
@GetMapping("dmp-blueprints-xml")
|
||||||
@Transactional
|
@Transactional
|
||||||
public boolean migrateDmpBlueprint() throws JAXBException, InvalidApplicationException, IOException, ParserConfigurationException, NoSuchFieldException, TransformerException, IllegalAccessException, InstantiationException, SAXException {
|
public boolean migrateDmpBlueprint() throws JAXBException, InvalidApplicationException, IOException, ParserConfigurationException, NoSuchFieldException, TransformerException, IllegalAccessException, InstantiationException, SAXException {
|
||||||
this.dmpBlueprintXmlMigrationService.migrate();
|
this.planBlueprintXmlMigrationService.migrate();
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -239,7 +239,7 @@ public class MigrationController {
|
||||||
@GetMapping("dmps")
|
@GetMapping("dmps")
|
||||||
@Transactional
|
@Transactional
|
||||||
public boolean migrateDmps() throws IOException, NoSuchFieldException, IllegalAccessException, JAXBException, ParserConfigurationException, InstantiationException, SAXException {
|
public boolean migrateDmps() throws IOException, NoSuchFieldException, IllegalAccessException, JAXBException, ParserConfigurationException, InstantiationException, SAXException {
|
||||||
this.dmpMigrationService.migrate();
|
this.planMigrationService.migrate();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,7 +260,7 @@ public class MigrationController {
|
||||||
@GetMapping("dmp-dataset-profiles")
|
@GetMapping("dmp-dataset-profiles")
|
||||||
@Transactional
|
@Transactional
|
||||||
public boolean migrateDmpDatasetProfiles() throws IOException, JAXBException, ParserConfigurationException, InstantiationException, IllegalAccessException, SAXException {
|
public boolean migrateDmpDatasetProfiles() throws IOException, JAXBException, ParserConfigurationException, InstantiationException, IllegalAccessException, SAXException {
|
||||||
this.dmpDatasetProfileMigrationService.migrate();
|
this.planDatasetProfileMigrationService.migrate();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,7 +282,7 @@ public class MigrationController {
|
||||||
@GetMapping("dmp-users")
|
@GetMapping("dmp-users")
|
||||||
@Transactional
|
@Transactional
|
||||||
public boolean migrateDmpUsers() {
|
public boolean migrateDmpUsers() {
|
||||||
this.dmpUserMigrationService.migrate();
|
this.planUserMigrationService.migrate();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue