From 0166bf8ecef6a85f61e0fb8452feb3888ec052b1 Mon Sep 17 00:00:00 2001 From: Thomas Georgios Giannos Date: Tue, 28 Nov 2023 12:54:08 +0200 Subject: [PATCH] Refactoring and preparing for dmp and dataset conversion for public API --- .../DmpToPublicApiDmpListingMapper.java | 28 ++ .../publicapi/DmpToPublicApiDmpMapper.java | 22 ++ .../AssociatedProfilePublicModel.java | 2 +- .../DatasetProfilePublicModel.java | 11 +- .../DataRepositoryPublicModel.java | 8 +- .../datasetwizard/DatasetProfile.java | 86 +++++ .../datasetwizard/DatasetProfilePage.java | 33 ++ .../ExternalDatasetPublicListingModel.java | 9 +- .../datasetwizard}/ExternalDatasetType.java | 7 +- .../model/publicapi/datasetwizard/Field.java | 296 ++++++++++++++++++ .../publicapi/datasetwizard/FieldSet.java | 215 +++++++++++++ .../model/publicapi/datasetwizard/Page.java | 51 +++ .../datasetwizard/PagedDatasetProfile.java | 60 ++++ .../datasetwizard/PropertiesModelBuilder.java | 9 + .../datasetwizard/RegistryPublicModel.java | 9 +- .../model/publicapi/datasetwizard/Rule.java | 49 +++ .../publicapi/datasetwizard/Section.java | 157 ++++++++++ .../datasetwizard/ServicePublicModel.java | 8 +- .../model/publicapi}/doi/DoiPublicModel.java | 6 +- .../funder/FunderPublicOverviewModel.java | 8 +- .../grant/GrantPublicOverviewModel.java | 10 +- .../DataManagementPlanPublicListingModel.java | 4 +- .../DatasetPublicListingModel.java | 4 +- .../organisation/OrganizationPublicModel.java | 10 +- .../DataManagementPlanPublicModel.java | 161 ++++++++++ .../overviewmodels/DatasetPublicModel.java | 21 +- .../researcher/ResearcherPublicModel.java | 39 +-- ...ublicDatasetsDescriptionDocumentation.java | 28 +- .../publicapi/PublicDmpsDocumentation.java | 111 ++++++- .../DataManagementPlanPublicManager.java | 80 ----- .../managers/DatasetPublicManager.java | 113 ------- .../DataManagementPlanPublicModel.java | 249 --------------- .../ExternalDatasetListingModel.java | 2 +- 33 files changed, 1317 insertions(+), 589 deletions(-) create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/mapper/publicapi/DmpToPublicApiDmpListingMapper.java rename dmp-backend/{web/src/main/java/eu/eudat/controllers/publicapi/models => core/src/main/java/eu/eudat/model/publicapi}/associatedprofile/AssociatedProfilePublicModel.java (96%) rename dmp-backend/{web/src/main/java/eu/eudat/controllers/publicapi/models => core/src/main/java/eu/eudat/model/publicapi}/datasetprofile/DatasetProfilePublicModel.java (71%) rename dmp-backend/{web/src/main/java/eu/eudat/controllers/publicapi/models => core/src/main/java/eu/eudat/model/publicapi}/datasetwizard/DataRepositoryPublicModel.java (91%) create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/publicapi/datasetwizard/DatasetProfile.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/publicapi/datasetwizard/DatasetProfilePage.java rename dmp-backend/{web/src/main/java/eu/eudat/controllers/publicapi/models => core/src/main/java/eu/eudat/model/publicapi}/datasetwizard/ExternalDatasetPublicListingModel.java (92%) rename dmp-backend/{web/src/main/java/eu/eudat/types/externalsourcetype => core/src/main/java/eu/eudat/model/publicapi/datasetwizard}/ExternalDatasetType.java (80%) create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/publicapi/datasetwizard/Field.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/publicapi/datasetwizard/FieldSet.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/publicapi/datasetwizard/Page.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/publicapi/datasetwizard/PagedDatasetProfile.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/publicapi/datasetwizard/PropertiesModelBuilder.java rename dmp-backend/{web/src/main/java/eu/eudat/controllers/publicapi/models => core/src/main/java/eu/eudat/model/publicapi}/datasetwizard/RegistryPublicModel.java (91%) create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/publicapi/datasetwizard/Rule.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/publicapi/datasetwizard/Section.java rename dmp-backend/{web/src/main/java/eu/eudat/controllers/publicapi/models => core/src/main/java/eu/eudat/model/publicapi}/datasetwizard/ServicePublicModel.java (91%) rename dmp-backend/{web/src/main/java/eu/eudat/controllers/publicapi/models => core/src/main/java/eu/eudat/model/publicapi}/doi/DoiPublicModel.java (86%) rename dmp-backend/{web/src/main/java/eu/eudat/controllers/publicapi/models => core/src/main/java/eu/eudat/model/publicapi}/funder/FunderPublicOverviewModel.java (74%) rename dmp-backend/{web/src/main/java/eu/eudat/controllers/publicapi/models => core/src/main/java/eu/eudat/model/publicapi}/grant/GrantPublicOverviewModel.java (87%) rename dmp-backend/{web/src/main/java/eu/eudat/controllers/publicapi/models => core/src/main/java/eu/eudat/model/publicapi}/listingmodels/DataManagementPlanPublicListingModel.java (96%) rename dmp-backend/{web/src/main/java/eu/eudat/controllers/publicapi/models => core/src/main/java/eu/eudat/model/publicapi}/listingmodels/DatasetPublicListingModel.java (95%) rename dmp-backend/{web/src/main/java/eu/eudat/controllers/publicapi/models => core/src/main/java/eu/eudat/model/publicapi}/organisation/OrganizationPublicModel.java (90%) create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/publicapi/overviewmodels/DataManagementPlanPublicModel.java rename dmp-backend/{web/src/main/java/eu/eudat/controllers/publicapi/models => core/src/main/java/eu/eudat/model/publicapi}/overviewmodels/DatasetPublicModel.java (93%) rename dmp-backend/{web/src/main/java/eu/eudat/controllers/publicapi/models => core/src/main/java/eu/eudat/model/publicapi}/researcher/ResearcherPublicModel.java (77%) delete mode 100644 dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/managers/DataManagementPlanPublicManager.java delete mode 100644 dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/managers/DatasetPublicManager.java delete mode 100644 dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/models/overviewmodels/DataManagementPlanPublicModel.java diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/mapper/publicapi/DmpToPublicApiDmpListingMapper.java b/dmp-backend/core/src/main/java/eu/eudat/model/mapper/publicapi/DmpToPublicApiDmpListingMapper.java new file mode 100644 index 000000000..225ede58d --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/mapper/publicapi/DmpToPublicApiDmpListingMapper.java @@ -0,0 +1,28 @@ +package eu.eudat.model.mapper.publicapi; + +import eu.eudat.model.Dmp; +import eu.eudat.model.publicapi.listingmodels.DataManagementPlanPublicListingModel; +import org.springframework.stereotype.Component; + +import java.sql.Date; + +@Component +public class DmpToPublicApiDmpListingMapper { + + public DataManagementPlanPublicListingModel toPublicListingModel(Dmp dmp) { + DataManagementPlanPublicListingModel model = new DataManagementPlanPublicListingModel(); + model.setId(dmp.getId().toString()); + model.setLabel(dmp.getLabel()); + model.setVersion(dmp.getVersion()); + model.setGroupId(dmp.getGroupId()); + +// model.set + + model.setCreatedAt(Date.from(dmp.getCreatedAt())); + model.setModifiedAt(Date.from(dmp.getUpdatedAt())); + model.setFinalizedAt(Date.from(dmp.getFinalizedAt())); + + return model; + } + +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/mapper/publicapi/DmpToPublicApiDmpMapper.java b/dmp-backend/core/src/main/java/eu/eudat/model/mapper/publicapi/DmpToPublicApiDmpMapper.java index f7e3e7cd8..cf8c0af3f 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/mapper/publicapi/DmpToPublicApiDmpMapper.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/mapper/publicapi/DmpToPublicApiDmpMapper.java @@ -1,7 +1,29 @@ package eu.eudat.model.mapper.publicapi; +import eu.eudat.model.Dmp; +import eu.eudat.model.publicapi.overviewmodels.DataManagementPlanPublicModel; +import org.springframework.stereotype.Component; + +import java.sql.Date; + +@Component public class DmpToPublicApiDmpMapper { + public DataManagementPlanPublicModel toPublicModel(Dmp dmp) { + DataManagementPlanPublicModel model = new DataManagementPlanPublicModel(); + model.setId(dmp.getId().toString()); + model.setLabel(dmp.getLabel()); + model.setDescription(dmp.getDescription()); + model.setVersion(dmp.getVersion()); + model.setGroupId(dmp.getGroupId()); + + model.setCreatedAt(Date.from(dmp.getCreatedAt())); + model.setModifiedAt(Date.from(dmp.getUpdatedAt())); + model.setFinalizedAt(Date.from(dmp.getFinalizedAt())); + + return model; + } + } diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/models/associatedprofile/AssociatedProfilePublicModel.java b/dmp-backend/core/src/main/java/eu/eudat/model/publicapi/associatedprofile/AssociatedProfilePublicModel.java similarity index 96% rename from dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/models/associatedprofile/AssociatedProfilePublicModel.java rename to dmp-backend/core/src/main/java/eu/eudat/model/publicapi/associatedprofile/AssociatedProfilePublicModel.java index b8c348cfe..278640dc4 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/models/associatedprofile/AssociatedProfilePublicModel.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/publicapi/associatedprofile/AssociatedProfilePublicModel.java @@ -1,4 +1,4 @@ -package eu.eudat.controllers.publicapi.models.associatedprofile; +package eu.eudat.model.publicapi.associatedprofile; import eu.eudat.data.DescriptionTemplateEntity; import eu.eudat.commons.types.xml.XmlSerializable; diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/models/datasetprofile/DatasetProfilePublicModel.java b/dmp-backend/core/src/main/java/eu/eudat/model/publicapi/datasetprofile/DatasetProfilePublicModel.java similarity index 71% rename from dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/models/datasetprofile/DatasetProfilePublicModel.java rename to dmp-backend/core/src/main/java/eu/eudat/model/publicapi/datasetprofile/DatasetProfilePublicModel.java index c843fb3ee..03ff3ec3e 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/models/datasetprofile/DatasetProfilePublicModel.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/publicapi/datasetprofile/DatasetProfilePublicModel.java @@ -1,11 +1,10 @@ -package eu.eudat.controllers.publicapi.models.datasetprofile; +package eu.eudat.model.publicapi.datasetprofile; import eu.eudat.data.DescriptionTemplateEntity; -import eu.eudat.models.DataModel; import java.util.UUID; -public class DatasetProfilePublicModel implements DataModel { +public class DatasetProfilePublicModel { private UUID id; private String label; @@ -23,14 +22,12 @@ public class DatasetProfilePublicModel implements DataModel, LabelGenerator { +public class DataRepositoryPublicModel { private String id; private String pid; private String name; @@ -124,12 +122,10 @@ public class DataRepositoryPublicModel implements DataModel sections; + private List rules; + private List pages; + private int status; + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getLanguage() { + return language; + } + + public void setLanguage(String language) { + this.language = language; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public List
getSections() { + return sections; + } + + public void setSections(List
sections) { + this.sections = sections; + } + + + public List getRules() { + return rules; + } + + public void setRules(List rules) { + this.rules = rules; + } + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + public List getPages() { + return pages; + } + + public void setPages(List pages) { + this.pages = pages; + } + + @Override + public void fromJsonObject(Map properties) { + this.sections.forEach(item -> item.fromJsonObject(properties)); + + } + + @Override + public void fromJsonObject(Map properties, String index) { + // TODO Auto-generated method stub + + } + +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/publicapi/datasetwizard/DatasetProfilePage.java b/dmp-backend/core/src/main/java/eu/eudat/model/publicapi/datasetwizard/DatasetProfilePage.java new file mode 100644 index 000000000..dbe027089 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/publicapi/datasetwizard/DatasetProfilePage.java @@ -0,0 +1,33 @@ +package eu.eudat.model.publicapi.datasetwizard; + +import java.util.List; + +public class DatasetProfilePage { + private Integer ordinal; + private String title; + private List
sections; + + public Integer getOrdinal() { + return ordinal; + } + + public void setOrdinal(Integer ordinal) { + this.ordinal = ordinal; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public List
getSections() { + return sections; + } + + public void setSections(List
sections) { + this.sections = sections; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/models/datasetwizard/ExternalDatasetPublicListingModel.java b/dmp-backend/core/src/main/java/eu/eudat/model/publicapi/datasetwizard/ExternalDatasetPublicListingModel.java similarity index 92% rename from dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/models/datasetwizard/ExternalDatasetPublicListingModel.java rename to dmp-backend/core/src/main/java/eu/eudat/model/publicapi/datasetwizard/ExternalDatasetPublicListingModel.java index 183f2c32d..5b37a3564 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/models/datasetwizard/ExternalDatasetPublicListingModel.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/publicapi/datasetwizard/ExternalDatasetPublicListingModel.java @@ -1,13 +1,11 @@ -package eu.eudat.controllers.publicapi.models.datasetwizard; +package eu.eudat.model.publicapi.datasetwizard; import eu.eudat.data.old.ExternalDataset; -import eu.eudat.models.DataModel; -import eu.eudat.types.externalsourcetype.ExternalDatasetType; import java.util.Date; import java.util.UUID; -public class ExternalDatasetPublicListingModel implements DataModel { +public class ExternalDatasetPublicListingModel { private UUID id; private String name; private String abbreviation; @@ -105,7 +103,6 @@ public class ExternalDatasetPublicListingModel implements DataModel multiplicityItems; + private List validations; + private VisibilityEntity visible; + private List schematics; + + private Boolean export; + + public List getMultiplicityItems() { + return multiplicityItems; + } + + public void setMultiplicityItems(List multiplicityItems) { + this.multiplicityItems = multiplicityItems; + } + + public void setOrdinal(Integer ordinal) { + this.ordinal = ordinal; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Integer getOrdinal() { + return ordinal; + } + + public void setOrdinal(int ordinal) { + this.ordinal = ordinal; + } + + public Object getValue() { + return value; + } + + public void setValue(Object value) { + this.value = value; + } + + public FieldDescriptionEntity getViewStyle() { + return viewStyle; + } + + public void setViewStyle(FieldDescriptionEntity viewStyle) { + this.viewStyle = viewStyle; + } + + public int getPage() { + return page; + } + + public void setPage(int page) { + this.page = page; + } + + public DefaultValueEntity getDefaultValue() { + return defaultValue; + } + + public void setDefaultValue(DefaultValueEntity defaultValue) { + this.defaultValue = defaultValue; + } + + public String getDatatype() { + return datatype; + } + + public void setDatatype(String datatype) { + this.datatype = datatype; + } + + public MultiplicityEntity getMultiplicity() { + return multiplicity; + } + + public void setMultiplicity(MultiplicityEntity multiplicity) { + this.multiplicity = multiplicity; + } + + public Object getData() { + return data; + } + + public void setData(Object data) { + this.data = data; + } + + public VisibilityEntity getVisible() { + return visible; + } + + public void setVisible(VisibilityEntity visible) { + this.visible = visible; + } + + public List getValidations() { + if(this.validations == null) { + return null; + } + return this.validations.stream().map(item -> (int) item.getValue()).collect(Collectors.toList()); + } + + public void setValidations(List validations) { + this.validations = validations.stream().map(x-> FieldValidationType.of(x.shortValue())).collect(Collectors.toList()); + } + + public String getNumbering() { + return numbering; + } + + public void setNumbering(String numbering) { + this.numbering = numbering; + } + + public List getSchematics() { + return schematics; + } + + public void setSchematics(List schematics) { + this.schematics = schematics; + } + + public Boolean getExport() { + return export; + } + + public void setExport(Boolean export) { + this.export = export; + } + + Field cloneForMultiplicity(String key, Map properties, int index) { + Field newField = new Field(); + newField.id = key; + newField.ordinal = this.ordinal; + newField.value = properties.containsKey(key)? properties.get(key): null; + newField.viewStyle = this.viewStyle; + newField.datatype = this.datatype; + newField.page = this.page; + newField.defaultValue = this.defaultValue; + newField.data = this.data; + newField.validations = this.validations; + newField.schematics = this.schematics; + newField.numbering = "mult" + index + "_" + this.numbering; + newField.export = this.export; + return newField; + } + + public FieldEntity toDatabaseDefinition(FieldEntity fieldEntity) { + fieldEntity.setId(this.id); + fieldEntity.setOrdinal(this.ordinal); + throw new NotImplementedException(" Use new logic"); + //TODO: Use new logic +// fieldEntity.setData(new FieldDataHelper().toFieldData(data, this.viewStyle.getFieldType())); +// fieldEntity.setDefaultValue(this.defaultValue.getValue()); +// fieldEntity.setVisibilityRules(this.visible.getRules()); +// fieldEntity.setValidations(this.validations); +// fieldEntity.setSchematics(this.schematics); +// fieldEntity.setIncludeInExport(this.export); +// return fieldEntity; + } + + public void fromDatabaseDefinition(FieldEntity item) { + this.id = item.getId(); + this.ordinal = item.getOrdinal(); + FieldDescriptionEntity fieldDescription = new FieldDescriptionEntity(); + fieldDescription.setFieldType(item.getData().getFieldType()); + this.viewStyle = fieldDescription; + this.numbering = item.getNumbering(); + this.data = item.getData(); + + DefaultValueEntity defaultValueEntity = new DefaultValueEntity(); + defaultValueEntity.setValue(item.getDefaultValue()); + this.defaultValue = defaultValueEntity; + VisibilityEntity visibilityEntity = new VisibilityEntity(); + visibilityEntity.setRules(item.getVisibilityRules()); + this.visible = visibilityEntity; + this.validations = item.getValidations(); + this.schematics = item.getSchematics(); + this.export = item.getIncludeInExport(); + } + + @Override + public void fromJsonObject(Map properties) { + try { + ObjectMapper mapper = new ObjectMapper(); + List stringList = mapper.readValue(properties.get(this.id).toString(), LinkedList.class); + this.value = stringList; + } catch (JSONException | NullPointerException | IOException e) { + try { + this.value = (String) properties.get(this.id); + } catch (ClassCastException ce) { + this.value = properties.get(this.id); + } + } + this.multiplicityItems = new LinkedList<>(); + List compositeKeys = properties.keySet().stream().filter(keys -> keys.startsWith("multiple_" + this.getId())).collect(Collectors.toList()); + int index = 1; + for (String key : compositeKeys) { + this.multiplicityItems.add(this.cloneForMultiplicity(key, properties, index)); + } + } + + @Override + public int compareTo(Object o) { + Field comparedField = (Field) o; + if(this.ordinal != null) { + return this.ordinal.compareTo(comparedField.getOrdinal()); + } else if (comparedField.getOrdinal() != null) { + return comparedField.getOrdinal().compareTo(this.ordinal); + } else { + return 0; + } + } + + @Override + public void fromJsonObject(Map properties, String path) { + this.value = (String) properties.get(path); + } + + public void toMap(Map fieldValues) { + if (this.value != null) { + if ((this.viewStyle != null && this.viewStyle.getFieldType().equals("datasetIdentifier") && this.value instanceof Map || this.value instanceof Collection)) { + ObjectMapper mapper = new ObjectMapper(); + String valueString = null; + try { + valueString = mapper.writeValueAsString(this.value); + fieldValues.put(this.id, valueString); + } catch (JsonProcessingException e) { + logger.error(e.getMessage(), e); + } + } /*else if (this.value instanceof Collection) { + Collection valueCollection = (Collection) this.value; + StringBuilder valueBuilder = new StringBuilder(); + valueBuilder.append("["); + for (int i = 0; i < valueCollection.size(); i++) { + valueBuilder.append("\"").append(valueCollection.toArray()[i]).append("\""); + if (i < valueCollection.size() - 1) { + valueBuilder.append(", "); + } + } + valueBuilder.append("]"); + fieldValues.put(this.id, valueBuilder.toString()); + }*/ + else if ((this.viewStyle != null && this.viewStyle.getFieldType().equals("upload"))) { + fieldValues.put(this.id, this.value); + } + else { + fieldValues.put(this.id, this.value.toString()); + } + } else { + fieldValues.put(this.id, ""); + } + } + + public void toMap(Map fieldValues, int index) { + fieldValues.put(this.id, this.value); + } +} \ No newline at end of file diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/publicapi/datasetwizard/FieldSet.java b/dmp-backend/core/src/main/java/eu/eudat/model/publicapi/datasetwizard/FieldSet.java new file mode 100644 index 000000000..8dc43d8c1 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/publicapi/datasetwizard/FieldSet.java @@ -0,0 +1,215 @@ +package eu.eudat.model.publicapi.datasetwizard; + +import eu.eudat.commons.types.descriptiontemplate.FieldSetEntity; +import eu.eudat.commons.types.descriptiontemplate.MultiplicityEntity; + +import java.util.*; +import java.util.stream.Collectors; + +public class FieldSet implements Comparable, PropertiesModelBuilder { + private String id; + private Integer ordinal; + private String title; + private String numbering; + private String description; + private String extendedDescription; + private String additionalInformation; + private MultiplicityEntity multiplicity; + private List fields; + private List
multiplicityItems; + private boolean hasCommentField; + private String commentFieldValue; + + public List getFields() { + Collections.sort(this.fields); + return fields; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getExtendedDescription() { + return extendedDescription; + } + + public void setExtendedDescription(String extendedDescription) { + this.extendedDescription = extendedDescription; + } + + public void setFields(List fields) { + this.fields = fields; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public int getOrdinal() { + return ordinal; + } + + public void setOrdinal(int ordinal) { + this.ordinal = ordinal; + } + + public MultiplicityEntity getMultiplicity() { + return multiplicity; + } + + public void setMultiplicity(MultiplicityEntity multiplicity) { + this.multiplicity = multiplicity; + } + + public List
getMultiplicityItems() { + if (multiplicityItems != null) Collections.sort(multiplicityItems); + return multiplicityItems; + } + + public String getNumbering() { + return numbering; + } + + public void setNumbering(String numbering) { + this.numbering = numbering; + } + + public void setMultiplicityItems(List
multiplicityItems) { + this.multiplicityItems = multiplicityItems; + } + + public void setOrdinal(Integer ordinal) { + this.ordinal = ordinal; + } + + public void setHasCommentField(boolean hasCommentField) { + this.hasCommentField = hasCommentField; + } + + public boolean getHasCommentField() { + return hasCommentField; + } + + public String getCommentFieldValue() { + return commentFieldValue; + } + + public void setCommentFieldValue(String commentFieldValue) { + this.commentFieldValue = commentFieldValue; + } + + public String getAdditionalInformation() { + return additionalInformation; + } + + public void setAdditionalInformation(String additionalInformation) { + this.additionalInformation = additionalInformation; + } + + public FieldSetEntity toDatabaseDefinition(FieldSetEntity item) { +// List viewStylefields = new ModelBuilder().toViewStyleDefinition(this.fields, FieldEntity.class); +// item.setFields(viewStylefields); +// item.setId(this.id); +// item.setOrdinal(this.ordinal); +// item.setHasCommentField(this.hasCommentField); +// item.setMultiplicity(this.multiplicity); +//// item.setCommentFieldValue(this.commentFieldValue); +// return item; + return null; + } + + + public void fromDatabaseDefinition(FieldSetEntity item) { +// this.fields = new ModelBuilder().fromViewStyleDefinition(item.getFields(), Field.class); +// this.id = item.getId(); +// this.ordinal = item.getOrdinal(); +// this.title = item.getTitle(); +// this.description = item.getDescription(); +// this.additionalInformation=item.getAdditionalInformation(); +// this.numbering = item.getNumbering(); +// this.extendedDescription = item.getExtendedDescription(); +// this.hasCommentField = item.getHasCommentField(); +// this.multiplicity = item.getMultiplicity(); +//// this.commentFieldValue = item.getCommentFieldValue(); + } + + @Override + public void fromJsonObject(Map properties) { + this.commentFieldValue = (String) properties.get("commentFieldValue" + this.id); + this.multiplicityItems = new LinkedList
(); + this.fields.forEach(item -> { + item.fromJsonObject(properties); + }); + List compositeKeysFather = properties.keySet().stream().filter(keys -> keys.startsWith("multiple_" + this.getId())).collect(Collectors.toList()); + List Ids=new ArrayList<>(); + int index = 1; + for (String composite : compositeKeysFather) { + String[] split = composite.split("_"); + if (!Ids.contains(split[2])) { + Ids.add(split[2]); + this.multiplicityItems.add(this.CloneForMultiplicity2(properties.keySet().stream().filter(keys -> keys.startsWith("multiple_" + this.getId() + "_" + split[2])).collect(Collectors.toList()), properties,split, index)); + index++; + } + } + } + + private FieldSet CloneForMultiplicity2(List key, Map properties,String[] ids, int index){ + FieldSet newFieldSet = new FieldSet(); + newFieldSet.id = ids[0]+"_"+ids[1]+"_"+ids[2] + (ids.length > 4 ? "_" + ids[3] : ""); + newFieldSet.description = this.description; + newFieldSet.extendedDescription = this.extendedDescription; + newFieldSet.additionalInformation=this.additionalInformation; + newFieldSet.title = this.title; + newFieldSet.ordinal = ids.length > 4 ? Integer.valueOf(ids[3]) : this.ordinal; + newFieldSet.fields = new LinkedList(); + + for (Field field: this.fields) { + newFieldSet.fields.add(field.cloneForMultiplicity(newFieldSet.id + "_" + field.getId(), properties, index)); + } + return newFieldSet; + } + + + + @Override + public int compareTo(Object o) { + return this.ordinal.compareTo(((FieldSet) o).getOrdinal()); + } + + @Override + public void fromJsonObject(Map properties, String path) { + // TODO Auto-generated method stub + + } + + public void toMap(Map fieldValues) { + fieldValues.put("commentFieldValue" + this.id, this.commentFieldValue); + this.fields.forEach(item -> item.toMap(fieldValues)); + Map multiplicity = new HashMap(); + if (this.multiplicityItems != null) { + this.multiplicityItems.forEach(item -> item.toMap(fieldValues, this.multiplicityItems.indexOf(item))); + } + //fieldValues.put(this.id,multiplicity); + } + + public void toMap(Map fieldValues, int index) { + this.fields.forEach(item -> item.toMap(fieldValues, index)); + //this.multiplicityItems.forEach(item->item.toMap(fieldValues,index)); + } +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/publicapi/datasetwizard/Page.java b/dmp-backend/core/src/main/java/eu/eudat/model/publicapi/datasetwizard/Page.java new file mode 100644 index 000000000..a22dde89d --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/publicapi/datasetwizard/Page.java @@ -0,0 +1,51 @@ +package eu.eudat.model.publicapi.datasetwizard; + +import eu.eudat.commons.types.descriptiontemplate.PageEntity; + +public class Page implements Comparable { + private String id; + private Integer ordinal; + private String title; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public int getOrdinal() { + return ordinal; + } + + public void setOrdinal(int ordinal) { + this.ordinal = ordinal; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public PageEntity toDatabaseDefinition(PageEntity item) { + item.setId(this.id); + item.setOrdinal(this.ordinal); + item.setTitle(this.title); + return item; + } + + public void fromDatabaseDefinition(PageEntity item) { + this.title = item.getTitle(); + this.ordinal = item.getOrdinal(); + this.id = item.getId(); + } + + @Override + public int compareTo(Object o) { + return this.ordinal.compareTo((Integer) o); + } +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/publicapi/datasetwizard/PagedDatasetProfile.java b/dmp-backend/core/src/main/java/eu/eudat/model/publicapi/datasetwizard/PagedDatasetProfile.java new file mode 100644 index 000000000..7a6677514 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/publicapi/datasetwizard/PagedDatasetProfile.java @@ -0,0 +1,60 @@ +package eu.eudat.model.publicapi.datasetwizard; + +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +public class PagedDatasetProfile { + private List pages; + private List rules; + private int status; + + public List getPages() { + return pages; + } + + public void setPages(List pages) { + this.pages = pages; + } + + public List getRules() { + return rules; + } + + public void setRules(List rules) { + this.rules = rules; + } + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + public PagedDatasetProfile buildPagedDatasetProfile(DatasetProfile profile) { + this.status = profile.getStatus(); + this.rules = profile.getRules(); + this.pages = new LinkedList<>(); + List pages = profile.getPages(); + for (Page page : pages) { + DatasetProfilePage datasetProfilePage = new DatasetProfilePage(); + datasetProfilePage.setOrdinal(page.getOrdinal()); + datasetProfilePage.setTitle(page.getTitle()); + datasetProfilePage.setSections(profile.getSections().stream().filter(item -> item.getPage().equals(page.getId())).collect(Collectors.toList())); + this.pages.add(datasetProfilePage); + } + + return this; + } + + public void toMap(Map fieldValues) { + this.pages.forEach(item -> item.getSections().forEach(sectionItem -> sectionItem.toMap(fieldValues))); + } + + public void toMap(Map fieldValues, int index) { + + } +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/publicapi/datasetwizard/PropertiesModelBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/publicapi/datasetwizard/PropertiesModelBuilder.java new file mode 100644 index 000000000..08f55ed9c --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/publicapi/datasetwizard/PropertiesModelBuilder.java @@ -0,0 +1,9 @@ +package eu.eudat.model.publicapi.datasetwizard; + +import java.util.Map; + +public interface PropertiesModelBuilder { + void fromJsonObject(Map properties); + + void fromJsonObject(Map properties, String pathKey); +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/models/datasetwizard/RegistryPublicModel.java b/dmp-backend/core/src/main/java/eu/eudat/model/publicapi/datasetwizard/RegistryPublicModel.java similarity index 91% rename from dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/models/datasetwizard/RegistryPublicModel.java rename to dmp-backend/core/src/main/java/eu/eudat/model/publicapi/datasetwizard/RegistryPublicModel.java index 85cb749ae..168976d46 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/models/datasetwizard/RegistryPublicModel.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/publicapi/datasetwizard/RegistryPublicModel.java @@ -1,13 +1,11 @@ -package eu.eudat.controllers.publicapi.models.datasetwizard; +package eu.eudat.model.publicapi.datasetwizard; import eu.eudat.data.old.Registry; -import eu.eudat.logic.utilities.helpers.LabelGenerator; -import eu.eudat.models.DataModel; import java.util.Date; import java.util.UUID; -public class RegistryPublicModel implements DataModel, LabelGenerator { +public class RegistryPublicModel { private UUID id; private String label; private String abbreviation; @@ -33,7 +31,7 @@ public class RegistryPublicModel implements DataModel, PropertiesModelBuilder { + private List
sections; + private List
compositeFields; + private Boolean defaultVisibility; + private String numbering; + private String page; + private Integer ordinal; + private String id; + private String title; + private String description; + private Boolean multiplicity; + + public List
getSections() { + Collections.sort(sections); + return sections; + } + + public void setSections(List
sections) { + this.sections = sections; + } + + public List
getCompositeFields() { + Collections.sort(compositeFields); + return compositeFields; + } + + public void setCompositeFields(List
compositeFields) { + this.compositeFields = compositeFields; + } + + public Boolean getDefaultVisibility() { + return defaultVisibility; + } + + public void setDefaultVisibility(Boolean defaultVisibility) { + this.defaultVisibility = defaultVisibility; + } + + public String getPage() { + return page; + } + + public void setPage(String page) { + this.page = page; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public int getOrdinal() { + return ordinal; + } + + public void setOrdinal(int ordinal) { + this.ordinal = ordinal; + } + + public String getNumbering() { + return numbering; + } + + public void setNumbering(String numbering) { + this.numbering = numbering; + } + + public Boolean getMultiplicity() { + return multiplicity; + } + + public void setMultiplicity(Boolean multiplicity) { + this.multiplicity = multiplicity; + } + + public SectionEntity toDatabaseDefinition(SectionEntity item) { +// item.setDefaultVisibility(this.defaultVisibility); +// item.setDescription(this.description); +// if (this.compositeFields != null) +// item.setFieldSets(new ModelBuilder().toViewStyleDefinition(this.compositeFields, FieldSetEntity.class)); +// item.setId(this.id); +// item.setOrdinal(this.ordinal); +// item.setPage(this.page); +// if (this.sections != null) +// item.setSections(new ModelBuilder().toViewStyleDefinition(this.sections, SectionEntity.class)); +// item.setTitle(this.title); +// item.setMultiplicity(this.multiplicity); +// return item; + return null; + } + + public void fromDatabaseDefinition(SectionEntity item) { +// this.defaultVisibility = item.isDefaultVisibility(); +// this.description = item.getDescription(); +// this.compositeFields = new ModelBuilder().fromViewStyleDefinition(item.getFieldSets(), FieldSet.class); +// this.id = item.getId(); +// this.ordinal = item.getOrdinal(); +// this.numbering = item.getNumbering(); +// this.page = item.getPage(); +// this.sections = new ModelBuilder().fromViewStyleDefinition(item.getSections(), Section.class); +// this.title = item.getTitle(); +// this.multiplicity = item.getMultiplicity(); + } + + @Override + public void fromJsonObject(Map properties) { + this.sections.forEach(item -> item.fromJsonObject(properties)); + this.compositeFields.forEach(item -> item.fromJsonObject(properties)); + } + + @Override + public int compareTo(Object o) { + return this.ordinal.compareTo(((Section) o).getOrdinal()); + } + + @Override + public void fromJsonObject(Map properties, String index) { + // TODO Auto-generated method stub + + } + + public void toMap(Map fieldValues) { + this.sections.forEach(item -> item.toMap(fieldValues)); + this.compositeFields.forEach(item -> item.toMap(fieldValues)); + } + + public void toMap(Map fieldValues, int index) { + + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/models/datasetwizard/ServicePublicModel.java b/dmp-backend/core/src/main/java/eu/eudat/model/publicapi/datasetwizard/ServicePublicModel.java similarity index 91% rename from dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/models/datasetwizard/ServicePublicModel.java rename to dmp-backend/core/src/main/java/eu/eudat/model/publicapi/datasetwizard/ServicePublicModel.java index 79f085088..83a8edea6 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/models/datasetwizard/ServicePublicModel.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/publicapi/datasetwizard/ServicePublicModel.java @@ -1,13 +1,11 @@ -package eu.eudat.controllers.publicapi.models.datasetwizard; +package eu.eudat.model.publicapi.datasetwizard; import eu.eudat.data.old.Service; -import eu.eudat.logic.utilities.helpers.LabelGenerator; -import eu.eudat.models.DataModel; import java.util.Date; import java.util.UUID; -public class ServicePublicModel implements DataModel, LabelGenerator { +public class ServicePublicModel { private UUID id; private String label; private String abbreviation; @@ -101,12 +99,10 @@ public class ServicePublicModel implements DataModel { +public class FunderPublicOverviewModel { private UUID id; private String label; @@ -23,19 +22,16 @@ public class FunderPublicOverviewModel implements DataModel { +public class GrantPublicOverviewModel { private UUID id; private String label; private String abbreviation; @@ -73,7 +72,6 @@ public class GrantPublicOverviewModel implements DataModel, LabelGenerator { +public class OrganizationPublicModel { private String label; private String name; private String id; @@ -66,7 +64,6 @@ public class OrganizationPublicModel implements DataModel organisations; + private int version; + private UUID groupId; + private List datasets; + private List associatedProfiles; + private List researchers; + private List users; + private String description; + private Date publishedAt; + private List dois; + + + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + + public String getLabel() { + return label; + } + public void setLabel(String label) { + this.label = label; + } + + public String getProfile() { + return profile; + } + public void setProfile(String profile) { + this.profile = profile; + } + + public GrantPublicOverviewModel getGrant() { + return grant; + } + public void setGrant(GrantPublicOverviewModel grant) { + this.grant = grant; + } + + public Date getCreatedAt() { + return createdAt; + } + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public Date getModifiedAt() { + return modifiedAt; + } + public void setModifiedAt(Date modifiedAt) { + this.modifiedAt = modifiedAt; + } + + public Date getFinalizedAt() { + return finalizedAt; + } + public void setFinalizedAt(Date finalizedAt) { + this.finalizedAt = finalizedAt; + } + + public List getOrganisations() { + return organisations; + } + public void setOrganisations(List organizations) { + this.organisations = organizations; + } + + public int getVersion() { + return version; + } + public void setVersion(int version) { + this.version = version; + } + + public UUID getGroupId() { + return groupId; + } + public void setGroupId(UUID groupId) { + this.groupId = groupId; + } + + public List getDatasets() { + return datasets; + } + public void setDatasets(List datasets) { + this.datasets = datasets; + } + + public List getAssociatedProfiles() { + return associatedProfiles; + } + public void setAssociatedProfiles(List associatedProfiles) { + this.associatedProfiles = associatedProfiles; + } + + public List getUsers() { + return users; + } + public void setUsers(List users) { + this.users = users; + } + + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + + public List getResearchers() { + return researchers; + } + public void setResearchers(List researchers) { + this.researchers = researchers; + } + + public Date getPublishedAt() { + return publishedAt; + } + public void setPublishedAt(Date publishedAt) { + this.publishedAt = publishedAt; + } + + public List getDois() { + return dois; + } + public void setDois(List dois) { + this.dois = dois; + } + + public DmpEntity toDataModel() { + return null; + } + + public String getHint() { + return "dataManagementPlanOverviewModel"; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/models/overviewmodels/DatasetPublicModel.java b/dmp-backend/core/src/main/java/eu/eudat/model/publicapi/overviewmodels/DatasetPublicModel.java similarity index 93% rename from dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/models/overviewmodels/DatasetPublicModel.java rename to dmp-backend/core/src/main/java/eu/eudat/model/publicapi/overviewmodels/DatasetPublicModel.java index c29540840..d5501211d 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/models/overviewmodels/DatasetPublicModel.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/publicapi/overviewmodels/DatasetPublicModel.java @@ -1,19 +1,14 @@ -package eu.eudat.controllers.publicapi.models.overviewmodels; +package eu.eudat.model.publicapi.overviewmodels; import eu.eudat.commons.enums.DescriptionStatus; -import eu.eudat.controllers.publicapi.models.datasetprofile.DatasetProfilePublicModel; -import eu.eudat.controllers.publicapi.models.datasetwizard.DataRepositoryPublicModel; -import eu.eudat.controllers.publicapi.models.datasetwizard.ExternalDatasetPublicListingModel; -import eu.eudat.controllers.publicapi.models.datasetwizard.RegistryPublicModel; -import eu.eudat.controllers.publicapi.models.datasetwizard.ServicePublicModel; -import eu.eudat.controllers.publicapi.models.listingmodels.DataManagementPlanPublicListingModel; +import eu.eudat.model.publicapi.datasetprofile.DatasetProfilePublicModel; +import eu.eudat.model.publicapi.datasetwizard.*; +import eu.eudat.model.publicapi.listingmodels.DataManagementPlanPublicListingModel; import eu.eudat.data.DescriptionEntity; -import eu.eudat.models.DataModel; -import eu.eudat.models.data.user.composite.PagedDatasetProfile; import java.util.*; -public class DatasetPublicModel implements DataModel { +public class DatasetPublicModel { private UUID id; private String label; private String reference; @@ -143,7 +138,6 @@ public class DatasetPublicModel implements DataModel, LabelGenerator { - private static final Logger logger = LoggerFactory.getLogger(eu.eudat.models.data.dmp.Researcher.class); +public class ResearcherPublicModel { + private static final Logger logger = LoggerFactory.getLogger(ResearcherPublicModel.class); private String label; private String name; private String id; @@ -70,14 +68,13 @@ public class ResearcherPublicModel implements DataModel>> getPaged(@Valid @RequestBody @io.swagger.v3.oas.annotations.parameters.RequestBody(description = PublicApiStaticHelpers.Description.getPagedRequestBodyDescription) DatasetPublicTableRequest datasetTableRequest) throws Exception { - DataTableData dataTable = this.datasetManager.getPublicPaged(datasetTableRequest); - return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable)); + public @ResponseBody ResponseEntity>> getPaged( + @Valid @RequestBody @io.swagger.v3.oas.annotations.parameters.RequestBody(description = PublicApiStaticHelpers.Description.getPagedRequestBodyDescription) DatasetPublicTableRequest datasetTableRequest + ) throws Exception { +// DataTableData dataTable = this.datasetManager.getPublicPaged(datasetTableRequest); TODO + return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem>().status(ApiMessageCode.NO_MESSAGE).payload(null)); } @Operation(summary = "This method is used to get the overview of a public dataset.", description = PublicApiStaticHelpers.Description.getOverviewSinglePublicNotes) @@ -65,9 +62,10 @@ public class PublicDatasetsDescriptionDocumentation extends BaseController { )}) )}) @RequestMapping(method = RequestMethod.GET, value = {"/{id}"}, produces = "application/json") - public @ResponseBody - ResponseEntity> getOverviewSinglePublic(@PathVariable @Parameter(description = "fetch the dataset with the given id", example = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx") String id) throws Exception { - DatasetPublicModel dataset = this.datasetManager.getOverviewSinglePublic(id); - return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).payload(dataset)); + public @ResponseBody ResponseEntity> getOverviewSinglePublic( + @PathVariable @Parameter(description = "fetch the dataset with the given id", example = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx") String id + ) { +// DatasetPublicModel dataset = this.datasetManager.getOverviewSinglePublic(id); TODO + return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).payload(null)); } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/PublicDmpsDocumentation.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/PublicDmpsDocumentation.java index 882ed3087..bd226cc96 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/PublicDmpsDocumentation.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/PublicDmpsDocumentation.java @@ -1,14 +1,25 @@ package eu.eudat.controllers.publicapi; +import eu.eudat.commons.enums.DmpAccessType; import eu.eudat.controllers.BaseController; -import eu.eudat.controllers.publicapi.managers.DataManagementPlanPublicManager; -import eu.eudat.controllers.publicapi.models.listingmodels.DataManagementPlanPublicListingModel; -import eu.eudat.controllers.publicapi.models.overviewmodels.DataManagementPlanPublicModel; import eu.eudat.controllers.publicapi.request.dmp.DataManagmentPlanPublicTableRequest; import eu.eudat.controllers.publicapi.response.DataTableData; +import eu.eudat.data.DmpEntity; import eu.eudat.logic.services.ApiContext; +import eu.eudat.model.Dmp; +import eu.eudat.model.builder.DmpBuilder; +import eu.eudat.model.mapper.publicapi.DmpToPublicApiDmpListingMapper; +import eu.eudat.model.mapper.publicapi.DmpToPublicApiDmpMapper; +import eu.eudat.model.publicapi.listingmodels.DataManagementPlanPublicListingModel; +import eu.eudat.model.publicapi.overviewmodels.DataManagementPlanPublicModel; import eu.eudat.models.data.helpers.responses.ResponseItem; +import eu.eudat.query.DmpQuery; +import eu.eudat.query.lookup.DmpLookup; import eu.eudat.types.ApiMessageCode; +import gr.cite.tools.data.builder.BuilderFactory; +import gr.cite.tools.data.query.QueryFactory; +import gr.cite.tools.exception.MyNotFoundException; +import gr.cite.tools.fieldset.BaseFieldSet; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Content; @@ -16,13 +27,20 @@ import io.swagger.v3.oas.annotations.media.ExampleObject; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; +import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.MessageSource; +import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; +import java.util.List; +import java.util.Set; +import java.util.UUID; + import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; @Tag(name = "DMPs", description = "Provides DMP public API's.") @@ -33,9 +51,24 @@ public class PublicDmpsDocumentation extends BaseController { private static final Logger logger = LoggerFactory.getLogger(PublicDmpsDocumentation.class); + private final QueryFactory queryFactory; + + private final BuilderFactory builderFactory; + + private final MessageSource messageSource; + + private final DmpToPublicApiDmpMapper dmpToPublicApiDmpMapper; + + private final DmpToPublicApiDmpListingMapper dmpToPublicApiDmpListingMapper; + @Autowired - public PublicDmpsDocumentation(ApiContext apiContext) { + public PublicDmpsDocumentation(ApiContext apiContext, QueryFactory queryFactory, BuilderFactory builderFactory, MessageSource messageSource, DmpToPublicApiDmpMapper dmpToPublicApiDmpMapper, DmpToPublicApiDmpListingMapper dmpToPublicApiDmpListingMapper) { super(apiContext); + this.queryFactory = queryFactory; + this.builderFactory = builderFactory; + this.messageSource = messageSource; + this.dmpToPublicApiDmpMapper = dmpToPublicApiDmpMapper; + this.dmpToPublicApiDmpListingMapper = dmpToPublicApiDmpListingMapper; } @Operation(summary = "This method is used to get a listing of public dmps.", description = PublicApiStaticHelpers.Dmp.getPagedNotes) @@ -50,11 +83,47 @@ public class PublicDmpsDocumentation extends BaseController { )}) )}) @RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json") - public @ResponseBody - ResponseEntity>> getPaged(@Valid @RequestBody @io.swagger.v3.oas.annotations.parameters.RequestBody(description = PublicApiStaticHelpers.Dmp.getPagedRequestBodyDescription) DataManagmentPlanPublicTableRequest dmpTableRequest, - @RequestParam @Parameter(description = PublicApiStaticHelpers.Dmp.getPagedRequestParamDescription, example = "listing") String fieldsGroup) throws Exception { -// DataTableData dataTable = this.dataManagementPlanManager.getPublicPaged(dmpTableRequest, fieldsGroup); //TODO - return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem>().status(ApiMessageCode.NO_MESSAGE).payload(null)); + public @ResponseBody ResponseEntity>> getPaged( + @Valid @RequestBody @io.swagger.v3.oas.annotations.parameters.RequestBody(description = PublicApiStaticHelpers.Dmp.getPagedRequestBodyDescription) DataManagmentPlanPublicTableRequest dmpTableRequest, + @RequestParam @Parameter(description = PublicApiStaticHelpers.Dmp.getPagedRequestParamDescription, example = "listing") String fieldsGroup + ) throws Exception { + DmpLookup lookup = getDmpLookup(fieldsGroup, dmpTableRequest); + DmpQuery query = lookup.enrich(this.queryFactory).accessTypes(DmpAccessType.Public); + + List data = query.collectAs(lookup.getProject()); + List models = this.builderFactory.builder(DmpBuilder.class).build(lookup.getProject(), data); + DataTableData dataTableData = new DataTableData<>(); + dataTableData.setData(models.stream().map(this.dmpToPublicApiDmpListingMapper::toPublicListingModel).toList()); + return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem>().status(ApiMessageCode.NO_MESSAGE).payload(dataTableData)); + } + + @NotNull + private static DmpLookup getDmpLookup(String fieldsGroup, DataManagmentPlanPublicTableRequest request) { + BaseFieldSet fieldSet = new BaseFieldSet(); + Set fields; + if (fieldsGroup.equals("listing")) { + fields = Set.of( + Dmp._id, + Dmp._label, + Dmp._description, + Dmp._version, + Dmp._groupId, + Dmp._createdAt, + Dmp._updatedAt, + Dmp._finalizedAt + ); + } else { + fields = Set.of( + Dmp._id, + Dmp._label, + Dmp._groupId, + Dmp._createdAt + ); + } + fieldSet.setFields(fields); + DmpLookup lookup = new DmpLookup(); + lookup.setProject(fieldSet); + return lookup; } @Operation(summary = "This method is used to get the overview of a public dmp.", description = PublicApiStaticHelpers.Dmp.getOverviewSinglePublicNotes) @@ -66,9 +135,27 @@ public class PublicDmpsDocumentation extends BaseController { )}) )}) @RequestMapping(method = RequestMethod.GET, value = {"/{id}"}, produces = "application/json") - public @ResponseBody ResponseEntity> getOverviewSinglePublic(@PathVariable @Parameter(description = "fetch the dmp with the given id", example = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx") String id) throws Exception { -// DataManagementPlanPublicModel dataManagementPlan = this.dataManagementPlanManager.getOverviewSinglePublic(id); //TODO - return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).payload(null)); + public @ResponseBody ResponseEntity> getOverviewSinglePublic( + @PathVariable @Parameter(description = "fetch the dmp with the given id", example = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx") String id + ) { + BaseFieldSet fieldSet = new BaseFieldSet(); + Set fields = Set.of( + Dmp._id, + Dmp._label, + Dmp._description, + Dmp._version, + Dmp._groupId, + Dmp._createdAt, + Dmp._updatedAt, + Dmp._finalizedAt + ); + fieldSet.setFields(fields); + DmpQuery query = this.queryFactory.query(DmpQuery.class).ids(UUID.fromString(id)).accessTypes(DmpAccessType.Public); + Dmp model = this.builderFactory.builder(DmpBuilder.class).build(fieldSet, query.firstAs(fieldSet)); + if (model == null) + throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale())); + DataManagementPlanPublicModel dataManagementPlan = this.dmpToPublicApiDmpMapper.toPublicModel(model); + return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan)); } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/managers/DataManagementPlanPublicManager.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/managers/DataManagementPlanPublicManager.java deleted file mode 100644 index 381ff5b49..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/managers/DataManagementPlanPublicManager.java +++ /dev/null @@ -1,80 +0,0 @@ -package eu.eudat.controllers.publicapi.managers; - -import eu.eudat.commons.enums.DmpAccessType; -import eu.eudat.commons.enums.IsActive; -import eu.eudat.controllers.publicapi.models.listingmodels.DataManagementPlanPublicListingModel; -import eu.eudat.controllers.publicapi.response.DataTableData; -import eu.eudat.data.DmpEntity; -import eu.eudat.exceptions.security.ForbiddenException; -import eu.eudat.logic.managers.PaginationManager; -import eu.eudat.logic.services.ApiContext; -import eu.eudat.logic.services.operations.DatabaseRepository; -import eu.eudat.models.HintedModelFactory; -import eu.eudat.controllers.publicapi.models.overviewmodels.DataManagementPlanPublicModel; -import eu.eudat.controllers.publicapi.request.dmp.DataManagmentPlanPublicTableRequest; -import eu.eudat.queryable.QueryableList; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import java.util.UUID; -import java.util.concurrent.CompletableFuture; - -@Component -public class DataManagementPlanPublicManager { - private static final Logger logger = LoggerFactory.getLogger(DataManagementPlanPublicManager.class); - - private DatabaseRepository databaseRepository; - - @Autowired - public DataManagementPlanPublicManager(ApiContext apiContext) { - this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository(); - } - - public DataTableData getPublicPaged(DataManagmentPlanPublicTableRequest dmpTableRequest, String fieldsGroup) throws Exception { - dmpTableRequest.setQuery(databaseRepository.getDmpDao().asQueryable().withHint(DataManagementPlanPublicListingModel.getHint())); - QueryableList items = dmpTableRequest.applyCriteria(); - QueryableList pagedItems = PaginationManager.applyPaging(items, dmpTableRequest); - - DataTableData dataTable = new DataTableData<>(); - - CompletableFuture itemsFuture; - if (fieldsGroup.equals("listing")) { - itemsFuture = pagedItems.withHint(DataManagementPlanPublicListingModel.getHint()) - .selectAsync(item -> { -// item.setDataset( -// item.getDataset().stream() -// .filter(dataset -> dataset.getStatus().equals(Dataset.Status.FINALISED.getValue())).collect(Collectors.toSet())); - return new DataManagementPlanPublicListingModel().fromDataModelNoDatasets(item); - }) - .whenComplete((resultList, throwable) -> dataTable.setData(resultList)); - } else { - itemsFuture = pagedItems - .selectAsync(item -> new DataManagementPlanPublicListingModel().fromDataModel(item)) - .whenComplete((resultList, throwable) -> dataTable.setData(resultList)); - } - - CompletableFuture countFuture = pagedItems.countAsync().whenComplete((count, throwable) -> { - dataTable.setTotalCount(count); - }); - CompletableFuture.allOf(itemsFuture, countFuture).join(); - - return dataTable; - } - - public DataManagementPlanPublicModel getOverviewSinglePublic(String id) throws Exception { - DmpEntity dataManagementPlanEntity = databaseRepository.getDmpDao().find(UUID.fromString(id)); - if (dataManagementPlanEntity.getIsActive().equals(IsActive.Inactive)) { - throw new Exception("DMP is deleted."); - } - if (!dataManagementPlanEntity.getAccessType().equals(DmpAccessType.Public)) { - throw new ForbiddenException("Selected DMP is not public"); - } - DataManagementPlanPublicModel datamanagementPlan = new DataManagementPlanPublicModel(); - datamanagementPlan.fromDataModelDatasets(dataManagementPlanEntity); - datamanagementPlan.setDatasets(datamanagementPlan.getDatasets()); - - return datamanagementPlan; - } -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/managers/DatasetPublicManager.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/managers/DatasetPublicManager.java deleted file mode 100644 index b64c91f48..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/managers/DatasetPublicManager.java +++ /dev/null @@ -1,113 +0,0 @@ -package eu.eudat.controllers.publicapi.managers; - -import eu.eudat.commons.enums.DescriptionStatus; -import eu.eudat.commons.enums.IsActive; -import eu.eudat.commons.types.descriptiontemplate.DefinitionEntity; -import eu.eudat.controllers.publicapi.models.listingmodels.DatasetPublicListingModel; -import eu.eudat.controllers.publicapi.request.dataset.DatasetPublicTableRequest; -import eu.eudat.controllers.publicapi.response.DataTableData; -import eu.eudat.data.DescriptionEntity; -import eu.eudat.data.DescriptionTemplateEntity; -import eu.eudat.data.query.definition.helpers.ColumnOrderings; -import eu.eudat.logic.managers.PaginationManager; -import eu.eudat.logic.services.ApiContext; -import eu.eudat.logic.services.operations.DatabaseRepository; -import eu.eudat.commons.types.xml.XmlBuilder; -import eu.eudat.models.HintedModelFactory; -import eu.eudat.models.data.user.composite.PagedDatasetProfile; -import eu.eudat.controllers.publicapi.models.overviewmodels.DatasetPublicModel; -import eu.eudat.queryable.QueryableList; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -import jakarta.transaction.Transactional; -import java.util.*; -import java.util.stream.Collectors; - -@Component -public class DatasetPublicManager { - private static final Logger logger = LoggerFactory.getLogger(DatasetPublicManager.class); - - private DatabaseRepository databaseRepository; - - @Autowired - public DatasetPublicManager(ApiContext apiContext){ - this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository(); - } - - public DataTableData getPublicPaged(DatasetPublicTableRequest datasetTableRequest) throws Exception { - Long count = 0L; - - datasetTableRequest.setQuery(databaseRepository.getDatasetDao().asQueryable().withHint(DatasetPublicListingModel.getHint())); - QueryableList items; - - items = datasetTableRequest.applyCriteria(); - - List strings = new ArrayList<>(); - strings.add("-dmp:publishedAt|join|"); - if(datasetTableRequest.getOrderings() != null) { - datasetTableRequest.getOrderings().setFields(strings); - } - else{ - datasetTableRequest.setOrderings(new ColumnOrderings()); - datasetTableRequest.getOrderings().setFields(strings); - } - count = items.count(); - QueryableList pagedItems = PaginationManager.applyPaging(items, datasetTableRequest); - DataTableData dataTable = new DataTableData<>(); - - List datasetLists = pagedItems. - select(this::mapPublicModel); - - dataTable.setData(datasetLists.stream().filter(Objects::nonNull).collect(Collectors.toList())); - dataTable.setTotalCount(count); - return dataTable; - } - - public DatasetPublicModel getOverviewSinglePublic(String id) throws Exception { - DescriptionEntity descriptionEntityEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id)); - if (descriptionEntityEntity.getIsActive() == IsActive.Inactive) { - throw new Exception("Dataset is deleted."); - } - DatasetPublicModel dataset = new DatasetPublicModel(); - dataset.setDatasetProfileDefinition(this.getPagedProfile(dataset.getStatus(), descriptionEntityEntity)); - dataset.fromDataModel(descriptionEntityEntity); - - return dataset; - } - - @Transactional - private DatasetPublicListingModel mapPublicModel(DescriptionEntity item) { - DatasetPublicListingModel listingPublicModel = new DatasetPublicListingModel().fromDataModel(item); - return listingPublicModel; - } - - private PagedDatasetProfile getPagedProfile(DescriptionStatus status, DescriptionEntity descriptionEntityEntity){ - //TODO -// eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = this.generateDatasetProfileModel(descriptionEntityEntity.getProfile()); -// datasetprofile.setStatus(status.getValue()); -// if (descriptionEntityEntity.getProperties() != null) { -// JSONObject jObject = new JSONObject(descriptionEntityEntity.getProperties()); -// Map properties = jObject.toMap(); -// datasetprofile.fromJsonObject(properties); -// } - PagedDatasetProfile pagedDatasetProfile = new PagedDatasetProfile(); -// pagedDatasetProfile.buildPagedDatasetProfile(datasetprofile); - return pagedDatasetProfile; - } - - private eu.eudat.models.data.user.composite.DatasetProfile generateDatasetProfileModel(DescriptionTemplateEntity profile) { - Document viewStyleDoc = XmlBuilder.fromXml(profile.getDefinition()); - Element root = (Element) viewStyleDoc.getDocumentElement(); - DefinitionEntity viewstyle = new DefinitionEntity().fromXml(root); - - eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = new eu.eudat.models.data.user.composite.DatasetProfile(); - datasetprofile.buildProfile(viewstyle); - - return datasetprofile; - } -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/models/overviewmodels/DataManagementPlanPublicModel.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/models/overviewmodels/DataManagementPlanPublicModel.java deleted file mode 100644 index af4a81a52..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/models/overviewmodels/DataManagementPlanPublicModel.java +++ /dev/null @@ -1,249 +0,0 @@ -package eu.eudat.controllers.publicapi.models.overviewmodels; - -import eu.eudat.commons.types.descriptiontemplate.DefinitionEntity; -import eu.eudat.controllers.publicapi.models.doi.DoiPublicModel; -import eu.eudat.controllers.publicapi.models.grant.GrantPublicOverviewModel; -import eu.eudat.controllers.publicapi.models.organisation.OrganizationPublicModel; -import eu.eudat.controllers.publicapi.models.researcher.ResearcherPublicModel; -import eu.eudat.data.DescriptionEntity; -import eu.eudat.data.DescriptionTemplateEntity; -import eu.eudat.commons.types.xml.XmlBuilder; -import eu.eudat.data.DmpEntity; -import eu.eudat.model.DmpUser; -import eu.eudat.models.DataModel; -import eu.eudat.models.data.user.composite.PagedDatasetProfile; -import eu.eudat.controllers.publicapi.models.associatedprofile.AssociatedProfilePublicModel; -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -import java.util.*; - -public class DataManagementPlanPublicModel implements DataModel { - private String id; - private String label; - private String profile; - private GrantPublicOverviewModel grant; - private Date createdAt; - private Date modifiedAt; - private Date finalizedAt; - private List organisations; - private int version; - private UUID groupId; - private List datasets; - private List associatedProfiles; - private List researchers; - private List users; - private String description; - private Date publishedAt; - private List dois; - - - public String getId() { - return id; - } - public void setId(String id) { - this.id = id; - } - - public String getLabel() { - return label; - } - public void setLabel(String label) { - this.label = label; - } - - public String getProfile() { - return profile; - } - public void setProfile(String profile) { - this.profile = profile; - } - - public GrantPublicOverviewModel getGrant() { - return grant; - } - public void setGrant(GrantPublicOverviewModel grant) { - this.grant = grant; - } - - public Date getCreatedAt() { - return createdAt; - } - public void setCreatedAt(Date createdAt) { - this.createdAt = createdAt; - } - - public Date getModifiedAt() { - return modifiedAt; - } - public void setModifiedAt(Date modifiedAt) { - this.modifiedAt = modifiedAt; - } - - public Date getFinalizedAt() { - return finalizedAt; - } - public void setFinalizedAt(Date finalizedAt) { - this.finalizedAt = finalizedAt; - } - - public List getOrganisations() { - return organisations; - } - public void setOrganisations(List organizations) { - this.organisations = organizations; - } - - public int getVersion() { - return version; - } - public void setVersion(int version) { - this.version = version; - } - - public UUID getGroupId() { - return groupId; - } - public void setGroupId(UUID groupId) { - this.groupId = groupId; - } - - public List getDatasets() { - return datasets; - } - public void setDatasets(List datasets) { - this.datasets = datasets; - } - - public List getAssociatedProfiles() { - return associatedProfiles; - } - public void setAssociatedProfiles(List associatedProfiles) { - this.associatedProfiles = associatedProfiles; - } - - public List getUsers() { - return users; - } - public void setUsers(List users) { - this.users = users; - } - - public String getDescription() { - return description; - } - public void setDescription(String description) { - this.description = description; - } - - public List getResearchers() { - return researchers; - } - public void setResearchers(List researchers) { - this.researchers = researchers; - } - - public Date getPublishedAt() { - return publishedAt; - } - public void setPublishedAt(Date publishedAt) { - this.publishedAt = publishedAt; - } - - public List getDois() { - return dois; - } - public void setDois(List dois) { - this.dois = dois; - } - - @Override - public DataManagementPlanPublicModel fromDataModel(DmpEntity entity) { - this.id = entity.getId().toString(); - this.label = entity.getLabel(); - this.groupId = entity.getGroupId(); -// if (entity.getResearchers() != null) { //TODO -// this.researchers = entity.getResearchers().stream().map(item -> new ResearcherPublicModel().fromDataModel(item)).collect(Collectors.toList()); -// } - return this; - } - - public DataManagementPlanPublicModel fromDataModelDatasets(DmpEntity entity) { - this.fromDataModel(entity); - this.version = entity.getVersion();//TODO -// if (entity.getGrant() != null) { -// this.grant = new GrantPublicOverviewModel().fromDataModel(entity.getGrant()); -// } -// if (entity.getProfile() != null) this.profile = entity.getProfile().getLabel(); -// this.createdAt = entity.getCreated(); -// this.modifiedAt = entity.getModified(); -// this.finalizedAt = entity.getFinalizedAt(); -// this.organisations = entity.getOrganisations().stream().map(item -> new OrganizationPublicModel().fromDataModel(item)).collect(Collectors.toList()); -// this.datasets = entity.getDataset().stream().filter(dataset -> !dataset.getIsActive().equals(IsActive.Inactive) && !dataset.getStatus().equals(DescriptionStatus.Canceled)) -// .map(datasetEntity-> { -// DatasetPublicModel dataset = new DatasetPublicModel(); -// dataset.setDatasetProfileDefinition(this.getPagedProfile(dataset.getStatus().getValue(), datasetEntity)); -// dataset.fromDataModel(datasetEntity); -// return dataset; -// }).collect(Collectors.toList()); -// this.users = entity.getUsers().stream().map(x -> new UserInfoPublicModel().fromDataModel(x)).collect(Collectors.toList()); -// this.description = entity.getDescription(); -// if (entity.getResearchers() != null) { -// this.researchers = entity.getResearchers().stream().map(item -> new ResearcherPublicModel().fromDataModel(item)).collect(Collectors.toList()); -// } -// -// if (entity.getAssociatedDmps() != null && !entity.getAssociatedDmps().isEmpty()) { -// this.associatedProfiles = new LinkedList<>(); -// for (DMPDatasetProfile dmpDescriptionProfile : entity.getAssociatedDmps()) { -// AssociatedProfilePublicModel associatedProfile = new AssociatedProfilePublicModel().fromData(dmpDescriptionProfile.getDatasetprofile()); -// associatedProfile.setId(dmpDescriptionProfile.getId()); -// try { -// associatedProfile.setData(new ObjectMapper().readValue(dmpDescriptionProfile.getData(), new TypeReference>() {})); -// } -// catch (Exception e) { -// associatedProfile.setData(null); -// } -// this.associatedProfiles.add(associatedProfile); -// } -// } -// this.publishedAt = entity.getPublishedAt(); -// this.dois = entity.getDois().stream().map(item -> new DoiPublicModel().fromDataModel(item)).collect(Collectors.toList()); - - return this; - } - - private PagedDatasetProfile getPagedProfile(int status, DescriptionEntity descriptionEntityEntity){ - //TODO -// eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = this.generateDatasetProfileModel(descriptionEntityEntity.getProfile()); -// datasetprofile.setStatus(status); -// if (descriptionEntityEntity.getProperties() != null) { -// JSONObject jObject = new JSONObject(descriptionEntityEntity.getProperties()); -// Map properties = jObject.toMap(); -// datasetprofile.fromJsonObject(properties); -// } - PagedDatasetProfile pagedDatasetProfile = new PagedDatasetProfile(); - //pagedDatasetProfile.buildPagedDatasetProfile(datasetprofile); - return pagedDatasetProfile; - } - - private eu.eudat.models.data.user.composite.DatasetProfile generateDatasetProfileModel(DescriptionTemplateEntity profile) { - Document viewStyleDoc = XmlBuilder.fromXml(profile.getDefinition()); - Element root = (Element) viewStyleDoc.getDocumentElement(); - DefinitionEntity viewstyle = new DefinitionEntity().fromXml(root); - - eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = new eu.eudat.models.data.user.composite.DatasetProfile(); - datasetprofile.buildProfile(viewstyle); - - return datasetprofile; - } - - @Override - public DmpEntity toDataModel() { - return null; - } - - @Override - public String getHint() { - return "dataManagementPlanOverviewModel"; - } -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/externaldataset/ExternalDatasetListingModel.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/externaldataset/ExternalDatasetListingModel.java index bc5692c39..5e7619387 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/externaldataset/ExternalDatasetListingModel.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/externaldataset/ExternalDatasetListingModel.java @@ -2,7 +2,7 @@ package eu.eudat.models.data.externaldataset; import eu.eudat.data.old.ExternalDataset; import eu.eudat.models.DataModel; -import eu.eudat.types.externalsourcetype.ExternalDatasetType; +import eu.eudat.model.publicapi.datasetwizard.ExternalDatasetType; import java.util.Date; import java.util.UUID;