diff --git a/backend/core/pom.xml b/backend/core/pom.xml index ed69c9b3c..5860e512b 100644 --- a/backend/core/pom.xml +++ b/backend/core/pom.xml @@ -51,12 +51,12 @@ org.opencdmp repositorydepositbase - 2.0.15 + 2.0.16 org.opencdmp common-models - 0.0.18 + 0.0.19 gr.cite @@ -66,7 +66,7 @@ org.opencdmp file-transformer-base - 0.0.23 + 0.0.24 gr.cite diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/PlanUserCommonModelBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/PlanUserCommonModelBuilder.java index b14524959..27d945528 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/PlanUserCommonModelBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/PlanUserCommonModelBuilder.java @@ -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 { +public class PlanUserCommonModelBuilder extends BaseCommonModelBuilder { private final BuilderFactory builderFactory; @@ -47,7 +47,7 @@ public class PlanUserCommonModelBuilder extends BaseCommonModelBuilder> buildInternal(List data) throws MyApplicationException { + protected List> buildInternal(List 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 userItemsMap = this.collectUsers(data); - List> models = new ArrayList<>(); + List> 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())); diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/description/DescriptionCommonModelBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/description/DescriptionCommonModelBuilder.java index 6afc75412..1abf5fe1e 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/description/DescriptionCommonModelBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/description/DescriptionCommonModelBuilder.java @@ -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(); Map descriptionTemplates = this.collectDescriptionTemplates(data); - Map plans = this.collectPlans(data); + Map plans = this.collectPlans(data); Map definitionEntityMap = this.collectDescriptionTemplateDefinitions(data); Map planDescriptionTemplateSections = this.collectPlanDescriptionTemplateSections(data); @@ -106,7 +106,7 @@ public class DescriptionCommonModelBuilder extends BaseCommonModelBuilder collectPlans(List data) throws MyApplicationException { + private Map collectPlans(List 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 itemMap; + Map 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); diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/descriptiontemplate/fielddata/BaseFieldDataCommonModelBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/descriptiontemplate/fielddata/BaseFieldDataCommonModelBuilder.java index e35b93f53..522655302 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/descriptiontemplate/fielddata/BaseFieldDataCommonModelBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/descriptiontemplate/fielddata/BaseFieldDataCommonModelBuilder.java @@ -53,7 +53,7 @@ public abstract class BaseFieldDataCommonModelBuilder 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); diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/plan/PlanBlueprintValueCommonModelBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/plan/PlanBlueprintValueCommonModelBuilder.java index 827519b3a..c4bfa6684 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/plan/PlanBlueprintValueCommonModelBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/plan/PlanBlueprintValueCommonModelBuilder.java @@ -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 { +public class PlanBlueprintValueCommonModelBuilder extends BaseCommonModelBuilder { private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); private DefinitionEntity definition; @@ -48,17 +48,17 @@ public class PlanBlueprintValueCommonModelBuilder extends BaseCommonModelBuilder } @Override - protected List> buildInternal(List data) throws MyApplicationException { + protected List> buildInternal(List 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> models = new ArrayList<>(); + List> 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()); diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/plan/PlanCommonModelBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/plan/PlanCommonModelBuilder.java index 6d90cbe54..611de965c 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/plan/PlanCommonModelBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/plan/PlanCommonModelBuilder.java @@ -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 { +public class PlanCommonModelBuilder extends BaseCommonModelBuilder { private final QueryFactory queryFactory; @@ -103,22 +103,22 @@ public class PlanCommonModelBuilder extends BaseCommonModelBuilder> buildInternal(List data) throws MyApplicationException { + protected List> buildInternal(List 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> models = new ArrayList<>(); + List> models = new ArrayList<>(); - Map> planReferencesMap = this.collectPlanReferences(data); - Map> planUsersMap = this.collectPlanUsers(data); + Map> planReferencesMap = this.collectPlanReferences(data); + Map> planUsersMap = this.collectPlanUsers(data); Map> descriptionsMap = this.disableDescriptions ? null : this.collectPlanDescriptions(data); Map> entityDois = this.collectPlanEntityDois(data); Map creators = this.collectCreators(data); - Map planBlueprints = this.collectPlanBlueprints(data); + Map planBlueprints = this.collectPlanBlueprints(data); Map 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 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 (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> collectPlanUsers(List data) throws MyApplicationException { + private Map> collectPlanUsers(List data) throws MyApplicationException { this.logger.debug("checking related - {}", PlanUser.class.getSimpleName()); - Map> itemMap; + Map> 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> collectPlanReferences(List data) throws MyApplicationException { + private Map> collectPlanReferences(List data) throws MyApplicationException { this.logger.debug("checking related - {}", PlanReference.class.getSimpleName()); - Map> itemMap; + Map> 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 collectPlanBlueprints(List data) throws MyApplicationException { + private Map collectPlanBlueprints(List 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 itemMap; + Map 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; diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/plan/PlanContactCommonModelBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/plan/PlanContactCommonModelBuilder.java index 6de7a490a..43ef72f3f 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/plan/PlanContactCommonModelBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/plan/PlanContactCommonModelBuilder.java @@ -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 { +public class PlanContactCommonModelBuilder extends BaseCommonModelBuilder { private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); private final BuilderFactory builderFactory; @@ -41,13 +41,13 @@ public class PlanContactCommonModelBuilder extends BaseCommonModelBuilder> buildInternal(List data) throws MyApplicationException { + protected List> buildInternal(List 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> models = new ArrayList<>(); + List> 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()); diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/plan/PlanPropertiesCommonModelBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/plan/PlanPropertiesCommonModelBuilder.java index 8c22130f2..a8837c27c 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/plan/PlanPropertiesCommonModelBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/plan/PlanPropertiesCommonModelBuilder.java @@ -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 { +public class PlanPropertiesCommonModelBuilder extends BaseCommonModelBuilder { private final BuilderFactory builderFactory; private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); private DefinitionEntity definition; @@ -46,14 +46,14 @@ public class PlanPropertiesCommonModelBuilder extends BaseCommonModelBuilder> buildInternal(List data) throws MyApplicationException { + protected List> buildInternal(List 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> models = new ArrayList<>(); + List> 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)); diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planblueprint/DefinitionCommonModelBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planblueprint/DefinitionCommonModelBuilder.java index 66f93e5d9..bdeb8b9b5 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planblueprint/DefinitionCommonModelBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planblueprint/DefinitionCommonModelBuilder.java @@ -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; diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planblueprint/ExtraFieldCommonModelBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planblueprint/ExtraFieldCommonModelBuilder.java index 51f958091..fab9c830e 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planblueprint/ExtraFieldCommonModelBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planblueprint/ExtraFieldCommonModelBuilder.java @@ -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 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; diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planblueprint/FieldCommonModelBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planblueprint/FieldCommonModelBuilder.java index 9bcbcfcb4..0c4c29d90 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planblueprint/FieldCommonModelBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planblueprint/FieldCommonModelBuilder.java @@ -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 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()); diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planblueprint/PlanBlueprintCommonModelBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planblueprint/PlanBlueprintCommonModelBuilder.java index 6ca616e34..51eab96b7 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planblueprint/PlanBlueprintCommonModelBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planblueprint/PlanBlueprintCommonModelBuilder.java @@ -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 { +public class PlanBlueprintCommonModelBuilder extends BaseCommonModelBuilder { private final BuilderFactory builderFactory; private final XmlHandlingService xmlHandlingService; @@ -44,21 +44,21 @@ public class PlanBlueprintCommonModelBuilder extends BaseCommonModelBuilder> buildInternal(List data) throws MyApplicationException { + protected List> buildInternal(List 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> models = new ArrayList<>(); + List> 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){ diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planblueprint/ReferenceTypeFieldCommonModelBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planblueprint/ReferenceTypeFieldCommonModelBuilder.java index 2a3fce7ca..23415bb95 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planblueprint/ReferenceTypeFieldCommonModelBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planblueprint/ReferenceTypeFieldCommonModelBuilder.java @@ -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; diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planblueprint/SectionCommonModelBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planblueprint/SectionCommonModelBuilder.java index 5dba895b3..908ec57f6 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planblueprint/SectionCommonModelBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planblueprint/SectionCommonModelBuilder.java @@ -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; diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planblueprint/SystemFieldCommonModelBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planblueprint/SystemFieldCommonModelBuilder.java index ab6cb0b9f..f6da49afd 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planblueprint/SystemFieldCommonModelBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planblueprint/SystemFieldCommonModelBuilder.java @@ -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 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; diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planreference/PlanReferenceCommonModelBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planreference/PlanReferenceCommonModelBuilder.java index 5adacde97..93a09be40 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planreference/PlanReferenceCommonModelBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planreference/PlanReferenceCommonModelBuilder.java @@ -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 { +public class PlanReferenceCommonModelBuilder extends BaseCommonModelBuilder { private final BuilderFactory builderFactory; private final QueryFactory queryFactory; @@ -50,14 +50,14 @@ public class PlanReferenceCommonModelBuilder extends BaseCommonModelBuilder> buildInternal(List data) throws MyApplicationException { + protected List> buildInternal(List 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 referenceModelMap = this.collectReferences(data); - List> models = new ArrayList<>(); + List> 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()); diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planreference/PlanReferenceDataCommonModelBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planreference/PlanReferenceDataCommonModelBuilder.java index 746572554..cda48995a 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planreference/PlanReferenceDataCommonModelBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planreference/PlanReferenceDataCommonModelBuilder.java @@ -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 { +public class PlanReferenceDataCommonModelBuilder extends BaseCommonModelBuilder { private final BuilderFactory builderFactory; private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); @@ -40,13 +40,13 @@ public class PlanReferenceDataCommonModelBuilder extends BaseCommonModelBuilder< } @Override - protected List> buildInternal(List data) throws MyApplicationException { + protected List> buildInternal(List 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> models = new ArrayList<>(); + List> 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)); } diff --git a/backend/core/src/main/java/org/opencdmp/service/deposit/DepositClientImpl.java b/backend/core/src/main/java/org/opencdmp/service/deposit/DepositClientImpl.java index 33b345917..8ff3959e1 100644 --- a/backend/core/src/main/java/org/opencdmp/service/deposit/DepositClientImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/deposit/DepositClientImpl.java @@ -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 diff --git a/backend/core/src/main/java/org/opencdmp/service/deposit/DepositServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/deposit/DepositServiceImpl.java index fcbd448dd..26c68fda4 100644 --- a/backend/core/src/main/java/org/opencdmp/service/deposit/DepositServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/deposit/DepositServiceImpl.java @@ -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); diff --git a/backend/core/src/main/java/org/opencdmp/service/descriptiontemplate/DescriptionTemplateServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/descriptiontemplate/DescriptionTemplateServiceImpl.java index 4b1ac610a..6718c6787 100644 --- a/backend/core/src/main/java/org/opencdmp/service/descriptiontemplate/DescriptionTemplateServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/descriptiontemplate/DescriptionTemplateServiceImpl.java @@ -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; diff --git a/backend/core/src/main/java/org/opencdmp/service/filetransformer/FileTransformerRepository.java b/backend/core/src/main/java/org/opencdmp/service/filetransformer/FileTransformerRepository.java index 035949b8d..f0af05a4e 100644 --- a/backend/core/src/main/java/org/opencdmp/service/filetransformer/FileTransformerRepository.java +++ b/backend/core/src/main/java/org/opencdmp/service/filetransformer/FileTransformerRepository.java @@ -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 diff --git a/backend/core/src/main/java/org/opencdmp/service/filetransformer/FileTransformerService.java b/backend/core/src/main/java/org/opencdmp/service/filetransformer/FileTransformerService.java index 766acf1db..4aaf45cb8 100644 --- a/backend/core/src/main/java/org/opencdmp/service/filetransformer/FileTransformerService.java +++ b/backend/core/src/main/java/org/opencdmp/service/filetransformer/FileTransformerService.java @@ -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; } diff --git a/backend/core/src/main/java/org/opencdmp/service/filetransformer/FileTransformerServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/filetransformer/FileTransformerServiceImpl.java index 03e1cbeec..c9e63b715 100644 --- a/backend/core/src/main/java/org/opencdmp/service/filetransformer/FileTransformerServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/filetransformer/FileTransformerServiceImpl.java @@ -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 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); } } diff --git a/backend/core/src/main/java/org/opencdmp/service/plan/PlanService.java b/backend/core/src/main/java/org/opencdmp/service/plan/PlanService.java index df39a64b4..71c39bf35 100644 --- a/backend/core/src/main/java/org/opencdmp/service/plan/PlanService.java +++ b/backend/core/src/main/java/org/opencdmp/service/plan/PlanService.java @@ -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; } diff --git a/backend/core/src/main/java/org/opencdmp/service/plan/PlanServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/plan/PlanServiceImpl.java index e40b3f5e8..485112522 100644 --- a/backend/core/src/main/java/org/opencdmp/service/plan/PlanServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/plan/PlanServiceImpl.java @@ -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 dmpUserEntities = this.queryFactory.query(PlanUserQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).planIds(data.getId()).isActives(IsActive.Active).collect(); + List 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 dmpDescriptionTemplateEntities = this.queryFactory.query(PlanDescriptionTemplateQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).planIds(data.getId()).isActive(IsActive.Active).collect(); - if (!this.conventionService.isListNullOrEmpty(dmpDescriptionTemplateEntities)){ + List 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 commonModelPlanDescriptionTemplatesToPersist(DmpModel commonModel){ + private List commonModelPlanDescriptionTemplatesToPersist(PlanModel commonModel){ if (!this.conventionService.isListNullOrEmpty(commonModel.getDescriptionTemplates())) { List 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 commonModelToPlanContactPersist(DmpPropertiesModel commonModel){ + private List commonModelToPlanContactPersist(PlanPropertiesModel commonModel){ if (!this.conventionService.isListNullOrEmpty(commonModel.getContacts())) { List 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 commonModelToPlanBlueprintValuePersist(DmpModel commonModel){ - if (commonModel.getDmpBlueprint() != null && commonModel.getDmpBlueprint().getDefinition() != null && !this.conventionService.isListNullOrEmpty(commonModel.getDmpBlueprint().getDefinition().getSections())) { + private Map commonModelToPlanBlueprintValuePersist(PlanModel commonModel){ + if (commonModel.getPlanBlueprint() != null && commonModel.getPlanBlueprint().getDefinition() != null && !this.conventionService.isListNullOrEmpty(commonModel.getPlanBlueprint().getDefinition().getSections())) { Map planBlueprintValues = new HashMap<>(); - List sections = commonModel.getDmpBlueprint().getDefinition().getSections(); + List 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 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 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 planReferences) { + private PlanBlueprintValuePersist commonModelPlanReferenceFieldToPlanBlueprintValuePersist(ReferenceTypeFieldModel model, List 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 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 commonModelToPlanUsersPersist(DmpModel commonModel){ + private List commonModelToPlanUsersPersist(PlanModel commonModel){ if (!this.conventionService.isListNullOrEmpty(commonModel.getUsers())) { - List 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 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 userIds = users == null ? new ArrayList<>() : users.stream().map(UserEntity::getId).collect(Collectors.toList()); - List dmpUsers = new ArrayList<>(); - for (DmpUserModel user : commonModel.getUsers()) { - dmpUsers.add(this.commonModelPlanUserToPersist(user, userIds)); + List 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 userIds) { + private PlanUserPersist commonModelPlanUserToPersist(PlanUserModel commonModel, List 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; diff --git a/backend/core/src/main/java/org/opencdmp/service/planblueprint/PlanBlueprintService.java b/backend/core/src/main/java/org/opencdmp/service/planblueprint/PlanBlueprintService.java index d0c96d1e1..6f7b48a0e 100644 --- a/backend/core/src/main/java/org/opencdmp/service/planblueprint/PlanBlueprintService.java +++ b/backend/core/src/main/java/org/opencdmp/service/planblueprint/PlanBlueprintService.java @@ -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; } diff --git a/backend/core/src/main/java/org/opencdmp/service/planblueprint/PlanBlueprintServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/planblueprint/PlanBlueprintServiceImpl.java index 722357d2c..ec1bc973f 100644 --- a/backend/core/src/main/java/org/opencdmp/service/planblueprint/PlanBlueprintServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/planblueprint/PlanBlueprintServiceImpl.java @@ -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 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)); } } diff --git a/backend/web/src/main/java/org/opencdmp/controllers/PlanController.java b/backend/web/src/main/java/org/opencdmp/controllers/PlanController.java index bd83e4e7d..21dd17228 100644 --- a/backend/web/src/main/java/org/opencdmp/controllers/PlanController.java +++ b/backend/web/src/main/java/org/opencdmp/controllers/PlanController.java @@ -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("transformerId", repositoryId),