Refactoring and preparing for dmp and dataset conversion for public API
This commit is contained in:
parent
61218ed220
commit
0166bf8ece
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
|
@ -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<DescriptionTemplateEntity, DatasetProfilePublicModel> {
|
||||
public class DatasetProfilePublicModel {
|
||||
private UUID id;
|
||||
private String label;
|
||||
|
||||
|
@ -23,14 +22,12 @@ public class DatasetProfilePublicModel implements DataModel<DescriptionTemplateE
|
|||
this.label = label;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DatasetProfilePublicModel fromDataModel(DescriptionTemplateEntity entity) {
|
||||
this.id = entity.getId();
|
||||
this.label = entity.getLabel();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DescriptionTemplateEntity toDataModel() {
|
||||
DescriptionTemplateEntity entity = new DescriptionTemplateEntity();
|
||||
entity.setId(this.getId());
|
||||
|
@ -38,8 +35,4 @@ public class DatasetProfilePublicModel implements DataModel<DescriptionTemplateE
|
|||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHint() {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,13 +1,11 @@
|
|||
package eu.eudat.controllers.publicapi.models.datasetwizard;
|
||||
package eu.eudat.model.publicapi.datasetwizard;
|
||||
|
||||
import eu.eudat.data.old.DataRepository;
|
||||
import eu.eudat.logic.utilities.helpers.LabelGenerator;
|
||||
import eu.eudat.models.DataModel;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
public class DataRepositoryPublicModel implements DataModel<DataRepository, DataRepositoryPublicModel>, LabelGenerator {
|
||||
public class DataRepositoryPublicModel {
|
||||
private String id;
|
||||
private String pid;
|
||||
private String name;
|
||||
|
@ -124,12 +122,10 @@ public class DataRepositoryPublicModel implements DataModel<DataRepository, Data
|
|||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String generateLabel() {
|
||||
return this.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHint() {
|
||||
return null;
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
package eu.eudat.model.publicapi.datasetwizard;
|
||||
|
||||
import eu.eudat.commons.types.descriptiontemplate.DefinitionEntity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class DatasetProfile implements PropertiesModelBuilder {
|
||||
private String description;
|
||||
private String language;
|
||||
private String type;
|
||||
private List<Section> sections;
|
||||
private List<Rule> rules;
|
||||
private List<Page> 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<Section> getSections() {
|
||||
return sections;
|
||||
}
|
||||
|
||||
public void setSections(List<Section> sections) {
|
||||
this.sections = sections;
|
||||
}
|
||||
|
||||
|
||||
public List<Rule> getRules() {
|
||||
return rules;
|
||||
}
|
||||
|
||||
public void setRules(List<Rule> rules) {
|
||||
this.rules = rules;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public List<Page> getPages() {
|
||||
return pages;
|
||||
}
|
||||
|
||||
public void setPages(List<Page> pages) {
|
||||
this.pages = pages;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromJsonObject(Map<String, Object> properties) {
|
||||
this.sections.forEach(item -> item.fromJsonObject(properties));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromJsonObject(Map<String, Object> properties, String index) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -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<Section> 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<Section> getSections() {
|
||||
return sections;
|
||||
}
|
||||
|
||||
public void setSections(List<Section> sections) {
|
||||
this.sections = sections;
|
||||
}
|
||||
}
|
|
@ -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<ExternalDataset, ExternalDatasetPublicListingModel> {
|
||||
public class ExternalDatasetPublicListingModel {
|
||||
private UUID id;
|
||||
private String name;
|
||||
private String abbreviation;
|
||||
|
@ -105,7 +103,6 @@ public class ExternalDatasetPublicListingModel implements DataModel<ExternalData
|
|||
this.source = source;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExternalDatasetPublicListingModel fromDataModel(ExternalDataset entity) {
|
||||
this.id = entity.getId();
|
||||
this.abbreviation = entity.getAbbreviation();
|
||||
|
@ -122,7 +119,6 @@ public class ExternalDatasetPublicListingModel implements DataModel<ExternalData
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExternalDataset toDataModel() throws Exception {
|
||||
ExternalDataset externalDataset = new ExternalDataset();
|
||||
externalDataset.setAbbreviation(this.abbreviation);
|
||||
|
@ -146,7 +142,6 @@ public class ExternalDatasetPublicListingModel implements DataModel<ExternalData
|
|||
return externalDataset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHint() {
|
||||
return null;
|
||||
}
|
|
@ -1,10 +1,5 @@
|
|||
package eu.eudat.types.externalsourcetype;
|
||||
package eu.eudat.model.publicapi.datasetwizard;
|
||||
|
||||
import eu.eudat.types.ApiMessageCode;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 5/28/2018.
|
||||
*/
|
||||
public enum ExternalDatasetType{
|
||||
|
||||
SOURCE(0), OUTPUT(1) ;
|
|
@ -0,0 +1,296 @@
|
|||
package eu.eudat.model.publicapi.datasetwizard;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import eu.eudat.commons.enums.FieldValidationType;
|
||||
import eu.eudat.commons.types.descriptiontemplate.FieldEntity;
|
||||
import eu.eudat.commons.types.descriptiontemplate.MultiplicityEntity;
|
||||
import eu.eudat.commons.types.descriptiontemplate.todelete.DefaultValueEntity;
|
||||
import eu.eudat.commons.types.descriptiontemplate.todelete.FieldDescriptionEntity;
|
||||
import eu.eudat.commons.types.descriptiontemplate.todelete.VisibilityEntity;
|
||||
import org.apache.commons.lang3.NotImplementedException;
|
||||
import org.json.JSONException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Field implements Comparable, PropertiesModelBuilder {
|
||||
private static final Logger logger = LoggerFactory.getLogger(Field.class);
|
||||
private String id;
|
||||
private Integer ordinal;
|
||||
private Object value;
|
||||
private FieldDescriptionEntity viewStyle;
|
||||
private String datatype;
|
||||
private String numbering;
|
||||
private int page;
|
||||
private DefaultValueEntity defaultValue;
|
||||
private MultiplicityEntity multiplicity;
|
||||
private Object data;
|
||||
private List<Field> multiplicityItems;
|
||||
private List<FieldValidationType> validations;
|
||||
private VisibilityEntity visible;
|
||||
private List<String> schematics;
|
||||
|
||||
private Boolean export;
|
||||
|
||||
public List<Field> getMultiplicityItems() {
|
||||
return multiplicityItems;
|
||||
}
|
||||
|
||||
public void setMultiplicityItems(List<Field> 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<Integer> getValidations() {
|
||||
if(this.validations == null) {
|
||||
return null;
|
||||
}
|
||||
return this.validations.stream().map(item -> (int) item.getValue()).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public void setValidations(List<Integer> 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<String> getSchematics() {
|
||||
return schematics;
|
||||
}
|
||||
|
||||
public void setSchematics(List<String> schematics) {
|
||||
this.schematics = schematics;
|
||||
}
|
||||
|
||||
public Boolean getExport() {
|
||||
return export;
|
||||
}
|
||||
|
||||
public void setExport(Boolean export) {
|
||||
this.export = export;
|
||||
}
|
||||
|
||||
Field cloneForMultiplicity(String key, Map<String, Object> 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<String, Object> properties) {
|
||||
try {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
List<String> 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<String> 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<String, Object> properties, String path) {
|
||||
this.value = (String) properties.get(path);
|
||||
}
|
||||
|
||||
public void toMap(Map<String, Object> 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<String, Object> fieldValues, int index) {
|
||||
fieldValues.put(this.id, this.value);
|
||||
}
|
||||
}
|
|
@ -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<Object>, 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<Field> fields;
|
||||
private List<FieldSet> multiplicityItems;
|
||||
private boolean hasCommentField;
|
||||
private String commentFieldValue;
|
||||
|
||||
public List<Field> 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<Field> 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<FieldSet> 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<FieldSet> 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<FieldEntity> 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<String, Object> properties) {
|
||||
this.commentFieldValue = (String) properties.get("commentFieldValue" + this.id);
|
||||
this.multiplicityItems = new LinkedList<FieldSet>();
|
||||
this.fields.forEach(item -> {
|
||||
item.fromJsonObject(properties);
|
||||
});
|
||||
List<String> compositeKeysFather = properties.keySet().stream().filter(keys -> keys.startsWith("multiple_" + this.getId())).collect(Collectors.toList());
|
||||
List<String> 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<String> key, Map<String, Object> 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<String, Object> properties, String path) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public void toMap(Map<String, Object> fieldValues) {
|
||||
fieldValues.put("commentFieldValue" + this.id, this.commentFieldValue);
|
||||
this.fields.forEach(item -> item.toMap(fieldValues));
|
||||
Map<String, Object> multiplicity = new HashMap<String, Object>();
|
||||
if (this.multiplicityItems != null) {
|
||||
this.multiplicityItems.forEach(item -> item.toMap(fieldValues, this.multiplicityItems.indexOf(item)));
|
||||
}
|
||||
//fieldValues.put(this.id,multiplicity);
|
||||
}
|
||||
|
||||
public void toMap(Map<String, Object> fieldValues, int index) {
|
||||
this.fields.forEach(item -> item.toMap(fieldValues, index));
|
||||
//this.multiplicityItems.forEach(item->item.toMap(fieldValues,index));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package eu.eudat.model.publicapi.datasetwizard;
|
||||
|
||||
import eu.eudat.commons.types.descriptiontemplate.PageEntity;
|
||||
|
||||
public class Page implements Comparable<Object> {
|
||||
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);
|
||||
}
|
||||
}
|
|
@ -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<DatasetProfilePage> pages;
|
||||
private List<Rule> rules;
|
||||
private int status;
|
||||
|
||||
public List<DatasetProfilePage> getPages() {
|
||||
return pages;
|
||||
}
|
||||
|
||||
public void setPages(List<DatasetProfilePage> pages) {
|
||||
this.pages = pages;
|
||||
}
|
||||
|
||||
public List<Rule> getRules() {
|
||||
return rules;
|
||||
}
|
||||
|
||||
public void setRules(List<Rule> 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<Page> 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<String, Object> fieldValues) {
|
||||
this.pages.forEach(item -> item.getSections().forEach(sectionItem -> sectionItem.toMap(fieldValues)));
|
||||
}
|
||||
|
||||
public void toMap(Map<String, Object> fieldValues, int index) {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package eu.eudat.model.publicapi.datasetwizard;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface PropertiesModelBuilder {
|
||||
void fromJsonObject(Map<String, Object> properties);
|
||||
|
||||
void fromJsonObject(Map<String, Object> properties, String pathKey);
|
||||
}
|
|
@ -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<Registry,RegistryPublicModel>, LabelGenerator {
|
||||
public class RegistryPublicModel {
|
||||
private UUID id;
|
||||
private String label;
|
||||
private String abbreviation;
|
||||
|
@ -33,7 +31,7 @@ public class RegistryPublicModel implements DataModel<Registry,RegistryPublicMod
|
|||
public String getAbbreviation() {
|
||||
return abbreviation;
|
||||
}
|
||||
@Override
|
||||
|
||||
public String generateLabel() {
|
||||
return getLabel();
|
||||
}
|
||||
|
@ -105,7 +103,6 @@ public class RegistryPublicModel implements DataModel<Registry,RegistryPublicMod
|
|||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHint() {
|
||||
return null;
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package eu.eudat.model.publicapi.datasetwizard;
|
||||
|
||||
import eu.eudat.commons.types.descriptiontemplate.RuleEntity;
|
||||
|
||||
public class Rule {
|
||||
private String sourceField;
|
||||
private String targetField;
|
||||
private String requiredValue;
|
||||
private String type;
|
||||
|
||||
public String getSourceField() {
|
||||
return sourceField;
|
||||
}
|
||||
|
||||
public void setSourceField(String sourceField) {
|
||||
this.sourceField = sourceField;
|
||||
}
|
||||
|
||||
public String getTargetField() {
|
||||
return targetField;
|
||||
}
|
||||
|
||||
public void setTargetField(String targetField) {
|
||||
this.targetField = targetField;
|
||||
}
|
||||
|
||||
public String getRequiredValue() {
|
||||
return requiredValue;
|
||||
}
|
||||
|
||||
public void setRequiredValue(String requiredValue) {
|
||||
this.requiredValue = requiredValue;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Rule fromDefinitionRule(RuleEntity rule) {
|
||||
this.targetField = rule.getTarget();
|
||||
this.requiredValue = rule.getValue();
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,157 @@
|
|||
package eu.eudat.model.publicapi.datasetwizard;
|
||||
|
||||
import eu.eudat.commons.types.descriptiontemplate.SectionEntity;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class Section implements Comparable<Object>, PropertiesModelBuilder {
|
||||
private List<Section> sections;
|
||||
private List<FieldSet> 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<Section> getSections() {
|
||||
Collections.sort(sections);
|
||||
return sections;
|
||||
}
|
||||
|
||||
public void setSections(List<Section> sections) {
|
||||
this.sections = sections;
|
||||
}
|
||||
|
||||
public List<FieldSet> getCompositeFields() {
|
||||
Collections.sort(compositeFields);
|
||||
return compositeFields;
|
||||
}
|
||||
|
||||
public void setCompositeFields(List<FieldSet> 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<String, Object> 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<String, Object> properties, String index) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public void toMap(Map<String, Object> fieldValues) {
|
||||
this.sections.forEach(item -> item.toMap(fieldValues));
|
||||
this.compositeFields.forEach(item -> item.toMap(fieldValues));
|
||||
}
|
||||
|
||||
public void toMap(Map<String, Object> fieldValues, int index) {
|
||||
|
||||
}
|
||||
}
|
|
@ -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<Service, ServicePublicModel>, LabelGenerator {
|
||||
public class ServicePublicModel {
|
||||
private UUID id;
|
||||
private String label;
|
||||
private String abbreviation;
|
||||
|
@ -101,12 +99,10 @@ public class ServicePublicModel implements DataModel<Service, ServicePublicModel
|
|||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String generateLabel() {
|
||||
return this.label;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHint() {
|
||||
return null;
|
||||
}
|
|
@ -1,11 +1,10 @@
|
|||
package eu.eudat.controllers.publicapi.models.doi;
|
||||
package eu.eudat.model.publicapi.doi;
|
||||
|
||||
import eu.eudat.data.EntityDoiEntity;
|
||||
import eu.eudat.logic.utilities.helpers.LabelGenerator;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class DoiPublicModel implements LabelGenerator {
|
||||
public class DoiPublicModel {
|
||||
private UUID id;
|
||||
private String repositoryId;
|
||||
private String doi;
|
||||
|
@ -46,7 +45,6 @@ public class DoiPublicModel implements LabelGenerator {
|
|||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String generateLabel() {
|
||||
return this.getDoi();
|
||||
}
|
|
@ -1,11 +1,10 @@
|
|||
package eu.eudat.controllers.publicapi.models.funder;
|
||||
package eu.eudat.model.publicapi.funder;
|
||||
|
||||
import eu.eudat.data.old.Funder;
|
||||
import eu.eudat.models.DataModel;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class FunderPublicOverviewModel implements DataModel<Funder, FunderPublicOverviewModel> {
|
||||
public class FunderPublicOverviewModel {
|
||||
private UUID id;
|
||||
private String label;
|
||||
|
||||
|
@ -23,19 +22,16 @@ public class FunderPublicOverviewModel implements DataModel<Funder, FunderPublic
|
|||
this.label = label;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FunderPublicOverviewModel fromDataModel(Funder entity) {
|
||||
this.id = entity.getId();
|
||||
this.label = entity.getLabel();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Funder toDataModel() throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHint() {
|
||||
return null;
|
||||
}
|
|
@ -1,13 +1,12 @@
|
|||
package eu.eudat.controllers.publicapi.models.grant;
|
||||
package eu.eudat.model.publicapi.grant;
|
||||
|
||||
import eu.eudat.controllers.publicapi.models.funder.FunderPublicOverviewModel;
|
||||
import eu.eudat.data.old.Grant;
|
||||
import eu.eudat.models.DataModel;
|
||||
import eu.eudat.model.publicapi.funder.FunderPublicOverviewModel;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
public class GrantPublicOverviewModel implements DataModel<Grant, GrantPublicOverviewModel> {
|
||||
public class GrantPublicOverviewModel {
|
||||
private UUID id;
|
||||
private String label;
|
||||
private String abbreviation;
|
||||
|
@ -73,7 +72,6 @@ public class GrantPublicOverviewModel implements DataModel<Grant, GrantPublicOve
|
|||
this.funder = funder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GrantPublicOverviewModel fromDataModel(Grant entity) {
|
||||
this.id = entity.getId();
|
||||
this.label = entity.getLabel();
|
||||
|
@ -88,12 +86,10 @@ public class GrantPublicOverviewModel implements DataModel<Grant, GrantPublicOve
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Grant toDataModel() throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHint() {
|
||||
return null;
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
package eu.eudat.controllers.publicapi.models.listingmodels;
|
||||
package eu.eudat.model.publicapi.listingmodels;
|
||||
|
||||
import eu.eudat.data.DmpEntity;
|
||||
import eu.eudat.model.DmpUser;
|
||||
import eu.eudat.controllers.publicapi.models.researcher.ResearcherPublicModel;
|
||||
import eu.eudat.model.publicapi.researcher.ResearcherPublicModel;
|
||||
|
||||
import java.util.*;
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
package eu.eudat.controllers.publicapi.models.listingmodels;
|
||||
package eu.eudat.model.publicapi.listingmodels;
|
||||
|
||||
import eu.eudat.data.DescriptionEntity;
|
||||
import eu.eudat.model.DmpUser;
|
||||
import eu.eudat.controllers.publicapi.models.datasetprofile.DatasetProfilePublicModel;
|
||||
import eu.eudat.model.publicapi.datasetprofile.DatasetProfilePublicModel;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
|
@ -1,14 +1,12 @@
|
|||
package eu.eudat.controllers.publicapi.models.organisation;
|
||||
package eu.eudat.model.publicapi.organisation;
|
||||
|
||||
import eu.eudat.data.old.Organisation;
|
||||
import eu.eudat.logic.utilities.helpers.LabelGenerator;
|
||||
import eu.eudat.models.DataModel;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
public class OrganizationPublicModel implements DataModel<Organisation, OrganizationPublicModel>, LabelGenerator {
|
||||
public class OrganizationPublicModel {
|
||||
private String label;
|
||||
private String name;
|
||||
private String id;
|
||||
|
@ -66,7 +64,6 @@ public class OrganizationPublicModel implements DataModel<Organisation, Organiza
|
|||
this.key = key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrganizationPublicModel fromDataModel(Organisation entity) {
|
||||
this.id = entity.getId().toString();
|
||||
this.name = entity.getLabel();
|
||||
|
@ -78,7 +75,6 @@ public class OrganizationPublicModel implements DataModel<Organisation, Organiza
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Organisation toDataModel() {
|
||||
Organisation organisationEntity = new Organisation();
|
||||
if (this.key != null && this.reference != null) {
|
||||
|
@ -112,12 +108,10 @@ public class OrganizationPublicModel implements DataModel<Organisation, Organiza
|
|||
return model;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String generateLabel() {
|
||||
return this.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHint() {
|
||||
return null;
|
||||
}
|
|
@ -0,0 +1,161 @@
|
|||
package eu.eudat.model.publicapi.overviewmodels;
|
||||
|
||||
import eu.eudat.data.DmpEntity;
|
||||
import eu.eudat.model.DmpUser;
|
||||
import eu.eudat.model.publicapi.associatedprofile.AssociatedProfilePublicModel;
|
||||
import eu.eudat.model.publicapi.doi.DoiPublicModel;
|
||||
import eu.eudat.model.publicapi.grant.GrantPublicOverviewModel;
|
||||
import eu.eudat.model.publicapi.organisation.OrganizationPublicModel;
|
||||
import eu.eudat.model.publicapi.researcher.ResearcherPublicModel;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class DataManagementPlanPublicModel {
|
||||
private String id;
|
||||
private String label;
|
||||
private String profile;
|
||||
private GrantPublicOverviewModel grant;
|
||||
private Date createdAt;
|
||||
private Date modifiedAt;
|
||||
private Date finalizedAt;
|
||||
private List<OrganizationPublicModel> organisations;
|
||||
private int version;
|
||||
private UUID groupId;
|
||||
private List<DatasetPublicModel> datasets;
|
||||
private List<AssociatedProfilePublicModel> associatedProfiles;
|
||||
private List<ResearcherPublicModel> researchers;
|
||||
private List<DmpUser> users;
|
||||
private String description;
|
||||
private Date publishedAt;
|
||||
private List<DoiPublicModel> 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<OrganizationPublicModel> getOrganisations() {
|
||||
return organisations;
|
||||
}
|
||||
public void setOrganisations(List<OrganizationPublicModel> 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<DatasetPublicModel> getDatasets() {
|
||||
return datasets;
|
||||
}
|
||||
public void setDatasets(List<DatasetPublicModel> datasets) {
|
||||
this.datasets = datasets;
|
||||
}
|
||||
|
||||
public List<AssociatedProfilePublicModel> getAssociatedProfiles() {
|
||||
return associatedProfiles;
|
||||
}
|
||||
public void setAssociatedProfiles(List<AssociatedProfilePublicModel> associatedProfiles) {
|
||||
this.associatedProfiles = associatedProfiles;
|
||||
}
|
||||
|
||||
public List<DmpUser> getUsers() {
|
||||
return users;
|
||||
}
|
||||
public void setUsers(List<DmpUser> users) {
|
||||
this.users = users;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public List<ResearcherPublicModel> getResearchers() {
|
||||
return researchers;
|
||||
}
|
||||
public void setResearchers(List<ResearcherPublicModel> researchers) {
|
||||
this.researchers = researchers;
|
||||
}
|
||||
|
||||
public Date getPublishedAt() {
|
||||
return publishedAt;
|
||||
}
|
||||
public void setPublishedAt(Date publishedAt) {
|
||||
this.publishedAt = publishedAt;
|
||||
}
|
||||
|
||||
public List<DoiPublicModel> getDois() {
|
||||
return dois;
|
||||
}
|
||||
public void setDois(List<DoiPublicModel> dois) {
|
||||
this.dois = dois;
|
||||
}
|
||||
|
||||
public DmpEntity toDataModel() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getHint() {
|
||||
return "dataManagementPlanOverviewModel";
|
||||
}
|
||||
}
|
|
@ -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<DescriptionEntity, DatasetPublicModel> {
|
||||
public class DatasetPublicModel {
|
||||
private UUID id;
|
||||
private String label;
|
||||
private String reference;
|
||||
|
@ -143,7 +138,6 @@ public class DatasetPublicModel implements DataModel<DescriptionEntity, DatasetP
|
|||
this.modifiedAt = modifiedAt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DatasetPublicModel fromDataModel(DescriptionEntity entity) {
|
||||
//TODO:
|
||||
// this.id = entity.getId();
|
||||
|
@ -217,7 +211,6 @@ public class DatasetPublicModel implements DataModel<DescriptionEntity, DatasetP
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DescriptionEntity toDataModel() throws Exception {
|
||||
//TODO:
|
||||
DescriptionEntity entity = new DescriptionEntity();
|
||||
|
@ -286,8 +279,6 @@ public class DatasetPublicModel implements DataModel<DescriptionEntity, DatasetP
|
|||
return entity;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getHint() {
|
||||
return "datasetOverviewModel";
|
||||
}
|
|
@ -1,9 +1,7 @@
|
|||
package eu.eudat.controllers.publicapi.models.researcher;
|
||||
package eu.eudat.model.publicapi.researcher;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import eu.eudat.data.old.Researcher;
|
||||
import eu.eudat.logic.utilities.helpers.LabelGenerator;
|
||||
import eu.eudat.models.DataModel;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -11,8 +9,8 @@ import java.util.Date;
|
|||
import java.util.UUID;
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class ResearcherPublicModel implements DataModel<Researcher, ResearcherPublicModel>, 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<Researcher, ResearcherPu
|
|||
this.key = key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResearcherPublicModel fromDataModel(Researcher entity) {
|
||||
this.id = entity.getId().toString();
|
||||
this.label = entity.getUri();
|
||||
this.name = entity.getLabel();
|
||||
this.status = entity.getStatus();
|
||||
this.reference = entity.getReference();
|
||||
String refParts[] = entity.getReference().split(":");
|
||||
String[] refParts = entity.getReference().split(":");
|
||||
String source = refParts[0];
|
||||
if (source.equals("dmp"))
|
||||
this.key = "Internal";
|
||||
|
@ -86,7 +83,6 @@ public class ResearcherPublicModel implements DataModel<Researcher, ResearcherPu
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Researcher toDataModel() {
|
||||
Researcher researcher = new Researcher();
|
||||
if (this.id == null) {
|
||||
|
@ -94,7 +90,7 @@ public class ResearcherPublicModel implements DataModel<Researcher, ResearcherPu
|
|||
}
|
||||
researcher.setId(UUID.fromString(this.id));
|
||||
if (this.key != null) {
|
||||
if (this.key.toLowerCase().equals("internal")) {
|
||||
if (this.key.equalsIgnoreCase("internal")) {
|
||||
if (this.reference != null && !this.reference.startsWith("dmp:")) {
|
||||
researcher.setReference("dmp:" + this.reference);
|
||||
} else if (this.reference == null) {
|
||||
|
@ -123,29 +119,4 @@ public class ResearcherPublicModel implements DataModel<Researcher, ResearcherPu
|
|||
researcher.setStatus((short) this.status);
|
||||
return researcher;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String generateLabel() {
|
||||
return this.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHint() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
ResearcherPublicModel that = (ResearcherPublicModel) o;
|
||||
|
||||
return id.equals(that.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return reference.hashCode();
|
||||
}
|
||||
}
|
|
@ -1,12 +1,11 @@
|
|||
package eu.eudat.controllers.publicapi;
|
||||
|
||||
import eu.eudat.controllers.BaseController;
|
||||
import eu.eudat.controllers.publicapi.managers.DatasetPublicManager;
|
||||
import eu.eudat.controllers.publicapi.models.listingmodels.DatasetPublicListingModel;
|
||||
import eu.eudat.model.publicapi.listingmodels.DatasetPublicListingModel;
|
||||
import eu.eudat.controllers.publicapi.response.DataTableData;
|
||||
import eu.eudat.logic.services.ApiContext;
|
||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||
import eu.eudat.controllers.publicapi.models.overviewmodels.DatasetPublicModel;
|
||||
import eu.eudat.model.publicapi.overviewmodels.DatasetPublicModel;
|
||||
import eu.eudat.controllers.publicapi.request.dataset.DatasetPublicTableRequest;
|
||||
import eu.eudat.types.ApiMessageCode;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
@ -33,12 +32,9 @@ public class PublicDatasetsDescriptionDocumentation extends BaseController {
|
|||
|
||||
private static final Logger logger = LoggerFactory.getLogger(PublicDatasetsDescriptionDocumentation.class);
|
||||
|
||||
private DatasetPublicManager datasetManager;
|
||||
|
||||
@Autowired
|
||||
public PublicDatasetsDescriptionDocumentation(ApiContext apiContext, DatasetPublicManager datasetManager) {
|
||||
public PublicDatasetsDescriptionDocumentation(ApiContext apiContext) {
|
||||
super(apiContext);
|
||||
this.datasetManager = datasetManager;
|
||||
}
|
||||
|
||||
@Operation(summary = "This method is used to get a listing of public datasets.", description = PublicApiStaticHelpers.Description.getPagedNotes)
|
||||
|
@ -50,10 +46,11 @@ public class PublicDatasetsDescriptionDocumentation extends BaseController {
|
|||
)})
|
||||
)})
|
||||
@RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DataTableData<DatasetPublicListingModel>>> getPaged(@Valid @RequestBody @io.swagger.v3.oas.annotations.parameters.RequestBody(description = PublicApiStaticHelpers.Description.getPagedRequestBodyDescription) DatasetPublicTableRequest datasetTableRequest) throws Exception {
|
||||
DataTableData<DatasetPublicListingModel> dataTable = this.datasetManager.getPublicPaged(datasetTableRequest);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DatasetPublicListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
|
||||
public @ResponseBody ResponseEntity<ResponseItem<DataTableData<DatasetPublicListingModel>>> getPaged(
|
||||
@Valid @RequestBody @io.swagger.v3.oas.annotations.parameters.RequestBody(description = PublicApiStaticHelpers.Description.getPagedRequestBodyDescription) DatasetPublicTableRequest datasetTableRequest
|
||||
) throws Exception {
|
||||
// DataTableData<DatasetPublicListingModel> dataTable = this.datasetManager.getPublicPaged(datasetTableRequest); TODO
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DatasetPublicListingModel>>().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<ResponseItem<DatasetPublicModel>> 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<DatasetPublicModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataset));
|
||||
public @ResponseBody ResponseEntity<ResponseItem<DatasetPublicModel>> 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<DatasetPublicModel>().status(ApiMessageCode.NO_MESSAGE).payload(null));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<ResponseItem<DataTableData<DataManagementPlanPublicListingModel>>> 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<DataManagementPlanPublicListingModel> dataTable = this.dataManagementPlanManager.getPublicPaged(dmpTableRequest, fieldsGroup); //TODO
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DataManagementPlanPublicListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(null));
|
||||
public @ResponseBody ResponseEntity<ResponseItem<DataTableData<DataManagementPlanPublicListingModel>>> 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<DmpEntity> data = query.collectAs(lookup.getProject());
|
||||
List<Dmp> models = this.builderFactory.builder(DmpBuilder.class).build(lookup.getProject(), data);
|
||||
DataTableData<DataManagementPlanPublicListingModel> dataTableData = new DataTableData<>();
|
||||
dataTableData.setData(models.stream().map(this.dmpToPublicApiDmpListingMapper::toPublicListingModel).toList());
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DataManagementPlanPublicListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTableData));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static DmpLookup getDmpLookup(String fieldsGroup, DataManagmentPlanPublicTableRequest request) {
|
||||
BaseFieldSet fieldSet = new BaseFieldSet();
|
||||
Set<String> 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<ResponseItem<DataManagementPlanPublicModel>> 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<DataManagementPlanPublicModel>().status(ApiMessageCode.NO_MESSAGE).payload(null));
|
||||
public @ResponseBody ResponseEntity<ResponseItem<DataManagementPlanPublicModel>> getOverviewSinglePublic(
|
||||
@PathVariable @Parameter(description = "fetch the dmp with the given id", example = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx") String id
|
||||
) {
|
||||
BaseFieldSet fieldSet = new BaseFieldSet();
|
||||
Set<String> 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<DataManagementPlanPublicModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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<DataManagementPlanPublicListingModel> getPublicPaged(DataManagmentPlanPublicTableRequest dmpTableRequest, String fieldsGroup) throws Exception {
|
||||
dmpTableRequest.setQuery(databaseRepository.getDmpDao().asQueryable().withHint(DataManagementPlanPublicListingModel.getHint()));
|
||||
QueryableList<DmpEntity> items = dmpTableRequest.applyCriteria();
|
||||
QueryableList<DmpEntity> pagedItems = PaginationManager.applyPaging(items, dmpTableRequest);
|
||||
|
||||
DataTableData<DataManagementPlanPublicListingModel> 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;
|
||||
}
|
||||
}
|
|
@ -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<DatasetPublicListingModel> getPublicPaged(DatasetPublicTableRequest datasetTableRequest) throws Exception {
|
||||
Long count = 0L;
|
||||
|
||||
datasetTableRequest.setQuery(databaseRepository.getDatasetDao().asQueryable().withHint(DatasetPublicListingModel.getHint()));
|
||||
QueryableList<DescriptionEntity> items;
|
||||
|
||||
items = datasetTableRequest.applyCriteria();
|
||||
|
||||
List<String> 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<DescriptionEntity> pagedItems = PaginationManager.applyPaging(items, datasetTableRequest);
|
||||
DataTableData<DatasetPublicListingModel> dataTable = new DataTableData<>();
|
||||
|
||||
List<DatasetPublicListingModel> 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<String, Object> 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;
|
||||
}
|
||||
}
|
|
@ -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<DmpEntity, DataManagementPlanPublicModel> {
|
||||
private String id;
|
||||
private String label;
|
||||
private String profile;
|
||||
private GrantPublicOverviewModel grant;
|
||||
private Date createdAt;
|
||||
private Date modifiedAt;
|
||||
private Date finalizedAt;
|
||||
private List<OrganizationPublicModel> organisations;
|
||||
private int version;
|
||||
private UUID groupId;
|
||||
private List<DatasetPublicModel> datasets;
|
||||
private List<AssociatedProfilePublicModel> associatedProfiles;
|
||||
private List<ResearcherPublicModel> researchers;
|
||||
private List<DmpUser> users;
|
||||
private String description;
|
||||
private Date publishedAt;
|
||||
private List<DoiPublicModel> 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<OrganizationPublicModel> getOrganisations() {
|
||||
return organisations;
|
||||
}
|
||||
public void setOrganisations(List<OrganizationPublicModel> 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<DatasetPublicModel> getDatasets() {
|
||||
return datasets;
|
||||
}
|
||||
public void setDatasets(List<DatasetPublicModel> datasets) {
|
||||
this.datasets = datasets;
|
||||
}
|
||||
|
||||
public List<AssociatedProfilePublicModel> getAssociatedProfiles() {
|
||||
return associatedProfiles;
|
||||
}
|
||||
public void setAssociatedProfiles(List<AssociatedProfilePublicModel> associatedProfiles) {
|
||||
this.associatedProfiles = associatedProfiles;
|
||||
}
|
||||
|
||||
public List<DmpUser> getUsers() {
|
||||
return users;
|
||||
}
|
||||
public void setUsers(List<DmpUser> users) {
|
||||
this.users = users;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public List<ResearcherPublicModel> getResearchers() {
|
||||
return researchers;
|
||||
}
|
||||
public void setResearchers(List<ResearcherPublicModel> researchers) {
|
||||
this.researchers = researchers;
|
||||
}
|
||||
|
||||
public Date getPublishedAt() {
|
||||
return publishedAt;
|
||||
}
|
||||
public void setPublishedAt(Date publishedAt) {
|
||||
this.publishedAt = publishedAt;
|
||||
}
|
||||
|
||||
public List<DoiPublicModel> getDois() {
|
||||
return dois;
|
||||
}
|
||||
public void setDois(List<DoiPublicModel> 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<Map<String, Object>>() {}));
|
||||
// }
|
||||
// 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<String, Object> 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";
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue