rename dmp to plan for common models, repository deposit base, file transformer base

This commit is contained in:
amentis 2024-07-05 15:20:33 +03:00
parent ac6d7ab003
commit fca1eb2a91
28 changed files with 210 additions and 210 deletions

View File

@ -51,12 +51,12 @@
<dependency>
<groupId>org.opencdmp</groupId>
<artifactId>repositorydepositbase</artifactId>
<version>2.0.15</version>
<version>2.0.16</version>
</dependency>
<dependency>
<groupId>org.opencdmp</groupId>
<artifactId>common-models</artifactId>
<version>0.0.18</version>
<version>0.0.19</version>
</dependency>
<dependency>
<groupId>gr.cite</groupId>
@ -66,7 +66,7 @@
<dependency>
<groupId>org.opencdmp</groupId>
<artifactId>file-transformer-base</artifactId>
<version>0.0.23</version>
<version>0.0.24</version>
</dependency>
<dependency>
<groupId>gr.cite</groupId>

View File

@ -5,8 +5,8 @@ import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.logging.LoggerService;
import org.opencdmp.authorization.AuthorizationFlags;
import org.opencdmp.commonmodels.enums.DmpUserRole;
import org.opencdmp.commonmodels.models.DmpUserModel;
import org.opencdmp.commonmodels.enums.PlanUserRole;
import org.opencdmp.commonmodels.models.PlanUserModel;
import org.opencdmp.commonmodels.models.UserModel;
import org.opencdmp.commons.enums.IsActive;
import org.opencdmp.convention.ConventionService;
@ -24,7 +24,7 @@ import java.util.stream.Collectors;
@Component
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class PlanUserCommonModelBuilder extends BaseCommonModelBuilder<DmpUserModel, PlanUserEntity> {
public class PlanUserCommonModelBuilder extends BaseCommonModelBuilder<PlanUserModel, PlanUserEntity> {
private final BuilderFactory builderFactory;
@ -47,7 +47,7 @@ public class PlanUserCommonModelBuilder extends BaseCommonModelBuilder<DmpUserMo
}
@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));
if (data == null)
return new ArrayList<>();
@ -55,14 +55,14 @@ public class PlanUserCommonModelBuilder extends BaseCommonModelBuilder<DmpUserMo
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) {
DmpUserModel m = new DmpUserModel();
PlanUserModel m = new PlanUserModel();
switch (d.getRole()){
case Viewer -> m.setRole(DmpUserRole.Viewer);
case Owner -> m.setRole(DmpUserRole.Owner);
case DescriptionContributor -> m.setRole(DmpUserRole.DescriptionContributor);
case Reviewer -> m.setRole(DmpUserRole.Reviewer);
case Viewer -> m.setRole(PlanUserRole.Viewer);
case Owner -> m.setRole(PlanUserRole.Owner);
case DescriptionContributor -> m.setRole(PlanUserRole.DescriptionContributor);
case Reviewer -> m.setRole(PlanUserRole.Reviewer);
default -> throw new MyApplicationException("unrecognized type " + d.getRole().getValue());
}
if (userItemsMap != null && userItemsMap.containsKey(d.getUserId())) m.setUser(userItemsMap.get(d.getUserId()));

View File

@ -9,7 +9,7 @@ import org.opencdmp.authorization.AuthorizationFlags;
import org.opencdmp.commonmodels.enums.DescriptionStatus;
import org.opencdmp.commonmodels.models.description.DescriptionModel;
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.XmlHandlingService;
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<>();
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, UUID> planDescriptionTemplateSections = this.collectPlanDescriptionTemplateSections(data);
@ -106,7 +106,7 @@ public class DescriptionCommonModelBuilder extends BaseCommonModelBuilder<Descri
}
m.setCreatedAt(d.getCreatedAt());
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 (descriptionTemplates != null && d.getDescriptionTemplateId() != null && descriptionTemplates.containsKey(d.getDescriptionTemplateId())) m.setDescriptionTemplate(descriptionTemplates.get(d.getDescriptionTemplateId()));
if (d.getProperties() != null){
@ -155,12 +155,12 @@ public class DescriptionCommonModelBuilder extends BaseCommonModelBuilder<Descri
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())
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()));
itemMap = this.builderFactory.builder(PlanCommonModelBuilder.class).setRepositoryId(this.repositoryId).useSharedStorage(this.useSharedStorage).setDisableDescriptions(true).authorize(this.authorize).asForeignKey(q, PlanEntity::getId);

View File

@ -53,7 +53,7 @@ public abstract class BaseFieldDataCommonModelBuilder<Model extends BaseFieldDat
case SELECT -> m.setFieldType(FieldType.SELECT);
case BOOLEAN_DECISION -> m.setFieldType(FieldType.BOOLEAN_DECISION);
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 CHECK_BOX -> m.setFieldType(FieldType.CHECK_BOX);
case FREE_TEXT -> m.setFieldType(FieldType.FREE_TEXT);

View File

@ -1,7 +1,7 @@
package org.opencdmp.model.builder.commonmodels.plan;
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.PlanBlueprintFieldCategory;
import org.opencdmp.commons.types.plan.PlanBlueprintValueEntity;
@ -26,7 +26,7 @@ import java.util.Optional;
@Component
@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 DefinitionEntity definition;
@ -48,17 +48,17 @@ public class PlanBlueprintValueCommonModelBuilder extends BaseCommonModelBuilder
}
@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));
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) {
FieldEntity fieldEntity = this.definition != null ? this.definition.getFieldById(d.getFieldId()).stream().findFirst().orElse(null) : null;
if (fieldEntity != null && fieldEntity.getCategory().equals(PlanBlueprintFieldCategory.Extra)) {
ExtraFieldEntity extraFieldEntity = (ExtraFieldEntity) fieldEntity;
DmpBlueprintValueModel m = new DmpBlueprintValueModel();
PlanBlueprintValueModel m = new PlanBlueprintValueModel();
m.setFieldId(d.getFieldId());
if (extraFieldEntity != null && PlanBlueprintExtraFieldDataType.isDateType(extraFieldEntity.getType())){
m.setDateValue(d.getDateValue());

View File

@ -7,16 +7,16 @@ import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.fieldset.BaseFieldSet;
import gr.cite.tools.logging.LoggerService;
import org.opencdmp.authorization.AuthorizationFlags;
import org.opencdmp.commonmodels.enums.DmpAccessType;
import org.opencdmp.commonmodels.enums.DmpStatus;
import org.opencdmp.commonmodels.models.DmpUserModel;
import org.opencdmp.commonmodels.enums.PlanAccessType;
import org.opencdmp.commonmodels.enums.PlanStatus;
import org.opencdmp.commonmodels.models.PlanUserModel;
import org.opencdmp.commonmodels.models.EntityDoiModel;
import org.opencdmp.commonmodels.models.FileEnvelopeModel;
import org.opencdmp.commonmodels.models.UserModel;
import org.opencdmp.commonmodels.models.description.DescriptionModel;
import org.opencdmp.commonmodels.models.dmp.DmpModel;
import org.opencdmp.commonmodels.models.dmpblueprint.DmpBlueprintModel;
import org.opencdmp.commonmodels.models.dmpreference.DmpReferenceModel;
import org.opencdmp.commonmodels.models.plan.PlanModel;
import org.opencdmp.commonmodels.models.planblueprint.PlanBlueprintModel;
import org.opencdmp.commonmodels.models.planreference.PlanReferenceModel;
import org.opencdmp.commons.JsonHandlingService;
import org.opencdmp.commons.XmlHandlingService;
import org.opencdmp.commons.enums.IsActive;
@ -46,7 +46,7 @@ import java.util.stream.Collectors;
@Component
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class PlanCommonModelBuilder extends BaseCommonModelBuilder<DmpModel, PlanEntity> {
public class PlanCommonModelBuilder extends BaseCommonModelBuilder<PlanModel, PlanEntity> {
private final QueryFactory queryFactory;
@ -103,22 +103,22 @@ public class PlanCommonModelBuilder extends BaseCommonModelBuilder<DmpModel, Pla
}
@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));
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<DmpUserModel>> planUsersMap = this.collectPlanUsers(data);
Map<UUID, List<PlanReferenceModel>> planReferencesMap = this.collectPlanReferences(data);
Map<UUID, List<PlanUserModel>> planUsersMap = this.collectPlanUsers(data);
Map<UUID, List<DescriptionModel>> descriptionsMap = this.disableDescriptions ? null : this.collectPlanDescriptions(data);
Map<UUID, List<EntityDoiModel>> entityDois = this.collectPlanEntityDois(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);
for (PlanEntity d : data) {
DmpModel m = new DmpModel();
PlanModel m = new PlanModel();
m.setId(d.getId());
m.setLabel(d.getLabel());
m.setVersion(d.getVersion());
@ -127,13 +127,13 @@ public class PlanCommonModelBuilder extends BaseCommonModelBuilder<DmpModel, Pla
m.setCreatedAt(d.getCreatedAt());
m.setLanguage(d.getLanguage());
switch (d.getStatus()){
case Finalized -> m.setStatus(DmpStatus.Finalized);
case Draft -> m.setStatus(DmpStatus.Draft);
case Finalized -> m.setStatus(PlanStatus.Finalized);
case Draft -> m.setStatus(PlanStatus.Draft);
default -> throw new MyApplicationException("unrecognized type " + d.getStatus());
}
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 (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){
//TODO Update with the new logic of property definition
PlanPropertiesEntity propertyDefinition = this.jsonHandlingService.fromJsonSafe(PlanPropertiesEntity.class, d.getProperties());
@ -145,8 +145,8 @@ public class PlanCommonModelBuilder extends BaseCommonModelBuilder<DmpModel, Pla
m.setRdaJsonFile(this.rdaJsonFile);
if (d.getVersion() > (short)1) m.setPreviousDOI(this.getPreviousDOI(d.getGroupId(), d.getId()));
switch (d.getAccessType()){
case Public -> m.setAccessType(DmpAccessType.Public);
case Restricted -> m.setAccessType(DmpAccessType.Restricted);
case Public -> m.setAccessType(PlanAccessType.Public);
case Restricted -> m.setAccessType(PlanAccessType.Restricted);
case null -> m.setAccessType(null);
default -> throw new MyApplicationException("unrecognized type " + d.getAccessType());
}
@ -179,20 +179,20 @@ public class PlanCommonModelBuilder extends BaseCommonModelBuilder<DmpModel, Pla
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());
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()));
itemMap = this.builderFactory.builder(PlanUserCommonModelBuilder.class).authorize(this.authorize).asMasterKey(query, PlanUserEntity::getPlanId);
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());
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()));
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;
}
private Map<UUID, DmpBlueprintModel> collectPlanBlueprints(List<PlanEntity> data) throws MyApplicationException {
private Map<UUID, PlanBlueprintModel> collectPlanBlueprints(List<PlanEntity> data) throws MyApplicationException {
if (data.isEmpty())
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()));
itemMap = this.builderFactory.builder(PlanBlueprintCommonModelBuilder.class).authorize(this.authorize).asForeignKey(q, PlanBlueprintEntity::getId);
return itemMap;

View File

@ -5,7 +5,7 @@ import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.logging.LoggerService;
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.convention.ConventionService;
import org.opencdmp.model.builder.commonmodels.BaseCommonModelBuilder;
@ -20,7 +20,7 @@ import java.util.*;
@Component
@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 final BuilderFactory builderFactory;
@ -41,13 +41,13 @@ public class PlanContactCommonModelBuilder extends BaseCommonModelBuilder<DmpCon
}
@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));
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) {
DmpContactModel m = new DmpContactModel();
PlanContactModel m = new PlanContactModel();
m.setEmail(d.getEmail());
m.setFirstName(d.getFirstName());
m.setLastName(d.getLastName());

View File

@ -1,7 +1,7 @@
package org.opencdmp.model.builder.commonmodels.plan;
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.planblueprint.DefinitionEntity;
import org.opencdmp.convention.ConventionService;
@ -23,7 +23,7 @@ import java.util.Optional;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class PlanPropertiesCommonModelBuilder extends BaseCommonModelBuilder<DmpPropertiesModel, PlanPropertiesEntity> {
public class PlanPropertiesCommonModelBuilder extends BaseCommonModelBuilder<PlanPropertiesModel, PlanPropertiesEntity> {
private final BuilderFactory builderFactory;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
private DefinitionEntity definition;
@ -46,14 +46,14 @@ public class PlanPropertiesCommonModelBuilder extends BaseCommonModelBuilder<Dmp
}
@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));
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) {
DmpPropertiesModel m = new DmpPropertiesModel();
if (d.getPlanBlueprintValues() != null) m.setDmpBlueprintValues(this.builderFactory.builder(PlanBlueprintValueCommonModelBuilder.class).withDefinition(definition).authorize(this.authorize).build(d.getPlanBlueprintValues()));
PlanPropertiesModel m = new PlanPropertiesModel();
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()));
models.add(new CommonModelBuilderItemResponse<>(m, d));

View File

@ -1,7 +1,7 @@
package org.opencdmp.model.builder.commonmodels.planblueprint;
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.convention.ConventionService;
import org.opencdmp.model.builder.commonmodels.BaseCommonModelBuilder;

View File

@ -1,7 +1,7 @@
package org.opencdmp.model.builder.commonmodels.planblueprint;
import org.opencdmp.commonmodels.enums.DmpBlueprintExtraFieldDataType;
import org.opencdmp.commonmodels.models.dmpblueprint.ExtraFieldModel;
import org.opencdmp.commonmodels.enums.PlanBlueprintExtraFieldDataType;
import org.opencdmp.commonmodels.models.planblueprint.ExtraFieldModel;
import org.opencdmp.commons.types.planblueprint.ExtraFieldEntity;
import org.opencdmp.convention.ConventionService;
import gr.cite.tools.exception.MyApplicationException;
@ -26,10 +26,10 @@ public class ExtraFieldCommonModelBuilder extends FieldCommonModelBuilder<ExtraF
protected ExtraFieldModel buildChild(ExtraFieldEntity data, ExtraFieldModel model) {
switch (data.getType()){
case Date -> model.setDataType(DmpBlueprintExtraFieldDataType.Date);
case Number -> model.setDataType(DmpBlueprintExtraFieldDataType.Number);
case RichTex -> model.setDataType(DmpBlueprintExtraFieldDataType.RichTex);
case Text -> model.setDataType(DmpBlueprintExtraFieldDataType.Text);
case Date -> model.setDataType(PlanBlueprintExtraFieldDataType.Date);
case Number -> model.setDataType(PlanBlueprintExtraFieldDataType.Number);
case RichTex -> model.setDataType(PlanBlueprintExtraFieldDataType.RichTex);
case Text -> model.setDataType(PlanBlueprintExtraFieldDataType.Text);
default -> throw new MyApplicationException("unrecognized type " + data.getType());
}
return model;

View File

@ -1,8 +1,8 @@
package org.opencdmp.model.builder.commonmodels.planblueprint;
import org.opencdmp.authorization.AuthorizationFlags;
import org.opencdmp.commonmodels.enums.DmpBlueprintFieldCategory;
import org.opencdmp.commonmodels.models.dmpblueprint.FieldModel;
import org.opencdmp.commonmodels.enums.PlanBlueprintFieldCategory;
import org.opencdmp.commonmodels.models.planblueprint.FieldModel;
import org.opencdmp.commons.types.planblueprint.FieldEntity;
import org.opencdmp.convention.ConventionService;
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.setDescription(d.getDescription());
switch (d.getCategory()){
case System -> m.setCategory(DmpBlueprintFieldCategory.System);
case Extra -> m.setCategory(DmpBlueprintFieldCategory.Extra);
case ReferenceType -> m.setCategory(DmpBlueprintFieldCategory.ReferenceType);
case System -> m.setCategory(PlanBlueprintFieldCategory.System);
case Extra -> m.setCategory(PlanBlueprintFieldCategory.Extra);
case ReferenceType -> m.setCategory(PlanBlueprintFieldCategory.ReferenceType);
default -> throw new MyApplicationException("unrecognized type " + d.getCategory());
}
m.setPlaceholder(d.getPlaceholder());

View File

@ -1,8 +1,8 @@
package org.opencdmp.model.builder.commonmodels.planblueprint;
import org.opencdmp.authorization.AuthorizationFlags;
import org.opencdmp.commonmodels.enums.DmpBlueprintStatus;
import org.opencdmp.commonmodels.models.dmpblueprint.DmpBlueprintModel;
import org.opencdmp.commonmodels.enums.PlanBlueprintStatus;
import org.opencdmp.commonmodels.models.planblueprint.PlanBlueprintModel;
import org.opencdmp.commons.XmlHandlingService;
import org.opencdmp.commons.types.planblueprint.DefinitionEntity;
import org.opencdmp.convention.ConventionService;
@ -25,7 +25,7 @@ import java.util.Optional;
@Component
@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 XmlHandlingService xmlHandlingService;
@ -44,21 +44,21 @@ public class PlanBlueprintCommonModelBuilder extends BaseCommonModelBuilder<DmpB
return this;
}
@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));
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) {
DmpBlueprintModel m = new DmpBlueprintModel();
PlanBlueprintModel m = new PlanBlueprintModel();
m.setId(d.getId());
m.setLabel(d.getLabel());
m.setGroupId(d.getGroupId());
switch (d.getStatus()){
case Finalized -> m.setStatus(DmpBlueprintStatus.Finalized);
case Draft -> m.setStatus(DmpBlueprintStatus.Draft);
case Finalized -> m.setStatus(PlanBlueprintStatus.Finalized);
case Draft -> m.setStatus(PlanBlueprintStatus.Draft);
default -> throw new MyApplicationException("unrecognized type " + d.getStatus());
}
if (d.getDefinition() != null){

View File

@ -2,7 +2,7 @@ package org.opencdmp.model.builder.commonmodels.planblueprint;
import gr.cite.tools.data.builder.BuilderFactory;
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.convention.ConventionService;
import org.opencdmp.model.builder.commonmodels.ReferenceTypeCommonModelBuilder;

View File

@ -1,7 +1,7 @@
package org.opencdmp.model.builder.commonmodels.planblueprint;
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.types.planblueprint.ExtraFieldEntity;
import org.opencdmp.commons.types.planblueprint.ReferenceTypeFieldEntity;

View File

@ -1,7 +1,7 @@
package org.opencdmp.model.builder.commonmodels.planblueprint;
import org.opencdmp.commonmodels.enums.DmpBlueprintSystemFieldType;
import org.opencdmp.commonmodels.models.dmpblueprint.SystemFieldModel;
import org.opencdmp.commonmodels.enums.PlanBlueprintSystemFieldType;
import org.opencdmp.commonmodels.models.planblueprint.SystemFieldModel;
import org.opencdmp.commons.types.planblueprint.SystemFieldEntity;
import org.opencdmp.convention.ConventionService;
import gr.cite.tools.exception.MyApplicationException;
@ -26,12 +26,12 @@ public class SystemFieldCommonModelBuilder extends FieldCommonModelBuilder<Syste
protected SystemFieldModel buildChild(SystemFieldEntity data, SystemFieldModel model) {
switch (data.getType()){
case AccessRights -> model.setSystemFieldType(DmpBlueprintSystemFieldType.AccessRights);
case Contact -> model.setSystemFieldType(DmpBlueprintSystemFieldType.Contact);
case Description -> model.setSystemFieldType(DmpBlueprintSystemFieldType.Description);
case Language -> model.setSystemFieldType(DmpBlueprintSystemFieldType.Language);
case Title -> model.setSystemFieldType(DmpBlueprintSystemFieldType.Title);
case User -> model.setSystemFieldType(DmpBlueprintSystemFieldType.User);
case AccessRights -> model.setSystemFieldType(PlanBlueprintSystemFieldType.AccessRights);
case Contact -> model.setSystemFieldType(PlanBlueprintSystemFieldType.Contact);
case Description -> model.setSystemFieldType(PlanBlueprintSystemFieldType.Description);
case Language -> model.setSystemFieldType(PlanBlueprintSystemFieldType.Language);
case Title -> model.setSystemFieldType(PlanBlueprintSystemFieldType.Title);
case User -> model.setSystemFieldType(PlanBlueprintSystemFieldType.User);
default -> throw new MyApplicationException("unrecognized type " + data.getType());
}
return model;

View File

@ -5,7 +5,7 @@ import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.logging.LoggerService;
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.commons.JsonHandlingService;
import org.opencdmp.commons.types.planreference.PlanReferenceDataEntity;
@ -27,7 +27,7 @@ import java.util.stream.Collectors;
@Component
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class PlanReferenceCommonModelBuilder extends BaseCommonModelBuilder<DmpReferenceModel, PlanReferenceEntity> {
public class PlanReferenceCommonModelBuilder extends BaseCommonModelBuilder<PlanReferenceModel, PlanReferenceEntity> {
private final BuilderFactory builderFactory;
private final QueryFactory queryFactory;
@ -50,14 +50,14 @@ public class PlanReferenceCommonModelBuilder extends BaseCommonModelBuilder<DmpR
}
@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));
if (data == null || data.isEmpty()) return new ArrayList<>();
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) {
DmpReferenceModel m = new DmpReferenceModel();
PlanReferenceModel m = new PlanReferenceModel();
m.setId(d.getId());
if (d.getData() != null){
PlanReferenceDataEntity definition = this.jsonHandlingService.fromJsonSafe(PlanReferenceDataEntity.class, d.getData());

View File

@ -1,7 +1,7 @@
package org.opencdmp.model.builder.commonmodels.planreference;
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.convention.ConventionService;
import org.opencdmp.model.builder.commonmodels.BaseCommonModelBuilder;
@ -22,7 +22,7 @@ import java.util.Optional;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class PlanReferenceDataCommonModelBuilder extends BaseCommonModelBuilder<DmpReferenceDataModel, PlanReferenceDataEntity> {
public class PlanReferenceDataCommonModelBuilder extends BaseCommonModelBuilder<PlanReferenceDataModel, PlanReferenceDataEntity> {
private final BuilderFactory builderFactory;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
@ -40,13 +40,13 @@ public class PlanReferenceDataCommonModelBuilder extends BaseCommonModelBuilder<
}
@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));
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) {
DmpReferenceDataModel m = new DmpReferenceDataModel();
PlanReferenceDataModel m = new PlanReferenceDataModel();
m.setBlueprintFieldId(d.getBlueprintFieldId());
models.add(new CommonModelBuilderItemResponse<>(m, d));
}

View File

@ -2,7 +2,7 @@ package org.opencdmp.service.deposit;
import gr.cite.tools.logging.LoggerService;
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.DepositConfiguration;
import org.slf4j.LoggerFactory;
@ -21,9 +21,9 @@ public class DepositClientImpl implements DepositClient {
@Override
public String deposit(DmpModel dmpDepositModel, String repositoryAccessToken) throws Exception {
logger.debug(new MapLogEntry("deposit").And("dmpDepositModel", dmpDepositModel));
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();
public String deposit(PlanModel planDepositModel, String repositoryAccessToken) throws Exception {
logger.debug(new MapLogEntry("deposit").And("planDepositModel", planDepositModel));
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

View File

@ -17,7 +17,7 @@ import org.opencdmp.authorization.AuthorizationFlags;
import org.opencdmp.authorization.Permission;
import org.opencdmp.authorization.authorizationcontentresolver.AuthorizationContentResolver;
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.enums.IsActive;
import org.opencdmp.commons.enums.StorageType;
@ -311,7 +311,7 @@ public class DepositServiceImpl implements DepositService {
}
//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);

View File

@ -1187,7 +1187,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
case SELECT -> fieldType = FieldType.SELECT;
case BOOLEAN_DECISION -> fieldType = FieldType.BOOLEAN_DECISION;
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 CHECK_BOX -> fieldType = FieldType.CHECK_BOX;
case FREE_TEXT -> fieldType = FieldType.FREE_TEXT;

View File

@ -4,13 +4,13 @@ import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry;
import org.opencdmp.commonmodels.models.FileEnvelopeModel;
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.FileTransformerConfiguration;
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.PreprocessingDmpModel;
import org.opencdmp.filetransformerbase.models.misc.PreprocessingPlanModel;
import org.slf4j.LoggerFactory;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.web.reactive.function.client.WebClient;
@ -27,17 +27,17 @@ public class FileTransformerRepository implements FileTransformerClient {
}
@Override
public FileEnvelopeModel exportDmp(DmpModel dmpModel, String format) {
logger.debug(new MapLogEntry("exportDmp").And("format", format).And("dmpModel", dmpModel));
return this.transformerClient.post().uri("/export/dmp", uriBuilder -> uriBuilder.queryParam("format", format).build()).bodyValue(dmpModel)
public FileEnvelopeModel exportPlan(PlanModel planModel, String format) {
logger.debug(new MapLogEntry("exportPlan").And("format", format).And("planModel", planModel));
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();
}
@Override
public DmpModel importDmp(DmpImportModel dmpImportModel) {
logger.debug(new MapLogEntry("importDmp").And("fileEnvelope", dmpImportModel.getFile()));
return this.transformerClient.post().uri("/import/dmp").bodyValue(dmpImportModel)
.exchangeToMono(mono -> mono.statusCode().isError() ? mono.createException().flatMap(Mono::error) : mono.bodyToMono(DmpModel.class)).block();
public PlanModel importPlan(PlanImportModel planImportModel) {
logger.debug(new MapLogEntry("importPlan").And("fileEnvelope", planImportModel.getFile()));
return this.transformerClient.post().uri("/import/plan").bodyValue(planImportModel)
.exchangeToMono(mono -> mono.statusCode().isError() ? mono.createException().flatMap(Mono::error) : mono.bodyToMono(PlanModel.class)).block();
}
@Override
@ -62,10 +62,10 @@ public class FileTransformerRepository implements FileTransformerClient {
}
@Override
public PreprocessingDmpModel preprocessingDmp(FileEnvelopeModel fileEnvelopeModel) {
logger.debug(new MapLogEntry("preprocessingDmp").And("fileEnvelope", fileEnvelopeModel));
return this.transformerClient.post().uri("/preprocessing/dmp").bodyValue(fileEnvelopeModel)
.exchangeToMono(mono -> mono.statusCode().isError() ? mono.createException().flatMap(Mono::error) : mono.bodyToMono(PreprocessingDmpModel.class)).block();
public PreprocessingPlanModel preprocessingPlan(FileEnvelopeModel fileEnvelopeModel) {
logger.debug(new MapLogEntry("preprocessingPlan").And("fileEnvelope", fileEnvelopeModel));
return this.transformerClient.post().uri("/preprocessing/plan").bodyValue(fileEnvelopeModel)
.exchangeToMono(mono -> mono.statusCode().isError() ? mono.createException().flatMap(Mono::error) : mono.bodyToMono(PreprocessingPlanModel.class)).block();
}
@Override

View File

@ -1,8 +1,8 @@
package org.opencdmp.service.filetransformer;
import jakarta.xml.bind.JAXBException;
import org.opencdmp.commonmodels.models.dmp.DmpModel;
import org.opencdmp.filetransformerbase.models.misc.PreprocessingDmpModel;
import org.opencdmp.commonmodels.models.plan.PlanModel;
import org.opencdmp.filetransformerbase.models.misc.PreprocessingPlanModel;
import org.opencdmp.model.file.RepositoryFileFormat;
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;
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;
}

View File

@ -19,8 +19,8 @@ import org.opencdmp.authorization.Permission;
import org.opencdmp.commonmodels.models.FileEnvelopeModel;
import org.opencdmp.commonmodels.models.description.DescriptionModel;
import org.opencdmp.commonmodels.models.descriptiotemplate.DescriptionTemplateModel;
import org.opencdmp.commonmodels.models.dmp.DmpModel;
import org.opencdmp.commonmodels.models.dmpblueprint.DmpBlueprintModel;
import org.opencdmp.commonmodels.models.plan.PlanModel;
import org.opencdmp.commonmodels.models.planblueprint.PlanBlueprintModel;
import org.opencdmp.commons.JsonHandlingService;
import org.opencdmp.commons.enums.IsActive;
import org.opencdmp.commons.enums.StorageType;
@ -36,8 +36,8 @@ import org.opencdmp.data.TenantConfigurationEntity;
import org.opencdmp.event.TenantConfigurationTouchedEvent;
import org.opencdmp.filetransformerbase.interfaces.FileTransformerConfiguration;
import org.opencdmp.filetransformerbase.models.misc.DescriptionImportModel;
import org.opencdmp.filetransformerbase.models.misc.DmpImportModel;
import org.opencdmp.filetransformerbase.models.misc.PreprocessingDmpModel;
import org.opencdmp.filetransformerbase.models.misc.PlanImportModel;
import org.opencdmp.filetransformerbase.models.misc.PreprocessingPlanModel;
import org.opencdmp.model.StorageFile;
import org.opencdmp.model.builder.commonmodels.description.DescriptionCommonModelBuilder;
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()));
//GK: Second get the Target Data Management Plan
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());
if (dmpFileTransformerModel == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{planId, Plan.class.getSimpleName()}, LocaleContextHolder.getLocale()));
PlanModel planFileTransformerModel = this.builderFactory.builder(PlanCommonModelBuilder.class).useSharedStorage(repository.getConfiguration().isUseSharedStorage()).setRepositoryId(repository.getConfiguration().getFileTransformerId()).authorize(AuthorizationFlags.AllExceptPublic).build(query.first());
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();
byte[] data = repository.getConfiguration().isUseSharedStorage() ? this.storageFileService.readByFileRefAsBytesSafe(fileEnvelope.getFileRef(), StorageType.Transformer) : fileEnvelope.getFile();
@ -313,7 +313,7 @@ public class FileTransformerServiceImpl implements FileTransformerService {
}
@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);
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()));
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());
if (dmpBlueprintModel == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{planCommonModelConfig.getBlueprintId(), PlanBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale()));
PlanBlueprintModel planBlueprintModel = this.builderFactory.builder(PlanBlueprintCommonModelBuilder.class).authorize(AuthorizationFlags.AllExceptPublic).build(planBlueprintQuery.first());
if (planBlueprintModel == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{planCommonModelConfig.getBlueprintId(), PlanBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale()));
DmpImportModel dmpImportModel = new DmpImportModel();
dmpImportModel.setBlueprintModel(dmpBlueprintModel);
PlanImportModel planImportModel = new PlanImportModel();
planImportModel.setBlueprintModel(planBlueprintModel);
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();
@ -351,7 +351,7 @@ public class FileTransformerServiceImpl implements FileTransformerService {
}
}
dmpImportModel.setDescriptions(descriptionImportModels);
planImportModel.setDescriptions(descriptionImportModels);
}
String originalFileName = tempFile.getName() + (tempFile.getExtension().startsWith(".") ? "" : ".") + tempFile.getExtension();
@ -374,13 +374,13 @@ public class FileTransformerServiceImpl implements FileTransformerService {
fileEnvelope.setFileRef(storageFile.getFileRef());
}
dmpImportModel.setFile(fileEnvelope);
planImportModel.setFile(fileEnvelope);
return repository.importDmp(dmpImportModel);
return repository.importPlan(planImportModel);
}
@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);
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());
}
return repository.preprocessingDmp(fileEnvelope);
return repository.preprocessingPlan(fileEnvelope);
}
}

View File

@ -7,7 +7,7 @@ import gr.cite.tools.exception.MyValidationException;
import gr.cite.tools.fieldset.FieldSet;
import jakarta.xml.bind.JAXBException;
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.PlanValidationResult;
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;
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;
}

View File

@ -21,19 +21,19 @@ import org.jetbrains.annotations.NotNull;
import org.opencdmp.authorization.AuthorizationFlags;
import org.opencdmp.authorization.Permission;
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.description.DescriptionModel;
import org.opencdmp.commonmodels.models.dmp.DmpBlueprintValueModel;
import org.opencdmp.commonmodels.models.dmp.DmpContactModel;
import org.opencdmp.commonmodels.models.dmp.DmpModel;
import org.opencdmp.commonmodels.models.dmp.DmpPropertiesModel;
import org.opencdmp.commonmodels.models.dmpblueprint.ExtraFieldModel;
import org.opencdmp.commonmodels.models.dmpblueprint.FieldModel;
import org.opencdmp.commonmodels.models.dmpblueprint.ReferenceTypeFieldModel;
import org.opencdmp.commonmodels.models.dmpblueprint.SectionModel;
import org.opencdmp.commonmodels.models.dmpdescriptiontemplate.DmpDescriptionTemplateModel;
import org.opencdmp.commonmodels.models.dmpreference.DmpReferenceModel;
import org.opencdmp.commonmodels.models.plan.PlanBlueprintValueModel;
import org.opencdmp.commonmodels.models.plan.PlanContactModel;
import org.opencdmp.commonmodels.models.plan.PlanModel;
import org.opencdmp.commonmodels.models.plan.PlanPropertiesModel;
import org.opencdmp.commonmodels.models.planblueprint.ExtraFieldModel;
import org.opencdmp.commonmodels.models.planblueprint.FieldModel;
import org.opencdmp.commonmodels.models.planblueprint.ReferenceTypeFieldModel;
import org.opencdmp.commonmodels.models.planblueprint.SectionModel;
import org.opencdmp.commonmodels.models.plandescriptiontemplate.PlanDescriptionTemplateModel;
import org.opencdmp.commonmodels.models.planreference.PlanReferenceModel;
import org.opencdmp.commonmodels.models.reference.ReferenceModel;
import org.opencdmp.commons.JsonHandlingService;
import org.opencdmp.commons.XmlHandlingService;
@ -64,7 +64,7 @@ import org.opencdmp.data.*;
import org.opencdmp.errorcode.ErrorThesaurusProperties;
import org.opencdmp.event.PlanTouchedEvent;
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.annotationentitytouch.AnnotationEntityTouchedIntegrationEventHandler;
import org.opencdmp.integrationevent.outbox.notification.NotifyIntegrationEvent;
@ -931,7 +931,7 @@ public class PlanServiceImpl implements PlanService {
if (persist.getPlanBlueprintValues() != null && !persist.getPlanBlueprintValues().isEmpty()){
data.setPlanBlueprintValues(new ArrayList<>());
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;
@ -947,7 +947,7 @@ public class PlanServiceImpl implements PlanService {
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();
if (persist == null || definition == null) return data;
@ -1266,11 +1266,11 @@ public class PlanServiceImpl implements PlanService {
persist.setAccessType(data.getAccessType());
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<>());
for (PlanUserEntity user: dmpUserEntities) {
for (PlanUserEntity user: planUserEntities) {
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());
List<PlanDescriptionTemplateEntity> dmpDescriptionTemplateEntities = this.queryFactory.query(PlanDescriptionTemplateQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).planIds(data.getId()).isActive(IsActive.Active).collect();
if (!this.conventionService.isListNullOrEmpty(dmpDescriptionTemplateEntities)){
List<PlanDescriptionTemplateEntity> planDescriptionTemplateEntities = this.queryFactory.query(PlanDescriptionTemplateQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).planIds(data.getId()).isActive(IsActive.Active).collect();
if (!this.conventionService.isListNullOrEmpty(planDescriptionTemplateEntities)){
persist.setDescriptionTemplates(new ArrayList<>());
for (PlanDescriptionTemplateEntity descriptionTemplateEntity: dmpDescriptionTemplateEntities) {
for (PlanDescriptionTemplateEntity descriptionTemplateEntity: planDescriptionTemplateEntities) {
persist.getDescriptionTemplates().add(this.buildPlanDescriptionTemplatePersists(descriptionTemplateEntity));
}
}
@ -2053,14 +2053,14 @@ public class PlanServiceImpl implements PlanService {
//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);
}
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));
DmpModel model = this.fileTransformerService.importPlan(planCommonModelConfig);
PlanModel model = this.fileTransformerService.importPlan(planCommonModelConfig);
if (model == null) throw new MyNotFoundException("Plan Import Error");
PlanPersist persist = new PlanPersist();
@ -2093,10 +2093,10 @@ public class PlanServiceImpl implements PlanService {
return plan;
}
private List<PlanDescriptionTemplatePersist> commonModelPlanDescriptionTemplatesToPersist(DmpModel commonModel){
private List<PlanDescriptionTemplatePersist> commonModelPlanDescriptionTemplatesToPersist(PlanModel commonModel){
if (!this.conventionService.isListNullOrEmpty(commonModel.getDescriptionTemplates())) {
List<PlanDescriptionTemplatePersist> descriptionTemplates = new ArrayList<>();
for (DmpDescriptionTemplateModel descriptionTemplate : commonModel.getDescriptionTemplates()) {
for (PlanDescriptionTemplateModel descriptionTemplate : commonModel.getDescriptionTemplates()) {
descriptionTemplates.add(this.commonModelPlanDescriptionTemplateToPersist(descriptionTemplate));
}
return descriptionTemplates.stream().filter(Objects::nonNull).toList();
@ -2104,7 +2104,7 @@ public class PlanServiceImpl implements PlanService {
return null;
}
private PlanDescriptionTemplatePersist commonModelPlanDescriptionTemplateToPersist(DmpDescriptionTemplateModel commonModel) {
private PlanDescriptionTemplatePersist commonModelPlanDescriptionTemplateToPersist(PlanDescriptionTemplateModel commonModel) {
if (commonModel == null)
return null;
@ -2116,21 +2116,21 @@ public class PlanServiceImpl implements PlanService {
return persist;
}
private UUID commonModelPlanBlueprintToPersist(DmpModel planXml) throws JAXBException, InvalidApplicationException, ParserConfigurationException, IOException, TransformerException, InstantiationException, IllegalAccessException, SAXException {
if (planXml.getDmpBlueprint() != null){
PlanBlueprintEntity planBlueprintEntity = this.queryFactory.query(PlanBlueprintQuery.class).disableTracking().ids(planXml.getDmpBlueprint().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();
private UUID commonModelPlanBlueprintToPersist(PlanModel planXml) throws JAXBException, InvalidApplicationException, ParserConfigurationException, IOException, TransformerException, InstantiationException, IllegalAccessException, SAXException {
if (planXml.getPlanBlueprint() != null){
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.getPlanBlueprint().getGroupId()).versionStatuses(PlanBlueprintVersionStatus.Current).isActive(IsActive.Active).statuses(PlanBlueprintStatus.Finalized).first();
if (planBlueprintEntity != null){
return planBlueprintEntity.getId();
} 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 null;
}
private PlanPropertiesPersist commonModelPlanPropertiesToPersist(DmpModel commonModel) {
private PlanPropertiesPersist commonModelPlanPropertiesToPersist(PlanModel commonModel) {
if (commonModel == null || commonModel.getProperties() == null) return null;
PlanPropertiesPersist persist = new PlanPropertiesPersist();
@ -2140,10 +2140,10 @@ public class PlanServiceImpl implements PlanService {
return persist;
}
private List<PlanContactPersist> commonModelToPlanContactPersist(DmpPropertiesModel commonModel){
private List<PlanContactPersist> commonModelToPlanContactPersist(PlanPropertiesModel commonModel){
if (!this.conventionService.isListNullOrEmpty(commonModel.getContacts())) {
List<PlanContactPersist> contacts = new ArrayList<>();
for (DmpContactModel contact : commonModel.getContacts()) {
for (PlanContactModel contact : commonModel.getContacts()) {
contacts.add(this.commonModelPlanContactToPersist(contact));
}
return contacts;
@ -2151,27 +2151,27 @@ public class PlanServiceImpl implements PlanService {
return null;
}
private Map<UUID, PlanBlueprintValuePersist> commonModelToPlanBlueprintValuePersist(DmpModel commonModel){
if (commonModel.getDmpBlueprint() != null && commonModel.getDmpBlueprint().getDefinition() != null && !this.conventionService.isListNullOrEmpty(commonModel.getDmpBlueprint().getDefinition().getSections())) {
private Map<UUID, PlanBlueprintValuePersist> commonModelToPlanBlueprintValuePersist(PlanModel commonModel){
if (commonModel.getPlanBlueprint() != null && commonModel.getPlanBlueprint().getDefinition() != null && !this.conventionService.isListNullOrEmpty(commonModel.getPlanBlueprint().getDefinition().getSections())) {
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)){
for (SectionModel section : sections) {
if (!this.conventionService.isListNullOrEmpty(section.getFields())){
for (FieldModel field : section.getFields()) {
// 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;
List<DmpReferenceModel> dmpReferencesByField = commonModel.getReferences().stream().filter(x -> x.getData() != null && x.getData().getBlueprintFieldId().equals(referenceField.getId())).collect(Collectors.toList());
if (!this.conventionService.isListNullOrEmpty(dmpReferencesByField)){
planBlueprintValues.put(referenceField.getId(), this.commonModelPlanReferenceFieldToPlanBlueprintValuePersist(referenceField, dmpReferencesByField));
List<PlanReferenceModel> planReferencesByField = commonModel.getReferences().stream().filter(x -> x.getData() != null && x.getData().getBlueprintFieldId().equals(referenceField.getId())).collect(Collectors.toList());
if (!this.conventionService.isListNullOrEmpty(planReferencesByField)){
planBlueprintValues.put(referenceField.getId(), this.commonModelPlanReferenceFieldToPlanBlueprintValuePersist(referenceField, planReferencesByField));
}
} else {
// custom fields
if (field.getCategory().equals(org.opencdmp.commonmodels.enums.DmpBlueprintFieldCategory.Extra) && commonModel.getProperties() != null && !this.conventionService.isListNullOrEmpty(commonModel.getProperties().getDmpBlueprintValues())){
DmpBlueprintValueModel dmpBlueprintValueModel = commonModel.getProperties().getDmpBlueprintValues().stream().filter(x -> x.getFieldId().equals(field.getId())).findFirst().orElse(null);
if (field.getCategory().equals(org.opencdmp.commonmodels.enums.PlanBlueprintFieldCategory.Extra) && commonModel.getProperties() != null && !this.conventionService.isListNullOrEmpty(commonModel.getProperties().getPlanBlueprintValues())){
PlanBlueprintValueModel planBlueprintValueModel = commonModel.getProperties().getPlanBlueprintValues().stream().filter(x -> x.getFieldId().equals(field.getId())).findFirst().orElse(null);
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;
}
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)
return null;
@ -2196,7 +2196,7 @@ public class PlanServiceImpl implements PlanService {
persist.setFieldId(model.getId());
if (model.getMultipleSelect()){
List<ReferencePersist> references = new ArrayList<>();
for (DmpReferenceModel planReference : planReferences) {
for (PlanReferenceModel planReference : planReferences) {
references.add(this.commonPlanReferenceToReferencePersist(planReference.getReference(), referenceTypeEntity));
}
persist.setReferences(references);
@ -2239,7 +2239,7 @@ public class PlanServiceImpl implements PlanService {
return persist;
}
private PlanBlueprintValuePersist commonModelPlanBlueprintValueToPersist(DmpBlueprintValueModel commonModel, ExtraFieldModel extraFieldModel) {
private PlanBlueprintValuePersist commonModelPlanBlueprintValueToPersist(PlanBlueprintValueModel commonModel, ExtraFieldModel extraFieldModel) {
if (commonModel == null || extraFieldModel == null)
return null;
PlanBlueprintValuePersist persist = new PlanBlueprintValuePersist();
@ -2255,22 +2255,22 @@ public class PlanServiceImpl implements PlanService {
return persist;
}
private List<PlanUserPersist> commonModelToPlanUsersPersist(DmpModel commonModel){
private List<PlanUserPersist> commonModelToPlanUsersPersist(PlanModel commonModel){
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<PlanUserPersist> dmpUsers = new ArrayList<>();
for (DmpUserModel user : commonModel.getUsers()) {
dmpUsers.add(this.commonModelPlanUserToPersist(user, userIds));
List<PlanUserPersist> planUsers = new ArrayList<>();
for (PlanUserModel user : commonModel.getUsers()) {
planUsers.add(this.commonModelPlanUserToPersist(user, userIds));
}
return dmpUsers;
return planUsers;
}
return null;
}
private PlanUserPersist commonModelPlanUserToPersist(DmpUserModel commonModel, List<UUID> userIds) {
private PlanUserPersist commonModelPlanUserToPersist(PlanUserModel commonModel, List<UUID> userIds) {
if (commonModel == null)
return null;
@ -2293,7 +2293,7 @@ public class PlanServiceImpl implements PlanService {
return null;
}
private PlanContactPersist commonModelPlanContactToPersist(DmpContactModel commonModel) {
private PlanContactPersist commonModelPlanContactToPersist(PlanContactModel commonModel) {
if (commonModel == null)
return null;

View File

@ -7,7 +7,7 @@ import gr.cite.tools.exception.MyNotFoundException;
import gr.cite.tools.exception.MyValidationException;
import gr.cite.tools.fieldset.FieldSet;
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.types.planblueprint.importexport.BlueprintImportExport;
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(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;
}

View File

@ -18,7 +18,7 @@ import jakarta.xml.bind.JAXBException;
import org.jetbrains.annotations.NotNull;
import org.opencdmp.authorization.AuthorizationFlags;
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.enums.*;
import org.opencdmp.commons.scope.tenant.TenantScope;
@ -809,7 +809,7 @@ public class PlanBlueprintServiceImpl implements PlanBlueprintService {
//region Import Common Model
@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));
this.authorizationService.authorizeForce(Permission.ImportPlanBlueprint);
@ -872,13 +872,13 @@ public class PlanBlueprintServiceImpl implements PlanBlueprintService {
persist.setHasTemplates(commonModel.getHasTemplates());
List<FieldPersist> planBlueprintFieldModels = new LinkedList<>();
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));
}
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));
}
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));
}
}

View File

@ -30,7 +30,7 @@ import org.opencdmp.controllers.swagger.annotation.OperationWithTenantHeader;
import org.opencdmp.controllers.swagger.annotation.Swagger400;
import org.opencdmp.controllers.swagger.annotation.Swagger404;
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.PlanUser;
import org.opencdmp.model.PlanValidationResult;
@ -499,17 +499,17 @@ public class PlanController {
@OperationWithTenantHeader(summary = "Preprocess a plan from a json file", description = "",
responses = @ApiResponse(description = "OK", responseCode = "200", content = @Content(
schema = @Schema(
implementation = PreprocessingDmpModel.class
implementation = PreprocessingPlanModel.class
))
))
@Transactional
public PreprocessingDmpModel preprocessing(
public PreprocessingPlanModel preprocessing(
@RequestParam("fileId") UUID fileId,
@RequestParam("repositoryId") String repositoryId
) 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));
PreprocessingDmpModel model = this.planService.preprocessingPlan(fileId, repositoryId);
PreprocessingPlanModel model = this.planService.preprocessingPlan(fileId, repositoryId);
this.auditService.track(AuditableAction.Plan_Import, Map.ofEntries(
new AbstractMap.SimpleEntry<String, Object>("transformerId", repositoryId),