From 4219d9003951900e22323d8e02e256a267ea8bf1 Mon Sep 17 00:00:00 2001 From: Aldo Mihasi Date: Mon, 11 Sep 2023 08:57:09 +0300 Subject: [PATCH] add "DmpSectionIndex" column to descriptions in order to know in which section of a dmp the description belongs, add "data" column in DmpDatasetProfile table, data stores in which sections a description template is saved --- .../data/dao/entities/DatasetProfileDao.java | 3 +- .../dao/entities/DatasetProfileDaoImpl.java | 4 +- .../main/java/eu/eudat/data/entities/DMP.java | 10 +- .../data/entities/DMPDatasetProfile.java | 77 ++++ .../java/eu/eudat/data/entities/Dataset.java | 10 + .../data/entities/DescriptionTemplate.java | 8 +- .../managers/DataManagementPlanManager.java | 4 +- .../datasetwizard/DatasetWizardModel.java | 11 + .../models/data/dmp/AssociatedProfile.java | 10 + .../models/data/dmp/DataManagementPlan.java | 33 +- .../dmp/DataManagementPlanEditorModel.java | 23 +- .../DataManagementPlanNewVersionModel.java | 15 +- .../DataManagementPlanOverviewModel.java | 18 +- .../AssociatedProfilePublicModel.java | 10 + .../DataManagementPlanPublicModel.java | 14 +- dmp-db-scema/main/dmp-dump.sql | 4 +- ...olumn_to_Dataset_and_DMPDatasetProfile.sql | 15 + .../app/core/model/dataset/dataset-wizard.ts | 1 + ...dmp-dataset-profile-sections-form.model.ts | 28 ++ .../dmp-dataset-profile.ts | 7 + dmp-frontend/src/app/core/model/dmp/dmp.ts | 8 +- .../dataset-wizard-editor.model.ts | 4 + .../dataset-wizard.component.ts | 4 + .../src/app/ui/dataset/dataset.routing.ts | 2 +- .../dmp-editor-blueprint.component.html | 350 ++++++++++-------- .../dmp-editor-blueprint.component.scss | 18 + .../dmp-editor-blueprint.component.ts | 45 ++- .../src/app/ui/dmp/editor/dmp-editor.model.ts | 8 +- .../ui/dmp/wizard/dmp-wizard-editor.model.ts | 3 +- 29 files changed, 535 insertions(+), 212 deletions(-) create mode 100644 dmp-backend/data/src/main/java/eu/eudat/data/entities/DMPDatasetProfile.java create mode 100644 dmp-db-scema/updates/00.00.015_Add_new_column_to_Dataset_and_DMPDatasetProfile.sql create mode 100644 dmp-frontend/src/app/core/model/dmp/dmp-dataset-profile/dmp-dataset-profile-sections-form.model.ts create mode 100644 dmp-frontend/src/app/core/model/dmp/dmp-dataset-profile/dmp-dataset-profile.ts diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/DatasetProfileDao.java b/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/DatasetProfileDao.java index 5365067fc..35f508436 100644 --- a/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/DatasetProfileDao.java +++ b/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/DatasetProfileDao.java @@ -3,6 +3,7 @@ package eu.eudat.data.dao.entities; import eu.eudat.data.dao.DatabaseAccessLayer; import eu.eudat.data.dao.criteria.DatasetProfileCriteria; import eu.eudat.data.entities.DescriptionTemplate; +import eu.eudat.data.entities.DescriptionTemplateType; import eu.eudat.queryable.QueryableList; import java.util.List; @@ -18,6 +19,6 @@ public interface DatasetProfileDao extends DatabaseAccessLayer getAllIds(); - Long countWithType(UUID id); + Long countWithType(DescriptionTemplateType type); } \ No newline at end of file diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/DatasetProfileDaoImpl.java b/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/DatasetProfileDaoImpl.java index eae2be263..3ba9fe758 100644 --- a/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/DatasetProfileDaoImpl.java +++ b/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/DatasetProfileDaoImpl.java @@ -128,7 +128,7 @@ public class DatasetProfileDaoImpl extends DatabaseAccess i } @Override - public Long countWithType(UUID id) { - return this.getDatabaseService().getQueryable(DescriptionTemplate.class).where((builder, root) -> builder.equal(root.get("type"), id)).count(); + public Long countWithType(DescriptionTemplateType type) { + return this.getDatabaseService().getQueryable(DescriptionTemplate.class).where((builder, root) -> builder.equal(root.get("type"), type)).count(); } } diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/entities/DMP.java b/dmp-backend/data/src/main/java/eu/eudat/data/entities/DMP.java index 54beaeeb9..dcfbdb698 100644 --- a/dmp-backend/data/src/main/java/eu/eudat/data/entities/DMP.java +++ b/dmp-backend/data/src/main/java/eu/eudat/data/entities/DMP.java @@ -113,11 +113,7 @@ public class DMP implements DataEntity { @Column(name = "\"AssociatedDmps\"", columnDefinition = "xml", nullable = true) private String associatedDmps;*/ @OneToMany(fetch = FetchType.LAZY) - @JoinTable(name = "\"DMPDatasetProfile\"", - joinColumns = {@JoinColumn(name = "\"dmp\"", referencedColumnName = "\"ID\"")}, - inverseJoinColumns = {@JoinColumn(name = "\"datasetprofile\"", referencedColumnName = "\"ID\"")} - ) - private Set associatedDmps; + private Set associatedDmps; @ManyToOne(fetch = FetchType.LAZY) @@ -274,10 +270,10 @@ public class DMP implements DataEntity { this.grant = grant; } - public Set getAssociatedDmps() { + public Set getAssociatedDmps() { return associatedDmps; } - public void setAssociatedDmps(Set associatedDmps) { + public void setAssociatedDmps(Set associatedDmps) { this.associatedDmps = associatedDmps; } diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/entities/DMPDatasetProfile.java b/dmp-backend/data/src/main/java/eu/eudat/data/entities/DMPDatasetProfile.java new file mode 100644 index 000000000..8ee7a59fc --- /dev/null +++ b/dmp-backend/data/src/main/java/eu/eudat/data/entities/DMPDatasetProfile.java @@ -0,0 +1,77 @@ +package eu.eudat.data.entities; + +import eu.eudat.queryable.queryableentity.DataEntity; +import org.hibernate.annotations.GenericGenerator; +import org.hibernate.annotations.Type; + +import javax.persistence.*; +import java.util.List; +import java.util.UUID; + +@Entity +@Table(name = "\"DMPDatasetProfile\"") +public class DMPDatasetProfile implements DataEntity { + + @Id + @GeneratedValue + @GenericGenerator(name = "uuid2", strategy = "uuid2") + @Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)") + private UUID id; + + @ManyToOne + @JoinColumn(name = "\"dmp\"") + private DMP dmp; + + @ManyToOne + @JoinColumn(name = "\"datasetprofile\"") + private DescriptionTemplate datasetprofile; + + @Column(name = "\"data\"") + private String data; + + public UUID getId() { + return id; + } + public void setId(UUID id) { + this.id = id; + } + + public DMP getDmp() { + return dmp; + } + public void setDmp(DMP dmp) { + this.dmp = dmp; + } + + public DescriptionTemplate getDatasetprofile() { + return datasetprofile; + } + public void setDatasetprofile(DescriptionTemplate datasetprofile) { + this.datasetprofile = datasetprofile; + } + + public String getData() { + return data; + } + public void setData(String data) { + this.data = data; + } + + @Override + public void update(DMPDatasetProfile entity) { + this.dmp = entity.getDmp(); + this.datasetprofile = entity.getDatasetprofile(); + this.data = entity.getData(); + } + + @Override + public UUID getKeys() { + return this.id; + } + + @Override + public DMPDatasetProfile buildFromTuple(List tuple, List fields, String base) { + this.id = UUID.fromString((String) tuple.get(0).get(base.isEmpty() ? base + "." + "id" : "id")); + return this; + } +} diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/entities/Dataset.java b/dmp-backend/data/src/main/java/eu/eudat/data/entities/Dataset.java index 7456b21d8..357f49ec9 100644 --- a/dmp-backend/data/src/main/java/eu/eudat/data/entities/Dataset.java +++ b/dmp-backend/data/src/main/java/eu/eudat/data/entities/Dataset.java @@ -100,6 +100,9 @@ public class Dataset implements DataEntity { @JoinColumn(name = "\"DMP\"", nullable = false) private DMP dmp; + @Column(name = "\"DmpSectionIndex\"") + private Integer dmpSectionIndex; + @Column(name = "\"Uri\"") private String uri; @@ -232,6 +235,12 @@ public class Dataset implements DataEntity { this.dmp = dmp; } + public Integer getDmpSectionIndex() { + return dmpSectionIndex; + } + public void setDmpSectionIndex(Integer dmpSectionIndex) { + this.dmpSectionIndex = dmpSectionIndex; + } public String getUri() { return uri; @@ -328,6 +337,7 @@ public class Dataset implements DataEntity { this.setRegistries(entity.getRegistries()); this.setDmp(entity.getDmp()); + this.setDmpSectionIndex(entity.getDmpSectionIndex()); this.setStatus(entity.getStatus()); this.setProfile(entity.getProfile()); this.setModified(new Date()); diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/entities/DescriptionTemplate.java b/dmp-backend/data/src/main/java/eu/eudat/data/entities/DescriptionTemplate.java index c30018630..fdfd02b57 100644 --- a/dmp-backend/data/src/main/java/eu/eudat/data/entities/DescriptionTemplate.java +++ b/dmp-backend/data/src/main/java/eu/eudat/data/entities/DescriptionTemplate.java @@ -79,12 +79,8 @@ public class DescriptionTemplate implements DataEntity @Column(name = "\"Version\"", nullable = false) private Short version; - @ManyToMany(fetch = FetchType.LAZY) - @JoinTable(name = "\"DMPDatasetProfile\"", - joinColumns = {@JoinColumn(name = "\"datasetprofile\"", referencedColumnName = "\"ID\"")}, - inverseJoinColumns = {@JoinColumn(name = "\"dmp\"", referencedColumnName = "\"ID\"")} - ) - private List dmps; + @OneToMany(fetch = FetchType.LAZY) + private Set dmps; @Column(name = "\"Language\"", nullable = false) private String language; diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java index c112be774..6a68163cb 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java @@ -5,6 +5,7 @@ import eu.eudat.configurations.dynamicgrant.DynamicGrantConfiguration; import eu.eudat.configurations.dynamicgrant.entities.Property; import eu.eudat.data.dao.criteria.*; import eu.eudat.data.dao.entities.*; +import eu.eudat.data.entities.DescriptionTemplate; import eu.eudat.data.entities.Organisation; import eu.eudat.data.entities.Researcher; import eu.eudat.data.entities.*; @@ -1755,7 +1756,8 @@ public class DataManagementPlanManager { Element profiles = xmlDoc.createElement("profiles"); // Get DatasetProfiles from DMP to add to XML. - for (DescriptionTemplate descriptionTemplate : dmp.getAssociatedDmps()) { + for (DMPDatasetProfile dmpDescriptionProfile : dmp.getAssociatedDmps()) { + DescriptionTemplate descriptionTemplate = dmpDescriptionProfile.getDatasetprofile(); Element profile = xmlDoc.createElement("profile"); Element profileId = xmlDoc.createElement("profileId"); profileId.setTextContent(descriptionTemplate.getId().toString()); diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/datasetwizard/DatasetWizardModel.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/datasetwizard/DatasetWizardModel.java index bd3c0a429..439b673f6 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/datasetwizard/DatasetWizardModel.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/datasetwizard/DatasetWizardModel.java @@ -26,6 +26,7 @@ public class DatasetWizardModel implements DataModel registries; private List services; @@ -92,6 +93,13 @@ public class DatasetWizardModel implements DataModel new Service().fromDataModel(item.getService())).collect(Collectors.toList()) : new ArrayList<>(); this.created = entity.getCreated(); this.dmp = new DataManagementPlan().fromDataModelNoDatasets(entity.getDmp()); + this.dmpSectionIndex = entity.getDmpSectionIndex(); this.externalDatasets = entity.getDatasetExternalDatasets() != null ? entity.getDatasetExternalDatasets().stream().map(item -> { ExternalDatasetListingModel externalDatasetListingModel = new ExternalDatasetListingModel().fromDataModel(item.getExternalDataset()); if (item.getData() != null) { @@ -202,6 +211,7 @@ public class DatasetWizardModel implements DataModel new Registry().fromDataModel(item)).collect(Collectors.toList()) : new ArrayList<>(); this.dataRepositories = entity.getDatasetDataRepositories() != null ? entity.getDatasetDataRepositories().stream().map(item -> { DataRepository dataRepository = new DataRepository().fromDataModel(item.getDataRepository()); @@ -241,6 +251,7 @@ public class DatasetWizardModel implements DataModel { private UUID id; private String label; + private Map data; public UUID getId() { return id; @@ -28,6 +30,14 @@ public class AssociatedProfile implements XmlSerializable { this.label = label; } + public Map getData() { + return data; + } + + public void setData(Map data) { + this.data = data; + } + @Override public Element toXml(Document doc) { Element profile = doc.createElement("profile"); diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlan.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlan.java index f86cea599..2de902349 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlan.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlan.java @@ -1,5 +1,7 @@ package eu.eudat.models.data.dmp; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; import eu.eudat.data.entities.*; import eu.eudat.logic.utilities.builders.XmlBuilder; import eu.eudat.models.DataModel; @@ -258,8 +260,14 @@ public class DataManagementPlan implements DataModel { if (entity.getAssociatedDmps() != null && !entity.getAssociatedDmps().isEmpty()) { this.profiles = new LinkedList<>(); - for (DescriptionTemplate descriptionTemplate : entity.getAssociatedDmps()) { - AssociatedProfile associatedProfile = new AssociatedProfile().fromData(descriptionTemplate); + for (DMPDatasetProfile dmpDescriptionProfile : entity.getAssociatedDmps()) { + AssociatedProfile associatedProfile = new AssociatedProfile().fromData(dmpDescriptionProfile.getDatasetprofile()); + try { + associatedProfile.setData(new ObjectMapper().readValue(dmpDescriptionProfile.getData(), new TypeReference>() {})); + } + catch (Exception e) { + associatedProfile.setData(null); + } this.profiles.add(associatedProfile); } } @@ -320,11 +328,16 @@ public class DataManagementPlan implements DataModel { dataManagementPlanEntity.setProject(this.project.toDataModel()); } if (this.profiles != null) { - Set descriptionTemplates = new HashSet<>(); + Set dmpDatasetProfiles = new HashSet<>(); for (AssociatedProfile profile : this.profiles) { - descriptionTemplates.add(profile.toData()); + DMPDatasetProfile dmpDatasetProfile = new DMPDatasetProfile(); + dmpDatasetProfile.setId(UUID.randomUUID()); + dmpDatasetProfile.setDmp(dataManagementPlanEntity); + dmpDatasetProfile.setDatasetprofile(profile.toData()); + dmpDatasetProfile.setData(new ObjectMapper().writeValueAsString(profile.getData())); + dmpDatasetProfiles.add(dmpDatasetProfile); } - dataManagementPlanEntity.setAssociatedDmps(descriptionTemplates); + dataManagementPlanEntity.setAssociatedDmps(dmpDatasetProfiles); } dataManagementPlanEntity.setProperties(this.properties != null ? JSONObject.toJSONString(this.properties) : null); dataManagementPlanEntity.setGroupId(this.groupId != null ? this.groupId : UUID.randomUUID()); @@ -365,8 +378,14 @@ public class DataManagementPlan implements DataModel { if (entity.getAssociatedDmps() != null && !entity.getAssociatedDmps().isEmpty()) { this.profiles = new LinkedList<>(); - for (DescriptionTemplate descriptionTemplate : entity.getAssociatedDmps()) { - AssociatedProfile associatedProfile = new AssociatedProfile().fromData(descriptionTemplate); + for (DMPDatasetProfile dmpDescriptionProfile : entity.getAssociatedDmps()) { + AssociatedProfile associatedProfile = new AssociatedProfile().fromData(dmpDescriptionProfile.getDatasetprofile()); + try { + associatedProfile.setData(new ObjectMapper().readValue(dmpDescriptionProfile.getData(), new TypeReference>() {})); + } + catch (Exception e) { + associatedProfile.setData(null); + } this.profiles.add(associatedProfile); } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlanEditorModel.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlanEditorModel.java index fc1cd7f84..1fde4e113 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlanEditorModel.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlanEditorModel.java @@ -1,5 +1,7 @@ package eu.eudat.models.data.dmp; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; import eu.eudat.data.entities.*; import eu.eudat.logic.utilities.builders.XmlBuilder; import eu.eudat.models.DataModel; @@ -249,8 +251,14 @@ public class DataManagementPlanEditorModel implements DataModel(); - for (DescriptionTemplate descriptionTemplate : entity.getAssociatedDmps()) { - AssociatedProfile associatedProfile = new AssociatedProfile().fromData(descriptionTemplate); + for (DMPDatasetProfile dmpDescriptionProfile : entity.getAssociatedDmps()) { + AssociatedProfile associatedProfile = new AssociatedProfile().fromData(dmpDescriptionProfile.getDatasetprofile()); + try { + associatedProfile.setData(new ObjectMapper().readValue(dmpDescriptionProfile.getData(), new TypeReference>() {})); + } + catch (Exception e) { + associatedProfile.setData(null); + } this.profiles.add(associatedProfile); } } @@ -358,11 +366,16 @@ public class DataManagementPlanEditorModel implements DataModel descriptionTemplates = new HashSet<>(); + Set dmpDatasetProfiles = new HashSet<>(); for (AssociatedProfile profile : this.profiles) { - descriptionTemplates.add(profile.toData()); + DMPDatasetProfile dmpDatasetProfile = new DMPDatasetProfile(); + dmpDatasetProfile.setId(UUID.randomUUID()); + dmpDatasetProfile.setDmp(dataManagementPlanEntity); + dmpDatasetProfile.setDatasetprofile(profile.toData()); + dmpDatasetProfile.setData(new ObjectMapper().writeValueAsString(profile.getData())); + dmpDatasetProfiles.add(dmpDatasetProfile); } - dataManagementPlanEntity.setAssociatedDmps(descriptionTemplates); + dataManagementPlanEntity.setAssociatedDmps(dmpDatasetProfiles); } dataManagementPlanEntity.setProperties(this.properties != null ? JSONObject.toJSONString(this.properties) : null); dataManagementPlanEntity.setGroupId(this.groupId != null ? this.groupId : UUID.randomUUID()); diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlanNewVersionModel.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlanNewVersionModel.java index eae784aeb..a45246e2e 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlanNewVersionModel.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlanNewVersionModel.java @@ -1,5 +1,6 @@ package eu.eudat.models.data.dmp; +import com.fasterxml.jackson.databind.ObjectMapper; import eu.eudat.data.entities.*; import eu.eudat.models.DataModel; import eu.eudat.models.data.dataset.Dataset; @@ -260,8 +261,18 @@ public class DataManagementPlanNewVersionModel implements DataModel x.toData()).collect(Collectors.toSet())); + if (this.profiles != null) { + Set dmpDatasetProfiles = new HashSet<>(); + for (AssociatedProfile profile : this.profiles) { + DMPDatasetProfile dmpDatasetProfile = new DMPDatasetProfile(); + dmpDatasetProfile.setId(UUID.randomUUID()); + dmpDatasetProfile.setDmp(entity); + dmpDatasetProfile.setDatasetprofile(profile.toData()); + dmpDatasetProfile.setData(new ObjectMapper().writeValueAsString(profile.getData())); + dmpDatasetProfiles.add(dmpDatasetProfile); + } + entity.setAssociatedDmps(dmpDatasetProfiles); + } return entity; } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/listingmodels/DataManagementPlanOverviewModel.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/listingmodels/DataManagementPlanOverviewModel.java index 98d491343..1c79930b0 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/listingmodels/DataManagementPlanOverviewModel.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/listingmodels/DataManagementPlanOverviewModel.java @@ -1,6 +1,9 @@ package eu.eudat.models.data.listingmodels; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; import eu.eudat.data.entities.DMP; +import eu.eudat.data.entities.DMPDatasetProfile; import eu.eudat.data.entities.Dataset; import eu.eudat.data.entities.DescriptionTemplate; import eu.eudat.models.DataModel; @@ -11,10 +14,7 @@ import eu.eudat.models.data.dmp.Researcher; import eu.eudat.models.data.doi.Doi; import eu.eudat.models.data.grant.GrantOverviewModel; -import java.util.Date; -import java.util.LinkedList; -import java.util.List; -import java.util.UUID; +import java.util.*; import java.util.stream.Collectors; public class DataManagementPlanOverviewModel implements DataModel { @@ -205,8 +205,14 @@ public class DataManagementPlanOverviewModel implements DataModel(); - for (DescriptionTemplate descriptionTemplate : entity.getAssociatedDmps()) { - AssociatedProfile associatedProfile = new AssociatedProfile().fromData(descriptionTemplate); + for (DMPDatasetProfile dmpDescriptionProfile : entity.getAssociatedDmps()) { + AssociatedProfile associatedProfile = new AssociatedProfile().fromData(dmpDescriptionProfile.getDatasetprofile()); + try { + associatedProfile.setData(new ObjectMapper().readValue(dmpDescriptionProfile.getData(), new TypeReference>() {})); + } + catch (Exception e) { + associatedProfile.setData(null); + } this.associatedProfiles.add(associatedProfile); } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/associatedprofile/AssociatedProfilePublicModel.java b/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/associatedprofile/AssociatedProfilePublicModel.java index d2783e56a..228f843e5 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/associatedprofile/AssociatedProfilePublicModel.java +++ b/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/associatedprofile/AssociatedProfilePublicModel.java @@ -5,11 +5,13 @@ import eu.eudat.logic.utilities.interfaces.XmlSerializable; import org.w3c.dom.Document; import org.w3c.dom.Element; +import java.util.Map; import java.util.UUID; public class AssociatedProfilePublicModel implements XmlSerializable { private UUID id; private String label; + private Map data; public UUID getId() { return id; @@ -27,6 +29,14 @@ public class AssociatedProfilePublicModel implements XmlSerializable getData() { + return data; + } + + public void setData(Map data) { + this.data = data; + } + @Override public Element toXml(Document doc) { Element profile = doc.createElement("profile"); diff --git a/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/overviewmodels/DataManagementPlanPublicModel.java b/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/overviewmodels/DataManagementPlanPublicModel.java index 9f8f5fb81..702f9b13f 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/overviewmodels/DataManagementPlanPublicModel.java +++ b/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/overviewmodels/DataManagementPlanPublicModel.java @@ -1,10 +1,14 @@ package eu.eudat.publicapi.models.overviewmodels; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; import eu.eudat.data.entities.DMP; +import eu.eudat.data.entities.DMPDatasetProfile; import eu.eudat.data.entities.Dataset; import eu.eudat.data.entities.DescriptionTemplate; import eu.eudat.logic.utilities.builders.XmlBuilder; import eu.eudat.models.DataModel; +import eu.eudat.models.data.dmp.AssociatedProfile; import eu.eudat.models.data.user.composite.PagedDatasetProfile; import eu.eudat.publicapi.models.associatedprofile.AssociatedProfilePublicModel; import eu.eudat.publicapi.models.doi.DoiPublicModel; @@ -193,8 +197,14 @@ public class DataManagementPlanPublicModel implements DataModel(); - for (DescriptionTemplate descriptionTemplate : entity.getAssociatedDmps()) { - AssociatedProfilePublicModel associatedProfile = new AssociatedProfilePublicModel().fromData(descriptionTemplate); + for (DMPDatasetProfile dmpDescriptionProfile : entity.getAssociatedDmps()) { + AssociatedProfilePublicModel associatedProfile = new AssociatedProfilePublicModel().fromData(dmpDescriptionProfile.getDatasetprofile()); + try { + associatedProfile.setData(new ObjectMapper().readValue(dmpDescriptionProfile.getData(), new TypeReference>() {})); + } + catch (Exception e) { + associatedProfile.setData(null); + } this.associatedProfiles.add(associatedProfile); } } diff --git a/dmp-db-scema/main/dmp-dump.sql b/dmp-db-scema/main/dmp-dump.sql index 4e09de7e5..5852e0e75 100644 --- a/dmp-db-scema/main/dmp-dump.sql +++ b/dmp-db-scema/main/dmp-dump.sql @@ -129,7 +129,8 @@ COMMENT ON COLUMN public."DMP"."AssociatedDmps" IS 'More data about the DMP as d CREATE TABLE public."DMPDatasetProfile" ( "ID" uuid DEFAULT public.uuid_generate_v4() NOT NULL, dmp uuid NOT NULL, - datasetprofile uuid NOT NULL + datasetprofile uuid NOT NULL, + "data" text ); @@ -235,6 +236,7 @@ CREATE TABLE public."Dataset" ( "ID" uuid DEFAULT public.uuid_generate_v4() NOT NULL, "Label" character varying(250) NOT NULL, "DMP" uuid, + "DmpSectionIndex" integer, "Uri" character varying(250), "Properties" text, "Profile" uuid, diff --git a/dmp-db-scema/updates/00.00.015_Add_new_column_to_Dataset_and_DMPDatasetProfile.sql b/dmp-db-scema/updates/00.00.015_Add_new_column_to_Dataset_and_DMPDatasetProfile.sql new file mode 100644 index 000000000..b0cd7df0c --- /dev/null +++ b/dmp-db-scema/updates/00.00.015_Add_new_column_to_Dataset_and_DMPDatasetProfile.sql @@ -0,0 +1,15 @@ +DO $$DECLARE + this_version CONSTANT varchar := '00.00.014'; +BEGIN + PERFORM * FROM "DBVersion" WHERE version = this_version; + IF FOUND THEN RETURN; END IF; + +ALTER TABLE public."Dataset" +ADD COLUMN "DmpSectionIndex" integer; + +ALTER TABLE public."DMPDatasetProfile" +ADD COLUMN "data" text; + +INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.00.015', '2023-09-01 12:00:00.000000+02', now(), 'Add column DmpSectionIndex to Dataset table and data to DMPDatasetProfile.'); + +END$$; \ No newline at end of file diff --git a/dmp-frontend/src/app/core/model/dataset/dataset-wizard.ts b/dmp-frontend/src/app/core/model/dataset/dataset-wizard.ts index 48a031cfa..ccbe8d43c 100644 --- a/dmp-frontend/src/app/core/model/dataset/dataset-wizard.ts +++ b/dmp-frontend/src/app/core/model/dataset/dataset-wizard.ts @@ -14,6 +14,7 @@ export interface DatasetWizardModel { description?: String; status?: number; dmp?: DmpModel; + dmpSectionIndex?: number; datasetProfileDefinition?: DatasetProfileDefinitionModel; registries?: RegistryModel[]; services?: ServiceModel[]; diff --git a/dmp-frontend/src/app/core/model/dmp/dmp-dataset-profile/dmp-dataset-profile-sections-form.model.ts b/dmp-frontend/src/app/core/model/dmp/dmp-dataset-profile/dmp-dataset-profile-sections-form.model.ts new file mode 100644 index 000000000..8f0745359 --- /dev/null +++ b/dmp-frontend/src/app/core/model/dmp/dmp-dataset-profile/dmp-dataset-profile-sections-form.model.ts @@ -0,0 +1,28 @@ +import { FormGroup, FormBuilder } from "@angular/forms"; +import { BackendErrorValidator } from "@common/forms/validation/custom-validator"; +import { ValidationErrorModel } from "@common/forms/validation/error-model/validation-error-model"; +import { ValidationContext } from "@common/forms/validation/validation-context"; + +export class DmpDatasetProfileSectionsFormModel { + public dmpSectionIndex: number[] = []; + public validationErrorModel: ValidationErrorModel = new ValidationErrorModel(); + + fromModel(item: any): DmpDatasetProfileSectionsFormModel { + this.dmpSectionIndex = item.dmpSectionIndex; + return this; + } + + buildForm(context: ValidationContext = null, disabled: boolean = false): FormGroup { + if (context == null) { context = this.createValidationContext(); } + const formGroup = new FormBuilder().group({ + language: [{ value: this.dmpSectionIndex, disabled: disabled }, context.getValidation('dmpSectionIndex').validators], + }); + return formGroup; + } + + createValidationContext(): ValidationContext { + const baseContext: ValidationContext = new ValidationContext(); + baseContext.validation.push({ key: 'dmpSectionIndex', validators: [BackendErrorValidator(this.validationErrorModel, 'dmpSectionIndex')] }); + return baseContext; + } +} \ No newline at end of file diff --git a/dmp-frontend/src/app/core/model/dmp/dmp-dataset-profile/dmp-dataset-profile.ts b/dmp-frontend/src/app/core/model/dmp/dmp-dataset-profile/dmp-dataset-profile.ts new file mode 100644 index 000000000..9c40d752e --- /dev/null +++ b/dmp-frontend/src/app/core/model/dmp/dmp-dataset-profile/dmp-dataset-profile.ts @@ -0,0 +1,7 @@ +import { DmpDatasetProfileSectionsFormModel } from "./dmp-dataset-profile-sections-form.model"; + +export interface DmpDatasetProfile { + id: string; + label: string; + data: DmpDatasetProfileSectionsFormModel; +} \ No newline at end of file diff --git a/dmp-frontend/src/app/core/model/dmp/dmp.ts b/dmp-frontend/src/app/core/model/dmp/dmp.ts index 2ebc47fcc..d26912dc4 100644 --- a/dmp-frontend/src/app/core/model/dmp/dmp.ts +++ b/dmp-frontend/src/app/core/model/dmp/dmp.ts @@ -1,17 +1,15 @@ -import { Status } from "../../common/enum/status"; -import { DmpProfile, DmpProfileDefinition } from "../dmp-profile/dmp-profile"; +import { DmpProfileDefinition } from "../dmp-profile/dmp-profile"; import { OrganizationModel } from "../organisation/organization"; import { GrantListingModel } from "../grant/grant-listing"; import { ResearcherModel } from "../researcher/researcher"; import { UserModel } from "../user/user"; import { DmpDynamicField } from "./dmp-dynamic-field"; import { UserInfoListingModel } from "../user/user-info-listing"; -import { DatasetModel } from "../dataset/dataset"; import { ProjectModel } from "../project/project"; import { FunderModel } from "../funder/funder"; import { DmpStatus } from '@app/core/common/enum/dmp-status'; -import { ExtraPropertiesFormModel } from '@app/ui/dmp/editor/general-tab/extra-properties-form.model'; import { DatasetWizardModel } from '../dataset/dataset-wizard'; +import { DmpDatasetProfile } from "./dmp-dataset-profile/dmp-dataset-profile"; export interface DmpModel { id: string; @@ -27,7 +25,7 @@ export interface DmpModel { funder: FunderModel; datasets: DatasetWizardModel[]; datasetsToBeFinalized: string[]; - profiles: DmpProfile[]; + profiles: DmpDatasetProfile[]; organisations: OrganizationModel[]; researchers: ResearcherModel[]; associatedUsers: UserModel[]; diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard-editor.model.ts b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard-editor.model.ts index f4ad2cf38..e2a3f45a5 100644 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard-editor.model.ts +++ b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard-editor.model.ts @@ -26,6 +26,7 @@ export class DatasetWizardEditorModel { public tags: ExternalTagEditorModel[] = []; public externalDatasets: ExternalDatasetEditorModel[] = []; public dmp: DmpModel; + public dmpSectionIndex: number; public datasetProfileDefinition: DatasetDescriptionFormEditorModel; public validationErrorModel: ValidationErrorModel = new ValidationErrorModel(); public isProfileLatestVersion: Boolean; @@ -43,6 +44,7 @@ export class DatasetWizardEditorModel { if (item.dataRepositories) { this.dataRepositories = item.dataRepositories.map(x => new ExternalDataRepositoryEditorModel().fromModel(x)); } if (item.externalDatasets) { this.externalDatasets = item.externalDatasets.map(x => new ExternalDatasetEditorModel().fromModel(x)); } this.dmp = item.dmp; + this.dmpSectionIndex = item.dmpSectionIndex; if (item.datasetProfileDefinition) { this.datasetProfileDefinition = new DatasetDescriptionFormEditorModel().fromModel(item.datasetProfileDefinition); } if (item.tags) { this.tags = item.tags.map(x => new ExternalTagEditorModel().fromModel(x)); } this.isProfileLatestVersion = item.isProfileLatestVersion; @@ -60,6 +62,7 @@ export class DatasetWizardEditorModel { status: [{ value: this.status, disabled: disabled }, context.getValidation('status').validators], description: [{ value: this.description, disabled: disabled }, context.getValidation('description').validators], dmp: [{ value: this.dmp, disabled: disabled }, context.getValidation('dmp').validators], + dmpSectionIndex: [{ value: this.dmpSectionIndex, disabled: disabled }, context.getValidation('dmpSectionIndex').validators], //externalDatasets: [{ value: this.externalDatasets, disabled: disabled }, context.getValidation('externalDatasets').validators], tags: [{ value: this.tags, disabled: disabled }, context.getValidation('tags').validators], //registries: [{ value: this.registries, disabled: disabled }, context.getValidation('registries').validators], @@ -143,6 +146,7 @@ export class DatasetWizardEditorModel { baseContext.validation.push({ key: 'dataRepositories', validators: [BackendErrorValidator(this.validationErrorModel, 'dataRepositories')] }); baseContext.validation.push({ key: 'externalDatasets', validators: [BackendErrorValidator(this.validationErrorModel, 'externalDatasets')] }); baseContext.validation.push({ key: 'dmp', validators: [BackendErrorValidator(this.validationErrorModel, 'dmp')] }); + baseContext.validation.push({ key: 'dmpSectionIndex', validators: [BackendErrorValidator(this.validationErrorModel, 'dmpSectionIndex')] }); baseContext.validation.push({ key: 'datasetProfileDefinition', validators: [BackendErrorValidator(this.validationErrorModel, 'datasetProfileDefinition')] }); baseContext.validation.push({ key: 'tags', validators: [BackendErrorValidator(this.validationErrorModel, 'datasetProfileDefinition')] }); baseContext.validation.push({ key: 'modified', validators: []}); diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts index 3f7210658..70cd17950 100644 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts +++ b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts @@ -95,6 +95,7 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme finalize: boolean = false; itemId: string; dmpId: string; + dmpSectionIndex: number; newDmpId: string; publicId: string; profileUpdateId: string; @@ -171,6 +172,7 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme const data: any = this.route.snapshot.data; this.itemId = params['id']; this.dmpId = params['dmpId']; + this.dmpSectionIndex = params['dmpSectionIndex']; this.newDmpId = queryParams['newDmpId']; this.publicId = params['publicId']; this.profileUpdateId = params['updateId']; @@ -266,6 +268,7 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme this.datasetWizardModel = new DatasetWizardEditorModel(); setTimeout(() => { this.datasetWizardModel.dmp = data; + this.datasetWizardModel.dmpSectionIndex = this.dmpSectionIndex; this.formGroup = this.datasetWizardModel.buildForm(); this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft; @@ -283,6 +286,7 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme if(result) { this.datasetWizardModel = this.datasetWizardModel.fromModel(result); this.datasetWizardModel.dmp = data; + this.datasetWizardModel.dmpSectionIndex = this.dmpSectionIndex; this.formGroup = this.datasetWizardModel.buildForm(); this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); this.formGroup.get('dmp').disable(); diff --git a/dmp-frontend/src/app/ui/dataset/dataset.routing.ts b/dmp-frontend/src/app/ui/dataset/dataset.routing.ts index c3381dc06..ab3bb27ed 100644 --- a/dmp-frontend/src/app/ui/dataset/dataset.routing.ts +++ b/dmp-frontend/src/app/ui/dataset/dataset.routing.ts @@ -8,7 +8,7 @@ import { DatasetOverviewComponent } from './overview/dataset-overview.component' const routes: Routes = [ { - path: 'new/:dmpId', + path: 'new/:dmpId/:dmpSectionIndex', component: DatasetWizardComponent, canActivate: [AuthGuard], data: { diff --git a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor-blueprint.component.html b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor-blueprint.component.html index 34735967d..7a6652240 100644 --- a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor-blueprint.component.html +++ b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor-blueprint.component.html @@ -34,18 +34,27 @@
-
+
DMP Blueprint
-
    -
  1. Select Blueprint
  2. +
      +
      -
    1. {{section.label}}
    2. +
- - +
-
+
0.1 Title of DMP *
@@ -106,177 +115,210 @@
+
+