From cbf8bca268c06a062313756ed1780a81097d1be1 Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Fri, 20 Mar 2020 18:20:22 +0200 Subject: [PATCH 01/20] Add new RDA exporter --- .../managers/DataManagementPlanManager.java | 13 +- .../logic/managers/DatasetProfileManager.java | 4 +- .../eu/eudat/logic/managers/RDAManager.java | 38 + .../logic/utilities/json/JsonSearcher.java | 32 + .../commons/datafield/AutoCompleteData.java | 2 + .../commons/datafield/ComboBoxData.java | 11 + .../ExternalAutocompleteFieldModel.java | 12 +- .../data/rda/DatasetRDAExportModel.java | 3 +- .../java/eu/eudat/models/rda/Contact.java | 146 +++ .../java/eu/eudat/models/rda/ContactId.java | 154 ++++ .../java/eu/eudat/models/rda/Contributor.java | 181 ++++ .../eu/eudat/models/rda/ContributorId.java | 155 ++++ .../main/java/eu/eudat/models/rda/Cost.java | 374 ++++++++ .../java/eu/eudat/models/rda/Dataset.java | 839 ++++++++++++++++++ .../java/eu/eudat/models/rda/DatasetId.java | 156 ++++ .../eu/eudat/models/rda/Distribution.java | 412 +++++++++ .../main/java/eu/eudat/models/rda/Dmp.java | 774 ++++++++++++++++ .../main/java/eu/eudat/models/rda/DmpId.java | 156 ++++ .../java/eu/eudat/models/rda/FunderId.java | 154 ++++ .../java/eu/eudat/models/rda/Funding.java | 187 ++++ .../java/eu/eudat/models/rda/GrantId.java | 153 ++++ .../main/java/eu/eudat/models/rda/Host.java | 775 ++++++++++++++++ .../java/eu/eudat/models/rda/License.java | 113 +++ .../eudat/models/rda/MetadataStandardId.java | 153 ++++ .../java/eu/eudat/models/rda/Metadatum.java | 368 ++++++++ .../java/eu/eudat/models/rda/PidSystem.java | 63 ++ .../java/eu/eudat/models/rda/Project.java | 212 +++++ .../java/eu/eudat/models/rda/RDAModel.java | 58 ++ .../eudat/models/rda/SecurityAndPrivacy.java | 109 +++ .../eudat/models/rda/TechnicalResource.java | 109 +++ .../models/rda/mapper/ContactIdRDAMapper.java | 15 + .../models/rda/mapper/ContactRDAMapper.java | 16 + .../rda/mapper/ContributorIdRDAMapper.java | 16 + .../rda/mapper/ContributorRDAMapper.java | 20 + .../models/rda/mapper/DatasetIdRDAMapper.java | 17 + .../models/rda/mapper/DatasetRDAMapper.java | 100 +++ .../rda/mapper/DistributionRDAMapper.java | 39 + .../models/rda/mapper/DmpIdRDAMapper.java | 19 + .../eudat/models/rda/mapper/DmpRDAMapper.java | 51 ++ .../models/rda/mapper/FunderIdRDAMapper.java | 19 + .../models/rda/mapper/FundingRDAMapper.java | 25 + .../models/rda/mapper/GrantIdRDAMapper.java | 13 + .../models/rda/mapper/HostRDAMapper.java | 41 + .../models/rda/mapper/LicenseRDAMapper.java | 23 + .../models/rda/mapper/MetadataRDAMapper.java | 44 + .../mapper/MetadataStandardIdRDAMapper.java | 13 + .../models/rda/mapper/ProjectRDAMapper.java | 25 + .../mapper/SecurityAndPrivacyRDAMapper.java | 21 + .../mapper/TechnicalResourceRDAMapper.java | 21 + 49 files changed, 6447 insertions(+), 7 deletions(-) create mode 100644 dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Contact.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/ContactId.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Contributor.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/ContributorId.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Cost.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/DatasetId.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/DmpId.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/FunderId.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Funding.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/GrantId.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Host.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/License.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/MetadataStandardId.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/PidSystem.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Project.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/RDAModel.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorIdRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetIdRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpIdRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FunderIdRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/GrantIdRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataStandardIdRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java index e88e48524..2710ec60c 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java @@ -105,14 +105,16 @@ public class DataManagementPlanManager { private UtilitiesService utilitiesService; private DatabaseRepository databaseRepository; private Environment environment; + private RDAManager rdaManager; @Autowired - public DataManagementPlanManager(ApiContext apiContext, DatasetManager datasetManager, Environment environment) { + public DataManagementPlanManager(ApiContext apiContext, DatasetManager datasetManager, Environment environment, RDAManager rdaManager) { this.apiContext = apiContext; this.datasetManager = datasetManager; this.utilitiesService = apiContext.getUtilitiesService(); this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository(); this.environment = environment; + this.rdaManager = rdaManager; } public DataTableData getPaged(DataManagementPlanTableRequest dataManagementPlanTableRequest, Principal principal, String fieldsGroup) throws Exception { @@ -1129,15 +1131,20 @@ public class DataManagementPlanManager { eu.eudat.data.entities.DMP dmp = databaseRepository.getDmpDao().find(UUID.fromString(id)); if (!dmp.isPublic() && dmp.getUsers().stream().noneMatch(userInfo -> userInfo.getUser().getId() == principal.getId())) throw new UnauthorisedException(); - RDAExportModel rdaExportModel = new RDAExportModel().fromDataModel(dmp, datasetManager, principal); +// RDAExportModel rdaExportModel = new RDAExportModel().fromDataModel(dmp, datasetManager, principal); + String result = rdaManager.convertToRDA(dmp); ObjectMapper mapper = new ObjectMapper(); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); String fileName = dmp.getLabel(); fileName = fileName.replaceAll("[^a-zA-Z0-9+ ]", ""); File file = new File(fileName + ".json"); + OutputStream output = new FileOutputStream(file); try { - mapper.writeValue(file, rdaExportModel); +// mapper.writeValue(file, rdaExportModel); + output.write(result.getBytes()); + output.flush(); + output.close(); } catch (IOException e) { logger.error(e.getMessage(), e); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetProfileManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetProfileManager.java index 079359827..81693e917 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetProfileManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetProfileManager.java @@ -113,8 +113,8 @@ public class DatasetProfileManager { ResponseEntity response = restTemplate.exchange(data.getUrl() + "?search=" + like, HttpMethod.GET, entity, Object.class); DocumentContext jsonContext = JsonPath.parse(response.getBody()); - List> jsonItems = jsonContext.read(data.getOptionsRoot() + "['" + data.getAutoCompleteOptions().getLabel() + "','" + data.getAutoCompleteOptions().getValue() + "','" + data.getAutoCompleteOptions().getSource() + "']"); - jsonItems.forEach(item -> result.add(new ExternalAutocompleteFieldModel(item.get(data.getAutoCompleteOptions().getValue()), item.get(data.getAutoCompleteOptions().getLabel()), item.get(data.getAutoCompleteOptions().getSource())))); + List> jsonItems = jsonContext.read(data.getOptionsRoot() + "['" + data.getAutoCompleteOptions().getLabel() + "','" + data.getAutoCompleteOptions().getValue() + "','" + data.getAutoCompleteOptions().getSource() + "','" + "uri" + "']"); + jsonItems.forEach(item -> result.add(new ExternalAutocompleteFieldModel(item.get(data.getAutoCompleteOptions().getValue()), item.get(data.getAutoCompleteOptions().getLabel()), item.get(data.getAutoCompleteOptions().getSource()), item.get("uri")))); return result; } diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java new file mode 100644 index 000000000..eb10fd753 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java @@ -0,0 +1,38 @@ +package eu.eudat.logic.managers; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import eu.eudat.data.entities.DMP; +import eu.eudat.models.rda.Dmp; +import eu.eudat.models.rda.RDAModel; +import eu.eudat.models.rda.mapper.DmpRDAMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.transaction.Transactional; +import java.text.SimpleDateFormat; + +@Component +public class RDAManager { + + private DmpRDAMapper dmpRDAMapper; + + @Autowired + public RDAManager(DmpRDAMapper dmpRDAMapper) { + this.dmpRDAMapper = dmpRDAMapper; + } + + @Transactional + public String convertToRDA(DMP dmp) throws JsonProcessingException { + String result = ""; + + Dmp rdaDmp = dmpRDAMapper.toRDA(dmp); + + ObjectMapper mapper = new ObjectMapper(); + mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")); + + result = mapper.writeValueAsString(rdaDmp); + + return result; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java new file mode 100644 index 000000000..ca2372b91 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java @@ -0,0 +1,32 @@ +package eu.eudat.logic.utilities.json; + +import com.fasterxml.jackson.databind.JsonNode; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +public class JsonSearcher { + + public static List findNodes(JsonNode root, String key, String value) { + List nodes = new ArrayList<>(); + for (Iterator it = root.elements(); it.hasNext(); ) { + JsonNode node = it.next(); + int found = 0; + for (Iterator iter = node.fieldNames(); iter.hasNext(); ) { + String fieldName = iter.next(); + if (fieldName.equals(key)) { + if (node.get(fieldName).asText().equals(value) || node.get(fieldName).asText().startsWith(value)) { + nodes.add(node); + found++; + } + } + + } + if (found == 0) { + nodes.addAll(findNodes(node, key, value)); + } + } + return nodes; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/AutoCompleteData.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/AutoCompleteData.java index 8fbedc873..5b33f115d 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/AutoCompleteData.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/AutoCompleteData.java @@ -64,6 +64,7 @@ public class AutoCompleteData extends ComboBoxData { this.autoCompleteOptions.setLabel(optionElement.getAttribute("label")); this.autoCompleteOptions.setValue(optionElement.getAttribute("value")); this.autoCompleteOptions.setSource(optionElement.getAttribute("source")); + this.autoCompleteOptions.setUri(optionElement.getAttribute("uri")); } return this; } @@ -81,6 +82,7 @@ public class AutoCompleteData extends ComboBoxData { this.autoCompleteOptions.setLabel(options.get("label")); this.autoCompleteOptions.setValue(options.get("value")); this.autoCompleteOptions.setSource(options.get("source")); + this.autoCompleteOptions.setUri(options.get("uri")); } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/ComboBoxData.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/ComboBoxData.java index db67ea301..59bc6ea79 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/ComboBoxData.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/ComboBoxData.java @@ -12,6 +12,7 @@ public abstract class ComboBoxData extends FieldData { private String label; private String value; private String source; + private String uri; public String getLabel() { return label; @@ -34,12 +35,21 @@ public abstract class ComboBoxData extends FieldData { this.source = source; } + public String getUri() { + return uri; + } + + public void setUri(String uri) { + this.uri = uri; + } + @Override public Element toXml(Document doc) { Element option = doc.createElement("option"); option.setAttribute("label", this.label); option.setAttribute("value", this.value); option.setAttribute("source", this.source); + option.setAttribute("uri", this.uri); return option; } @@ -48,6 +58,7 @@ public abstract class ComboBoxData extends FieldData { this.label = item.getAttribute("label"); this.value = item.getAttribute("value"); this.source = item.getAttribute("source"); + this.uri = item.getAttribute("uri"); return this; } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/externaldataset/ExternalAutocompleteFieldModel.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/externaldataset/ExternalAutocompleteFieldModel.java index d57605a72..039c63acd 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/externaldataset/ExternalAutocompleteFieldModel.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/externaldataset/ExternalAutocompleteFieldModel.java @@ -4,11 +4,13 @@ public class ExternalAutocompleteFieldModel { private String id; private String label; private String source; + private String uri; - public ExternalAutocompleteFieldModel(String id, String label, String source) { + public ExternalAutocompleteFieldModel(String id, String label, String source, String uri) { this.id = id; this.label = label; this.source = source; + this.uri = uri; } public String getId() { @@ -31,4 +33,12 @@ public class ExternalAutocompleteFieldModel { public void setSource(String source) { this.source = source; } + + public String getUri() { + return uri; + } + + public void setUri(String uri) { + this.uri = uri; + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/rda/DatasetRDAExportModel.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/rda/DatasetRDAExportModel.java index c9f509020..ccd79971f 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/rda/DatasetRDAExportModel.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/rda/DatasetRDAExportModel.java @@ -321,7 +321,8 @@ public class DatasetRDAExportModel { JSONObject jsonObject = jsonArray.getJSONObject(i); Map jsonObjectMap = jsonObject.toMap(); DatasetMetadataRDAExportModel metadataRda1 = new DatasetMetadataRDAExportModel(); - metadataRda1.setMetadata_standard_id(new IdRDAExportModel(jsonObjectMap.get("label").toString(), jsonObjectMap.get("source").toString())); +// metadataRda1.setMetadata_standard_id(new IdRDAExportModel(jsonObjectMap.get("label").toString(), jsonObjectMap.get("source").toString())); + metadataRda1.setMetadata_standard_id(new IdRDAExportModel(jsonObjectMap.get("uri").toString(), "url")); metadataRDAExportModelList.add(metadataRda1); } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Contact.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Contact.java new file mode 100644 index 000000000..606a3ae2c --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Contact.java @@ -0,0 +1,146 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * The DMP Contact Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "contact_id", + "mbox", + "name" +}) +public class Contact implements Serializable +{ + + /** + * The Contact ID Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contact_id") + private ContactId contactId; + /** + * The Mailbox Schema + *

+ * Contact Person's E-mail address + * (Required) + * + */ + @JsonProperty("mbox") + @JsonPropertyDescription("Contact Person's E-mail address") + private String mbox; + /** + * The Name Schema + *

+ * Name of the contact person + * (Required) + * + */ + @JsonProperty("name") + @JsonPropertyDescription("Name of the contact person") + private String name; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -2062619884605400321L; + + /** + * The Contact ID Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contact_id") + public ContactId getContactId() { + return contactId; + } + + /** + * The Contact ID Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contact_id") + public void setContactId(ContactId contactId) { + this.contactId = contactId; + } + + /** + * The Mailbox Schema + *

+ * Contact Person's E-mail address + * (Required) + * + */ + @JsonProperty("mbox") + public String getMbox() { + return mbox; + } + + /** + * The Mailbox Schema + *

+ * Contact Person's E-mail address + * (Required) + * + */ + @JsonProperty("mbox") + public void setMbox(String mbox) { + this.mbox = mbox; + } + + /** + * The Name Schema + *

+ * Name of the contact person + * (Required) + * + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * The Name Schema + *

+ * Name of the contact person + * (Required) + * + */ + @JsonProperty("name") + public void setName(String name) { + this.name = name; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/ContactId.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/ContactId.java new file mode 100644 index 000000000..60454ea6c --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/ContactId.java @@ -0,0 +1,154 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Contact ID Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "identifier", + "type" +}) +public class ContactId implements Serializable +{ + + /** + * The DMP Contact Identifier Schema + *

+ * + * (Required) + * + */ + @JsonProperty("identifier") + private String identifier; + /** + * The DMP Contact Identifier Type Schema + *

+ * Identifier type. Allowed values: orcid, isni, openid, other + * (Required) + * + */ + @JsonProperty("type") + @JsonPropertyDescription("Identifier type. Allowed values: orcid, isni, openid, other") + private ContactId.Type type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -7066973565810615822L; + + /** + * The DMP Contact Identifier Schema + *

+ * + * (Required) + * + */ + @JsonProperty("identifier") + public String getIdentifier() { + return identifier; + } + + /** + * The DMP Contact Identifier Schema + *

+ * + * (Required) + * + */ + @JsonProperty("identifier") + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + * The DMP Contact Identifier Type Schema + *

+ * Identifier type. Allowed values: orcid, isni, openid, other + * (Required) + * + */ + @JsonProperty("type") + public ContactId.Type getType() { + return type; + } + + /** + * The DMP Contact Identifier Type Schema + *

+ * Identifier type. Allowed values: orcid, isni, openid, other + * (Required) + * + */ + @JsonProperty("type") + public void setType(ContactId.Type type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Type { + + ORCID("orcid"), + ISNI("isni"), + OPENID("openid"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (ContactId.Type c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Type(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static ContactId.Type fromValue(String value) { + ContactId.Type constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Contributor.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Contributor.java new file mode 100644 index 000000000..21dfe68c8 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Contributor.java @@ -0,0 +1,181 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + + +/** + * The Contributor Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "contributor_id", + "mbox", + "name", + "role" +}) +public class Contributor implements Serializable +{ + + /** + * The Contributor_id Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contributor_id") + private ContributorId contributorId; + /** + * The Contributor Mailbox Schema + *

+ * Contributor Mail address + * + */ + @JsonProperty("mbox") + @JsonPropertyDescription("Contributor Mail address") + private String mbox; + /** + * The Name Schema + *

+ * Name of the contributor + * (Required) + * + */ + @JsonProperty("name") + @JsonPropertyDescription("Name of the contributor") + private String name; + /** + * The Role Schema + *

+ * Type of contributor + * (Required) + * + */ + @JsonProperty("role") + @JsonDeserialize(as = java.util.LinkedHashSet.class) + @JsonPropertyDescription("Type of contributor") + private Set role = null; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 3452606902359513114L; + + /** + * The Contributor_id Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contributor_id") + public ContributorId getContributorId() { + return contributorId; + } + + /** + * The Contributor_id Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contributor_id") + public void setContributorId(ContributorId contributorId) { + this.contributorId = contributorId; + } + + /** + * The Contributor Mailbox Schema + *

+ * Contributor Mail address + * + */ + @JsonProperty("mbox") + public String getMbox() { + return mbox; + } + + /** + * The Contributor Mailbox Schema + *

+ * Contributor Mail address + * + */ + @JsonProperty("mbox") + public void setMbox(String mbox) { + this.mbox = mbox; + } + + /** + * The Name Schema + *

+ * Name of the contributor + * (Required) + * + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * The Name Schema + *

+ * Name of the contributor + * (Required) + * + */ + @JsonProperty("name") + public void setName(String name) { + this.name = name; + } + + /** + * The Role Schema + *

+ * Type of contributor + * (Required) + * + */ + @JsonProperty("role") + public Set getRole() { + return role; + } + + /** + * The Role Schema + *

+ * Type of contributor + * (Required) + * + */ + @JsonProperty("role") + public void setRole(Set role) { + this.role = role; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/ContributorId.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/ContributorId.java new file mode 100644 index 000000000..4045f5e0e --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/ContributorId.java @@ -0,0 +1,155 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Contributor_id Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "identifier", + "type" +}) +public class ContributorId implements Serializable +{ + + /** + * The Contributor Identifier Schema + *

+ * Identifier for a contact person + * (Required) + * + */ + @JsonProperty("identifier") + @JsonPropertyDescription("Identifier for a contact person") + private String identifier; + /** + * The Contributor Identifier Type Schema + *

+ * Identifier type. Allowed values: orcid, isni, openid, other + * (Required) + * + */ + @JsonProperty("type") + @JsonPropertyDescription("Identifier type. Allowed values: orcid, isni, openid, other") + private ContributorId.Type type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 3089650417960767482L; + + /** + * The Contributor Identifier Schema + *

+ * Identifier for a contact person + * (Required) + * + */ + @JsonProperty("identifier") + public String getIdentifier() { + return identifier; + } + + /** + * The Contributor Identifier Schema + *

+ * Identifier for a contact person + * (Required) + * + */ + @JsonProperty("identifier") + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + * The Contributor Identifier Type Schema + *

+ * Identifier type. Allowed values: orcid, isni, openid, other + * (Required) + * + */ + @JsonProperty("type") + public ContributorId.Type getType() { + return type; + } + + /** + * The Contributor Identifier Type Schema + *

+ * Identifier type. Allowed values: orcid, isni, openid, other + * (Required) + * + */ + @JsonProperty("type") + public void setType(ContributorId.Type type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Type { + + ORCID("orcid"), + ISNI("isni"), + OPENID("openid"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (ContributorId.Type c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Type(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static ContributorId.Type fromValue(String value) { + ContributorId.Type constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Cost.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Cost.java new file mode 100644 index 000000000..db32ff641 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Cost.java @@ -0,0 +1,374 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Cost Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "currency_code", + "description", + "title", + "value" +}) +public class Cost implements Serializable +{ + + /** + * The Cost Currency Code Schema + *

+ * Allowed values defined by ISO 4217 + * + */ + @JsonProperty("currency_code") + @JsonPropertyDescription("Allowed values defined by ISO 4217") + private Cost.CurrencyCode currencyCode; + /** + * The Cost Description Schema + *

+ * Cost(s) Description + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Cost(s) Description") + private String description; + /** + * The Cost Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + @JsonPropertyDescription("Title") + private String title; + /** + * The Cost Value Schema + *

+ * Value + * + */ + @JsonProperty("value") + @JsonPropertyDescription("Value") + private Double value; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -322637784848035165L; + + /** + * The Cost Currency Code Schema + *

+ * Allowed values defined by ISO 4217 + * + */ + @JsonProperty("currency_code") + public Cost.CurrencyCode getCurrencyCode() { + return currencyCode; + } + + /** + * The Cost Currency Code Schema + *

+ * Allowed values defined by ISO 4217 + * + */ + @JsonProperty("currency_code") + public void setCurrencyCode(Cost.CurrencyCode currencyCode) { + this.currencyCode = currencyCode; + } + + /** + * The Cost Description Schema + *

+ * Cost(s) Description + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The Cost Description Schema + *

+ * Cost(s) Description + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The Cost Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * The Cost Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } + + /** + * The Cost Value Schema + *

+ * Value + * + */ + @JsonProperty("value") + public Double getValue() { + return value; + } + + /** + * The Cost Value Schema + *

+ * Value + * + */ + @JsonProperty("value") + public void setValue(Double value) { + this.value = value; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum CurrencyCode { + + AED("AED"), + AFN("AFN"), + ALL("ALL"), + AMD("AMD"), + ANG("ANG"), + AOA("AOA"), + ARS("ARS"), + AUD("AUD"), + AWG("AWG"), + AZN("AZN"), + BAM("BAM"), + BBD("BBD"), + BDT("BDT"), + BGN("BGN"), + BHD("BHD"), + BIF("BIF"), + BMD("BMD"), + BND("BND"), + BOB("BOB"), + BRL("BRL"), + BSD("BSD"), + BTN("BTN"), + BWP("BWP"), + BYN("BYN"), + BZD("BZD"), + CAD("CAD"), + CDF("CDF"), + CHF("CHF"), + CLP("CLP"), + CNY("CNY"), + COP("COP"), + CRC("CRC"), + CUC("CUC"), + CUP("CUP"), + CVE("CVE"), + CZK("CZK"), + DJF("DJF"), + DKK("DKK"), + DOP("DOP"), + DZD("DZD"), + EGP("EGP"), + ERN("ERN"), + ETB("ETB"), + EUR("EUR"), + FJD("FJD"), + FKP("FKP"), + GBP("GBP"), + GEL("GEL"), + GGP("GGP"), + GHS("GHS"), + GIP("GIP"), + GMD("GMD"), + GNF("GNF"), + GTQ("GTQ"), + GYD("GYD"), + HKD("HKD"), + HNL("HNL"), + HRK("HRK"), + HTG("HTG"), + HUF("HUF"), + IDR("IDR"), + ILS("ILS"), + IMP("IMP"), + INR("INR"), + IQD("IQD"), + IRR("IRR"), + ISK("ISK"), + JEP("JEP"), + JMD("JMD"), + JOD("JOD"), + JPY("JPY"), + KES("KES"), + KGS("KGS"), + KHR("KHR"), + KMF("KMF"), + KPW("KPW"), + KRW("KRW"), + KWD("KWD"), + KYD("KYD"), + KZT("KZT"), + LAK("LAK"), + LBP("LBP"), + LKR("LKR"), + LRD("LRD"), + LSL("LSL"), + LYD("LYD"), + MAD("MAD"), + MDL("MDL"), + MGA("MGA"), + MKD("MKD"), + MMK("MMK"), + MNT("MNT"), + MOP("MOP"), + MRU("MRU"), + MUR("MUR"), + MVR("MVR"), + MWK("MWK"), + MXN("MXN"), + MYR("MYR"), + MZN("MZN"), + NAD("NAD"), + NGN("NGN"), + NIO("NIO"), + NOK("NOK"), + NPR("NPR"), + NZD("NZD"), + OMR("OMR"), + PAB("PAB"), + PEN("PEN"), + PGK("PGK"), + PHP("PHP"), + PKR("PKR"), + PLN("PLN"), + PYG("PYG"), + QAR("QAR"), + RON("RON"), + RSD("RSD"), + RUB("RUB"), + RWF("RWF"), + SAR("SAR"), + SBD("SBD"), + SCR("SCR"), + SDG("SDG"), + SEK("SEK"), + SGD("SGD"), + SHP("SHP"), + SLL("SLL"), + SOS("SOS"), + SPL("SPL*"), + SRD("SRD"), + STN("STN"), + SVC("SVC"), + SYP("SYP"), + SZL("SZL"), + THB("THB"), + TJS("TJS"), + TMT("TMT"), + TND("TND"), + TOP("TOP"), + TRY("TRY"), + TTD("TTD"), + TVD("TVD"), + TWD("TWD"), + TZS("TZS"), + UAH("UAH"), + UGX("UGX"), + USD("USD"), + UYU("UYU"), + UZS("UZS"), + VEF("VEF"), + VND("VND"), + VUV("VUV"), + WST("WST"), + XAF("XAF"), + XCD("XCD"), + XDR("XDR"), + XOF("XOF"), + XPF("XPF"), + YER("YER"), + ZAR("ZAR"), + ZMW("ZMW"), + ZWD("ZWD"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Cost.CurrencyCode c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private CurrencyCode(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Cost.CurrencyCode fromValue(String value) { + Cost.CurrencyCode constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java new file mode 100644 index 000000000..43a7ac0cd --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java @@ -0,0 +1,839 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Dataset Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "data_quality_assurance", + "dataset_id", + "description", + "distribution", + "issued", + "keyword", + "language", + "metadata", + "personal_data", + "preservation_statement", + "security_and_privacy", + "sensitive_data", + "technical_resource", + "title", + "type" +}) +public class Dataset implements Serializable +{ + + /** + * The Data Quality Assurance Schema + *

+ * Data Quality Assurance + * + */ + @JsonProperty("data_quality_assurance") + @JsonPropertyDescription("Data Quality Assurance") + private List dataQualityAssurance = null; + /** + * The Dataset ID Schema + *

+ * Dataset ID + * (Required) + * + */ + @JsonProperty("dataset_id") + @JsonPropertyDescription("Dataset ID") + private DatasetId datasetId; + /** + * The Dataset Description Schema + *

+ * Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file.") + private String description; + /** + * The Dataset Distribution Schema + *

+ * To provide technical information on a specific instance of data. + * + */ + @JsonProperty("distribution") + @JsonPropertyDescription("To provide technical information on a specific instance of data.") + private List distribution = null; + /** + * The Dataset Date of Issue Schema + *

+ * Date of Issue + * + */ + @JsonProperty("issued") + @JsonPropertyDescription("Date of Issue") + private String issued; + /** + * The Dataset Keyword(s) Schema + *

+ * Keywords + * + */ + @JsonProperty("keyword") + @JsonPropertyDescription("Keywords") + private List keyword = null; + /** + * The Dataset Language Schema + *

+ * Language of the dataset expressed using ISO 639-3. + * + */ + @JsonProperty("language") + @JsonPropertyDescription("Language of the dataset expressed using ISO 639-3.") + private Dataset.Language language; + /** + * The Dataset Metadata Schema + *

+ * To describe metadata standards used. + * + */ + @JsonProperty("metadata") + @JsonPropertyDescription("To describe metadata standards used.") + private List metadata = null; + /** + * The Dataset Personal Data Schema + *

+ * If any personal data is contained. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("personal_data") + @JsonPropertyDescription("If any personal data is contained. Allowed values: yes, no, unknown") + private Dataset.PersonalData personalData; + /** + * The Dataset Preservation Statement Schema + *

+ * Preservation Statement + * + */ + @JsonProperty("preservation_statement") + @JsonPropertyDescription("Preservation Statement") + private String preservationStatement; + /** + * The Dataset Security and Policy Schema + *

+ * To list all issues and requirements related to security and privacy + * + */ + @JsonProperty("security_and_privacy") + @JsonPropertyDescription("To list all issues and requirements related to security and privacy") + private List securityAndPrivacy = null; + /** + * The Dataset Sensitive Data Schema + *

+ * If any sensitive data is contained. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("sensitive_data") + @JsonPropertyDescription("If any sensitive data is contained. Allowed values: yes, no, unknown") + private Dataset.SensitiveData sensitiveData; + /** + * The Dataset Technical Resource Schema + *

+ * To list all technical resources needed to implement a DMP + * + */ + @JsonProperty("technical_resource") + @JsonPropertyDescription("To list all technical resources needed to implement a DMP") + private List technicalResource = null; + /** + * The Dataset Title Schema + *

+ * Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * (Required) + * + */ + @JsonProperty("title") + @JsonPropertyDescription("Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file.") + private String title; + /** + * The Dataset Type Schema + *

+ * If appropriate, type according to: DataCite and/or COAR dictionary. Otherwise use the common name for the type, e.g. raw data, software, survey, etc. https://schema.datacite.org/meta/kernel-4.1/doc/DataCite-MetadataKernel_v4.1.pdf http://vocabularies.coar-repositories.org/pubby/resource_type.html + * + */ + @JsonProperty("type") + @JsonPropertyDescription("If appropriate, type according to: DataCite and/or COAR dictionary. Otherwise use the common name for the type, e.g. raw data, software, survey, etc. https://schema.datacite.org/meta/kernel-4.1/doc/DataCite-MetadataKernel_v4.1.pdf http://vocabularies.coar-repositories.org/pubby/resource_type.html") + private String type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -6931119120629009399L; + + /** + * The Data Quality Assurance Schema + *

+ * Data Quality Assurance + * + */ + @JsonProperty("data_quality_assurance") + public List getDataQualityAssurance() { + return dataQualityAssurance; + } + + /** + * The Data Quality Assurance Schema + *

+ * Data Quality Assurance + * + */ + @JsonProperty("data_quality_assurance") + public void setDataQualityAssurance(List dataQualityAssurance) { + this.dataQualityAssurance = dataQualityAssurance; + } + + /** + * The Dataset ID Schema + *

+ * Dataset ID + * (Required) + * + */ + @JsonProperty("dataset_id") + public DatasetId getDatasetId() { + return datasetId; + } + + /** + * The Dataset ID Schema + *

+ * Dataset ID + * (Required) + * + */ + @JsonProperty("dataset_id") + public void setDatasetId(DatasetId datasetId) { + this.datasetId = datasetId; + } + + /** + * The Dataset Description Schema + *

+ * Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The Dataset Description Schema + *

+ * Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The Dataset Distribution Schema + *

+ * To provide technical information on a specific instance of data. + * + */ + @JsonProperty("distribution") + public List getDistribution() { + return distribution; + } + + /** + * The Dataset Distribution Schema + *

+ * To provide technical information on a specific instance of data. + * + */ + @JsonProperty("distribution") + public void setDistribution(List distribution) { + this.distribution = distribution; + } + + /** + * The Dataset Date of Issue Schema + *

+ * Date of Issue + * + */ + @JsonProperty("issued") + public String getIssued() { + return issued; + } + + /** + * The Dataset Date of Issue Schema + *

+ * Date of Issue + * + */ + @JsonProperty("issued") + public void setIssued(String issued) { + this.issued = issued; + } + + /** + * The Dataset Keyword(s) Schema + *

+ * Keywords + * + */ + @JsonProperty("keyword") + public List getKeyword() { + return keyword; + } + + /** + * The Dataset Keyword(s) Schema + *

+ * Keywords + * + */ + @JsonProperty("keyword") + public void setKeyword(List keyword) { + this.keyword = keyword; + } + + /** + * The Dataset Language Schema + *

+ * Language of the dataset expressed using ISO 639-3. + * + */ + @JsonProperty("language") + public Dataset.Language getLanguage() { + return language; + } + + /** + * The Dataset Language Schema + *

+ * Language of the dataset expressed using ISO 639-3. + * + */ + @JsonProperty("language") + public void setLanguage(Dataset.Language language) { + this.language = language; + } + + /** + * The Dataset Metadata Schema + *

+ * To describe metadata standards used. + * + */ + @JsonProperty("metadata") + public List getMetadata() { + return metadata; + } + + /** + * The Dataset Metadata Schema + *

+ * To describe metadata standards used. + * + */ + @JsonProperty("metadata") + public void setMetadata(List metadata) { + this.metadata = metadata; + } + + /** + * The Dataset Personal Data Schema + *

+ * If any personal data is contained. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("personal_data") + public Dataset.PersonalData getPersonalData() { + return personalData; + } + + /** + * The Dataset Personal Data Schema + *

+ * If any personal data is contained. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("personal_data") + public void setPersonalData(Dataset.PersonalData personalData) { + this.personalData = personalData; + } + + /** + * The Dataset Preservation Statement Schema + *

+ * Preservation Statement + * + */ + @JsonProperty("preservation_statement") + public String getPreservationStatement() { + return preservationStatement; + } + + /** + * The Dataset Preservation Statement Schema + *

+ * Preservation Statement + * + */ + @JsonProperty("preservation_statement") + public void setPreservationStatement(String preservationStatement) { + this.preservationStatement = preservationStatement; + } + + /** + * The Dataset Security and Policy Schema + *

+ * To list all issues and requirements related to security and privacy + * + */ + @JsonProperty("security_and_privacy") + public List getSecurityAndPrivacy() { + return securityAndPrivacy; + } + + /** + * The Dataset Security and Policy Schema + *

+ * To list all issues and requirements related to security and privacy + * + */ + @JsonProperty("security_and_privacy") + public void setSecurityAndPrivacy(List securityAndPrivacy) { + this.securityAndPrivacy = securityAndPrivacy; + } + + /** + * The Dataset Sensitive Data Schema + *

+ * If any sensitive data is contained. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("sensitive_data") + public Dataset.SensitiveData getSensitiveData() { + return sensitiveData; + } + + /** + * The Dataset Sensitive Data Schema + *

+ * If any sensitive data is contained. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("sensitive_data") + public void setSensitiveData(Dataset.SensitiveData sensitiveData) { + this.sensitiveData = sensitiveData; + } + + /** + * The Dataset Technical Resource Schema + *

+ * To list all technical resources needed to implement a DMP + * + */ + @JsonProperty("technical_resource") + public List getTechnicalResource() { + return technicalResource; + } + + /** + * The Dataset Technical Resource Schema + *

+ * To list all technical resources needed to implement a DMP + * + */ + @JsonProperty("technical_resource") + public void setTechnicalResource(List technicalResource) { + this.technicalResource = technicalResource; + } + + /** + * The Dataset Title Schema + *

+ * Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * (Required) + * + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * The Dataset Title Schema + *

+ * Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * (Required) + * + */ + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } + + /** + * The Dataset Type Schema + *

+ * If appropriate, type according to: DataCite and/or COAR dictionary. Otherwise use the common name for the type, e.g. raw data, software, survey, etc. https://schema.datacite.org/meta/kernel-4.1/doc/DataCite-MetadataKernel_v4.1.pdf http://vocabularies.coar-repositories.org/pubby/resource_type.html + * + */ + @JsonProperty("type") + public String getType() { + return type; + } + + /** + * The Dataset Type Schema + *

+ * If appropriate, type according to: DataCite and/or COAR dictionary. Otherwise use the common name for the type, e.g. raw data, software, survey, etc. https://schema.datacite.org/meta/kernel-4.1/doc/DataCite-MetadataKernel_v4.1.pdf http://vocabularies.coar-repositories.org/pubby/resource_type.html + * + */ + @JsonProperty("type") + public void setType(String type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Language { + + AAR("aar"), + ABK("abk"), + AFR("afr"), + AKA("aka"), + AMH("amh"), + ARA("ara"), + ARG("arg"), + ASM("asm"), + AVA("ava"), + AVE("ave"), + AYM("aym"), + AZE("aze"), + BAK("bak"), + BAM("bam"), + BEL("bel"), + BEN("ben"), + BIH("bih"), + BIS("bis"), + BOD("bod"), + BOS("bos"), + BRE("bre"), + BUL("bul"), + CAT("cat"), + CES("ces"), + CHA("cha"), + CHE("che"), + CHU("chu"), + CHV("chv"), + COR("cor"), + COS("cos"), + CRE("cre"), + CYM("cym"), + DAN("dan"), + DEU("deu"), + DIV("div"), + DZO("dzo"), + ELL("ell"), + ENG("eng"), + EPO("epo"), + EST("est"), + EUS("eus"), + EWE("ewe"), + FAO("fao"), + FAS("fas"), + FIJ("fij"), + FIN("fin"), + FRA("fra"), + FRY("fry"), + FUL("ful"), + GLA("gla"), + GLE("gle"), + GLG("glg"), + GLV("glv"), + GRN("grn"), + GUJ("guj"), + HAT("hat"), + HAU("hau"), + HBS("hbs"), + HEB("heb"), + HER("her"), + HIN("hin"), + HMO("hmo"), + HRV("hrv"), + HUN("hun"), + HYE("hye"), + IBO("ibo"), + IDO("ido"), + III("iii"), + IKU("iku"), + ILE("ile"), + INA("ina"), + IND("ind"), + IPK("ipk"), + ISL("isl"), + ITA("ita"), + JAV("jav"), + JPN("jpn"), + KAL("kal"), + KAN("kan"), + KAS("kas"), + KAT("kat"), + KAU("kau"), + KAZ("kaz"), + KHM("khm"), + KIK("kik"), + KIN("kin"), + KIR("kir"), + KOM("kom"), + KON("kon"), + KOR("kor"), + KUA("kua"), + KUR("kur"), + LAO("lao"), + LAT("lat"), + LAV("lav"), + LIM("lim"), + LIN("lin"), + LIT("lit"), + LTZ("ltz"), + LUB("lub"), + LUG("lug"), + MAH("mah"), + MAL("mal"), + MAR("mar"), + MKD("mkd"), + MLG("mlg"), + MLT("mlt"), + MON("mon"), + MRI("mri"), + MSA("msa"), + MYA("mya"), + NAU("nau"), + NAV("nav"), + NBL("nbl"), + NDE("nde"), + NDO("ndo"), + NEP("nep"), + NLD("nld"), + NNO("nno"), + NOB("nob"), + NOR("nor"), + NYA("nya"), + OCI("oci"), + OJI("oji"), + ORI("ori"), + ORM("orm"), + OSS("oss"), + PAN("pan"), + PLI("pli"), + POL("pol"), + POR("por"), + PUS("pus"), + QUE("que"), + ROH("roh"), + RON("ron"), + RUN("run"), + RUS("rus"), + SAG("sag"), + SAN("san"), + SIN("sin"), + SLK("slk"), + SLV("slv"), + SME("sme"), + SMO("smo"), + SNA("sna"), + SND("snd"), + SOM("som"), + SOT("sot"), + SPA("spa"), + SQI("sqi"), + SRD("srd"), + SRP("srp"), + SSW("ssw"), + SUN("sun"), + SWA("swa"), + SWE("swe"), + TAH("tah"), + TAM("tam"), + TAT("tat"), + TEL("tel"), + TGK("tgk"), + TGL("tgl"), + THA("tha"), + TIR("tir"), + TON("ton"), + TSN("tsn"), + TSO("tso"), + TUK("tuk"), + TUR("tur"), + TWI("twi"), + UIG("uig"), + UKR("ukr"), + URD("urd"), + UZB("uzb"), + VEN("ven"), + VIE("vie"), + VOL("vol"), + WLN("wln"), + WOL("wol"), + XHO("xho"), + YID("yid"), + YOR("yor"), + ZHA("zha"), + ZHO("zho"), + ZUL("zul"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Dataset.Language c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Language(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Dataset.Language fromValue(String value) { + Dataset.Language constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + + public enum PersonalData { + + YES("yes"), + NO("no"), + UNKNOWN("unknown"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Dataset.PersonalData c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private PersonalData(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Dataset.PersonalData fromValue(String value) { + Dataset.PersonalData constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + + public enum SensitiveData { + + YES("yes"), + NO("no"), + UNKNOWN("unknown"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Dataset.SensitiveData c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private SensitiveData(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Dataset.SensitiveData fromValue(String value) { + Dataset.SensitiveData constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/DatasetId.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/DatasetId.java new file mode 100644 index 000000000..c1cc1e57a --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/DatasetId.java @@ -0,0 +1,156 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Dataset ID Schema + *

+ * Dataset ID + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "identifier", + "type" +}) +public class DatasetId implements Serializable +{ + + /** + * The Dataset Identifier Schema + *

+ * Identifier for a dataset + * (Required) + * + */ + @JsonProperty("identifier") + @JsonPropertyDescription("Identifier for a dataset") + private String identifier; + /** + * The Dataset Identifier Type Schema + *

+ * Dataset identifier type. Allowed values: handle, doi, ark, url, other + * (Required) + * + */ + @JsonProperty("type") + @JsonPropertyDescription("Dataset identifier type. Allowed values: handle, doi, ark, url, other") + private DatasetId.Type type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -6295164005851378031L; + + /** + * The Dataset Identifier Schema + *

+ * Identifier for a dataset + * (Required) + * + */ + @JsonProperty("identifier") + public String getIdentifier() { + return identifier; + } + + /** + * The Dataset Identifier Schema + *

+ * Identifier for a dataset + * (Required) + * + */ + @JsonProperty("identifier") + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + * The Dataset Identifier Type Schema + *

+ * Dataset identifier type. Allowed values: handle, doi, ark, url, other + * (Required) + * + */ + @JsonProperty("type") + public DatasetId.Type getType() { + return type; + } + + /** + * The Dataset Identifier Type Schema + *

+ * Dataset identifier type. Allowed values: handle, doi, ark, url, other + * (Required) + * + */ + @JsonProperty("type") + public void setType(DatasetId.Type type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Type { + + HANDLE("handle"), + DOI("doi"), + ARK("ark"), + URL("url"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (DatasetId.Type c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Type(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static DatasetId.Type fromValue(String value) { + DatasetId.Type constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java new file mode 100644 index 000000000..d005e7564 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java @@ -0,0 +1,412 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.net.URI; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Dataset Distribution Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "access_url", + "available_until", + "byte_size", + "data_access", + "description", + "download_url", + "format", + "host", + "license", + "title" +}) +public class Distribution implements Serializable +{ + + /** + * The Dataset Distribution Access URL Schema + *

+ * A URL of the resource that gives access to a distribution of the dataset. e.g. landing page. + * + */ + @JsonProperty("access_url") + @JsonPropertyDescription("A URL of the resource that gives access to a distribution of the dataset. e.g. landing page.") + private String accessUrl; + /** + * The Dataset Distribution Available Until Schema + *

+ * Indicates how long this distribution will be / should be available. + * + */ + @JsonProperty("available_until") + @JsonPropertyDescription("Indicates how long this distribution will be / should be available.") + private String availableUntil; + /** + * The Dataset Distribution Byte Size Schema + *

+ * Size in bytes. + * + */ + @JsonProperty("byte_size") + @JsonPropertyDescription("Size in bytes.") + private Integer byteSize; + /** + * The Dataset Distribution Data Access Schema + *

+ * Indicates access mode for data. Allowed values: open, shared, closed + * (Required) + * + */ + @JsonProperty("data_access") + @JsonPropertyDescription("Indicates access mode for data. Allowed values: open, shared, closed") + private Distribution.DataAccess dataAccess; + /** + * The Dataset Distribution Description Schema + *

+ * Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file.") + private String description; + /** + * The Dataset Distribution Download URL Schema + *

+ * The URL of the downloadable file in a given format. E.g. CSV file or RDF file. + * + */ + @JsonProperty("download_url") + @JsonPropertyDescription("The URL of the downloadable file in a given format. E.g. CSV file or RDF file.") + private URI downloadUrl; + /** + * The Dataset Distribution Format Schema + *

+ * Format according to: https://www.iana.org/assignments/media-types/media-types.xhtml if appropriate, otherwise use the common name for this format. + * + */ + @JsonProperty("format") + @JsonPropertyDescription("Format according to: https://www.iana.org/assignments/media-types/media-types.xhtml if appropriate, otherwise use the common name for this format.") + private List format = null; + /** + * The Dataset Distribution Host Schema + *

+ * To provide information on quality of service provided by infrastructure (e.g. repository) where data is stored. + * + */ + @JsonProperty("host") + @JsonPropertyDescription("To provide information on quality of service provided by infrastructure (e.g. repository) where data is stored.") + private Host host; + /** + * The Dataset Distribution License(s) Schema + *

+ * To list all licenses applied to a specific distribution of data. + * + */ + @JsonProperty("license") + @JsonPropertyDescription("To list all licenses applied to a specific distribution of data.") + private List license = null; + /** + * The Dataset Distribution Title Schema + *

+ * Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * (Required) + * + */ + @JsonProperty("title") + @JsonPropertyDescription("Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file.") + private String title; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -6018365280419917902L; + + /** + * The Dataset Distribution Access URL Schema + *

+ * A URL of the resource that gives access to a distribution of the dataset. e.g. landing page. + * + */ + @JsonProperty("access_url") + public String getAccessUrl() { + return accessUrl; + } + + /** + * The Dataset Distribution Access URL Schema + *

+ * A URL of the resource that gives access to a distribution of the dataset. e.g. landing page. + * + */ + @JsonProperty("access_url") + public void setAccessUrl(String accessUrl) { + this.accessUrl = accessUrl; + } + + /** + * The Dataset Distribution Available Until Schema + *

+ * Indicates how long this distribution will be / should be available. + * + */ + @JsonProperty("available_until") + public String getAvailableUntil() { + return availableUntil; + } + + /** + * The Dataset Distribution Available Until Schema + *

+ * Indicates how long this distribution will be / should be available. + * + */ + @JsonProperty("available_until") + public void setAvailableUntil(String availableUntil) { + this.availableUntil = availableUntil; + } + + /** + * The Dataset Distribution Byte Size Schema + *

+ * Size in bytes. + * + */ + @JsonProperty("byte_size") + public Integer getByteSize() { + return byteSize; + } + + /** + * The Dataset Distribution Byte Size Schema + *

+ * Size in bytes. + * + */ + @JsonProperty("byte_size") + public void setByteSize(Integer byteSize) { + this.byteSize = byteSize; + } + + /** + * The Dataset Distribution Data Access Schema + *

+ * Indicates access mode for data. Allowed values: open, shared, closed + * (Required) + * + */ + @JsonProperty("data_access") + public Distribution.DataAccess getDataAccess() { + return dataAccess; + } + + /** + * The Dataset Distribution Data Access Schema + *

+ * Indicates access mode for data. Allowed values: open, shared, closed + * (Required) + * + */ + @JsonProperty("data_access") + public void setDataAccess(Distribution.DataAccess dataAccess) { + this.dataAccess = dataAccess; + } + + /** + * The Dataset Distribution Description Schema + *

+ * Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The Dataset Distribution Description Schema + *

+ * Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The Dataset Distribution Download URL Schema + *

+ * The URL of the downloadable file in a given format. E.g. CSV file or RDF file. + * + */ + @JsonProperty("download_url") + public URI getDownloadUrl() { + return downloadUrl; + } + + /** + * The Dataset Distribution Download URL Schema + *

+ * The URL of the downloadable file in a given format. E.g. CSV file or RDF file. + * + */ + @JsonProperty("download_url") + public void setDownloadUrl(URI downloadUrl) { + this.downloadUrl = downloadUrl; + } + + /** + * The Dataset Distribution Format Schema + *

+ * Format according to: https://www.iana.org/assignments/media-types/media-types.xhtml if appropriate, otherwise use the common name for this format. + * + */ + @JsonProperty("format") + public List getFormat() { + return format; + } + + /** + * The Dataset Distribution Format Schema + *

+ * Format according to: https://www.iana.org/assignments/media-types/media-types.xhtml if appropriate, otherwise use the common name for this format. + * + */ + @JsonProperty("format") + public void setFormat(List format) { + this.format = format; + } + + /** + * The Dataset Distribution Host Schema + *

+ * To provide information on quality of service provided by infrastructure (e.g. repository) where data is stored. + * + */ + @JsonProperty("host") + public Host getHost() { + return host; + } + + /** + * The Dataset Distribution Host Schema + *

+ * To provide information on quality of service provided by infrastructure (e.g. repository) where data is stored. + * + */ + @JsonProperty("host") + public void setHost(Host host) { + this.host = host; + } + + /** + * The Dataset Distribution License(s) Schema + *

+ * To list all licenses applied to a specific distribution of data. + * + */ + @JsonProperty("license") + public List getLicense() { + return license; + } + + /** + * The Dataset Distribution License(s) Schema + *

+ * To list all licenses applied to a specific distribution of data. + * + */ + @JsonProperty("license") + public void setLicense(List license) { + this.license = license; + } + + /** + * The Dataset Distribution Title Schema + *

+ * Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * (Required) + * + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * The Dataset Distribution Title Schema + *

+ * Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * (Required) + * + */ + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum DataAccess { + + OPEN("open"), + SHARED("shared"), + CLOSED("closed"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Distribution.DataAccess c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private DataAccess(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Distribution.DataAccess fromValue(String value) { + Distribution.DataAccess constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java new file mode 100644 index 000000000..7cac25d62 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java @@ -0,0 +1,774 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.net.URI; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The DMP Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "contact", + "contributor", + "cost", + "created", + "dataset", + "description", + "dmp_id", + "ethical_issues_description", + "ethical_issues_exist", + "ethical_issues_report", + "language", + "modified", + "project", + "title" +}) +public class Dmp implements Serializable +{ + + /** + * The DMP Contact Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contact") + private Contact contact; + /** + * The Contributor Schema + *

+ * + * + */ + @JsonProperty("contributor") + private List contributor = null; + /** + * The Cost Schema + *

+ * + * + */ + @JsonProperty("cost") + private List cost = null; + /** + * The DMP Creation Schema + *

+ * + * + */ + @JsonProperty("created") + @JsonPropertyDescription("") + private Date created; + /** + * The Dataset Schema + *

+ * + * (Required) + * + */ + @JsonProperty("dataset") + private List dataset = null; + /** + * The DMP Description Schema + *

+ * To provide any free-form text information on a DMP + * + */ + @JsonProperty("description") + @JsonPropertyDescription("To provide any free-form text information on a DMP") + private String description; + /** + * The DMP Identifier Schema + *

+ * Identifier for the DMP itself + * (Required) + * + */ + @JsonProperty("dmp_id") + @JsonPropertyDescription("Identifier for the DMP itself") + private DmpId dmpId; + /** + * The DMP Ethical Issues Description Schema + *

+ * To describe ethical issues directly in a DMP + * + */ + @JsonProperty("ethical_issues_description") + @JsonPropertyDescription("To describe ethical issues directly in a DMP") + private String ethicalIssuesDescription; + /** + * The DMP Ethical Issues Exist Schema + *

+ * To indicate whether there are ethical issues related to data that this DMP describes. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("ethical_issues_exist") + @JsonPropertyDescription("To indicate whether there are ethical issues related to data that this DMP describes. Allowed values: yes, no, unknown") + private Dmp.EthicalIssuesExist ethicalIssuesExist; + /** + * The DMP Ethical Issues Report Schema + *

+ * To indicate where a protocol from a meeting with an ethical commitee can be found + * + */ + @JsonProperty("ethical_issues_report") + @JsonPropertyDescription("To indicate where a protocol from a meeting with an ethical commitee can be found") + private URI ethicalIssuesReport; + /** + * The DMP Language Schema + *

+ * Language of the DMP expressed using ISO 639-3. + * (Required) + * + */ + @JsonProperty("language") + @JsonPropertyDescription("Language of the DMP expressed using ISO 639-3.") + private Dmp.Language language; + /** + * The DMP Modification Schema + *

+ * Must be set each time DMP is modified. Indicates DMP version. + * (Required) + * + */ + @JsonProperty("modified") + @JsonPropertyDescription("Must be set each time DMP is modified. Indicates DMP version.") + private Date modified; + /** + * The DMP Project Schema + *

+ * Project related to a DMP + * + */ + @JsonProperty("project") + @JsonPropertyDescription("Project related to a DMP") + private List project = null; + /** + * The DMP Title Schema + *

+ * Title of a DMP + * (Required) + * + */ + @JsonProperty("title") + @JsonPropertyDescription("Title of a DMP") + private String title; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 4599713332472772292L; + + /** + * The DMP Contact Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contact") + public Contact getContact() { + return contact; + } + + /** + * The DMP Contact Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contact") + public void setContact(Contact contact) { + this.contact = contact; + } + + /** + * The Contributor Schema + *

+ * + * + */ + @JsonProperty("contributor") + public List getContributor() { + return contributor; + } + + /** + * The Contributor Schema + *

+ * + * + */ + @JsonProperty("contributor") + public void setContributor(List contributor) { + this.contributor = contributor; + } + + /** + * The Cost Schema + *

+ * + * + */ + @JsonProperty("cost") + public List getCost() { + return cost; + } + + /** + * The Cost Schema + *

+ * + * + */ + @JsonProperty("cost") + public void setCost(List cost) { + this.cost = cost; + } + + /** + * The DMP Creation Schema + *

+ * + * + */ + @JsonProperty("created") + public Date getCreated() { + return created; + } + + /** + * The DMP Creation Schema + *

+ * + * + */ + @JsonProperty("created") + public void setCreated(Date created) { + this.created = created; + } + + /** + * The Dataset Schema + *

+ * + * (Required) + * + */ + @JsonProperty("dataset") + public List getDataset() { + return dataset; + } + + /** + * The Dataset Schema + *

+ * + * (Required) + * + */ + @JsonProperty("dataset") + public void setDataset(List dataset) { + this.dataset = dataset; + } + + /** + * The DMP Description Schema + *

+ * To provide any free-form text information on a DMP + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The DMP Description Schema + *

+ * To provide any free-form text information on a DMP + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The DMP Identifier Schema + *

+ * Identifier for the DMP itself + * (Required) + * + */ + @JsonProperty("dmp_id") + public DmpId getDmpId() { + return dmpId; + } + + /** + * The DMP Identifier Schema + *

+ * Identifier for the DMP itself + * (Required) + * + */ + @JsonProperty("dmp_id") + public void setDmpId(DmpId dmpId) { + this.dmpId = dmpId; + } + + /** + * The DMP Ethical Issues Description Schema + *

+ * To describe ethical issues directly in a DMP + * + */ + @JsonProperty("ethical_issues_description") + public String getEthicalIssuesDescription() { + return ethicalIssuesDescription; + } + + /** + * The DMP Ethical Issues Description Schema + *

+ * To describe ethical issues directly in a DMP + * + */ + @JsonProperty("ethical_issues_description") + public void setEthicalIssuesDescription(String ethicalIssuesDescription) { + this.ethicalIssuesDescription = ethicalIssuesDescription; + } + + /** + * The DMP Ethical Issues Exist Schema + *

+ * To indicate whether there are ethical issues related to data that this DMP describes. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("ethical_issues_exist") + public Dmp.EthicalIssuesExist getEthicalIssuesExist() { + return ethicalIssuesExist; + } + + /** + * The DMP Ethical Issues Exist Schema + *

+ * To indicate whether there are ethical issues related to data that this DMP describes. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("ethical_issues_exist") + public void setEthicalIssuesExist(Dmp.EthicalIssuesExist ethicalIssuesExist) { + this.ethicalIssuesExist = ethicalIssuesExist; + } + + /** + * The DMP Ethical Issues Report Schema + *

+ * To indicate where a protocol from a meeting with an ethical commitee can be found + * + */ + @JsonProperty("ethical_issues_report") + public URI getEthicalIssuesReport() { + return ethicalIssuesReport; + } + + /** + * The DMP Ethical Issues Report Schema + *

+ * To indicate where a protocol from a meeting with an ethical commitee can be found + * + */ + @JsonProperty("ethical_issues_report") + public void setEthicalIssuesReport(URI ethicalIssuesReport) { + this.ethicalIssuesReport = ethicalIssuesReport; + } + + /** + * The DMP Language Schema + *

+ * Language of the DMP expressed using ISO 639-3. + * (Required) + * + */ + @JsonProperty("language") + public Dmp.Language getLanguage() { + return language; + } + + /** + * The DMP Language Schema + *

+ * Language of the DMP expressed using ISO 639-3. + * (Required) + * + */ + @JsonProperty("language") + public void setLanguage(Dmp.Language language) { + this.language = language; + } + + /** + * The DMP Modification Schema + *

+ * Must be set each time DMP is modified. Indicates DMP version. + * (Required) + * + */ + @JsonProperty("modified") + public Date getModified() { + return modified; + } + + /** + * The DMP Modification Schema + *

+ * Must be set each time DMP is modified. Indicates DMP version. + * (Required) + * + */ + @JsonProperty("modified") + public void setModified(Date modified) { + this.modified = modified; + } + + /** + * The DMP Project Schema + *

+ * Project related to a DMP + * + */ + @JsonProperty("project") + public List getProject() { + return project; + } + + /** + * The DMP Project Schema + *

+ * Project related to a DMP + * + */ + @JsonProperty("project") + public void setProject(List project) { + this.project = project; + } + + /** + * The DMP Title Schema + *

+ * Title of a DMP + * (Required) + * + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * The DMP Title Schema + *

+ * Title of a DMP + * (Required) + * + */ + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum EthicalIssuesExist { + + YES("yes"), + NO("no"), + UNKNOWN("unknown"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Dmp.EthicalIssuesExist c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private EthicalIssuesExist(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Dmp.EthicalIssuesExist fromValue(String value) { + Dmp.EthicalIssuesExist constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + + public enum Language { + + AAR("aar"), + ABK("abk"), + AFR("afr"), + AKA("aka"), + AMH("amh"), + ARA("ara"), + ARG("arg"), + ASM("asm"), + AVA("ava"), + AVE("ave"), + AYM("aym"), + AZE("aze"), + BAK("bak"), + BAM("bam"), + BEL("bel"), + BEN("ben"), + BIH("bih"), + BIS("bis"), + BOD("bod"), + BOS("bos"), + BRE("bre"), + BUL("bul"), + CAT("cat"), + CES("ces"), + CHA("cha"), + CHE("che"), + CHU("chu"), + CHV("chv"), + COR("cor"), + COS("cos"), + CRE("cre"), + CYM("cym"), + DAN("dan"), + DEU("deu"), + DIV("div"), + DZO("dzo"), + ELL("ell"), + ENG("eng"), + EPO("epo"), + EST("est"), + EUS("eus"), + EWE("ewe"), + FAO("fao"), + FAS("fas"), + FIJ("fij"), + FIN("fin"), + FRA("fra"), + FRY("fry"), + FUL("ful"), + GLA("gla"), + GLE("gle"), + GLG("glg"), + GLV("glv"), + GRN("grn"), + GUJ("guj"), + HAT("hat"), + HAU("hau"), + HBS("hbs"), + HEB("heb"), + HER("her"), + HIN("hin"), + HMO("hmo"), + HRV("hrv"), + HUN("hun"), + HYE("hye"), + IBO("ibo"), + IDO("ido"), + III("iii"), + IKU("iku"), + ILE("ile"), + INA("ina"), + IND("ind"), + IPK("ipk"), + ISL("isl"), + ITA("ita"), + JAV("jav"), + JPN("jpn"), + KAL("kal"), + KAN("kan"), + KAS("kas"), + KAT("kat"), + KAU("kau"), + KAZ("kaz"), + KHM("khm"), + KIK("kik"), + KIN("kin"), + KIR("kir"), + KOM("kom"), + KON("kon"), + KOR("kor"), + KUA("kua"), + KUR("kur"), + LAO("lao"), + LAT("lat"), + LAV("lav"), + LIM("lim"), + LIN("lin"), + LIT("lit"), + LTZ("ltz"), + LUB("lub"), + LUG("lug"), + MAH("mah"), + MAL("mal"), + MAR("mar"), + MKD("mkd"), + MLG("mlg"), + MLT("mlt"), + MON("mon"), + MRI("mri"), + MSA("msa"), + MYA("mya"), + NAU("nau"), + NAV("nav"), + NBL("nbl"), + NDE("nde"), + NDO("ndo"), + NEP("nep"), + NLD("nld"), + NNO("nno"), + NOB("nob"), + NOR("nor"), + NYA("nya"), + OCI("oci"), + OJI("oji"), + ORI("ori"), + ORM("orm"), + OSS("oss"), + PAN("pan"), + PLI("pli"), + POL("pol"), + POR("por"), + PUS("pus"), + QUE("que"), + ROH("roh"), + RON("ron"), + RUN("run"), + RUS("rus"), + SAG("sag"), + SAN("san"), + SIN("sin"), + SLK("slk"), + SLV("slv"), + SME("sme"), + SMO("smo"), + SNA("sna"), + SND("snd"), + SOM("som"), + SOT("sot"), + SPA("spa"), + SQI("sqi"), + SRD("srd"), + SRP("srp"), + SSW("ssw"), + SUN("sun"), + SWA("swa"), + SWE("swe"), + TAH("tah"), + TAM("tam"), + TAT("tat"), + TEL("tel"), + TGK("tgk"), + TGL("tgl"), + THA("tha"), + TIR("tir"), + TON("ton"), + TSN("tsn"), + TSO("tso"), + TUK("tuk"), + TUR("tur"), + TWI("twi"), + UIG("uig"), + UKR("ukr"), + URD("urd"), + UZB("uzb"), + VEN("ven"), + VIE("vie"), + VOL("vol"), + WLN("wln"), + WOL("wol"), + XHO("xho"), + YID("yid"), + YOR("yor"), + ZHA("zha"), + ZHO("zho"), + ZUL("zul"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Dmp.Language c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Language(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Dmp.Language fromValue(String value) { + Dmp.Language constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/DmpId.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/DmpId.java new file mode 100644 index 000000000..7240efaa4 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/DmpId.java @@ -0,0 +1,156 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The DMP Identifier Schema + *

+ * Identifier for the DMP itself + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "identifier", + "type" +}) +public class DmpId implements Serializable +{ + + /** + * The DMP Identifier Value Schema + *

+ * Identifier for a DMP + * (Required) + * + */ + @JsonProperty("identifier") + @JsonPropertyDescription("Identifier for a DMP") + private String identifier; + /** + * The DMP Identifier Type Schema + *

+ * The DMP Identifier Type. Allowed values: handle, doi, ark, url, other + * (Required) + * + */ + @JsonProperty("type") + @JsonPropertyDescription("The DMP Identifier Type. Allowed values: handle, doi, ark, url, other") + private DmpId.Type type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -6059908070202476841L; + + /** + * The DMP Identifier Value Schema + *

+ * Identifier for a DMP + * (Required) + * + */ + @JsonProperty("identifier") + public String getIdentifier() { + return identifier; + } + + /** + * The DMP Identifier Value Schema + *

+ * Identifier for a DMP + * (Required) + * + */ + @JsonProperty("identifier") + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + * The DMP Identifier Type Schema + *

+ * The DMP Identifier Type. Allowed values: handle, doi, ark, url, other + * (Required) + * + */ + @JsonProperty("type") + public DmpId.Type getType() { + return type; + } + + /** + * The DMP Identifier Type Schema + *

+ * The DMP Identifier Type. Allowed values: handle, doi, ark, url, other + * (Required) + * + */ + @JsonProperty("type") + public void setType(DmpId.Type type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Type { + + HANDLE("handle"), + DOI("doi"), + ARK("ark"), + URL("url"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (DmpId.Type c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Type(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static DmpId.Type fromValue(String value) { + DmpId.Type constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/FunderId.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/FunderId.java new file mode 100644 index 000000000..12b8bb8f7 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/FunderId.java @@ -0,0 +1,154 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Funder ID Schema + *

+ * Funder ID of the associated project + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "identifier", + "type" +}) +public class FunderId implements Serializable +{ + + /** + * The Funder ID Value Schema + *

+ * Funder ID, recommended to use CrossRef Funder Registry. See: https://www.crossref.org/services/funder-registry/ + * (Required) + * + */ + @JsonProperty("identifier") + @JsonPropertyDescription("Funder ID, recommended to use CrossRef Funder Registry. See: https://www.crossref.org/services/funder-registry/") + private String identifier; + /** + * The Funder ID Type Schema + *

+ * Identifier type. Allowed values: fundref, url, other + * (Required) + * + */ + @JsonProperty("type") + @JsonPropertyDescription("Identifier type. Allowed values: fundref, url, other") + private FunderId.Type type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 1783349151334366078L; + + /** + * The Funder ID Value Schema + *

+ * Funder ID, recommended to use CrossRef Funder Registry. See: https://www.crossref.org/services/funder-registry/ + * (Required) + * + */ + @JsonProperty("identifier") + public String getIdentifier() { + return identifier; + } + + /** + * The Funder ID Value Schema + *

+ * Funder ID, recommended to use CrossRef Funder Registry. See: https://www.crossref.org/services/funder-registry/ + * (Required) + * + */ + @JsonProperty("identifier") + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + * The Funder ID Type Schema + *

+ * Identifier type. Allowed values: fundref, url, other + * (Required) + * + */ + @JsonProperty("type") + public FunderId.Type getType() { + return type; + } + + /** + * The Funder ID Type Schema + *

+ * Identifier type. Allowed values: fundref, url, other + * (Required) + * + */ + @JsonProperty("type") + public void setType(FunderId.Type type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Type { + + FUNDREF("fundref"), + URL("url"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (FunderId.Type c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Type(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static FunderId.Type fromValue(String value) { + FunderId.Type constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Funding.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Funding.java new file mode 100644 index 000000000..0cc378e7c --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Funding.java @@ -0,0 +1,187 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The DMP Project Funding Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "funder_id", + "funding_status", + "grant_id" +}) +public class Funding implements Serializable +{ + + /** + * The Funder ID Schema + *

+ * Funder ID of the associated project + * (Required) + * + */ + @JsonProperty("funder_id") + @JsonPropertyDescription("Funder ID of the associated project") + private FunderId funderId; + /** + * The Funding Status Schema + *

+ * To express different phases of project lifecycle. Allowed values: planned, applied, granted, rejected + * + */ + @JsonProperty("funding_status") + @JsonPropertyDescription("To express different phases of project lifecycle. Allowed values: planned, applied, granted, rejected") + private Funding.FundingStatus fundingStatus; + /** + * The Funding Grant ID Schema + *

+ * Grant ID of the associated project + * (Required) + * + */ + @JsonProperty("grant_id") + @JsonPropertyDescription("Grant ID of the associated project") + private GrantId grantId; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 8962229321225336165L; + + /** + * The Funder ID Schema + *

+ * Funder ID of the associated project + * (Required) + * + */ + @JsonProperty("funder_id") + public FunderId getFunderId() { + return funderId; + } + + /** + * The Funder ID Schema + *

+ * Funder ID of the associated project + * (Required) + * + */ + @JsonProperty("funder_id") + public void setFunderId(FunderId funderId) { + this.funderId = funderId; + } + + /** + * The Funding Status Schema + *

+ * To express different phases of project lifecycle. Allowed values: planned, applied, granted, rejected + * + */ + @JsonProperty("funding_status") + public Funding.FundingStatus getFundingStatus() { + return fundingStatus; + } + + /** + * The Funding Status Schema + *

+ * To express different phases of project lifecycle. Allowed values: planned, applied, granted, rejected + * + */ + @JsonProperty("funding_status") + public void setFundingStatus(Funding.FundingStatus fundingStatus) { + this.fundingStatus = fundingStatus; + } + + /** + * The Funding Grant ID Schema + *

+ * Grant ID of the associated project + * (Required) + * + */ + @JsonProperty("grant_id") + public GrantId getGrantId() { + return grantId; + } + + /** + * The Funding Grant ID Schema + *

+ * Grant ID of the associated project + * (Required) + * + */ + @JsonProperty("grant_id") + public void setGrantId(GrantId grantId) { + this.grantId = grantId; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum FundingStatus { + + PLANNED("planned"), + APPLIED("applied"), + GRANTED("granted"), + REJECTED("rejected"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Funding.FundingStatus c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private FundingStatus(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Funding.FundingStatus fromValue(String value) { + Funding.FundingStatus constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/GrantId.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/GrantId.java new file mode 100644 index 000000000..cb994a0ba --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/GrantId.java @@ -0,0 +1,153 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Funding Grant ID Schema + *

+ * Grant ID of the associated project + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "identifier", + "type" +}) +public class GrantId implements Serializable +{ + + /** + * The Funding Grant ID Value Schema + *

+ * Grant ID + * (Required) + * + */ + @JsonProperty("identifier") + @JsonPropertyDescription("Grant ID") + private String identifier; + /** + * The Funding Grant ID Type Schema + *

+ * Identifier type. Allowed values: url, other + * (Required) + * + */ + @JsonProperty("type") + @JsonPropertyDescription("Identifier type. Allowed values: url, other") + private GrantId.Type type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -7738072672837592065L; + + /** + * The Funding Grant ID Value Schema + *

+ * Grant ID + * (Required) + * + */ + @JsonProperty("identifier") + public String getIdentifier() { + return identifier; + } + + /** + * The Funding Grant ID Value Schema + *

+ * Grant ID + * (Required) + * + */ + @JsonProperty("identifier") + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + * The Funding Grant ID Type Schema + *

+ * Identifier type. Allowed values: url, other + * (Required) + * + */ + @JsonProperty("type") + public GrantId.Type getType() { + return type; + } + + /** + * The Funding Grant ID Type Schema + *

+ * Identifier type. Allowed values: url, other + * (Required) + * + */ + @JsonProperty("type") + public void setType(GrantId.Type type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Type { + + URL("url"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (GrantId.Type c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Type(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static GrantId.Type fromValue(String value) { + GrantId.Type constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Host.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Host.java new file mode 100644 index 000000000..bfa6ec615 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Host.java @@ -0,0 +1,775 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.net.URI; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Dataset Distribution Host Schema + *

+ * To provide information on quality of service provided by infrastructure (e.g. repository) where data is stored. + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "availability", + "backup_frequency", + "backup_type", + "certified_with", + "description", + "geo_location", + "pid_system", + "storage_type", + "support_versioning", + "title", + "url" +}) +public class Host implements Serializable +{ + + /** + * The Dataset Distribution Host Availability Schema + *

+ * Availability + * + */ + @JsonProperty("availability") + @JsonPropertyDescription("Availability") + private String availability; + /** + * The Dataset Distribution Host Backup Frequency Schema + *

+ * Backup Frequency + * + */ + @JsonProperty("backup_frequency") + @JsonPropertyDescription("Backup Frequency") + private String backupFrequency; + /** + * The Dataset Distribution Host Backup Type Schema + *

+ * Backup Type + * + */ + @JsonProperty("backup_type") + @JsonPropertyDescription("Backup Type") + private String backupType; + /** + * The Dataset Distribution Host Certification Type Schema + *

+ * Repository certified to a recognised standard. Allowed values: din31644, dini-zertifikat, dsa, iso16363, iso16919, trac, wds, coretrustseal + * + */ + @JsonProperty("certified_with") + @JsonPropertyDescription("Repository certified to a recognised standard. Allowed values: din31644, dini-zertifikat, dsa, iso16363, iso16919, trac, wds, coretrustseal") + private Host.CertifiedWith certifiedWith; + /** + * The Dataset Distribution Host Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Description") + private String description; + /** + * The Dataset Distribution Host Geographical Location Schema + *

+ * Physical location of the data expressed using ISO 3166-1 country code. + * + */ + @JsonProperty("geo_location") + @JsonPropertyDescription("Physical location of the data expressed using ISO 3166-1 country code.") + private Host.GeoLocation geoLocation; + /** + * The Dataset Distribution Host PID System Schema + *

+ * PID system(s). Allowed values: ark, arxiv, bibcode, doi, ean13, eissn, handle, igsn, isbn, issn, istc, lissn, lsid, pmid, purl, upc, url, urn, other + * + */ + @JsonProperty("pid_system") + @JsonPropertyDescription("PID system(s). Allowed values: ark, arxiv, bibcode, doi, ean13, eissn, handle, igsn, isbn, issn, istc, lissn, lsid, pmid, purl, upc, url, urn, other") + private List pidSystem = null; + /** + * The Dataset Distribution Host Storage Type Schema + *

+ * The type of storage required + * + */ + @JsonProperty("storage_type") + @JsonPropertyDescription("The type of storage required") + private String storageType; + /** + * The Dataset Distribution Host Support Versioning Schema + *

+ * If host supports versioning. Allowed values: yes, no, unknown + * + */ + @JsonProperty("support_versioning") + @JsonPropertyDescription("If host supports versioning. Allowed values: yes, no, unknown") + private Host.SupportVersioning supportVersioning; + /** + * The Dataset Distribution Host Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + @JsonPropertyDescription("Title") + private String title; + /** + * The Dataset Distribution Host Title Schema + *

+ * The URL of the system hosting a distribution of a dataset + * (Required) + * + */ + @JsonProperty("url") + @JsonPropertyDescription("The URL of the system hosting a distribution of a dataset") + private URI url; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 8564338806797654115L; + + /** + * The Dataset Distribution Host Availability Schema + *

+ * Availability + * + */ + @JsonProperty("availability") + public String getAvailability() { + return availability; + } + + /** + * The Dataset Distribution Host Availability Schema + *

+ * Availability + * + */ + @JsonProperty("availability") + public void setAvailability(String availability) { + this.availability = availability; + } + + /** + * The Dataset Distribution Host Backup Frequency Schema + *

+ * Backup Frequency + * + */ + @JsonProperty("backup_frequency") + public String getBackupFrequency() { + return backupFrequency; + } + + /** + * The Dataset Distribution Host Backup Frequency Schema + *

+ * Backup Frequency + * + */ + @JsonProperty("backup_frequency") + public void setBackupFrequency(String backupFrequency) { + this.backupFrequency = backupFrequency; + } + + /** + * The Dataset Distribution Host Backup Type Schema + *

+ * Backup Type + * + */ + @JsonProperty("backup_type") + public String getBackupType() { + return backupType; + } + + /** + * The Dataset Distribution Host Backup Type Schema + *

+ * Backup Type + * + */ + @JsonProperty("backup_type") + public void setBackupType(String backupType) { + this.backupType = backupType; + } + + /** + * The Dataset Distribution Host Certification Type Schema + *

+ * Repository certified to a recognised standard. Allowed values: din31644, dini-zertifikat, dsa, iso16363, iso16919, trac, wds, coretrustseal + * + */ + @JsonProperty("certified_with") + public Host.CertifiedWith getCertifiedWith() { + return certifiedWith; + } + + /** + * The Dataset Distribution Host Certification Type Schema + *

+ * Repository certified to a recognised standard. Allowed values: din31644, dini-zertifikat, dsa, iso16363, iso16919, trac, wds, coretrustseal + * + */ + @JsonProperty("certified_with") + public void setCertifiedWith(Host.CertifiedWith certifiedWith) { + this.certifiedWith = certifiedWith; + } + + /** + * The Dataset Distribution Host Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The Dataset Distribution Host Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The Dataset Distribution Host Geographical Location Schema + *

+ * Physical location of the data expressed using ISO 3166-1 country code. + * + */ + @JsonProperty("geo_location") + public Host.GeoLocation getGeoLocation() { + return geoLocation; + } + + /** + * The Dataset Distribution Host Geographical Location Schema + *

+ * Physical location of the data expressed using ISO 3166-1 country code. + * + */ + @JsonProperty("geo_location") + public void setGeoLocation(Host.GeoLocation geoLocation) { + this.geoLocation = geoLocation; + } + + /** + * The Dataset Distribution Host PID System Schema + *

+ * PID system(s). Allowed values: ark, arxiv, bibcode, doi, ean13, eissn, handle, igsn, isbn, issn, istc, lissn, lsid, pmid, purl, upc, url, urn, other + * + */ + @JsonProperty("pid_system") + public List getPidSystem() { + return pidSystem; + } + + /** + * The Dataset Distribution Host PID System Schema + *

+ * PID system(s). Allowed values: ark, arxiv, bibcode, doi, ean13, eissn, handle, igsn, isbn, issn, istc, lissn, lsid, pmid, purl, upc, url, urn, other + * + */ + @JsonProperty("pid_system") + public void setPidSystem(List pidSystem) { + this.pidSystem = pidSystem; + } + + /** + * The Dataset Distribution Host Storage Type Schema + *

+ * The type of storage required + * + */ + @JsonProperty("storage_type") + public String getStorageType() { + return storageType; + } + + /** + * The Dataset Distribution Host Storage Type Schema + *

+ * The type of storage required + * + */ + @JsonProperty("storage_type") + public void setStorageType(String storageType) { + this.storageType = storageType; + } + + /** + * The Dataset Distribution Host Support Versioning Schema + *

+ * If host supports versioning. Allowed values: yes, no, unknown + * + */ + @JsonProperty("support_versioning") + public Host.SupportVersioning getSupportVersioning() { + return supportVersioning; + } + + /** + * The Dataset Distribution Host Support Versioning Schema + *

+ * If host supports versioning. Allowed values: yes, no, unknown + * + */ + @JsonProperty("support_versioning") + public void setSupportVersioning(Host.SupportVersioning supportVersioning) { + this.supportVersioning = supportVersioning; + } + + /** + * The Dataset Distribution Host Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * The Dataset Distribution Host Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } + + /** + * The Dataset Distribution Host Title Schema + *

+ * The URL of the system hosting a distribution of a dataset + * (Required) + * + */ + @JsonProperty("url") + public URI getUrl() { + return url; + } + + /** + * The Dataset Distribution Host Title Schema + *

+ * The URL of the system hosting a distribution of a dataset + * (Required) + * + */ + @JsonProperty("url") + public void setUrl(URI url) { + this.url = url; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum CertifiedWith { + + DIN_31644("din31644"), + DINI_ZERTIFIKAT("dini-zertifikat"), + DSA("dsa"), + ISO_16363("iso16363"), + ISO_16919("iso16919"), + TRAC("trac"), + WDS("wds"), + CORETRUSTSEAL("coretrustseal"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Host.CertifiedWith c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private CertifiedWith(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Host.CertifiedWith fromValue(String value) { + Host.CertifiedWith constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + + public enum GeoLocation { + + AD("AD"), + AE("AE"), + AF("AF"), + AG("AG"), + AI("AI"), + AL("AL"), + AM("AM"), + AO("AO"), + AQ("AQ"), + AR("AR"), + AS("AS"), + AT("AT"), + AU("AU"), + AW("AW"), + AX("AX"), + AZ("AZ"), + BA("BA"), + BB("BB"), + BD("BD"), + BE("BE"), + BF("BF"), + BG("BG"), + BH("BH"), + BI("BI"), + BJ("BJ"), + BL("BL"), + BM("BM"), + BN("BN"), + BO("BO"), + BQ("BQ"), + BR("BR"), + BS("BS"), + BT("BT"), + BV("BV"), + BW("BW"), + BY("BY"), + BZ("BZ"), + CA("CA"), + CC("CC"), + CD("CD"), + CF("CF"), + CG("CG"), + CH("CH"), + CI("CI"), + CK("CK"), + CL("CL"), + CM("CM"), + CN("CN"), + CO("CO"), + CR("CR"), + CU("CU"), + CV("CV"), + CW("CW"), + CX("CX"), + CY("CY"), + CZ("CZ"), + DE("DE"), + DJ("DJ"), + DK("DK"), + DM("DM"), + DO("DO"), + DZ("DZ"), + EC("EC"), + EE("EE"), + EG("EG"), + EH("EH"), + ER("ER"), + ES("ES"), + ET("ET"), + FI("FI"), + FJ("FJ"), + FK("FK"), + FM("FM"), + FO("FO"), + FR("FR"), + GA("GA"), + GB("GB"), + GD("GD"), + GE("GE"), + GF("GF"), + GG("GG"), + GH("GH"), + GI("GI"), + GL("GL"), + GM("GM"), + GN("GN"), + GP("GP"), + GQ("GQ"), + GR("GR"), + GS("GS"), + GT("GT"), + GU("GU"), + GW("GW"), + GY("GY"), + HK("HK"), + HM("HM"), + HN("HN"), + HR("HR"), + HT("HT"), + HU("HU"), + ID("ID"), + IE("IE"), + IL("IL"), + IM("IM"), + IN("IN"), + IO("IO"), + IQ("IQ"), + IR("IR"), + IS("IS"), + IT("IT"), + JE("JE"), + JM("JM"), + JO("JO"), + JP("JP"), + KE("KE"), + KG("KG"), + KH("KH"), + KI("KI"), + KM("KM"), + KN("KN"), + KP("KP"), + KR("KR"), + KW("KW"), + KY("KY"), + KZ("KZ"), + LA("LA"), + LB("LB"), + LC("LC"), + LI("LI"), + LK("LK"), + LR("LR"), + LS("LS"), + LT("LT"), + LU("LU"), + LV("LV"), + LY("LY"), + MA("MA"), + MC("MC"), + MD("MD"), + ME("ME"), + MF("MF"), + MG("MG"), + MH("MH"), + MK("MK"), + ML("ML"), + MM("MM"), + MN("MN"), + MO("MO"), + MP("MP"), + MQ("MQ"), + MR("MR"), + MS("MS"), + MT("MT"), + MU("MU"), + MV("MV"), + MW("MW"), + MX("MX"), + MY("MY"), + MZ("MZ"), + NA("NA"), + NC("NC"), + NE("NE"), + NF("NF"), + NG("NG"), + NI("NI"), + NL("NL"), + NO("NO"), + NP("NP"), + NR("NR"), + NU("NU"), + NZ("NZ"), + OM("OM"), + PA("PA"), + PE("PE"), + PF("PF"), + PG("PG"), + PH("PH"), + PK("PK"), + PL("PL"), + PM("PM"), + PN("PN"), + PR("PR"), + PS("PS"), + PT("PT"), + PW("PW"), + PY("PY"), + QA("QA"), + RE("RE"), + RO("RO"), + RS("RS"), + RU("RU"), + RW("RW"), + SA("SA"), + SB("SB"), + SC("SC"), + SD("SD"), + SE("SE"), + SG("SG"), + SH("SH"), + SI("SI"), + SJ("SJ"), + SK("SK"), + SL("SL"), + SM("SM"), + SN("SN"), + SO("SO"), + SR("SR"), + SS("SS"), + ST("ST"), + SV("SV"), + SX("SX"), + SY("SY"), + SZ("SZ"), + TC("TC"), + TD("TD"), + TF("TF"), + TG("TG"), + TH("TH"), + TJ("TJ"), + TK("TK"), + TL("TL"), + TM("TM"), + TN("TN"), + TO("TO"), + TR("TR"), + TT("TT"), + TV("TV"), + TW("TW"), + TZ("TZ"), + UA("UA"), + UG("UG"), + UM("UM"), + US("US"), + UY("UY"), + UZ("UZ"), + VA("VA"), + VC("VC"), + VE("VE"), + VG("VG"), + VI("VI"), + VN("VN"), + VU("VU"), + WF("WF"), + WS("WS"), + YE("YE"), + YT("YT"), + ZA("ZA"), + ZM("ZM"), + ZW("ZW"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Host.GeoLocation c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private GeoLocation(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Host.GeoLocation fromValue(String value) { + Host.GeoLocation constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + + public enum SupportVersioning { + + YES("yes"), + NO("no"), + UNKNOWN("unknown"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Host.SupportVersioning c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private SupportVersioning(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Host.SupportVersioning fromValue(String value) { + Host.SupportVersioning constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/License.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/License.java new file mode 100644 index 000000000..1527f5503 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/License.java @@ -0,0 +1,113 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.net.URI; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * The Dataset Distribution License Items + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "license_ref", + "start_date" +}) +public class License implements Serializable +{ + + /** + * The Dataset Distribution License Reference Schema + *

+ * Link to license document. + * (Required) + * + */ + @JsonProperty("license_ref") + @JsonPropertyDescription("Link to license document.") + private URI licenseRef; + /** + * The Dataset Distribution License Start Date Schema + *

+ * Starting date of license. If date is set in the future, it indicates embargo period. + * (Required) + * + */ + @JsonProperty("start_date") + @JsonPropertyDescription("Starting date of license. If date is set in the future, it indicates embargo period.") + private String startDate; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 4148207295817559010L; + + /** + * The Dataset Distribution License Reference Schema + *

+ * Link to license document. + * (Required) + * + */ + @JsonProperty("license_ref") + public URI getLicenseRef() { + return licenseRef; + } + + /** + * The Dataset Distribution License Reference Schema + *

+ * Link to license document. + * (Required) + * + */ + @JsonProperty("license_ref") + public void setLicenseRef(URI licenseRef) { + this.licenseRef = licenseRef; + } + + /** + * The Dataset Distribution License Start Date Schema + *

+ * Starting date of license. If date is set in the future, it indicates embargo period. + * (Required) + * + */ + @JsonProperty("start_date") + public String getStartDate() { + return startDate; + } + + /** + * The Dataset Distribution License Start Date Schema + *

+ * Starting date of license. If date is set in the future, it indicates embargo period. + * (Required) + * + */ + @JsonProperty("start_date") + public void setStartDate(String startDate) { + this.startDate = startDate; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/MetadataStandardId.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/MetadataStandardId.java new file mode 100644 index 000000000..06b54a1f1 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/MetadataStandardId.java @@ -0,0 +1,153 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Dataset Metadata Standard ID Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "identifier", + "type" +}) +public class MetadataStandardId implements Serializable +{ + + /** + * The Dataset Metadata Standard Identifier Value Schema + *

+ * Identifier for the metadata standard used. + * (Required) + * + */ + @JsonProperty("identifier") + @JsonPropertyDescription("Identifier for the metadata standard used.") + private String identifier; + /** + * The Dataset Metadata Standard Identifier Type Schema + *

+ * Identifier type. Allowed values: url, other + * (Required) + * + */ + @JsonProperty("type") + @JsonPropertyDescription("Identifier type. Allowed values: url, other") + private MetadataStandardId.Type type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -7641042701935397947L; + + /** + * The Dataset Metadata Standard Identifier Value Schema + *

+ * Identifier for the metadata standard used. + * (Required) + * + */ + @JsonProperty("identifier") + public String getIdentifier() { + return identifier; + } + + /** + * The Dataset Metadata Standard Identifier Value Schema + *

+ * Identifier for the metadata standard used. + * (Required) + * + */ + @JsonProperty("identifier") + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + * The Dataset Metadata Standard Identifier Type Schema + *

+ * Identifier type. Allowed values: url, other + * (Required) + * + */ + @JsonProperty("type") + public MetadataStandardId.Type getType() { + return type; + } + + /** + * The Dataset Metadata Standard Identifier Type Schema + *

+ * Identifier type. Allowed values: url, other + * (Required) + * + */ + @JsonProperty("type") + public void setType(MetadataStandardId.Type type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Type { + + URL("url"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (MetadataStandardId.Type c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Type(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static MetadataStandardId.Type fromValue(String value) { + MetadataStandardId.Type constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java new file mode 100644 index 000000000..d6057ca62 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java @@ -0,0 +1,368 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Dataset Metadata Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "description", + "language", + "metadata_standard_id" +}) +public class Metadatum implements Serializable +{ + + /** + * The Dataset Metadata Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Description") + private String description; + /** + * The Dataset Metadata Language Schema + *

+ * Language of the metadata expressed using ISO 639-3. + * (Required) + * + */ + @JsonProperty("language") + @JsonPropertyDescription("Language of the metadata expressed using ISO 639-3.") + private Metadatum.Language language; + /** + * The Dataset Metadata Standard ID Schema + *

+ * + * (Required) + * + */ + @JsonProperty("metadata_standard_id") + private MetadataStandardId metadataStandardId; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 6511312853153406190L; + + /** + * The Dataset Metadata Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The Dataset Metadata Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The Dataset Metadata Language Schema + *

+ * Language of the metadata expressed using ISO 639-3. + * (Required) + * + */ + @JsonProperty("language") + public Metadatum.Language getLanguage() { + return language; + } + + /** + * The Dataset Metadata Language Schema + *

+ * Language of the metadata expressed using ISO 639-3. + * (Required) + * + */ + @JsonProperty("language") + public void setLanguage(Metadatum.Language language) { + this.language = language; + } + + /** + * The Dataset Metadata Standard ID Schema + *

+ * + * (Required) + * + */ + @JsonProperty("metadata_standard_id") + public MetadataStandardId getMetadataStandardId() { + return metadataStandardId; + } + + /** + * The Dataset Metadata Standard ID Schema + *

+ * + * (Required) + * + */ + @JsonProperty("metadata_standard_id") + public void setMetadataStandardId(MetadataStandardId metadataStandardId) { + this.metadataStandardId = metadataStandardId; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Language { + + AAR("aar"), + ABK("abk"), + AFR("afr"), + AKA("aka"), + AMH("amh"), + ARA("ara"), + ARG("arg"), + ASM("asm"), + AVA("ava"), + AVE("ave"), + AYM("aym"), + AZE("aze"), + BAK("bak"), + BAM("bam"), + BEL("bel"), + BEN("ben"), + BIH("bih"), + BIS("bis"), + BOD("bod"), + BOS("bos"), + BRE("bre"), + BUL("bul"), + CAT("cat"), + CES("ces"), + CHA("cha"), + CHE("che"), + CHU("chu"), + CHV("chv"), + COR("cor"), + COS("cos"), + CRE("cre"), + CYM("cym"), + DAN("dan"), + DEU("deu"), + DIV("div"), + DZO("dzo"), + ELL("ell"), + ENG("eng"), + EPO("epo"), + EST("est"), + EUS("eus"), + EWE("ewe"), + FAO("fao"), + FAS("fas"), + FIJ("fij"), + FIN("fin"), + FRA("fra"), + FRY("fry"), + FUL("ful"), + GLA("gla"), + GLE("gle"), + GLG("glg"), + GLV("glv"), + GRN("grn"), + GUJ("guj"), + HAT("hat"), + HAU("hau"), + HBS("hbs"), + HEB("heb"), + HER("her"), + HIN("hin"), + HMO("hmo"), + HRV("hrv"), + HUN("hun"), + HYE("hye"), + IBO("ibo"), + IDO("ido"), + III("iii"), + IKU("iku"), + ILE("ile"), + INA("ina"), + IND("ind"), + IPK("ipk"), + ISL("isl"), + ITA("ita"), + JAV("jav"), + JPN("jpn"), + KAL("kal"), + KAN("kan"), + KAS("kas"), + KAT("kat"), + KAU("kau"), + KAZ("kaz"), + KHM("khm"), + KIK("kik"), + KIN("kin"), + KIR("kir"), + KOM("kom"), + KON("kon"), + KOR("kor"), + KUA("kua"), + KUR("kur"), + LAO("lao"), + LAT("lat"), + LAV("lav"), + LIM("lim"), + LIN("lin"), + LIT("lit"), + LTZ("ltz"), + LUB("lub"), + LUG("lug"), + MAH("mah"), + MAL("mal"), + MAR("mar"), + MKD("mkd"), + MLG("mlg"), + MLT("mlt"), + MON("mon"), + MRI("mri"), + MSA("msa"), + MYA("mya"), + NAU("nau"), + NAV("nav"), + NBL("nbl"), + NDE("nde"), + NDO("ndo"), + NEP("nep"), + NLD("nld"), + NNO("nno"), + NOB("nob"), + NOR("nor"), + NYA("nya"), + OCI("oci"), + OJI("oji"), + ORI("ori"), + ORM("orm"), + OSS("oss"), + PAN("pan"), + PLI("pli"), + POL("pol"), + POR("por"), + PUS("pus"), + QUE("que"), + ROH("roh"), + RON("ron"), + RUN("run"), + RUS("rus"), + SAG("sag"), + SAN("san"), + SIN("sin"), + SLK("slk"), + SLV("slv"), + SME("sme"), + SMO("smo"), + SNA("sna"), + SND("snd"), + SOM("som"), + SOT("sot"), + SPA("spa"), + SQI("sqi"), + SRD("srd"), + SRP("srp"), + SSW("ssw"), + SUN("sun"), + SWA("swa"), + SWE("swe"), + TAH("tah"), + TAM("tam"), + TAT("tat"), + TEL("tel"), + TGK("tgk"), + TGL("tgl"), + THA("tha"), + TIR("tir"), + TON("ton"), + TSN("tsn"), + TSO("tso"), + TUK("tuk"), + TUR("tur"), + TWI("twi"), + UIG("uig"), + UKR("ukr"), + URD("urd"), + UZB("uzb"), + VEN("ven"), + VIE("vie"), + VOL("vol"), + WLN("wln"), + WOL("wol"), + XHO("xho"), + YID("yid"), + YOR("yor"), + ZHA("zha"), + ZHO("zho"), + ZUL("zul"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Metadatum.Language c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Language(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Metadatum.Language fromValue(String value) { + Metadatum.Language constant = CONSTANTS.get(value); + if (constant == null) { + return null; +// throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/PidSystem.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/PidSystem.java new file mode 100644 index 000000000..0e29d1153 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/PidSystem.java @@ -0,0 +1,63 @@ + +package eu.eudat.models.rda; + +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public enum PidSystem { + + ARK("ark"), + ARXIV("arxiv"), + BIBCODE("bibcode"), + DOI("doi"), + EAN_13("ean13"), + EISSN("eissn"), + HANDLE("handle"), + IGSN("igsn"), + ISBN("isbn"), + ISSN("issn"), + ISTC("istc"), + LISSN("lissn"), + LSID("lsid"), + PMID("pmid"), + PURL("purl"), + UPC("upc"), + URL("url"), + URN("urn"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (PidSystem c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private PidSystem(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static PidSystem fromValue(String value) { + PidSystem constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Project.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Project.java new file mode 100644 index 000000000..09c231ca3 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Project.java @@ -0,0 +1,212 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * The DMP Project Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "description", + "end", + "funding", + "start", + "title" +}) +public class Project implements Serializable +{ + + /** + * The DMP Project Description Schema + *

+ * Project description + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Project description") + private String description; + /** + * The DMP Project End Date Schema + *

+ * Project end date + * (Required) + * + */ + @JsonProperty("end") + @JsonPropertyDescription("Project end date") + private String end; + /** + * The DMP Project Funding Schema + *

+ * Funding related with a project + * + */ + @JsonProperty("funding") + @JsonPropertyDescription("Funding related with a project") + private List funding = null; + /** + * The DMP Project Start Date Schema + *

+ * Project start date + * (Required) + * + */ + @JsonProperty("start") + @JsonPropertyDescription("Project start date") + private String start; + /** + * The DMP Project Title Schema + *

+ * Project title + * (Required) + * + */ + @JsonProperty("title") + @JsonPropertyDescription("Project title") + private String title; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 1437619307195890472L; + + /** + * The DMP Project Description Schema + *

+ * Project description + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The DMP Project Description Schema + *

+ * Project description + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The DMP Project End Date Schema + *

+ * Project end date + * (Required) + * + */ + @JsonProperty("end") + public String getEnd() { + return end; + } + + /** + * The DMP Project End Date Schema + *

+ * Project end date + * (Required) + * + */ + @JsonProperty("end") + public void setEnd(String end) { + this.end = end; + } + + /** + * The DMP Project Funding Schema + *

+ * Funding related with a project + * + */ + @JsonProperty("funding") + public List getFunding() { + return funding; + } + + /** + * The DMP Project Funding Schema + *

+ * Funding related with a project + * + */ + @JsonProperty("funding") + public void setFunding(List funding) { + this.funding = funding; + } + + /** + * The DMP Project Start Date Schema + *

+ * Project start date + * (Required) + * + */ + @JsonProperty("start") + public String getStart() { + return start; + } + + /** + * The DMP Project Start Date Schema + *

+ * Project start date + * (Required) + * + */ + @JsonProperty("start") + public void setStart(String start) { + this.start = start; + } + + /** + * The DMP Project Title Schema + *

+ * Project title + * (Required) + * + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * The DMP Project Title Schema + *

+ * Project title + * (Required) + * + */ + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/RDAModel.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/RDAModel.java new file mode 100644 index 000000000..61df61b32 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/RDAModel.java @@ -0,0 +1,58 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * RDA DMP Common Standard Schema + *

+ * JSON Schema for the RDA DMP Common Standard + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "dmp" +}) +public class RDAModel implements Serializable +{ + + /** + * The DMP Schema + *

+ * + * (Required) + * + */ + @JsonProperty("dmp") + private Dmp dmp; + private final static long serialVersionUID = 7331666133368350998L; + + /** + * The DMP Schema + *

+ * + * (Required) + * + */ + @JsonProperty("dmp") + public Dmp getDmp() { + return dmp; + } + + /** + * The DMP Schema + *

+ * + * (Required) + * + */ + @JsonProperty("dmp") + public void setDmp(Dmp dmp) { + this.dmp = dmp; + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java new file mode 100644 index 000000000..0486df588 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java @@ -0,0 +1,109 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * The Dataset Security & Policy Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "description", + "title" +}) +public class SecurityAndPrivacy implements Serializable +{ + + /** + * The Dataset Security & Policy Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Description") + private String description; + /** + * The Dataset Security & Policy Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + @JsonPropertyDescription("Title") + private String title; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 7863747935827682977L; + + /** + * The Dataset Security & Policy Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The Dataset Security & Policy Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The Dataset Security & Policy Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * The Dataset Security & Policy Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java new file mode 100644 index 000000000..eac85da72 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java @@ -0,0 +1,109 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * The Dataset Technical Resource Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "description", + "name" +}) +public class TechnicalResource implements Serializable +{ + + /** + * The Dataset Technical Resource Description Schema + *

+ * Description of the technical resource + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Description of the technical resource") + private String description; + /** + * The Dataset Technical Resource Name Schema + *

+ * Name of the technical resource + * (Required) + * + */ + @JsonProperty("name") + @JsonPropertyDescription("Name of the technical resource") + private String name; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -7451757227129483110L; + + /** + * The Dataset Technical Resource Description Schema + *

+ * Description of the technical resource + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The Dataset Technical Resource Description Schema + *

+ * Description of the technical resource + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The Dataset Technical Resource Name Schema + *

+ * Name of the technical resource + * (Required) + * + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * The Dataset Technical Resource Name Schema + *

+ * Name of the technical resource + * (Required) + * + */ + @JsonProperty("name") + public void setName(String name) { + this.name = name; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java new file mode 100644 index 000000000..48549d75a --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java @@ -0,0 +1,15 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.models.rda.ContactId; + +import java.util.UUID; + +public class ContactIdRDAMapper { + + public static ContactId toRDA(UUID id) { + ContactId rda = new ContactId(); + rda.setIdentifier(id.toString()); + rda.setType(ContactId.Type.OTHER); + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java new file mode 100644 index 000000000..69ea2310e --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java @@ -0,0 +1,16 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.data.entities.UserInfo; +import eu.eudat.models.rda.Contact; +import eu.eudat.models.rda.ContactId; + +public class ContactRDAMapper { + + public static Contact toRDA(UserInfo creator) { + Contact rda = new Contact(); + rda.setName(creator.getName()); + rda.setMbox(creator.getEmail()); + rda.setContactId(ContactIdRDAMapper.toRDA(creator.getId())); + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorIdRDAMapper.java new file mode 100644 index 000000000..107dfb996 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorIdRDAMapper.java @@ -0,0 +1,16 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.models.rda.Contributor; +import eu.eudat.models.rda.ContributorId; + +import java.util.UUID; + +public class ContributorIdRDAMapper { + + public static ContributorId toRDA(UUID id) { + ContributorId rda = new ContributorId(); + rda.setIdentifier(id.toString()); + rda.setType(ContributorId.Type.OTHER); + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorRDAMapper.java new file mode 100644 index 000000000..681d98940 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorRDAMapper.java @@ -0,0 +1,20 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.data.entities.UserDMP; +import eu.eudat.models.rda.Contributor; + +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; + +public class ContributorRDAMapper { + + public static Contributor toRDA(UserDMP userDMP) { + Contributor rda = new Contributor(); + rda.setContributorId(ContributorIdRDAMapper.toRDA(userDMP.getUser().getId())); + rda.setName(userDMP.getUser().getName()); + rda.setMbox(userDMP.getUser().getEmail()); + rda.setRole(new HashSet<>(Arrays.asList(UserDMP.UserDMPRoles.fromInteger(userDMP.getRole()).name()))); + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetIdRDAMapper.java new file mode 100644 index 000000000..ab791e215 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetIdRDAMapper.java @@ -0,0 +1,17 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.databind.ObjectMapper; +import eu.eudat.models.rda.DatasetId; + +import java.util.UUID; + +public class DatasetIdRDAMapper { + + public static DatasetId toRDA(UUID id) { + DatasetId rda = new DatasetId(); + rda.setIdentifier(id.toString()); + rda.setType(DatasetId.Type.OTHER); + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java new file mode 100644 index 000000000..103ba72c6 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java @@ -0,0 +1,100 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import eu.eudat.logic.managers.DatasetManager; +import eu.eudat.logic.utilities.json.JsonSearcher; +import eu.eudat.models.data.datasetwizard.DatasetWizardModel; +import eu.eudat.models.rda.Dataset; +import org.json.JSONObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.transaction.Transactional; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.stream.Collectors; + +@Component +public class DatasetRDAMapper { + private static final Logger logger = LoggerFactory.getLogger(DatasetRDAMapper.class); + + private DatasetManager datasetManager; + + @Autowired + public DatasetRDAMapper(DatasetManager datasetManager) { + this.datasetManager = datasetManager; + } + + @Transactional + public Dataset toRDA(eu.eudat.data.entities.Dataset dataset) { + Dataset rda = new Dataset(); + rda.setDatasetId(DatasetIdRDAMapper.toRDA(dataset.getId())); + rda.setTitle(dataset.getLabel()); + rda.setDescription(dataset.getDescription()); + try { + + DatasetWizardModel datasetWizardModel = new DatasetWizardModel().fromDataModel(dataset); + datasetWizardModel.setDatasetProfileDefinition(datasetManager.getPagedProfile(datasetWizardModel, dataset)); + ObjectMapper mapper = new ObjectMapper(); + JsonNode properties = mapper.readTree(dataset.getProperties()); + String datasetDescriptionJson = mapper.writeValueAsString(datasetWizardModel.getDatasetProfileDefinition()); + JsonNode datasetDescriptionObj = mapper.readTree(datasetDescriptionJson); + List typeNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.type"); + if (!typeNodes.isEmpty()) { + rda.setType(properties.get(typeNodes.get(0).get("id").asText()).asText()); + } + List languageNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.language"); + if (!languageNodes.isEmpty()) { + rda.setLanguage(Dataset.Language.fromValue(properties.get(languageNodes.get(0).get("id").asText()).asText())); + } + List metadataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.metadata"); + if (!metadataNodes.isEmpty()) { + rda.setMetadata(metadataNodes.stream().map(node -> MetadataRDAMapper.toRDA(node, properties)).collect(Collectors.toList())); + } + List qaNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.data_quality_assurance"); + if (!qaNodes.isEmpty()) { + rda.setDataQualityAssurance(qaNodes.stream().map(qaNode -> properties.get(qaNode.get("id").asText()).asText()).collect(Collectors.toList())); + } + List preservationNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.preservation_statement"); + if (!preservationNodes.isEmpty()) { + rda.setDataQualityAssurance(preservationNodes.stream().map(preservationNode -> properties.get(preservationNode.get("id").asText()).asText()).collect(Collectors.toList())); + } + List distributionNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.distribution"); + if (!distributionNodes.isEmpty()) { + rda.setDistribution(distributionNodes.stream().map(distributionNode -> DistributionRDAMapper.toRDA(distributionNode, properties)).collect(Collectors.toList())); + } + List keywordNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.keyword"); + if (!keywordNodes.isEmpty()) { + rda.setKeyword(keywordNodes.stream().map(keywordNode -> properties.get(keywordNode.get("id").asText()).asText()).collect(Collectors.toList())); + } + List personalDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.personal_data"); + if (!personalDataNodes.isEmpty()) { + rda.setPersonalData(personalDataNodes.stream().map(personalDataNode -> Dataset.PersonalData.fromValue(properties.get(personalDataNode.get("id").asText()).asText())).findFirst().get()); + } + List securityAndPrivacyNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.security_and_privacy"); + if (!securityAndPrivacyNodes.isEmpty()) { + rda.setSecurityAndPrivacy(securityAndPrivacyNodes.stream().map(securityAndPrivacyNode -> SecurityAndPrivacyRDAMapper.toRDA(securityAndPrivacyNode, properties)).collect(Collectors.toList())); + } + List sensitiveDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.sensitive_data"); + if (!sensitiveDataNodes.isEmpty()) { + rda.setSensitiveData(securityAndPrivacyNodes.stream().map(sensitiveDataNode -> Dataset.SensitiveData.fromValue(properties.get(sensitiveDataNode.get("id").asText()).asText())).findFirst().get()); + } + List technicalResourceNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.technical_resource"); + if (!technicalResourceNodes.isEmpty()) { + rda.setTechnicalResource(technicalResourceNodes.stream().map(technicalResourceNode -> TechnicalResourceRDAMapper.toRDA(technicalResourceNode, properties)).collect(Collectors.toList())); + } + + + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java new file mode 100644 index 000000000..513affd98 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java @@ -0,0 +1,39 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.models.rda.Distribution; + +import java.net.URI; +import java.util.Collections; + +public class DistributionRDAMapper { + + public static Distribution toRDA(JsonNode structure, JsonNode properties) { + Distribution rda = new Distribution(); + String rdaProperty = structure.get("rdaProperty").asText(); + if (rdaProperty.contains("access_url")) { + rda.setAccessUrl(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("available_util")) { + rda.setAvailableUntil(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("byte_size")) { + rda.setByteSize(properties.get(structure.get("id").asText()).asInt()); + } else if (rdaProperty.contains("data_access")) { + rda.setDataAccess(Distribution.DataAccess.fromValue(properties.get(structure.get("id").asText()).asText())); + } else if (rdaProperty.contains("description")) { + rda.setDescription(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("download_url")) { + rda.setDownloadUrl(URI.create(properties.get(structure.get("id").asText()).asText())); + } else if (rdaProperty.contains("format")) { + rda.setFormat(Collections.singletonList(properties.get(structure.get("id").asText()).asText())); + } else if (rdaProperty.contains("host")) { + rda.setHost(HostRDAMapper.toRDA(structure, properties)); + } else if (rdaProperty.contains("license")) { + rda.setLicense(Collections.singletonList(LicenseRDAMapper.toRDA(structure, properties))); + } else if (rdaProperty.contains("title")) { + rda.setTitle(properties.get(structure.get("id").asText()).asText()); + } + + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpIdRDAMapper.java new file mode 100644 index 000000000..095c26e11 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpIdRDAMapper.java @@ -0,0 +1,19 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.models.rda.DmpId; + +import java.util.UUID; + +public class DmpIdRDAMapper { + + public static DmpId toRDA(Object id) { + DmpId rda = new DmpId(); + rda.setIdentifier(id.toString()); + if (id instanceof UUID) { + rda.setType(DmpId.Type.OTHER); + } else { + rda.setType(DmpId.Type.DOI); + } + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java new file mode 100644 index 000000000..620229a27 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java @@ -0,0 +1,51 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.data.entities.DMP; +import eu.eudat.data.entities.UserDMP; +import eu.eudat.data.entities.UserInfo; +import eu.eudat.models.rda.Dmp; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.transaction.Transactional; +import java.util.Collections; +import java.util.stream.Collectors; + +@Component +public class DmpRDAMapper { + + private DatasetRDAMapper datasetRDAMapper; + + @Autowired + public DmpRDAMapper(DatasetRDAMapper datasetRDAMapper) { + this.datasetRDAMapper = datasetRDAMapper; + } + + @Transactional + public Dmp toRDA(DMP dmp) { + Dmp rda = new Dmp(); + if (dmp.getDoi() != null && !dmp.getDoi().isEmpty()) { + rda.setDmpId(DmpIdRDAMapper.toRDA(dmp.getDoi())); + } else { + rda.setDmpId(DmpIdRDAMapper.toRDA(dmp.getId())); + } + rda.setCreated(dmp.getCreated()); + rda.setDescription(dmp.getDescription()); + rda.setModified(dmp.getModified()); + rda.setTitle(dmp.getLabel()); + + UserInfo creator; + if (dmp.getCreator() != null) { + creator = dmp.getCreator(); + } else { + creator = dmp.getUsers().stream().filter(userDMP -> userDMP.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())).map(UserDMP::getUser).findFirst().orElse(new UserInfo()); + } + rda.setContact(ContactRDAMapper.toRDA(creator)); + rda.setContributor(dmp.getUsers().stream().map(ContributorRDAMapper::toRDA).collect(Collectors.toList())); + rda.setDataset(dmp.getDataset().stream().map(dataset -> datasetRDAMapper.toRDA(dataset)).collect(Collectors.toList())); + rda.setProject(Collections.singletonList(ProjectRDAMapper.toRDA(dmp.getProject(), dmp.getGrant()))); + + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FunderIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FunderIdRDAMapper.java new file mode 100644 index 000000000..f0dc5ff4a --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FunderIdRDAMapper.java @@ -0,0 +1,19 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.models.rda.FunderId; + +import java.util.UUID; + +public class FunderIdRDAMapper { + + public static FunderId toRDA(Object id) { + FunderId rda = new FunderId(); + rda.setIdentifier(id.toString()); + if (id instanceof UUID) { + rda.setType(FunderId.Type.OTHER); + } else { + rda.setType(FunderId.Type.FUNDREF); + } + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java new file mode 100644 index 000000000..e0b8fbe65 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java @@ -0,0 +1,25 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.data.entities.Funder; +import eu.eudat.data.entities.Grant; +import eu.eudat.models.rda.Funding; + +public class FundingRDAMapper { + + public static Funding toRDA(Grant grant) { + Funding rda = new Funding(); + String referencePrefix; + String shortReference; + if (grant.getFunder().getReference() != null) { + referencePrefix = grant.getFunder().getReference().split(":")[0]; + shortReference = grant.getFunder().getReference().substring(referencePrefix.length() + 1); + rda.setFunderId(FunderIdRDAMapper.toRDA(shortReference)); + } else { + rda.setFunderId(FunderIdRDAMapper.toRDA(grant.getFunder().getId())); + } + referencePrefix = grant.getReference().split(":")[0]; + shortReference = grant.getReference().substring(referencePrefix.length() + 1); + rda.setGrantId(GrantIdRDAMapper.toRDA(shortReference)); + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/GrantIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/GrantIdRDAMapper.java new file mode 100644 index 000000000..d05ec5d02 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/GrantIdRDAMapper.java @@ -0,0 +1,13 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.models.rda.GrantId; + +public class GrantIdRDAMapper { + + public static GrantId toRDA(String id) { + GrantId rda = new GrantId(); + rda.setIdentifier(id); + rda.setType(GrantId.Type.OTHER); + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java new file mode 100644 index 000000000..9a32cc697 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java @@ -0,0 +1,41 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.models.rda.Host; +import eu.eudat.models.rda.PidSystem; + +import java.net.URI; +import java.util.Collections; + +public class HostRDAMapper { + + public static Host toRDA(JsonNode structure, JsonNode properties) { + Host rda = new Host(); + String rdaProperty = structure.get("rdaProperties").asText(); + if (rdaProperty.contains("availability")) { + rda.setAvailability(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("backup_frequency")) { + rda.setBackupFrequency(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("backup_type")) { + rda.setBackupType(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("certified_with")) { + rda.setCertifiedWith(Host.CertifiedWith.fromValue(properties.get(structure.get("id").asText()).asText())); + } else if (rdaProperty.contains("description")) { + rda.setDescription(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("geo_location")) { + rda.setGeoLocation(Host.GeoLocation.fromValue(properties.get(structure.get("id").asText()).asText())); + } else if (rdaProperty.contains("pid_system")) { + rda.setPidSystem(Collections.singletonList(PidSystem.fromValue(properties.get(structure.get("id").asText()).asText()))); + } else if (rdaProperty.contains("storage_type")) { + rda.setStorageType(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("support_versioning")) { + rda.setSupportVersioning(Host.SupportVersioning.fromValue(properties.get(structure.get("id").asText()).asText())); + } else if (rdaProperty.contains("title")) { + rda.setTitle(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("url")) { + rda.setUrl(URI.create(properties.get(structure.get("id").asText()).asText())); + } + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java new file mode 100644 index 000000000..68817bd3d --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java @@ -0,0 +1,23 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.models.rda.License; + +import java.net.URI; + +public class LicenseRDAMapper { + + public static License toRDA(JsonNode structure, JsonNode properties) { + License rda = new License(); + String rdaProperty = structure.get("rdaProperty").asText(); + String value = properties.get(structure.get("id").asText()).asText(); + + if (rdaProperty.contains("license_ref")) { + rda.setLicenseRef(URI.create(value)); + } else if (rdaProperty.contains("start_date")) { + rda.setStartDate(value); + } + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java new file mode 100644 index 000000000..fa638d3e3 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java @@ -0,0 +1,44 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import eu.eudat.models.rda.Metadatum; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.util.Iterator; + +public class MetadataRDAMapper { + private static final Logger logger = LoggerFactory.getLogger(MetadataRDAMapper.class); + + public static Metadatum toRDA(JsonNode structure, JsonNode properties) { + Metadatum rda = new Metadatum(); + JsonNode dataNode = null; + String rdaProperty = structure.get("rdaProperty").asText(); + if (rdaProperty.contains("metadata_standard_id")) { + try { + String jsonText = properties.get(structure.get("id").asText()).asText(); + if (jsonText != null && !jsonText.isEmpty()) { + dataNode = new ObjectMapper().readTree(jsonText); + for (Iterator it = dataNode.elements(); it.hasNext(); ) { + JsonNode data = it.next(); + if (data.get("uri") != null) { + rda.setMetadataStandardId(MetadataStandardIdRDAMapper.toRDA(data.get("uri").asText())); + } + } + } + } catch (IOException e) { + logger.error(e.getMessage(), e); + } + } else if (rdaProperty.contains("description")) { + rda.setDescription(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("language")) { + String language = properties.get(structure.get("id").asText()).asText(); + Metadatum.Language lang = Metadatum.Language.fromValue(language); + rda.setLanguage(lang); + } + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataStandardIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataStandardIdRDAMapper.java new file mode 100644 index 000000000..586446e02 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataStandardIdRDAMapper.java @@ -0,0 +1,13 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.models.rda.MetadataStandardId; + +public class MetadataStandardIdRDAMapper { + + public static MetadataStandardId toRDA(String uri) { + MetadataStandardId rda = new MetadataStandardId(); + rda.setIdentifier(uri); + rda.setType(MetadataStandardId.Type.URL); + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java new file mode 100644 index 000000000..d97eace4a --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java @@ -0,0 +1,25 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.data.entities.Funder; +import eu.eudat.data.entities.Grant; +import eu.eudat.models.rda.Project; + +import java.util.Collections; + +public class ProjectRDAMapper { + + public static Project toRDA(eu.eudat.data.entities.Project project, Grant grant) { + Project rda = new Project(); + rda.setTitle(project.getLabel()); + rda.setDescription(project.getDescription()); + if (project.getStartdate() != null) { + rda.setStart(project.getStartdate().toString()); + } + if (project.getEnddate() != null) { + rda.setEnd(project.getEnddate().toString()); + } + rda.setFunding(Collections.singletonList(FundingRDAMapper.toRDA(grant))); + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java new file mode 100644 index 000000000..f7f95633f --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java @@ -0,0 +1,21 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.models.rda.SecurityAndPrivacy; + +public class SecurityAndPrivacyRDAMapper { + + public static SecurityAndPrivacy toRDA(JsonNode structure, JsonNode properties) { + SecurityAndPrivacy rda = new SecurityAndPrivacy(); + String rdaProperty = structure.get("rdaProperty").asText(); + String value = properties.get(structure.get("id").asText()).asText(); + + if (rdaProperty.contains("description")) { + rda.setDescription(value); + } else if (rdaProperty.contains("title")) { + rda.setTitle(value); + } + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java new file mode 100644 index 000000000..b2652901a --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java @@ -0,0 +1,21 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.models.rda.TechnicalResource; + +public class TechnicalResourceRDAMapper { + + public static TechnicalResource toRDA(JsonNode structure, JsonNode properties) { + TechnicalResource rda = new TechnicalResource(); + String rdaProperty = structure.get("rdaProperty").asText(); + String value = properties.get(structure.get("id").asText()).asText(); + + if (rdaProperty.contains("description")) { + rda.setDescription(value); + } else if (rdaProperty.contains("name")) { + rda.setName(value); + } + + return rda; + } +} From f1c405dae9383397cc3cd729e62865dd37f355b5 Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Mon, 23 Mar 2020 18:09:31 +0200 Subject: [PATCH 02/20] Improved object coupling for various objects on the dataset form --- .../utilities/helpers/MyStringUtils.java | 21 ++++ .../logic/utilities/json/JsonSearcher.java | 1 + .../user/components/datasetprofile/Field.java | 6 +- .../components/datasetprofile/FieldSet.java | 9 +- .../models/rda/mapper/DatasetRDAMapper.java | 27 ++-- .../rda/mapper/DistributionRDAMapper.java | 107 ++++++++++++++-- .../models/rda/mapper/HostRDAMapper.java | 98 +++++++++++---- .../models/rda/mapper/LicenseRDAMapper.java | 6 +- .../models/rda/mapper/MetadataRDAMapper.java | 119 +++++++++++++++--- .../mapper/SecurityAndPrivacyRDAMapper.java | 57 ++++++++- .../mapper/TechnicalResourceRDAMapper.java | 58 ++++++++- .../dataset-description-form.model.ts | 2 +- 12 files changed, 424 insertions(+), 87 deletions(-) create mode 100644 dmp-backend/web/src/main/java/eu/eudat/logic/utilities/helpers/MyStringUtils.java diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/helpers/MyStringUtils.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/helpers/MyStringUtils.java new file mode 100644 index 000000000..1a071e04c --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/helpers/MyStringUtils.java @@ -0,0 +1,21 @@ +package eu.eudat.logic.utilities.helpers; + +public class MyStringUtils { + + public static int getFirstDifference(String s1, String s2) { + char[] s1ar = s1.toCharArray(); + char[] s2ar = s2.toCharArray(); + + for(int i = 0; i < s1ar.length; i++) { + if (s2ar.length > i) { + if (s1ar[i] != s2ar[i]) { + return i; + } + } else { + return i; + } + } + + return -1; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java index ca2372b91..979053830 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java @@ -1,6 +1,7 @@ package eu.eudat.logic.utilities.json; import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.ObjectNode; import java.util.ArrayList; import java.util.Iterator; diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/Field.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/Field.java index 4950261c4..1c735e1a9 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/Field.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/Field.java @@ -149,7 +149,7 @@ public class Field implements Comparable, PropertiesModelBuilder, ViewStyleDefin this.rdaProperty = rdaProperty; } - Field cloneForMultiplicity(String key, Map properties) { + Field cloneForMultiplicity(String key, Map properties, int index) { Field newField = new Field(); newField.id = key; newField.ordinal = this.ordinal; @@ -161,6 +161,7 @@ public class Field implements Comparable, PropertiesModelBuilder, ViewStyleDefin newField.data = this.data; newField.validations = this.validations; newField.rdaProperty = this.rdaProperty; + newField.numbering = "mult" + index + "_" + this.numbering; return newField; } @@ -204,8 +205,9 @@ public class Field implements Comparable, PropertiesModelBuilder, ViewStyleDefin } 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)); + this.multiplicityItems.add(this.cloneForMultiplicity(key, properties, index)); } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/FieldSet.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/FieldSet.java index 51663ddaf..277534d16 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/FieldSet.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/FieldSet.java @@ -163,16 +163,18 @@ public class FieldSet implements Comparable, PropertiesModelBuilder, ViewStyleDe }); 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)); + 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){ + private FieldSet CloneForMultiplicity2(List key, Map properties,String[] ids, int index){ FieldSet newFieldSet = new FieldSet(); newFieldSet.id = ids[0]+"_"+ids[1]+"_"+ids[2]; newFieldSet.description = this.description; @@ -181,8 +183,9 @@ public class FieldSet implements Comparable, PropertiesModelBuilder, ViewStyleDe newFieldSet.title = this.title; newFieldSet.ordinal = this.ordinal; newFieldSet.fields = new LinkedList(); + for (Field field: this.fields) { - newFieldSet.fields.add(field.cloneForMultiplicity(newFieldSet.id + "_" + field.getId(), properties)); + newFieldSet.fields.add(field.cloneForMultiplicity(newFieldSet.id + "_" + field.getId(), properties, index)); } return newFieldSet; } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java index 103ba72c6..5eb9cc685 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java @@ -1,21 +1,17 @@ package eu.eudat.models.rda.mapper; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import eu.eudat.logic.managers.DatasetManager; import eu.eudat.logic.utilities.json.JsonSearcher; import eu.eudat.models.data.datasetwizard.DatasetWizardModel; import eu.eudat.models.rda.Dataset; -import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import javax.transaction.Transactional; -import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import java.util.stream.Collectors; @@ -41,52 +37,51 @@ public class DatasetRDAMapper { DatasetWizardModel datasetWizardModel = new DatasetWizardModel().fromDataModel(dataset); datasetWizardModel.setDatasetProfileDefinition(datasetManager.getPagedProfile(datasetWizardModel, dataset)); ObjectMapper mapper = new ObjectMapper(); - JsonNode properties = mapper.readTree(dataset.getProperties()); String datasetDescriptionJson = mapper.writeValueAsString(datasetWizardModel.getDatasetProfileDefinition()); JsonNode datasetDescriptionObj = mapper.readTree(datasetDescriptionJson); List typeNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.type"); if (!typeNodes.isEmpty()) { - rda.setType(properties.get(typeNodes.get(0).get("id").asText()).asText()); + rda.setType(typeNodes.get(0).get("value").asText()); } List languageNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.language"); if (!languageNodes.isEmpty()) { - rda.setLanguage(Dataset.Language.fromValue(properties.get(languageNodes.get(0).get("id").asText()).asText())); + rda.setLanguage(Dataset.Language.fromValue(languageNodes.get(0).get("value").asText())); } List metadataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.metadata"); if (!metadataNodes.isEmpty()) { - rda.setMetadata(metadataNodes.stream().map(node -> MetadataRDAMapper.toRDA(node, properties)).collect(Collectors.toList())); + rda.setMetadata(MetadataRDAMapper.toRDAList(metadataNodes)); } List qaNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.data_quality_assurance"); if (!qaNodes.isEmpty()) { - rda.setDataQualityAssurance(qaNodes.stream().map(qaNode -> properties.get(qaNode.get("id").asText()).asText()).collect(Collectors.toList())); + rda.setDataQualityAssurance(qaNodes.stream().map(qaNode -> qaNode.get("value").asText()).collect(Collectors.toList())); } List preservationNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.preservation_statement"); if (!preservationNodes.isEmpty()) { - rda.setDataQualityAssurance(preservationNodes.stream().map(preservationNode -> properties.get(preservationNode.get("id").asText()).asText()).collect(Collectors.toList())); + rda.setDataQualityAssurance(preservationNodes.stream().map(preservationNode -> preservationNode.get("value").asText()).collect(Collectors.toList())); } List distributionNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.distribution"); if (!distributionNodes.isEmpty()) { - rda.setDistribution(distributionNodes.stream().map(distributionNode -> DistributionRDAMapper.toRDA(distributionNode, properties)).collect(Collectors.toList())); + rda.setDistribution(DistributionRDAMapper.toRDAList(distributionNodes)); } List keywordNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.keyword"); if (!keywordNodes.isEmpty()) { - rda.setKeyword(keywordNodes.stream().map(keywordNode -> properties.get(keywordNode.get("id").asText()).asText()).collect(Collectors.toList())); + rda.setKeyword(keywordNodes.stream().map(keywordNode -> keywordNode.get("value").asText()).collect(Collectors.toList())); } List personalDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.personal_data"); if (!personalDataNodes.isEmpty()) { - rda.setPersonalData(personalDataNodes.stream().map(personalDataNode -> Dataset.PersonalData.fromValue(properties.get(personalDataNode.get("id").asText()).asText())).findFirst().get()); + rda.setPersonalData(personalDataNodes.stream().map(personalDataNode -> Dataset.PersonalData.fromValue(personalDataNode.get("value").asText())).findFirst().get()); } List securityAndPrivacyNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.security_and_privacy"); if (!securityAndPrivacyNodes.isEmpty()) { - rda.setSecurityAndPrivacy(securityAndPrivacyNodes.stream().map(securityAndPrivacyNode -> SecurityAndPrivacyRDAMapper.toRDA(securityAndPrivacyNode, properties)).collect(Collectors.toList())); + rda.setSecurityAndPrivacy(SecurityAndPrivacyRDAMapper.toRDAList(securityAndPrivacyNodes)); } List sensitiveDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.sensitive_data"); if (!sensitiveDataNodes.isEmpty()) { - rda.setSensitiveData(securityAndPrivacyNodes.stream().map(sensitiveDataNode -> Dataset.SensitiveData.fromValue(properties.get(sensitiveDataNode.get("id").asText()).asText())).findFirst().get()); + rda.setSensitiveData(securityAndPrivacyNodes.stream().map(sensitiveDataNode -> Dataset.SensitiveData.fromValue(sensitiveDataNode.get("value").asText())).findFirst().get()); } List technicalResourceNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.technical_resource"); if (!technicalResourceNodes.isEmpty()) { - rda.setTechnicalResource(technicalResourceNodes.stream().map(technicalResourceNode -> TechnicalResourceRDAMapper.toRDA(technicalResourceNode, properties)).collect(Collectors.toList())); + rda.setTechnicalResource(TechnicalResourceRDAMapper.toRDAList(technicalResourceNodes)); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java index 513affd98..98cb6960b 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java @@ -1,39 +1,120 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.logic.utilities.helpers.MyStringUtils; import eu.eudat.models.rda.Distribution; import java.net.URI; -import java.util.Collections; +import java.util.*; public class DistributionRDAMapper { - public static Distribution toRDA(JsonNode structure, JsonNode properties) { + public static List toRDAList(List nodes) { + Map rdaMap = new HashMap<>(); + + for (JsonNode node: nodes) { + String rdaProperty = node.get("rdaProperty").asText(); + String rdaValue = node.get("value").asText(); + Distribution rda = getRelative(rdaMap, node.get("numbering").asText()); + if (!rdaMap.containsValue(rda)) { + rdaMap.put(node.get("numbering").asText(), rda); + } + for (PropertyName propertyName : PropertyName.values()) { + if (rdaProperty.contains(propertyName.getName())) { + switch (propertyName) { + case ACCESS_URL: + rda.setAccessUrl(rdaValue); + break; + case AVAILABLE_UTIL: + rda.setAvailableUntil(rdaValue); + break; + case DOWNLOAD_URL: + rda.setDownloadUrl(URI.create(rdaValue)); + break; + case DESCRIPTION: + rda.setDescription(rdaValue); + break; + case DATA_ACCESS: + rda.setDataAccess(Distribution.DataAccess.fromValue(rdaValue)); + break; + case BYTE_SIZE: + rda.setByteSize(Integer.parseInt(rdaValue)); + break; + case LICENSE: + rda.setLicense(Collections.singletonList(LicenseRDAMapper.toRDA(node))); + break; + case FORMAT: + rda.setFormat(Collections.singletonList(rdaValue)); + break; + case TITLE: + rda.setTitle(rdaValue); + break; + case HOST: + rda.setHost(HostRDAMapper.toRDA(nodes, node.get("numbering").asText())); + break; + } + } + } + } + + return new ArrayList<>(rdaMap.values()); + } + + public static Distribution toRDA(JsonNode node) { Distribution rda = new Distribution(); - String rdaProperty = structure.get("rdaProperty").asText(); + String rdaProperty = node.get("rdaProperty").asText(); + String rdaValue = node.get("value").asText(); if (rdaProperty.contains("access_url")) { - rda.setAccessUrl(properties.get(structure.get("id").asText()).asText()); + rda.setAccessUrl(rdaValue); } else if (rdaProperty.contains("available_util")) { - rda.setAvailableUntil(properties.get(structure.get("id").asText()).asText()); + rda.setAvailableUntil(rdaValue); } else if (rdaProperty.contains("byte_size")) { - rda.setByteSize(properties.get(structure.get("id").asText()).asInt()); + rda.setByteSize(Integer.parseInt(rdaValue)); } else if (rdaProperty.contains("data_access")) { - rda.setDataAccess(Distribution.DataAccess.fromValue(properties.get(structure.get("id").asText()).asText())); + rda.setDataAccess(Distribution.DataAccess.fromValue(rdaValue)); } else if (rdaProperty.contains("description")) { - rda.setDescription(properties.get(structure.get("id").asText()).asText()); + rda.setDescription(rdaValue); } else if (rdaProperty.contains("download_url")) { - rda.setDownloadUrl(URI.create(properties.get(structure.get("id").asText()).asText())); + rda.setDownloadUrl(URI.create(rdaValue)); } else if (rdaProperty.contains("format")) { - rda.setFormat(Collections.singletonList(properties.get(structure.get("id").asText()).asText())); + rda.setFormat(Collections.singletonList(rdaValue)); } else if (rdaProperty.contains("host")) { - rda.setHost(HostRDAMapper.toRDA(structure, properties)); +// rda.setHost(HostRDAMapper.toRDA(node)); } else if (rdaProperty.contains("license")) { - rda.setLicense(Collections.singletonList(LicenseRDAMapper.toRDA(structure, properties))); + rda.setLicense(Collections.singletonList(LicenseRDAMapper.toRDA(node))); } else if (rdaProperty.contains("title")) { - rda.setTitle(properties.get(structure.get("id").asText()).asText()); + rda.setTitle(rdaValue); } return rda; } + + private static Distribution getRelative( Map rdaMap, String numbering) { + return rdaMap.entrySet().stream().filter(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering) > 0) + .max(Comparator.comparingInt(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering))).map(Map.Entry::getValue).orElse(new Distribution()); + } + + private enum PropertyName { + ACCESS_URL("access_url"), + AVAILABLE_UTIL("available_util"), + BYTE_SIZE("byte_size"), + DATA_ACCESS("data_access"), + DESCRIPTION("description"), + DOWNLOAD_URL("download_url"), + FORMAT("format"), + HOST("host"), + LICENSE("license"), + TITLE("title"); + + private final String name; + + PropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java index 9a32cc697..0983f3d3b 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java @@ -1,41 +1,91 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.logic.utilities.helpers.MyStringUtils; import eu.eudat.models.rda.Host; import eu.eudat.models.rda.PidSystem; import java.net.URI; import java.util.Collections; +import java.util.List; public class HostRDAMapper { - public static Host toRDA(JsonNode structure, JsonNode properties) { + public static Host toRDA(List nodes, String numbering) { Host rda = new Host(); - String rdaProperty = structure.get("rdaProperties").asText(); - if (rdaProperty.contains("availability")) { - rda.setAvailability(properties.get(structure.get("id").asText()).asText()); - } else if (rdaProperty.contains("backup_frequency")) { - rda.setBackupFrequency(properties.get(structure.get("id").asText()).asText()); - } else if (rdaProperty.contains("backup_type")) { - rda.setBackupType(properties.get(structure.get("id").asText()).asText()); - } else if (rdaProperty.contains("certified_with")) { - rda.setCertifiedWith(Host.CertifiedWith.fromValue(properties.get(structure.get("id").asText()).asText())); - } else if (rdaProperty.contains("description")) { - rda.setDescription(properties.get(structure.get("id").asText()).asText()); - } else if (rdaProperty.contains("geo_location")) { - rda.setGeoLocation(Host.GeoLocation.fromValue(properties.get(structure.get("id").asText()).asText())); - } else if (rdaProperty.contains("pid_system")) { - rda.setPidSystem(Collections.singletonList(PidSystem.fromValue(properties.get(structure.get("id").asText()).asText()))); - } else if (rdaProperty.contains("storage_type")) { - rda.setStorageType(properties.get(structure.get("id").asText()).asText()); - } else if (rdaProperty.contains("support_versioning")) { - rda.setSupportVersioning(Host.SupportVersioning.fromValue(properties.get(structure.get("id").asText()).asText())); - } else if (rdaProperty.contains("title")) { - rda.setTitle(properties.get(structure.get("id").asText()).asText()); - } else if (rdaProperty.contains("url")) { - rda.setUrl(URI.create(properties.get(structure.get("id").asText()).asText())); + for (JsonNode node: nodes) { + String rdaProperty = node.get("rdaProperties").asText(); + if (rdaProperty.contains("host")) { + int firstDiff = MyStringUtils.getFirstDifference(numbering, node.get("numbering").asText()); + if (firstDiff == -1 || firstDiff > 2) { + String rdaValue = node.get("value").asText(); + for (PropertyName propertyName: PropertyName.values()) { + if (rdaProperty.contains(propertyName.getName())) { + switch (propertyName) { + case AVAILABILITY: + rda.setAvailability(rdaValue); + break; + case BACKUP_FREQUENCY: + rda.setBackupFrequency(rdaValue); + break; + case BACKUP_TYPE: + rda.setBackupType(rdaValue); + break; + case CERTIFIED_WITH: + rda.setCertifiedWith(Host.CertifiedWith.fromValue(rdaValue)); + break; + case DESCRIPTION: + rda.setDescription(rdaValue); + break; + case GEO_LOCATION: + rda.setGeoLocation(Host.GeoLocation.fromValue(rdaValue)); + break; + case PID_SYSTEM: + rda.setPidSystem(Collections.singletonList(PidSystem.fromValue(rdaValue))); + break; + case STORAGE_TYPE: + rda.setStorageType(rdaValue); + break; + case SUPPORT_VERSIONING: + rda.setSupportVersioning(Host.SupportVersioning.fromValue(rdaValue)); + break; + case TITLE: + rda.setTitle(rdaValue); + break; + case URL: + rda.setUrl(URI.create(rdaValue)); + break; + } + } + } + } + } } return rda; } + + private enum PropertyName { + AVAILABILITY("availability"), + BACKUP_FREQUENCY("backup_frequency"), + BACKUP_TYPE("backup_type"), + CERTIFIED_WITH("certified_with"), + DESCRIPTION("description"), + GEO_LOCATION("geo_location"), + PID_SYSTEM("pid_system"), + STORAGE_TYPE("storage_type"), + SUPPORT_VERSIONING("support_versioning"), + TITLE("title"), + URL("url"); + + private final String name; + + PropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java index 68817bd3d..6f94a73c4 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java @@ -7,10 +7,10 @@ import java.net.URI; public class LicenseRDAMapper { - public static License toRDA(JsonNode structure, JsonNode properties) { + public static License toRDA(JsonNode node) { License rda = new License(); - String rdaProperty = structure.get("rdaProperty").asText(); - String value = properties.get(structure.get("id").asText()).asText(); + String rdaProperty = node.get("rdaProperty").asText(); + String value = node.get("value").asText(); if (rdaProperty.contains("license_ref")) { rda.setLicenseRef(URI.create(value)); diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java index fa638d3e3..c7e3ba35f 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java @@ -2,43 +2,124 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.TextNode; +import eu.eudat.logic.utilities.helpers.MyStringUtils; import eu.eudat.models.rda.Metadatum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.IOException; -import java.util.Iterator; +import java.util.*; public class MetadataRDAMapper { private static final Logger logger = LoggerFactory.getLogger(MetadataRDAMapper.class); - public static Metadatum toRDA(JsonNode structure, JsonNode properties) { - Metadatum rda = new Metadatum(); - JsonNode dataNode = null; - String rdaProperty = structure.get("rdaProperty").asText(); - if (rdaProperty.contains("metadata_standard_id")) { - try { - String jsonText = properties.get(structure.get("id").asText()).asText(); - if (jsonText != null && !jsonText.isEmpty()) { - dataNode = new ObjectMapper().readTree(jsonText); - for (Iterator it = dataNode.elements(); it.hasNext(); ) { - JsonNode data = it.next(); - if (data.get("uri") != null) { - rda.setMetadataStandardId(MetadataStandardIdRDAMapper.toRDA(data.get("uri").asText())); - } + public static List toRDAList(List nodes) { + Map rdaMap = new HashMap<>(); + List rdas = new ArrayList<>(); + for (JsonNode node: nodes) { + String rdaProperty = node.get("rdaProperty").asText(); + JsonNode rdaValue = node.get("value"); + + for (PropertyName propertyName: PropertyName.values()) { + if (rdaProperty.contains(propertyName.getName())) { + switch (propertyName) { + case METADATA_STANDARD_ID: + if (rdaValue instanceof ArrayNode) { + try { + ObjectMapper mapper = new ObjectMapper(); + for (Iterator it = rdaValue.elements(); it.hasNext(); ) { + JsonNode data = null; + data = mapper.readTree(it.next().asText()); + if (data.get("uri") != null) { + rdas.add(new Metadatum()); + rdas.get(rdas.size() - 1).setMetadataStandardId(MetadataStandardIdRDAMapper.toRDA(data.get("uri").asText())); + rdas.get(rdas.size() - 1).setDescription(data.get("label").asText()); + rdaMap.put(data.get("uri").asText(), node.get("numbering").asText()); + } + } + } catch (IOException e) { + logger.error(e.getMessage(), e); + } + } else if (rdaValue instanceof TextNode && rdaProperty.contains("identifier") && !rdaValue.asText().isEmpty()) { + rdas.add(new Metadatum()); + rdas.get(rdas.size() - 1).setMetadataStandardId(MetadataStandardIdRDAMapper.toRDA(rdaValue.asText())); + rdaMap.put(rdaValue.asText(), node.get("numbering").asText()); + } + break; + case DESCRIPTION: + if (!rdaValue.asText().isEmpty()) { + Metadatum rda = getRelative(rdas, rdaMap, node.get("numbering").asText()); + if (rda != null) { + rda.setDescription(rdaValue.asText()); + } else { + rdas.stream().filter(rda1 -> rda1.getDescription() == null || rda1.getDescription().isEmpty()).forEach(rda1 -> rda1.setDescription(rdaValue.asText())); + } + } + break; + case LANGUAGE: + String language = rdaValue.asText(); + Metadatum.Language lang = Metadatum.Language.fromValue(language); + Metadatum rda = getRelative(rdas, rdaMap, node.get("numbering").asText()); + if (rda != null) { + rda.setLanguage(lang); + } else { + rdas.forEach(rda1 -> rda1.setLanguage(lang)); + } + break; + } + } + } + + } + + return rdas; + } + + public static Metadatum toRDA(JsonNode node) { + Metadatum rda = new Metadatum(); + String rdaProperty = node.get("rdaProperty").asText(); + JsonNode rdaValue = node.get("value"); + if (rdaProperty.contains("metadata_standard_id")) { + if (rdaValue instanceof ArrayNode) { + for (Iterator it = rdaValue.elements(); it.hasNext(); ) { + JsonNode data = it.next(); + if (data.get("uri") != null) { + rda.setMetadataStandardId(MetadataStandardIdRDAMapper.toRDA(data.get("uri").asText())); } } - } catch (IOException e) { - logger.error(e.getMessage(), e); } } else if (rdaProperty.contains("description")) { - rda.setDescription(properties.get(structure.get("id").asText()).asText()); + rda.setDescription(rdaValue.asText()); } else if (rdaProperty.contains("language")) { - String language = properties.get(structure.get("id").asText()).asText(); + String language = rdaValue.asText(); Metadatum.Language lang = Metadatum.Language.fromValue(language); rda.setLanguage(lang); } return rda; } + + private static Metadatum getRelative(List rdas, Map rdaMap, String numbering) { + String target = rdaMap.entrySet().stream().filter(entry -> MyStringUtils.getFirstDifference(entry.getValue(), numbering) > 0) + .max(Comparator.comparingInt(entry -> MyStringUtils.getFirstDifference(entry.getValue(), numbering))).map(Map.Entry::getKey).orElse(""); + return rdas.stream().filter(rda -> rda.getMetadataStandardId().getIdentifier().equals(target)).distinct().findFirst().orElse(null); + } + + private enum PropertyName { + METADATA_STANDARD_ID("metadata_standard_id"), + DESCRIPTION("description"), + LANGUAGE("language"); + + private final String name; + + PropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java index f7f95633f..fc44cc182 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java @@ -1,14 +1,45 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.logic.utilities.helpers.MyStringUtils; import eu.eudat.models.rda.SecurityAndPrivacy; +import java.util.*; + public class SecurityAndPrivacyRDAMapper { - public static SecurityAndPrivacy toRDA(JsonNode structure, JsonNode properties) { + public static List toRDAList(List nodes) { + Map rdaMap = new HashMap<>(); + + for (JsonNode node: nodes) { + String rdaProperty = node.get("rdaProperty").asText(); + String rdaValue = node.get("value").asText(); + + SecurityAndPrivacy rda = getRelative(rdaMap, node.get("numbering").asText()); + if (!rdaMap.containsValue(rda)) { + rdaMap.put(node.get("numbering").asText(), rda); + } + for (PropertyName propertyName: PropertyName.values()) { + if (rdaProperty.contains(propertyName.getName())) { + switch (propertyName) { + case TITLE: + rda.setTitle(rdaValue); + break; + case DESCRIPTION: + rda.setDescription(rdaValue); + break; + } + } + } + } + + return new ArrayList<>(rdaMap.values()); + } + + public static SecurityAndPrivacy toRDA(JsonNode node) { SecurityAndPrivacy rda = new SecurityAndPrivacy(); - String rdaProperty = structure.get("rdaProperty").asText(); - String value = properties.get(structure.get("id").asText()).asText(); + String rdaProperty = node.get("rdaProperty").asText(); + String value =node.get("value").asText(); if (rdaProperty.contains("description")) { rda.setDescription(value); @@ -18,4 +49,24 @@ public class SecurityAndPrivacyRDAMapper { return rda; } + + private static SecurityAndPrivacy getRelative(Map rdaMap, String numbering) { + return rdaMap.entrySet().stream().filter(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering) > 0) + .max(Comparator.comparingInt(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering))).map(Map.Entry::getValue).orElse(new SecurityAndPrivacy()); + } + + private enum PropertyName { + TITLE("title"), + DESCRIPTION("description"); + + private String name; + + PropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java index b2652901a..c48f93cae 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java @@ -1,14 +1,46 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.logic.utilities.helpers.MyStringUtils; +import eu.eudat.models.rda.SecurityAndPrivacy; import eu.eudat.models.rda.TechnicalResource; +import java.util.*; + public class TechnicalResourceRDAMapper { - public static TechnicalResource toRDA(JsonNode structure, JsonNode properties) { + public static List toRDAList(List nodes) { + Map rdaMap = new HashMap<>(); + + for (JsonNode node: nodes) { + String rdaProperty = node.get("rdaProperty").asText(); + String rdaValue = node.get("value").asText(); + + TechnicalResource rda = getRelative(rdaMap, node.get("numbering").asText()); + if (!rdaMap.containsValue(rda)) { + rdaMap.put(node.get("numbering").asText(), rda); + } + for (PropertyName propertyName: PropertyName.values()) { + if (rdaProperty.contains(propertyName.getName())) { + switch (propertyName) { + case NAME: + rda.setName(rdaValue); + break; + case DESCRIPTION: + rda.setDescription(rdaValue); + break; + } + } + } + } + + return new ArrayList<>(rdaMap.values()); + } + + public static TechnicalResource toRDA(JsonNode node) { TechnicalResource rda = new TechnicalResource(); - String rdaProperty = structure.get("rdaProperty").asText(); - String value = properties.get(structure.get("id").asText()).asText(); + String rdaProperty = node.get("rdaProperty").asText(); + String value = node.get("value").asText(); if (rdaProperty.contains("description")) { rda.setDescription(value); @@ -18,4 +50,24 @@ public class TechnicalResourceRDAMapper { return rda; } + + private static TechnicalResource getRelative(Map rdaMap, String numbering) { + return rdaMap.entrySet().stream().filter(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering) > 0) + .max(Comparator.comparingInt(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering))).map(Map.Entry::getValue).orElse(new TechnicalResource()); + } + + private enum PropertyName { + NAME("name"), + DESCRIPTION("description"); + + private String name; + + PropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + } } diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description-form.model.ts b/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description-form.model.ts index c4b8153b8..fd8824ba3 100644 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description-form.model.ts +++ b/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description-form.model.ts @@ -338,4 +338,4 @@ export class DatasetDescriptionDefaultValueEditorModel extends BaseFormModel { }); return formGroup; } -} \ No newline at end of file +} From 926946018936104f9948e41eec93dbc6e9ae7dc4 Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Tue, 24 Mar 2020 11:26:17 +0200 Subject: [PATCH 03/20] Minor bug fixes on the exporter --- .../src/main/java/eu/eudat/logic/managers/RDAManager.java | 2 +- .../java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java index eb10fd753..3a9f2f7a8 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java @@ -29,7 +29,7 @@ public class RDAManager { Dmp rdaDmp = dmpRDAMapper.toRDA(dmp); ObjectMapper mapper = new ObjectMapper(); - mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")); + mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss Z")); result = mapper.writeValueAsString(rdaDmp); diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java index 5eb9cc685..da04fe043 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java @@ -32,6 +32,7 @@ public class DatasetRDAMapper { rda.setDatasetId(DatasetIdRDAMapper.toRDA(dataset.getId())); rda.setTitle(dataset.getLabel()); rda.setDescription(dataset.getDescription()); +// rda.setAdditionalProperty("template", dataset.getProfile().getId()); try { DatasetWizardModel datasetWizardModel = new DatasetWizardModel().fromDataModel(dataset); @@ -57,7 +58,7 @@ public class DatasetRDAMapper { } List preservationNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.preservation_statement"); if (!preservationNodes.isEmpty()) { - rda.setDataQualityAssurance(preservationNodes.stream().map(preservationNode -> preservationNode.get("value").asText()).collect(Collectors.toList())); + rda.setPreservationStatement(preservationNodes.get(0).get("value").asText()); } List distributionNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.distribution"); if (!distributionNodes.isEmpty()) { @@ -77,7 +78,7 @@ public class DatasetRDAMapper { } List sensitiveDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.sensitive_data"); if (!sensitiveDataNodes.isEmpty()) { - rda.setSensitiveData(securityAndPrivacyNodes.stream().map(sensitiveDataNode -> Dataset.SensitiveData.fromValue(sensitiveDataNode.get("value").asText())).findFirst().get()); + rda.setSensitiveData(sensitiveDataNodes.stream().map(sensitiveDataNode -> Dataset.SensitiveData.fromValue(sensitiveDataNode.get("value").asText())).findFirst().get()); } List technicalResourceNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.technical_resource"); if (!technicalResourceNodes.isEmpty()) { From a283bd47cfc3f7ab1aa737d469c4f9f3d61ad104 Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Thu, 26 Mar 2020 18:39:25 +0200 Subject: [PATCH 04/20] Add RDA Import --- .../main/java/eu/eudat/controllers/DMPs.java | 11 +- .../managers/DataManagementPlanManager.java | 35 ++++++ .../eu/eudat/logic/managers/RDAManager.java | 9 ++ .../java/eu/eudat/models/rda/Dataset.java | 9 +- .../eu/eudat/models/rda/Distribution.java | 9 +- .../main/java/eu/eudat/models/rda/Dmp.java | 9 +- .../java/eu/eudat/models/rda/Metadatum.java | 9 +- .../eudat/models/rda/SecurityAndPrivacy.java | 9 +- .../eudat/models/rda/TechnicalResource.java | 9 +- .../models/rda/mapper/ContactIdRDAMapper.java | 4 + .../models/rda/mapper/ContactRDAMapper.java | 8 ++ .../models/rda/mapper/DatasetRDAMapper.java | 112 +++++++++++++++++- .../rda/mapper/DistributionRDAMapper.java | 97 ++++++++++++++- .../eudat/models/rda/mapper/DmpRDAMapper.java | 36 ++++-- .../models/rda/mapper/FundingRDAMapper.java | 9 +- .../models/rda/mapper/MetadataRDAMapper.java | 66 +++++++++++ .../models/rda/mapper/ProjectRDAMapper.java | 22 +++- .../mapper/SecurityAndPrivacyRDAMapper.java | 60 +++++++++- .../mapper/TechnicalResourceRDAMapper.java | 62 +++++++++- .../dmp-upload-dialogue.component.html | 2 +- 20 files changed, 531 insertions(+), 56 deletions(-) diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java index c87ce4590..0e25b98f6 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java @@ -53,6 +53,9 @@ import java.util.List; import java.util.Map; import java.util.UUID; +import static org.springframework.http.MediaType.APPLICATION_ATOM_XML; +import static org.springframework.http.MediaType.APPLICATION_JSON; + @RestController @CrossOrigin @@ -224,8 +227,12 @@ public class DMPs extends BaseController { } @RequestMapping(method = RequestMethod.POST, value = {"/upload"}) - public ResponseEntity dmpXmlUpload(@RequestParam("file") MultipartFile[] files, Principal principal) throws Exception { - this.dataManagementPlanManager.createDmpFromXml(this.getApiContext(), files, principal); + public ResponseEntity dmpUpload(@RequestParam("file") MultipartFile[] files, Principal principal) throws Exception { + if (files[0].getContentType().equals(APPLICATION_JSON.toString())) { + this.dataManagementPlanManager.createFromRDA(files, principal); + } else if (files[0].getContentType().equals(APPLICATION_ATOM_XML.toString())) { + this.dataManagementPlanManager.createDmpFromXml(this.getApiContext(), files, principal); + } return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem() .status(ApiMessageCode.SUCCESS_MESSAGE)); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java index 2710ec60c..c8dee4802 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java @@ -131,6 +131,13 @@ public class DataManagementPlanManager { if (fieldsGroup.equals("listing")) { itemsFuture = pagedItems.withHint(HintedModelFactory.getHint(DataManagementPlanListingModel.class)) .selectAsync(item -> { + if (item.getUsers().stream().noneMatch(userDMP -> userDMP.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue()))) { + for (UserDMP userDMP: item.getUsers()) { + userDMP.setRole(UserDMP.UserDMPRoles.OWNER.getValue()); + databaseRepository.getUserDmpDao().createOrUpdate(userDMP); + break; + } + } item.setDataset( item.getDataset().stream() .filter(dataset -> !dataset.getStatus().equals(Dataset.Status.DELETED.getValue()) && !dataset.getStatus().equals(Dataset.Status.CANCELED.getValue())).collect(Collectors.toList()).stream() @@ -1329,6 +1336,34 @@ public class DataManagementPlanManager { return dataManagementPlans; } + public List createFromRDA(MultipartFile[] files, Principal principal) throws IOException { + if (principal.getId() == null) { + throw new UnauthorisedException("No user is logged in"); + } + List result = new ArrayList<>(); + for (MultipartFile file: files) { + DMP dmp = rdaManager.convertToEntity(new String(file.getBytes(), "UTF-8")); + UserInfo me = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId()); + dmp.setModified(new Date()); + dmp.setCreator(me); + dmp.setVersion(0); + dmp.setStatus((short)0); + dmp.setGroupId(UUID.randomUUID()); + databaseRepository.getDmpDao().createOrUpdate(dmp); + assignUser(dmp, me); + dmp.getDataset().forEach(dataset -> { + dataset.setStatus(Dataset.Status.SAVED.getValue()); + dataset.setCreated(new Date()); + dataset.setModified(new Date()); + dataset.setDmp(dmp); + databaseRepository.getDatasetDao().createOrUpdate(dataset); + }); + result.add(dmp); + } + + return result; + } + public DataTableData getDatasetProfilesUsedByDMP(DatasetProfileTableRequestItem datasetProfileTableRequestItem, Principal principal) { datasetProfileTableRequestItem.getCriteria().setFilter(DatasetProfileCriteria.DatasetProfileFilter.DMPs.getValue()); datasetProfileTableRequestItem.getCriteria().setUserId(principal.getId()); diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java index 3a9f2f7a8..ff194455e 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java @@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import javax.transaction.Transactional; +import java.io.IOException; import java.text.SimpleDateFormat; @Component @@ -35,4 +36,12 @@ public class RDAManager { return result; } + + public DMP convertToEntity(String json) throws IOException { + ObjectMapper mapper = new ObjectMapper(); + mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss Z")); + + Dmp rda = mapper.readValue(json, Dmp.class); + return dmpRDAMapper.toEntity(rda); + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java index 43a7ac0cd..3c064965e 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java @@ -38,7 +38,8 @@ import com.fasterxml.jackson.annotation.JsonValue; "sensitive_data", "technical_resource", "title", - "type" + "type", + "additional_properties" }) public class Dataset implements Serializable { @@ -182,7 +183,7 @@ public class Dataset implements Serializable @JsonProperty("type") @JsonPropertyDescription("If appropriate, type according to: DataCite and/or COAR dictionary. Otherwise use the common name for the type, e.g. raw data, software, survey, etc. https://schema.datacite.org/meta/kernel-4.1/doc/DataCite-MetadataKernel_v4.1.pdf http://vocabularies.coar-repositories.org/pubby/resource_type.html") private String type; - @JsonIgnore + @JsonProperty("additional_properties") private Map additionalProperties = new HashMap(); private final static long serialVersionUID = -6931119120629009399L; @@ -524,12 +525,12 @@ public class Dataset implements Serializable this.type = type; } - @JsonAnyGetter + @JsonProperty("additional_properties") public Map getAdditionalProperties() { return this.additionalProperties; } - @JsonAnySetter + @JsonProperty("additional_properties") public void setAdditionalProperty(String name, Object value) { this.additionalProperties.put(name, value); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java index d005e7564..176931e9e 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java @@ -34,7 +34,8 @@ import com.fasterxml.jackson.annotation.JsonValue; "format", "host", "license", - "title" + "title", + "additional_properties" }) public class Distribution implements Serializable { @@ -131,7 +132,7 @@ public class Distribution implements Serializable @JsonProperty("title") @JsonPropertyDescription("Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file.") private String title; - @JsonIgnore + @JsonProperty("additional_properties") private Map additionalProperties = new HashMap(); private final static long serialVersionUID = -6018365280419917902L; @@ -359,12 +360,12 @@ public class Distribution implements Serializable this.title = title; } - @JsonAnyGetter + @JsonProperty("additional_properties") public Map getAdditionalProperties() { return this.additionalProperties; } - @JsonAnySetter + @JsonProperty("additional_properties") public void setAdditionalProperty(String name, Object value) { this.additionalProperties.put(name, value); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java index 7cac25d62..b53d26147 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java @@ -39,7 +39,8 @@ import com.fasterxml.jackson.annotation.JsonValue; "language", "modified", "project", - "title" + "title", + "additional_properties" }) public class Dmp implements Serializable { @@ -173,7 +174,7 @@ public class Dmp implements Serializable @JsonProperty("title") @JsonPropertyDescription("Title of a DMP") private String title; - @JsonIgnore + @JsonProperty("additional_properties") private Map additionalProperties = new HashMap(); private final static long serialVersionUID = 4599713332472772292L; @@ -499,12 +500,12 @@ public class Dmp implements Serializable this.title = title; } - @JsonAnyGetter + @JsonProperty("additional_properties") public Map getAdditionalProperties() { return this.additionalProperties; } - @JsonAnySetter + @JsonProperty("additional_properties") public void setAdditionalProperty(String name, Object value) { this.additionalProperties.put(name, value); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java index d6057ca62..56bee437d 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java @@ -25,7 +25,8 @@ import com.fasterxml.jackson.annotation.JsonValue; @JsonPropertyOrder({ "description", "language", - "metadata_standard_id" + "metadata_standard_id", + "additional_properties" }) public class Metadatum implements Serializable { @@ -58,7 +59,7 @@ public class Metadatum implements Serializable */ @JsonProperty("metadata_standard_id") private MetadataStandardId metadataStandardId; - @JsonIgnore + @JsonProperty("additional_properties") private Map additionalProperties = new HashMap(); private final static long serialVersionUID = 6511312853153406190L; @@ -132,12 +133,12 @@ public class Metadatum implements Serializable this.metadataStandardId = metadataStandardId; } - @JsonAnyGetter + @JsonProperty("additional_properties") public Map getAdditionalProperties() { return this.additionalProperties; } - @JsonAnySetter + @JsonProperty("additional_properties") public void setAdditionalProperty(String name, Object value) { this.additionalProperties.put(name, value); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java index 0486df588..245d202d0 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java @@ -22,7 +22,8 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonPropertyOrder({ "description", - "title" + "title", + "additional_properties" }) public class SecurityAndPrivacy implements Serializable { @@ -46,7 +47,7 @@ public class SecurityAndPrivacy implements Serializable @JsonProperty("title") @JsonPropertyDescription("Title") private String title; - @JsonIgnore + @JsonProperty("additional_properties") private Map additionalProperties = new HashMap(); private final static long serialVersionUID = 7863747935827682977L; @@ -96,12 +97,12 @@ public class SecurityAndPrivacy implements Serializable this.title = title; } - @JsonAnyGetter + @JsonProperty("additional_properties") public Map getAdditionalProperties() { return this.additionalProperties; } - @JsonAnySetter + @JsonProperty("additional_properties") public void setAdditionalProperty(String name, Object value) { this.additionalProperties.put(name, value); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java index eac85da72..c7bd2b055 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java @@ -22,7 +22,8 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonPropertyOrder({ "description", - "name" + "name", + "additional_properties" }) public class TechnicalResource implements Serializable { @@ -46,7 +47,7 @@ public class TechnicalResource implements Serializable @JsonProperty("name") @JsonPropertyDescription("Name of the technical resource") private String name; - @JsonIgnore + @JsonProperty("additional_properties") private Map additionalProperties = new HashMap(); private final static long serialVersionUID = -7451757227129483110L; @@ -96,12 +97,12 @@ public class TechnicalResource implements Serializable this.name = name; } - @JsonAnyGetter + @JsonProperty("additional_properties") public Map getAdditionalProperties() { return this.additionalProperties; } - @JsonAnySetter + @JsonProperty("additional_properties") public void setAdditionalProperty(String name, Object value) { this.additionalProperties.put(name, value); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java index 48549d75a..c9eac2009 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java @@ -12,4 +12,8 @@ public class ContactIdRDAMapper { rda.setType(ContactId.Type.OTHER); return rda; } + + public static UUID toEntity(ContactId rda) { + return UUID.fromString(rda.getIdentifier()); + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java index 69ea2310e..957fef8d4 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java @@ -13,4 +13,12 @@ public class ContactRDAMapper { rda.setContactId(ContactIdRDAMapper.toRDA(creator.getId())); return rda; } + + public static UserInfo toEntity(Contact rda) { + UserInfo entity = new UserInfo(); + entity.setId(ContactIdRDAMapper.toEntity(rda.getContactId())); + entity.setName(rda.getName()); + entity.setEmail(rda.getMbox()); + return entity; + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java index da04fe043..90aa4ec7c 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java @@ -2,28 +2,34 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import eu.eudat.data.entities.DatasetProfile; import eu.eudat.logic.managers.DatasetManager; +import eu.eudat.logic.services.ApiContext; import eu.eudat.logic.utilities.json.JsonSearcher; import eu.eudat.models.data.datasetwizard.DatasetWizardModel; import eu.eudat.models.rda.Dataset; +import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import javax.transaction.Transactional; -import java.util.List; +import java.util.*; import java.util.stream.Collectors; +import java.util.stream.Stream; @Component public class DatasetRDAMapper { private static final Logger logger = LoggerFactory.getLogger(DatasetRDAMapper.class); private DatasetManager datasetManager; + private ApiContext apiContext; @Autowired - public DatasetRDAMapper(DatasetManager datasetManager) { + public DatasetRDAMapper(DatasetManager datasetManager, ApiContext apiContext) { this.datasetManager = datasetManager; + this.apiContext = apiContext; } @Transactional @@ -32,9 +38,10 @@ public class DatasetRDAMapper { rda.setDatasetId(DatasetIdRDAMapper.toRDA(dataset.getId())); rda.setTitle(dataset.getLabel()); rda.setDescription(dataset.getDescription()); -// rda.setAdditionalProperty("template", dataset.getProfile().getId()); + rda.setAdditionalProperty("template", dataset.getProfile().getId()); try { - + JSONObject jObject = new JSONObject(dataset.getProperties()); + Map templateIdsToValues = jObject.toMap(); DatasetWizardModel datasetWizardModel = new DatasetWizardModel().fromDataModel(dataset); datasetWizardModel.setDatasetProfileDefinition(datasetManager.getPagedProfile(datasetWizardModel, dataset)); ObjectMapper mapper = new ObjectMapper(); @@ -55,6 +62,9 @@ public class DatasetRDAMapper { List qaNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.data_quality_assurance"); if (!qaNodes.isEmpty()) { rda.setDataQualityAssurance(qaNodes.stream().map(qaNode -> qaNode.get("value").asText()).collect(Collectors.toList())); + for (int i = 0; i < qaNodes.size(); i++) { + rda.setAdditionalProperty("qa" + (i + 1), qaNodes.get(i).get("id").asText()); + } } List preservationNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.preservation_statement"); if (!preservationNodes.isEmpty()) { @@ -67,6 +77,9 @@ public class DatasetRDAMapper { List keywordNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.keyword"); if (!keywordNodes.isEmpty()) { rda.setKeyword(keywordNodes.stream().map(keywordNode -> keywordNode.get("value").asText()).collect(Collectors.toList())); + for (int i = 0; i < keywordNodes.size(); i++) { + rda.setAdditionalProperty("keyword" + (i + 1), keywordNodes.get(i).get("id").asText()); + } } List personalDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.personal_data"); if (!personalDataNodes.isEmpty()) { @@ -84,6 +97,14 @@ public class DatasetRDAMapper { if (!technicalResourceNodes.isEmpty()) { rda.setTechnicalResource(TechnicalResourceRDAMapper.toRDAList(technicalResourceNodes)); } + List foundNodes = Stream.of(typeNodes, languageNodes, metadataNodes, qaNodes, preservationNodes, distributionNodes, + keywordNodes, personalDataNodes, securityAndPrivacyNodes, sensitiveDataNodes, technicalResourceNodes).flatMap(Collection::stream).collect(Collectors.toList()); + templateIdsToValues.entrySet().forEach(entry -> { + boolean isFound = foundNodes.stream().anyMatch(node -> node.get("id").asText().equals(entry.getKey())); + if (!isFound && entry.getValue() != null && !entry.getValue().toString().isEmpty()) { + rda.setAdditionalProperty(entry.getKey(), entry.getValue()); + } + }); } catch (Exception e) { @@ -93,4 +114,87 @@ public class DatasetRDAMapper { return rda; } + + + public eu.eudat.data.entities.Dataset toEntity(Dataset rda) { + eu.eudat.data.entities.Dataset entity = new eu.eudat.data.entities.Dataset(); + entity.setLabel(rda.getTitle()); + entity.setDescription(rda.getDescription()); + try { + DatasetProfile profile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(rda.getAdditionalProperties().get("template").toString())); + entity.setProfile(profile); + }catch(Exception e) { + logger.warn(e.getMessage(), e); + } + try { + Map properties = new HashMap<>(); + DatasetWizardModel datasetWizardModel = new DatasetWizardModel(); + datasetWizardModel.setProfile(entity.getProfile().getId()); + datasetWizardModel.setDatasetProfileDefinition(datasetManager.getPagedProfile(datasetWizardModel, entity)); + ObjectMapper mapper = new ObjectMapper(); + String datasetDescriptionJson = mapper.writeValueAsString(datasetWizardModel.getDatasetProfileDefinition()); + JsonNode datasetDescriptionObj = mapper.readTree(datasetDescriptionJson); + + List typeNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.type"); + if (!typeNodes.isEmpty()) { + properties.put(typeNodes.get(0).get("id").asText(), rda.getType()); + } + + List languageNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.language"); + if (!languageNodes.isEmpty()) { + properties.put(languageNodes.get(0).get("id").asText(), rda.getLanguage().value()); + } + + if (rda.getMetadata() != null) { + properties.putAll(MetadataRDAMapper.toProperties(rda.getMetadata())); + } + + List qaIds = rda.getAdditionalProperties().entrySet().stream().filter(entry -> entry.getKey().startsWith("qa")).map(entry -> entry.getValue().toString()).collect(Collectors.toList()); + for (int i = 0; i < qaIds.size(); i++) { + properties.put(qaIds.get(i), rda.getDataQualityAssurance().get(i)); + } + + List preservationNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.preservation_statement"); + if (!preservationNodes.isEmpty()) { + properties.put(preservationNodes.get(0).get("id").asText(), rda.getPreservationStatement()); + } + + if (rda.getDistribution() != null) { + properties.putAll(DistributionRDAMapper.toProperties(rda.getDistribution())); + } + + List keywordIds = rda.getAdditionalProperties().entrySet().stream().filter(entry -> entry.getKey().startsWith("keyword")).map(entry -> entry.getValue().toString()).collect(Collectors.toList()); + for (int i = 0; i < keywordIds.size(); i++) { + properties.put(keywordIds.get(i), rda.getKeyword().get(i)); + } + + List personalDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.personal_data"); + if (!personalDataNodes.isEmpty()) { + properties.put(personalDataNodes.get(0).get("id").asText(), rda.getPersonalData().value()); + } + + if (rda.getSecurityAndPrivacy() != null) { + properties.putAll(SecurityAndPrivacyRDAMapper.toProperties(rda.getSecurityAndPrivacy())); + } + + List sensitiveDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.sensitive_data"); + if (!sensitiveDataNodes.isEmpty()) { + properties.put(sensitiveDataNodes.get(0).get("id").asText(), rda.getSensitiveData().value()); + } + + if (rda.getTechnicalResource() != null) { + properties.putAll(TechnicalResourceRDAMapper.toProperties(rda.getTechnicalResource())); + } + + rda.getAdditionalProperties().entrySet().stream() + .filter(entry -> !entry.getKey().equals("template") && !entry.getKey().startsWith("qa") && !entry.getKey().startsWith("keyword")) + .forEach(entry -> properties.put(entry.getKey(), entry.getValue())); + entity.setProperties(new ObjectMapper().writeValueAsString(properties)); + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + + + return entity; + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java index 98cb6960b..566288452 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java @@ -1,13 +1,17 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; +import com.lowagie.text.ExceptionConverter; import eu.eudat.logic.utilities.helpers.MyStringUtils; import eu.eudat.models.rda.Distribution; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.net.URI; import java.util.*; public class DistributionRDAMapper { + private static final Logger logger = LoggerFactory.getLogger(DistributionRDAMapper.class); public static List toRDAList(List nodes) { Map rdaMap = new HashMap<>(); @@ -19,35 +23,43 @@ public class DistributionRDAMapper { if (!rdaMap.containsValue(rda)) { rdaMap.put(node.get("numbering").asText(), rda); } - for (PropertyName propertyName : PropertyName.values()) { - if (rdaProperty.contains(propertyName.getName())) { - switch (propertyName) { + for (ExportPropertyName exportPropertyName : ExportPropertyName.values()) { + if (rdaProperty.contains(exportPropertyName.getName())) { + switch (exportPropertyName) { case ACCESS_URL: rda.setAccessUrl(rdaValue); + rda.setAdditionalProperty(ImportPropertyName.ACCESS_URL.getName(), node.get("id").asText()); break; case AVAILABLE_UTIL: rda.setAvailableUntil(rdaValue); + rda.setAdditionalProperty(ImportPropertyName.AVAILABLE_UTIL.getName(), node.get("id").asText()); break; case DOWNLOAD_URL: rda.setDownloadUrl(URI.create(rdaValue)); + rda.setAdditionalProperty(ImportPropertyName.DOWNLOAD_URL.getName(), node.get("id").asText()); break; case DESCRIPTION: rda.setDescription(rdaValue); + rda.setAdditionalProperty(ImportPropertyName.DESCRIPTION.getName(), node.get("id").asText()); break; case DATA_ACCESS: rda.setDataAccess(Distribution.DataAccess.fromValue(rdaValue)); + rda.setAdditionalProperty(ImportPropertyName.DATA_ACCESS.getName(), node.get("id").asText()); break; case BYTE_SIZE: rda.setByteSize(Integer.parseInt(rdaValue)); + rda.setAdditionalProperty(ImportPropertyName.BYTE_SIZE.getName(), node.get("id").asText()); break; case LICENSE: rda.setLicense(Collections.singletonList(LicenseRDAMapper.toRDA(node))); break; case FORMAT: rda.setFormat(Collections.singletonList(rdaValue)); + rda.setAdditionalProperty(ImportPropertyName.FORMAT.getName(), node.get("id").asText()); break; case TITLE: rda.setTitle(rdaValue); + rda.setAdditionalProperty(ImportPropertyName.TITLE.getName(), node.get("id").asText()); break; case HOST: rda.setHost(HostRDAMapper.toRDA(nodes, node.get("numbering").asText())); @@ -60,6 +72,49 @@ public class DistributionRDAMapper { return new ArrayList<>(rdaMap.values()); } + public static Map toProperties(List rdas) { + Map properties = new HashMap<>(); + + rdas.forEach(rda -> { + rda.getAdditionalProperties().entrySet().forEach(entry -> { + try { + ImportPropertyName importPropertyName = ImportPropertyName.fromString(entry.getKey()); + switch (importPropertyName) { + case ACCESS_URL: + properties.put(entry.getValue().toString(), rda.getAccessUrl()); + break; + case TITLE: + properties.put(entry.getValue().toString(), rda.getTitle()); + break; + case DESCRIPTION: + properties.put(entry.getValue().toString(), rda.getDescription()); + break; + case FORMAT: + properties.put(entry.getValue().toString(), rda.getFormat().get(0)); + break; + case BYTE_SIZE: + properties.put(entry.getValue().toString(), rda.getByteSize().toString()); + break; + case DATA_ACCESS: + properties.put(entry.getValue().toString(), rda.getDataAccess().value()); + break; + case DOWNLOAD_URL: + properties.put(entry.getValue().toString(), rda.getDownloadUrl().toString()); + break; + case AVAILABLE_UTIL: + properties.put(entry.getValue().toString(), rda.getAvailableUntil()); + break; + } + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + + }); + }); + + return properties; + } + public static Distribution toRDA(JsonNode node) { Distribution rda = new Distribution(); String rdaProperty = node.get("rdaProperty").asText(); @@ -95,7 +150,7 @@ public class DistributionRDAMapper { .max(Comparator.comparingInt(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering))).map(Map.Entry::getValue).orElse(new Distribution()); } - private enum PropertyName { + private enum ExportPropertyName { ACCESS_URL("access_url"), AVAILABLE_UTIL("available_util"), BYTE_SIZE("byte_size"), @@ -109,7 +164,7 @@ public class DistributionRDAMapper { private final String name; - PropertyName(String name) { + ExportPropertyName(String name) { this.name = name; } @@ -117,4 +172,36 @@ public class DistributionRDAMapper { return name; } } + + private enum ImportPropertyName { + ACCESS_URL("accessurlId"), + AVAILABLE_UTIL("availableUtilId"), + BYTE_SIZE("byteSizeId"), + DATA_ACCESS("dataAccessId"), + DESCRIPTION("descriptionId"), + DOWNLOAD_URL("downloadUrlId"), + FORMAT("formatId"), + /*HOST("host"), + LICENSE("license"),*/ + TITLE("titleId"); + + private final String name; + + ImportPropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public static ImportPropertyName fromString(String name) throws Exception { + for (ImportPropertyName importPropertyName: ImportPropertyName.values()) { + if (importPropertyName.getName().equals(name)) { + return importPropertyName; + } + } + throw new Exception("No name available"); + } + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java index 620229a27..7176f3b8d 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java @@ -1,24 +1,26 @@ package eu.eudat.models.rda.mapper; -import eu.eudat.data.entities.DMP; -import eu.eudat.data.entities.UserDMP; -import eu.eudat.data.entities.UserInfo; +import eu.eudat.data.entities.*; +import eu.eudat.logic.services.ApiContext; import eu.eudat.models.rda.Dmp; +import eu.eudat.models.rda.DmpId; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import javax.transaction.Transactional; -import java.util.Collections; +import java.util.*; import java.util.stream.Collectors; @Component public class DmpRDAMapper { private DatasetRDAMapper datasetRDAMapper; + private ApiContext apiContext; @Autowired - public DmpRDAMapper(DatasetRDAMapper datasetRDAMapper) { + public DmpRDAMapper(DatasetRDAMapper datasetRDAMapper, ApiContext apiContext) { this.datasetRDAMapper = datasetRDAMapper; + this.apiContext = apiContext; } @Transactional @@ -44,8 +46,28 @@ public class DmpRDAMapper { rda.setContributor(dmp.getUsers().stream().map(ContributorRDAMapper::toRDA).collect(Collectors.toList())); rda.setDataset(dmp.getDataset().stream().map(dataset -> datasetRDAMapper.toRDA(dataset)).collect(Collectors.toList())); rda.setProject(Collections.singletonList(ProjectRDAMapper.toRDA(dmp.getProject(), dmp.getGrant()))); - - + rda.setAdditionalProperty("templates", dmp.getAssociatedDmps().stream().map(datasetProfile -> datasetProfile.getId().toString()).toArray()); return rda; } + + public DMP toEntity(Dmp rda) { + DMP entity = new DMP(); + entity.setLabel(rda.getTitle()); + if (rda.getDmpId().getType() == DmpId.Type.DOI) { + entity.setDoi(rda.getDmpId().getIdentifier()); + } + entity.setCreated(rda.getCreated()); + entity.setModified(rda.getModified()); + entity.setDescription(rda.getDescription()); + entity.setDataset(rda.getDataset().stream().map(rda1 -> datasetRDAMapper.toEntity(rda1)).collect(Collectors.toSet())); + Map result = ProjectRDAMapper.toEntity(rda.getProject().get(0), apiContext); + entity.setProject((Project) result.get("project")); + result.entrySet().stream().filter(entry -> entry.getKey().startsWith("grant")).forEach(entry -> entity.setGrant((Grant) entry.getValue())); + entity.setAssociatedDmps(((List) rda.getAdditionalProperties().get("templates")).stream().map(this::getProfile).collect(Collectors.toSet())); + return entity; + } + + private DatasetProfile getProfile(String id) { + return apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id)); + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java index e0b8fbe65..2dd3f6cc2 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java @@ -1,7 +1,8 @@ package eu.eudat.models.rda.mapper; -import eu.eudat.data.entities.Funder; +import eu.eudat.data.dao.criteria.GrantCriteria; import eu.eudat.data.entities.Grant; +import eu.eudat.logic.services.ApiContext; import eu.eudat.models.rda.Funding; public class FundingRDAMapper { @@ -22,4 +23,10 @@ public class FundingRDAMapper { rda.setGrantId(GrantIdRDAMapper.toRDA(shortReference)); return rda; } + + public static Grant toEntity(Funding rda, ApiContext apiContext) { + GrantCriteria criteria = new GrantCriteria(); + criteria.setReference(rda.getGrantId().getIdentifier()); + return apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().getWithCriteria(criteria).getSingle(); + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java index c7e3ba35f..49bbbb527 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java @@ -11,6 +11,7 @@ import org.slf4j.LoggerFactory; import java.io.IOException; import java.util.*; +import java.util.stream.Collectors; public class MetadataRDAMapper { private static final Logger logger = LoggerFactory.getLogger(MetadataRDAMapper.class); @@ -36,6 +37,7 @@ public class MetadataRDAMapper { rdas.add(new Metadatum()); rdas.get(rdas.size() - 1).setMetadataStandardId(MetadataStandardIdRDAMapper.toRDA(data.get("uri").asText())); rdas.get(rdas.size() - 1).setDescription(data.get("label").asText()); + rdas.get(rdas.size() - 1).setAdditionalProperty("fieldId", node.get("id").asText()); rdaMap.put(data.get("uri").asText(), node.get("numbering").asText()); } } @@ -45,6 +47,7 @@ public class MetadataRDAMapper { } else if (rdaValue instanceof TextNode && rdaProperty.contains("identifier") && !rdaValue.asText().isEmpty()) { rdas.add(new Metadatum()); rdas.get(rdas.size() - 1).setMetadataStandardId(MetadataStandardIdRDAMapper.toRDA(rdaValue.asText())); + rdas.get(rdas.size() - 1).setAdditionalProperty("identifierId", node.get("id").asText()); rdaMap.put(rdaValue.asText(), node.get("numbering").asText()); } break; @@ -53,6 +56,7 @@ public class MetadataRDAMapper { Metadatum rda = getRelative(rdas, rdaMap, node.get("numbering").asText()); if (rda != null) { rda.setDescription(rdaValue.asText()); + rda.setAdditionalProperty("descriptionId", node.get("id").asText()); } else { rdas.stream().filter(rda1 -> rda1.getDescription() == null || rda1.getDescription().isEmpty()).forEach(rda1 -> rda1.setDescription(rdaValue.asText())); } @@ -64,6 +68,7 @@ public class MetadataRDAMapper { Metadatum rda = getRelative(rdas, rdaMap, node.get("numbering").asText()); if (rda != null) { rda.setLanguage(lang); + rda.setAdditionalProperty("languageId", node.get("id").asText()); } else { rdas.forEach(rda1 -> rda1.setLanguage(lang)); } @@ -77,6 +82,40 @@ public class MetadataRDAMapper { return rdas; } + public static Map toProperties(List rdas) { + Map properties = new HashMap<>(); + List standardIds = new ArrayList<>(); + ObjectMapper mapper = new ObjectMapper(); + rdas.forEach(rda -> { + rda.getAdditionalProperties().entrySet().forEach(entry -> { + try { + switch (entry.getKey()) { + case "fieldId": + Map metadata = toMap(rda); + standardIds.add(metadata); + properties.put(entry.getValue().toString(), mapper.writeValueAsString(standardIds)); + break; + case "identifierId": + properties.put(entry.getValue().toString(), rda.getMetadataStandardId().getIdentifier()); + break; + case "descriptionId": + properties.put(entry.getValue().toString(), rda.getDescription()); + break; + case "languageId": + if (rda.getLanguage() != null) { + properties.put(entry.getValue().toString(), rda.getLanguage().value()); + } + break; + } + }catch (Exception e) { + logger.error(e.getMessage(), e); + } + }); + }); + + return properties; + } + public static Metadatum toRDA(JsonNode node) { Metadatum rda = new Metadatum(); String rdaProperty = node.get("rdaProperty").asText(); @@ -122,4 +161,31 @@ public class MetadataRDAMapper { return name; } } + + private static Map toMap(Metadatum rda) { + Map result = new HashMap<>(); + + ObjectMapper mapper = new ObjectMapper(); + + Map metadata = mapper.convertValue(rda, Map.class); + + Map metadataStandardId = mapper.convertValue(metadata.get("metadata_standard_id"), Map.class); + + String url = metadataStandardId.remove("identifier"); + metadataStandardId.remove("type"); + metadataStandardId.put("uri", url); + + metadata.remove("additional_properties"); + metadata.remove("metadata_standard_id"); + + Map newMetadata = metadata.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue().toString())); + + String label = newMetadata.remove("description"); + newMetadata.put("label", label); + + result.putAll(newMetadata); + result.putAll(metadataStandardId); + + return result; + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java index d97eace4a..b21a9403c 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java @@ -2,9 +2,10 @@ package eu.eudat.models.rda.mapper; import eu.eudat.data.entities.Funder; import eu.eudat.data.entities.Grant; +import eu.eudat.logic.services.ApiContext; import eu.eudat.models.rda.Project; -import java.util.Collections; +import java.util.*; public class ProjectRDAMapper { @@ -22,4 +23,23 @@ public class ProjectRDAMapper { return rda; } + + public static Map toEntity(Project rda, ApiContext apiContext) { + Map entities = new HashMap<>(); + + entities.put("project", new eu.eudat.data.entities.Project()); + ((eu.eudat.data.entities.Project) entities.get("project")).setLabel(rda.getTitle()); + ((eu.eudat.data.entities.Project) entities.get("project")).setDescription(rda.getDescription()); + ((eu.eudat.data.entities.Project) entities.get("project")).setId(UUID.randomUUID()); + ((eu.eudat.data.entities.Project) entities.get("project")).setStatus((short)1); + ((eu.eudat.data.entities.Project) entities.get("project")).setCreated(new Date()); + ((eu.eudat.data.entities.Project) entities.get("project")).setModified(new Date()); + ((eu.eudat.data.entities.Project) entities.get("project")).setType(0); + apiContext.getOperationsContext().getDatabaseRepository().getProjectDao().createOrUpdate(((eu.eudat.data.entities.Project) entities.get("project"))); + for (int i = 0; i < rda.getFunding().size(); i++) { + entities.put("grant" + (i + 1), FundingRDAMapper.toEntity(rda.getFunding().get(i), apiContext)); + } + + return entities; + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java index fc44cc182..3b5d28649 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java @@ -3,10 +3,13 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; import eu.eudat.logic.utilities.helpers.MyStringUtils; import eu.eudat.models.rda.SecurityAndPrivacy; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.*; public class SecurityAndPrivacyRDAMapper { + private static final Logger logger = LoggerFactory.getLogger(SecurityAndPrivacyRDAMapper.class); public static List toRDAList(List nodes) { Map rdaMap = new HashMap<>(); @@ -19,14 +22,16 @@ public class SecurityAndPrivacyRDAMapper { if (!rdaMap.containsValue(rda)) { rdaMap.put(node.get("numbering").asText(), rda); } - for (PropertyName propertyName: PropertyName.values()) { - if (rdaProperty.contains(propertyName.getName())) { - switch (propertyName) { + for (ExportPropertyName exportPropertyName : ExportPropertyName.values()) { + if (rdaProperty.contains(exportPropertyName.getName())) { + switch (exportPropertyName) { case TITLE: rda.setTitle(rdaValue); + rda.getAdditionalProperties().put(ImportPropertyName.TITLE.getName(), node.get("id").asText()); break; case DESCRIPTION: rda.setDescription(rdaValue); + rda.getAdditionalProperties().put(ImportPropertyName.DESCRIPTION.getName(), node.get("id").asText()); break; } } @@ -36,6 +41,27 @@ public class SecurityAndPrivacyRDAMapper { return new ArrayList<>(rdaMap.values()); } + public static Map toProperties(List rdas) { + Map properties = new HashMap<>(); + rdas.forEach(rda -> rda.getAdditionalProperties().entrySet().forEach(entry -> { + try { + ImportPropertyName importPropertyName = ImportPropertyName.fromString(entry.getKey()); + switch(importPropertyName) { + case TITLE: + properties.put(entry.getValue().toString(), rda.getTitle()); + break; + case DESCRIPTION: + properties.put(entry.getValue().toString(), rda.getDescription()); + break; + } + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + })); + + return properties; + } + public static SecurityAndPrivacy toRDA(JsonNode node) { SecurityAndPrivacy rda = new SecurityAndPrivacy(); String rdaProperty = node.get("rdaProperty").asText(); @@ -55,13 +81,13 @@ public class SecurityAndPrivacyRDAMapper { .max(Comparator.comparingInt(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering))).map(Map.Entry::getValue).orElse(new SecurityAndPrivacy()); } - private enum PropertyName { + private enum ExportPropertyName { TITLE("title"), DESCRIPTION("description"); private String name; - PropertyName(String name) { + ExportPropertyName(String name) { this.name = name; } @@ -69,4 +95,28 @@ public class SecurityAndPrivacyRDAMapper { return name; } } + + private enum ImportPropertyName { + TITLE("titleId"), + DESCRIPTION("descriptionId"); + + private String name; + + ImportPropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public static ImportPropertyName fromString(String name) throws Exception { + for (ImportPropertyName importPropertyName: ImportPropertyName.values()) { + if (importPropertyName.getName().equals(name)) { + return importPropertyName; + } + } + throw new Exception("Property not available"); + } + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java index c48f93cae..cd764c302 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java @@ -2,12 +2,14 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; import eu.eudat.logic.utilities.helpers.MyStringUtils; -import eu.eudat.models.rda.SecurityAndPrivacy; import eu.eudat.models.rda.TechnicalResource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.*; public class TechnicalResourceRDAMapper { + private static final Logger logger = LoggerFactory.getLogger(TechnicalResourceRDAMapper.class); public static List toRDAList(List nodes) { Map rdaMap = new HashMap<>(); @@ -20,14 +22,16 @@ public class TechnicalResourceRDAMapper { if (!rdaMap.containsValue(rda)) { rdaMap.put(node.get("numbering").asText(), rda); } - for (PropertyName propertyName: PropertyName.values()) { - if (rdaProperty.contains(propertyName.getName())) { - switch (propertyName) { + for (ExportPropertyName exportPropertyName : ExportPropertyName.values()) { + if (rdaProperty.contains(exportPropertyName.getName())) { + switch (exportPropertyName) { case NAME: rda.setName(rdaValue); + rda.setAdditionalProperty(ImportPropertyName.NAME.getName(), node.get("id").asText()); break; case DESCRIPTION: rda.setDescription(rdaValue); + rda.setAdditionalProperty(ImportPropertyName.DESCRIPTION.getName(), node.get("id").asText()); break; } } @@ -37,6 +41,28 @@ public class TechnicalResourceRDAMapper { return new ArrayList<>(rdaMap.values()); } + public static Map toProperties(List rdas) { + Map properties = new HashMap<>(); + + rdas.forEach(rda -> rda.getAdditionalProperties().entrySet().forEach(entry -> { + try { + ImportPropertyName importPropertyName = ImportPropertyName.fromString(entry.getKey()); + switch(importPropertyName) { + case DESCRIPTION: + properties.put(entry.getValue().toString(), rda.getDescription()); + break; + case NAME: + properties.put(entry.getValue().toString(), rda.getName()); + break; + } + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + })); + + return properties; + } + public static TechnicalResource toRDA(JsonNode node) { TechnicalResource rda = new TechnicalResource(); String rdaProperty = node.get("rdaProperty").asText(); @@ -56,13 +82,13 @@ public class TechnicalResourceRDAMapper { .max(Comparator.comparingInt(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering))).map(Map.Entry::getValue).orElse(new TechnicalResource()); } - private enum PropertyName { + private enum ExportPropertyName { NAME("name"), DESCRIPTION("description"); private String name; - PropertyName(String name) { + ExportPropertyName(String name) { this.name = name; } @@ -70,4 +96,28 @@ public class TechnicalResourceRDAMapper { return name; } } + + private enum ImportPropertyName { + NAME("nameId"), + DESCRIPTION("descriptionId"); + + private String name; + + ImportPropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public static ImportPropertyName fromString(String name) throws Exception { + for (ImportPropertyName importPropertyName: ImportPropertyName.values()) { + if (importPropertyName.getName().equals(name)) { + return importPropertyName; + } + } + throw new Exception("Property name not available"); + } + } } diff --git a/dmp-frontend/src/app/ui/dmp/listing/upload-dialogue/dmp-upload-dialogue.component.html b/dmp-frontend/src/app/ui/dmp/listing/upload-dialogue/dmp-upload-dialogue.component.html index 81779fadc..f9669094e 100644 --- a/dmp-frontend/src/app/ui/dmp/listing/upload-dialogue/dmp-upload-dialogue.component.html +++ b/dmp-frontend/src/app/ui/dmp/listing/upload-dialogue/dmp-upload-dialogue.component.html @@ -7,7 +7,7 @@ - +
From c05fa8b768a4d88c09421281a3a634da0268ff43 Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Fri, 20 Mar 2020 18:20:22 +0200 Subject: [PATCH 05/20] Add new RDA exporter --- .../managers/DataManagementPlanManager.java | 13 +- .../logic/managers/DatasetProfileManager.java | 4 +- .../eu/eudat/logic/managers/RDAManager.java | 38 + .../logic/utilities/json/JsonSearcher.java | 32 + .../commons/datafield/AutoCompleteData.java | 2 + .../commons/datafield/ComboBoxData.java | 11 + .../ExternalAutocompleteFieldModel.java | 12 +- .../data/rda/DatasetRDAExportModel.java | 3 +- .../java/eu/eudat/models/rda/Contact.java | 146 +++ .../java/eu/eudat/models/rda/ContactId.java | 154 ++++ .../java/eu/eudat/models/rda/Contributor.java | 181 ++++ .../eu/eudat/models/rda/ContributorId.java | 155 ++++ .../main/java/eu/eudat/models/rda/Cost.java | 374 ++++++++ .../java/eu/eudat/models/rda/Dataset.java | 839 ++++++++++++++++++ .../java/eu/eudat/models/rda/DatasetId.java | 156 ++++ .../eu/eudat/models/rda/Distribution.java | 412 +++++++++ .../main/java/eu/eudat/models/rda/Dmp.java | 774 ++++++++++++++++ .../main/java/eu/eudat/models/rda/DmpId.java | 156 ++++ .../java/eu/eudat/models/rda/FunderId.java | 154 ++++ .../java/eu/eudat/models/rda/Funding.java | 187 ++++ .../java/eu/eudat/models/rda/GrantId.java | 153 ++++ .../main/java/eu/eudat/models/rda/Host.java | 775 ++++++++++++++++ .../java/eu/eudat/models/rda/License.java | 113 +++ .../eudat/models/rda/MetadataStandardId.java | 153 ++++ .../java/eu/eudat/models/rda/Metadatum.java | 368 ++++++++ .../java/eu/eudat/models/rda/PidSystem.java | 63 ++ .../java/eu/eudat/models/rda/Project.java | 212 +++++ .../java/eu/eudat/models/rda/RDAModel.java | 58 ++ .../eudat/models/rda/SecurityAndPrivacy.java | 109 +++ .../eudat/models/rda/TechnicalResource.java | 109 +++ .../models/rda/mapper/ContactIdRDAMapper.java | 15 + .../models/rda/mapper/ContactRDAMapper.java | 16 + .../rda/mapper/ContributorIdRDAMapper.java | 16 + .../rda/mapper/ContributorRDAMapper.java | 20 + .../models/rda/mapper/DatasetIdRDAMapper.java | 17 + .../models/rda/mapper/DatasetRDAMapper.java | 100 +++ .../rda/mapper/DistributionRDAMapper.java | 39 + .../models/rda/mapper/DmpIdRDAMapper.java | 19 + .../eudat/models/rda/mapper/DmpRDAMapper.java | 51 ++ .../models/rda/mapper/FunderIdRDAMapper.java | 19 + .../models/rda/mapper/FundingRDAMapper.java | 25 + .../models/rda/mapper/GrantIdRDAMapper.java | 13 + .../models/rda/mapper/HostRDAMapper.java | 41 + .../models/rda/mapper/LicenseRDAMapper.java | 23 + .../models/rda/mapper/MetadataRDAMapper.java | 44 + .../mapper/MetadataStandardIdRDAMapper.java | 13 + .../models/rda/mapper/ProjectRDAMapper.java | 25 + .../mapper/SecurityAndPrivacyRDAMapper.java | 21 + .../mapper/TechnicalResourceRDAMapper.java | 21 + 49 files changed, 6447 insertions(+), 7 deletions(-) create mode 100644 dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Contact.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/ContactId.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Contributor.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/ContributorId.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Cost.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/DatasetId.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/DmpId.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/FunderId.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Funding.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/GrantId.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Host.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/License.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/MetadataStandardId.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/PidSystem.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Project.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/RDAModel.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorIdRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetIdRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpIdRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FunderIdRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/GrantIdRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataStandardIdRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java index e88e48524..2710ec60c 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java @@ -105,14 +105,16 @@ public class DataManagementPlanManager { private UtilitiesService utilitiesService; private DatabaseRepository databaseRepository; private Environment environment; + private RDAManager rdaManager; @Autowired - public DataManagementPlanManager(ApiContext apiContext, DatasetManager datasetManager, Environment environment) { + public DataManagementPlanManager(ApiContext apiContext, DatasetManager datasetManager, Environment environment, RDAManager rdaManager) { this.apiContext = apiContext; this.datasetManager = datasetManager; this.utilitiesService = apiContext.getUtilitiesService(); this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository(); this.environment = environment; + this.rdaManager = rdaManager; } public DataTableData getPaged(DataManagementPlanTableRequest dataManagementPlanTableRequest, Principal principal, String fieldsGroup) throws Exception { @@ -1129,15 +1131,20 @@ public class DataManagementPlanManager { eu.eudat.data.entities.DMP dmp = databaseRepository.getDmpDao().find(UUID.fromString(id)); if (!dmp.isPublic() && dmp.getUsers().stream().noneMatch(userInfo -> userInfo.getUser().getId() == principal.getId())) throw new UnauthorisedException(); - RDAExportModel rdaExportModel = new RDAExportModel().fromDataModel(dmp, datasetManager, principal); +// RDAExportModel rdaExportModel = new RDAExportModel().fromDataModel(dmp, datasetManager, principal); + String result = rdaManager.convertToRDA(dmp); ObjectMapper mapper = new ObjectMapper(); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); String fileName = dmp.getLabel(); fileName = fileName.replaceAll("[^a-zA-Z0-9+ ]", ""); File file = new File(fileName + ".json"); + OutputStream output = new FileOutputStream(file); try { - mapper.writeValue(file, rdaExportModel); +// mapper.writeValue(file, rdaExportModel); + output.write(result.getBytes()); + output.flush(); + output.close(); } catch (IOException e) { logger.error(e.getMessage(), e); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetProfileManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetProfileManager.java index 079359827..81693e917 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetProfileManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetProfileManager.java @@ -113,8 +113,8 @@ public class DatasetProfileManager { ResponseEntity response = restTemplate.exchange(data.getUrl() + "?search=" + like, HttpMethod.GET, entity, Object.class); DocumentContext jsonContext = JsonPath.parse(response.getBody()); - List> jsonItems = jsonContext.read(data.getOptionsRoot() + "['" + data.getAutoCompleteOptions().getLabel() + "','" + data.getAutoCompleteOptions().getValue() + "','" + data.getAutoCompleteOptions().getSource() + "']"); - jsonItems.forEach(item -> result.add(new ExternalAutocompleteFieldModel(item.get(data.getAutoCompleteOptions().getValue()), item.get(data.getAutoCompleteOptions().getLabel()), item.get(data.getAutoCompleteOptions().getSource())))); + List> jsonItems = jsonContext.read(data.getOptionsRoot() + "['" + data.getAutoCompleteOptions().getLabel() + "','" + data.getAutoCompleteOptions().getValue() + "','" + data.getAutoCompleteOptions().getSource() + "','" + "uri" + "']"); + jsonItems.forEach(item -> result.add(new ExternalAutocompleteFieldModel(item.get(data.getAutoCompleteOptions().getValue()), item.get(data.getAutoCompleteOptions().getLabel()), item.get(data.getAutoCompleteOptions().getSource()), item.get("uri")))); return result; } diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java new file mode 100644 index 000000000..eb10fd753 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java @@ -0,0 +1,38 @@ +package eu.eudat.logic.managers; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import eu.eudat.data.entities.DMP; +import eu.eudat.models.rda.Dmp; +import eu.eudat.models.rda.RDAModel; +import eu.eudat.models.rda.mapper.DmpRDAMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.transaction.Transactional; +import java.text.SimpleDateFormat; + +@Component +public class RDAManager { + + private DmpRDAMapper dmpRDAMapper; + + @Autowired + public RDAManager(DmpRDAMapper dmpRDAMapper) { + this.dmpRDAMapper = dmpRDAMapper; + } + + @Transactional + public String convertToRDA(DMP dmp) throws JsonProcessingException { + String result = ""; + + Dmp rdaDmp = dmpRDAMapper.toRDA(dmp); + + ObjectMapper mapper = new ObjectMapper(); + mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")); + + result = mapper.writeValueAsString(rdaDmp); + + return result; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java new file mode 100644 index 000000000..ca2372b91 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java @@ -0,0 +1,32 @@ +package eu.eudat.logic.utilities.json; + +import com.fasterxml.jackson.databind.JsonNode; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +public class JsonSearcher { + + public static List findNodes(JsonNode root, String key, String value) { + List nodes = new ArrayList<>(); + for (Iterator it = root.elements(); it.hasNext(); ) { + JsonNode node = it.next(); + int found = 0; + for (Iterator iter = node.fieldNames(); iter.hasNext(); ) { + String fieldName = iter.next(); + if (fieldName.equals(key)) { + if (node.get(fieldName).asText().equals(value) || node.get(fieldName).asText().startsWith(value)) { + nodes.add(node); + found++; + } + } + + } + if (found == 0) { + nodes.addAll(findNodes(node, key, value)); + } + } + return nodes; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/AutoCompleteData.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/AutoCompleteData.java index 8fbedc873..5b33f115d 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/AutoCompleteData.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/AutoCompleteData.java @@ -64,6 +64,7 @@ public class AutoCompleteData extends ComboBoxData { this.autoCompleteOptions.setLabel(optionElement.getAttribute("label")); this.autoCompleteOptions.setValue(optionElement.getAttribute("value")); this.autoCompleteOptions.setSource(optionElement.getAttribute("source")); + this.autoCompleteOptions.setUri(optionElement.getAttribute("uri")); } return this; } @@ -81,6 +82,7 @@ public class AutoCompleteData extends ComboBoxData { this.autoCompleteOptions.setLabel(options.get("label")); this.autoCompleteOptions.setValue(options.get("value")); this.autoCompleteOptions.setSource(options.get("source")); + this.autoCompleteOptions.setUri(options.get("uri")); } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/ComboBoxData.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/ComboBoxData.java index db67ea301..59bc6ea79 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/ComboBoxData.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/ComboBoxData.java @@ -12,6 +12,7 @@ public abstract class ComboBoxData extends FieldData { private String label; private String value; private String source; + private String uri; public String getLabel() { return label; @@ -34,12 +35,21 @@ public abstract class ComboBoxData extends FieldData { this.source = source; } + public String getUri() { + return uri; + } + + public void setUri(String uri) { + this.uri = uri; + } + @Override public Element toXml(Document doc) { Element option = doc.createElement("option"); option.setAttribute("label", this.label); option.setAttribute("value", this.value); option.setAttribute("source", this.source); + option.setAttribute("uri", this.uri); return option; } @@ -48,6 +58,7 @@ public abstract class ComboBoxData extends FieldData { this.label = item.getAttribute("label"); this.value = item.getAttribute("value"); this.source = item.getAttribute("source"); + this.uri = item.getAttribute("uri"); return this; } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/externaldataset/ExternalAutocompleteFieldModel.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/externaldataset/ExternalAutocompleteFieldModel.java index d57605a72..039c63acd 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/externaldataset/ExternalAutocompleteFieldModel.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/externaldataset/ExternalAutocompleteFieldModel.java @@ -4,11 +4,13 @@ public class ExternalAutocompleteFieldModel { private String id; private String label; private String source; + private String uri; - public ExternalAutocompleteFieldModel(String id, String label, String source) { + public ExternalAutocompleteFieldModel(String id, String label, String source, String uri) { this.id = id; this.label = label; this.source = source; + this.uri = uri; } public String getId() { @@ -31,4 +33,12 @@ public class ExternalAutocompleteFieldModel { public void setSource(String source) { this.source = source; } + + public String getUri() { + return uri; + } + + public void setUri(String uri) { + this.uri = uri; + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/rda/DatasetRDAExportModel.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/rda/DatasetRDAExportModel.java index c9f509020..ccd79971f 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/rda/DatasetRDAExportModel.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/rda/DatasetRDAExportModel.java @@ -321,7 +321,8 @@ public class DatasetRDAExportModel { JSONObject jsonObject = jsonArray.getJSONObject(i); Map jsonObjectMap = jsonObject.toMap(); DatasetMetadataRDAExportModel metadataRda1 = new DatasetMetadataRDAExportModel(); - metadataRda1.setMetadata_standard_id(new IdRDAExportModel(jsonObjectMap.get("label").toString(), jsonObjectMap.get("source").toString())); +// metadataRda1.setMetadata_standard_id(new IdRDAExportModel(jsonObjectMap.get("label").toString(), jsonObjectMap.get("source").toString())); + metadataRda1.setMetadata_standard_id(new IdRDAExportModel(jsonObjectMap.get("uri").toString(), "url")); metadataRDAExportModelList.add(metadataRda1); } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Contact.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Contact.java new file mode 100644 index 000000000..606a3ae2c --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Contact.java @@ -0,0 +1,146 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * The DMP Contact Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "contact_id", + "mbox", + "name" +}) +public class Contact implements Serializable +{ + + /** + * The Contact ID Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contact_id") + private ContactId contactId; + /** + * The Mailbox Schema + *

+ * Contact Person's E-mail address + * (Required) + * + */ + @JsonProperty("mbox") + @JsonPropertyDescription("Contact Person's E-mail address") + private String mbox; + /** + * The Name Schema + *

+ * Name of the contact person + * (Required) + * + */ + @JsonProperty("name") + @JsonPropertyDescription("Name of the contact person") + private String name; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -2062619884605400321L; + + /** + * The Contact ID Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contact_id") + public ContactId getContactId() { + return contactId; + } + + /** + * The Contact ID Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contact_id") + public void setContactId(ContactId contactId) { + this.contactId = contactId; + } + + /** + * The Mailbox Schema + *

+ * Contact Person's E-mail address + * (Required) + * + */ + @JsonProperty("mbox") + public String getMbox() { + return mbox; + } + + /** + * The Mailbox Schema + *

+ * Contact Person's E-mail address + * (Required) + * + */ + @JsonProperty("mbox") + public void setMbox(String mbox) { + this.mbox = mbox; + } + + /** + * The Name Schema + *

+ * Name of the contact person + * (Required) + * + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * The Name Schema + *

+ * Name of the contact person + * (Required) + * + */ + @JsonProperty("name") + public void setName(String name) { + this.name = name; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/ContactId.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/ContactId.java new file mode 100644 index 000000000..60454ea6c --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/ContactId.java @@ -0,0 +1,154 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Contact ID Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "identifier", + "type" +}) +public class ContactId implements Serializable +{ + + /** + * The DMP Contact Identifier Schema + *

+ * + * (Required) + * + */ + @JsonProperty("identifier") + private String identifier; + /** + * The DMP Contact Identifier Type Schema + *

+ * Identifier type. Allowed values: orcid, isni, openid, other + * (Required) + * + */ + @JsonProperty("type") + @JsonPropertyDescription("Identifier type. Allowed values: orcid, isni, openid, other") + private ContactId.Type type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -7066973565810615822L; + + /** + * The DMP Contact Identifier Schema + *

+ * + * (Required) + * + */ + @JsonProperty("identifier") + public String getIdentifier() { + return identifier; + } + + /** + * The DMP Contact Identifier Schema + *

+ * + * (Required) + * + */ + @JsonProperty("identifier") + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + * The DMP Contact Identifier Type Schema + *

+ * Identifier type. Allowed values: orcid, isni, openid, other + * (Required) + * + */ + @JsonProperty("type") + public ContactId.Type getType() { + return type; + } + + /** + * The DMP Contact Identifier Type Schema + *

+ * Identifier type. Allowed values: orcid, isni, openid, other + * (Required) + * + */ + @JsonProperty("type") + public void setType(ContactId.Type type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Type { + + ORCID("orcid"), + ISNI("isni"), + OPENID("openid"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (ContactId.Type c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Type(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static ContactId.Type fromValue(String value) { + ContactId.Type constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Contributor.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Contributor.java new file mode 100644 index 000000000..21dfe68c8 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Contributor.java @@ -0,0 +1,181 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + + +/** + * The Contributor Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "contributor_id", + "mbox", + "name", + "role" +}) +public class Contributor implements Serializable +{ + + /** + * The Contributor_id Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contributor_id") + private ContributorId contributorId; + /** + * The Contributor Mailbox Schema + *

+ * Contributor Mail address + * + */ + @JsonProperty("mbox") + @JsonPropertyDescription("Contributor Mail address") + private String mbox; + /** + * The Name Schema + *

+ * Name of the contributor + * (Required) + * + */ + @JsonProperty("name") + @JsonPropertyDescription("Name of the contributor") + private String name; + /** + * The Role Schema + *

+ * Type of contributor + * (Required) + * + */ + @JsonProperty("role") + @JsonDeserialize(as = java.util.LinkedHashSet.class) + @JsonPropertyDescription("Type of contributor") + private Set role = null; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 3452606902359513114L; + + /** + * The Contributor_id Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contributor_id") + public ContributorId getContributorId() { + return contributorId; + } + + /** + * The Contributor_id Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contributor_id") + public void setContributorId(ContributorId contributorId) { + this.contributorId = contributorId; + } + + /** + * The Contributor Mailbox Schema + *

+ * Contributor Mail address + * + */ + @JsonProperty("mbox") + public String getMbox() { + return mbox; + } + + /** + * The Contributor Mailbox Schema + *

+ * Contributor Mail address + * + */ + @JsonProperty("mbox") + public void setMbox(String mbox) { + this.mbox = mbox; + } + + /** + * The Name Schema + *

+ * Name of the contributor + * (Required) + * + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * The Name Schema + *

+ * Name of the contributor + * (Required) + * + */ + @JsonProperty("name") + public void setName(String name) { + this.name = name; + } + + /** + * The Role Schema + *

+ * Type of contributor + * (Required) + * + */ + @JsonProperty("role") + public Set getRole() { + return role; + } + + /** + * The Role Schema + *

+ * Type of contributor + * (Required) + * + */ + @JsonProperty("role") + public void setRole(Set role) { + this.role = role; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/ContributorId.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/ContributorId.java new file mode 100644 index 000000000..4045f5e0e --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/ContributorId.java @@ -0,0 +1,155 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Contributor_id Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "identifier", + "type" +}) +public class ContributorId implements Serializable +{ + + /** + * The Contributor Identifier Schema + *

+ * Identifier for a contact person + * (Required) + * + */ + @JsonProperty("identifier") + @JsonPropertyDescription("Identifier for a contact person") + private String identifier; + /** + * The Contributor Identifier Type Schema + *

+ * Identifier type. Allowed values: orcid, isni, openid, other + * (Required) + * + */ + @JsonProperty("type") + @JsonPropertyDescription("Identifier type. Allowed values: orcid, isni, openid, other") + private ContributorId.Type type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 3089650417960767482L; + + /** + * The Contributor Identifier Schema + *

+ * Identifier for a contact person + * (Required) + * + */ + @JsonProperty("identifier") + public String getIdentifier() { + return identifier; + } + + /** + * The Contributor Identifier Schema + *

+ * Identifier for a contact person + * (Required) + * + */ + @JsonProperty("identifier") + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + * The Contributor Identifier Type Schema + *

+ * Identifier type. Allowed values: orcid, isni, openid, other + * (Required) + * + */ + @JsonProperty("type") + public ContributorId.Type getType() { + return type; + } + + /** + * The Contributor Identifier Type Schema + *

+ * Identifier type. Allowed values: orcid, isni, openid, other + * (Required) + * + */ + @JsonProperty("type") + public void setType(ContributorId.Type type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Type { + + ORCID("orcid"), + ISNI("isni"), + OPENID("openid"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (ContributorId.Type c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Type(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static ContributorId.Type fromValue(String value) { + ContributorId.Type constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Cost.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Cost.java new file mode 100644 index 000000000..db32ff641 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Cost.java @@ -0,0 +1,374 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Cost Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "currency_code", + "description", + "title", + "value" +}) +public class Cost implements Serializable +{ + + /** + * The Cost Currency Code Schema + *

+ * Allowed values defined by ISO 4217 + * + */ + @JsonProperty("currency_code") + @JsonPropertyDescription("Allowed values defined by ISO 4217") + private Cost.CurrencyCode currencyCode; + /** + * The Cost Description Schema + *

+ * Cost(s) Description + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Cost(s) Description") + private String description; + /** + * The Cost Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + @JsonPropertyDescription("Title") + private String title; + /** + * The Cost Value Schema + *

+ * Value + * + */ + @JsonProperty("value") + @JsonPropertyDescription("Value") + private Double value; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -322637784848035165L; + + /** + * The Cost Currency Code Schema + *

+ * Allowed values defined by ISO 4217 + * + */ + @JsonProperty("currency_code") + public Cost.CurrencyCode getCurrencyCode() { + return currencyCode; + } + + /** + * The Cost Currency Code Schema + *

+ * Allowed values defined by ISO 4217 + * + */ + @JsonProperty("currency_code") + public void setCurrencyCode(Cost.CurrencyCode currencyCode) { + this.currencyCode = currencyCode; + } + + /** + * The Cost Description Schema + *

+ * Cost(s) Description + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The Cost Description Schema + *

+ * Cost(s) Description + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The Cost Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * The Cost Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } + + /** + * The Cost Value Schema + *

+ * Value + * + */ + @JsonProperty("value") + public Double getValue() { + return value; + } + + /** + * The Cost Value Schema + *

+ * Value + * + */ + @JsonProperty("value") + public void setValue(Double value) { + this.value = value; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum CurrencyCode { + + AED("AED"), + AFN("AFN"), + ALL("ALL"), + AMD("AMD"), + ANG("ANG"), + AOA("AOA"), + ARS("ARS"), + AUD("AUD"), + AWG("AWG"), + AZN("AZN"), + BAM("BAM"), + BBD("BBD"), + BDT("BDT"), + BGN("BGN"), + BHD("BHD"), + BIF("BIF"), + BMD("BMD"), + BND("BND"), + BOB("BOB"), + BRL("BRL"), + BSD("BSD"), + BTN("BTN"), + BWP("BWP"), + BYN("BYN"), + BZD("BZD"), + CAD("CAD"), + CDF("CDF"), + CHF("CHF"), + CLP("CLP"), + CNY("CNY"), + COP("COP"), + CRC("CRC"), + CUC("CUC"), + CUP("CUP"), + CVE("CVE"), + CZK("CZK"), + DJF("DJF"), + DKK("DKK"), + DOP("DOP"), + DZD("DZD"), + EGP("EGP"), + ERN("ERN"), + ETB("ETB"), + EUR("EUR"), + FJD("FJD"), + FKP("FKP"), + GBP("GBP"), + GEL("GEL"), + GGP("GGP"), + GHS("GHS"), + GIP("GIP"), + GMD("GMD"), + GNF("GNF"), + GTQ("GTQ"), + GYD("GYD"), + HKD("HKD"), + HNL("HNL"), + HRK("HRK"), + HTG("HTG"), + HUF("HUF"), + IDR("IDR"), + ILS("ILS"), + IMP("IMP"), + INR("INR"), + IQD("IQD"), + IRR("IRR"), + ISK("ISK"), + JEP("JEP"), + JMD("JMD"), + JOD("JOD"), + JPY("JPY"), + KES("KES"), + KGS("KGS"), + KHR("KHR"), + KMF("KMF"), + KPW("KPW"), + KRW("KRW"), + KWD("KWD"), + KYD("KYD"), + KZT("KZT"), + LAK("LAK"), + LBP("LBP"), + LKR("LKR"), + LRD("LRD"), + LSL("LSL"), + LYD("LYD"), + MAD("MAD"), + MDL("MDL"), + MGA("MGA"), + MKD("MKD"), + MMK("MMK"), + MNT("MNT"), + MOP("MOP"), + MRU("MRU"), + MUR("MUR"), + MVR("MVR"), + MWK("MWK"), + MXN("MXN"), + MYR("MYR"), + MZN("MZN"), + NAD("NAD"), + NGN("NGN"), + NIO("NIO"), + NOK("NOK"), + NPR("NPR"), + NZD("NZD"), + OMR("OMR"), + PAB("PAB"), + PEN("PEN"), + PGK("PGK"), + PHP("PHP"), + PKR("PKR"), + PLN("PLN"), + PYG("PYG"), + QAR("QAR"), + RON("RON"), + RSD("RSD"), + RUB("RUB"), + RWF("RWF"), + SAR("SAR"), + SBD("SBD"), + SCR("SCR"), + SDG("SDG"), + SEK("SEK"), + SGD("SGD"), + SHP("SHP"), + SLL("SLL"), + SOS("SOS"), + SPL("SPL*"), + SRD("SRD"), + STN("STN"), + SVC("SVC"), + SYP("SYP"), + SZL("SZL"), + THB("THB"), + TJS("TJS"), + TMT("TMT"), + TND("TND"), + TOP("TOP"), + TRY("TRY"), + TTD("TTD"), + TVD("TVD"), + TWD("TWD"), + TZS("TZS"), + UAH("UAH"), + UGX("UGX"), + USD("USD"), + UYU("UYU"), + UZS("UZS"), + VEF("VEF"), + VND("VND"), + VUV("VUV"), + WST("WST"), + XAF("XAF"), + XCD("XCD"), + XDR("XDR"), + XOF("XOF"), + XPF("XPF"), + YER("YER"), + ZAR("ZAR"), + ZMW("ZMW"), + ZWD("ZWD"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Cost.CurrencyCode c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private CurrencyCode(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Cost.CurrencyCode fromValue(String value) { + Cost.CurrencyCode constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java new file mode 100644 index 000000000..43a7ac0cd --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java @@ -0,0 +1,839 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Dataset Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "data_quality_assurance", + "dataset_id", + "description", + "distribution", + "issued", + "keyword", + "language", + "metadata", + "personal_data", + "preservation_statement", + "security_and_privacy", + "sensitive_data", + "technical_resource", + "title", + "type" +}) +public class Dataset implements Serializable +{ + + /** + * The Data Quality Assurance Schema + *

+ * Data Quality Assurance + * + */ + @JsonProperty("data_quality_assurance") + @JsonPropertyDescription("Data Quality Assurance") + private List dataQualityAssurance = null; + /** + * The Dataset ID Schema + *

+ * Dataset ID + * (Required) + * + */ + @JsonProperty("dataset_id") + @JsonPropertyDescription("Dataset ID") + private DatasetId datasetId; + /** + * The Dataset Description Schema + *

+ * Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file.") + private String description; + /** + * The Dataset Distribution Schema + *

+ * To provide technical information on a specific instance of data. + * + */ + @JsonProperty("distribution") + @JsonPropertyDescription("To provide technical information on a specific instance of data.") + private List distribution = null; + /** + * The Dataset Date of Issue Schema + *

+ * Date of Issue + * + */ + @JsonProperty("issued") + @JsonPropertyDescription("Date of Issue") + private String issued; + /** + * The Dataset Keyword(s) Schema + *

+ * Keywords + * + */ + @JsonProperty("keyword") + @JsonPropertyDescription("Keywords") + private List keyword = null; + /** + * The Dataset Language Schema + *

+ * Language of the dataset expressed using ISO 639-3. + * + */ + @JsonProperty("language") + @JsonPropertyDescription("Language of the dataset expressed using ISO 639-3.") + private Dataset.Language language; + /** + * The Dataset Metadata Schema + *

+ * To describe metadata standards used. + * + */ + @JsonProperty("metadata") + @JsonPropertyDescription("To describe metadata standards used.") + private List metadata = null; + /** + * The Dataset Personal Data Schema + *

+ * If any personal data is contained. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("personal_data") + @JsonPropertyDescription("If any personal data is contained. Allowed values: yes, no, unknown") + private Dataset.PersonalData personalData; + /** + * The Dataset Preservation Statement Schema + *

+ * Preservation Statement + * + */ + @JsonProperty("preservation_statement") + @JsonPropertyDescription("Preservation Statement") + private String preservationStatement; + /** + * The Dataset Security and Policy Schema + *

+ * To list all issues and requirements related to security and privacy + * + */ + @JsonProperty("security_and_privacy") + @JsonPropertyDescription("To list all issues and requirements related to security and privacy") + private List securityAndPrivacy = null; + /** + * The Dataset Sensitive Data Schema + *

+ * If any sensitive data is contained. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("sensitive_data") + @JsonPropertyDescription("If any sensitive data is contained. Allowed values: yes, no, unknown") + private Dataset.SensitiveData sensitiveData; + /** + * The Dataset Technical Resource Schema + *

+ * To list all technical resources needed to implement a DMP + * + */ + @JsonProperty("technical_resource") + @JsonPropertyDescription("To list all technical resources needed to implement a DMP") + private List technicalResource = null; + /** + * The Dataset Title Schema + *

+ * Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * (Required) + * + */ + @JsonProperty("title") + @JsonPropertyDescription("Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file.") + private String title; + /** + * The Dataset Type Schema + *

+ * If appropriate, type according to: DataCite and/or COAR dictionary. Otherwise use the common name for the type, e.g. raw data, software, survey, etc. https://schema.datacite.org/meta/kernel-4.1/doc/DataCite-MetadataKernel_v4.1.pdf http://vocabularies.coar-repositories.org/pubby/resource_type.html + * + */ + @JsonProperty("type") + @JsonPropertyDescription("If appropriate, type according to: DataCite and/or COAR dictionary. Otherwise use the common name for the type, e.g. raw data, software, survey, etc. https://schema.datacite.org/meta/kernel-4.1/doc/DataCite-MetadataKernel_v4.1.pdf http://vocabularies.coar-repositories.org/pubby/resource_type.html") + private String type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -6931119120629009399L; + + /** + * The Data Quality Assurance Schema + *

+ * Data Quality Assurance + * + */ + @JsonProperty("data_quality_assurance") + public List getDataQualityAssurance() { + return dataQualityAssurance; + } + + /** + * The Data Quality Assurance Schema + *

+ * Data Quality Assurance + * + */ + @JsonProperty("data_quality_assurance") + public void setDataQualityAssurance(List dataQualityAssurance) { + this.dataQualityAssurance = dataQualityAssurance; + } + + /** + * The Dataset ID Schema + *

+ * Dataset ID + * (Required) + * + */ + @JsonProperty("dataset_id") + public DatasetId getDatasetId() { + return datasetId; + } + + /** + * The Dataset ID Schema + *

+ * Dataset ID + * (Required) + * + */ + @JsonProperty("dataset_id") + public void setDatasetId(DatasetId datasetId) { + this.datasetId = datasetId; + } + + /** + * The Dataset Description Schema + *

+ * Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The Dataset Description Schema + *

+ * Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The Dataset Distribution Schema + *

+ * To provide technical information on a specific instance of data. + * + */ + @JsonProperty("distribution") + public List getDistribution() { + return distribution; + } + + /** + * The Dataset Distribution Schema + *

+ * To provide technical information on a specific instance of data. + * + */ + @JsonProperty("distribution") + public void setDistribution(List distribution) { + this.distribution = distribution; + } + + /** + * The Dataset Date of Issue Schema + *

+ * Date of Issue + * + */ + @JsonProperty("issued") + public String getIssued() { + return issued; + } + + /** + * The Dataset Date of Issue Schema + *

+ * Date of Issue + * + */ + @JsonProperty("issued") + public void setIssued(String issued) { + this.issued = issued; + } + + /** + * The Dataset Keyword(s) Schema + *

+ * Keywords + * + */ + @JsonProperty("keyword") + public List getKeyword() { + return keyword; + } + + /** + * The Dataset Keyword(s) Schema + *

+ * Keywords + * + */ + @JsonProperty("keyword") + public void setKeyword(List keyword) { + this.keyword = keyword; + } + + /** + * The Dataset Language Schema + *

+ * Language of the dataset expressed using ISO 639-3. + * + */ + @JsonProperty("language") + public Dataset.Language getLanguage() { + return language; + } + + /** + * The Dataset Language Schema + *

+ * Language of the dataset expressed using ISO 639-3. + * + */ + @JsonProperty("language") + public void setLanguage(Dataset.Language language) { + this.language = language; + } + + /** + * The Dataset Metadata Schema + *

+ * To describe metadata standards used. + * + */ + @JsonProperty("metadata") + public List getMetadata() { + return metadata; + } + + /** + * The Dataset Metadata Schema + *

+ * To describe metadata standards used. + * + */ + @JsonProperty("metadata") + public void setMetadata(List metadata) { + this.metadata = metadata; + } + + /** + * The Dataset Personal Data Schema + *

+ * If any personal data is contained. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("personal_data") + public Dataset.PersonalData getPersonalData() { + return personalData; + } + + /** + * The Dataset Personal Data Schema + *

+ * If any personal data is contained. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("personal_data") + public void setPersonalData(Dataset.PersonalData personalData) { + this.personalData = personalData; + } + + /** + * The Dataset Preservation Statement Schema + *

+ * Preservation Statement + * + */ + @JsonProperty("preservation_statement") + public String getPreservationStatement() { + return preservationStatement; + } + + /** + * The Dataset Preservation Statement Schema + *

+ * Preservation Statement + * + */ + @JsonProperty("preservation_statement") + public void setPreservationStatement(String preservationStatement) { + this.preservationStatement = preservationStatement; + } + + /** + * The Dataset Security and Policy Schema + *

+ * To list all issues and requirements related to security and privacy + * + */ + @JsonProperty("security_and_privacy") + public List getSecurityAndPrivacy() { + return securityAndPrivacy; + } + + /** + * The Dataset Security and Policy Schema + *

+ * To list all issues and requirements related to security and privacy + * + */ + @JsonProperty("security_and_privacy") + public void setSecurityAndPrivacy(List securityAndPrivacy) { + this.securityAndPrivacy = securityAndPrivacy; + } + + /** + * The Dataset Sensitive Data Schema + *

+ * If any sensitive data is contained. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("sensitive_data") + public Dataset.SensitiveData getSensitiveData() { + return sensitiveData; + } + + /** + * The Dataset Sensitive Data Schema + *

+ * If any sensitive data is contained. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("sensitive_data") + public void setSensitiveData(Dataset.SensitiveData sensitiveData) { + this.sensitiveData = sensitiveData; + } + + /** + * The Dataset Technical Resource Schema + *

+ * To list all technical resources needed to implement a DMP + * + */ + @JsonProperty("technical_resource") + public List getTechnicalResource() { + return technicalResource; + } + + /** + * The Dataset Technical Resource Schema + *

+ * To list all technical resources needed to implement a DMP + * + */ + @JsonProperty("technical_resource") + public void setTechnicalResource(List technicalResource) { + this.technicalResource = technicalResource; + } + + /** + * The Dataset Title Schema + *

+ * Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * (Required) + * + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * The Dataset Title Schema + *

+ * Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * (Required) + * + */ + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } + + /** + * The Dataset Type Schema + *

+ * If appropriate, type according to: DataCite and/or COAR dictionary. Otherwise use the common name for the type, e.g. raw data, software, survey, etc. https://schema.datacite.org/meta/kernel-4.1/doc/DataCite-MetadataKernel_v4.1.pdf http://vocabularies.coar-repositories.org/pubby/resource_type.html + * + */ + @JsonProperty("type") + public String getType() { + return type; + } + + /** + * The Dataset Type Schema + *

+ * If appropriate, type according to: DataCite and/or COAR dictionary. Otherwise use the common name for the type, e.g. raw data, software, survey, etc. https://schema.datacite.org/meta/kernel-4.1/doc/DataCite-MetadataKernel_v4.1.pdf http://vocabularies.coar-repositories.org/pubby/resource_type.html + * + */ + @JsonProperty("type") + public void setType(String type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Language { + + AAR("aar"), + ABK("abk"), + AFR("afr"), + AKA("aka"), + AMH("amh"), + ARA("ara"), + ARG("arg"), + ASM("asm"), + AVA("ava"), + AVE("ave"), + AYM("aym"), + AZE("aze"), + BAK("bak"), + BAM("bam"), + BEL("bel"), + BEN("ben"), + BIH("bih"), + BIS("bis"), + BOD("bod"), + BOS("bos"), + BRE("bre"), + BUL("bul"), + CAT("cat"), + CES("ces"), + CHA("cha"), + CHE("che"), + CHU("chu"), + CHV("chv"), + COR("cor"), + COS("cos"), + CRE("cre"), + CYM("cym"), + DAN("dan"), + DEU("deu"), + DIV("div"), + DZO("dzo"), + ELL("ell"), + ENG("eng"), + EPO("epo"), + EST("est"), + EUS("eus"), + EWE("ewe"), + FAO("fao"), + FAS("fas"), + FIJ("fij"), + FIN("fin"), + FRA("fra"), + FRY("fry"), + FUL("ful"), + GLA("gla"), + GLE("gle"), + GLG("glg"), + GLV("glv"), + GRN("grn"), + GUJ("guj"), + HAT("hat"), + HAU("hau"), + HBS("hbs"), + HEB("heb"), + HER("her"), + HIN("hin"), + HMO("hmo"), + HRV("hrv"), + HUN("hun"), + HYE("hye"), + IBO("ibo"), + IDO("ido"), + III("iii"), + IKU("iku"), + ILE("ile"), + INA("ina"), + IND("ind"), + IPK("ipk"), + ISL("isl"), + ITA("ita"), + JAV("jav"), + JPN("jpn"), + KAL("kal"), + KAN("kan"), + KAS("kas"), + KAT("kat"), + KAU("kau"), + KAZ("kaz"), + KHM("khm"), + KIK("kik"), + KIN("kin"), + KIR("kir"), + KOM("kom"), + KON("kon"), + KOR("kor"), + KUA("kua"), + KUR("kur"), + LAO("lao"), + LAT("lat"), + LAV("lav"), + LIM("lim"), + LIN("lin"), + LIT("lit"), + LTZ("ltz"), + LUB("lub"), + LUG("lug"), + MAH("mah"), + MAL("mal"), + MAR("mar"), + MKD("mkd"), + MLG("mlg"), + MLT("mlt"), + MON("mon"), + MRI("mri"), + MSA("msa"), + MYA("mya"), + NAU("nau"), + NAV("nav"), + NBL("nbl"), + NDE("nde"), + NDO("ndo"), + NEP("nep"), + NLD("nld"), + NNO("nno"), + NOB("nob"), + NOR("nor"), + NYA("nya"), + OCI("oci"), + OJI("oji"), + ORI("ori"), + ORM("orm"), + OSS("oss"), + PAN("pan"), + PLI("pli"), + POL("pol"), + POR("por"), + PUS("pus"), + QUE("que"), + ROH("roh"), + RON("ron"), + RUN("run"), + RUS("rus"), + SAG("sag"), + SAN("san"), + SIN("sin"), + SLK("slk"), + SLV("slv"), + SME("sme"), + SMO("smo"), + SNA("sna"), + SND("snd"), + SOM("som"), + SOT("sot"), + SPA("spa"), + SQI("sqi"), + SRD("srd"), + SRP("srp"), + SSW("ssw"), + SUN("sun"), + SWA("swa"), + SWE("swe"), + TAH("tah"), + TAM("tam"), + TAT("tat"), + TEL("tel"), + TGK("tgk"), + TGL("tgl"), + THA("tha"), + TIR("tir"), + TON("ton"), + TSN("tsn"), + TSO("tso"), + TUK("tuk"), + TUR("tur"), + TWI("twi"), + UIG("uig"), + UKR("ukr"), + URD("urd"), + UZB("uzb"), + VEN("ven"), + VIE("vie"), + VOL("vol"), + WLN("wln"), + WOL("wol"), + XHO("xho"), + YID("yid"), + YOR("yor"), + ZHA("zha"), + ZHO("zho"), + ZUL("zul"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Dataset.Language c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Language(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Dataset.Language fromValue(String value) { + Dataset.Language constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + + public enum PersonalData { + + YES("yes"), + NO("no"), + UNKNOWN("unknown"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Dataset.PersonalData c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private PersonalData(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Dataset.PersonalData fromValue(String value) { + Dataset.PersonalData constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + + public enum SensitiveData { + + YES("yes"), + NO("no"), + UNKNOWN("unknown"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Dataset.SensitiveData c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private SensitiveData(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Dataset.SensitiveData fromValue(String value) { + Dataset.SensitiveData constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/DatasetId.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/DatasetId.java new file mode 100644 index 000000000..c1cc1e57a --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/DatasetId.java @@ -0,0 +1,156 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Dataset ID Schema + *

+ * Dataset ID + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "identifier", + "type" +}) +public class DatasetId implements Serializable +{ + + /** + * The Dataset Identifier Schema + *

+ * Identifier for a dataset + * (Required) + * + */ + @JsonProperty("identifier") + @JsonPropertyDescription("Identifier for a dataset") + private String identifier; + /** + * The Dataset Identifier Type Schema + *

+ * Dataset identifier type. Allowed values: handle, doi, ark, url, other + * (Required) + * + */ + @JsonProperty("type") + @JsonPropertyDescription("Dataset identifier type. Allowed values: handle, doi, ark, url, other") + private DatasetId.Type type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -6295164005851378031L; + + /** + * The Dataset Identifier Schema + *

+ * Identifier for a dataset + * (Required) + * + */ + @JsonProperty("identifier") + public String getIdentifier() { + return identifier; + } + + /** + * The Dataset Identifier Schema + *

+ * Identifier for a dataset + * (Required) + * + */ + @JsonProperty("identifier") + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + * The Dataset Identifier Type Schema + *

+ * Dataset identifier type. Allowed values: handle, doi, ark, url, other + * (Required) + * + */ + @JsonProperty("type") + public DatasetId.Type getType() { + return type; + } + + /** + * The Dataset Identifier Type Schema + *

+ * Dataset identifier type. Allowed values: handle, doi, ark, url, other + * (Required) + * + */ + @JsonProperty("type") + public void setType(DatasetId.Type type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Type { + + HANDLE("handle"), + DOI("doi"), + ARK("ark"), + URL("url"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (DatasetId.Type c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Type(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static DatasetId.Type fromValue(String value) { + DatasetId.Type constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java new file mode 100644 index 000000000..d005e7564 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java @@ -0,0 +1,412 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.net.URI; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Dataset Distribution Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "access_url", + "available_until", + "byte_size", + "data_access", + "description", + "download_url", + "format", + "host", + "license", + "title" +}) +public class Distribution implements Serializable +{ + + /** + * The Dataset Distribution Access URL Schema + *

+ * A URL of the resource that gives access to a distribution of the dataset. e.g. landing page. + * + */ + @JsonProperty("access_url") + @JsonPropertyDescription("A URL of the resource that gives access to a distribution of the dataset. e.g. landing page.") + private String accessUrl; + /** + * The Dataset Distribution Available Until Schema + *

+ * Indicates how long this distribution will be / should be available. + * + */ + @JsonProperty("available_until") + @JsonPropertyDescription("Indicates how long this distribution will be / should be available.") + private String availableUntil; + /** + * The Dataset Distribution Byte Size Schema + *

+ * Size in bytes. + * + */ + @JsonProperty("byte_size") + @JsonPropertyDescription("Size in bytes.") + private Integer byteSize; + /** + * The Dataset Distribution Data Access Schema + *

+ * Indicates access mode for data. Allowed values: open, shared, closed + * (Required) + * + */ + @JsonProperty("data_access") + @JsonPropertyDescription("Indicates access mode for data. Allowed values: open, shared, closed") + private Distribution.DataAccess dataAccess; + /** + * The Dataset Distribution Description Schema + *

+ * Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file.") + private String description; + /** + * The Dataset Distribution Download URL Schema + *

+ * The URL of the downloadable file in a given format. E.g. CSV file or RDF file. + * + */ + @JsonProperty("download_url") + @JsonPropertyDescription("The URL of the downloadable file in a given format. E.g. CSV file or RDF file.") + private URI downloadUrl; + /** + * The Dataset Distribution Format Schema + *

+ * Format according to: https://www.iana.org/assignments/media-types/media-types.xhtml if appropriate, otherwise use the common name for this format. + * + */ + @JsonProperty("format") + @JsonPropertyDescription("Format according to: https://www.iana.org/assignments/media-types/media-types.xhtml if appropriate, otherwise use the common name for this format.") + private List format = null; + /** + * The Dataset Distribution Host Schema + *

+ * To provide information on quality of service provided by infrastructure (e.g. repository) where data is stored. + * + */ + @JsonProperty("host") + @JsonPropertyDescription("To provide information on quality of service provided by infrastructure (e.g. repository) where data is stored.") + private Host host; + /** + * The Dataset Distribution License(s) Schema + *

+ * To list all licenses applied to a specific distribution of data. + * + */ + @JsonProperty("license") + @JsonPropertyDescription("To list all licenses applied to a specific distribution of data.") + private List license = null; + /** + * The Dataset Distribution Title Schema + *

+ * Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * (Required) + * + */ + @JsonProperty("title") + @JsonPropertyDescription("Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file.") + private String title; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -6018365280419917902L; + + /** + * The Dataset Distribution Access URL Schema + *

+ * A URL of the resource that gives access to a distribution of the dataset. e.g. landing page. + * + */ + @JsonProperty("access_url") + public String getAccessUrl() { + return accessUrl; + } + + /** + * The Dataset Distribution Access URL Schema + *

+ * A URL of the resource that gives access to a distribution of the dataset. e.g. landing page. + * + */ + @JsonProperty("access_url") + public void setAccessUrl(String accessUrl) { + this.accessUrl = accessUrl; + } + + /** + * The Dataset Distribution Available Until Schema + *

+ * Indicates how long this distribution will be / should be available. + * + */ + @JsonProperty("available_until") + public String getAvailableUntil() { + return availableUntil; + } + + /** + * The Dataset Distribution Available Until Schema + *

+ * Indicates how long this distribution will be / should be available. + * + */ + @JsonProperty("available_until") + public void setAvailableUntil(String availableUntil) { + this.availableUntil = availableUntil; + } + + /** + * The Dataset Distribution Byte Size Schema + *

+ * Size in bytes. + * + */ + @JsonProperty("byte_size") + public Integer getByteSize() { + return byteSize; + } + + /** + * The Dataset Distribution Byte Size Schema + *

+ * Size in bytes. + * + */ + @JsonProperty("byte_size") + public void setByteSize(Integer byteSize) { + this.byteSize = byteSize; + } + + /** + * The Dataset Distribution Data Access Schema + *

+ * Indicates access mode for data. Allowed values: open, shared, closed + * (Required) + * + */ + @JsonProperty("data_access") + public Distribution.DataAccess getDataAccess() { + return dataAccess; + } + + /** + * The Dataset Distribution Data Access Schema + *

+ * Indicates access mode for data. Allowed values: open, shared, closed + * (Required) + * + */ + @JsonProperty("data_access") + public void setDataAccess(Distribution.DataAccess dataAccess) { + this.dataAccess = dataAccess; + } + + /** + * The Dataset Distribution Description Schema + *

+ * Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The Dataset Distribution Description Schema + *

+ * Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The Dataset Distribution Download URL Schema + *

+ * The URL of the downloadable file in a given format. E.g. CSV file or RDF file. + * + */ + @JsonProperty("download_url") + public URI getDownloadUrl() { + return downloadUrl; + } + + /** + * The Dataset Distribution Download URL Schema + *

+ * The URL of the downloadable file in a given format. E.g. CSV file or RDF file. + * + */ + @JsonProperty("download_url") + public void setDownloadUrl(URI downloadUrl) { + this.downloadUrl = downloadUrl; + } + + /** + * The Dataset Distribution Format Schema + *

+ * Format according to: https://www.iana.org/assignments/media-types/media-types.xhtml if appropriate, otherwise use the common name for this format. + * + */ + @JsonProperty("format") + public List getFormat() { + return format; + } + + /** + * The Dataset Distribution Format Schema + *

+ * Format according to: https://www.iana.org/assignments/media-types/media-types.xhtml if appropriate, otherwise use the common name for this format. + * + */ + @JsonProperty("format") + public void setFormat(List format) { + this.format = format; + } + + /** + * The Dataset Distribution Host Schema + *

+ * To provide information on quality of service provided by infrastructure (e.g. repository) where data is stored. + * + */ + @JsonProperty("host") + public Host getHost() { + return host; + } + + /** + * The Dataset Distribution Host Schema + *

+ * To provide information on quality of service provided by infrastructure (e.g. repository) where data is stored. + * + */ + @JsonProperty("host") + public void setHost(Host host) { + this.host = host; + } + + /** + * The Dataset Distribution License(s) Schema + *

+ * To list all licenses applied to a specific distribution of data. + * + */ + @JsonProperty("license") + public List getLicense() { + return license; + } + + /** + * The Dataset Distribution License(s) Schema + *

+ * To list all licenses applied to a specific distribution of data. + * + */ + @JsonProperty("license") + public void setLicense(List license) { + this.license = license; + } + + /** + * The Dataset Distribution Title Schema + *

+ * Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * (Required) + * + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * The Dataset Distribution Title Schema + *

+ * Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * (Required) + * + */ + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum DataAccess { + + OPEN("open"), + SHARED("shared"), + CLOSED("closed"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Distribution.DataAccess c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private DataAccess(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Distribution.DataAccess fromValue(String value) { + Distribution.DataAccess constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java new file mode 100644 index 000000000..7cac25d62 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java @@ -0,0 +1,774 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.net.URI; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The DMP Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "contact", + "contributor", + "cost", + "created", + "dataset", + "description", + "dmp_id", + "ethical_issues_description", + "ethical_issues_exist", + "ethical_issues_report", + "language", + "modified", + "project", + "title" +}) +public class Dmp implements Serializable +{ + + /** + * The DMP Contact Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contact") + private Contact contact; + /** + * The Contributor Schema + *

+ * + * + */ + @JsonProperty("contributor") + private List contributor = null; + /** + * The Cost Schema + *

+ * + * + */ + @JsonProperty("cost") + private List cost = null; + /** + * The DMP Creation Schema + *

+ * + * + */ + @JsonProperty("created") + @JsonPropertyDescription("") + private Date created; + /** + * The Dataset Schema + *

+ * + * (Required) + * + */ + @JsonProperty("dataset") + private List dataset = null; + /** + * The DMP Description Schema + *

+ * To provide any free-form text information on a DMP + * + */ + @JsonProperty("description") + @JsonPropertyDescription("To provide any free-form text information on a DMP") + private String description; + /** + * The DMP Identifier Schema + *

+ * Identifier for the DMP itself + * (Required) + * + */ + @JsonProperty("dmp_id") + @JsonPropertyDescription("Identifier for the DMP itself") + private DmpId dmpId; + /** + * The DMP Ethical Issues Description Schema + *

+ * To describe ethical issues directly in a DMP + * + */ + @JsonProperty("ethical_issues_description") + @JsonPropertyDescription("To describe ethical issues directly in a DMP") + private String ethicalIssuesDescription; + /** + * The DMP Ethical Issues Exist Schema + *

+ * To indicate whether there are ethical issues related to data that this DMP describes. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("ethical_issues_exist") + @JsonPropertyDescription("To indicate whether there are ethical issues related to data that this DMP describes. Allowed values: yes, no, unknown") + private Dmp.EthicalIssuesExist ethicalIssuesExist; + /** + * The DMP Ethical Issues Report Schema + *

+ * To indicate where a protocol from a meeting with an ethical commitee can be found + * + */ + @JsonProperty("ethical_issues_report") + @JsonPropertyDescription("To indicate where a protocol from a meeting with an ethical commitee can be found") + private URI ethicalIssuesReport; + /** + * The DMP Language Schema + *

+ * Language of the DMP expressed using ISO 639-3. + * (Required) + * + */ + @JsonProperty("language") + @JsonPropertyDescription("Language of the DMP expressed using ISO 639-3.") + private Dmp.Language language; + /** + * The DMP Modification Schema + *

+ * Must be set each time DMP is modified. Indicates DMP version. + * (Required) + * + */ + @JsonProperty("modified") + @JsonPropertyDescription("Must be set each time DMP is modified. Indicates DMP version.") + private Date modified; + /** + * The DMP Project Schema + *

+ * Project related to a DMP + * + */ + @JsonProperty("project") + @JsonPropertyDescription("Project related to a DMP") + private List project = null; + /** + * The DMP Title Schema + *

+ * Title of a DMP + * (Required) + * + */ + @JsonProperty("title") + @JsonPropertyDescription("Title of a DMP") + private String title; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 4599713332472772292L; + + /** + * The DMP Contact Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contact") + public Contact getContact() { + return contact; + } + + /** + * The DMP Contact Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contact") + public void setContact(Contact contact) { + this.contact = contact; + } + + /** + * The Contributor Schema + *

+ * + * + */ + @JsonProperty("contributor") + public List getContributor() { + return contributor; + } + + /** + * The Contributor Schema + *

+ * + * + */ + @JsonProperty("contributor") + public void setContributor(List contributor) { + this.contributor = contributor; + } + + /** + * The Cost Schema + *

+ * + * + */ + @JsonProperty("cost") + public List getCost() { + return cost; + } + + /** + * The Cost Schema + *

+ * + * + */ + @JsonProperty("cost") + public void setCost(List cost) { + this.cost = cost; + } + + /** + * The DMP Creation Schema + *

+ * + * + */ + @JsonProperty("created") + public Date getCreated() { + return created; + } + + /** + * The DMP Creation Schema + *

+ * + * + */ + @JsonProperty("created") + public void setCreated(Date created) { + this.created = created; + } + + /** + * The Dataset Schema + *

+ * + * (Required) + * + */ + @JsonProperty("dataset") + public List getDataset() { + return dataset; + } + + /** + * The Dataset Schema + *

+ * + * (Required) + * + */ + @JsonProperty("dataset") + public void setDataset(List dataset) { + this.dataset = dataset; + } + + /** + * The DMP Description Schema + *

+ * To provide any free-form text information on a DMP + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The DMP Description Schema + *

+ * To provide any free-form text information on a DMP + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The DMP Identifier Schema + *

+ * Identifier for the DMP itself + * (Required) + * + */ + @JsonProperty("dmp_id") + public DmpId getDmpId() { + return dmpId; + } + + /** + * The DMP Identifier Schema + *

+ * Identifier for the DMP itself + * (Required) + * + */ + @JsonProperty("dmp_id") + public void setDmpId(DmpId dmpId) { + this.dmpId = dmpId; + } + + /** + * The DMP Ethical Issues Description Schema + *

+ * To describe ethical issues directly in a DMP + * + */ + @JsonProperty("ethical_issues_description") + public String getEthicalIssuesDescription() { + return ethicalIssuesDescription; + } + + /** + * The DMP Ethical Issues Description Schema + *

+ * To describe ethical issues directly in a DMP + * + */ + @JsonProperty("ethical_issues_description") + public void setEthicalIssuesDescription(String ethicalIssuesDescription) { + this.ethicalIssuesDescription = ethicalIssuesDescription; + } + + /** + * The DMP Ethical Issues Exist Schema + *

+ * To indicate whether there are ethical issues related to data that this DMP describes. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("ethical_issues_exist") + public Dmp.EthicalIssuesExist getEthicalIssuesExist() { + return ethicalIssuesExist; + } + + /** + * The DMP Ethical Issues Exist Schema + *

+ * To indicate whether there are ethical issues related to data that this DMP describes. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("ethical_issues_exist") + public void setEthicalIssuesExist(Dmp.EthicalIssuesExist ethicalIssuesExist) { + this.ethicalIssuesExist = ethicalIssuesExist; + } + + /** + * The DMP Ethical Issues Report Schema + *

+ * To indicate where a protocol from a meeting with an ethical commitee can be found + * + */ + @JsonProperty("ethical_issues_report") + public URI getEthicalIssuesReport() { + return ethicalIssuesReport; + } + + /** + * The DMP Ethical Issues Report Schema + *

+ * To indicate where a protocol from a meeting with an ethical commitee can be found + * + */ + @JsonProperty("ethical_issues_report") + public void setEthicalIssuesReport(URI ethicalIssuesReport) { + this.ethicalIssuesReport = ethicalIssuesReport; + } + + /** + * The DMP Language Schema + *

+ * Language of the DMP expressed using ISO 639-3. + * (Required) + * + */ + @JsonProperty("language") + public Dmp.Language getLanguage() { + return language; + } + + /** + * The DMP Language Schema + *

+ * Language of the DMP expressed using ISO 639-3. + * (Required) + * + */ + @JsonProperty("language") + public void setLanguage(Dmp.Language language) { + this.language = language; + } + + /** + * The DMP Modification Schema + *

+ * Must be set each time DMP is modified. Indicates DMP version. + * (Required) + * + */ + @JsonProperty("modified") + public Date getModified() { + return modified; + } + + /** + * The DMP Modification Schema + *

+ * Must be set each time DMP is modified. Indicates DMP version. + * (Required) + * + */ + @JsonProperty("modified") + public void setModified(Date modified) { + this.modified = modified; + } + + /** + * The DMP Project Schema + *

+ * Project related to a DMP + * + */ + @JsonProperty("project") + public List getProject() { + return project; + } + + /** + * The DMP Project Schema + *

+ * Project related to a DMP + * + */ + @JsonProperty("project") + public void setProject(List project) { + this.project = project; + } + + /** + * The DMP Title Schema + *

+ * Title of a DMP + * (Required) + * + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * The DMP Title Schema + *

+ * Title of a DMP + * (Required) + * + */ + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum EthicalIssuesExist { + + YES("yes"), + NO("no"), + UNKNOWN("unknown"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Dmp.EthicalIssuesExist c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private EthicalIssuesExist(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Dmp.EthicalIssuesExist fromValue(String value) { + Dmp.EthicalIssuesExist constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + + public enum Language { + + AAR("aar"), + ABK("abk"), + AFR("afr"), + AKA("aka"), + AMH("amh"), + ARA("ara"), + ARG("arg"), + ASM("asm"), + AVA("ava"), + AVE("ave"), + AYM("aym"), + AZE("aze"), + BAK("bak"), + BAM("bam"), + BEL("bel"), + BEN("ben"), + BIH("bih"), + BIS("bis"), + BOD("bod"), + BOS("bos"), + BRE("bre"), + BUL("bul"), + CAT("cat"), + CES("ces"), + CHA("cha"), + CHE("che"), + CHU("chu"), + CHV("chv"), + COR("cor"), + COS("cos"), + CRE("cre"), + CYM("cym"), + DAN("dan"), + DEU("deu"), + DIV("div"), + DZO("dzo"), + ELL("ell"), + ENG("eng"), + EPO("epo"), + EST("est"), + EUS("eus"), + EWE("ewe"), + FAO("fao"), + FAS("fas"), + FIJ("fij"), + FIN("fin"), + FRA("fra"), + FRY("fry"), + FUL("ful"), + GLA("gla"), + GLE("gle"), + GLG("glg"), + GLV("glv"), + GRN("grn"), + GUJ("guj"), + HAT("hat"), + HAU("hau"), + HBS("hbs"), + HEB("heb"), + HER("her"), + HIN("hin"), + HMO("hmo"), + HRV("hrv"), + HUN("hun"), + HYE("hye"), + IBO("ibo"), + IDO("ido"), + III("iii"), + IKU("iku"), + ILE("ile"), + INA("ina"), + IND("ind"), + IPK("ipk"), + ISL("isl"), + ITA("ita"), + JAV("jav"), + JPN("jpn"), + KAL("kal"), + KAN("kan"), + KAS("kas"), + KAT("kat"), + KAU("kau"), + KAZ("kaz"), + KHM("khm"), + KIK("kik"), + KIN("kin"), + KIR("kir"), + KOM("kom"), + KON("kon"), + KOR("kor"), + KUA("kua"), + KUR("kur"), + LAO("lao"), + LAT("lat"), + LAV("lav"), + LIM("lim"), + LIN("lin"), + LIT("lit"), + LTZ("ltz"), + LUB("lub"), + LUG("lug"), + MAH("mah"), + MAL("mal"), + MAR("mar"), + MKD("mkd"), + MLG("mlg"), + MLT("mlt"), + MON("mon"), + MRI("mri"), + MSA("msa"), + MYA("mya"), + NAU("nau"), + NAV("nav"), + NBL("nbl"), + NDE("nde"), + NDO("ndo"), + NEP("nep"), + NLD("nld"), + NNO("nno"), + NOB("nob"), + NOR("nor"), + NYA("nya"), + OCI("oci"), + OJI("oji"), + ORI("ori"), + ORM("orm"), + OSS("oss"), + PAN("pan"), + PLI("pli"), + POL("pol"), + POR("por"), + PUS("pus"), + QUE("que"), + ROH("roh"), + RON("ron"), + RUN("run"), + RUS("rus"), + SAG("sag"), + SAN("san"), + SIN("sin"), + SLK("slk"), + SLV("slv"), + SME("sme"), + SMO("smo"), + SNA("sna"), + SND("snd"), + SOM("som"), + SOT("sot"), + SPA("spa"), + SQI("sqi"), + SRD("srd"), + SRP("srp"), + SSW("ssw"), + SUN("sun"), + SWA("swa"), + SWE("swe"), + TAH("tah"), + TAM("tam"), + TAT("tat"), + TEL("tel"), + TGK("tgk"), + TGL("tgl"), + THA("tha"), + TIR("tir"), + TON("ton"), + TSN("tsn"), + TSO("tso"), + TUK("tuk"), + TUR("tur"), + TWI("twi"), + UIG("uig"), + UKR("ukr"), + URD("urd"), + UZB("uzb"), + VEN("ven"), + VIE("vie"), + VOL("vol"), + WLN("wln"), + WOL("wol"), + XHO("xho"), + YID("yid"), + YOR("yor"), + ZHA("zha"), + ZHO("zho"), + ZUL("zul"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Dmp.Language c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Language(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Dmp.Language fromValue(String value) { + Dmp.Language constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/DmpId.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/DmpId.java new file mode 100644 index 000000000..7240efaa4 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/DmpId.java @@ -0,0 +1,156 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The DMP Identifier Schema + *

+ * Identifier for the DMP itself + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "identifier", + "type" +}) +public class DmpId implements Serializable +{ + + /** + * The DMP Identifier Value Schema + *

+ * Identifier for a DMP + * (Required) + * + */ + @JsonProperty("identifier") + @JsonPropertyDescription("Identifier for a DMP") + private String identifier; + /** + * The DMP Identifier Type Schema + *

+ * The DMP Identifier Type. Allowed values: handle, doi, ark, url, other + * (Required) + * + */ + @JsonProperty("type") + @JsonPropertyDescription("The DMP Identifier Type. Allowed values: handle, doi, ark, url, other") + private DmpId.Type type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -6059908070202476841L; + + /** + * The DMP Identifier Value Schema + *

+ * Identifier for a DMP + * (Required) + * + */ + @JsonProperty("identifier") + public String getIdentifier() { + return identifier; + } + + /** + * The DMP Identifier Value Schema + *

+ * Identifier for a DMP + * (Required) + * + */ + @JsonProperty("identifier") + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + * The DMP Identifier Type Schema + *

+ * The DMP Identifier Type. Allowed values: handle, doi, ark, url, other + * (Required) + * + */ + @JsonProperty("type") + public DmpId.Type getType() { + return type; + } + + /** + * The DMP Identifier Type Schema + *

+ * The DMP Identifier Type. Allowed values: handle, doi, ark, url, other + * (Required) + * + */ + @JsonProperty("type") + public void setType(DmpId.Type type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Type { + + HANDLE("handle"), + DOI("doi"), + ARK("ark"), + URL("url"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (DmpId.Type c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Type(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static DmpId.Type fromValue(String value) { + DmpId.Type constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/FunderId.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/FunderId.java new file mode 100644 index 000000000..12b8bb8f7 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/FunderId.java @@ -0,0 +1,154 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Funder ID Schema + *

+ * Funder ID of the associated project + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "identifier", + "type" +}) +public class FunderId implements Serializable +{ + + /** + * The Funder ID Value Schema + *

+ * Funder ID, recommended to use CrossRef Funder Registry. See: https://www.crossref.org/services/funder-registry/ + * (Required) + * + */ + @JsonProperty("identifier") + @JsonPropertyDescription("Funder ID, recommended to use CrossRef Funder Registry. See: https://www.crossref.org/services/funder-registry/") + private String identifier; + /** + * The Funder ID Type Schema + *

+ * Identifier type. Allowed values: fundref, url, other + * (Required) + * + */ + @JsonProperty("type") + @JsonPropertyDescription("Identifier type. Allowed values: fundref, url, other") + private FunderId.Type type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 1783349151334366078L; + + /** + * The Funder ID Value Schema + *

+ * Funder ID, recommended to use CrossRef Funder Registry. See: https://www.crossref.org/services/funder-registry/ + * (Required) + * + */ + @JsonProperty("identifier") + public String getIdentifier() { + return identifier; + } + + /** + * The Funder ID Value Schema + *

+ * Funder ID, recommended to use CrossRef Funder Registry. See: https://www.crossref.org/services/funder-registry/ + * (Required) + * + */ + @JsonProperty("identifier") + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + * The Funder ID Type Schema + *

+ * Identifier type. Allowed values: fundref, url, other + * (Required) + * + */ + @JsonProperty("type") + public FunderId.Type getType() { + return type; + } + + /** + * The Funder ID Type Schema + *

+ * Identifier type. Allowed values: fundref, url, other + * (Required) + * + */ + @JsonProperty("type") + public void setType(FunderId.Type type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Type { + + FUNDREF("fundref"), + URL("url"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (FunderId.Type c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Type(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static FunderId.Type fromValue(String value) { + FunderId.Type constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Funding.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Funding.java new file mode 100644 index 000000000..0cc378e7c --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Funding.java @@ -0,0 +1,187 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The DMP Project Funding Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "funder_id", + "funding_status", + "grant_id" +}) +public class Funding implements Serializable +{ + + /** + * The Funder ID Schema + *

+ * Funder ID of the associated project + * (Required) + * + */ + @JsonProperty("funder_id") + @JsonPropertyDescription("Funder ID of the associated project") + private FunderId funderId; + /** + * The Funding Status Schema + *

+ * To express different phases of project lifecycle. Allowed values: planned, applied, granted, rejected + * + */ + @JsonProperty("funding_status") + @JsonPropertyDescription("To express different phases of project lifecycle. Allowed values: planned, applied, granted, rejected") + private Funding.FundingStatus fundingStatus; + /** + * The Funding Grant ID Schema + *

+ * Grant ID of the associated project + * (Required) + * + */ + @JsonProperty("grant_id") + @JsonPropertyDescription("Grant ID of the associated project") + private GrantId grantId; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 8962229321225336165L; + + /** + * The Funder ID Schema + *

+ * Funder ID of the associated project + * (Required) + * + */ + @JsonProperty("funder_id") + public FunderId getFunderId() { + return funderId; + } + + /** + * The Funder ID Schema + *

+ * Funder ID of the associated project + * (Required) + * + */ + @JsonProperty("funder_id") + public void setFunderId(FunderId funderId) { + this.funderId = funderId; + } + + /** + * The Funding Status Schema + *

+ * To express different phases of project lifecycle. Allowed values: planned, applied, granted, rejected + * + */ + @JsonProperty("funding_status") + public Funding.FundingStatus getFundingStatus() { + return fundingStatus; + } + + /** + * The Funding Status Schema + *

+ * To express different phases of project lifecycle. Allowed values: planned, applied, granted, rejected + * + */ + @JsonProperty("funding_status") + public void setFundingStatus(Funding.FundingStatus fundingStatus) { + this.fundingStatus = fundingStatus; + } + + /** + * The Funding Grant ID Schema + *

+ * Grant ID of the associated project + * (Required) + * + */ + @JsonProperty("grant_id") + public GrantId getGrantId() { + return grantId; + } + + /** + * The Funding Grant ID Schema + *

+ * Grant ID of the associated project + * (Required) + * + */ + @JsonProperty("grant_id") + public void setGrantId(GrantId grantId) { + this.grantId = grantId; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum FundingStatus { + + PLANNED("planned"), + APPLIED("applied"), + GRANTED("granted"), + REJECTED("rejected"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Funding.FundingStatus c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private FundingStatus(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Funding.FundingStatus fromValue(String value) { + Funding.FundingStatus constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/GrantId.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/GrantId.java new file mode 100644 index 000000000..cb994a0ba --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/GrantId.java @@ -0,0 +1,153 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Funding Grant ID Schema + *

+ * Grant ID of the associated project + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "identifier", + "type" +}) +public class GrantId implements Serializable +{ + + /** + * The Funding Grant ID Value Schema + *

+ * Grant ID + * (Required) + * + */ + @JsonProperty("identifier") + @JsonPropertyDescription("Grant ID") + private String identifier; + /** + * The Funding Grant ID Type Schema + *

+ * Identifier type. Allowed values: url, other + * (Required) + * + */ + @JsonProperty("type") + @JsonPropertyDescription("Identifier type. Allowed values: url, other") + private GrantId.Type type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -7738072672837592065L; + + /** + * The Funding Grant ID Value Schema + *

+ * Grant ID + * (Required) + * + */ + @JsonProperty("identifier") + public String getIdentifier() { + return identifier; + } + + /** + * The Funding Grant ID Value Schema + *

+ * Grant ID + * (Required) + * + */ + @JsonProperty("identifier") + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + * The Funding Grant ID Type Schema + *

+ * Identifier type. Allowed values: url, other + * (Required) + * + */ + @JsonProperty("type") + public GrantId.Type getType() { + return type; + } + + /** + * The Funding Grant ID Type Schema + *

+ * Identifier type. Allowed values: url, other + * (Required) + * + */ + @JsonProperty("type") + public void setType(GrantId.Type type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Type { + + URL("url"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (GrantId.Type c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Type(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static GrantId.Type fromValue(String value) { + GrantId.Type constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Host.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Host.java new file mode 100644 index 000000000..bfa6ec615 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Host.java @@ -0,0 +1,775 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.net.URI; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Dataset Distribution Host Schema + *

+ * To provide information on quality of service provided by infrastructure (e.g. repository) where data is stored. + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "availability", + "backup_frequency", + "backup_type", + "certified_with", + "description", + "geo_location", + "pid_system", + "storage_type", + "support_versioning", + "title", + "url" +}) +public class Host implements Serializable +{ + + /** + * The Dataset Distribution Host Availability Schema + *

+ * Availability + * + */ + @JsonProperty("availability") + @JsonPropertyDescription("Availability") + private String availability; + /** + * The Dataset Distribution Host Backup Frequency Schema + *

+ * Backup Frequency + * + */ + @JsonProperty("backup_frequency") + @JsonPropertyDescription("Backup Frequency") + private String backupFrequency; + /** + * The Dataset Distribution Host Backup Type Schema + *

+ * Backup Type + * + */ + @JsonProperty("backup_type") + @JsonPropertyDescription("Backup Type") + private String backupType; + /** + * The Dataset Distribution Host Certification Type Schema + *

+ * Repository certified to a recognised standard. Allowed values: din31644, dini-zertifikat, dsa, iso16363, iso16919, trac, wds, coretrustseal + * + */ + @JsonProperty("certified_with") + @JsonPropertyDescription("Repository certified to a recognised standard. Allowed values: din31644, dini-zertifikat, dsa, iso16363, iso16919, trac, wds, coretrustseal") + private Host.CertifiedWith certifiedWith; + /** + * The Dataset Distribution Host Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Description") + private String description; + /** + * The Dataset Distribution Host Geographical Location Schema + *

+ * Physical location of the data expressed using ISO 3166-1 country code. + * + */ + @JsonProperty("geo_location") + @JsonPropertyDescription("Physical location of the data expressed using ISO 3166-1 country code.") + private Host.GeoLocation geoLocation; + /** + * The Dataset Distribution Host PID System Schema + *

+ * PID system(s). Allowed values: ark, arxiv, bibcode, doi, ean13, eissn, handle, igsn, isbn, issn, istc, lissn, lsid, pmid, purl, upc, url, urn, other + * + */ + @JsonProperty("pid_system") + @JsonPropertyDescription("PID system(s). Allowed values: ark, arxiv, bibcode, doi, ean13, eissn, handle, igsn, isbn, issn, istc, lissn, lsid, pmid, purl, upc, url, urn, other") + private List pidSystem = null; + /** + * The Dataset Distribution Host Storage Type Schema + *

+ * The type of storage required + * + */ + @JsonProperty("storage_type") + @JsonPropertyDescription("The type of storage required") + private String storageType; + /** + * The Dataset Distribution Host Support Versioning Schema + *

+ * If host supports versioning. Allowed values: yes, no, unknown + * + */ + @JsonProperty("support_versioning") + @JsonPropertyDescription("If host supports versioning. Allowed values: yes, no, unknown") + private Host.SupportVersioning supportVersioning; + /** + * The Dataset Distribution Host Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + @JsonPropertyDescription("Title") + private String title; + /** + * The Dataset Distribution Host Title Schema + *

+ * The URL of the system hosting a distribution of a dataset + * (Required) + * + */ + @JsonProperty("url") + @JsonPropertyDescription("The URL of the system hosting a distribution of a dataset") + private URI url; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 8564338806797654115L; + + /** + * The Dataset Distribution Host Availability Schema + *

+ * Availability + * + */ + @JsonProperty("availability") + public String getAvailability() { + return availability; + } + + /** + * The Dataset Distribution Host Availability Schema + *

+ * Availability + * + */ + @JsonProperty("availability") + public void setAvailability(String availability) { + this.availability = availability; + } + + /** + * The Dataset Distribution Host Backup Frequency Schema + *

+ * Backup Frequency + * + */ + @JsonProperty("backup_frequency") + public String getBackupFrequency() { + return backupFrequency; + } + + /** + * The Dataset Distribution Host Backup Frequency Schema + *

+ * Backup Frequency + * + */ + @JsonProperty("backup_frequency") + public void setBackupFrequency(String backupFrequency) { + this.backupFrequency = backupFrequency; + } + + /** + * The Dataset Distribution Host Backup Type Schema + *

+ * Backup Type + * + */ + @JsonProperty("backup_type") + public String getBackupType() { + return backupType; + } + + /** + * The Dataset Distribution Host Backup Type Schema + *

+ * Backup Type + * + */ + @JsonProperty("backup_type") + public void setBackupType(String backupType) { + this.backupType = backupType; + } + + /** + * The Dataset Distribution Host Certification Type Schema + *

+ * Repository certified to a recognised standard. Allowed values: din31644, dini-zertifikat, dsa, iso16363, iso16919, trac, wds, coretrustseal + * + */ + @JsonProperty("certified_with") + public Host.CertifiedWith getCertifiedWith() { + return certifiedWith; + } + + /** + * The Dataset Distribution Host Certification Type Schema + *

+ * Repository certified to a recognised standard. Allowed values: din31644, dini-zertifikat, dsa, iso16363, iso16919, trac, wds, coretrustseal + * + */ + @JsonProperty("certified_with") + public void setCertifiedWith(Host.CertifiedWith certifiedWith) { + this.certifiedWith = certifiedWith; + } + + /** + * The Dataset Distribution Host Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The Dataset Distribution Host Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The Dataset Distribution Host Geographical Location Schema + *

+ * Physical location of the data expressed using ISO 3166-1 country code. + * + */ + @JsonProperty("geo_location") + public Host.GeoLocation getGeoLocation() { + return geoLocation; + } + + /** + * The Dataset Distribution Host Geographical Location Schema + *

+ * Physical location of the data expressed using ISO 3166-1 country code. + * + */ + @JsonProperty("geo_location") + public void setGeoLocation(Host.GeoLocation geoLocation) { + this.geoLocation = geoLocation; + } + + /** + * The Dataset Distribution Host PID System Schema + *

+ * PID system(s). Allowed values: ark, arxiv, bibcode, doi, ean13, eissn, handle, igsn, isbn, issn, istc, lissn, lsid, pmid, purl, upc, url, urn, other + * + */ + @JsonProperty("pid_system") + public List getPidSystem() { + return pidSystem; + } + + /** + * The Dataset Distribution Host PID System Schema + *

+ * PID system(s). Allowed values: ark, arxiv, bibcode, doi, ean13, eissn, handle, igsn, isbn, issn, istc, lissn, lsid, pmid, purl, upc, url, urn, other + * + */ + @JsonProperty("pid_system") + public void setPidSystem(List pidSystem) { + this.pidSystem = pidSystem; + } + + /** + * The Dataset Distribution Host Storage Type Schema + *

+ * The type of storage required + * + */ + @JsonProperty("storage_type") + public String getStorageType() { + return storageType; + } + + /** + * The Dataset Distribution Host Storage Type Schema + *

+ * The type of storage required + * + */ + @JsonProperty("storage_type") + public void setStorageType(String storageType) { + this.storageType = storageType; + } + + /** + * The Dataset Distribution Host Support Versioning Schema + *

+ * If host supports versioning. Allowed values: yes, no, unknown + * + */ + @JsonProperty("support_versioning") + public Host.SupportVersioning getSupportVersioning() { + return supportVersioning; + } + + /** + * The Dataset Distribution Host Support Versioning Schema + *

+ * If host supports versioning. Allowed values: yes, no, unknown + * + */ + @JsonProperty("support_versioning") + public void setSupportVersioning(Host.SupportVersioning supportVersioning) { + this.supportVersioning = supportVersioning; + } + + /** + * The Dataset Distribution Host Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * The Dataset Distribution Host Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } + + /** + * The Dataset Distribution Host Title Schema + *

+ * The URL of the system hosting a distribution of a dataset + * (Required) + * + */ + @JsonProperty("url") + public URI getUrl() { + return url; + } + + /** + * The Dataset Distribution Host Title Schema + *

+ * The URL of the system hosting a distribution of a dataset + * (Required) + * + */ + @JsonProperty("url") + public void setUrl(URI url) { + this.url = url; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum CertifiedWith { + + DIN_31644("din31644"), + DINI_ZERTIFIKAT("dini-zertifikat"), + DSA("dsa"), + ISO_16363("iso16363"), + ISO_16919("iso16919"), + TRAC("trac"), + WDS("wds"), + CORETRUSTSEAL("coretrustseal"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Host.CertifiedWith c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private CertifiedWith(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Host.CertifiedWith fromValue(String value) { + Host.CertifiedWith constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + + public enum GeoLocation { + + AD("AD"), + AE("AE"), + AF("AF"), + AG("AG"), + AI("AI"), + AL("AL"), + AM("AM"), + AO("AO"), + AQ("AQ"), + AR("AR"), + AS("AS"), + AT("AT"), + AU("AU"), + AW("AW"), + AX("AX"), + AZ("AZ"), + BA("BA"), + BB("BB"), + BD("BD"), + BE("BE"), + BF("BF"), + BG("BG"), + BH("BH"), + BI("BI"), + BJ("BJ"), + BL("BL"), + BM("BM"), + BN("BN"), + BO("BO"), + BQ("BQ"), + BR("BR"), + BS("BS"), + BT("BT"), + BV("BV"), + BW("BW"), + BY("BY"), + BZ("BZ"), + CA("CA"), + CC("CC"), + CD("CD"), + CF("CF"), + CG("CG"), + CH("CH"), + CI("CI"), + CK("CK"), + CL("CL"), + CM("CM"), + CN("CN"), + CO("CO"), + CR("CR"), + CU("CU"), + CV("CV"), + CW("CW"), + CX("CX"), + CY("CY"), + CZ("CZ"), + DE("DE"), + DJ("DJ"), + DK("DK"), + DM("DM"), + DO("DO"), + DZ("DZ"), + EC("EC"), + EE("EE"), + EG("EG"), + EH("EH"), + ER("ER"), + ES("ES"), + ET("ET"), + FI("FI"), + FJ("FJ"), + FK("FK"), + FM("FM"), + FO("FO"), + FR("FR"), + GA("GA"), + GB("GB"), + GD("GD"), + GE("GE"), + GF("GF"), + GG("GG"), + GH("GH"), + GI("GI"), + GL("GL"), + GM("GM"), + GN("GN"), + GP("GP"), + GQ("GQ"), + GR("GR"), + GS("GS"), + GT("GT"), + GU("GU"), + GW("GW"), + GY("GY"), + HK("HK"), + HM("HM"), + HN("HN"), + HR("HR"), + HT("HT"), + HU("HU"), + ID("ID"), + IE("IE"), + IL("IL"), + IM("IM"), + IN("IN"), + IO("IO"), + IQ("IQ"), + IR("IR"), + IS("IS"), + IT("IT"), + JE("JE"), + JM("JM"), + JO("JO"), + JP("JP"), + KE("KE"), + KG("KG"), + KH("KH"), + KI("KI"), + KM("KM"), + KN("KN"), + KP("KP"), + KR("KR"), + KW("KW"), + KY("KY"), + KZ("KZ"), + LA("LA"), + LB("LB"), + LC("LC"), + LI("LI"), + LK("LK"), + LR("LR"), + LS("LS"), + LT("LT"), + LU("LU"), + LV("LV"), + LY("LY"), + MA("MA"), + MC("MC"), + MD("MD"), + ME("ME"), + MF("MF"), + MG("MG"), + MH("MH"), + MK("MK"), + ML("ML"), + MM("MM"), + MN("MN"), + MO("MO"), + MP("MP"), + MQ("MQ"), + MR("MR"), + MS("MS"), + MT("MT"), + MU("MU"), + MV("MV"), + MW("MW"), + MX("MX"), + MY("MY"), + MZ("MZ"), + NA("NA"), + NC("NC"), + NE("NE"), + NF("NF"), + NG("NG"), + NI("NI"), + NL("NL"), + NO("NO"), + NP("NP"), + NR("NR"), + NU("NU"), + NZ("NZ"), + OM("OM"), + PA("PA"), + PE("PE"), + PF("PF"), + PG("PG"), + PH("PH"), + PK("PK"), + PL("PL"), + PM("PM"), + PN("PN"), + PR("PR"), + PS("PS"), + PT("PT"), + PW("PW"), + PY("PY"), + QA("QA"), + RE("RE"), + RO("RO"), + RS("RS"), + RU("RU"), + RW("RW"), + SA("SA"), + SB("SB"), + SC("SC"), + SD("SD"), + SE("SE"), + SG("SG"), + SH("SH"), + SI("SI"), + SJ("SJ"), + SK("SK"), + SL("SL"), + SM("SM"), + SN("SN"), + SO("SO"), + SR("SR"), + SS("SS"), + ST("ST"), + SV("SV"), + SX("SX"), + SY("SY"), + SZ("SZ"), + TC("TC"), + TD("TD"), + TF("TF"), + TG("TG"), + TH("TH"), + TJ("TJ"), + TK("TK"), + TL("TL"), + TM("TM"), + TN("TN"), + TO("TO"), + TR("TR"), + TT("TT"), + TV("TV"), + TW("TW"), + TZ("TZ"), + UA("UA"), + UG("UG"), + UM("UM"), + US("US"), + UY("UY"), + UZ("UZ"), + VA("VA"), + VC("VC"), + VE("VE"), + VG("VG"), + VI("VI"), + VN("VN"), + VU("VU"), + WF("WF"), + WS("WS"), + YE("YE"), + YT("YT"), + ZA("ZA"), + ZM("ZM"), + ZW("ZW"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Host.GeoLocation c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private GeoLocation(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Host.GeoLocation fromValue(String value) { + Host.GeoLocation constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + + public enum SupportVersioning { + + YES("yes"), + NO("no"), + UNKNOWN("unknown"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Host.SupportVersioning c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private SupportVersioning(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Host.SupportVersioning fromValue(String value) { + Host.SupportVersioning constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/License.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/License.java new file mode 100644 index 000000000..1527f5503 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/License.java @@ -0,0 +1,113 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.net.URI; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * The Dataset Distribution License Items + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "license_ref", + "start_date" +}) +public class License implements Serializable +{ + + /** + * The Dataset Distribution License Reference Schema + *

+ * Link to license document. + * (Required) + * + */ + @JsonProperty("license_ref") + @JsonPropertyDescription("Link to license document.") + private URI licenseRef; + /** + * The Dataset Distribution License Start Date Schema + *

+ * Starting date of license. If date is set in the future, it indicates embargo period. + * (Required) + * + */ + @JsonProperty("start_date") + @JsonPropertyDescription("Starting date of license. If date is set in the future, it indicates embargo period.") + private String startDate; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 4148207295817559010L; + + /** + * The Dataset Distribution License Reference Schema + *

+ * Link to license document. + * (Required) + * + */ + @JsonProperty("license_ref") + public URI getLicenseRef() { + return licenseRef; + } + + /** + * The Dataset Distribution License Reference Schema + *

+ * Link to license document. + * (Required) + * + */ + @JsonProperty("license_ref") + public void setLicenseRef(URI licenseRef) { + this.licenseRef = licenseRef; + } + + /** + * The Dataset Distribution License Start Date Schema + *

+ * Starting date of license. If date is set in the future, it indicates embargo period. + * (Required) + * + */ + @JsonProperty("start_date") + public String getStartDate() { + return startDate; + } + + /** + * The Dataset Distribution License Start Date Schema + *

+ * Starting date of license. If date is set in the future, it indicates embargo period. + * (Required) + * + */ + @JsonProperty("start_date") + public void setStartDate(String startDate) { + this.startDate = startDate; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/MetadataStandardId.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/MetadataStandardId.java new file mode 100644 index 000000000..06b54a1f1 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/MetadataStandardId.java @@ -0,0 +1,153 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Dataset Metadata Standard ID Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "identifier", + "type" +}) +public class MetadataStandardId implements Serializable +{ + + /** + * The Dataset Metadata Standard Identifier Value Schema + *

+ * Identifier for the metadata standard used. + * (Required) + * + */ + @JsonProperty("identifier") + @JsonPropertyDescription("Identifier for the metadata standard used.") + private String identifier; + /** + * The Dataset Metadata Standard Identifier Type Schema + *

+ * Identifier type. Allowed values: url, other + * (Required) + * + */ + @JsonProperty("type") + @JsonPropertyDescription("Identifier type. Allowed values: url, other") + private MetadataStandardId.Type type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -7641042701935397947L; + + /** + * The Dataset Metadata Standard Identifier Value Schema + *

+ * Identifier for the metadata standard used. + * (Required) + * + */ + @JsonProperty("identifier") + public String getIdentifier() { + return identifier; + } + + /** + * The Dataset Metadata Standard Identifier Value Schema + *

+ * Identifier for the metadata standard used. + * (Required) + * + */ + @JsonProperty("identifier") + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + * The Dataset Metadata Standard Identifier Type Schema + *

+ * Identifier type. Allowed values: url, other + * (Required) + * + */ + @JsonProperty("type") + public MetadataStandardId.Type getType() { + return type; + } + + /** + * The Dataset Metadata Standard Identifier Type Schema + *

+ * Identifier type. Allowed values: url, other + * (Required) + * + */ + @JsonProperty("type") + public void setType(MetadataStandardId.Type type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Type { + + URL("url"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (MetadataStandardId.Type c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Type(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static MetadataStandardId.Type fromValue(String value) { + MetadataStandardId.Type constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java new file mode 100644 index 000000000..d6057ca62 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java @@ -0,0 +1,368 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Dataset Metadata Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "description", + "language", + "metadata_standard_id" +}) +public class Metadatum implements Serializable +{ + + /** + * The Dataset Metadata Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Description") + private String description; + /** + * The Dataset Metadata Language Schema + *

+ * Language of the metadata expressed using ISO 639-3. + * (Required) + * + */ + @JsonProperty("language") + @JsonPropertyDescription("Language of the metadata expressed using ISO 639-3.") + private Metadatum.Language language; + /** + * The Dataset Metadata Standard ID Schema + *

+ * + * (Required) + * + */ + @JsonProperty("metadata_standard_id") + private MetadataStandardId metadataStandardId; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 6511312853153406190L; + + /** + * The Dataset Metadata Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The Dataset Metadata Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The Dataset Metadata Language Schema + *

+ * Language of the metadata expressed using ISO 639-3. + * (Required) + * + */ + @JsonProperty("language") + public Metadatum.Language getLanguage() { + return language; + } + + /** + * The Dataset Metadata Language Schema + *

+ * Language of the metadata expressed using ISO 639-3. + * (Required) + * + */ + @JsonProperty("language") + public void setLanguage(Metadatum.Language language) { + this.language = language; + } + + /** + * The Dataset Metadata Standard ID Schema + *

+ * + * (Required) + * + */ + @JsonProperty("metadata_standard_id") + public MetadataStandardId getMetadataStandardId() { + return metadataStandardId; + } + + /** + * The Dataset Metadata Standard ID Schema + *

+ * + * (Required) + * + */ + @JsonProperty("metadata_standard_id") + public void setMetadataStandardId(MetadataStandardId metadataStandardId) { + this.metadataStandardId = metadataStandardId; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Language { + + AAR("aar"), + ABK("abk"), + AFR("afr"), + AKA("aka"), + AMH("amh"), + ARA("ara"), + ARG("arg"), + ASM("asm"), + AVA("ava"), + AVE("ave"), + AYM("aym"), + AZE("aze"), + BAK("bak"), + BAM("bam"), + BEL("bel"), + BEN("ben"), + BIH("bih"), + BIS("bis"), + BOD("bod"), + BOS("bos"), + BRE("bre"), + BUL("bul"), + CAT("cat"), + CES("ces"), + CHA("cha"), + CHE("che"), + CHU("chu"), + CHV("chv"), + COR("cor"), + COS("cos"), + CRE("cre"), + CYM("cym"), + DAN("dan"), + DEU("deu"), + DIV("div"), + DZO("dzo"), + ELL("ell"), + ENG("eng"), + EPO("epo"), + EST("est"), + EUS("eus"), + EWE("ewe"), + FAO("fao"), + FAS("fas"), + FIJ("fij"), + FIN("fin"), + FRA("fra"), + FRY("fry"), + FUL("ful"), + GLA("gla"), + GLE("gle"), + GLG("glg"), + GLV("glv"), + GRN("grn"), + GUJ("guj"), + HAT("hat"), + HAU("hau"), + HBS("hbs"), + HEB("heb"), + HER("her"), + HIN("hin"), + HMO("hmo"), + HRV("hrv"), + HUN("hun"), + HYE("hye"), + IBO("ibo"), + IDO("ido"), + III("iii"), + IKU("iku"), + ILE("ile"), + INA("ina"), + IND("ind"), + IPK("ipk"), + ISL("isl"), + ITA("ita"), + JAV("jav"), + JPN("jpn"), + KAL("kal"), + KAN("kan"), + KAS("kas"), + KAT("kat"), + KAU("kau"), + KAZ("kaz"), + KHM("khm"), + KIK("kik"), + KIN("kin"), + KIR("kir"), + KOM("kom"), + KON("kon"), + KOR("kor"), + KUA("kua"), + KUR("kur"), + LAO("lao"), + LAT("lat"), + LAV("lav"), + LIM("lim"), + LIN("lin"), + LIT("lit"), + LTZ("ltz"), + LUB("lub"), + LUG("lug"), + MAH("mah"), + MAL("mal"), + MAR("mar"), + MKD("mkd"), + MLG("mlg"), + MLT("mlt"), + MON("mon"), + MRI("mri"), + MSA("msa"), + MYA("mya"), + NAU("nau"), + NAV("nav"), + NBL("nbl"), + NDE("nde"), + NDO("ndo"), + NEP("nep"), + NLD("nld"), + NNO("nno"), + NOB("nob"), + NOR("nor"), + NYA("nya"), + OCI("oci"), + OJI("oji"), + ORI("ori"), + ORM("orm"), + OSS("oss"), + PAN("pan"), + PLI("pli"), + POL("pol"), + POR("por"), + PUS("pus"), + QUE("que"), + ROH("roh"), + RON("ron"), + RUN("run"), + RUS("rus"), + SAG("sag"), + SAN("san"), + SIN("sin"), + SLK("slk"), + SLV("slv"), + SME("sme"), + SMO("smo"), + SNA("sna"), + SND("snd"), + SOM("som"), + SOT("sot"), + SPA("spa"), + SQI("sqi"), + SRD("srd"), + SRP("srp"), + SSW("ssw"), + SUN("sun"), + SWA("swa"), + SWE("swe"), + TAH("tah"), + TAM("tam"), + TAT("tat"), + TEL("tel"), + TGK("tgk"), + TGL("tgl"), + THA("tha"), + TIR("tir"), + TON("ton"), + TSN("tsn"), + TSO("tso"), + TUK("tuk"), + TUR("tur"), + TWI("twi"), + UIG("uig"), + UKR("ukr"), + URD("urd"), + UZB("uzb"), + VEN("ven"), + VIE("vie"), + VOL("vol"), + WLN("wln"), + WOL("wol"), + XHO("xho"), + YID("yid"), + YOR("yor"), + ZHA("zha"), + ZHO("zho"), + ZUL("zul"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Metadatum.Language c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Language(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Metadatum.Language fromValue(String value) { + Metadatum.Language constant = CONSTANTS.get(value); + if (constant == null) { + return null; +// throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/PidSystem.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/PidSystem.java new file mode 100644 index 000000000..0e29d1153 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/PidSystem.java @@ -0,0 +1,63 @@ + +package eu.eudat.models.rda; + +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public enum PidSystem { + + ARK("ark"), + ARXIV("arxiv"), + BIBCODE("bibcode"), + DOI("doi"), + EAN_13("ean13"), + EISSN("eissn"), + HANDLE("handle"), + IGSN("igsn"), + ISBN("isbn"), + ISSN("issn"), + ISTC("istc"), + LISSN("lissn"), + LSID("lsid"), + PMID("pmid"), + PURL("purl"), + UPC("upc"), + URL("url"), + URN("urn"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (PidSystem c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private PidSystem(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static PidSystem fromValue(String value) { + PidSystem constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Project.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Project.java new file mode 100644 index 000000000..09c231ca3 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Project.java @@ -0,0 +1,212 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * The DMP Project Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "description", + "end", + "funding", + "start", + "title" +}) +public class Project implements Serializable +{ + + /** + * The DMP Project Description Schema + *

+ * Project description + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Project description") + private String description; + /** + * The DMP Project End Date Schema + *

+ * Project end date + * (Required) + * + */ + @JsonProperty("end") + @JsonPropertyDescription("Project end date") + private String end; + /** + * The DMP Project Funding Schema + *

+ * Funding related with a project + * + */ + @JsonProperty("funding") + @JsonPropertyDescription("Funding related with a project") + private List funding = null; + /** + * The DMP Project Start Date Schema + *

+ * Project start date + * (Required) + * + */ + @JsonProperty("start") + @JsonPropertyDescription("Project start date") + private String start; + /** + * The DMP Project Title Schema + *

+ * Project title + * (Required) + * + */ + @JsonProperty("title") + @JsonPropertyDescription("Project title") + private String title; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 1437619307195890472L; + + /** + * The DMP Project Description Schema + *

+ * Project description + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The DMP Project Description Schema + *

+ * Project description + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The DMP Project End Date Schema + *

+ * Project end date + * (Required) + * + */ + @JsonProperty("end") + public String getEnd() { + return end; + } + + /** + * The DMP Project End Date Schema + *

+ * Project end date + * (Required) + * + */ + @JsonProperty("end") + public void setEnd(String end) { + this.end = end; + } + + /** + * The DMP Project Funding Schema + *

+ * Funding related with a project + * + */ + @JsonProperty("funding") + public List getFunding() { + return funding; + } + + /** + * The DMP Project Funding Schema + *

+ * Funding related with a project + * + */ + @JsonProperty("funding") + public void setFunding(List funding) { + this.funding = funding; + } + + /** + * The DMP Project Start Date Schema + *

+ * Project start date + * (Required) + * + */ + @JsonProperty("start") + public String getStart() { + return start; + } + + /** + * The DMP Project Start Date Schema + *

+ * Project start date + * (Required) + * + */ + @JsonProperty("start") + public void setStart(String start) { + this.start = start; + } + + /** + * The DMP Project Title Schema + *

+ * Project title + * (Required) + * + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * The DMP Project Title Schema + *

+ * Project title + * (Required) + * + */ + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/RDAModel.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/RDAModel.java new file mode 100644 index 000000000..61df61b32 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/RDAModel.java @@ -0,0 +1,58 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * RDA DMP Common Standard Schema + *

+ * JSON Schema for the RDA DMP Common Standard + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "dmp" +}) +public class RDAModel implements Serializable +{ + + /** + * The DMP Schema + *

+ * + * (Required) + * + */ + @JsonProperty("dmp") + private Dmp dmp; + private final static long serialVersionUID = 7331666133368350998L; + + /** + * The DMP Schema + *

+ * + * (Required) + * + */ + @JsonProperty("dmp") + public Dmp getDmp() { + return dmp; + } + + /** + * The DMP Schema + *

+ * + * (Required) + * + */ + @JsonProperty("dmp") + public void setDmp(Dmp dmp) { + this.dmp = dmp; + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java new file mode 100644 index 000000000..0486df588 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java @@ -0,0 +1,109 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * The Dataset Security & Policy Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "description", + "title" +}) +public class SecurityAndPrivacy implements Serializable +{ + + /** + * The Dataset Security & Policy Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Description") + private String description; + /** + * The Dataset Security & Policy Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + @JsonPropertyDescription("Title") + private String title; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 7863747935827682977L; + + /** + * The Dataset Security & Policy Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The Dataset Security & Policy Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The Dataset Security & Policy Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * The Dataset Security & Policy Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java new file mode 100644 index 000000000..eac85da72 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java @@ -0,0 +1,109 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * The Dataset Technical Resource Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "description", + "name" +}) +public class TechnicalResource implements Serializable +{ + + /** + * The Dataset Technical Resource Description Schema + *

+ * Description of the technical resource + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Description of the technical resource") + private String description; + /** + * The Dataset Technical Resource Name Schema + *

+ * Name of the technical resource + * (Required) + * + */ + @JsonProperty("name") + @JsonPropertyDescription("Name of the technical resource") + private String name; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -7451757227129483110L; + + /** + * The Dataset Technical Resource Description Schema + *

+ * Description of the technical resource + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The Dataset Technical Resource Description Schema + *

+ * Description of the technical resource + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The Dataset Technical Resource Name Schema + *

+ * Name of the technical resource + * (Required) + * + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * The Dataset Technical Resource Name Schema + *

+ * Name of the technical resource + * (Required) + * + */ + @JsonProperty("name") + public void setName(String name) { + this.name = name; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java new file mode 100644 index 000000000..48549d75a --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java @@ -0,0 +1,15 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.models.rda.ContactId; + +import java.util.UUID; + +public class ContactIdRDAMapper { + + public static ContactId toRDA(UUID id) { + ContactId rda = new ContactId(); + rda.setIdentifier(id.toString()); + rda.setType(ContactId.Type.OTHER); + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java new file mode 100644 index 000000000..69ea2310e --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java @@ -0,0 +1,16 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.data.entities.UserInfo; +import eu.eudat.models.rda.Contact; +import eu.eudat.models.rda.ContactId; + +public class ContactRDAMapper { + + public static Contact toRDA(UserInfo creator) { + Contact rda = new Contact(); + rda.setName(creator.getName()); + rda.setMbox(creator.getEmail()); + rda.setContactId(ContactIdRDAMapper.toRDA(creator.getId())); + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorIdRDAMapper.java new file mode 100644 index 000000000..107dfb996 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorIdRDAMapper.java @@ -0,0 +1,16 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.models.rda.Contributor; +import eu.eudat.models.rda.ContributorId; + +import java.util.UUID; + +public class ContributorIdRDAMapper { + + public static ContributorId toRDA(UUID id) { + ContributorId rda = new ContributorId(); + rda.setIdentifier(id.toString()); + rda.setType(ContributorId.Type.OTHER); + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorRDAMapper.java new file mode 100644 index 000000000..681d98940 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorRDAMapper.java @@ -0,0 +1,20 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.data.entities.UserDMP; +import eu.eudat.models.rda.Contributor; + +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; + +public class ContributorRDAMapper { + + public static Contributor toRDA(UserDMP userDMP) { + Contributor rda = new Contributor(); + rda.setContributorId(ContributorIdRDAMapper.toRDA(userDMP.getUser().getId())); + rda.setName(userDMP.getUser().getName()); + rda.setMbox(userDMP.getUser().getEmail()); + rda.setRole(new HashSet<>(Arrays.asList(UserDMP.UserDMPRoles.fromInteger(userDMP.getRole()).name()))); + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetIdRDAMapper.java new file mode 100644 index 000000000..ab791e215 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetIdRDAMapper.java @@ -0,0 +1,17 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.databind.ObjectMapper; +import eu.eudat.models.rda.DatasetId; + +import java.util.UUID; + +public class DatasetIdRDAMapper { + + public static DatasetId toRDA(UUID id) { + DatasetId rda = new DatasetId(); + rda.setIdentifier(id.toString()); + rda.setType(DatasetId.Type.OTHER); + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java new file mode 100644 index 000000000..103ba72c6 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java @@ -0,0 +1,100 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import eu.eudat.logic.managers.DatasetManager; +import eu.eudat.logic.utilities.json.JsonSearcher; +import eu.eudat.models.data.datasetwizard.DatasetWizardModel; +import eu.eudat.models.rda.Dataset; +import org.json.JSONObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.transaction.Transactional; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.stream.Collectors; + +@Component +public class DatasetRDAMapper { + private static final Logger logger = LoggerFactory.getLogger(DatasetRDAMapper.class); + + private DatasetManager datasetManager; + + @Autowired + public DatasetRDAMapper(DatasetManager datasetManager) { + this.datasetManager = datasetManager; + } + + @Transactional + public Dataset toRDA(eu.eudat.data.entities.Dataset dataset) { + Dataset rda = new Dataset(); + rda.setDatasetId(DatasetIdRDAMapper.toRDA(dataset.getId())); + rda.setTitle(dataset.getLabel()); + rda.setDescription(dataset.getDescription()); + try { + + DatasetWizardModel datasetWizardModel = new DatasetWizardModel().fromDataModel(dataset); + datasetWizardModel.setDatasetProfileDefinition(datasetManager.getPagedProfile(datasetWizardModel, dataset)); + ObjectMapper mapper = new ObjectMapper(); + JsonNode properties = mapper.readTree(dataset.getProperties()); + String datasetDescriptionJson = mapper.writeValueAsString(datasetWizardModel.getDatasetProfileDefinition()); + JsonNode datasetDescriptionObj = mapper.readTree(datasetDescriptionJson); + List typeNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.type"); + if (!typeNodes.isEmpty()) { + rda.setType(properties.get(typeNodes.get(0).get("id").asText()).asText()); + } + List languageNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.language"); + if (!languageNodes.isEmpty()) { + rda.setLanguage(Dataset.Language.fromValue(properties.get(languageNodes.get(0).get("id").asText()).asText())); + } + List metadataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.metadata"); + if (!metadataNodes.isEmpty()) { + rda.setMetadata(metadataNodes.stream().map(node -> MetadataRDAMapper.toRDA(node, properties)).collect(Collectors.toList())); + } + List qaNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.data_quality_assurance"); + if (!qaNodes.isEmpty()) { + rda.setDataQualityAssurance(qaNodes.stream().map(qaNode -> properties.get(qaNode.get("id").asText()).asText()).collect(Collectors.toList())); + } + List preservationNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.preservation_statement"); + if (!preservationNodes.isEmpty()) { + rda.setDataQualityAssurance(preservationNodes.stream().map(preservationNode -> properties.get(preservationNode.get("id").asText()).asText()).collect(Collectors.toList())); + } + List distributionNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.distribution"); + if (!distributionNodes.isEmpty()) { + rda.setDistribution(distributionNodes.stream().map(distributionNode -> DistributionRDAMapper.toRDA(distributionNode, properties)).collect(Collectors.toList())); + } + List keywordNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.keyword"); + if (!keywordNodes.isEmpty()) { + rda.setKeyword(keywordNodes.stream().map(keywordNode -> properties.get(keywordNode.get("id").asText()).asText()).collect(Collectors.toList())); + } + List personalDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.personal_data"); + if (!personalDataNodes.isEmpty()) { + rda.setPersonalData(personalDataNodes.stream().map(personalDataNode -> Dataset.PersonalData.fromValue(properties.get(personalDataNode.get("id").asText()).asText())).findFirst().get()); + } + List securityAndPrivacyNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.security_and_privacy"); + if (!securityAndPrivacyNodes.isEmpty()) { + rda.setSecurityAndPrivacy(securityAndPrivacyNodes.stream().map(securityAndPrivacyNode -> SecurityAndPrivacyRDAMapper.toRDA(securityAndPrivacyNode, properties)).collect(Collectors.toList())); + } + List sensitiveDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.sensitive_data"); + if (!sensitiveDataNodes.isEmpty()) { + rda.setSensitiveData(securityAndPrivacyNodes.stream().map(sensitiveDataNode -> Dataset.SensitiveData.fromValue(properties.get(sensitiveDataNode.get("id").asText()).asText())).findFirst().get()); + } + List technicalResourceNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.technical_resource"); + if (!technicalResourceNodes.isEmpty()) { + rda.setTechnicalResource(technicalResourceNodes.stream().map(technicalResourceNode -> TechnicalResourceRDAMapper.toRDA(technicalResourceNode, properties)).collect(Collectors.toList())); + } + + + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java new file mode 100644 index 000000000..513affd98 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java @@ -0,0 +1,39 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.models.rda.Distribution; + +import java.net.URI; +import java.util.Collections; + +public class DistributionRDAMapper { + + public static Distribution toRDA(JsonNode structure, JsonNode properties) { + Distribution rda = new Distribution(); + String rdaProperty = structure.get("rdaProperty").asText(); + if (rdaProperty.contains("access_url")) { + rda.setAccessUrl(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("available_util")) { + rda.setAvailableUntil(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("byte_size")) { + rda.setByteSize(properties.get(structure.get("id").asText()).asInt()); + } else if (rdaProperty.contains("data_access")) { + rda.setDataAccess(Distribution.DataAccess.fromValue(properties.get(structure.get("id").asText()).asText())); + } else if (rdaProperty.contains("description")) { + rda.setDescription(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("download_url")) { + rda.setDownloadUrl(URI.create(properties.get(structure.get("id").asText()).asText())); + } else if (rdaProperty.contains("format")) { + rda.setFormat(Collections.singletonList(properties.get(structure.get("id").asText()).asText())); + } else if (rdaProperty.contains("host")) { + rda.setHost(HostRDAMapper.toRDA(structure, properties)); + } else if (rdaProperty.contains("license")) { + rda.setLicense(Collections.singletonList(LicenseRDAMapper.toRDA(structure, properties))); + } else if (rdaProperty.contains("title")) { + rda.setTitle(properties.get(structure.get("id").asText()).asText()); + } + + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpIdRDAMapper.java new file mode 100644 index 000000000..095c26e11 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpIdRDAMapper.java @@ -0,0 +1,19 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.models.rda.DmpId; + +import java.util.UUID; + +public class DmpIdRDAMapper { + + public static DmpId toRDA(Object id) { + DmpId rda = new DmpId(); + rda.setIdentifier(id.toString()); + if (id instanceof UUID) { + rda.setType(DmpId.Type.OTHER); + } else { + rda.setType(DmpId.Type.DOI); + } + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java new file mode 100644 index 000000000..620229a27 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java @@ -0,0 +1,51 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.data.entities.DMP; +import eu.eudat.data.entities.UserDMP; +import eu.eudat.data.entities.UserInfo; +import eu.eudat.models.rda.Dmp; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.transaction.Transactional; +import java.util.Collections; +import java.util.stream.Collectors; + +@Component +public class DmpRDAMapper { + + private DatasetRDAMapper datasetRDAMapper; + + @Autowired + public DmpRDAMapper(DatasetRDAMapper datasetRDAMapper) { + this.datasetRDAMapper = datasetRDAMapper; + } + + @Transactional + public Dmp toRDA(DMP dmp) { + Dmp rda = new Dmp(); + if (dmp.getDoi() != null && !dmp.getDoi().isEmpty()) { + rda.setDmpId(DmpIdRDAMapper.toRDA(dmp.getDoi())); + } else { + rda.setDmpId(DmpIdRDAMapper.toRDA(dmp.getId())); + } + rda.setCreated(dmp.getCreated()); + rda.setDescription(dmp.getDescription()); + rda.setModified(dmp.getModified()); + rda.setTitle(dmp.getLabel()); + + UserInfo creator; + if (dmp.getCreator() != null) { + creator = dmp.getCreator(); + } else { + creator = dmp.getUsers().stream().filter(userDMP -> userDMP.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())).map(UserDMP::getUser).findFirst().orElse(new UserInfo()); + } + rda.setContact(ContactRDAMapper.toRDA(creator)); + rda.setContributor(dmp.getUsers().stream().map(ContributorRDAMapper::toRDA).collect(Collectors.toList())); + rda.setDataset(dmp.getDataset().stream().map(dataset -> datasetRDAMapper.toRDA(dataset)).collect(Collectors.toList())); + rda.setProject(Collections.singletonList(ProjectRDAMapper.toRDA(dmp.getProject(), dmp.getGrant()))); + + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FunderIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FunderIdRDAMapper.java new file mode 100644 index 000000000..f0dc5ff4a --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FunderIdRDAMapper.java @@ -0,0 +1,19 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.models.rda.FunderId; + +import java.util.UUID; + +public class FunderIdRDAMapper { + + public static FunderId toRDA(Object id) { + FunderId rda = new FunderId(); + rda.setIdentifier(id.toString()); + if (id instanceof UUID) { + rda.setType(FunderId.Type.OTHER); + } else { + rda.setType(FunderId.Type.FUNDREF); + } + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java new file mode 100644 index 000000000..e0b8fbe65 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java @@ -0,0 +1,25 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.data.entities.Funder; +import eu.eudat.data.entities.Grant; +import eu.eudat.models.rda.Funding; + +public class FundingRDAMapper { + + public static Funding toRDA(Grant grant) { + Funding rda = new Funding(); + String referencePrefix; + String shortReference; + if (grant.getFunder().getReference() != null) { + referencePrefix = grant.getFunder().getReference().split(":")[0]; + shortReference = grant.getFunder().getReference().substring(referencePrefix.length() + 1); + rda.setFunderId(FunderIdRDAMapper.toRDA(shortReference)); + } else { + rda.setFunderId(FunderIdRDAMapper.toRDA(grant.getFunder().getId())); + } + referencePrefix = grant.getReference().split(":")[0]; + shortReference = grant.getReference().substring(referencePrefix.length() + 1); + rda.setGrantId(GrantIdRDAMapper.toRDA(shortReference)); + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/GrantIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/GrantIdRDAMapper.java new file mode 100644 index 000000000..d05ec5d02 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/GrantIdRDAMapper.java @@ -0,0 +1,13 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.models.rda.GrantId; + +public class GrantIdRDAMapper { + + public static GrantId toRDA(String id) { + GrantId rda = new GrantId(); + rda.setIdentifier(id); + rda.setType(GrantId.Type.OTHER); + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java new file mode 100644 index 000000000..9a32cc697 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java @@ -0,0 +1,41 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.models.rda.Host; +import eu.eudat.models.rda.PidSystem; + +import java.net.URI; +import java.util.Collections; + +public class HostRDAMapper { + + public static Host toRDA(JsonNode structure, JsonNode properties) { + Host rda = new Host(); + String rdaProperty = structure.get("rdaProperties").asText(); + if (rdaProperty.contains("availability")) { + rda.setAvailability(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("backup_frequency")) { + rda.setBackupFrequency(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("backup_type")) { + rda.setBackupType(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("certified_with")) { + rda.setCertifiedWith(Host.CertifiedWith.fromValue(properties.get(structure.get("id").asText()).asText())); + } else if (rdaProperty.contains("description")) { + rda.setDescription(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("geo_location")) { + rda.setGeoLocation(Host.GeoLocation.fromValue(properties.get(structure.get("id").asText()).asText())); + } else if (rdaProperty.contains("pid_system")) { + rda.setPidSystem(Collections.singletonList(PidSystem.fromValue(properties.get(structure.get("id").asText()).asText()))); + } else if (rdaProperty.contains("storage_type")) { + rda.setStorageType(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("support_versioning")) { + rda.setSupportVersioning(Host.SupportVersioning.fromValue(properties.get(structure.get("id").asText()).asText())); + } else if (rdaProperty.contains("title")) { + rda.setTitle(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("url")) { + rda.setUrl(URI.create(properties.get(structure.get("id").asText()).asText())); + } + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java new file mode 100644 index 000000000..68817bd3d --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java @@ -0,0 +1,23 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.models.rda.License; + +import java.net.URI; + +public class LicenseRDAMapper { + + public static License toRDA(JsonNode structure, JsonNode properties) { + License rda = new License(); + String rdaProperty = structure.get("rdaProperty").asText(); + String value = properties.get(structure.get("id").asText()).asText(); + + if (rdaProperty.contains("license_ref")) { + rda.setLicenseRef(URI.create(value)); + } else if (rdaProperty.contains("start_date")) { + rda.setStartDate(value); + } + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java new file mode 100644 index 000000000..fa638d3e3 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java @@ -0,0 +1,44 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import eu.eudat.models.rda.Metadatum; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.util.Iterator; + +public class MetadataRDAMapper { + private static final Logger logger = LoggerFactory.getLogger(MetadataRDAMapper.class); + + public static Metadatum toRDA(JsonNode structure, JsonNode properties) { + Metadatum rda = new Metadatum(); + JsonNode dataNode = null; + String rdaProperty = structure.get("rdaProperty").asText(); + if (rdaProperty.contains("metadata_standard_id")) { + try { + String jsonText = properties.get(structure.get("id").asText()).asText(); + if (jsonText != null && !jsonText.isEmpty()) { + dataNode = new ObjectMapper().readTree(jsonText); + for (Iterator it = dataNode.elements(); it.hasNext(); ) { + JsonNode data = it.next(); + if (data.get("uri") != null) { + rda.setMetadataStandardId(MetadataStandardIdRDAMapper.toRDA(data.get("uri").asText())); + } + } + } + } catch (IOException e) { + logger.error(e.getMessage(), e); + } + } else if (rdaProperty.contains("description")) { + rda.setDescription(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("language")) { + String language = properties.get(structure.get("id").asText()).asText(); + Metadatum.Language lang = Metadatum.Language.fromValue(language); + rda.setLanguage(lang); + } + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataStandardIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataStandardIdRDAMapper.java new file mode 100644 index 000000000..586446e02 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataStandardIdRDAMapper.java @@ -0,0 +1,13 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.models.rda.MetadataStandardId; + +public class MetadataStandardIdRDAMapper { + + public static MetadataStandardId toRDA(String uri) { + MetadataStandardId rda = new MetadataStandardId(); + rda.setIdentifier(uri); + rda.setType(MetadataStandardId.Type.URL); + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java new file mode 100644 index 000000000..d97eace4a --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java @@ -0,0 +1,25 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.data.entities.Funder; +import eu.eudat.data.entities.Grant; +import eu.eudat.models.rda.Project; + +import java.util.Collections; + +public class ProjectRDAMapper { + + public static Project toRDA(eu.eudat.data.entities.Project project, Grant grant) { + Project rda = new Project(); + rda.setTitle(project.getLabel()); + rda.setDescription(project.getDescription()); + if (project.getStartdate() != null) { + rda.setStart(project.getStartdate().toString()); + } + if (project.getEnddate() != null) { + rda.setEnd(project.getEnddate().toString()); + } + rda.setFunding(Collections.singletonList(FundingRDAMapper.toRDA(grant))); + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java new file mode 100644 index 000000000..f7f95633f --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java @@ -0,0 +1,21 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.models.rda.SecurityAndPrivacy; + +public class SecurityAndPrivacyRDAMapper { + + public static SecurityAndPrivacy toRDA(JsonNode structure, JsonNode properties) { + SecurityAndPrivacy rda = new SecurityAndPrivacy(); + String rdaProperty = structure.get("rdaProperty").asText(); + String value = properties.get(structure.get("id").asText()).asText(); + + if (rdaProperty.contains("description")) { + rda.setDescription(value); + } else if (rdaProperty.contains("title")) { + rda.setTitle(value); + } + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java new file mode 100644 index 000000000..b2652901a --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java @@ -0,0 +1,21 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.models.rda.TechnicalResource; + +public class TechnicalResourceRDAMapper { + + public static TechnicalResource toRDA(JsonNode structure, JsonNode properties) { + TechnicalResource rda = new TechnicalResource(); + String rdaProperty = structure.get("rdaProperty").asText(); + String value = properties.get(structure.get("id").asText()).asText(); + + if (rdaProperty.contains("description")) { + rda.setDescription(value); + } else if (rdaProperty.contains("name")) { + rda.setName(value); + } + + return rda; + } +} From 72382529542a854e0baa69fa20c5318052962301 Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Mon, 23 Mar 2020 18:09:31 +0200 Subject: [PATCH 06/20] Improved object coupling for various objects on the dataset form --- .../utilities/helpers/MyStringUtils.java | 21 ++++ .../logic/utilities/json/JsonSearcher.java | 1 + .../user/components/datasetprofile/Field.java | 6 +- .../components/datasetprofile/FieldSet.java | 9 +- .../models/rda/mapper/DatasetRDAMapper.java | 27 ++-- .../rda/mapper/DistributionRDAMapper.java | 107 ++++++++++++++-- .../models/rda/mapper/HostRDAMapper.java | 98 +++++++++++---- .../models/rda/mapper/LicenseRDAMapper.java | 6 +- .../models/rda/mapper/MetadataRDAMapper.java | 119 +++++++++++++++--- .../mapper/SecurityAndPrivacyRDAMapper.java | 57 ++++++++- .../mapper/TechnicalResourceRDAMapper.java | 58 ++++++++- .../dataset-description-form.model.ts | 2 +- 12 files changed, 424 insertions(+), 87 deletions(-) create mode 100644 dmp-backend/web/src/main/java/eu/eudat/logic/utilities/helpers/MyStringUtils.java diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/helpers/MyStringUtils.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/helpers/MyStringUtils.java new file mode 100644 index 000000000..1a071e04c --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/helpers/MyStringUtils.java @@ -0,0 +1,21 @@ +package eu.eudat.logic.utilities.helpers; + +public class MyStringUtils { + + public static int getFirstDifference(String s1, String s2) { + char[] s1ar = s1.toCharArray(); + char[] s2ar = s2.toCharArray(); + + for(int i = 0; i < s1ar.length; i++) { + if (s2ar.length > i) { + if (s1ar[i] != s2ar[i]) { + return i; + } + } else { + return i; + } + } + + return -1; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java index ca2372b91..979053830 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java @@ -1,6 +1,7 @@ package eu.eudat.logic.utilities.json; import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.ObjectNode; import java.util.ArrayList; import java.util.Iterator; diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/Field.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/Field.java index 4950261c4..1c735e1a9 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/Field.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/Field.java @@ -149,7 +149,7 @@ public class Field implements Comparable, PropertiesModelBuilder, ViewStyleDefin this.rdaProperty = rdaProperty; } - Field cloneForMultiplicity(String key, Map properties) { + Field cloneForMultiplicity(String key, Map properties, int index) { Field newField = new Field(); newField.id = key; newField.ordinal = this.ordinal; @@ -161,6 +161,7 @@ public class Field implements Comparable, PropertiesModelBuilder, ViewStyleDefin newField.data = this.data; newField.validations = this.validations; newField.rdaProperty = this.rdaProperty; + newField.numbering = "mult" + index + "_" + this.numbering; return newField; } @@ -204,8 +205,9 @@ public class Field implements Comparable, PropertiesModelBuilder, ViewStyleDefin } 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)); + this.multiplicityItems.add(this.cloneForMultiplicity(key, properties, index)); } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/FieldSet.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/FieldSet.java index 51663ddaf..277534d16 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/FieldSet.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/FieldSet.java @@ -163,16 +163,18 @@ public class FieldSet implements Comparable, PropertiesModelBuilder, ViewStyleDe }); 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)); + 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){ + private FieldSet CloneForMultiplicity2(List key, Map properties,String[] ids, int index){ FieldSet newFieldSet = new FieldSet(); newFieldSet.id = ids[0]+"_"+ids[1]+"_"+ids[2]; newFieldSet.description = this.description; @@ -181,8 +183,9 @@ public class FieldSet implements Comparable, PropertiesModelBuilder, ViewStyleDe newFieldSet.title = this.title; newFieldSet.ordinal = this.ordinal; newFieldSet.fields = new LinkedList(); + for (Field field: this.fields) { - newFieldSet.fields.add(field.cloneForMultiplicity(newFieldSet.id + "_" + field.getId(), properties)); + newFieldSet.fields.add(field.cloneForMultiplicity(newFieldSet.id + "_" + field.getId(), properties, index)); } return newFieldSet; } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java index 103ba72c6..5eb9cc685 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java @@ -1,21 +1,17 @@ package eu.eudat.models.rda.mapper; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import eu.eudat.logic.managers.DatasetManager; import eu.eudat.logic.utilities.json.JsonSearcher; import eu.eudat.models.data.datasetwizard.DatasetWizardModel; import eu.eudat.models.rda.Dataset; -import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import javax.transaction.Transactional; -import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import java.util.stream.Collectors; @@ -41,52 +37,51 @@ public class DatasetRDAMapper { DatasetWizardModel datasetWizardModel = new DatasetWizardModel().fromDataModel(dataset); datasetWizardModel.setDatasetProfileDefinition(datasetManager.getPagedProfile(datasetWizardModel, dataset)); ObjectMapper mapper = new ObjectMapper(); - JsonNode properties = mapper.readTree(dataset.getProperties()); String datasetDescriptionJson = mapper.writeValueAsString(datasetWizardModel.getDatasetProfileDefinition()); JsonNode datasetDescriptionObj = mapper.readTree(datasetDescriptionJson); List typeNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.type"); if (!typeNodes.isEmpty()) { - rda.setType(properties.get(typeNodes.get(0).get("id").asText()).asText()); + rda.setType(typeNodes.get(0).get("value").asText()); } List languageNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.language"); if (!languageNodes.isEmpty()) { - rda.setLanguage(Dataset.Language.fromValue(properties.get(languageNodes.get(0).get("id").asText()).asText())); + rda.setLanguage(Dataset.Language.fromValue(languageNodes.get(0).get("value").asText())); } List metadataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.metadata"); if (!metadataNodes.isEmpty()) { - rda.setMetadata(metadataNodes.stream().map(node -> MetadataRDAMapper.toRDA(node, properties)).collect(Collectors.toList())); + rda.setMetadata(MetadataRDAMapper.toRDAList(metadataNodes)); } List qaNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.data_quality_assurance"); if (!qaNodes.isEmpty()) { - rda.setDataQualityAssurance(qaNodes.stream().map(qaNode -> properties.get(qaNode.get("id").asText()).asText()).collect(Collectors.toList())); + rda.setDataQualityAssurance(qaNodes.stream().map(qaNode -> qaNode.get("value").asText()).collect(Collectors.toList())); } List preservationNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.preservation_statement"); if (!preservationNodes.isEmpty()) { - rda.setDataQualityAssurance(preservationNodes.stream().map(preservationNode -> properties.get(preservationNode.get("id").asText()).asText()).collect(Collectors.toList())); + rda.setDataQualityAssurance(preservationNodes.stream().map(preservationNode -> preservationNode.get("value").asText()).collect(Collectors.toList())); } List distributionNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.distribution"); if (!distributionNodes.isEmpty()) { - rda.setDistribution(distributionNodes.stream().map(distributionNode -> DistributionRDAMapper.toRDA(distributionNode, properties)).collect(Collectors.toList())); + rda.setDistribution(DistributionRDAMapper.toRDAList(distributionNodes)); } List keywordNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.keyword"); if (!keywordNodes.isEmpty()) { - rda.setKeyword(keywordNodes.stream().map(keywordNode -> properties.get(keywordNode.get("id").asText()).asText()).collect(Collectors.toList())); + rda.setKeyword(keywordNodes.stream().map(keywordNode -> keywordNode.get("value").asText()).collect(Collectors.toList())); } List personalDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.personal_data"); if (!personalDataNodes.isEmpty()) { - rda.setPersonalData(personalDataNodes.stream().map(personalDataNode -> Dataset.PersonalData.fromValue(properties.get(personalDataNode.get("id").asText()).asText())).findFirst().get()); + rda.setPersonalData(personalDataNodes.stream().map(personalDataNode -> Dataset.PersonalData.fromValue(personalDataNode.get("value").asText())).findFirst().get()); } List securityAndPrivacyNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.security_and_privacy"); if (!securityAndPrivacyNodes.isEmpty()) { - rda.setSecurityAndPrivacy(securityAndPrivacyNodes.stream().map(securityAndPrivacyNode -> SecurityAndPrivacyRDAMapper.toRDA(securityAndPrivacyNode, properties)).collect(Collectors.toList())); + rda.setSecurityAndPrivacy(SecurityAndPrivacyRDAMapper.toRDAList(securityAndPrivacyNodes)); } List sensitiveDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.sensitive_data"); if (!sensitiveDataNodes.isEmpty()) { - rda.setSensitiveData(securityAndPrivacyNodes.stream().map(sensitiveDataNode -> Dataset.SensitiveData.fromValue(properties.get(sensitiveDataNode.get("id").asText()).asText())).findFirst().get()); + rda.setSensitiveData(securityAndPrivacyNodes.stream().map(sensitiveDataNode -> Dataset.SensitiveData.fromValue(sensitiveDataNode.get("value").asText())).findFirst().get()); } List technicalResourceNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.technical_resource"); if (!technicalResourceNodes.isEmpty()) { - rda.setTechnicalResource(technicalResourceNodes.stream().map(technicalResourceNode -> TechnicalResourceRDAMapper.toRDA(technicalResourceNode, properties)).collect(Collectors.toList())); + rda.setTechnicalResource(TechnicalResourceRDAMapper.toRDAList(technicalResourceNodes)); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java index 513affd98..98cb6960b 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java @@ -1,39 +1,120 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.logic.utilities.helpers.MyStringUtils; import eu.eudat.models.rda.Distribution; import java.net.URI; -import java.util.Collections; +import java.util.*; public class DistributionRDAMapper { - public static Distribution toRDA(JsonNode structure, JsonNode properties) { + public static List toRDAList(List nodes) { + Map rdaMap = new HashMap<>(); + + for (JsonNode node: nodes) { + String rdaProperty = node.get("rdaProperty").asText(); + String rdaValue = node.get("value").asText(); + Distribution rda = getRelative(rdaMap, node.get("numbering").asText()); + if (!rdaMap.containsValue(rda)) { + rdaMap.put(node.get("numbering").asText(), rda); + } + for (PropertyName propertyName : PropertyName.values()) { + if (rdaProperty.contains(propertyName.getName())) { + switch (propertyName) { + case ACCESS_URL: + rda.setAccessUrl(rdaValue); + break; + case AVAILABLE_UTIL: + rda.setAvailableUntil(rdaValue); + break; + case DOWNLOAD_URL: + rda.setDownloadUrl(URI.create(rdaValue)); + break; + case DESCRIPTION: + rda.setDescription(rdaValue); + break; + case DATA_ACCESS: + rda.setDataAccess(Distribution.DataAccess.fromValue(rdaValue)); + break; + case BYTE_SIZE: + rda.setByteSize(Integer.parseInt(rdaValue)); + break; + case LICENSE: + rda.setLicense(Collections.singletonList(LicenseRDAMapper.toRDA(node))); + break; + case FORMAT: + rda.setFormat(Collections.singletonList(rdaValue)); + break; + case TITLE: + rda.setTitle(rdaValue); + break; + case HOST: + rda.setHost(HostRDAMapper.toRDA(nodes, node.get("numbering").asText())); + break; + } + } + } + } + + return new ArrayList<>(rdaMap.values()); + } + + public static Distribution toRDA(JsonNode node) { Distribution rda = new Distribution(); - String rdaProperty = structure.get("rdaProperty").asText(); + String rdaProperty = node.get("rdaProperty").asText(); + String rdaValue = node.get("value").asText(); if (rdaProperty.contains("access_url")) { - rda.setAccessUrl(properties.get(structure.get("id").asText()).asText()); + rda.setAccessUrl(rdaValue); } else if (rdaProperty.contains("available_util")) { - rda.setAvailableUntil(properties.get(structure.get("id").asText()).asText()); + rda.setAvailableUntil(rdaValue); } else if (rdaProperty.contains("byte_size")) { - rda.setByteSize(properties.get(structure.get("id").asText()).asInt()); + rda.setByteSize(Integer.parseInt(rdaValue)); } else if (rdaProperty.contains("data_access")) { - rda.setDataAccess(Distribution.DataAccess.fromValue(properties.get(structure.get("id").asText()).asText())); + rda.setDataAccess(Distribution.DataAccess.fromValue(rdaValue)); } else if (rdaProperty.contains("description")) { - rda.setDescription(properties.get(structure.get("id").asText()).asText()); + rda.setDescription(rdaValue); } else if (rdaProperty.contains("download_url")) { - rda.setDownloadUrl(URI.create(properties.get(structure.get("id").asText()).asText())); + rda.setDownloadUrl(URI.create(rdaValue)); } else if (rdaProperty.contains("format")) { - rda.setFormat(Collections.singletonList(properties.get(structure.get("id").asText()).asText())); + rda.setFormat(Collections.singletonList(rdaValue)); } else if (rdaProperty.contains("host")) { - rda.setHost(HostRDAMapper.toRDA(structure, properties)); +// rda.setHost(HostRDAMapper.toRDA(node)); } else if (rdaProperty.contains("license")) { - rda.setLicense(Collections.singletonList(LicenseRDAMapper.toRDA(structure, properties))); + rda.setLicense(Collections.singletonList(LicenseRDAMapper.toRDA(node))); } else if (rdaProperty.contains("title")) { - rda.setTitle(properties.get(structure.get("id").asText()).asText()); + rda.setTitle(rdaValue); } return rda; } + + private static Distribution getRelative( Map rdaMap, String numbering) { + return rdaMap.entrySet().stream().filter(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering) > 0) + .max(Comparator.comparingInt(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering))).map(Map.Entry::getValue).orElse(new Distribution()); + } + + private enum PropertyName { + ACCESS_URL("access_url"), + AVAILABLE_UTIL("available_util"), + BYTE_SIZE("byte_size"), + DATA_ACCESS("data_access"), + DESCRIPTION("description"), + DOWNLOAD_URL("download_url"), + FORMAT("format"), + HOST("host"), + LICENSE("license"), + TITLE("title"); + + private final String name; + + PropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java index 9a32cc697..0983f3d3b 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java @@ -1,41 +1,91 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.logic.utilities.helpers.MyStringUtils; import eu.eudat.models.rda.Host; import eu.eudat.models.rda.PidSystem; import java.net.URI; import java.util.Collections; +import java.util.List; public class HostRDAMapper { - public static Host toRDA(JsonNode structure, JsonNode properties) { + public static Host toRDA(List nodes, String numbering) { Host rda = new Host(); - String rdaProperty = structure.get("rdaProperties").asText(); - if (rdaProperty.contains("availability")) { - rda.setAvailability(properties.get(structure.get("id").asText()).asText()); - } else if (rdaProperty.contains("backup_frequency")) { - rda.setBackupFrequency(properties.get(structure.get("id").asText()).asText()); - } else if (rdaProperty.contains("backup_type")) { - rda.setBackupType(properties.get(structure.get("id").asText()).asText()); - } else if (rdaProperty.contains("certified_with")) { - rda.setCertifiedWith(Host.CertifiedWith.fromValue(properties.get(structure.get("id").asText()).asText())); - } else if (rdaProperty.contains("description")) { - rda.setDescription(properties.get(structure.get("id").asText()).asText()); - } else if (rdaProperty.contains("geo_location")) { - rda.setGeoLocation(Host.GeoLocation.fromValue(properties.get(structure.get("id").asText()).asText())); - } else if (rdaProperty.contains("pid_system")) { - rda.setPidSystem(Collections.singletonList(PidSystem.fromValue(properties.get(structure.get("id").asText()).asText()))); - } else if (rdaProperty.contains("storage_type")) { - rda.setStorageType(properties.get(structure.get("id").asText()).asText()); - } else if (rdaProperty.contains("support_versioning")) { - rda.setSupportVersioning(Host.SupportVersioning.fromValue(properties.get(structure.get("id").asText()).asText())); - } else if (rdaProperty.contains("title")) { - rda.setTitle(properties.get(structure.get("id").asText()).asText()); - } else if (rdaProperty.contains("url")) { - rda.setUrl(URI.create(properties.get(structure.get("id").asText()).asText())); + for (JsonNode node: nodes) { + String rdaProperty = node.get("rdaProperties").asText(); + if (rdaProperty.contains("host")) { + int firstDiff = MyStringUtils.getFirstDifference(numbering, node.get("numbering").asText()); + if (firstDiff == -1 || firstDiff > 2) { + String rdaValue = node.get("value").asText(); + for (PropertyName propertyName: PropertyName.values()) { + if (rdaProperty.contains(propertyName.getName())) { + switch (propertyName) { + case AVAILABILITY: + rda.setAvailability(rdaValue); + break; + case BACKUP_FREQUENCY: + rda.setBackupFrequency(rdaValue); + break; + case BACKUP_TYPE: + rda.setBackupType(rdaValue); + break; + case CERTIFIED_WITH: + rda.setCertifiedWith(Host.CertifiedWith.fromValue(rdaValue)); + break; + case DESCRIPTION: + rda.setDescription(rdaValue); + break; + case GEO_LOCATION: + rda.setGeoLocation(Host.GeoLocation.fromValue(rdaValue)); + break; + case PID_SYSTEM: + rda.setPidSystem(Collections.singletonList(PidSystem.fromValue(rdaValue))); + break; + case STORAGE_TYPE: + rda.setStorageType(rdaValue); + break; + case SUPPORT_VERSIONING: + rda.setSupportVersioning(Host.SupportVersioning.fromValue(rdaValue)); + break; + case TITLE: + rda.setTitle(rdaValue); + break; + case URL: + rda.setUrl(URI.create(rdaValue)); + break; + } + } + } + } + } } return rda; } + + private enum PropertyName { + AVAILABILITY("availability"), + BACKUP_FREQUENCY("backup_frequency"), + BACKUP_TYPE("backup_type"), + CERTIFIED_WITH("certified_with"), + DESCRIPTION("description"), + GEO_LOCATION("geo_location"), + PID_SYSTEM("pid_system"), + STORAGE_TYPE("storage_type"), + SUPPORT_VERSIONING("support_versioning"), + TITLE("title"), + URL("url"); + + private final String name; + + PropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java index 68817bd3d..6f94a73c4 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java @@ -7,10 +7,10 @@ import java.net.URI; public class LicenseRDAMapper { - public static License toRDA(JsonNode structure, JsonNode properties) { + public static License toRDA(JsonNode node) { License rda = new License(); - String rdaProperty = structure.get("rdaProperty").asText(); - String value = properties.get(structure.get("id").asText()).asText(); + String rdaProperty = node.get("rdaProperty").asText(); + String value = node.get("value").asText(); if (rdaProperty.contains("license_ref")) { rda.setLicenseRef(URI.create(value)); diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java index fa638d3e3..c7e3ba35f 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java @@ -2,43 +2,124 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.TextNode; +import eu.eudat.logic.utilities.helpers.MyStringUtils; import eu.eudat.models.rda.Metadatum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.IOException; -import java.util.Iterator; +import java.util.*; public class MetadataRDAMapper { private static final Logger logger = LoggerFactory.getLogger(MetadataRDAMapper.class); - public static Metadatum toRDA(JsonNode structure, JsonNode properties) { - Metadatum rda = new Metadatum(); - JsonNode dataNode = null; - String rdaProperty = structure.get("rdaProperty").asText(); - if (rdaProperty.contains("metadata_standard_id")) { - try { - String jsonText = properties.get(structure.get("id").asText()).asText(); - if (jsonText != null && !jsonText.isEmpty()) { - dataNode = new ObjectMapper().readTree(jsonText); - for (Iterator it = dataNode.elements(); it.hasNext(); ) { - JsonNode data = it.next(); - if (data.get("uri") != null) { - rda.setMetadataStandardId(MetadataStandardIdRDAMapper.toRDA(data.get("uri").asText())); - } + public static List toRDAList(List nodes) { + Map rdaMap = new HashMap<>(); + List rdas = new ArrayList<>(); + for (JsonNode node: nodes) { + String rdaProperty = node.get("rdaProperty").asText(); + JsonNode rdaValue = node.get("value"); + + for (PropertyName propertyName: PropertyName.values()) { + if (rdaProperty.contains(propertyName.getName())) { + switch (propertyName) { + case METADATA_STANDARD_ID: + if (rdaValue instanceof ArrayNode) { + try { + ObjectMapper mapper = new ObjectMapper(); + for (Iterator it = rdaValue.elements(); it.hasNext(); ) { + JsonNode data = null; + data = mapper.readTree(it.next().asText()); + if (data.get("uri") != null) { + rdas.add(new Metadatum()); + rdas.get(rdas.size() - 1).setMetadataStandardId(MetadataStandardIdRDAMapper.toRDA(data.get("uri").asText())); + rdas.get(rdas.size() - 1).setDescription(data.get("label").asText()); + rdaMap.put(data.get("uri").asText(), node.get("numbering").asText()); + } + } + } catch (IOException e) { + logger.error(e.getMessage(), e); + } + } else if (rdaValue instanceof TextNode && rdaProperty.contains("identifier") && !rdaValue.asText().isEmpty()) { + rdas.add(new Metadatum()); + rdas.get(rdas.size() - 1).setMetadataStandardId(MetadataStandardIdRDAMapper.toRDA(rdaValue.asText())); + rdaMap.put(rdaValue.asText(), node.get("numbering").asText()); + } + break; + case DESCRIPTION: + if (!rdaValue.asText().isEmpty()) { + Metadatum rda = getRelative(rdas, rdaMap, node.get("numbering").asText()); + if (rda != null) { + rda.setDescription(rdaValue.asText()); + } else { + rdas.stream().filter(rda1 -> rda1.getDescription() == null || rda1.getDescription().isEmpty()).forEach(rda1 -> rda1.setDescription(rdaValue.asText())); + } + } + break; + case LANGUAGE: + String language = rdaValue.asText(); + Metadatum.Language lang = Metadatum.Language.fromValue(language); + Metadatum rda = getRelative(rdas, rdaMap, node.get("numbering").asText()); + if (rda != null) { + rda.setLanguage(lang); + } else { + rdas.forEach(rda1 -> rda1.setLanguage(lang)); + } + break; + } + } + } + + } + + return rdas; + } + + public static Metadatum toRDA(JsonNode node) { + Metadatum rda = new Metadatum(); + String rdaProperty = node.get("rdaProperty").asText(); + JsonNode rdaValue = node.get("value"); + if (rdaProperty.contains("metadata_standard_id")) { + if (rdaValue instanceof ArrayNode) { + for (Iterator it = rdaValue.elements(); it.hasNext(); ) { + JsonNode data = it.next(); + if (data.get("uri") != null) { + rda.setMetadataStandardId(MetadataStandardIdRDAMapper.toRDA(data.get("uri").asText())); } } - } catch (IOException e) { - logger.error(e.getMessage(), e); } } else if (rdaProperty.contains("description")) { - rda.setDescription(properties.get(structure.get("id").asText()).asText()); + rda.setDescription(rdaValue.asText()); } else if (rdaProperty.contains("language")) { - String language = properties.get(structure.get("id").asText()).asText(); + String language = rdaValue.asText(); Metadatum.Language lang = Metadatum.Language.fromValue(language); rda.setLanguage(lang); } return rda; } + + private static Metadatum getRelative(List rdas, Map rdaMap, String numbering) { + String target = rdaMap.entrySet().stream().filter(entry -> MyStringUtils.getFirstDifference(entry.getValue(), numbering) > 0) + .max(Comparator.comparingInt(entry -> MyStringUtils.getFirstDifference(entry.getValue(), numbering))).map(Map.Entry::getKey).orElse(""); + return rdas.stream().filter(rda -> rda.getMetadataStandardId().getIdentifier().equals(target)).distinct().findFirst().orElse(null); + } + + private enum PropertyName { + METADATA_STANDARD_ID("metadata_standard_id"), + DESCRIPTION("description"), + LANGUAGE("language"); + + private final String name; + + PropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java index f7f95633f..fc44cc182 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java @@ -1,14 +1,45 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.logic.utilities.helpers.MyStringUtils; import eu.eudat.models.rda.SecurityAndPrivacy; +import java.util.*; + public class SecurityAndPrivacyRDAMapper { - public static SecurityAndPrivacy toRDA(JsonNode structure, JsonNode properties) { + public static List toRDAList(List nodes) { + Map rdaMap = new HashMap<>(); + + for (JsonNode node: nodes) { + String rdaProperty = node.get("rdaProperty").asText(); + String rdaValue = node.get("value").asText(); + + SecurityAndPrivacy rda = getRelative(rdaMap, node.get("numbering").asText()); + if (!rdaMap.containsValue(rda)) { + rdaMap.put(node.get("numbering").asText(), rda); + } + for (PropertyName propertyName: PropertyName.values()) { + if (rdaProperty.contains(propertyName.getName())) { + switch (propertyName) { + case TITLE: + rda.setTitle(rdaValue); + break; + case DESCRIPTION: + rda.setDescription(rdaValue); + break; + } + } + } + } + + return new ArrayList<>(rdaMap.values()); + } + + public static SecurityAndPrivacy toRDA(JsonNode node) { SecurityAndPrivacy rda = new SecurityAndPrivacy(); - String rdaProperty = structure.get("rdaProperty").asText(); - String value = properties.get(structure.get("id").asText()).asText(); + String rdaProperty = node.get("rdaProperty").asText(); + String value =node.get("value").asText(); if (rdaProperty.contains("description")) { rda.setDescription(value); @@ -18,4 +49,24 @@ public class SecurityAndPrivacyRDAMapper { return rda; } + + private static SecurityAndPrivacy getRelative(Map rdaMap, String numbering) { + return rdaMap.entrySet().stream().filter(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering) > 0) + .max(Comparator.comparingInt(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering))).map(Map.Entry::getValue).orElse(new SecurityAndPrivacy()); + } + + private enum PropertyName { + TITLE("title"), + DESCRIPTION("description"); + + private String name; + + PropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java index b2652901a..c48f93cae 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java @@ -1,14 +1,46 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.logic.utilities.helpers.MyStringUtils; +import eu.eudat.models.rda.SecurityAndPrivacy; import eu.eudat.models.rda.TechnicalResource; +import java.util.*; + public class TechnicalResourceRDAMapper { - public static TechnicalResource toRDA(JsonNode structure, JsonNode properties) { + public static List toRDAList(List nodes) { + Map rdaMap = new HashMap<>(); + + for (JsonNode node: nodes) { + String rdaProperty = node.get("rdaProperty").asText(); + String rdaValue = node.get("value").asText(); + + TechnicalResource rda = getRelative(rdaMap, node.get("numbering").asText()); + if (!rdaMap.containsValue(rda)) { + rdaMap.put(node.get("numbering").asText(), rda); + } + for (PropertyName propertyName: PropertyName.values()) { + if (rdaProperty.contains(propertyName.getName())) { + switch (propertyName) { + case NAME: + rda.setName(rdaValue); + break; + case DESCRIPTION: + rda.setDescription(rdaValue); + break; + } + } + } + } + + return new ArrayList<>(rdaMap.values()); + } + + public static TechnicalResource toRDA(JsonNode node) { TechnicalResource rda = new TechnicalResource(); - String rdaProperty = structure.get("rdaProperty").asText(); - String value = properties.get(structure.get("id").asText()).asText(); + String rdaProperty = node.get("rdaProperty").asText(); + String value = node.get("value").asText(); if (rdaProperty.contains("description")) { rda.setDescription(value); @@ -18,4 +50,24 @@ public class TechnicalResourceRDAMapper { return rda; } + + private static TechnicalResource getRelative(Map rdaMap, String numbering) { + return rdaMap.entrySet().stream().filter(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering) > 0) + .max(Comparator.comparingInt(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering))).map(Map.Entry::getValue).orElse(new TechnicalResource()); + } + + private enum PropertyName { + NAME("name"), + DESCRIPTION("description"); + + private String name; + + PropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + } } diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description-form.model.ts b/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description-form.model.ts index c4b8153b8..fd8824ba3 100644 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description-form.model.ts +++ b/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description-form.model.ts @@ -338,4 +338,4 @@ export class DatasetDescriptionDefaultValueEditorModel extends BaseFormModel { }); return formGroup; } -} \ No newline at end of file +} From 357ad4ecda96adb6c5847f4ba5b74aba8d192693 Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Tue, 24 Mar 2020 11:26:17 +0200 Subject: [PATCH 07/20] Minor bug fixes on the exporter --- .../src/main/java/eu/eudat/logic/managers/RDAManager.java | 2 +- .../java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java index eb10fd753..3a9f2f7a8 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java @@ -29,7 +29,7 @@ public class RDAManager { Dmp rdaDmp = dmpRDAMapper.toRDA(dmp); ObjectMapper mapper = new ObjectMapper(); - mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")); + mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss Z")); result = mapper.writeValueAsString(rdaDmp); diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java index 5eb9cc685..da04fe043 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java @@ -32,6 +32,7 @@ public class DatasetRDAMapper { rda.setDatasetId(DatasetIdRDAMapper.toRDA(dataset.getId())); rda.setTitle(dataset.getLabel()); rda.setDescription(dataset.getDescription()); +// rda.setAdditionalProperty("template", dataset.getProfile().getId()); try { DatasetWizardModel datasetWizardModel = new DatasetWizardModel().fromDataModel(dataset); @@ -57,7 +58,7 @@ public class DatasetRDAMapper { } List preservationNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.preservation_statement"); if (!preservationNodes.isEmpty()) { - rda.setDataQualityAssurance(preservationNodes.stream().map(preservationNode -> preservationNode.get("value").asText()).collect(Collectors.toList())); + rda.setPreservationStatement(preservationNodes.get(0).get("value").asText()); } List distributionNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.distribution"); if (!distributionNodes.isEmpty()) { @@ -77,7 +78,7 @@ public class DatasetRDAMapper { } List sensitiveDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.sensitive_data"); if (!sensitiveDataNodes.isEmpty()) { - rda.setSensitiveData(securityAndPrivacyNodes.stream().map(sensitiveDataNode -> Dataset.SensitiveData.fromValue(sensitiveDataNode.get("value").asText())).findFirst().get()); + rda.setSensitiveData(sensitiveDataNodes.stream().map(sensitiveDataNode -> Dataset.SensitiveData.fromValue(sensitiveDataNode.get("value").asText())).findFirst().get()); } List technicalResourceNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.technical_resource"); if (!technicalResourceNodes.isEmpty()) { From 463277b399df3bd7fefc71bb4328aeff49068352 Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Thu, 26 Mar 2020 18:39:25 +0200 Subject: [PATCH 08/20] Add RDA Import --- .../main/java/eu/eudat/controllers/DMPs.java | 11 +- .../managers/DataManagementPlanManager.java | 35 ++++++ .../eu/eudat/logic/managers/RDAManager.java | 9 ++ .../java/eu/eudat/models/rda/Dataset.java | 9 +- .../eu/eudat/models/rda/Distribution.java | 9 +- .../main/java/eu/eudat/models/rda/Dmp.java | 9 +- .../java/eu/eudat/models/rda/Metadatum.java | 9 +- .../eudat/models/rda/SecurityAndPrivacy.java | 9 +- .../eudat/models/rda/TechnicalResource.java | 9 +- .../models/rda/mapper/ContactIdRDAMapper.java | 4 + .../models/rda/mapper/ContactRDAMapper.java | 8 ++ .../models/rda/mapper/DatasetRDAMapper.java | 112 +++++++++++++++++- .../rda/mapper/DistributionRDAMapper.java | 97 ++++++++++++++- .../eudat/models/rda/mapper/DmpRDAMapper.java | 36 ++++-- .../models/rda/mapper/FundingRDAMapper.java | 9 +- .../models/rda/mapper/MetadataRDAMapper.java | 66 +++++++++++ .../models/rda/mapper/ProjectRDAMapper.java | 22 +++- .../mapper/SecurityAndPrivacyRDAMapper.java | 60 +++++++++- .../mapper/TechnicalResourceRDAMapper.java | 62 +++++++++- .../dmp-upload-dialogue.component.html | 2 +- 20 files changed, 531 insertions(+), 56 deletions(-) diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java index c87ce4590..0e25b98f6 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java @@ -53,6 +53,9 @@ import java.util.List; import java.util.Map; import java.util.UUID; +import static org.springframework.http.MediaType.APPLICATION_ATOM_XML; +import static org.springframework.http.MediaType.APPLICATION_JSON; + @RestController @CrossOrigin @@ -224,8 +227,12 @@ public class DMPs extends BaseController { } @RequestMapping(method = RequestMethod.POST, value = {"/upload"}) - public ResponseEntity dmpXmlUpload(@RequestParam("file") MultipartFile[] files, Principal principal) throws Exception { - this.dataManagementPlanManager.createDmpFromXml(this.getApiContext(), files, principal); + public ResponseEntity dmpUpload(@RequestParam("file") MultipartFile[] files, Principal principal) throws Exception { + if (files[0].getContentType().equals(APPLICATION_JSON.toString())) { + this.dataManagementPlanManager.createFromRDA(files, principal); + } else if (files[0].getContentType().equals(APPLICATION_ATOM_XML.toString())) { + this.dataManagementPlanManager.createDmpFromXml(this.getApiContext(), files, principal); + } return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem() .status(ApiMessageCode.SUCCESS_MESSAGE)); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java index 2710ec60c..c8dee4802 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java @@ -131,6 +131,13 @@ public class DataManagementPlanManager { if (fieldsGroup.equals("listing")) { itemsFuture = pagedItems.withHint(HintedModelFactory.getHint(DataManagementPlanListingModel.class)) .selectAsync(item -> { + if (item.getUsers().stream().noneMatch(userDMP -> userDMP.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue()))) { + for (UserDMP userDMP: item.getUsers()) { + userDMP.setRole(UserDMP.UserDMPRoles.OWNER.getValue()); + databaseRepository.getUserDmpDao().createOrUpdate(userDMP); + break; + } + } item.setDataset( item.getDataset().stream() .filter(dataset -> !dataset.getStatus().equals(Dataset.Status.DELETED.getValue()) && !dataset.getStatus().equals(Dataset.Status.CANCELED.getValue())).collect(Collectors.toList()).stream() @@ -1329,6 +1336,34 @@ public class DataManagementPlanManager { return dataManagementPlans; } + public List createFromRDA(MultipartFile[] files, Principal principal) throws IOException { + if (principal.getId() == null) { + throw new UnauthorisedException("No user is logged in"); + } + List result = new ArrayList<>(); + for (MultipartFile file: files) { + DMP dmp = rdaManager.convertToEntity(new String(file.getBytes(), "UTF-8")); + UserInfo me = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId()); + dmp.setModified(new Date()); + dmp.setCreator(me); + dmp.setVersion(0); + dmp.setStatus((short)0); + dmp.setGroupId(UUID.randomUUID()); + databaseRepository.getDmpDao().createOrUpdate(dmp); + assignUser(dmp, me); + dmp.getDataset().forEach(dataset -> { + dataset.setStatus(Dataset.Status.SAVED.getValue()); + dataset.setCreated(new Date()); + dataset.setModified(new Date()); + dataset.setDmp(dmp); + databaseRepository.getDatasetDao().createOrUpdate(dataset); + }); + result.add(dmp); + } + + return result; + } + public DataTableData getDatasetProfilesUsedByDMP(DatasetProfileTableRequestItem datasetProfileTableRequestItem, Principal principal) { datasetProfileTableRequestItem.getCriteria().setFilter(DatasetProfileCriteria.DatasetProfileFilter.DMPs.getValue()); datasetProfileTableRequestItem.getCriteria().setUserId(principal.getId()); diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java index 3a9f2f7a8..ff194455e 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java @@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import javax.transaction.Transactional; +import java.io.IOException; import java.text.SimpleDateFormat; @Component @@ -35,4 +36,12 @@ public class RDAManager { return result; } + + public DMP convertToEntity(String json) throws IOException { + ObjectMapper mapper = new ObjectMapper(); + mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss Z")); + + Dmp rda = mapper.readValue(json, Dmp.class); + return dmpRDAMapper.toEntity(rda); + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java index 43a7ac0cd..3c064965e 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java @@ -38,7 +38,8 @@ import com.fasterxml.jackson.annotation.JsonValue; "sensitive_data", "technical_resource", "title", - "type" + "type", + "additional_properties" }) public class Dataset implements Serializable { @@ -182,7 +183,7 @@ public class Dataset implements Serializable @JsonProperty("type") @JsonPropertyDescription("If appropriate, type according to: DataCite and/or COAR dictionary. Otherwise use the common name for the type, e.g. raw data, software, survey, etc. https://schema.datacite.org/meta/kernel-4.1/doc/DataCite-MetadataKernel_v4.1.pdf http://vocabularies.coar-repositories.org/pubby/resource_type.html") private String type; - @JsonIgnore + @JsonProperty("additional_properties") private Map additionalProperties = new HashMap(); private final static long serialVersionUID = -6931119120629009399L; @@ -524,12 +525,12 @@ public class Dataset implements Serializable this.type = type; } - @JsonAnyGetter + @JsonProperty("additional_properties") public Map getAdditionalProperties() { return this.additionalProperties; } - @JsonAnySetter + @JsonProperty("additional_properties") public void setAdditionalProperty(String name, Object value) { this.additionalProperties.put(name, value); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java index d005e7564..176931e9e 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java @@ -34,7 +34,8 @@ import com.fasterxml.jackson.annotation.JsonValue; "format", "host", "license", - "title" + "title", + "additional_properties" }) public class Distribution implements Serializable { @@ -131,7 +132,7 @@ public class Distribution implements Serializable @JsonProperty("title") @JsonPropertyDescription("Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file.") private String title; - @JsonIgnore + @JsonProperty("additional_properties") private Map additionalProperties = new HashMap(); private final static long serialVersionUID = -6018365280419917902L; @@ -359,12 +360,12 @@ public class Distribution implements Serializable this.title = title; } - @JsonAnyGetter + @JsonProperty("additional_properties") public Map getAdditionalProperties() { return this.additionalProperties; } - @JsonAnySetter + @JsonProperty("additional_properties") public void setAdditionalProperty(String name, Object value) { this.additionalProperties.put(name, value); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java index 7cac25d62..b53d26147 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java @@ -39,7 +39,8 @@ import com.fasterxml.jackson.annotation.JsonValue; "language", "modified", "project", - "title" + "title", + "additional_properties" }) public class Dmp implements Serializable { @@ -173,7 +174,7 @@ public class Dmp implements Serializable @JsonProperty("title") @JsonPropertyDescription("Title of a DMP") private String title; - @JsonIgnore + @JsonProperty("additional_properties") private Map additionalProperties = new HashMap(); private final static long serialVersionUID = 4599713332472772292L; @@ -499,12 +500,12 @@ public class Dmp implements Serializable this.title = title; } - @JsonAnyGetter + @JsonProperty("additional_properties") public Map getAdditionalProperties() { return this.additionalProperties; } - @JsonAnySetter + @JsonProperty("additional_properties") public void setAdditionalProperty(String name, Object value) { this.additionalProperties.put(name, value); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java index d6057ca62..56bee437d 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java @@ -25,7 +25,8 @@ import com.fasterxml.jackson.annotation.JsonValue; @JsonPropertyOrder({ "description", "language", - "metadata_standard_id" + "metadata_standard_id", + "additional_properties" }) public class Metadatum implements Serializable { @@ -58,7 +59,7 @@ public class Metadatum implements Serializable */ @JsonProperty("metadata_standard_id") private MetadataStandardId metadataStandardId; - @JsonIgnore + @JsonProperty("additional_properties") private Map additionalProperties = new HashMap(); private final static long serialVersionUID = 6511312853153406190L; @@ -132,12 +133,12 @@ public class Metadatum implements Serializable this.metadataStandardId = metadataStandardId; } - @JsonAnyGetter + @JsonProperty("additional_properties") public Map getAdditionalProperties() { return this.additionalProperties; } - @JsonAnySetter + @JsonProperty("additional_properties") public void setAdditionalProperty(String name, Object value) { this.additionalProperties.put(name, value); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java index 0486df588..245d202d0 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java @@ -22,7 +22,8 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonPropertyOrder({ "description", - "title" + "title", + "additional_properties" }) public class SecurityAndPrivacy implements Serializable { @@ -46,7 +47,7 @@ public class SecurityAndPrivacy implements Serializable @JsonProperty("title") @JsonPropertyDescription("Title") private String title; - @JsonIgnore + @JsonProperty("additional_properties") private Map additionalProperties = new HashMap(); private final static long serialVersionUID = 7863747935827682977L; @@ -96,12 +97,12 @@ public class SecurityAndPrivacy implements Serializable this.title = title; } - @JsonAnyGetter + @JsonProperty("additional_properties") public Map getAdditionalProperties() { return this.additionalProperties; } - @JsonAnySetter + @JsonProperty("additional_properties") public void setAdditionalProperty(String name, Object value) { this.additionalProperties.put(name, value); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java index eac85da72..c7bd2b055 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java @@ -22,7 +22,8 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonPropertyOrder({ "description", - "name" + "name", + "additional_properties" }) public class TechnicalResource implements Serializable { @@ -46,7 +47,7 @@ public class TechnicalResource implements Serializable @JsonProperty("name") @JsonPropertyDescription("Name of the technical resource") private String name; - @JsonIgnore + @JsonProperty("additional_properties") private Map additionalProperties = new HashMap(); private final static long serialVersionUID = -7451757227129483110L; @@ -96,12 +97,12 @@ public class TechnicalResource implements Serializable this.name = name; } - @JsonAnyGetter + @JsonProperty("additional_properties") public Map getAdditionalProperties() { return this.additionalProperties; } - @JsonAnySetter + @JsonProperty("additional_properties") public void setAdditionalProperty(String name, Object value) { this.additionalProperties.put(name, value); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java index 48549d75a..c9eac2009 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java @@ -12,4 +12,8 @@ public class ContactIdRDAMapper { rda.setType(ContactId.Type.OTHER); return rda; } + + public static UUID toEntity(ContactId rda) { + return UUID.fromString(rda.getIdentifier()); + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java index 69ea2310e..957fef8d4 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java @@ -13,4 +13,12 @@ public class ContactRDAMapper { rda.setContactId(ContactIdRDAMapper.toRDA(creator.getId())); return rda; } + + public static UserInfo toEntity(Contact rda) { + UserInfo entity = new UserInfo(); + entity.setId(ContactIdRDAMapper.toEntity(rda.getContactId())); + entity.setName(rda.getName()); + entity.setEmail(rda.getMbox()); + return entity; + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java index da04fe043..90aa4ec7c 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java @@ -2,28 +2,34 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import eu.eudat.data.entities.DatasetProfile; import eu.eudat.logic.managers.DatasetManager; +import eu.eudat.logic.services.ApiContext; import eu.eudat.logic.utilities.json.JsonSearcher; import eu.eudat.models.data.datasetwizard.DatasetWizardModel; import eu.eudat.models.rda.Dataset; +import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import javax.transaction.Transactional; -import java.util.List; +import java.util.*; import java.util.stream.Collectors; +import java.util.stream.Stream; @Component public class DatasetRDAMapper { private static final Logger logger = LoggerFactory.getLogger(DatasetRDAMapper.class); private DatasetManager datasetManager; + private ApiContext apiContext; @Autowired - public DatasetRDAMapper(DatasetManager datasetManager) { + public DatasetRDAMapper(DatasetManager datasetManager, ApiContext apiContext) { this.datasetManager = datasetManager; + this.apiContext = apiContext; } @Transactional @@ -32,9 +38,10 @@ public class DatasetRDAMapper { rda.setDatasetId(DatasetIdRDAMapper.toRDA(dataset.getId())); rda.setTitle(dataset.getLabel()); rda.setDescription(dataset.getDescription()); -// rda.setAdditionalProperty("template", dataset.getProfile().getId()); + rda.setAdditionalProperty("template", dataset.getProfile().getId()); try { - + JSONObject jObject = new JSONObject(dataset.getProperties()); + Map templateIdsToValues = jObject.toMap(); DatasetWizardModel datasetWizardModel = new DatasetWizardModel().fromDataModel(dataset); datasetWizardModel.setDatasetProfileDefinition(datasetManager.getPagedProfile(datasetWizardModel, dataset)); ObjectMapper mapper = new ObjectMapper(); @@ -55,6 +62,9 @@ public class DatasetRDAMapper { List qaNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.data_quality_assurance"); if (!qaNodes.isEmpty()) { rda.setDataQualityAssurance(qaNodes.stream().map(qaNode -> qaNode.get("value").asText()).collect(Collectors.toList())); + for (int i = 0; i < qaNodes.size(); i++) { + rda.setAdditionalProperty("qa" + (i + 1), qaNodes.get(i).get("id").asText()); + } } List preservationNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.preservation_statement"); if (!preservationNodes.isEmpty()) { @@ -67,6 +77,9 @@ public class DatasetRDAMapper { List keywordNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.keyword"); if (!keywordNodes.isEmpty()) { rda.setKeyword(keywordNodes.stream().map(keywordNode -> keywordNode.get("value").asText()).collect(Collectors.toList())); + for (int i = 0; i < keywordNodes.size(); i++) { + rda.setAdditionalProperty("keyword" + (i + 1), keywordNodes.get(i).get("id").asText()); + } } List personalDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.personal_data"); if (!personalDataNodes.isEmpty()) { @@ -84,6 +97,14 @@ public class DatasetRDAMapper { if (!technicalResourceNodes.isEmpty()) { rda.setTechnicalResource(TechnicalResourceRDAMapper.toRDAList(technicalResourceNodes)); } + List foundNodes = Stream.of(typeNodes, languageNodes, metadataNodes, qaNodes, preservationNodes, distributionNodes, + keywordNodes, personalDataNodes, securityAndPrivacyNodes, sensitiveDataNodes, technicalResourceNodes).flatMap(Collection::stream).collect(Collectors.toList()); + templateIdsToValues.entrySet().forEach(entry -> { + boolean isFound = foundNodes.stream().anyMatch(node -> node.get("id").asText().equals(entry.getKey())); + if (!isFound && entry.getValue() != null && !entry.getValue().toString().isEmpty()) { + rda.setAdditionalProperty(entry.getKey(), entry.getValue()); + } + }); } catch (Exception e) { @@ -93,4 +114,87 @@ public class DatasetRDAMapper { return rda; } + + + public eu.eudat.data.entities.Dataset toEntity(Dataset rda) { + eu.eudat.data.entities.Dataset entity = new eu.eudat.data.entities.Dataset(); + entity.setLabel(rda.getTitle()); + entity.setDescription(rda.getDescription()); + try { + DatasetProfile profile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(rda.getAdditionalProperties().get("template").toString())); + entity.setProfile(profile); + }catch(Exception e) { + logger.warn(e.getMessage(), e); + } + try { + Map properties = new HashMap<>(); + DatasetWizardModel datasetWizardModel = new DatasetWizardModel(); + datasetWizardModel.setProfile(entity.getProfile().getId()); + datasetWizardModel.setDatasetProfileDefinition(datasetManager.getPagedProfile(datasetWizardModel, entity)); + ObjectMapper mapper = new ObjectMapper(); + String datasetDescriptionJson = mapper.writeValueAsString(datasetWizardModel.getDatasetProfileDefinition()); + JsonNode datasetDescriptionObj = mapper.readTree(datasetDescriptionJson); + + List typeNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.type"); + if (!typeNodes.isEmpty()) { + properties.put(typeNodes.get(0).get("id").asText(), rda.getType()); + } + + List languageNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.language"); + if (!languageNodes.isEmpty()) { + properties.put(languageNodes.get(0).get("id").asText(), rda.getLanguage().value()); + } + + if (rda.getMetadata() != null) { + properties.putAll(MetadataRDAMapper.toProperties(rda.getMetadata())); + } + + List qaIds = rda.getAdditionalProperties().entrySet().stream().filter(entry -> entry.getKey().startsWith("qa")).map(entry -> entry.getValue().toString()).collect(Collectors.toList()); + for (int i = 0; i < qaIds.size(); i++) { + properties.put(qaIds.get(i), rda.getDataQualityAssurance().get(i)); + } + + List preservationNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.preservation_statement"); + if (!preservationNodes.isEmpty()) { + properties.put(preservationNodes.get(0).get("id").asText(), rda.getPreservationStatement()); + } + + if (rda.getDistribution() != null) { + properties.putAll(DistributionRDAMapper.toProperties(rda.getDistribution())); + } + + List keywordIds = rda.getAdditionalProperties().entrySet().stream().filter(entry -> entry.getKey().startsWith("keyword")).map(entry -> entry.getValue().toString()).collect(Collectors.toList()); + for (int i = 0; i < keywordIds.size(); i++) { + properties.put(keywordIds.get(i), rda.getKeyword().get(i)); + } + + List personalDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.personal_data"); + if (!personalDataNodes.isEmpty()) { + properties.put(personalDataNodes.get(0).get("id").asText(), rda.getPersonalData().value()); + } + + if (rda.getSecurityAndPrivacy() != null) { + properties.putAll(SecurityAndPrivacyRDAMapper.toProperties(rda.getSecurityAndPrivacy())); + } + + List sensitiveDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.sensitive_data"); + if (!sensitiveDataNodes.isEmpty()) { + properties.put(sensitiveDataNodes.get(0).get("id").asText(), rda.getSensitiveData().value()); + } + + if (rda.getTechnicalResource() != null) { + properties.putAll(TechnicalResourceRDAMapper.toProperties(rda.getTechnicalResource())); + } + + rda.getAdditionalProperties().entrySet().stream() + .filter(entry -> !entry.getKey().equals("template") && !entry.getKey().startsWith("qa") && !entry.getKey().startsWith("keyword")) + .forEach(entry -> properties.put(entry.getKey(), entry.getValue())); + entity.setProperties(new ObjectMapper().writeValueAsString(properties)); + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + + + return entity; + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java index 98cb6960b..566288452 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java @@ -1,13 +1,17 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; +import com.lowagie.text.ExceptionConverter; import eu.eudat.logic.utilities.helpers.MyStringUtils; import eu.eudat.models.rda.Distribution; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.net.URI; import java.util.*; public class DistributionRDAMapper { + private static final Logger logger = LoggerFactory.getLogger(DistributionRDAMapper.class); public static List toRDAList(List nodes) { Map rdaMap = new HashMap<>(); @@ -19,35 +23,43 @@ public class DistributionRDAMapper { if (!rdaMap.containsValue(rda)) { rdaMap.put(node.get("numbering").asText(), rda); } - for (PropertyName propertyName : PropertyName.values()) { - if (rdaProperty.contains(propertyName.getName())) { - switch (propertyName) { + for (ExportPropertyName exportPropertyName : ExportPropertyName.values()) { + if (rdaProperty.contains(exportPropertyName.getName())) { + switch (exportPropertyName) { case ACCESS_URL: rda.setAccessUrl(rdaValue); + rda.setAdditionalProperty(ImportPropertyName.ACCESS_URL.getName(), node.get("id").asText()); break; case AVAILABLE_UTIL: rda.setAvailableUntil(rdaValue); + rda.setAdditionalProperty(ImportPropertyName.AVAILABLE_UTIL.getName(), node.get("id").asText()); break; case DOWNLOAD_URL: rda.setDownloadUrl(URI.create(rdaValue)); + rda.setAdditionalProperty(ImportPropertyName.DOWNLOAD_URL.getName(), node.get("id").asText()); break; case DESCRIPTION: rda.setDescription(rdaValue); + rda.setAdditionalProperty(ImportPropertyName.DESCRIPTION.getName(), node.get("id").asText()); break; case DATA_ACCESS: rda.setDataAccess(Distribution.DataAccess.fromValue(rdaValue)); + rda.setAdditionalProperty(ImportPropertyName.DATA_ACCESS.getName(), node.get("id").asText()); break; case BYTE_SIZE: rda.setByteSize(Integer.parseInt(rdaValue)); + rda.setAdditionalProperty(ImportPropertyName.BYTE_SIZE.getName(), node.get("id").asText()); break; case LICENSE: rda.setLicense(Collections.singletonList(LicenseRDAMapper.toRDA(node))); break; case FORMAT: rda.setFormat(Collections.singletonList(rdaValue)); + rda.setAdditionalProperty(ImportPropertyName.FORMAT.getName(), node.get("id").asText()); break; case TITLE: rda.setTitle(rdaValue); + rda.setAdditionalProperty(ImportPropertyName.TITLE.getName(), node.get("id").asText()); break; case HOST: rda.setHost(HostRDAMapper.toRDA(nodes, node.get("numbering").asText())); @@ -60,6 +72,49 @@ public class DistributionRDAMapper { return new ArrayList<>(rdaMap.values()); } + public static Map toProperties(List rdas) { + Map properties = new HashMap<>(); + + rdas.forEach(rda -> { + rda.getAdditionalProperties().entrySet().forEach(entry -> { + try { + ImportPropertyName importPropertyName = ImportPropertyName.fromString(entry.getKey()); + switch (importPropertyName) { + case ACCESS_URL: + properties.put(entry.getValue().toString(), rda.getAccessUrl()); + break; + case TITLE: + properties.put(entry.getValue().toString(), rda.getTitle()); + break; + case DESCRIPTION: + properties.put(entry.getValue().toString(), rda.getDescription()); + break; + case FORMAT: + properties.put(entry.getValue().toString(), rda.getFormat().get(0)); + break; + case BYTE_SIZE: + properties.put(entry.getValue().toString(), rda.getByteSize().toString()); + break; + case DATA_ACCESS: + properties.put(entry.getValue().toString(), rda.getDataAccess().value()); + break; + case DOWNLOAD_URL: + properties.put(entry.getValue().toString(), rda.getDownloadUrl().toString()); + break; + case AVAILABLE_UTIL: + properties.put(entry.getValue().toString(), rda.getAvailableUntil()); + break; + } + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + + }); + }); + + return properties; + } + public static Distribution toRDA(JsonNode node) { Distribution rda = new Distribution(); String rdaProperty = node.get("rdaProperty").asText(); @@ -95,7 +150,7 @@ public class DistributionRDAMapper { .max(Comparator.comparingInt(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering))).map(Map.Entry::getValue).orElse(new Distribution()); } - private enum PropertyName { + private enum ExportPropertyName { ACCESS_URL("access_url"), AVAILABLE_UTIL("available_util"), BYTE_SIZE("byte_size"), @@ -109,7 +164,7 @@ public class DistributionRDAMapper { private final String name; - PropertyName(String name) { + ExportPropertyName(String name) { this.name = name; } @@ -117,4 +172,36 @@ public class DistributionRDAMapper { return name; } } + + private enum ImportPropertyName { + ACCESS_URL("accessurlId"), + AVAILABLE_UTIL("availableUtilId"), + BYTE_SIZE("byteSizeId"), + DATA_ACCESS("dataAccessId"), + DESCRIPTION("descriptionId"), + DOWNLOAD_URL("downloadUrlId"), + FORMAT("formatId"), + /*HOST("host"), + LICENSE("license"),*/ + TITLE("titleId"); + + private final String name; + + ImportPropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public static ImportPropertyName fromString(String name) throws Exception { + for (ImportPropertyName importPropertyName: ImportPropertyName.values()) { + if (importPropertyName.getName().equals(name)) { + return importPropertyName; + } + } + throw new Exception("No name available"); + } + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java index 620229a27..7176f3b8d 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java @@ -1,24 +1,26 @@ package eu.eudat.models.rda.mapper; -import eu.eudat.data.entities.DMP; -import eu.eudat.data.entities.UserDMP; -import eu.eudat.data.entities.UserInfo; +import eu.eudat.data.entities.*; +import eu.eudat.logic.services.ApiContext; import eu.eudat.models.rda.Dmp; +import eu.eudat.models.rda.DmpId; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import javax.transaction.Transactional; -import java.util.Collections; +import java.util.*; import java.util.stream.Collectors; @Component public class DmpRDAMapper { private DatasetRDAMapper datasetRDAMapper; + private ApiContext apiContext; @Autowired - public DmpRDAMapper(DatasetRDAMapper datasetRDAMapper) { + public DmpRDAMapper(DatasetRDAMapper datasetRDAMapper, ApiContext apiContext) { this.datasetRDAMapper = datasetRDAMapper; + this.apiContext = apiContext; } @Transactional @@ -44,8 +46,28 @@ public class DmpRDAMapper { rda.setContributor(dmp.getUsers().stream().map(ContributorRDAMapper::toRDA).collect(Collectors.toList())); rda.setDataset(dmp.getDataset().stream().map(dataset -> datasetRDAMapper.toRDA(dataset)).collect(Collectors.toList())); rda.setProject(Collections.singletonList(ProjectRDAMapper.toRDA(dmp.getProject(), dmp.getGrant()))); - - + rda.setAdditionalProperty("templates", dmp.getAssociatedDmps().stream().map(datasetProfile -> datasetProfile.getId().toString()).toArray()); return rda; } + + public DMP toEntity(Dmp rda) { + DMP entity = new DMP(); + entity.setLabel(rda.getTitle()); + if (rda.getDmpId().getType() == DmpId.Type.DOI) { + entity.setDoi(rda.getDmpId().getIdentifier()); + } + entity.setCreated(rda.getCreated()); + entity.setModified(rda.getModified()); + entity.setDescription(rda.getDescription()); + entity.setDataset(rda.getDataset().stream().map(rda1 -> datasetRDAMapper.toEntity(rda1)).collect(Collectors.toSet())); + Map result = ProjectRDAMapper.toEntity(rda.getProject().get(0), apiContext); + entity.setProject((Project) result.get("project")); + result.entrySet().stream().filter(entry -> entry.getKey().startsWith("grant")).forEach(entry -> entity.setGrant((Grant) entry.getValue())); + entity.setAssociatedDmps(((List) rda.getAdditionalProperties().get("templates")).stream().map(this::getProfile).collect(Collectors.toSet())); + return entity; + } + + private DatasetProfile getProfile(String id) { + return apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id)); + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java index e0b8fbe65..2dd3f6cc2 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java @@ -1,7 +1,8 @@ package eu.eudat.models.rda.mapper; -import eu.eudat.data.entities.Funder; +import eu.eudat.data.dao.criteria.GrantCriteria; import eu.eudat.data.entities.Grant; +import eu.eudat.logic.services.ApiContext; import eu.eudat.models.rda.Funding; public class FundingRDAMapper { @@ -22,4 +23,10 @@ public class FundingRDAMapper { rda.setGrantId(GrantIdRDAMapper.toRDA(shortReference)); return rda; } + + public static Grant toEntity(Funding rda, ApiContext apiContext) { + GrantCriteria criteria = new GrantCriteria(); + criteria.setReference(rda.getGrantId().getIdentifier()); + return apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().getWithCriteria(criteria).getSingle(); + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java index c7e3ba35f..49bbbb527 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java @@ -11,6 +11,7 @@ import org.slf4j.LoggerFactory; import java.io.IOException; import java.util.*; +import java.util.stream.Collectors; public class MetadataRDAMapper { private static final Logger logger = LoggerFactory.getLogger(MetadataRDAMapper.class); @@ -36,6 +37,7 @@ public class MetadataRDAMapper { rdas.add(new Metadatum()); rdas.get(rdas.size() - 1).setMetadataStandardId(MetadataStandardIdRDAMapper.toRDA(data.get("uri").asText())); rdas.get(rdas.size() - 1).setDescription(data.get("label").asText()); + rdas.get(rdas.size() - 1).setAdditionalProperty("fieldId", node.get("id").asText()); rdaMap.put(data.get("uri").asText(), node.get("numbering").asText()); } } @@ -45,6 +47,7 @@ public class MetadataRDAMapper { } else if (rdaValue instanceof TextNode && rdaProperty.contains("identifier") && !rdaValue.asText().isEmpty()) { rdas.add(new Metadatum()); rdas.get(rdas.size() - 1).setMetadataStandardId(MetadataStandardIdRDAMapper.toRDA(rdaValue.asText())); + rdas.get(rdas.size() - 1).setAdditionalProperty("identifierId", node.get("id").asText()); rdaMap.put(rdaValue.asText(), node.get("numbering").asText()); } break; @@ -53,6 +56,7 @@ public class MetadataRDAMapper { Metadatum rda = getRelative(rdas, rdaMap, node.get("numbering").asText()); if (rda != null) { rda.setDescription(rdaValue.asText()); + rda.setAdditionalProperty("descriptionId", node.get("id").asText()); } else { rdas.stream().filter(rda1 -> rda1.getDescription() == null || rda1.getDescription().isEmpty()).forEach(rda1 -> rda1.setDescription(rdaValue.asText())); } @@ -64,6 +68,7 @@ public class MetadataRDAMapper { Metadatum rda = getRelative(rdas, rdaMap, node.get("numbering").asText()); if (rda != null) { rda.setLanguage(lang); + rda.setAdditionalProperty("languageId", node.get("id").asText()); } else { rdas.forEach(rda1 -> rda1.setLanguage(lang)); } @@ -77,6 +82,40 @@ public class MetadataRDAMapper { return rdas; } + public static Map toProperties(List rdas) { + Map properties = new HashMap<>(); + List standardIds = new ArrayList<>(); + ObjectMapper mapper = new ObjectMapper(); + rdas.forEach(rda -> { + rda.getAdditionalProperties().entrySet().forEach(entry -> { + try { + switch (entry.getKey()) { + case "fieldId": + Map metadata = toMap(rda); + standardIds.add(metadata); + properties.put(entry.getValue().toString(), mapper.writeValueAsString(standardIds)); + break; + case "identifierId": + properties.put(entry.getValue().toString(), rda.getMetadataStandardId().getIdentifier()); + break; + case "descriptionId": + properties.put(entry.getValue().toString(), rda.getDescription()); + break; + case "languageId": + if (rda.getLanguage() != null) { + properties.put(entry.getValue().toString(), rda.getLanguage().value()); + } + break; + } + }catch (Exception e) { + logger.error(e.getMessage(), e); + } + }); + }); + + return properties; + } + public static Metadatum toRDA(JsonNode node) { Metadatum rda = new Metadatum(); String rdaProperty = node.get("rdaProperty").asText(); @@ -122,4 +161,31 @@ public class MetadataRDAMapper { return name; } } + + private static Map toMap(Metadatum rda) { + Map result = new HashMap<>(); + + ObjectMapper mapper = new ObjectMapper(); + + Map metadata = mapper.convertValue(rda, Map.class); + + Map metadataStandardId = mapper.convertValue(metadata.get("metadata_standard_id"), Map.class); + + String url = metadataStandardId.remove("identifier"); + metadataStandardId.remove("type"); + metadataStandardId.put("uri", url); + + metadata.remove("additional_properties"); + metadata.remove("metadata_standard_id"); + + Map newMetadata = metadata.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue().toString())); + + String label = newMetadata.remove("description"); + newMetadata.put("label", label); + + result.putAll(newMetadata); + result.putAll(metadataStandardId); + + return result; + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java index d97eace4a..b21a9403c 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java @@ -2,9 +2,10 @@ package eu.eudat.models.rda.mapper; import eu.eudat.data.entities.Funder; import eu.eudat.data.entities.Grant; +import eu.eudat.logic.services.ApiContext; import eu.eudat.models.rda.Project; -import java.util.Collections; +import java.util.*; public class ProjectRDAMapper { @@ -22,4 +23,23 @@ public class ProjectRDAMapper { return rda; } + + public static Map toEntity(Project rda, ApiContext apiContext) { + Map entities = new HashMap<>(); + + entities.put("project", new eu.eudat.data.entities.Project()); + ((eu.eudat.data.entities.Project) entities.get("project")).setLabel(rda.getTitle()); + ((eu.eudat.data.entities.Project) entities.get("project")).setDescription(rda.getDescription()); + ((eu.eudat.data.entities.Project) entities.get("project")).setId(UUID.randomUUID()); + ((eu.eudat.data.entities.Project) entities.get("project")).setStatus((short)1); + ((eu.eudat.data.entities.Project) entities.get("project")).setCreated(new Date()); + ((eu.eudat.data.entities.Project) entities.get("project")).setModified(new Date()); + ((eu.eudat.data.entities.Project) entities.get("project")).setType(0); + apiContext.getOperationsContext().getDatabaseRepository().getProjectDao().createOrUpdate(((eu.eudat.data.entities.Project) entities.get("project"))); + for (int i = 0; i < rda.getFunding().size(); i++) { + entities.put("grant" + (i + 1), FundingRDAMapper.toEntity(rda.getFunding().get(i), apiContext)); + } + + return entities; + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java index fc44cc182..3b5d28649 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java @@ -3,10 +3,13 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; import eu.eudat.logic.utilities.helpers.MyStringUtils; import eu.eudat.models.rda.SecurityAndPrivacy; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.*; public class SecurityAndPrivacyRDAMapper { + private static final Logger logger = LoggerFactory.getLogger(SecurityAndPrivacyRDAMapper.class); public static List toRDAList(List nodes) { Map rdaMap = new HashMap<>(); @@ -19,14 +22,16 @@ public class SecurityAndPrivacyRDAMapper { if (!rdaMap.containsValue(rda)) { rdaMap.put(node.get("numbering").asText(), rda); } - for (PropertyName propertyName: PropertyName.values()) { - if (rdaProperty.contains(propertyName.getName())) { - switch (propertyName) { + for (ExportPropertyName exportPropertyName : ExportPropertyName.values()) { + if (rdaProperty.contains(exportPropertyName.getName())) { + switch (exportPropertyName) { case TITLE: rda.setTitle(rdaValue); + rda.getAdditionalProperties().put(ImportPropertyName.TITLE.getName(), node.get("id").asText()); break; case DESCRIPTION: rda.setDescription(rdaValue); + rda.getAdditionalProperties().put(ImportPropertyName.DESCRIPTION.getName(), node.get("id").asText()); break; } } @@ -36,6 +41,27 @@ public class SecurityAndPrivacyRDAMapper { return new ArrayList<>(rdaMap.values()); } + public static Map toProperties(List rdas) { + Map properties = new HashMap<>(); + rdas.forEach(rda -> rda.getAdditionalProperties().entrySet().forEach(entry -> { + try { + ImportPropertyName importPropertyName = ImportPropertyName.fromString(entry.getKey()); + switch(importPropertyName) { + case TITLE: + properties.put(entry.getValue().toString(), rda.getTitle()); + break; + case DESCRIPTION: + properties.put(entry.getValue().toString(), rda.getDescription()); + break; + } + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + })); + + return properties; + } + public static SecurityAndPrivacy toRDA(JsonNode node) { SecurityAndPrivacy rda = new SecurityAndPrivacy(); String rdaProperty = node.get("rdaProperty").asText(); @@ -55,13 +81,13 @@ public class SecurityAndPrivacyRDAMapper { .max(Comparator.comparingInt(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering))).map(Map.Entry::getValue).orElse(new SecurityAndPrivacy()); } - private enum PropertyName { + private enum ExportPropertyName { TITLE("title"), DESCRIPTION("description"); private String name; - PropertyName(String name) { + ExportPropertyName(String name) { this.name = name; } @@ -69,4 +95,28 @@ public class SecurityAndPrivacyRDAMapper { return name; } } + + private enum ImportPropertyName { + TITLE("titleId"), + DESCRIPTION("descriptionId"); + + private String name; + + ImportPropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public static ImportPropertyName fromString(String name) throws Exception { + for (ImportPropertyName importPropertyName: ImportPropertyName.values()) { + if (importPropertyName.getName().equals(name)) { + return importPropertyName; + } + } + throw new Exception("Property not available"); + } + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java index c48f93cae..cd764c302 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java @@ -2,12 +2,14 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; import eu.eudat.logic.utilities.helpers.MyStringUtils; -import eu.eudat.models.rda.SecurityAndPrivacy; import eu.eudat.models.rda.TechnicalResource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.*; public class TechnicalResourceRDAMapper { + private static final Logger logger = LoggerFactory.getLogger(TechnicalResourceRDAMapper.class); public static List toRDAList(List nodes) { Map rdaMap = new HashMap<>(); @@ -20,14 +22,16 @@ public class TechnicalResourceRDAMapper { if (!rdaMap.containsValue(rda)) { rdaMap.put(node.get("numbering").asText(), rda); } - for (PropertyName propertyName: PropertyName.values()) { - if (rdaProperty.contains(propertyName.getName())) { - switch (propertyName) { + for (ExportPropertyName exportPropertyName : ExportPropertyName.values()) { + if (rdaProperty.contains(exportPropertyName.getName())) { + switch (exportPropertyName) { case NAME: rda.setName(rdaValue); + rda.setAdditionalProperty(ImportPropertyName.NAME.getName(), node.get("id").asText()); break; case DESCRIPTION: rda.setDescription(rdaValue); + rda.setAdditionalProperty(ImportPropertyName.DESCRIPTION.getName(), node.get("id").asText()); break; } } @@ -37,6 +41,28 @@ public class TechnicalResourceRDAMapper { return new ArrayList<>(rdaMap.values()); } + public static Map toProperties(List rdas) { + Map properties = new HashMap<>(); + + rdas.forEach(rda -> rda.getAdditionalProperties().entrySet().forEach(entry -> { + try { + ImportPropertyName importPropertyName = ImportPropertyName.fromString(entry.getKey()); + switch(importPropertyName) { + case DESCRIPTION: + properties.put(entry.getValue().toString(), rda.getDescription()); + break; + case NAME: + properties.put(entry.getValue().toString(), rda.getName()); + break; + } + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + })); + + return properties; + } + public static TechnicalResource toRDA(JsonNode node) { TechnicalResource rda = new TechnicalResource(); String rdaProperty = node.get("rdaProperty").asText(); @@ -56,13 +82,13 @@ public class TechnicalResourceRDAMapper { .max(Comparator.comparingInt(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering))).map(Map.Entry::getValue).orElse(new TechnicalResource()); } - private enum PropertyName { + private enum ExportPropertyName { NAME("name"), DESCRIPTION("description"); private String name; - PropertyName(String name) { + ExportPropertyName(String name) { this.name = name; } @@ -70,4 +96,28 @@ public class TechnicalResourceRDAMapper { return name; } } + + private enum ImportPropertyName { + NAME("nameId"), + DESCRIPTION("descriptionId"); + + private String name; + + ImportPropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public static ImportPropertyName fromString(String name) throws Exception { + for (ImportPropertyName importPropertyName: ImportPropertyName.values()) { + if (importPropertyName.getName().equals(name)) { + return importPropertyName; + } + } + throw new Exception("Property name not available"); + } + } } diff --git a/dmp-frontend/src/app/ui/dmp/listing/upload-dialogue/dmp-upload-dialogue.component.html b/dmp-frontend/src/app/ui/dmp/listing/upload-dialogue/dmp-upload-dialogue.component.html index 81779fadc..f9669094e 100644 --- a/dmp-frontend/src/app/ui/dmp/listing/upload-dialogue/dmp-upload-dialogue.component.html +++ b/dmp-frontend/src/app/ui/dmp/listing/upload-dialogue/dmp-upload-dialogue.component.html @@ -7,7 +7,7 @@ - +
From db99cfe63dd205476132c889d88c4a1058cf9fed Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Fri, 27 Mar 2020 10:50:37 +0200 Subject: [PATCH 09/20] Small bugfix for RDA Import --- .../java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java index 90aa4ec7c..eef6eb6ed 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java @@ -63,7 +63,7 @@ public class DatasetRDAMapper { if (!qaNodes.isEmpty()) { rda.setDataQualityAssurance(qaNodes.stream().map(qaNode -> qaNode.get("value").asText()).collect(Collectors.toList())); for (int i = 0; i < qaNodes.size(); i++) { - rda.setAdditionalProperty("qa" + (i + 1), qaNodes.get(i).get("id").asText()); + rda.setAdditionalProperty("qaId" + (i + 1), qaNodes.get(i).get("id").asText()); } } List preservationNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.preservation_statement"); @@ -149,7 +149,7 @@ public class DatasetRDAMapper { properties.putAll(MetadataRDAMapper.toProperties(rda.getMetadata())); } - List qaIds = rda.getAdditionalProperties().entrySet().stream().filter(entry -> entry.getKey().startsWith("qa")).map(entry -> entry.getValue().toString()).collect(Collectors.toList()); + List qaIds = rda.getAdditionalProperties().entrySet().stream().filter(entry -> entry.getKey().startsWith("qaId")).map(entry -> entry.getValue().toString()).collect(Collectors.toList()); for (int i = 0; i < qaIds.size(); i++) { properties.put(qaIds.get(i), rda.getDataQualityAssurance().get(i)); } @@ -187,7 +187,7 @@ public class DatasetRDAMapper { } rda.getAdditionalProperties().entrySet().stream() - .filter(entry -> !entry.getKey().equals("template") && !entry.getKey().startsWith("qa") && !entry.getKey().startsWith("keyword")) + .filter(entry -> !entry.getKey().equals("template") && !entry.getKey().startsWith("qaId") && !entry.getKey().startsWith("keyword")) .forEach(entry -> properties.put(entry.getKey(), entry.getValue())); entity.setProperties(new ObjectMapper().writeValueAsString(properties)); } catch (Exception e) { From e8dcb6bd0ff9402a3d7f18cdd061adaf09b7b0f2 Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Fri, 20 Mar 2020 18:20:22 +0200 Subject: [PATCH 10/20] Add new RDA exporter --- .../managers/DataManagementPlanManager.java | 13 +- .../logic/managers/DatasetProfileManager.java | 4 +- .../eu/eudat/logic/managers/RDAManager.java | 38 + .../logic/utilities/json/JsonSearcher.java | 32 + .../commons/datafield/AutoCompleteData.java | 2 + .../commons/datafield/ComboBoxData.java | 11 + .../ExternalAutocompleteFieldModel.java | 12 +- .../data/rda/DatasetRDAExportModel.java | 3 +- .../java/eu/eudat/models/rda/Contact.java | 146 +++ .../java/eu/eudat/models/rda/ContactId.java | 154 ++++ .../java/eu/eudat/models/rda/Contributor.java | 181 ++++ .../eu/eudat/models/rda/ContributorId.java | 155 ++++ .../main/java/eu/eudat/models/rda/Cost.java | 374 ++++++++ .../java/eu/eudat/models/rda/Dataset.java | 839 ++++++++++++++++++ .../java/eu/eudat/models/rda/DatasetId.java | 156 ++++ .../eu/eudat/models/rda/Distribution.java | 412 +++++++++ .../main/java/eu/eudat/models/rda/Dmp.java | 774 ++++++++++++++++ .../main/java/eu/eudat/models/rda/DmpId.java | 156 ++++ .../java/eu/eudat/models/rda/FunderId.java | 154 ++++ .../java/eu/eudat/models/rda/Funding.java | 187 ++++ .../java/eu/eudat/models/rda/GrantId.java | 153 ++++ .../main/java/eu/eudat/models/rda/Host.java | 775 ++++++++++++++++ .../java/eu/eudat/models/rda/License.java | 113 +++ .../eudat/models/rda/MetadataStandardId.java | 153 ++++ .../java/eu/eudat/models/rda/Metadatum.java | 368 ++++++++ .../java/eu/eudat/models/rda/PidSystem.java | 63 ++ .../java/eu/eudat/models/rda/Project.java | 212 +++++ .../java/eu/eudat/models/rda/RDAModel.java | 58 ++ .../eudat/models/rda/SecurityAndPrivacy.java | 109 +++ .../eudat/models/rda/TechnicalResource.java | 109 +++ .../models/rda/mapper/ContactIdRDAMapper.java | 15 + .../models/rda/mapper/ContactRDAMapper.java | 16 + .../rda/mapper/ContributorIdRDAMapper.java | 16 + .../rda/mapper/ContributorRDAMapper.java | 20 + .../models/rda/mapper/DatasetIdRDAMapper.java | 17 + .../models/rda/mapper/DatasetRDAMapper.java | 100 +++ .../rda/mapper/DistributionRDAMapper.java | 39 + .../models/rda/mapper/DmpIdRDAMapper.java | 19 + .../eudat/models/rda/mapper/DmpRDAMapper.java | 51 ++ .../models/rda/mapper/FunderIdRDAMapper.java | 19 + .../models/rda/mapper/FundingRDAMapper.java | 25 + .../models/rda/mapper/GrantIdRDAMapper.java | 13 + .../models/rda/mapper/HostRDAMapper.java | 41 + .../models/rda/mapper/LicenseRDAMapper.java | 23 + .../models/rda/mapper/MetadataRDAMapper.java | 44 + .../mapper/MetadataStandardIdRDAMapper.java | 13 + .../models/rda/mapper/ProjectRDAMapper.java | 25 + .../mapper/SecurityAndPrivacyRDAMapper.java | 21 + .../mapper/TechnicalResourceRDAMapper.java | 21 + 49 files changed, 6447 insertions(+), 7 deletions(-) create mode 100644 dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Contact.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/ContactId.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Contributor.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/ContributorId.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Cost.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/DatasetId.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/DmpId.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/FunderId.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Funding.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/GrantId.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Host.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/License.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/MetadataStandardId.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/PidSystem.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Project.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/RDAModel.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorIdRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetIdRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpIdRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FunderIdRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/GrantIdRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataStandardIdRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java index e88e48524..2710ec60c 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java @@ -105,14 +105,16 @@ public class DataManagementPlanManager { private UtilitiesService utilitiesService; private DatabaseRepository databaseRepository; private Environment environment; + private RDAManager rdaManager; @Autowired - public DataManagementPlanManager(ApiContext apiContext, DatasetManager datasetManager, Environment environment) { + public DataManagementPlanManager(ApiContext apiContext, DatasetManager datasetManager, Environment environment, RDAManager rdaManager) { this.apiContext = apiContext; this.datasetManager = datasetManager; this.utilitiesService = apiContext.getUtilitiesService(); this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository(); this.environment = environment; + this.rdaManager = rdaManager; } public DataTableData getPaged(DataManagementPlanTableRequest dataManagementPlanTableRequest, Principal principal, String fieldsGroup) throws Exception { @@ -1129,15 +1131,20 @@ public class DataManagementPlanManager { eu.eudat.data.entities.DMP dmp = databaseRepository.getDmpDao().find(UUID.fromString(id)); if (!dmp.isPublic() && dmp.getUsers().stream().noneMatch(userInfo -> userInfo.getUser().getId() == principal.getId())) throw new UnauthorisedException(); - RDAExportModel rdaExportModel = new RDAExportModel().fromDataModel(dmp, datasetManager, principal); +// RDAExportModel rdaExportModel = new RDAExportModel().fromDataModel(dmp, datasetManager, principal); + String result = rdaManager.convertToRDA(dmp); ObjectMapper mapper = new ObjectMapper(); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); String fileName = dmp.getLabel(); fileName = fileName.replaceAll("[^a-zA-Z0-9+ ]", ""); File file = new File(fileName + ".json"); + OutputStream output = new FileOutputStream(file); try { - mapper.writeValue(file, rdaExportModel); +// mapper.writeValue(file, rdaExportModel); + output.write(result.getBytes()); + output.flush(); + output.close(); } catch (IOException e) { logger.error(e.getMessage(), e); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetProfileManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetProfileManager.java index 079359827..81693e917 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetProfileManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetProfileManager.java @@ -113,8 +113,8 @@ public class DatasetProfileManager { ResponseEntity response = restTemplate.exchange(data.getUrl() + "?search=" + like, HttpMethod.GET, entity, Object.class); DocumentContext jsonContext = JsonPath.parse(response.getBody()); - List> jsonItems = jsonContext.read(data.getOptionsRoot() + "['" + data.getAutoCompleteOptions().getLabel() + "','" + data.getAutoCompleteOptions().getValue() + "','" + data.getAutoCompleteOptions().getSource() + "']"); - jsonItems.forEach(item -> result.add(new ExternalAutocompleteFieldModel(item.get(data.getAutoCompleteOptions().getValue()), item.get(data.getAutoCompleteOptions().getLabel()), item.get(data.getAutoCompleteOptions().getSource())))); + List> jsonItems = jsonContext.read(data.getOptionsRoot() + "['" + data.getAutoCompleteOptions().getLabel() + "','" + data.getAutoCompleteOptions().getValue() + "','" + data.getAutoCompleteOptions().getSource() + "','" + "uri" + "']"); + jsonItems.forEach(item -> result.add(new ExternalAutocompleteFieldModel(item.get(data.getAutoCompleteOptions().getValue()), item.get(data.getAutoCompleteOptions().getLabel()), item.get(data.getAutoCompleteOptions().getSource()), item.get("uri")))); return result; } diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java new file mode 100644 index 000000000..eb10fd753 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java @@ -0,0 +1,38 @@ +package eu.eudat.logic.managers; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import eu.eudat.data.entities.DMP; +import eu.eudat.models.rda.Dmp; +import eu.eudat.models.rda.RDAModel; +import eu.eudat.models.rda.mapper.DmpRDAMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.transaction.Transactional; +import java.text.SimpleDateFormat; + +@Component +public class RDAManager { + + private DmpRDAMapper dmpRDAMapper; + + @Autowired + public RDAManager(DmpRDAMapper dmpRDAMapper) { + this.dmpRDAMapper = dmpRDAMapper; + } + + @Transactional + public String convertToRDA(DMP dmp) throws JsonProcessingException { + String result = ""; + + Dmp rdaDmp = dmpRDAMapper.toRDA(dmp); + + ObjectMapper mapper = new ObjectMapper(); + mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")); + + result = mapper.writeValueAsString(rdaDmp); + + return result; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java new file mode 100644 index 000000000..ca2372b91 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java @@ -0,0 +1,32 @@ +package eu.eudat.logic.utilities.json; + +import com.fasterxml.jackson.databind.JsonNode; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +public class JsonSearcher { + + public static List findNodes(JsonNode root, String key, String value) { + List nodes = new ArrayList<>(); + for (Iterator it = root.elements(); it.hasNext(); ) { + JsonNode node = it.next(); + int found = 0; + for (Iterator iter = node.fieldNames(); iter.hasNext(); ) { + String fieldName = iter.next(); + if (fieldName.equals(key)) { + if (node.get(fieldName).asText().equals(value) || node.get(fieldName).asText().startsWith(value)) { + nodes.add(node); + found++; + } + } + + } + if (found == 0) { + nodes.addAll(findNodes(node, key, value)); + } + } + return nodes; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/AutoCompleteData.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/AutoCompleteData.java index 8fbedc873..5b33f115d 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/AutoCompleteData.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/AutoCompleteData.java @@ -64,6 +64,7 @@ public class AutoCompleteData extends ComboBoxData { this.autoCompleteOptions.setLabel(optionElement.getAttribute("label")); this.autoCompleteOptions.setValue(optionElement.getAttribute("value")); this.autoCompleteOptions.setSource(optionElement.getAttribute("source")); + this.autoCompleteOptions.setUri(optionElement.getAttribute("uri")); } return this; } @@ -81,6 +82,7 @@ public class AutoCompleteData extends ComboBoxData { this.autoCompleteOptions.setLabel(options.get("label")); this.autoCompleteOptions.setValue(options.get("value")); this.autoCompleteOptions.setSource(options.get("source")); + this.autoCompleteOptions.setUri(options.get("uri")); } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/ComboBoxData.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/ComboBoxData.java index db67ea301..59bc6ea79 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/ComboBoxData.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/ComboBoxData.java @@ -12,6 +12,7 @@ public abstract class ComboBoxData extends FieldData { private String label; private String value; private String source; + private String uri; public String getLabel() { return label; @@ -34,12 +35,21 @@ public abstract class ComboBoxData extends FieldData { this.source = source; } + public String getUri() { + return uri; + } + + public void setUri(String uri) { + this.uri = uri; + } + @Override public Element toXml(Document doc) { Element option = doc.createElement("option"); option.setAttribute("label", this.label); option.setAttribute("value", this.value); option.setAttribute("source", this.source); + option.setAttribute("uri", this.uri); return option; } @@ -48,6 +58,7 @@ public abstract class ComboBoxData extends FieldData { this.label = item.getAttribute("label"); this.value = item.getAttribute("value"); this.source = item.getAttribute("source"); + this.uri = item.getAttribute("uri"); return this; } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/externaldataset/ExternalAutocompleteFieldModel.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/externaldataset/ExternalAutocompleteFieldModel.java index d57605a72..039c63acd 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/externaldataset/ExternalAutocompleteFieldModel.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/externaldataset/ExternalAutocompleteFieldModel.java @@ -4,11 +4,13 @@ public class ExternalAutocompleteFieldModel { private String id; private String label; private String source; + private String uri; - public ExternalAutocompleteFieldModel(String id, String label, String source) { + public ExternalAutocompleteFieldModel(String id, String label, String source, String uri) { this.id = id; this.label = label; this.source = source; + this.uri = uri; } public String getId() { @@ -31,4 +33,12 @@ public class ExternalAutocompleteFieldModel { public void setSource(String source) { this.source = source; } + + public String getUri() { + return uri; + } + + public void setUri(String uri) { + this.uri = uri; + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/rda/DatasetRDAExportModel.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/rda/DatasetRDAExportModel.java index c9f509020..ccd79971f 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/rda/DatasetRDAExportModel.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/rda/DatasetRDAExportModel.java @@ -321,7 +321,8 @@ public class DatasetRDAExportModel { JSONObject jsonObject = jsonArray.getJSONObject(i); Map jsonObjectMap = jsonObject.toMap(); DatasetMetadataRDAExportModel metadataRda1 = new DatasetMetadataRDAExportModel(); - metadataRda1.setMetadata_standard_id(new IdRDAExportModel(jsonObjectMap.get("label").toString(), jsonObjectMap.get("source").toString())); +// metadataRda1.setMetadata_standard_id(new IdRDAExportModel(jsonObjectMap.get("label").toString(), jsonObjectMap.get("source").toString())); + metadataRda1.setMetadata_standard_id(new IdRDAExportModel(jsonObjectMap.get("uri").toString(), "url")); metadataRDAExportModelList.add(metadataRda1); } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Contact.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Contact.java new file mode 100644 index 000000000..606a3ae2c --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Contact.java @@ -0,0 +1,146 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * The DMP Contact Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "contact_id", + "mbox", + "name" +}) +public class Contact implements Serializable +{ + + /** + * The Contact ID Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contact_id") + private ContactId contactId; + /** + * The Mailbox Schema + *

+ * Contact Person's E-mail address + * (Required) + * + */ + @JsonProperty("mbox") + @JsonPropertyDescription("Contact Person's E-mail address") + private String mbox; + /** + * The Name Schema + *

+ * Name of the contact person + * (Required) + * + */ + @JsonProperty("name") + @JsonPropertyDescription("Name of the contact person") + private String name; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -2062619884605400321L; + + /** + * The Contact ID Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contact_id") + public ContactId getContactId() { + return contactId; + } + + /** + * The Contact ID Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contact_id") + public void setContactId(ContactId contactId) { + this.contactId = contactId; + } + + /** + * The Mailbox Schema + *

+ * Contact Person's E-mail address + * (Required) + * + */ + @JsonProperty("mbox") + public String getMbox() { + return mbox; + } + + /** + * The Mailbox Schema + *

+ * Contact Person's E-mail address + * (Required) + * + */ + @JsonProperty("mbox") + public void setMbox(String mbox) { + this.mbox = mbox; + } + + /** + * The Name Schema + *

+ * Name of the contact person + * (Required) + * + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * The Name Schema + *

+ * Name of the contact person + * (Required) + * + */ + @JsonProperty("name") + public void setName(String name) { + this.name = name; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/ContactId.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/ContactId.java new file mode 100644 index 000000000..60454ea6c --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/ContactId.java @@ -0,0 +1,154 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Contact ID Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "identifier", + "type" +}) +public class ContactId implements Serializable +{ + + /** + * The DMP Contact Identifier Schema + *

+ * + * (Required) + * + */ + @JsonProperty("identifier") + private String identifier; + /** + * The DMP Contact Identifier Type Schema + *

+ * Identifier type. Allowed values: orcid, isni, openid, other + * (Required) + * + */ + @JsonProperty("type") + @JsonPropertyDescription("Identifier type. Allowed values: orcid, isni, openid, other") + private ContactId.Type type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -7066973565810615822L; + + /** + * The DMP Contact Identifier Schema + *

+ * + * (Required) + * + */ + @JsonProperty("identifier") + public String getIdentifier() { + return identifier; + } + + /** + * The DMP Contact Identifier Schema + *

+ * + * (Required) + * + */ + @JsonProperty("identifier") + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + * The DMP Contact Identifier Type Schema + *

+ * Identifier type. Allowed values: orcid, isni, openid, other + * (Required) + * + */ + @JsonProperty("type") + public ContactId.Type getType() { + return type; + } + + /** + * The DMP Contact Identifier Type Schema + *

+ * Identifier type. Allowed values: orcid, isni, openid, other + * (Required) + * + */ + @JsonProperty("type") + public void setType(ContactId.Type type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Type { + + ORCID("orcid"), + ISNI("isni"), + OPENID("openid"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (ContactId.Type c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Type(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static ContactId.Type fromValue(String value) { + ContactId.Type constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Contributor.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Contributor.java new file mode 100644 index 000000000..21dfe68c8 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Contributor.java @@ -0,0 +1,181 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + + +/** + * The Contributor Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "contributor_id", + "mbox", + "name", + "role" +}) +public class Contributor implements Serializable +{ + + /** + * The Contributor_id Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contributor_id") + private ContributorId contributorId; + /** + * The Contributor Mailbox Schema + *

+ * Contributor Mail address + * + */ + @JsonProperty("mbox") + @JsonPropertyDescription("Contributor Mail address") + private String mbox; + /** + * The Name Schema + *

+ * Name of the contributor + * (Required) + * + */ + @JsonProperty("name") + @JsonPropertyDescription("Name of the contributor") + private String name; + /** + * The Role Schema + *

+ * Type of contributor + * (Required) + * + */ + @JsonProperty("role") + @JsonDeserialize(as = java.util.LinkedHashSet.class) + @JsonPropertyDescription("Type of contributor") + private Set role = null; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 3452606902359513114L; + + /** + * The Contributor_id Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contributor_id") + public ContributorId getContributorId() { + return contributorId; + } + + /** + * The Contributor_id Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contributor_id") + public void setContributorId(ContributorId contributorId) { + this.contributorId = contributorId; + } + + /** + * The Contributor Mailbox Schema + *

+ * Contributor Mail address + * + */ + @JsonProperty("mbox") + public String getMbox() { + return mbox; + } + + /** + * The Contributor Mailbox Schema + *

+ * Contributor Mail address + * + */ + @JsonProperty("mbox") + public void setMbox(String mbox) { + this.mbox = mbox; + } + + /** + * The Name Schema + *

+ * Name of the contributor + * (Required) + * + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * The Name Schema + *

+ * Name of the contributor + * (Required) + * + */ + @JsonProperty("name") + public void setName(String name) { + this.name = name; + } + + /** + * The Role Schema + *

+ * Type of contributor + * (Required) + * + */ + @JsonProperty("role") + public Set getRole() { + return role; + } + + /** + * The Role Schema + *

+ * Type of contributor + * (Required) + * + */ + @JsonProperty("role") + public void setRole(Set role) { + this.role = role; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/ContributorId.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/ContributorId.java new file mode 100644 index 000000000..4045f5e0e --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/ContributorId.java @@ -0,0 +1,155 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Contributor_id Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "identifier", + "type" +}) +public class ContributorId implements Serializable +{ + + /** + * The Contributor Identifier Schema + *

+ * Identifier for a contact person + * (Required) + * + */ + @JsonProperty("identifier") + @JsonPropertyDescription("Identifier for a contact person") + private String identifier; + /** + * The Contributor Identifier Type Schema + *

+ * Identifier type. Allowed values: orcid, isni, openid, other + * (Required) + * + */ + @JsonProperty("type") + @JsonPropertyDescription("Identifier type. Allowed values: orcid, isni, openid, other") + private ContributorId.Type type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 3089650417960767482L; + + /** + * The Contributor Identifier Schema + *

+ * Identifier for a contact person + * (Required) + * + */ + @JsonProperty("identifier") + public String getIdentifier() { + return identifier; + } + + /** + * The Contributor Identifier Schema + *

+ * Identifier for a contact person + * (Required) + * + */ + @JsonProperty("identifier") + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + * The Contributor Identifier Type Schema + *

+ * Identifier type. Allowed values: orcid, isni, openid, other + * (Required) + * + */ + @JsonProperty("type") + public ContributorId.Type getType() { + return type; + } + + /** + * The Contributor Identifier Type Schema + *

+ * Identifier type. Allowed values: orcid, isni, openid, other + * (Required) + * + */ + @JsonProperty("type") + public void setType(ContributorId.Type type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Type { + + ORCID("orcid"), + ISNI("isni"), + OPENID("openid"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (ContributorId.Type c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Type(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static ContributorId.Type fromValue(String value) { + ContributorId.Type constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Cost.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Cost.java new file mode 100644 index 000000000..db32ff641 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Cost.java @@ -0,0 +1,374 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Cost Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "currency_code", + "description", + "title", + "value" +}) +public class Cost implements Serializable +{ + + /** + * The Cost Currency Code Schema + *

+ * Allowed values defined by ISO 4217 + * + */ + @JsonProperty("currency_code") + @JsonPropertyDescription("Allowed values defined by ISO 4217") + private Cost.CurrencyCode currencyCode; + /** + * The Cost Description Schema + *

+ * Cost(s) Description + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Cost(s) Description") + private String description; + /** + * The Cost Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + @JsonPropertyDescription("Title") + private String title; + /** + * The Cost Value Schema + *

+ * Value + * + */ + @JsonProperty("value") + @JsonPropertyDescription("Value") + private Double value; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -322637784848035165L; + + /** + * The Cost Currency Code Schema + *

+ * Allowed values defined by ISO 4217 + * + */ + @JsonProperty("currency_code") + public Cost.CurrencyCode getCurrencyCode() { + return currencyCode; + } + + /** + * The Cost Currency Code Schema + *

+ * Allowed values defined by ISO 4217 + * + */ + @JsonProperty("currency_code") + public void setCurrencyCode(Cost.CurrencyCode currencyCode) { + this.currencyCode = currencyCode; + } + + /** + * The Cost Description Schema + *

+ * Cost(s) Description + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The Cost Description Schema + *

+ * Cost(s) Description + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The Cost Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * The Cost Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } + + /** + * The Cost Value Schema + *

+ * Value + * + */ + @JsonProperty("value") + public Double getValue() { + return value; + } + + /** + * The Cost Value Schema + *

+ * Value + * + */ + @JsonProperty("value") + public void setValue(Double value) { + this.value = value; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum CurrencyCode { + + AED("AED"), + AFN("AFN"), + ALL("ALL"), + AMD("AMD"), + ANG("ANG"), + AOA("AOA"), + ARS("ARS"), + AUD("AUD"), + AWG("AWG"), + AZN("AZN"), + BAM("BAM"), + BBD("BBD"), + BDT("BDT"), + BGN("BGN"), + BHD("BHD"), + BIF("BIF"), + BMD("BMD"), + BND("BND"), + BOB("BOB"), + BRL("BRL"), + BSD("BSD"), + BTN("BTN"), + BWP("BWP"), + BYN("BYN"), + BZD("BZD"), + CAD("CAD"), + CDF("CDF"), + CHF("CHF"), + CLP("CLP"), + CNY("CNY"), + COP("COP"), + CRC("CRC"), + CUC("CUC"), + CUP("CUP"), + CVE("CVE"), + CZK("CZK"), + DJF("DJF"), + DKK("DKK"), + DOP("DOP"), + DZD("DZD"), + EGP("EGP"), + ERN("ERN"), + ETB("ETB"), + EUR("EUR"), + FJD("FJD"), + FKP("FKP"), + GBP("GBP"), + GEL("GEL"), + GGP("GGP"), + GHS("GHS"), + GIP("GIP"), + GMD("GMD"), + GNF("GNF"), + GTQ("GTQ"), + GYD("GYD"), + HKD("HKD"), + HNL("HNL"), + HRK("HRK"), + HTG("HTG"), + HUF("HUF"), + IDR("IDR"), + ILS("ILS"), + IMP("IMP"), + INR("INR"), + IQD("IQD"), + IRR("IRR"), + ISK("ISK"), + JEP("JEP"), + JMD("JMD"), + JOD("JOD"), + JPY("JPY"), + KES("KES"), + KGS("KGS"), + KHR("KHR"), + KMF("KMF"), + KPW("KPW"), + KRW("KRW"), + KWD("KWD"), + KYD("KYD"), + KZT("KZT"), + LAK("LAK"), + LBP("LBP"), + LKR("LKR"), + LRD("LRD"), + LSL("LSL"), + LYD("LYD"), + MAD("MAD"), + MDL("MDL"), + MGA("MGA"), + MKD("MKD"), + MMK("MMK"), + MNT("MNT"), + MOP("MOP"), + MRU("MRU"), + MUR("MUR"), + MVR("MVR"), + MWK("MWK"), + MXN("MXN"), + MYR("MYR"), + MZN("MZN"), + NAD("NAD"), + NGN("NGN"), + NIO("NIO"), + NOK("NOK"), + NPR("NPR"), + NZD("NZD"), + OMR("OMR"), + PAB("PAB"), + PEN("PEN"), + PGK("PGK"), + PHP("PHP"), + PKR("PKR"), + PLN("PLN"), + PYG("PYG"), + QAR("QAR"), + RON("RON"), + RSD("RSD"), + RUB("RUB"), + RWF("RWF"), + SAR("SAR"), + SBD("SBD"), + SCR("SCR"), + SDG("SDG"), + SEK("SEK"), + SGD("SGD"), + SHP("SHP"), + SLL("SLL"), + SOS("SOS"), + SPL("SPL*"), + SRD("SRD"), + STN("STN"), + SVC("SVC"), + SYP("SYP"), + SZL("SZL"), + THB("THB"), + TJS("TJS"), + TMT("TMT"), + TND("TND"), + TOP("TOP"), + TRY("TRY"), + TTD("TTD"), + TVD("TVD"), + TWD("TWD"), + TZS("TZS"), + UAH("UAH"), + UGX("UGX"), + USD("USD"), + UYU("UYU"), + UZS("UZS"), + VEF("VEF"), + VND("VND"), + VUV("VUV"), + WST("WST"), + XAF("XAF"), + XCD("XCD"), + XDR("XDR"), + XOF("XOF"), + XPF("XPF"), + YER("YER"), + ZAR("ZAR"), + ZMW("ZMW"), + ZWD("ZWD"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Cost.CurrencyCode c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private CurrencyCode(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Cost.CurrencyCode fromValue(String value) { + Cost.CurrencyCode constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java new file mode 100644 index 000000000..43a7ac0cd --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java @@ -0,0 +1,839 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Dataset Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "data_quality_assurance", + "dataset_id", + "description", + "distribution", + "issued", + "keyword", + "language", + "metadata", + "personal_data", + "preservation_statement", + "security_and_privacy", + "sensitive_data", + "technical_resource", + "title", + "type" +}) +public class Dataset implements Serializable +{ + + /** + * The Data Quality Assurance Schema + *

+ * Data Quality Assurance + * + */ + @JsonProperty("data_quality_assurance") + @JsonPropertyDescription("Data Quality Assurance") + private List dataQualityAssurance = null; + /** + * The Dataset ID Schema + *

+ * Dataset ID + * (Required) + * + */ + @JsonProperty("dataset_id") + @JsonPropertyDescription("Dataset ID") + private DatasetId datasetId; + /** + * The Dataset Description Schema + *

+ * Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file.") + private String description; + /** + * The Dataset Distribution Schema + *

+ * To provide technical information on a specific instance of data. + * + */ + @JsonProperty("distribution") + @JsonPropertyDescription("To provide technical information on a specific instance of data.") + private List distribution = null; + /** + * The Dataset Date of Issue Schema + *

+ * Date of Issue + * + */ + @JsonProperty("issued") + @JsonPropertyDescription("Date of Issue") + private String issued; + /** + * The Dataset Keyword(s) Schema + *

+ * Keywords + * + */ + @JsonProperty("keyword") + @JsonPropertyDescription("Keywords") + private List keyword = null; + /** + * The Dataset Language Schema + *

+ * Language of the dataset expressed using ISO 639-3. + * + */ + @JsonProperty("language") + @JsonPropertyDescription("Language of the dataset expressed using ISO 639-3.") + private Dataset.Language language; + /** + * The Dataset Metadata Schema + *

+ * To describe metadata standards used. + * + */ + @JsonProperty("metadata") + @JsonPropertyDescription("To describe metadata standards used.") + private List metadata = null; + /** + * The Dataset Personal Data Schema + *

+ * If any personal data is contained. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("personal_data") + @JsonPropertyDescription("If any personal data is contained. Allowed values: yes, no, unknown") + private Dataset.PersonalData personalData; + /** + * The Dataset Preservation Statement Schema + *

+ * Preservation Statement + * + */ + @JsonProperty("preservation_statement") + @JsonPropertyDescription("Preservation Statement") + private String preservationStatement; + /** + * The Dataset Security and Policy Schema + *

+ * To list all issues and requirements related to security and privacy + * + */ + @JsonProperty("security_and_privacy") + @JsonPropertyDescription("To list all issues and requirements related to security and privacy") + private List securityAndPrivacy = null; + /** + * The Dataset Sensitive Data Schema + *

+ * If any sensitive data is contained. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("sensitive_data") + @JsonPropertyDescription("If any sensitive data is contained. Allowed values: yes, no, unknown") + private Dataset.SensitiveData sensitiveData; + /** + * The Dataset Technical Resource Schema + *

+ * To list all technical resources needed to implement a DMP + * + */ + @JsonProperty("technical_resource") + @JsonPropertyDescription("To list all technical resources needed to implement a DMP") + private List technicalResource = null; + /** + * The Dataset Title Schema + *

+ * Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * (Required) + * + */ + @JsonProperty("title") + @JsonPropertyDescription("Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file.") + private String title; + /** + * The Dataset Type Schema + *

+ * If appropriate, type according to: DataCite and/or COAR dictionary. Otherwise use the common name for the type, e.g. raw data, software, survey, etc. https://schema.datacite.org/meta/kernel-4.1/doc/DataCite-MetadataKernel_v4.1.pdf http://vocabularies.coar-repositories.org/pubby/resource_type.html + * + */ + @JsonProperty("type") + @JsonPropertyDescription("If appropriate, type according to: DataCite and/or COAR dictionary. Otherwise use the common name for the type, e.g. raw data, software, survey, etc. https://schema.datacite.org/meta/kernel-4.1/doc/DataCite-MetadataKernel_v4.1.pdf http://vocabularies.coar-repositories.org/pubby/resource_type.html") + private String type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -6931119120629009399L; + + /** + * The Data Quality Assurance Schema + *

+ * Data Quality Assurance + * + */ + @JsonProperty("data_quality_assurance") + public List getDataQualityAssurance() { + return dataQualityAssurance; + } + + /** + * The Data Quality Assurance Schema + *

+ * Data Quality Assurance + * + */ + @JsonProperty("data_quality_assurance") + public void setDataQualityAssurance(List dataQualityAssurance) { + this.dataQualityAssurance = dataQualityAssurance; + } + + /** + * The Dataset ID Schema + *

+ * Dataset ID + * (Required) + * + */ + @JsonProperty("dataset_id") + public DatasetId getDatasetId() { + return datasetId; + } + + /** + * The Dataset ID Schema + *

+ * Dataset ID + * (Required) + * + */ + @JsonProperty("dataset_id") + public void setDatasetId(DatasetId datasetId) { + this.datasetId = datasetId; + } + + /** + * The Dataset Description Schema + *

+ * Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The Dataset Description Schema + *

+ * Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The Dataset Distribution Schema + *

+ * To provide technical information on a specific instance of data. + * + */ + @JsonProperty("distribution") + public List getDistribution() { + return distribution; + } + + /** + * The Dataset Distribution Schema + *

+ * To provide technical information on a specific instance of data. + * + */ + @JsonProperty("distribution") + public void setDistribution(List distribution) { + this.distribution = distribution; + } + + /** + * The Dataset Date of Issue Schema + *

+ * Date of Issue + * + */ + @JsonProperty("issued") + public String getIssued() { + return issued; + } + + /** + * The Dataset Date of Issue Schema + *

+ * Date of Issue + * + */ + @JsonProperty("issued") + public void setIssued(String issued) { + this.issued = issued; + } + + /** + * The Dataset Keyword(s) Schema + *

+ * Keywords + * + */ + @JsonProperty("keyword") + public List getKeyword() { + return keyword; + } + + /** + * The Dataset Keyword(s) Schema + *

+ * Keywords + * + */ + @JsonProperty("keyword") + public void setKeyword(List keyword) { + this.keyword = keyword; + } + + /** + * The Dataset Language Schema + *

+ * Language of the dataset expressed using ISO 639-3. + * + */ + @JsonProperty("language") + public Dataset.Language getLanguage() { + return language; + } + + /** + * The Dataset Language Schema + *

+ * Language of the dataset expressed using ISO 639-3. + * + */ + @JsonProperty("language") + public void setLanguage(Dataset.Language language) { + this.language = language; + } + + /** + * The Dataset Metadata Schema + *

+ * To describe metadata standards used. + * + */ + @JsonProperty("metadata") + public List getMetadata() { + return metadata; + } + + /** + * The Dataset Metadata Schema + *

+ * To describe metadata standards used. + * + */ + @JsonProperty("metadata") + public void setMetadata(List metadata) { + this.metadata = metadata; + } + + /** + * The Dataset Personal Data Schema + *

+ * If any personal data is contained. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("personal_data") + public Dataset.PersonalData getPersonalData() { + return personalData; + } + + /** + * The Dataset Personal Data Schema + *

+ * If any personal data is contained. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("personal_data") + public void setPersonalData(Dataset.PersonalData personalData) { + this.personalData = personalData; + } + + /** + * The Dataset Preservation Statement Schema + *

+ * Preservation Statement + * + */ + @JsonProperty("preservation_statement") + public String getPreservationStatement() { + return preservationStatement; + } + + /** + * The Dataset Preservation Statement Schema + *

+ * Preservation Statement + * + */ + @JsonProperty("preservation_statement") + public void setPreservationStatement(String preservationStatement) { + this.preservationStatement = preservationStatement; + } + + /** + * The Dataset Security and Policy Schema + *

+ * To list all issues and requirements related to security and privacy + * + */ + @JsonProperty("security_and_privacy") + public List getSecurityAndPrivacy() { + return securityAndPrivacy; + } + + /** + * The Dataset Security and Policy Schema + *

+ * To list all issues and requirements related to security and privacy + * + */ + @JsonProperty("security_and_privacy") + public void setSecurityAndPrivacy(List securityAndPrivacy) { + this.securityAndPrivacy = securityAndPrivacy; + } + + /** + * The Dataset Sensitive Data Schema + *

+ * If any sensitive data is contained. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("sensitive_data") + public Dataset.SensitiveData getSensitiveData() { + return sensitiveData; + } + + /** + * The Dataset Sensitive Data Schema + *

+ * If any sensitive data is contained. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("sensitive_data") + public void setSensitiveData(Dataset.SensitiveData sensitiveData) { + this.sensitiveData = sensitiveData; + } + + /** + * The Dataset Technical Resource Schema + *

+ * To list all technical resources needed to implement a DMP + * + */ + @JsonProperty("technical_resource") + public List getTechnicalResource() { + return technicalResource; + } + + /** + * The Dataset Technical Resource Schema + *

+ * To list all technical resources needed to implement a DMP + * + */ + @JsonProperty("technical_resource") + public void setTechnicalResource(List technicalResource) { + this.technicalResource = technicalResource; + } + + /** + * The Dataset Title Schema + *

+ * Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * (Required) + * + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * The Dataset Title Schema + *

+ * Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * (Required) + * + */ + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } + + /** + * The Dataset Type Schema + *

+ * If appropriate, type according to: DataCite and/or COAR dictionary. Otherwise use the common name for the type, e.g. raw data, software, survey, etc. https://schema.datacite.org/meta/kernel-4.1/doc/DataCite-MetadataKernel_v4.1.pdf http://vocabularies.coar-repositories.org/pubby/resource_type.html + * + */ + @JsonProperty("type") + public String getType() { + return type; + } + + /** + * The Dataset Type Schema + *

+ * If appropriate, type according to: DataCite and/or COAR dictionary. Otherwise use the common name for the type, e.g. raw data, software, survey, etc. https://schema.datacite.org/meta/kernel-4.1/doc/DataCite-MetadataKernel_v4.1.pdf http://vocabularies.coar-repositories.org/pubby/resource_type.html + * + */ + @JsonProperty("type") + public void setType(String type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Language { + + AAR("aar"), + ABK("abk"), + AFR("afr"), + AKA("aka"), + AMH("amh"), + ARA("ara"), + ARG("arg"), + ASM("asm"), + AVA("ava"), + AVE("ave"), + AYM("aym"), + AZE("aze"), + BAK("bak"), + BAM("bam"), + BEL("bel"), + BEN("ben"), + BIH("bih"), + BIS("bis"), + BOD("bod"), + BOS("bos"), + BRE("bre"), + BUL("bul"), + CAT("cat"), + CES("ces"), + CHA("cha"), + CHE("che"), + CHU("chu"), + CHV("chv"), + COR("cor"), + COS("cos"), + CRE("cre"), + CYM("cym"), + DAN("dan"), + DEU("deu"), + DIV("div"), + DZO("dzo"), + ELL("ell"), + ENG("eng"), + EPO("epo"), + EST("est"), + EUS("eus"), + EWE("ewe"), + FAO("fao"), + FAS("fas"), + FIJ("fij"), + FIN("fin"), + FRA("fra"), + FRY("fry"), + FUL("ful"), + GLA("gla"), + GLE("gle"), + GLG("glg"), + GLV("glv"), + GRN("grn"), + GUJ("guj"), + HAT("hat"), + HAU("hau"), + HBS("hbs"), + HEB("heb"), + HER("her"), + HIN("hin"), + HMO("hmo"), + HRV("hrv"), + HUN("hun"), + HYE("hye"), + IBO("ibo"), + IDO("ido"), + III("iii"), + IKU("iku"), + ILE("ile"), + INA("ina"), + IND("ind"), + IPK("ipk"), + ISL("isl"), + ITA("ita"), + JAV("jav"), + JPN("jpn"), + KAL("kal"), + KAN("kan"), + KAS("kas"), + KAT("kat"), + KAU("kau"), + KAZ("kaz"), + KHM("khm"), + KIK("kik"), + KIN("kin"), + KIR("kir"), + KOM("kom"), + KON("kon"), + KOR("kor"), + KUA("kua"), + KUR("kur"), + LAO("lao"), + LAT("lat"), + LAV("lav"), + LIM("lim"), + LIN("lin"), + LIT("lit"), + LTZ("ltz"), + LUB("lub"), + LUG("lug"), + MAH("mah"), + MAL("mal"), + MAR("mar"), + MKD("mkd"), + MLG("mlg"), + MLT("mlt"), + MON("mon"), + MRI("mri"), + MSA("msa"), + MYA("mya"), + NAU("nau"), + NAV("nav"), + NBL("nbl"), + NDE("nde"), + NDO("ndo"), + NEP("nep"), + NLD("nld"), + NNO("nno"), + NOB("nob"), + NOR("nor"), + NYA("nya"), + OCI("oci"), + OJI("oji"), + ORI("ori"), + ORM("orm"), + OSS("oss"), + PAN("pan"), + PLI("pli"), + POL("pol"), + POR("por"), + PUS("pus"), + QUE("que"), + ROH("roh"), + RON("ron"), + RUN("run"), + RUS("rus"), + SAG("sag"), + SAN("san"), + SIN("sin"), + SLK("slk"), + SLV("slv"), + SME("sme"), + SMO("smo"), + SNA("sna"), + SND("snd"), + SOM("som"), + SOT("sot"), + SPA("spa"), + SQI("sqi"), + SRD("srd"), + SRP("srp"), + SSW("ssw"), + SUN("sun"), + SWA("swa"), + SWE("swe"), + TAH("tah"), + TAM("tam"), + TAT("tat"), + TEL("tel"), + TGK("tgk"), + TGL("tgl"), + THA("tha"), + TIR("tir"), + TON("ton"), + TSN("tsn"), + TSO("tso"), + TUK("tuk"), + TUR("tur"), + TWI("twi"), + UIG("uig"), + UKR("ukr"), + URD("urd"), + UZB("uzb"), + VEN("ven"), + VIE("vie"), + VOL("vol"), + WLN("wln"), + WOL("wol"), + XHO("xho"), + YID("yid"), + YOR("yor"), + ZHA("zha"), + ZHO("zho"), + ZUL("zul"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Dataset.Language c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Language(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Dataset.Language fromValue(String value) { + Dataset.Language constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + + public enum PersonalData { + + YES("yes"), + NO("no"), + UNKNOWN("unknown"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Dataset.PersonalData c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private PersonalData(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Dataset.PersonalData fromValue(String value) { + Dataset.PersonalData constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + + public enum SensitiveData { + + YES("yes"), + NO("no"), + UNKNOWN("unknown"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Dataset.SensitiveData c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private SensitiveData(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Dataset.SensitiveData fromValue(String value) { + Dataset.SensitiveData constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/DatasetId.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/DatasetId.java new file mode 100644 index 000000000..c1cc1e57a --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/DatasetId.java @@ -0,0 +1,156 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Dataset ID Schema + *

+ * Dataset ID + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "identifier", + "type" +}) +public class DatasetId implements Serializable +{ + + /** + * The Dataset Identifier Schema + *

+ * Identifier for a dataset + * (Required) + * + */ + @JsonProperty("identifier") + @JsonPropertyDescription("Identifier for a dataset") + private String identifier; + /** + * The Dataset Identifier Type Schema + *

+ * Dataset identifier type. Allowed values: handle, doi, ark, url, other + * (Required) + * + */ + @JsonProperty("type") + @JsonPropertyDescription("Dataset identifier type. Allowed values: handle, doi, ark, url, other") + private DatasetId.Type type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -6295164005851378031L; + + /** + * The Dataset Identifier Schema + *

+ * Identifier for a dataset + * (Required) + * + */ + @JsonProperty("identifier") + public String getIdentifier() { + return identifier; + } + + /** + * The Dataset Identifier Schema + *

+ * Identifier for a dataset + * (Required) + * + */ + @JsonProperty("identifier") + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + * The Dataset Identifier Type Schema + *

+ * Dataset identifier type. Allowed values: handle, doi, ark, url, other + * (Required) + * + */ + @JsonProperty("type") + public DatasetId.Type getType() { + return type; + } + + /** + * The Dataset Identifier Type Schema + *

+ * Dataset identifier type. Allowed values: handle, doi, ark, url, other + * (Required) + * + */ + @JsonProperty("type") + public void setType(DatasetId.Type type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Type { + + HANDLE("handle"), + DOI("doi"), + ARK("ark"), + URL("url"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (DatasetId.Type c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Type(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static DatasetId.Type fromValue(String value) { + DatasetId.Type constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java new file mode 100644 index 000000000..d005e7564 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java @@ -0,0 +1,412 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.net.URI; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Dataset Distribution Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "access_url", + "available_until", + "byte_size", + "data_access", + "description", + "download_url", + "format", + "host", + "license", + "title" +}) +public class Distribution implements Serializable +{ + + /** + * The Dataset Distribution Access URL Schema + *

+ * A URL of the resource that gives access to a distribution of the dataset. e.g. landing page. + * + */ + @JsonProperty("access_url") + @JsonPropertyDescription("A URL of the resource that gives access to a distribution of the dataset. e.g. landing page.") + private String accessUrl; + /** + * The Dataset Distribution Available Until Schema + *

+ * Indicates how long this distribution will be / should be available. + * + */ + @JsonProperty("available_until") + @JsonPropertyDescription("Indicates how long this distribution will be / should be available.") + private String availableUntil; + /** + * The Dataset Distribution Byte Size Schema + *

+ * Size in bytes. + * + */ + @JsonProperty("byte_size") + @JsonPropertyDescription("Size in bytes.") + private Integer byteSize; + /** + * The Dataset Distribution Data Access Schema + *

+ * Indicates access mode for data. Allowed values: open, shared, closed + * (Required) + * + */ + @JsonProperty("data_access") + @JsonPropertyDescription("Indicates access mode for data. Allowed values: open, shared, closed") + private Distribution.DataAccess dataAccess; + /** + * The Dataset Distribution Description Schema + *

+ * Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file.") + private String description; + /** + * The Dataset Distribution Download URL Schema + *

+ * The URL of the downloadable file in a given format. E.g. CSV file or RDF file. + * + */ + @JsonProperty("download_url") + @JsonPropertyDescription("The URL of the downloadable file in a given format. E.g. CSV file or RDF file.") + private URI downloadUrl; + /** + * The Dataset Distribution Format Schema + *

+ * Format according to: https://www.iana.org/assignments/media-types/media-types.xhtml if appropriate, otherwise use the common name for this format. + * + */ + @JsonProperty("format") + @JsonPropertyDescription("Format according to: https://www.iana.org/assignments/media-types/media-types.xhtml if appropriate, otherwise use the common name for this format.") + private List format = null; + /** + * The Dataset Distribution Host Schema + *

+ * To provide information on quality of service provided by infrastructure (e.g. repository) where data is stored. + * + */ + @JsonProperty("host") + @JsonPropertyDescription("To provide information on quality of service provided by infrastructure (e.g. repository) where data is stored.") + private Host host; + /** + * The Dataset Distribution License(s) Schema + *

+ * To list all licenses applied to a specific distribution of data. + * + */ + @JsonProperty("license") + @JsonPropertyDescription("To list all licenses applied to a specific distribution of data.") + private List license = null; + /** + * The Dataset Distribution Title Schema + *

+ * Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * (Required) + * + */ + @JsonProperty("title") + @JsonPropertyDescription("Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file.") + private String title; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -6018365280419917902L; + + /** + * The Dataset Distribution Access URL Schema + *

+ * A URL of the resource that gives access to a distribution of the dataset. e.g. landing page. + * + */ + @JsonProperty("access_url") + public String getAccessUrl() { + return accessUrl; + } + + /** + * The Dataset Distribution Access URL Schema + *

+ * A URL of the resource that gives access to a distribution of the dataset. e.g. landing page. + * + */ + @JsonProperty("access_url") + public void setAccessUrl(String accessUrl) { + this.accessUrl = accessUrl; + } + + /** + * The Dataset Distribution Available Until Schema + *

+ * Indicates how long this distribution will be / should be available. + * + */ + @JsonProperty("available_until") + public String getAvailableUntil() { + return availableUntil; + } + + /** + * The Dataset Distribution Available Until Schema + *

+ * Indicates how long this distribution will be / should be available. + * + */ + @JsonProperty("available_until") + public void setAvailableUntil(String availableUntil) { + this.availableUntil = availableUntil; + } + + /** + * The Dataset Distribution Byte Size Schema + *

+ * Size in bytes. + * + */ + @JsonProperty("byte_size") + public Integer getByteSize() { + return byteSize; + } + + /** + * The Dataset Distribution Byte Size Schema + *

+ * Size in bytes. + * + */ + @JsonProperty("byte_size") + public void setByteSize(Integer byteSize) { + this.byteSize = byteSize; + } + + /** + * The Dataset Distribution Data Access Schema + *

+ * Indicates access mode for data. Allowed values: open, shared, closed + * (Required) + * + */ + @JsonProperty("data_access") + public Distribution.DataAccess getDataAccess() { + return dataAccess; + } + + /** + * The Dataset Distribution Data Access Schema + *

+ * Indicates access mode for data. Allowed values: open, shared, closed + * (Required) + * + */ + @JsonProperty("data_access") + public void setDataAccess(Distribution.DataAccess dataAccess) { + this.dataAccess = dataAccess; + } + + /** + * The Dataset Distribution Description Schema + *

+ * Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The Dataset Distribution Description Schema + *

+ * Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The Dataset Distribution Download URL Schema + *

+ * The URL of the downloadable file in a given format. E.g. CSV file or RDF file. + * + */ + @JsonProperty("download_url") + public URI getDownloadUrl() { + return downloadUrl; + } + + /** + * The Dataset Distribution Download URL Schema + *

+ * The URL of the downloadable file in a given format. E.g. CSV file or RDF file. + * + */ + @JsonProperty("download_url") + public void setDownloadUrl(URI downloadUrl) { + this.downloadUrl = downloadUrl; + } + + /** + * The Dataset Distribution Format Schema + *

+ * Format according to: https://www.iana.org/assignments/media-types/media-types.xhtml if appropriate, otherwise use the common name for this format. + * + */ + @JsonProperty("format") + public List getFormat() { + return format; + } + + /** + * The Dataset Distribution Format Schema + *

+ * Format according to: https://www.iana.org/assignments/media-types/media-types.xhtml if appropriate, otherwise use the common name for this format. + * + */ + @JsonProperty("format") + public void setFormat(List format) { + this.format = format; + } + + /** + * The Dataset Distribution Host Schema + *

+ * To provide information on quality of service provided by infrastructure (e.g. repository) where data is stored. + * + */ + @JsonProperty("host") + public Host getHost() { + return host; + } + + /** + * The Dataset Distribution Host Schema + *

+ * To provide information on quality of service provided by infrastructure (e.g. repository) where data is stored. + * + */ + @JsonProperty("host") + public void setHost(Host host) { + this.host = host; + } + + /** + * The Dataset Distribution License(s) Schema + *

+ * To list all licenses applied to a specific distribution of data. + * + */ + @JsonProperty("license") + public List getLicense() { + return license; + } + + /** + * The Dataset Distribution License(s) Schema + *

+ * To list all licenses applied to a specific distribution of data. + * + */ + @JsonProperty("license") + public void setLicense(List license) { + this.license = license; + } + + /** + * The Dataset Distribution Title Schema + *

+ * Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * (Required) + * + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * The Dataset Distribution Title Schema + *

+ * Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * (Required) + * + */ + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum DataAccess { + + OPEN("open"), + SHARED("shared"), + CLOSED("closed"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Distribution.DataAccess c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private DataAccess(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Distribution.DataAccess fromValue(String value) { + Distribution.DataAccess constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java new file mode 100644 index 000000000..7cac25d62 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java @@ -0,0 +1,774 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.net.URI; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The DMP Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "contact", + "contributor", + "cost", + "created", + "dataset", + "description", + "dmp_id", + "ethical_issues_description", + "ethical_issues_exist", + "ethical_issues_report", + "language", + "modified", + "project", + "title" +}) +public class Dmp implements Serializable +{ + + /** + * The DMP Contact Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contact") + private Contact contact; + /** + * The Contributor Schema + *

+ * + * + */ + @JsonProperty("contributor") + private List contributor = null; + /** + * The Cost Schema + *

+ * + * + */ + @JsonProperty("cost") + private List cost = null; + /** + * The DMP Creation Schema + *

+ * + * + */ + @JsonProperty("created") + @JsonPropertyDescription("") + private Date created; + /** + * The Dataset Schema + *

+ * + * (Required) + * + */ + @JsonProperty("dataset") + private List dataset = null; + /** + * The DMP Description Schema + *

+ * To provide any free-form text information on a DMP + * + */ + @JsonProperty("description") + @JsonPropertyDescription("To provide any free-form text information on a DMP") + private String description; + /** + * The DMP Identifier Schema + *

+ * Identifier for the DMP itself + * (Required) + * + */ + @JsonProperty("dmp_id") + @JsonPropertyDescription("Identifier for the DMP itself") + private DmpId dmpId; + /** + * The DMP Ethical Issues Description Schema + *

+ * To describe ethical issues directly in a DMP + * + */ + @JsonProperty("ethical_issues_description") + @JsonPropertyDescription("To describe ethical issues directly in a DMP") + private String ethicalIssuesDescription; + /** + * The DMP Ethical Issues Exist Schema + *

+ * To indicate whether there are ethical issues related to data that this DMP describes. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("ethical_issues_exist") + @JsonPropertyDescription("To indicate whether there are ethical issues related to data that this DMP describes. Allowed values: yes, no, unknown") + private Dmp.EthicalIssuesExist ethicalIssuesExist; + /** + * The DMP Ethical Issues Report Schema + *

+ * To indicate where a protocol from a meeting with an ethical commitee can be found + * + */ + @JsonProperty("ethical_issues_report") + @JsonPropertyDescription("To indicate where a protocol from a meeting with an ethical commitee can be found") + private URI ethicalIssuesReport; + /** + * The DMP Language Schema + *

+ * Language of the DMP expressed using ISO 639-3. + * (Required) + * + */ + @JsonProperty("language") + @JsonPropertyDescription("Language of the DMP expressed using ISO 639-3.") + private Dmp.Language language; + /** + * The DMP Modification Schema + *

+ * Must be set each time DMP is modified. Indicates DMP version. + * (Required) + * + */ + @JsonProperty("modified") + @JsonPropertyDescription("Must be set each time DMP is modified. Indicates DMP version.") + private Date modified; + /** + * The DMP Project Schema + *

+ * Project related to a DMP + * + */ + @JsonProperty("project") + @JsonPropertyDescription("Project related to a DMP") + private List project = null; + /** + * The DMP Title Schema + *

+ * Title of a DMP + * (Required) + * + */ + @JsonProperty("title") + @JsonPropertyDescription("Title of a DMP") + private String title; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 4599713332472772292L; + + /** + * The DMP Contact Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contact") + public Contact getContact() { + return contact; + } + + /** + * The DMP Contact Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contact") + public void setContact(Contact contact) { + this.contact = contact; + } + + /** + * The Contributor Schema + *

+ * + * + */ + @JsonProperty("contributor") + public List getContributor() { + return contributor; + } + + /** + * The Contributor Schema + *

+ * + * + */ + @JsonProperty("contributor") + public void setContributor(List contributor) { + this.contributor = contributor; + } + + /** + * The Cost Schema + *

+ * + * + */ + @JsonProperty("cost") + public List getCost() { + return cost; + } + + /** + * The Cost Schema + *

+ * + * + */ + @JsonProperty("cost") + public void setCost(List cost) { + this.cost = cost; + } + + /** + * The DMP Creation Schema + *

+ * + * + */ + @JsonProperty("created") + public Date getCreated() { + return created; + } + + /** + * The DMP Creation Schema + *

+ * + * + */ + @JsonProperty("created") + public void setCreated(Date created) { + this.created = created; + } + + /** + * The Dataset Schema + *

+ * + * (Required) + * + */ + @JsonProperty("dataset") + public List getDataset() { + return dataset; + } + + /** + * The Dataset Schema + *

+ * + * (Required) + * + */ + @JsonProperty("dataset") + public void setDataset(List dataset) { + this.dataset = dataset; + } + + /** + * The DMP Description Schema + *

+ * To provide any free-form text information on a DMP + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The DMP Description Schema + *

+ * To provide any free-form text information on a DMP + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The DMP Identifier Schema + *

+ * Identifier for the DMP itself + * (Required) + * + */ + @JsonProperty("dmp_id") + public DmpId getDmpId() { + return dmpId; + } + + /** + * The DMP Identifier Schema + *

+ * Identifier for the DMP itself + * (Required) + * + */ + @JsonProperty("dmp_id") + public void setDmpId(DmpId dmpId) { + this.dmpId = dmpId; + } + + /** + * The DMP Ethical Issues Description Schema + *

+ * To describe ethical issues directly in a DMP + * + */ + @JsonProperty("ethical_issues_description") + public String getEthicalIssuesDescription() { + return ethicalIssuesDescription; + } + + /** + * The DMP Ethical Issues Description Schema + *

+ * To describe ethical issues directly in a DMP + * + */ + @JsonProperty("ethical_issues_description") + public void setEthicalIssuesDescription(String ethicalIssuesDescription) { + this.ethicalIssuesDescription = ethicalIssuesDescription; + } + + /** + * The DMP Ethical Issues Exist Schema + *

+ * To indicate whether there are ethical issues related to data that this DMP describes. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("ethical_issues_exist") + public Dmp.EthicalIssuesExist getEthicalIssuesExist() { + return ethicalIssuesExist; + } + + /** + * The DMP Ethical Issues Exist Schema + *

+ * To indicate whether there are ethical issues related to data that this DMP describes. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("ethical_issues_exist") + public void setEthicalIssuesExist(Dmp.EthicalIssuesExist ethicalIssuesExist) { + this.ethicalIssuesExist = ethicalIssuesExist; + } + + /** + * The DMP Ethical Issues Report Schema + *

+ * To indicate where a protocol from a meeting with an ethical commitee can be found + * + */ + @JsonProperty("ethical_issues_report") + public URI getEthicalIssuesReport() { + return ethicalIssuesReport; + } + + /** + * The DMP Ethical Issues Report Schema + *

+ * To indicate where a protocol from a meeting with an ethical commitee can be found + * + */ + @JsonProperty("ethical_issues_report") + public void setEthicalIssuesReport(URI ethicalIssuesReport) { + this.ethicalIssuesReport = ethicalIssuesReport; + } + + /** + * The DMP Language Schema + *

+ * Language of the DMP expressed using ISO 639-3. + * (Required) + * + */ + @JsonProperty("language") + public Dmp.Language getLanguage() { + return language; + } + + /** + * The DMP Language Schema + *

+ * Language of the DMP expressed using ISO 639-3. + * (Required) + * + */ + @JsonProperty("language") + public void setLanguage(Dmp.Language language) { + this.language = language; + } + + /** + * The DMP Modification Schema + *

+ * Must be set each time DMP is modified. Indicates DMP version. + * (Required) + * + */ + @JsonProperty("modified") + public Date getModified() { + return modified; + } + + /** + * The DMP Modification Schema + *

+ * Must be set each time DMP is modified. Indicates DMP version. + * (Required) + * + */ + @JsonProperty("modified") + public void setModified(Date modified) { + this.modified = modified; + } + + /** + * The DMP Project Schema + *

+ * Project related to a DMP + * + */ + @JsonProperty("project") + public List getProject() { + return project; + } + + /** + * The DMP Project Schema + *

+ * Project related to a DMP + * + */ + @JsonProperty("project") + public void setProject(List project) { + this.project = project; + } + + /** + * The DMP Title Schema + *

+ * Title of a DMP + * (Required) + * + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * The DMP Title Schema + *

+ * Title of a DMP + * (Required) + * + */ + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum EthicalIssuesExist { + + YES("yes"), + NO("no"), + UNKNOWN("unknown"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Dmp.EthicalIssuesExist c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private EthicalIssuesExist(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Dmp.EthicalIssuesExist fromValue(String value) { + Dmp.EthicalIssuesExist constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + + public enum Language { + + AAR("aar"), + ABK("abk"), + AFR("afr"), + AKA("aka"), + AMH("amh"), + ARA("ara"), + ARG("arg"), + ASM("asm"), + AVA("ava"), + AVE("ave"), + AYM("aym"), + AZE("aze"), + BAK("bak"), + BAM("bam"), + BEL("bel"), + BEN("ben"), + BIH("bih"), + BIS("bis"), + BOD("bod"), + BOS("bos"), + BRE("bre"), + BUL("bul"), + CAT("cat"), + CES("ces"), + CHA("cha"), + CHE("che"), + CHU("chu"), + CHV("chv"), + COR("cor"), + COS("cos"), + CRE("cre"), + CYM("cym"), + DAN("dan"), + DEU("deu"), + DIV("div"), + DZO("dzo"), + ELL("ell"), + ENG("eng"), + EPO("epo"), + EST("est"), + EUS("eus"), + EWE("ewe"), + FAO("fao"), + FAS("fas"), + FIJ("fij"), + FIN("fin"), + FRA("fra"), + FRY("fry"), + FUL("ful"), + GLA("gla"), + GLE("gle"), + GLG("glg"), + GLV("glv"), + GRN("grn"), + GUJ("guj"), + HAT("hat"), + HAU("hau"), + HBS("hbs"), + HEB("heb"), + HER("her"), + HIN("hin"), + HMO("hmo"), + HRV("hrv"), + HUN("hun"), + HYE("hye"), + IBO("ibo"), + IDO("ido"), + III("iii"), + IKU("iku"), + ILE("ile"), + INA("ina"), + IND("ind"), + IPK("ipk"), + ISL("isl"), + ITA("ita"), + JAV("jav"), + JPN("jpn"), + KAL("kal"), + KAN("kan"), + KAS("kas"), + KAT("kat"), + KAU("kau"), + KAZ("kaz"), + KHM("khm"), + KIK("kik"), + KIN("kin"), + KIR("kir"), + KOM("kom"), + KON("kon"), + KOR("kor"), + KUA("kua"), + KUR("kur"), + LAO("lao"), + LAT("lat"), + LAV("lav"), + LIM("lim"), + LIN("lin"), + LIT("lit"), + LTZ("ltz"), + LUB("lub"), + LUG("lug"), + MAH("mah"), + MAL("mal"), + MAR("mar"), + MKD("mkd"), + MLG("mlg"), + MLT("mlt"), + MON("mon"), + MRI("mri"), + MSA("msa"), + MYA("mya"), + NAU("nau"), + NAV("nav"), + NBL("nbl"), + NDE("nde"), + NDO("ndo"), + NEP("nep"), + NLD("nld"), + NNO("nno"), + NOB("nob"), + NOR("nor"), + NYA("nya"), + OCI("oci"), + OJI("oji"), + ORI("ori"), + ORM("orm"), + OSS("oss"), + PAN("pan"), + PLI("pli"), + POL("pol"), + POR("por"), + PUS("pus"), + QUE("que"), + ROH("roh"), + RON("ron"), + RUN("run"), + RUS("rus"), + SAG("sag"), + SAN("san"), + SIN("sin"), + SLK("slk"), + SLV("slv"), + SME("sme"), + SMO("smo"), + SNA("sna"), + SND("snd"), + SOM("som"), + SOT("sot"), + SPA("spa"), + SQI("sqi"), + SRD("srd"), + SRP("srp"), + SSW("ssw"), + SUN("sun"), + SWA("swa"), + SWE("swe"), + TAH("tah"), + TAM("tam"), + TAT("tat"), + TEL("tel"), + TGK("tgk"), + TGL("tgl"), + THA("tha"), + TIR("tir"), + TON("ton"), + TSN("tsn"), + TSO("tso"), + TUK("tuk"), + TUR("tur"), + TWI("twi"), + UIG("uig"), + UKR("ukr"), + URD("urd"), + UZB("uzb"), + VEN("ven"), + VIE("vie"), + VOL("vol"), + WLN("wln"), + WOL("wol"), + XHO("xho"), + YID("yid"), + YOR("yor"), + ZHA("zha"), + ZHO("zho"), + ZUL("zul"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Dmp.Language c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Language(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Dmp.Language fromValue(String value) { + Dmp.Language constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/DmpId.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/DmpId.java new file mode 100644 index 000000000..7240efaa4 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/DmpId.java @@ -0,0 +1,156 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The DMP Identifier Schema + *

+ * Identifier for the DMP itself + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "identifier", + "type" +}) +public class DmpId implements Serializable +{ + + /** + * The DMP Identifier Value Schema + *

+ * Identifier for a DMP + * (Required) + * + */ + @JsonProperty("identifier") + @JsonPropertyDescription("Identifier for a DMP") + private String identifier; + /** + * The DMP Identifier Type Schema + *

+ * The DMP Identifier Type. Allowed values: handle, doi, ark, url, other + * (Required) + * + */ + @JsonProperty("type") + @JsonPropertyDescription("The DMP Identifier Type. Allowed values: handle, doi, ark, url, other") + private DmpId.Type type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -6059908070202476841L; + + /** + * The DMP Identifier Value Schema + *

+ * Identifier for a DMP + * (Required) + * + */ + @JsonProperty("identifier") + public String getIdentifier() { + return identifier; + } + + /** + * The DMP Identifier Value Schema + *

+ * Identifier for a DMP + * (Required) + * + */ + @JsonProperty("identifier") + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + * The DMP Identifier Type Schema + *

+ * The DMP Identifier Type. Allowed values: handle, doi, ark, url, other + * (Required) + * + */ + @JsonProperty("type") + public DmpId.Type getType() { + return type; + } + + /** + * The DMP Identifier Type Schema + *

+ * The DMP Identifier Type. Allowed values: handle, doi, ark, url, other + * (Required) + * + */ + @JsonProperty("type") + public void setType(DmpId.Type type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Type { + + HANDLE("handle"), + DOI("doi"), + ARK("ark"), + URL("url"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (DmpId.Type c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Type(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static DmpId.Type fromValue(String value) { + DmpId.Type constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/FunderId.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/FunderId.java new file mode 100644 index 000000000..12b8bb8f7 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/FunderId.java @@ -0,0 +1,154 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Funder ID Schema + *

+ * Funder ID of the associated project + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "identifier", + "type" +}) +public class FunderId implements Serializable +{ + + /** + * The Funder ID Value Schema + *

+ * Funder ID, recommended to use CrossRef Funder Registry. See: https://www.crossref.org/services/funder-registry/ + * (Required) + * + */ + @JsonProperty("identifier") + @JsonPropertyDescription("Funder ID, recommended to use CrossRef Funder Registry. See: https://www.crossref.org/services/funder-registry/") + private String identifier; + /** + * The Funder ID Type Schema + *

+ * Identifier type. Allowed values: fundref, url, other + * (Required) + * + */ + @JsonProperty("type") + @JsonPropertyDescription("Identifier type. Allowed values: fundref, url, other") + private FunderId.Type type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 1783349151334366078L; + + /** + * The Funder ID Value Schema + *

+ * Funder ID, recommended to use CrossRef Funder Registry. See: https://www.crossref.org/services/funder-registry/ + * (Required) + * + */ + @JsonProperty("identifier") + public String getIdentifier() { + return identifier; + } + + /** + * The Funder ID Value Schema + *

+ * Funder ID, recommended to use CrossRef Funder Registry. See: https://www.crossref.org/services/funder-registry/ + * (Required) + * + */ + @JsonProperty("identifier") + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + * The Funder ID Type Schema + *

+ * Identifier type. Allowed values: fundref, url, other + * (Required) + * + */ + @JsonProperty("type") + public FunderId.Type getType() { + return type; + } + + /** + * The Funder ID Type Schema + *

+ * Identifier type. Allowed values: fundref, url, other + * (Required) + * + */ + @JsonProperty("type") + public void setType(FunderId.Type type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Type { + + FUNDREF("fundref"), + URL("url"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (FunderId.Type c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Type(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static FunderId.Type fromValue(String value) { + FunderId.Type constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Funding.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Funding.java new file mode 100644 index 000000000..0cc378e7c --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Funding.java @@ -0,0 +1,187 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The DMP Project Funding Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "funder_id", + "funding_status", + "grant_id" +}) +public class Funding implements Serializable +{ + + /** + * The Funder ID Schema + *

+ * Funder ID of the associated project + * (Required) + * + */ + @JsonProperty("funder_id") + @JsonPropertyDescription("Funder ID of the associated project") + private FunderId funderId; + /** + * The Funding Status Schema + *

+ * To express different phases of project lifecycle. Allowed values: planned, applied, granted, rejected + * + */ + @JsonProperty("funding_status") + @JsonPropertyDescription("To express different phases of project lifecycle. Allowed values: planned, applied, granted, rejected") + private Funding.FundingStatus fundingStatus; + /** + * The Funding Grant ID Schema + *

+ * Grant ID of the associated project + * (Required) + * + */ + @JsonProperty("grant_id") + @JsonPropertyDescription("Grant ID of the associated project") + private GrantId grantId; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 8962229321225336165L; + + /** + * The Funder ID Schema + *

+ * Funder ID of the associated project + * (Required) + * + */ + @JsonProperty("funder_id") + public FunderId getFunderId() { + return funderId; + } + + /** + * The Funder ID Schema + *

+ * Funder ID of the associated project + * (Required) + * + */ + @JsonProperty("funder_id") + public void setFunderId(FunderId funderId) { + this.funderId = funderId; + } + + /** + * The Funding Status Schema + *

+ * To express different phases of project lifecycle. Allowed values: planned, applied, granted, rejected + * + */ + @JsonProperty("funding_status") + public Funding.FundingStatus getFundingStatus() { + return fundingStatus; + } + + /** + * The Funding Status Schema + *

+ * To express different phases of project lifecycle. Allowed values: planned, applied, granted, rejected + * + */ + @JsonProperty("funding_status") + public void setFundingStatus(Funding.FundingStatus fundingStatus) { + this.fundingStatus = fundingStatus; + } + + /** + * The Funding Grant ID Schema + *

+ * Grant ID of the associated project + * (Required) + * + */ + @JsonProperty("grant_id") + public GrantId getGrantId() { + return grantId; + } + + /** + * The Funding Grant ID Schema + *

+ * Grant ID of the associated project + * (Required) + * + */ + @JsonProperty("grant_id") + public void setGrantId(GrantId grantId) { + this.grantId = grantId; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum FundingStatus { + + PLANNED("planned"), + APPLIED("applied"), + GRANTED("granted"), + REJECTED("rejected"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Funding.FundingStatus c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private FundingStatus(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Funding.FundingStatus fromValue(String value) { + Funding.FundingStatus constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/GrantId.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/GrantId.java new file mode 100644 index 000000000..cb994a0ba --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/GrantId.java @@ -0,0 +1,153 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Funding Grant ID Schema + *

+ * Grant ID of the associated project + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "identifier", + "type" +}) +public class GrantId implements Serializable +{ + + /** + * The Funding Grant ID Value Schema + *

+ * Grant ID + * (Required) + * + */ + @JsonProperty("identifier") + @JsonPropertyDescription("Grant ID") + private String identifier; + /** + * The Funding Grant ID Type Schema + *

+ * Identifier type. Allowed values: url, other + * (Required) + * + */ + @JsonProperty("type") + @JsonPropertyDescription("Identifier type. Allowed values: url, other") + private GrantId.Type type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -7738072672837592065L; + + /** + * The Funding Grant ID Value Schema + *

+ * Grant ID + * (Required) + * + */ + @JsonProperty("identifier") + public String getIdentifier() { + return identifier; + } + + /** + * The Funding Grant ID Value Schema + *

+ * Grant ID + * (Required) + * + */ + @JsonProperty("identifier") + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + * The Funding Grant ID Type Schema + *

+ * Identifier type. Allowed values: url, other + * (Required) + * + */ + @JsonProperty("type") + public GrantId.Type getType() { + return type; + } + + /** + * The Funding Grant ID Type Schema + *

+ * Identifier type. Allowed values: url, other + * (Required) + * + */ + @JsonProperty("type") + public void setType(GrantId.Type type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Type { + + URL("url"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (GrantId.Type c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Type(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static GrantId.Type fromValue(String value) { + GrantId.Type constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Host.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Host.java new file mode 100644 index 000000000..bfa6ec615 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Host.java @@ -0,0 +1,775 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.net.URI; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Dataset Distribution Host Schema + *

+ * To provide information on quality of service provided by infrastructure (e.g. repository) where data is stored. + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "availability", + "backup_frequency", + "backup_type", + "certified_with", + "description", + "geo_location", + "pid_system", + "storage_type", + "support_versioning", + "title", + "url" +}) +public class Host implements Serializable +{ + + /** + * The Dataset Distribution Host Availability Schema + *

+ * Availability + * + */ + @JsonProperty("availability") + @JsonPropertyDescription("Availability") + private String availability; + /** + * The Dataset Distribution Host Backup Frequency Schema + *

+ * Backup Frequency + * + */ + @JsonProperty("backup_frequency") + @JsonPropertyDescription("Backup Frequency") + private String backupFrequency; + /** + * The Dataset Distribution Host Backup Type Schema + *

+ * Backup Type + * + */ + @JsonProperty("backup_type") + @JsonPropertyDescription("Backup Type") + private String backupType; + /** + * The Dataset Distribution Host Certification Type Schema + *

+ * Repository certified to a recognised standard. Allowed values: din31644, dini-zertifikat, dsa, iso16363, iso16919, trac, wds, coretrustseal + * + */ + @JsonProperty("certified_with") + @JsonPropertyDescription("Repository certified to a recognised standard. Allowed values: din31644, dini-zertifikat, dsa, iso16363, iso16919, trac, wds, coretrustseal") + private Host.CertifiedWith certifiedWith; + /** + * The Dataset Distribution Host Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Description") + private String description; + /** + * The Dataset Distribution Host Geographical Location Schema + *

+ * Physical location of the data expressed using ISO 3166-1 country code. + * + */ + @JsonProperty("geo_location") + @JsonPropertyDescription("Physical location of the data expressed using ISO 3166-1 country code.") + private Host.GeoLocation geoLocation; + /** + * The Dataset Distribution Host PID System Schema + *

+ * PID system(s). Allowed values: ark, arxiv, bibcode, doi, ean13, eissn, handle, igsn, isbn, issn, istc, lissn, lsid, pmid, purl, upc, url, urn, other + * + */ + @JsonProperty("pid_system") + @JsonPropertyDescription("PID system(s). Allowed values: ark, arxiv, bibcode, doi, ean13, eissn, handle, igsn, isbn, issn, istc, lissn, lsid, pmid, purl, upc, url, urn, other") + private List pidSystem = null; + /** + * The Dataset Distribution Host Storage Type Schema + *

+ * The type of storage required + * + */ + @JsonProperty("storage_type") + @JsonPropertyDescription("The type of storage required") + private String storageType; + /** + * The Dataset Distribution Host Support Versioning Schema + *

+ * If host supports versioning. Allowed values: yes, no, unknown + * + */ + @JsonProperty("support_versioning") + @JsonPropertyDescription("If host supports versioning. Allowed values: yes, no, unknown") + private Host.SupportVersioning supportVersioning; + /** + * The Dataset Distribution Host Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + @JsonPropertyDescription("Title") + private String title; + /** + * The Dataset Distribution Host Title Schema + *

+ * The URL of the system hosting a distribution of a dataset + * (Required) + * + */ + @JsonProperty("url") + @JsonPropertyDescription("The URL of the system hosting a distribution of a dataset") + private URI url; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 8564338806797654115L; + + /** + * The Dataset Distribution Host Availability Schema + *

+ * Availability + * + */ + @JsonProperty("availability") + public String getAvailability() { + return availability; + } + + /** + * The Dataset Distribution Host Availability Schema + *

+ * Availability + * + */ + @JsonProperty("availability") + public void setAvailability(String availability) { + this.availability = availability; + } + + /** + * The Dataset Distribution Host Backup Frequency Schema + *

+ * Backup Frequency + * + */ + @JsonProperty("backup_frequency") + public String getBackupFrequency() { + return backupFrequency; + } + + /** + * The Dataset Distribution Host Backup Frequency Schema + *

+ * Backup Frequency + * + */ + @JsonProperty("backup_frequency") + public void setBackupFrequency(String backupFrequency) { + this.backupFrequency = backupFrequency; + } + + /** + * The Dataset Distribution Host Backup Type Schema + *

+ * Backup Type + * + */ + @JsonProperty("backup_type") + public String getBackupType() { + return backupType; + } + + /** + * The Dataset Distribution Host Backup Type Schema + *

+ * Backup Type + * + */ + @JsonProperty("backup_type") + public void setBackupType(String backupType) { + this.backupType = backupType; + } + + /** + * The Dataset Distribution Host Certification Type Schema + *

+ * Repository certified to a recognised standard. Allowed values: din31644, dini-zertifikat, dsa, iso16363, iso16919, trac, wds, coretrustseal + * + */ + @JsonProperty("certified_with") + public Host.CertifiedWith getCertifiedWith() { + return certifiedWith; + } + + /** + * The Dataset Distribution Host Certification Type Schema + *

+ * Repository certified to a recognised standard. Allowed values: din31644, dini-zertifikat, dsa, iso16363, iso16919, trac, wds, coretrustseal + * + */ + @JsonProperty("certified_with") + public void setCertifiedWith(Host.CertifiedWith certifiedWith) { + this.certifiedWith = certifiedWith; + } + + /** + * The Dataset Distribution Host Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The Dataset Distribution Host Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The Dataset Distribution Host Geographical Location Schema + *

+ * Physical location of the data expressed using ISO 3166-1 country code. + * + */ + @JsonProperty("geo_location") + public Host.GeoLocation getGeoLocation() { + return geoLocation; + } + + /** + * The Dataset Distribution Host Geographical Location Schema + *

+ * Physical location of the data expressed using ISO 3166-1 country code. + * + */ + @JsonProperty("geo_location") + public void setGeoLocation(Host.GeoLocation geoLocation) { + this.geoLocation = geoLocation; + } + + /** + * The Dataset Distribution Host PID System Schema + *

+ * PID system(s). Allowed values: ark, arxiv, bibcode, doi, ean13, eissn, handle, igsn, isbn, issn, istc, lissn, lsid, pmid, purl, upc, url, urn, other + * + */ + @JsonProperty("pid_system") + public List getPidSystem() { + return pidSystem; + } + + /** + * The Dataset Distribution Host PID System Schema + *

+ * PID system(s). Allowed values: ark, arxiv, bibcode, doi, ean13, eissn, handle, igsn, isbn, issn, istc, lissn, lsid, pmid, purl, upc, url, urn, other + * + */ + @JsonProperty("pid_system") + public void setPidSystem(List pidSystem) { + this.pidSystem = pidSystem; + } + + /** + * The Dataset Distribution Host Storage Type Schema + *

+ * The type of storage required + * + */ + @JsonProperty("storage_type") + public String getStorageType() { + return storageType; + } + + /** + * The Dataset Distribution Host Storage Type Schema + *

+ * The type of storage required + * + */ + @JsonProperty("storage_type") + public void setStorageType(String storageType) { + this.storageType = storageType; + } + + /** + * The Dataset Distribution Host Support Versioning Schema + *

+ * If host supports versioning. Allowed values: yes, no, unknown + * + */ + @JsonProperty("support_versioning") + public Host.SupportVersioning getSupportVersioning() { + return supportVersioning; + } + + /** + * The Dataset Distribution Host Support Versioning Schema + *

+ * If host supports versioning. Allowed values: yes, no, unknown + * + */ + @JsonProperty("support_versioning") + public void setSupportVersioning(Host.SupportVersioning supportVersioning) { + this.supportVersioning = supportVersioning; + } + + /** + * The Dataset Distribution Host Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * The Dataset Distribution Host Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } + + /** + * The Dataset Distribution Host Title Schema + *

+ * The URL of the system hosting a distribution of a dataset + * (Required) + * + */ + @JsonProperty("url") + public URI getUrl() { + return url; + } + + /** + * The Dataset Distribution Host Title Schema + *

+ * The URL of the system hosting a distribution of a dataset + * (Required) + * + */ + @JsonProperty("url") + public void setUrl(URI url) { + this.url = url; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum CertifiedWith { + + DIN_31644("din31644"), + DINI_ZERTIFIKAT("dini-zertifikat"), + DSA("dsa"), + ISO_16363("iso16363"), + ISO_16919("iso16919"), + TRAC("trac"), + WDS("wds"), + CORETRUSTSEAL("coretrustseal"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Host.CertifiedWith c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private CertifiedWith(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Host.CertifiedWith fromValue(String value) { + Host.CertifiedWith constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + + public enum GeoLocation { + + AD("AD"), + AE("AE"), + AF("AF"), + AG("AG"), + AI("AI"), + AL("AL"), + AM("AM"), + AO("AO"), + AQ("AQ"), + AR("AR"), + AS("AS"), + AT("AT"), + AU("AU"), + AW("AW"), + AX("AX"), + AZ("AZ"), + BA("BA"), + BB("BB"), + BD("BD"), + BE("BE"), + BF("BF"), + BG("BG"), + BH("BH"), + BI("BI"), + BJ("BJ"), + BL("BL"), + BM("BM"), + BN("BN"), + BO("BO"), + BQ("BQ"), + BR("BR"), + BS("BS"), + BT("BT"), + BV("BV"), + BW("BW"), + BY("BY"), + BZ("BZ"), + CA("CA"), + CC("CC"), + CD("CD"), + CF("CF"), + CG("CG"), + CH("CH"), + CI("CI"), + CK("CK"), + CL("CL"), + CM("CM"), + CN("CN"), + CO("CO"), + CR("CR"), + CU("CU"), + CV("CV"), + CW("CW"), + CX("CX"), + CY("CY"), + CZ("CZ"), + DE("DE"), + DJ("DJ"), + DK("DK"), + DM("DM"), + DO("DO"), + DZ("DZ"), + EC("EC"), + EE("EE"), + EG("EG"), + EH("EH"), + ER("ER"), + ES("ES"), + ET("ET"), + FI("FI"), + FJ("FJ"), + FK("FK"), + FM("FM"), + FO("FO"), + FR("FR"), + GA("GA"), + GB("GB"), + GD("GD"), + GE("GE"), + GF("GF"), + GG("GG"), + GH("GH"), + GI("GI"), + GL("GL"), + GM("GM"), + GN("GN"), + GP("GP"), + GQ("GQ"), + GR("GR"), + GS("GS"), + GT("GT"), + GU("GU"), + GW("GW"), + GY("GY"), + HK("HK"), + HM("HM"), + HN("HN"), + HR("HR"), + HT("HT"), + HU("HU"), + ID("ID"), + IE("IE"), + IL("IL"), + IM("IM"), + IN("IN"), + IO("IO"), + IQ("IQ"), + IR("IR"), + IS("IS"), + IT("IT"), + JE("JE"), + JM("JM"), + JO("JO"), + JP("JP"), + KE("KE"), + KG("KG"), + KH("KH"), + KI("KI"), + KM("KM"), + KN("KN"), + KP("KP"), + KR("KR"), + KW("KW"), + KY("KY"), + KZ("KZ"), + LA("LA"), + LB("LB"), + LC("LC"), + LI("LI"), + LK("LK"), + LR("LR"), + LS("LS"), + LT("LT"), + LU("LU"), + LV("LV"), + LY("LY"), + MA("MA"), + MC("MC"), + MD("MD"), + ME("ME"), + MF("MF"), + MG("MG"), + MH("MH"), + MK("MK"), + ML("ML"), + MM("MM"), + MN("MN"), + MO("MO"), + MP("MP"), + MQ("MQ"), + MR("MR"), + MS("MS"), + MT("MT"), + MU("MU"), + MV("MV"), + MW("MW"), + MX("MX"), + MY("MY"), + MZ("MZ"), + NA("NA"), + NC("NC"), + NE("NE"), + NF("NF"), + NG("NG"), + NI("NI"), + NL("NL"), + NO("NO"), + NP("NP"), + NR("NR"), + NU("NU"), + NZ("NZ"), + OM("OM"), + PA("PA"), + PE("PE"), + PF("PF"), + PG("PG"), + PH("PH"), + PK("PK"), + PL("PL"), + PM("PM"), + PN("PN"), + PR("PR"), + PS("PS"), + PT("PT"), + PW("PW"), + PY("PY"), + QA("QA"), + RE("RE"), + RO("RO"), + RS("RS"), + RU("RU"), + RW("RW"), + SA("SA"), + SB("SB"), + SC("SC"), + SD("SD"), + SE("SE"), + SG("SG"), + SH("SH"), + SI("SI"), + SJ("SJ"), + SK("SK"), + SL("SL"), + SM("SM"), + SN("SN"), + SO("SO"), + SR("SR"), + SS("SS"), + ST("ST"), + SV("SV"), + SX("SX"), + SY("SY"), + SZ("SZ"), + TC("TC"), + TD("TD"), + TF("TF"), + TG("TG"), + TH("TH"), + TJ("TJ"), + TK("TK"), + TL("TL"), + TM("TM"), + TN("TN"), + TO("TO"), + TR("TR"), + TT("TT"), + TV("TV"), + TW("TW"), + TZ("TZ"), + UA("UA"), + UG("UG"), + UM("UM"), + US("US"), + UY("UY"), + UZ("UZ"), + VA("VA"), + VC("VC"), + VE("VE"), + VG("VG"), + VI("VI"), + VN("VN"), + VU("VU"), + WF("WF"), + WS("WS"), + YE("YE"), + YT("YT"), + ZA("ZA"), + ZM("ZM"), + ZW("ZW"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Host.GeoLocation c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private GeoLocation(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Host.GeoLocation fromValue(String value) { + Host.GeoLocation constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + + public enum SupportVersioning { + + YES("yes"), + NO("no"), + UNKNOWN("unknown"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Host.SupportVersioning c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private SupportVersioning(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Host.SupportVersioning fromValue(String value) { + Host.SupportVersioning constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/License.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/License.java new file mode 100644 index 000000000..1527f5503 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/License.java @@ -0,0 +1,113 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.net.URI; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * The Dataset Distribution License Items + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "license_ref", + "start_date" +}) +public class License implements Serializable +{ + + /** + * The Dataset Distribution License Reference Schema + *

+ * Link to license document. + * (Required) + * + */ + @JsonProperty("license_ref") + @JsonPropertyDescription("Link to license document.") + private URI licenseRef; + /** + * The Dataset Distribution License Start Date Schema + *

+ * Starting date of license. If date is set in the future, it indicates embargo period. + * (Required) + * + */ + @JsonProperty("start_date") + @JsonPropertyDescription("Starting date of license. If date is set in the future, it indicates embargo period.") + private String startDate; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 4148207295817559010L; + + /** + * The Dataset Distribution License Reference Schema + *

+ * Link to license document. + * (Required) + * + */ + @JsonProperty("license_ref") + public URI getLicenseRef() { + return licenseRef; + } + + /** + * The Dataset Distribution License Reference Schema + *

+ * Link to license document. + * (Required) + * + */ + @JsonProperty("license_ref") + public void setLicenseRef(URI licenseRef) { + this.licenseRef = licenseRef; + } + + /** + * The Dataset Distribution License Start Date Schema + *

+ * Starting date of license. If date is set in the future, it indicates embargo period. + * (Required) + * + */ + @JsonProperty("start_date") + public String getStartDate() { + return startDate; + } + + /** + * The Dataset Distribution License Start Date Schema + *

+ * Starting date of license. If date is set in the future, it indicates embargo period. + * (Required) + * + */ + @JsonProperty("start_date") + public void setStartDate(String startDate) { + this.startDate = startDate; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/MetadataStandardId.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/MetadataStandardId.java new file mode 100644 index 000000000..06b54a1f1 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/MetadataStandardId.java @@ -0,0 +1,153 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Dataset Metadata Standard ID Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "identifier", + "type" +}) +public class MetadataStandardId implements Serializable +{ + + /** + * The Dataset Metadata Standard Identifier Value Schema + *

+ * Identifier for the metadata standard used. + * (Required) + * + */ + @JsonProperty("identifier") + @JsonPropertyDescription("Identifier for the metadata standard used.") + private String identifier; + /** + * The Dataset Metadata Standard Identifier Type Schema + *

+ * Identifier type. Allowed values: url, other + * (Required) + * + */ + @JsonProperty("type") + @JsonPropertyDescription("Identifier type. Allowed values: url, other") + private MetadataStandardId.Type type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -7641042701935397947L; + + /** + * The Dataset Metadata Standard Identifier Value Schema + *

+ * Identifier for the metadata standard used. + * (Required) + * + */ + @JsonProperty("identifier") + public String getIdentifier() { + return identifier; + } + + /** + * The Dataset Metadata Standard Identifier Value Schema + *

+ * Identifier for the metadata standard used. + * (Required) + * + */ + @JsonProperty("identifier") + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + * The Dataset Metadata Standard Identifier Type Schema + *

+ * Identifier type. Allowed values: url, other + * (Required) + * + */ + @JsonProperty("type") + public MetadataStandardId.Type getType() { + return type; + } + + /** + * The Dataset Metadata Standard Identifier Type Schema + *

+ * Identifier type. Allowed values: url, other + * (Required) + * + */ + @JsonProperty("type") + public void setType(MetadataStandardId.Type type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Type { + + URL("url"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (MetadataStandardId.Type c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Type(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static MetadataStandardId.Type fromValue(String value) { + MetadataStandardId.Type constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java new file mode 100644 index 000000000..d6057ca62 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java @@ -0,0 +1,368 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Dataset Metadata Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "description", + "language", + "metadata_standard_id" +}) +public class Metadatum implements Serializable +{ + + /** + * The Dataset Metadata Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Description") + private String description; + /** + * The Dataset Metadata Language Schema + *

+ * Language of the metadata expressed using ISO 639-3. + * (Required) + * + */ + @JsonProperty("language") + @JsonPropertyDescription("Language of the metadata expressed using ISO 639-3.") + private Metadatum.Language language; + /** + * The Dataset Metadata Standard ID Schema + *

+ * + * (Required) + * + */ + @JsonProperty("metadata_standard_id") + private MetadataStandardId metadataStandardId; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 6511312853153406190L; + + /** + * The Dataset Metadata Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The Dataset Metadata Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The Dataset Metadata Language Schema + *

+ * Language of the metadata expressed using ISO 639-3. + * (Required) + * + */ + @JsonProperty("language") + public Metadatum.Language getLanguage() { + return language; + } + + /** + * The Dataset Metadata Language Schema + *

+ * Language of the metadata expressed using ISO 639-3. + * (Required) + * + */ + @JsonProperty("language") + public void setLanguage(Metadatum.Language language) { + this.language = language; + } + + /** + * The Dataset Metadata Standard ID Schema + *

+ * + * (Required) + * + */ + @JsonProperty("metadata_standard_id") + public MetadataStandardId getMetadataStandardId() { + return metadataStandardId; + } + + /** + * The Dataset Metadata Standard ID Schema + *

+ * + * (Required) + * + */ + @JsonProperty("metadata_standard_id") + public void setMetadataStandardId(MetadataStandardId metadataStandardId) { + this.metadataStandardId = metadataStandardId; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Language { + + AAR("aar"), + ABK("abk"), + AFR("afr"), + AKA("aka"), + AMH("amh"), + ARA("ara"), + ARG("arg"), + ASM("asm"), + AVA("ava"), + AVE("ave"), + AYM("aym"), + AZE("aze"), + BAK("bak"), + BAM("bam"), + BEL("bel"), + BEN("ben"), + BIH("bih"), + BIS("bis"), + BOD("bod"), + BOS("bos"), + BRE("bre"), + BUL("bul"), + CAT("cat"), + CES("ces"), + CHA("cha"), + CHE("che"), + CHU("chu"), + CHV("chv"), + COR("cor"), + COS("cos"), + CRE("cre"), + CYM("cym"), + DAN("dan"), + DEU("deu"), + DIV("div"), + DZO("dzo"), + ELL("ell"), + ENG("eng"), + EPO("epo"), + EST("est"), + EUS("eus"), + EWE("ewe"), + FAO("fao"), + FAS("fas"), + FIJ("fij"), + FIN("fin"), + FRA("fra"), + FRY("fry"), + FUL("ful"), + GLA("gla"), + GLE("gle"), + GLG("glg"), + GLV("glv"), + GRN("grn"), + GUJ("guj"), + HAT("hat"), + HAU("hau"), + HBS("hbs"), + HEB("heb"), + HER("her"), + HIN("hin"), + HMO("hmo"), + HRV("hrv"), + HUN("hun"), + HYE("hye"), + IBO("ibo"), + IDO("ido"), + III("iii"), + IKU("iku"), + ILE("ile"), + INA("ina"), + IND("ind"), + IPK("ipk"), + ISL("isl"), + ITA("ita"), + JAV("jav"), + JPN("jpn"), + KAL("kal"), + KAN("kan"), + KAS("kas"), + KAT("kat"), + KAU("kau"), + KAZ("kaz"), + KHM("khm"), + KIK("kik"), + KIN("kin"), + KIR("kir"), + KOM("kom"), + KON("kon"), + KOR("kor"), + KUA("kua"), + KUR("kur"), + LAO("lao"), + LAT("lat"), + LAV("lav"), + LIM("lim"), + LIN("lin"), + LIT("lit"), + LTZ("ltz"), + LUB("lub"), + LUG("lug"), + MAH("mah"), + MAL("mal"), + MAR("mar"), + MKD("mkd"), + MLG("mlg"), + MLT("mlt"), + MON("mon"), + MRI("mri"), + MSA("msa"), + MYA("mya"), + NAU("nau"), + NAV("nav"), + NBL("nbl"), + NDE("nde"), + NDO("ndo"), + NEP("nep"), + NLD("nld"), + NNO("nno"), + NOB("nob"), + NOR("nor"), + NYA("nya"), + OCI("oci"), + OJI("oji"), + ORI("ori"), + ORM("orm"), + OSS("oss"), + PAN("pan"), + PLI("pli"), + POL("pol"), + POR("por"), + PUS("pus"), + QUE("que"), + ROH("roh"), + RON("ron"), + RUN("run"), + RUS("rus"), + SAG("sag"), + SAN("san"), + SIN("sin"), + SLK("slk"), + SLV("slv"), + SME("sme"), + SMO("smo"), + SNA("sna"), + SND("snd"), + SOM("som"), + SOT("sot"), + SPA("spa"), + SQI("sqi"), + SRD("srd"), + SRP("srp"), + SSW("ssw"), + SUN("sun"), + SWA("swa"), + SWE("swe"), + TAH("tah"), + TAM("tam"), + TAT("tat"), + TEL("tel"), + TGK("tgk"), + TGL("tgl"), + THA("tha"), + TIR("tir"), + TON("ton"), + TSN("tsn"), + TSO("tso"), + TUK("tuk"), + TUR("tur"), + TWI("twi"), + UIG("uig"), + UKR("ukr"), + URD("urd"), + UZB("uzb"), + VEN("ven"), + VIE("vie"), + VOL("vol"), + WLN("wln"), + WOL("wol"), + XHO("xho"), + YID("yid"), + YOR("yor"), + ZHA("zha"), + ZHO("zho"), + ZUL("zul"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Metadatum.Language c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Language(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Metadatum.Language fromValue(String value) { + Metadatum.Language constant = CONSTANTS.get(value); + if (constant == null) { + return null; +// throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/PidSystem.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/PidSystem.java new file mode 100644 index 000000000..0e29d1153 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/PidSystem.java @@ -0,0 +1,63 @@ + +package eu.eudat.models.rda; + +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public enum PidSystem { + + ARK("ark"), + ARXIV("arxiv"), + BIBCODE("bibcode"), + DOI("doi"), + EAN_13("ean13"), + EISSN("eissn"), + HANDLE("handle"), + IGSN("igsn"), + ISBN("isbn"), + ISSN("issn"), + ISTC("istc"), + LISSN("lissn"), + LSID("lsid"), + PMID("pmid"), + PURL("purl"), + UPC("upc"), + URL("url"), + URN("urn"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (PidSystem c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private PidSystem(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static PidSystem fromValue(String value) { + PidSystem constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Project.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Project.java new file mode 100644 index 000000000..09c231ca3 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Project.java @@ -0,0 +1,212 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * The DMP Project Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "description", + "end", + "funding", + "start", + "title" +}) +public class Project implements Serializable +{ + + /** + * The DMP Project Description Schema + *

+ * Project description + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Project description") + private String description; + /** + * The DMP Project End Date Schema + *

+ * Project end date + * (Required) + * + */ + @JsonProperty("end") + @JsonPropertyDescription("Project end date") + private String end; + /** + * The DMP Project Funding Schema + *

+ * Funding related with a project + * + */ + @JsonProperty("funding") + @JsonPropertyDescription("Funding related with a project") + private List funding = null; + /** + * The DMP Project Start Date Schema + *

+ * Project start date + * (Required) + * + */ + @JsonProperty("start") + @JsonPropertyDescription("Project start date") + private String start; + /** + * The DMP Project Title Schema + *

+ * Project title + * (Required) + * + */ + @JsonProperty("title") + @JsonPropertyDescription("Project title") + private String title; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 1437619307195890472L; + + /** + * The DMP Project Description Schema + *

+ * Project description + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The DMP Project Description Schema + *

+ * Project description + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The DMP Project End Date Schema + *

+ * Project end date + * (Required) + * + */ + @JsonProperty("end") + public String getEnd() { + return end; + } + + /** + * The DMP Project End Date Schema + *

+ * Project end date + * (Required) + * + */ + @JsonProperty("end") + public void setEnd(String end) { + this.end = end; + } + + /** + * The DMP Project Funding Schema + *

+ * Funding related with a project + * + */ + @JsonProperty("funding") + public List getFunding() { + return funding; + } + + /** + * The DMP Project Funding Schema + *

+ * Funding related with a project + * + */ + @JsonProperty("funding") + public void setFunding(List funding) { + this.funding = funding; + } + + /** + * The DMP Project Start Date Schema + *

+ * Project start date + * (Required) + * + */ + @JsonProperty("start") + public String getStart() { + return start; + } + + /** + * The DMP Project Start Date Schema + *

+ * Project start date + * (Required) + * + */ + @JsonProperty("start") + public void setStart(String start) { + this.start = start; + } + + /** + * The DMP Project Title Schema + *

+ * Project title + * (Required) + * + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * The DMP Project Title Schema + *

+ * Project title + * (Required) + * + */ + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/RDAModel.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/RDAModel.java new file mode 100644 index 000000000..61df61b32 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/RDAModel.java @@ -0,0 +1,58 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * RDA DMP Common Standard Schema + *

+ * JSON Schema for the RDA DMP Common Standard + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "dmp" +}) +public class RDAModel implements Serializable +{ + + /** + * The DMP Schema + *

+ * + * (Required) + * + */ + @JsonProperty("dmp") + private Dmp dmp; + private final static long serialVersionUID = 7331666133368350998L; + + /** + * The DMP Schema + *

+ * + * (Required) + * + */ + @JsonProperty("dmp") + public Dmp getDmp() { + return dmp; + } + + /** + * The DMP Schema + *

+ * + * (Required) + * + */ + @JsonProperty("dmp") + public void setDmp(Dmp dmp) { + this.dmp = dmp; + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java new file mode 100644 index 000000000..0486df588 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java @@ -0,0 +1,109 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * The Dataset Security & Policy Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "description", + "title" +}) +public class SecurityAndPrivacy implements Serializable +{ + + /** + * The Dataset Security & Policy Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Description") + private String description; + /** + * The Dataset Security & Policy Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + @JsonPropertyDescription("Title") + private String title; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 7863747935827682977L; + + /** + * The Dataset Security & Policy Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The Dataset Security & Policy Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The Dataset Security & Policy Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * The Dataset Security & Policy Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java new file mode 100644 index 000000000..eac85da72 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java @@ -0,0 +1,109 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * The Dataset Technical Resource Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "description", + "name" +}) +public class TechnicalResource implements Serializable +{ + + /** + * The Dataset Technical Resource Description Schema + *

+ * Description of the technical resource + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Description of the technical resource") + private String description; + /** + * The Dataset Technical Resource Name Schema + *

+ * Name of the technical resource + * (Required) + * + */ + @JsonProperty("name") + @JsonPropertyDescription("Name of the technical resource") + private String name; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -7451757227129483110L; + + /** + * The Dataset Technical Resource Description Schema + *

+ * Description of the technical resource + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The Dataset Technical Resource Description Schema + *

+ * Description of the technical resource + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The Dataset Technical Resource Name Schema + *

+ * Name of the technical resource + * (Required) + * + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * The Dataset Technical Resource Name Schema + *

+ * Name of the technical resource + * (Required) + * + */ + @JsonProperty("name") + public void setName(String name) { + this.name = name; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java new file mode 100644 index 000000000..48549d75a --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java @@ -0,0 +1,15 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.models.rda.ContactId; + +import java.util.UUID; + +public class ContactIdRDAMapper { + + public static ContactId toRDA(UUID id) { + ContactId rda = new ContactId(); + rda.setIdentifier(id.toString()); + rda.setType(ContactId.Type.OTHER); + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java new file mode 100644 index 000000000..69ea2310e --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java @@ -0,0 +1,16 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.data.entities.UserInfo; +import eu.eudat.models.rda.Contact; +import eu.eudat.models.rda.ContactId; + +public class ContactRDAMapper { + + public static Contact toRDA(UserInfo creator) { + Contact rda = new Contact(); + rda.setName(creator.getName()); + rda.setMbox(creator.getEmail()); + rda.setContactId(ContactIdRDAMapper.toRDA(creator.getId())); + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorIdRDAMapper.java new file mode 100644 index 000000000..107dfb996 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorIdRDAMapper.java @@ -0,0 +1,16 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.models.rda.Contributor; +import eu.eudat.models.rda.ContributorId; + +import java.util.UUID; + +public class ContributorIdRDAMapper { + + public static ContributorId toRDA(UUID id) { + ContributorId rda = new ContributorId(); + rda.setIdentifier(id.toString()); + rda.setType(ContributorId.Type.OTHER); + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorRDAMapper.java new file mode 100644 index 000000000..681d98940 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorRDAMapper.java @@ -0,0 +1,20 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.data.entities.UserDMP; +import eu.eudat.models.rda.Contributor; + +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; + +public class ContributorRDAMapper { + + public static Contributor toRDA(UserDMP userDMP) { + Contributor rda = new Contributor(); + rda.setContributorId(ContributorIdRDAMapper.toRDA(userDMP.getUser().getId())); + rda.setName(userDMP.getUser().getName()); + rda.setMbox(userDMP.getUser().getEmail()); + rda.setRole(new HashSet<>(Arrays.asList(UserDMP.UserDMPRoles.fromInteger(userDMP.getRole()).name()))); + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetIdRDAMapper.java new file mode 100644 index 000000000..ab791e215 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetIdRDAMapper.java @@ -0,0 +1,17 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.databind.ObjectMapper; +import eu.eudat.models.rda.DatasetId; + +import java.util.UUID; + +public class DatasetIdRDAMapper { + + public static DatasetId toRDA(UUID id) { + DatasetId rda = new DatasetId(); + rda.setIdentifier(id.toString()); + rda.setType(DatasetId.Type.OTHER); + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java new file mode 100644 index 000000000..103ba72c6 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java @@ -0,0 +1,100 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import eu.eudat.logic.managers.DatasetManager; +import eu.eudat.logic.utilities.json.JsonSearcher; +import eu.eudat.models.data.datasetwizard.DatasetWizardModel; +import eu.eudat.models.rda.Dataset; +import org.json.JSONObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.transaction.Transactional; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.stream.Collectors; + +@Component +public class DatasetRDAMapper { + private static final Logger logger = LoggerFactory.getLogger(DatasetRDAMapper.class); + + private DatasetManager datasetManager; + + @Autowired + public DatasetRDAMapper(DatasetManager datasetManager) { + this.datasetManager = datasetManager; + } + + @Transactional + public Dataset toRDA(eu.eudat.data.entities.Dataset dataset) { + Dataset rda = new Dataset(); + rda.setDatasetId(DatasetIdRDAMapper.toRDA(dataset.getId())); + rda.setTitle(dataset.getLabel()); + rda.setDescription(dataset.getDescription()); + try { + + DatasetWizardModel datasetWizardModel = new DatasetWizardModel().fromDataModel(dataset); + datasetWizardModel.setDatasetProfileDefinition(datasetManager.getPagedProfile(datasetWizardModel, dataset)); + ObjectMapper mapper = new ObjectMapper(); + JsonNode properties = mapper.readTree(dataset.getProperties()); + String datasetDescriptionJson = mapper.writeValueAsString(datasetWizardModel.getDatasetProfileDefinition()); + JsonNode datasetDescriptionObj = mapper.readTree(datasetDescriptionJson); + List typeNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.type"); + if (!typeNodes.isEmpty()) { + rda.setType(properties.get(typeNodes.get(0).get("id").asText()).asText()); + } + List languageNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.language"); + if (!languageNodes.isEmpty()) { + rda.setLanguage(Dataset.Language.fromValue(properties.get(languageNodes.get(0).get("id").asText()).asText())); + } + List metadataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.metadata"); + if (!metadataNodes.isEmpty()) { + rda.setMetadata(metadataNodes.stream().map(node -> MetadataRDAMapper.toRDA(node, properties)).collect(Collectors.toList())); + } + List qaNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.data_quality_assurance"); + if (!qaNodes.isEmpty()) { + rda.setDataQualityAssurance(qaNodes.stream().map(qaNode -> properties.get(qaNode.get("id").asText()).asText()).collect(Collectors.toList())); + } + List preservationNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.preservation_statement"); + if (!preservationNodes.isEmpty()) { + rda.setDataQualityAssurance(preservationNodes.stream().map(preservationNode -> properties.get(preservationNode.get("id").asText()).asText()).collect(Collectors.toList())); + } + List distributionNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.distribution"); + if (!distributionNodes.isEmpty()) { + rda.setDistribution(distributionNodes.stream().map(distributionNode -> DistributionRDAMapper.toRDA(distributionNode, properties)).collect(Collectors.toList())); + } + List keywordNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.keyword"); + if (!keywordNodes.isEmpty()) { + rda.setKeyword(keywordNodes.stream().map(keywordNode -> properties.get(keywordNode.get("id").asText()).asText()).collect(Collectors.toList())); + } + List personalDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.personal_data"); + if (!personalDataNodes.isEmpty()) { + rda.setPersonalData(personalDataNodes.stream().map(personalDataNode -> Dataset.PersonalData.fromValue(properties.get(personalDataNode.get("id").asText()).asText())).findFirst().get()); + } + List securityAndPrivacyNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.security_and_privacy"); + if (!securityAndPrivacyNodes.isEmpty()) { + rda.setSecurityAndPrivacy(securityAndPrivacyNodes.stream().map(securityAndPrivacyNode -> SecurityAndPrivacyRDAMapper.toRDA(securityAndPrivacyNode, properties)).collect(Collectors.toList())); + } + List sensitiveDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.sensitive_data"); + if (!sensitiveDataNodes.isEmpty()) { + rda.setSensitiveData(securityAndPrivacyNodes.stream().map(sensitiveDataNode -> Dataset.SensitiveData.fromValue(properties.get(sensitiveDataNode.get("id").asText()).asText())).findFirst().get()); + } + List technicalResourceNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.technical_resource"); + if (!technicalResourceNodes.isEmpty()) { + rda.setTechnicalResource(technicalResourceNodes.stream().map(technicalResourceNode -> TechnicalResourceRDAMapper.toRDA(technicalResourceNode, properties)).collect(Collectors.toList())); + } + + + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java new file mode 100644 index 000000000..513affd98 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java @@ -0,0 +1,39 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.models.rda.Distribution; + +import java.net.URI; +import java.util.Collections; + +public class DistributionRDAMapper { + + public static Distribution toRDA(JsonNode structure, JsonNode properties) { + Distribution rda = new Distribution(); + String rdaProperty = structure.get("rdaProperty").asText(); + if (rdaProperty.contains("access_url")) { + rda.setAccessUrl(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("available_util")) { + rda.setAvailableUntil(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("byte_size")) { + rda.setByteSize(properties.get(structure.get("id").asText()).asInt()); + } else if (rdaProperty.contains("data_access")) { + rda.setDataAccess(Distribution.DataAccess.fromValue(properties.get(structure.get("id").asText()).asText())); + } else if (rdaProperty.contains("description")) { + rda.setDescription(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("download_url")) { + rda.setDownloadUrl(URI.create(properties.get(structure.get("id").asText()).asText())); + } else if (rdaProperty.contains("format")) { + rda.setFormat(Collections.singletonList(properties.get(structure.get("id").asText()).asText())); + } else if (rdaProperty.contains("host")) { + rda.setHost(HostRDAMapper.toRDA(structure, properties)); + } else if (rdaProperty.contains("license")) { + rda.setLicense(Collections.singletonList(LicenseRDAMapper.toRDA(structure, properties))); + } else if (rdaProperty.contains("title")) { + rda.setTitle(properties.get(structure.get("id").asText()).asText()); + } + + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpIdRDAMapper.java new file mode 100644 index 000000000..095c26e11 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpIdRDAMapper.java @@ -0,0 +1,19 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.models.rda.DmpId; + +import java.util.UUID; + +public class DmpIdRDAMapper { + + public static DmpId toRDA(Object id) { + DmpId rda = new DmpId(); + rda.setIdentifier(id.toString()); + if (id instanceof UUID) { + rda.setType(DmpId.Type.OTHER); + } else { + rda.setType(DmpId.Type.DOI); + } + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java new file mode 100644 index 000000000..620229a27 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java @@ -0,0 +1,51 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.data.entities.DMP; +import eu.eudat.data.entities.UserDMP; +import eu.eudat.data.entities.UserInfo; +import eu.eudat.models.rda.Dmp; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.transaction.Transactional; +import java.util.Collections; +import java.util.stream.Collectors; + +@Component +public class DmpRDAMapper { + + private DatasetRDAMapper datasetRDAMapper; + + @Autowired + public DmpRDAMapper(DatasetRDAMapper datasetRDAMapper) { + this.datasetRDAMapper = datasetRDAMapper; + } + + @Transactional + public Dmp toRDA(DMP dmp) { + Dmp rda = new Dmp(); + if (dmp.getDoi() != null && !dmp.getDoi().isEmpty()) { + rda.setDmpId(DmpIdRDAMapper.toRDA(dmp.getDoi())); + } else { + rda.setDmpId(DmpIdRDAMapper.toRDA(dmp.getId())); + } + rda.setCreated(dmp.getCreated()); + rda.setDescription(dmp.getDescription()); + rda.setModified(dmp.getModified()); + rda.setTitle(dmp.getLabel()); + + UserInfo creator; + if (dmp.getCreator() != null) { + creator = dmp.getCreator(); + } else { + creator = dmp.getUsers().stream().filter(userDMP -> userDMP.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())).map(UserDMP::getUser).findFirst().orElse(new UserInfo()); + } + rda.setContact(ContactRDAMapper.toRDA(creator)); + rda.setContributor(dmp.getUsers().stream().map(ContributorRDAMapper::toRDA).collect(Collectors.toList())); + rda.setDataset(dmp.getDataset().stream().map(dataset -> datasetRDAMapper.toRDA(dataset)).collect(Collectors.toList())); + rda.setProject(Collections.singletonList(ProjectRDAMapper.toRDA(dmp.getProject(), dmp.getGrant()))); + + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FunderIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FunderIdRDAMapper.java new file mode 100644 index 000000000..f0dc5ff4a --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FunderIdRDAMapper.java @@ -0,0 +1,19 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.models.rda.FunderId; + +import java.util.UUID; + +public class FunderIdRDAMapper { + + public static FunderId toRDA(Object id) { + FunderId rda = new FunderId(); + rda.setIdentifier(id.toString()); + if (id instanceof UUID) { + rda.setType(FunderId.Type.OTHER); + } else { + rda.setType(FunderId.Type.FUNDREF); + } + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java new file mode 100644 index 000000000..e0b8fbe65 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java @@ -0,0 +1,25 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.data.entities.Funder; +import eu.eudat.data.entities.Grant; +import eu.eudat.models.rda.Funding; + +public class FundingRDAMapper { + + public static Funding toRDA(Grant grant) { + Funding rda = new Funding(); + String referencePrefix; + String shortReference; + if (grant.getFunder().getReference() != null) { + referencePrefix = grant.getFunder().getReference().split(":")[0]; + shortReference = grant.getFunder().getReference().substring(referencePrefix.length() + 1); + rda.setFunderId(FunderIdRDAMapper.toRDA(shortReference)); + } else { + rda.setFunderId(FunderIdRDAMapper.toRDA(grant.getFunder().getId())); + } + referencePrefix = grant.getReference().split(":")[0]; + shortReference = grant.getReference().substring(referencePrefix.length() + 1); + rda.setGrantId(GrantIdRDAMapper.toRDA(shortReference)); + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/GrantIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/GrantIdRDAMapper.java new file mode 100644 index 000000000..d05ec5d02 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/GrantIdRDAMapper.java @@ -0,0 +1,13 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.models.rda.GrantId; + +public class GrantIdRDAMapper { + + public static GrantId toRDA(String id) { + GrantId rda = new GrantId(); + rda.setIdentifier(id); + rda.setType(GrantId.Type.OTHER); + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java new file mode 100644 index 000000000..9a32cc697 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java @@ -0,0 +1,41 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.models.rda.Host; +import eu.eudat.models.rda.PidSystem; + +import java.net.URI; +import java.util.Collections; + +public class HostRDAMapper { + + public static Host toRDA(JsonNode structure, JsonNode properties) { + Host rda = new Host(); + String rdaProperty = structure.get("rdaProperties").asText(); + if (rdaProperty.contains("availability")) { + rda.setAvailability(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("backup_frequency")) { + rda.setBackupFrequency(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("backup_type")) { + rda.setBackupType(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("certified_with")) { + rda.setCertifiedWith(Host.CertifiedWith.fromValue(properties.get(structure.get("id").asText()).asText())); + } else if (rdaProperty.contains("description")) { + rda.setDescription(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("geo_location")) { + rda.setGeoLocation(Host.GeoLocation.fromValue(properties.get(structure.get("id").asText()).asText())); + } else if (rdaProperty.contains("pid_system")) { + rda.setPidSystem(Collections.singletonList(PidSystem.fromValue(properties.get(structure.get("id").asText()).asText()))); + } else if (rdaProperty.contains("storage_type")) { + rda.setStorageType(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("support_versioning")) { + rda.setSupportVersioning(Host.SupportVersioning.fromValue(properties.get(structure.get("id").asText()).asText())); + } else if (rdaProperty.contains("title")) { + rda.setTitle(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("url")) { + rda.setUrl(URI.create(properties.get(structure.get("id").asText()).asText())); + } + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java new file mode 100644 index 000000000..68817bd3d --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java @@ -0,0 +1,23 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.models.rda.License; + +import java.net.URI; + +public class LicenseRDAMapper { + + public static License toRDA(JsonNode structure, JsonNode properties) { + License rda = new License(); + String rdaProperty = structure.get("rdaProperty").asText(); + String value = properties.get(structure.get("id").asText()).asText(); + + if (rdaProperty.contains("license_ref")) { + rda.setLicenseRef(URI.create(value)); + } else if (rdaProperty.contains("start_date")) { + rda.setStartDate(value); + } + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java new file mode 100644 index 000000000..fa638d3e3 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java @@ -0,0 +1,44 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import eu.eudat.models.rda.Metadatum; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.util.Iterator; + +public class MetadataRDAMapper { + private static final Logger logger = LoggerFactory.getLogger(MetadataRDAMapper.class); + + public static Metadatum toRDA(JsonNode structure, JsonNode properties) { + Metadatum rda = new Metadatum(); + JsonNode dataNode = null; + String rdaProperty = structure.get("rdaProperty").asText(); + if (rdaProperty.contains("metadata_standard_id")) { + try { + String jsonText = properties.get(structure.get("id").asText()).asText(); + if (jsonText != null && !jsonText.isEmpty()) { + dataNode = new ObjectMapper().readTree(jsonText); + for (Iterator it = dataNode.elements(); it.hasNext(); ) { + JsonNode data = it.next(); + if (data.get("uri") != null) { + rda.setMetadataStandardId(MetadataStandardIdRDAMapper.toRDA(data.get("uri").asText())); + } + } + } + } catch (IOException e) { + logger.error(e.getMessage(), e); + } + } else if (rdaProperty.contains("description")) { + rda.setDescription(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("language")) { + String language = properties.get(structure.get("id").asText()).asText(); + Metadatum.Language lang = Metadatum.Language.fromValue(language); + rda.setLanguage(lang); + } + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataStandardIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataStandardIdRDAMapper.java new file mode 100644 index 000000000..586446e02 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataStandardIdRDAMapper.java @@ -0,0 +1,13 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.models.rda.MetadataStandardId; + +public class MetadataStandardIdRDAMapper { + + public static MetadataStandardId toRDA(String uri) { + MetadataStandardId rda = new MetadataStandardId(); + rda.setIdentifier(uri); + rda.setType(MetadataStandardId.Type.URL); + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java new file mode 100644 index 000000000..d97eace4a --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java @@ -0,0 +1,25 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.data.entities.Funder; +import eu.eudat.data.entities.Grant; +import eu.eudat.models.rda.Project; + +import java.util.Collections; + +public class ProjectRDAMapper { + + public static Project toRDA(eu.eudat.data.entities.Project project, Grant grant) { + Project rda = new Project(); + rda.setTitle(project.getLabel()); + rda.setDescription(project.getDescription()); + if (project.getStartdate() != null) { + rda.setStart(project.getStartdate().toString()); + } + if (project.getEnddate() != null) { + rda.setEnd(project.getEnddate().toString()); + } + rda.setFunding(Collections.singletonList(FundingRDAMapper.toRDA(grant))); + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java new file mode 100644 index 000000000..f7f95633f --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java @@ -0,0 +1,21 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.models.rda.SecurityAndPrivacy; + +public class SecurityAndPrivacyRDAMapper { + + public static SecurityAndPrivacy toRDA(JsonNode structure, JsonNode properties) { + SecurityAndPrivacy rda = new SecurityAndPrivacy(); + String rdaProperty = structure.get("rdaProperty").asText(); + String value = properties.get(structure.get("id").asText()).asText(); + + if (rdaProperty.contains("description")) { + rda.setDescription(value); + } else if (rdaProperty.contains("title")) { + rda.setTitle(value); + } + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java new file mode 100644 index 000000000..b2652901a --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java @@ -0,0 +1,21 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.models.rda.TechnicalResource; + +public class TechnicalResourceRDAMapper { + + public static TechnicalResource toRDA(JsonNode structure, JsonNode properties) { + TechnicalResource rda = new TechnicalResource(); + String rdaProperty = structure.get("rdaProperty").asText(); + String value = properties.get(structure.get("id").asText()).asText(); + + if (rdaProperty.contains("description")) { + rda.setDescription(value); + } else if (rdaProperty.contains("name")) { + rda.setName(value); + } + + return rda; + } +} From dbf271047cb8b5971f132873b916f3f3884346e7 Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Mon, 23 Mar 2020 18:09:31 +0200 Subject: [PATCH 11/20] Improved object coupling for various objects on the dataset form --- .../utilities/helpers/MyStringUtils.java | 21 ++++ .../logic/utilities/json/JsonSearcher.java | 1 + .../user/components/datasetprofile/Field.java | 6 +- .../components/datasetprofile/FieldSet.java | 9 +- .../models/rda/mapper/DatasetRDAMapper.java | 27 ++-- .../rda/mapper/DistributionRDAMapper.java | 107 ++++++++++++++-- .../models/rda/mapper/HostRDAMapper.java | 98 +++++++++++---- .../models/rda/mapper/LicenseRDAMapper.java | 6 +- .../models/rda/mapper/MetadataRDAMapper.java | 119 +++++++++++++++--- .../mapper/SecurityAndPrivacyRDAMapper.java | 57 ++++++++- .../mapper/TechnicalResourceRDAMapper.java | 58 ++++++++- .../dataset-description-form.model.ts | 2 +- 12 files changed, 424 insertions(+), 87 deletions(-) create mode 100644 dmp-backend/web/src/main/java/eu/eudat/logic/utilities/helpers/MyStringUtils.java diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/helpers/MyStringUtils.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/helpers/MyStringUtils.java new file mode 100644 index 000000000..1a071e04c --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/helpers/MyStringUtils.java @@ -0,0 +1,21 @@ +package eu.eudat.logic.utilities.helpers; + +public class MyStringUtils { + + public static int getFirstDifference(String s1, String s2) { + char[] s1ar = s1.toCharArray(); + char[] s2ar = s2.toCharArray(); + + for(int i = 0; i < s1ar.length; i++) { + if (s2ar.length > i) { + if (s1ar[i] != s2ar[i]) { + return i; + } + } else { + return i; + } + } + + return -1; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java index ca2372b91..979053830 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java @@ -1,6 +1,7 @@ package eu.eudat.logic.utilities.json; import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.ObjectNode; import java.util.ArrayList; import java.util.Iterator; diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/Field.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/Field.java index 4950261c4..1c735e1a9 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/Field.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/Field.java @@ -149,7 +149,7 @@ public class Field implements Comparable, PropertiesModelBuilder, ViewStyleDefin this.rdaProperty = rdaProperty; } - Field cloneForMultiplicity(String key, Map properties) { + Field cloneForMultiplicity(String key, Map properties, int index) { Field newField = new Field(); newField.id = key; newField.ordinal = this.ordinal; @@ -161,6 +161,7 @@ public class Field implements Comparable, PropertiesModelBuilder, ViewStyleDefin newField.data = this.data; newField.validations = this.validations; newField.rdaProperty = this.rdaProperty; + newField.numbering = "mult" + index + "_" + this.numbering; return newField; } @@ -204,8 +205,9 @@ public class Field implements Comparable, PropertiesModelBuilder, ViewStyleDefin } 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)); + this.multiplicityItems.add(this.cloneForMultiplicity(key, properties, index)); } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/FieldSet.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/FieldSet.java index 51663ddaf..277534d16 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/FieldSet.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/FieldSet.java @@ -163,16 +163,18 @@ public class FieldSet implements Comparable, PropertiesModelBuilder, ViewStyleDe }); 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)); + 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){ + private FieldSet CloneForMultiplicity2(List key, Map properties,String[] ids, int index){ FieldSet newFieldSet = new FieldSet(); newFieldSet.id = ids[0]+"_"+ids[1]+"_"+ids[2]; newFieldSet.description = this.description; @@ -181,8 +183,9 @@ public class FieldSet implements Comparable, PropertiesModelBuilder, ViewStyleDe newFieldSet.title = this.title; newFieldSet.ordinal = this.ordinal; newFieldSet.fields = new LinkedList(); + for (Field field: this.fields) { - newFieldSet.fields.add(field.cloneForMultiplicity(newFieldSet.id + "_" + field.getId(), properties)); + newFieldSet.fields.add(field.cloneForMultiplicity(newFieldSet.id + "_" + field.getId(), properties, index)); } return newFieldSet; } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java index 103ba72c6..5eb9cc685 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java @@ -1,21 +1,17 @@ package eu.eudat.models.rda.mapper; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import eu.eudat.logic.managers.DatasetManager; import eu.eudat.logic.utilities.json.JsonSearcher; import eu.eudat.models.data.datasetwizard.DatasetWizardModel; import eu.eudat.models.rda.Dataset; -import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import javax.transaction.Transactional; -import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import java.util.stream.Collectors; @@ -41,52 +37,51 @@ public class DatasetRDAMapper { DatasetWizardModel datasetWizardModel = new DatasetWizardModel().fromDataModel(dataset); datasetWizardModel.setDatasetProfileDefinition(datasetManager.getPagedProfile(datasetWizardModel, dataset)); ObjectMapper mapper = new ObjectMapper(); - JsonNode properties = mapper.readTree(dataset.getProperties()); String datasetDescriptionJson = mapper.writeValueAsString(datasetWizardModel.getDatasetProfileDefinition()); JsonNode datasetDescriptionObj = mapper.readTree(datasetDescriptionJson); List typeNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.type"); if (!typeNodes.isEmpty()) { - rda.setType(properties.get(typeNodes.get(0).get("id").asText()).asText()); + rda.setType(typeNodes.get(0).get("value").asText()); } List languageNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.language"); if (!languageNodes.isEmpty()) { - rda.setLanguage(Dataset.Language.fromValue(properties.get(languageNodes.get(0).get("id").asText()).asText())); + rda.setLanguage(Dataset.Language.fromValue(languageNodes.get(0).get("value").asText())); } List metadataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.metadata"); if (!metadataNodes.isEmpty()) { - rda.setMetadata(metadataNodes.stream().map(node -> MetadataRDAMapper.toRDA(node, properties)).collect(Collectors.toList())); + rda.setMetadata(MetadataRDAMapper.toRDAList(metadataNodes)); } List qaNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.data_quality_assurance"); if (!qaNodes.isEmpty()) { - rda.setDataQualityAssurance(qaNodes.stream().map(qaNode -> properties.get(qaNode.get("id").asText()).asText()).collect(Collectors.toList())); + rda.setDataQualityAssurance(qaNodes.stream().map(qaNode -> qaNode.get("value").asText()).collect(Collectors.toList())); } List preservationNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.preservation_statement"); if (!preservationNodes.isEmpty()) { - rda.setDataQualityAssurance(preservationNodes.stream().map(preservationNode -> properties.get(preservationNode.get("id").asText()).asText()).collect(Collectors.toList())); + rda.setDataQualityAssurance(preservationNodes.stream().map(preservationNode -> preservationNode.get("value").asText()).collect(Collectors.toList())); } List distributionNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.distribution"); if (!distributionNodes.isEmpty()) { - rda.setDistribution(distributionNodes.stream().map(distributionNode -> DistributionRDAMapper.toRDA(distributionNode, properties)).collect(Collectors.toList())); + rda.setDistribution(DistributionRDAMapper.toRDAList(distributionNodes)); } List keywordNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.keyword"); if (!keywordNodes.isEmpty()) { - rda.setKeyword(keywordNodes.stream().map(keywordNode -> properties.get(keywordNode.get("id").asText()).asText()).collect(Collectors.toList())); + rda.setKeyword(keywordNodes.stream().map(keywordNode -> keywordNode.get("value").asText()).collect(Collectors.toList())); } List personalDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.personal_data"); if (!personalDataNodes.isEmpty()) { - rda.setPersonalData(personalDataNodes.stream().map(personalDataNode -> Dataset.PersonalData.fromValue(properties.get(personalDataNode.get("id").asText()).asText())).findFirst().get()); + rda.setPersonalData(personalDataNodes.stream().map(personalDataNode -> Dataset.PersonalData.fromValue(personalDataNode.get("value").asText())).findFirst().get()); } List securityAndPrivacyNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.security_and_privacy"); if (!securityAndPrivacyNodes.isEmpty()) { - rda.setSecurityAndPrivacy(securityAndPrivacyNodes.stream().map(securityAndPrivacyNode -> SecurityAndPrivacyRDAMapper.toRDA(securityAndPrivacyNode, properties)).collect(Collectors.toList())); + rda.setSecurityAndPrivacy(SecurityAndPrivacyRDAMapper.toRDAList(securityAndPrivacyNodes)); } List sensitiveDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.sensitive_data"); if (!sensitiveDataNodes.isEmpty()) { - rda.setSensitiveData(securityAndPrivacyNodes.stream().map(sensitiveDataNode -> Dataset.SensitiveData.fromValue(properties.get(sensitiveDataNode.get("id").asText()).asText())).findFirst().get()); + rda.setSensitiveData(securityAndPrivacyNodes.stream().map(sensitiveDataNode -> Dataset.SensitiveData.fromValue(sensitiveDataNode.get("value").asText())).findFirst().get()); } List technicalResourceNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.technical_resource"); if (!technicalResourceNodes.isEmpty()) { - rda.setTechnicalResource(technicalResourceNodes.stream().map(technicalResourceNode -> TechnicalResourceRDAMapper.toRDA(technicalResourceNode, properties)).collect(Collectors.toList())); + rda.setTechnicalResource(TechnicalResourceRDAMapper.toRDAList(technicalResourceNodes)); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java index 513affd98..98cb6960b 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java @@ -1,39 +1,120 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.logic.utilities.helpers.MyStringUtils; import eu.eudat.models.rda.Distribution; import java.net.URI; -import java.util.Collections; +import java.util.*; public class DistributionRDAMapper { - public static Distribution toRDA(JsonNode structure, JsonNode properties) { + public static List toRDAList(List nodes) { + Map rdaMap = new HashMap<>(); + + for (JsonNode node: nodes) { + String rdaProperty = node.get("rdaProperty").asText(); + String rdaValue = node.get("value").asText(); + Distribution rda = getRelative(rdaMap, node.get("numbering").asText()); + if (!rdaMap.containsValue(rda)) { + rdaMap.put(node.get("numbering").asText(), rda); + } + for (PropertyName propertyName : PropertyName.values()) { + if (rdaProperty.contains(propertyName.getName())) { + switch (propertyName) { + case ACCESS_URL: + rda.setAccessUrl(rdaValue); + break; + case AVAILABLE_UTIL: + rda.setAvailableUntil(rdaValue); + break; + case DOWNLOAD_URL: + rda.setDownloadUrl(URI.create(rdaValue)); + break; + case DESCRIPTION: + rda.setDescription(rdaValue); + break; + case DATA_ACCESS: + rda.setDataAccess(Distribution.DataAccess.fromValue(rdaValue)); + break; + case BYTE_SIZE: + rda.setByteSize(Integer.parseInt(rdaValue)); + break; + case LICENSE: + rda.setLicense(Collections.singletonList(LicenseRDAMapper.toRDA(node))); + break; + case FORMAT: + rda.setFormat(Collections.singletonList(rdaValue)); + break; + case TITLE: + rda.setTitle(rdaValue); + break; + case HOST: + rda.setHost(HostRDAMapper.toRDA(nodes, node.get("numbering").asText())); + break; + } + } + } + } + + return new ArrayList<>(rdaMap.values()); + } + + public static Distribution toRDA(JsonNode node) { Distribution rda = new Distribution(); - String rdaProperty = structure.get("rdaProperty").asText(); + String rdaProperty = node.get("rdaProperty").asText(); + String rdaValue = node.get("value").asText(); if (rdaProperty.contains("access_url")) { - rda.setAccessUrl(properties.get(structure.get("id").asText()).asText()); + rda.setAccessUrl(rdaValue); } else if (rdaProperty.contains("available_util")) { - rda.setAvailableUntil(properties.get(structure.get("id").asText()).asText()); + rda.setAvailableUntil(rdaValue); } else if (rdaProperty.contains("byte_size")) { - rda.setByteSize(properties.get(structure.get("id").asText()).asInt()); + rda.setByteSize(Integer.parseInt(rdaValue)); } else if (rdaProperty.contains("data_access")) { - rda.setDataAccess(Distribution.DataAccess.fromValue(properties.get(structure.get("id").asText()).asText())); + rda.setDataAccess(Distribution.DataAccess.fromValue(rdaValue)); } else if (rdaProperty.contains("description")) { - rda.setDescription(properties.get(structure.get("id").asText()).asText()); + rda.setDescription(rdaValue); } else if (rdaProperty.contains("download_url")) { - rda.setDownloadUrl(URI.create(properties.get(structure.get("id").asText()).asText())); + rda.setDownloadUrl(URI.create(rdaValue)); } else if (rdaProperty.contains("format")) { - rda.setFormat(Collections.singletonList(properties.get(structure.get("id").asText()).asText())); + rda.setFormat(Collections.singletonList(rdaValue)); } else if (rdaProperty.contains("host")) { - rda.setHost(HostRDAMapper.toRDA(structure, properties)); +// rda.setHost(HostRDAMapper.toRDA(node)); } else if (rdaProperty.contains("license")) { - rda.setLicense(Collections.singletonList(LicenseRDAMapper.toRDA(structure, properties))); + rda.setLicense(Collections.singletonList(LicenseRDAMapper.toRDA(node))); } else if (rdaProperty.contains("title")) { - rda.setTitle(properties.get(structure.get("id").asText()).asText()); + rda.setTitle(rdaValue); } return rda; } + + private static Distribution getRelative( Map rdaMap, String numbering) { + return rdaMap.entrySet().stream().filter(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering) > 0) + .max(Comparator.comparingInt(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering))).map(Map.Entry::getValue).orElse(new Distribution()); + } + + private enum PropertyName { + ACCESS_URL("access_url"), + AVAILABLE_UTIL("available_util"), + BYTE_SIZE("byte_size"), + DATA_ACCESS("data_access"), + DESCRIPTION("description"), + DOWNLOAD_URL("download_url"), + FORMAT("format"), + HOST("host"), + LICENSE("license"), + TITLE("title"); + + private final String name; + + PropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java index 9a32cc697..0983f3d3b 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java @@ -1,41 +1,91 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.logic.utilities.helpers.MyStringUtils; import eu.eudat.models.rda.Host; import eu.eudat.models.rda.PidSystem; import java.net.URI; import java.util.Collections; +import java.util.List; public class HostRDAMapper { - public static Host toRDA(JsonNode structure, JsonNode properties) { + public static Host toRDA(List nodes, String numbering) { Host rda = new Host(); - String rdaProperty = structure.get("rdaProperties").asText(); - if (rdaProperty.contains("availability")) { - rda.setAvailability(properties.get(structure.get("id").asText()).asText()); - } else if (rdaProperty.contains("backup_frequency")) { - rda.setBackupFrequency(properties.get(structure.get("id").asText()).asText()); - } else if (rdaProperty.contains("backup_type")) { - rda.setBackupType(properties.get(structure.get("id").asText()).asText()); - } else if (rdaProperty.contains("certified_with")) { - rda.setCertifiedWith(Host.CertifiedWith.fromValue(properties.get(structure.get("id").asText()).asText())); - } else if (rdaProperty.contains("description")) { - rda.setDescription(properties.get(structure.get("id").asText()).asText()); - } else if (rdaProperty.contains("geo_location")) { - rda.setGeoLocation(Host.GeoLocation.fromValue(properties.get(structure.get("id").asText()).asText())); - } else if (rdaProperty.contains("pid_system")) { - rda.setPidSystem(Collections.singletonList(PidSystem.fromValue(properties.get(structure.get("id").asText()).asText()))); - } else if (rdaProperty.contains("storage_type")) { - rda.setStorageType(properties.get(structure.get("id").asText()).asText()); - } else if (rdaProperty.contains("support_versioning")) { - rda.setSupportVersioning(Host.SupportVersioning.fromValue(properties.get(structure.get("id").asText()).asText())); - } else if (rdaProperty.contains("title")) { - rda.setTitle(properties.get(structure.get("id").asText()).asText()); - } else if (rdaProperty.contains("url")) { - rda.setUrl(URI.create(properties.get(structure.get("id").asText()).asText())); + for (JsonNode node: nodes) { + String rdaProperty = node.get("rdaProperties").asText(); + if (rdaProperty.contains("host")) { + int firstDiff = MyStringUtils.getFirstDifference(numbering, node.get("numbering").asText()); + if (firstDiff == -1 || firstDiff > 2) { + String rdaValue = node.get("value").asText(); + for (PropertyName propertyName: PropertyName.values()) { + if (rdaProperty.contains(propertyName.getName())) { + switch (propertyName) { + case AVAILABILITY: + rda.setAvailability(rdaValue); + break; + case BACKUP_FREQUENCY: + rda.setBackupFrequency(rdaValue); + break; + case BACKUP_TYPE: + rda.setBackupType(rdaValue); + break; + case CERTIFIED_WITH: + rda.setCertifiedWith(Host.CertifiedWith.fromValue(rdaValue)); + break; + case DESCRIPTION: + rda.setDescription(rdaValue); + break; + case GEO_LOCATION: + rda.setGeoLocation(Host.GeoLocation.fromValue(rdaValue)); + break; + case PID_SYSTEM: + rda.setPidSystem(Collections.singletonList(PidSystem.fromValue(rdaValue))); + break; + case STORAGE_TYPE: + rda.setStorageType(rdaValue); + break; + case SUPPORT_VERSIONING: + rda.setSupportVersioning(Host.SupportVersioning.fromValue(rdaValue)); + break; + case TITLE: + rda.setTitle(rdaValue); + break; + case URL: + rda.setUrl(URI.create(rdaValue)); + break; + } + } + } + } + } } return rda; } + + private enum PropertyName { + AVAILABILITY("availability"), + BACKUP_FREQUENCY("backup_frequency"), + BACKUP_TYPE("backup_type"), + CERTIFIED_WITH("certified_with"), + DESCRIPTION("description"), + GEO_LOCATION("geo_location"), + PID_SYSTEM("pid_system"), + STORAGE_TYPE("storage_type"), + SUPPORT_VERSIONING("support_versioning"), + TITLE("title"), + URL("url"); + + private final String name; + + PropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java index 68817bd3d..6f94a73c4 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java @@ -7,10 +7,10 @@ import java.net.URI; public class LicenseRDAMapper { - public static License toRDA(JsonNode structure, JsonNode properties) { + public static License toRDA(JsonNode node) { License rda = new License(); - String rdaProperty = structure.get("rdaProperty").asText(); - String value = properties.get(structure.get("id").asText()).asText(); + String rdaProperty = node.get("rdaProperty").asText(); + String value = node.get("value").asText(); if (rdaProperty.contains("license_ref")) { rda.setLicenseRef(URI.create(value)); diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java index fa638d3e3..c7e3ba35f 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java @@ -2,43 +2,124 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.TextNode; +import eu.eudat.logic.utilities.helpers.MyStringUtils; import eu.eudat.models.rda.Metadatum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.IOException; -import java.util.Iterator; +import java.util.*; public class MetadataRDAMapper { private static final Logger logger = LoggerFactory.getLogger(MetadataRDAMapper.class); - public static Metadatum toRDA(JsonNode structure, JsonNode properties) { - Metadatum rda = new Metadatum(); - JsonNode dataNode = null; - String rdaProperty = structure.get("rdaProperty").asText(); - if (rdaProperty.contains("metadata_standard_id")) { - try { - String jsonText = properties.get(structure.get("id").asText()).asText(); - if (jsonText != null && !jsonText.isEmpty()) { - dataNode = new ObjectMapper().readTree(jsonText); - for (Iterator it = dataNode.elements(); it.hasNext(); ) { - JsonNode data = it.next(); - if (data.get("uri") != null) { - rda.setMetadataStandardId(MetadataStandardIdRDAMapper.toRDA(data.get("uri").asText())); - } + public static List toRDAList(List nodes) { + Map rdaMap = new HashMap<>(); + List rdas = new ArrayList<>(); + for (JsonNode node: nodes) { + String rdaProperty = node.get("rdaProperty").asText(); + JsonNode rdaValue = node.get("value"); + + for (PropertyName propertyName: PropertyName.values()) { + if (rdaProperty.contains(propertyName.getName())) { + switch (propertyName) { + case METADATA_STANDARD_ID: + if (rdaValue instanceof ArrayNode) { + try { + ObjectMapper mapper = new ObjectMapper(); + for (Iterator it = rdaValue.elements(); it.hasNext(); ) { + JsonNode data = null; + data = mapper.readTree(it.next().asText()); + if (data.get("uri") != null) { + rdas.add(new Metadatum()); + rdas.get(rdas.size() - 1).setMetadataStandardId(MetadataStandardIdRDAMapper.toRDA(data.get("uri").asText())); + rdas.get(rdas.size() - 1).setDescription(data.get("label").asText()); + rdaMap.put(data.get("uri").asText(), node.get("numbering").asText()); + } + } + } catch (IOException e) { + logger.error(e.getMessage(), e); + } + } else if (rdaValue instanceof TextNode && rdaProperty.contains("identifier") && !rdaValue.asText().isEmpty()) { + rdas.add(new Metadatum()); + rdas.get(rdas.size() - 1).setMetadataStandardId(MetadataStandardIdRDAMapper.toRDA(rdaValue.asText())); + rdaMap.put(rdaValue.asText(), node.get("numbering").asText()); + } + break; + case DESCRIPTION: + if (!rdaValue.asText().isEmpty()) { + Metadatum rda = getRelative(rdas, rdaMap, node.get("numbering").asText()); + if (rda != null) { + rda.setDescription(rdaValue.asText()); + } else { + rdas.stream().filter(rda1 -> rda1.getDescription() == null || rda1.getDescription().isEmpty()).forEach(rda1 -> rda1.setDescription(rdaValue.asText())); + } + } + break; + case LANGUAGE: + String language = rdaValue.asText(); + Metadatum.Language lang = Metadatum.Language.fromValue(language); + Metadatum rda = getRelative(rdas, rdaMap, node.get("numbering").asText()); + if (rda != null) { + rda.setLanguage(lang); + } else { + rdas.forEach(rda1 -> rda1.setLanguage(lang)); + } + break; + } + } + } + + } + + return rdas; + } + + public static Metadatum toRDA(JsonNode node) { + Metadatum rda = new Metadatum(); + String rdaProperty = node.get("rdaProperty").asText(); + JsonNode rdaValue = node.get("value"); + if (rdaProperty.contains("metadata_standard_id")) { + if (rdaValue instanceof ArrayNode) { + for (Iterator it = rdaValue.elements(); it.hasNext(); ) { + JsonNode data = it.next(); + if (data.get("uri") != null) { + rda.setMetadataStandardId(MetadataStandardIdRDAMapper.toRDA(data.get("uri").asText())); } } - } catch (IOException e) { - logger.error(e.getMessage(), e); } } else if (rdaProperty.contains("description")) { - rda.setDescription(properties.get(structure.get("id").asText()).asText()); + rda.setDescription(rdaValue.asText()); } else if (rdaProperty.contains("language")) { - String language = properties.get(structure.get("id").asText()).asText(); + String language = rdaValue.asText(); Metadatum.Language lang = Metadatum.Language.fromValue(language); rda.setLanguage(lang); } return rda; } + + private static Metadatum getRelative(List rdas, Map rdaMap, String numbering) { + String target = rdaMap.entrySet().stream().filter(entry -> MyStringUtils.getFirstDifference(entry.getValue(), numbering) > 0) + .max(Comparator.comparingInt(entry -> MyStringUtils.getFirstDifference(entry.getValue(), numbering))).map(Map.Entry::getKey).orElse(""); + return rdas.stream().filter(rda -> rda.getMetadataStandardId().getIdentifier().equals(target)).distinct().findFirst().orElse(null); + } + + private enum PropertyName { + METADATA_STANDARD_ID("metadata_standard_id"), + DESCRIPTION("description"), + LANGUAGE("language"); + + private final String name; + + PropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java index f7f95633f..fc44cc182 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java @@ -1,14 +1,45 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.logic.utilities.helpers.MyStringUtils; import eu.eudat.models.rda.SecurityAndPrivacy; +import java.util.*; + public class SecurityAndPrivacyRDAMapper { - public static SecurityAndPrivacy toRDA(JsonNode structure, JsonNode properties) { + public static List toRDAList(List nodes) { + Map rdaMap = new HashMap<>(); + + for (JsonNode node: nodes) { + String rdaProperty = node.get("rdaProperty").asText(); + String rdaValue = node.get("value").asText(); + + SecurityAndPrivacy rda = getRelative(rdaMap, node.get("numbering").asText()); + if (!rdaMap.containsValue(rda)) { + rdaMap.put(node.get("numbering").asText(), rda); + } + for (PropertyName propertyName: PropertyName.values()) { + if (rdaProperty.contains(propertyName.getName())) { + switch (propertyName) { + case TITLE: + rda.setTitle(rdaValue); + break; + case DESCRIPTION: + rda.setDescription(rdaValue); + break; + } + } + } + } + + return new ArrayList<>(rdaMap.values()); + } + + public static SecurityAndPrivacy toRDA(JsonNode node) { SecurityAndPrivacy rda = new SecurityAndPrivacy(); - String rdaProperty = structure.get("rdaProperty").asText(); - String value = properties.get(structure.get("id").asText()).asText(); + String rdaProperty = node.get("rdaProperty").asText(); + String value =node.get("value").asText(); if (rdaProperty.contains("description")) { rda.setDescription(value); @@ -18,4 +49,24 @@ public class SecurityAndPrivacyRDAMapper { return rda; } + + private static SecurityAndPrivacy getRelative(Map rdaMap, String numbering) { + return rdaMap.entrySet().stream().filter(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering) > 0) + .max(Comparator.comparingInt(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering))).map(Map.Entry::getValue).orElse(new SecurityAndPrivacy()); + } + + private enum PropertyName { + TITLE("title"), + DESCRIPTION("description"); + + private String name; + + PropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java index b2652901a..c48f93cae 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java @@ -1,14 +1,46 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.logic.utilities.helpers.MyStringUtils; +import eu.eudat.models.rda.SecurityAndPrivacy; import eu.eudat.models.rda.TechnicalResource; +import java.util.*; + public class TechnicalResourceRDAMapper { - public static TechnicalResource toRDA(JsonNode structure, JsonNode properties) { + public static List toRDAList(List nodes) { + Map rdaMap = new HashMap<>(); + + for (JsonNode node: nodes) { + String rdaProperty = node.get("rdaProperty").asText(); + String rdaValue = node.get("value").asText(); + + TechnicalResource rda = getRelative(rdaMap, node.get("numbering").asText()); + if (!rdaMap.containsValue(rda)) { + rdaMap.put(node.get("numbering").asText(), rda); + } + for (PropertyName propertyName: PropertyName.values()) { + if (rdaProperty.contains(propertyName.getName())) { + switch (propertyName) { + case NAME: + rda.setName(rdaValue); + break; + case DESCRIPTION: + rda.setDescription(rdaValue); + break; + } + } + } + } + + return new ArrayList<>(rdaMap.values()); + } + + public static TechnicalResource toRDA(JsonNode node) { TechnicalResource rda = new TechnicalResource(); - String rdaProperty = structure.get("rdaProperty").asText(); - String value = properties.get(structure.get("id").asText()).asText(); + String rdaProperty = node.get("rdaProperty").asText(); + String value = node.get("value").asText(); if (rdaProperty.contains("description")) { rda.setDescription(value); @@ -18,4 +50,24 @@ public class TechnicalResourceRDAMapper { return rda; } + + private static TechnicalResource getRelative(Map rdaMap, String numbering) { + return rdaMap.entrySet().stream().filter(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering) > 0) + .max(Comparator.comparingInt(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering))).map(Map.Entry::getValue).orElse(new TechnicalResource()); + } + + private enum PropertyName { + NAME("name"), + DESCRIPTION("description"); + + private String name; + + PropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + } } diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description-form.model.ts b/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description-form.model.ts index c4b8153b8..fd8824ba3 100644 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description-form.model.ts +++ b/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description-form.model.ts @@ -338,4 +338,4 @@ export class DatasetDescriptionDefaultValueEditorModel extends BaseFormModel { }); return formGroup; } -} \ No newline at end of file +} From 646de5ccfb1c48496c4a4e357e32bdac065248a2 Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Tue, 24 Mar 2020 11:26:17 +0200 Subject: [PATCH 12/20] Minor bug fixes on the exporter --- .../src/main/java/eu/eudat/logic/managers/RDAManager.java | 2 +- .../java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java index eb10fd753..3a9f2f7a8 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java @@ -29,7 +29,7 @@ public class RDAManager { Dmp rdaDmp = dmpRDAMapper.toRDA(dmp); ObjectMapper mapper = new ObjectMapper(); - mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")); + mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss Z")); result = mapper.writeValueAsString(rdaDmp); diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java index 5eb9cc685..da04fe043 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java @@ -32,6 +32,7 @@ public class DatasetRDAMapper { rda.setDatasetId(DatasetIdRDAMapper.toRDA(dataset.getId())); rda.setTitle(dataset.getLabel()); rda.setDescription(dataset.getDescription()); +// rda.setAdditionalProperty("template", dataset.getProfile().getId()); try { DatasetWizardModel datasetWizardModel = new DatasetWizardModel().fromDataModel(dataset); @@ -57,7 +58,7 @@ public class DatasetRDAMapper { } List preservationNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.preservation_statement"); if (!preservationNodes.isEmpty()) { - rda.setDataQualityAssurance(preservationNodes.stream().map(preservationNode -> preservationNode.get("value").asText()).collect(Collectors.toList())); + rda.setPreservationStatement(preservationNodes.get(0).get("value").asText()); } List distributionNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.distribution"); if (!distributionNodes.isEmpty()) { @@ -77,7 +78,7 @@ public class DatasetRDAMapper { } List sensitiveDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.sensitive_data"); if (!sensitiveDataNodes.isEmpty()) { - rda.setSensitiveData(securityAndPrivacyNodes.stream().map(sensitiveDataNode -> Dataset.SensitiveData.fromValue(sensitiveDataNode.get("value").asText())).findFirst().get()); + rda.setSensitiveData(sensitiveDataNodes.stream().map(sensitiveDataNode -> Dataset.SensitiveData.fromValue(sensitiveDataNode.get("value").asText())).findFirst().get()); } List technicalResourceNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.technical_resource"); if (!technicalResourceNodes.isEmpty()) { From 7a0e9132d0c449268e1eb577b15ca60c39513b12 Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Thu, 26 Mar 2020 18:39:25 +0200 Subject: [PATCH 13/20] Add RDA Import --- .../main/java/eu/eudat/controllers/DMPs.java | 11 +- .../managers/DataManagementPlanManager.java | 35 ++++++ .../eu/eudat/logic/managers/RDAManager.java | 9 ++ .../java/eu/eudat/models/rda/Dataset.java | 9 +- .../eu/eudat/models/rda/Distribution.java | 9 +- .../main/java/eu/eudat/models/rda/Dmp.java | 9 +- .../java/eu/eudat/models/rda/Metadatum.java | 9 +- .../eudat/models/rda/SecurityAndPrivacy.java | 9 +- .../eudat/models/rda/TechnicalResource.java | 9 +- .../models/rda/mapper/ContactIdRDAMapper.java | 4 + .../models/rda/mapper/ContactRDAMapper.java | 8 ++ .../models/rda/mapper/DatasetRDAMapper.java | 112 +++++++++++++++++- .../rda/mapper/DistributionRDAMapper.java | 97 ++++++++++++++- .../eudat/models/rda/mapper/DmpRDAMapper.java | 36 ++++-- .../models/rda/mapper/FundingRDAMapper.java | 9 +- .../models/rda/mapper/MetadataRDAMapper.java | 66 +++++++++++ .../models/rda/mapper/ProjectRDAMapper.java | 22 +++- .../mapper/SecurityAndPrivacyRDAMapper.java | 60 +++++++++- .../mapper/TechnicalResourceRDAMapper.java | 62 +++++++++- .../dmp-upload-dialogue.component.html | 2 +- 20 files changed, 531 insertions(+), 56 deletions(-) diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java index c87ce4590..0e25b98f6 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java @@ -53,6 +53,9 @@ import java.util.List; import java.util.Map; import java.util.UUID; +import static org.springframework.http.MediaType.APPLICATION_ATOM_XML; +import static org.springframework.http.MediaType.APPLICATION_JSON; + @RestController @CrossOrigin @@ -224,8 +227,12 @@ public class DMPs extends BaseController { } @RequestMapping(method = RequestMethod.POST, value = {"/upload"}) - public ResponseEntity dmpXmlUpload(@RequestParam("file") MultipartFile[] files, Principal principal) throws Exception { - this.dataManagementPlanManager.createDmpFromXml(this.getApiContext(), files, principal); + public ResponseEntity dmpUpload(@RequestParam("file") MultipartFile[] files, Principal principal) throws Exception { + if (files[0].getContentType().equals(APPLICATION_JSON.toString())) { + this.dataManagementPlanManager.createFromRDA(files, principal); + } else if (files[0].getContentType().equals(APPLICATION_ATOM_XML.toString())) { + this.dataManagementPlanManager.createDmpFromXml(this.getApiContext(), files, principal); + } return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem() .status(ApiMessageCode.SUCCESS_MESSAGE)); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java index 2710ec60c..c8dee4802 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java @@ -131,6 +131,13 @@ public class DataManagementPlanManager { if (fieldsGroup.equals("listing")) { itemsFuture = pagedItems.withHint(HintedModelFactory.getHint(DataManagementPlanListingModel.class)) .selectAsync(item -> { + if (item.getUsers().stream().noneMatch(userDMP -> userDMP.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue()))) { + for (UserDMP userDMP: item.getUsers()) { + userDMP.setRole(UserDMP.UserDMPRoles.OWNER.getValue()); + databaseRepository.getUserDmpDao().createOrUpdate(userDMP); + break; + } + } item.setDataset( item.getDataset().stream() .filter(dataset -> !dataset.getStatus().equals(Dataset.Status.DELETED.getValue()) && !dataset.getStatus().equals(Dataset.Status.CANCELED.getValue())).collect(Collectors.toList()).stream() @@ -1329,6 +1336,34 @@ public class DataManagementPlanManager { return dataManagementPlans; } + public List createFromRDA(MultipartFile[] files, Principal principal) throws IOException { + if (principal.getId() == null) { + throw new UnauthorisedException("No user is logged in"); + } + List result = new ArrayList<>(); + for (MultipartFile file: files) { + DMP dmp = rdaManager.convertToEntity(new String(file.getBytes(), "UTF-8")); + UserInfo me = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId()); + dmp.setModified(new Date()); + dmp.setCreator(me); + dmp.setVersion(0); + dmp.setStatus((short)0); + dmp.setGroupId(UUID.randomUUID()); + databaseRepository.getDmpDao().createOrUpdate(dmp); + assignUser(dmp, me); + dmp.getDataset().forEach(dataset -> { + dataset.setStatus(Dataset.Status.SAVED.getValue()); + dataset.setCreated(new Date()); + dataset.setModified(new Date()); + dataset.setDmp(dmp); + databaseRepository.getDatasetDao().createOrUpdate(dataset); + }); + result.add(dmp); + } + + return result; + } + public DataTableData getDatasetProfilesUsedByDMP(DatasetProfileTableRequestItem datasetProfileTableRequestItem, Principal principal) { datasetProfileTableRequestItem.getCriteria().setFilter(DatasetProfileCriteria.DatasetProfileFilter.DMPs.getValue()); datasetProfileTableRequestItem.getCriteria().setUserId(principal.getId()); diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java index 3a9f2f7a8..ff194455e 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java @@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import javax.transaction.Transactional; +import java.io.IOException; import java.text.SimpleDateFormat; @Component @@ -35,4 +36,12 @@ public class RDAManager { return result; } + + public DMP convertToEntity(String json) throws IOException { + ObjectMapper mapper = new ObjectMapper(); + mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss Z")); + + Dmp rda = mapper.readValue(json, Dmp.class); + return dmpRDAMapper.toEntity(rda); + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java index 43a7ac0cd..3c064965e 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java @@ -38,7 +38,8 @@ import com.fasterxml.jackson.annotation.JsonValue; "sensitive_data", "technical_resource", "title", - "type" + "type", + "additional_properties" }) public class Dataset implements Serializable { @@ -182,7 +183,7 @@ public class Dataset implements Serializable @JsonProperty("type") @JsonPropertyDescription("If appropriate, type according to: DataCite and/or COAR dictionary. Otherwise use the common name for the type, e.g. raw data, software, survey, etc. https://schema.datacite.org/meta/kernel-4.1/doc/DataCite-MetadataKernel_v4.1.pdf http://vocabularies.coar-repositories.org/pubby/resource_type.html") private String type; - @JsonIgnore + @JsonProperty("additional_properties") private Map additionalProperties = new HashMap(); private final static long serialVersionUID = -6931119120629009399L; @@ -524,12 +525,12 @@ public class Dataset implements Serializable this.type = type; } - @JsonAnyGetter + @JsonProperty("additional_properties") public Map getAdditionalProperties() { return this.additionalProperties; } - @JsonAnySetter + @JsonProperty("additional_properties") public void setAdditionalProperty(String name, Object value) { this.additionalProperties.put(name, value); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java index d005e7564..176931e9e 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java @@ -34,7 +34,8 @@ import com.fasterxml.jackson.annotation.JsonValue; "format", "host", "license", - "title" + "title", + "additional_properties" }) public class Distribution implements Serializable { @@ -131,7 +132,7 @@ public class Distribution implements Serializable @JsonProperty("title") @JsonPropertyDescription("Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file.") private String title; - @JsonIgnore + @JsonProperty("additional_properties") private Map additionalProperties = new HashMap(); private final static long serialVersionUID = -6018365280419917902L; @@ -359,12 +360,12 @@ public class Distribution implements Serializable this.title = title; } - @JsonAnyGetter + @JsonProperty("additional_properties") public Map getAdditionalProperties() { return this.additionalProperties; } - @JsonAnySetter + @JsonProperty("additional_properties") public void setAdditionalProperty(String name, Object value) { this.additionalProperties.put(name, value); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java index 7cac25d62..b53d26147 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java @@ -39,7 +39,8 @@ import com.fasterxml.jackson.annotation.JsonValue; "language", "modified", "project", - "title" + "title", + "additional_properties" }) public class Dmp implements Serializable { @@ -173,7 +174,7 @@ public class Dmp implements Serializable @JsonProperty("title") @JsonPropertyDescription("Title of a DMP") private String title; - @JsonIgnore + @JsonProperty("additional_properties") private Map additionalProperties = new HashMap(); private final static long serialVersionUID = 4599713332472772292L; @@ -499,12 +500,12 @@ public class Dmp implements Serializable this.title = title; } - @JsonAnyGetter + @JsonProperty("additional_properties") public Map getAdditionalProperties() { return this.additionalProperties; } - @JsonAnySetter + @JsonProperty("additional_properties") public void setAdditionalProperty(String name, Object value) { this.additionalProperties.put(name, value); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java index d6057ca62..56bee437d 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java @@ -25,7 +25,8 @@ import com.fasterxml.jackson.annotation.JsonValue; @JsonPropertyOrder({ "description", "language", - "metadata_standard_id" + "metadata_standard_id", + "additional_properties" }) public class Metadatum implements Serializable { @@ -58,7 +59,7 @@ public class Metadatum implements Serializable */ @JsonProperty("metadata_standard_id") private MetadataStandardId metadataStandardId; - @JsonIgnore + @JsonProperty("additional_properties") private Map additionalProperties = new HashMap(); private final static long serialVersionUID = 6511312853153406190L; @@ -132,12 +133,12 @@ public class Metadatum implements Serializable this.metadataStandardId = metadataStandardId; } - @JsonAnyGetter + @JsonProperty("additional_properties") public Map getAdditionalProperties() { return this.additionalProperties; } - @JsonAnySetter + @JsonProperty("additional_properties") public void setAdditionalProperty(String name, Object value) { this.additionalProperties.put(name, value); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java index 0486df588..245d202d0 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java @@ -22,7 +22,8 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonPropertyOrder({ "description", - "title" + "title", + "additional_properties" }) public class SecurityAndPrivacy implements Serializable { @@ -46,7 +47,7 @@ public class SecurityAndPrivacy implements Serializable @JsonProperty("title") @JsonPropertyDescription("Title") private String title; - @JsonIgnore + @JsonProperty("additional_properties") private Map additionalProperties = new HashMap(); private final static long serialVersionUID = 7863747935827682977L; @@ -96,12 +97,12 @@ public class SecurityAndPrivacy implements Serializable this.title = title; } - @JsonAnyGetter + @JsonProperty("additional_properties") public Map getAdditionalProperties() { return this.additionalProperties; } - @JsonAnySetter + @JsonProperty("additional_properties") public void setAdditionalProperty(String name, Object value) { this.additionalProperties.put(name, value); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java index eac85da72..c7bd2b055 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java @@ -22,7 +22,8 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonPropertyOrder({ "description", - "name" + "name", + "additional_properties" }) public class TechnicalResource implements Serializable { @@ -46,7 +47,7 @@ public class TechnicalResource implements Serializable @JsonProperty("name") @JsonPropertyDescription("Name of the technical resource") private String name; - @JsonIgnore + @JsonProperty("additional_properties") private Map additionalProperties = new HashMap(); private final static long serialVersionUID = -7451757227129483110L; @@ -96,12 +97,12 @@ public class TechnicalResource implements Serializable this.name = name; } - @JsonAnyGetter + @JsonProperty("additional_properties") public Map getAdditionalProperties() { return this.additionalProperties; } - @JsonAnySetter + @JsonProperty("additional_properties") public void setAdditionalProperty(String name, Object value) { this.additionalProperties.put(name, value); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java index 48549d75a..c9eac2009 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java @@ -12,4 +12,8 @@ public class ContactIdRDAMapper { rda.setType(ContactId.Type.OTHER); return rda; } + + public static UUID toEntity(ContactId rda) { + return UUID.fromString(rda.getIdentifier()); + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java index 69ea2310e..957fef8d4 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java @@ -13,4 +13,12 @@ public class ContactRDAMapper { rda.setContactId(ContactIdRDAMapper.toRDA(creator.getId())); return rda; } + + public static UserInfo toEntity(Contact rda) { + UserInfo entity = new UserInfo(); + entity.setId(ContactIdRDAMapper.toEntity(rda.getContactId())); + entity.setName(rda.getName()); + entity.setEmail(rda.getMbox()); + return entity; + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java index da04fe043..90aa4ec7c 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java @@ -2,28 +2,34 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import eu.eudat.data.entities.DatasetProfile; import eu.eudat.logic.managers.DatasetManager; +import eu.eudat.logic.services.ApiContext; import eu.eudat.logic.utilities.json.JsonSearcher; import eu.eudat.models.data.datasetwizard.DatasetWizardModel; import eu.eudat.models.rda.Dataset; +import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import javax.transaction.Transactional; -import java.util.List; +import java.util.*; import java.util.stream.Collectors; +import java.util.stream.Stream; @Component public class DatasetRDAMapper { private static final Logger logger = LoggerFactory.getLogger(DatasetRDAMapper.class); private DatasetManager datasetManager; + private ApiContext apiContext; @Autowired - public DatasetRDAMapper(DatasetManager datasetManager) { + public DatasetRDAMapper(DatasetManager datasetManager, ApiContext apiContext) { this.datasetManager = datasetManager; + this.apiContext = apiContext; } @Transactional @@ -32,9 +38,10 @@ public class DatasetRDAMapper { rda.setDatasetId(DatasetIdRDAMapper.toRDA(dataset.getId())); rda.setTitle(dataset.getLabel()); rda.setDescription(dataset.getDescription()); -// rda.setAdditionalProperty("template", dataset.getProfile().getId()); + rda.setAdditionalProperty("template", dataset.getProfile().getId()); try { - + JSONObject jObject = new JSONObject(dataset.getProperties()); + Map templateIdsToValues = jObject.toMap(); DatasetWizardModel datasetWizardModel = new DatasetWizardModel().fromDataModel(dataset); datasetWizardModel.setDatasetProfileDefinition(datasetManager.getPagedProfile(datasetWizardModel, dataset)); ObjectMapper mapper = new ObjectMapper(); @@ -55,6 +62,9 @@ public class DatasetRDAMapper { List qaNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.data_quality_assurance"); if (!qaNodes.isEmpty()) { rda.setDataQualityAssurance(qaNodes.stream().map(qaNode -> qaNode.get("value").asText()).collect(Collectors.toList())); + for (int i = 0; i < qaNodes.size(); i++) { + rda.setAdditionalProperty("qa" + (i + 1), qaNodes.get(i).get("id").asText()); + } } List preservationNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.preservation_statement"); if (!preservationNodes.isEmpty()) { @@ -67,6 +77,9 @@ public class DatasetRDAMapper { List keywordNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.keyword"); if (!keywordNodes.isEmpty()) { rda.setKeyword(keywordNodes.stream().map(keywordNode -> keywordNode.get("value").asText()).collect(Collectors.toList())); + for (int i = 0; i < keywordNodes.size(); i++) { + rda.setAdditionalProperty("keyword" + (i + 1), keywordNodes.get(i).get("id").asText()); + } } List personalDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.personal_data"); if (!personalDataNodes.isEmpty()) { @@ -84,6 +97,14 @@ public class DatasetRDAMapper { if (!technicalResourceNodes.isEmpty()) { rda.setTechnicalResource(TechnicalResourceRDAMapper.toRDAList(technicalResourceNodes)); } + List foundNodes = Stream.of(typeNodes, languageNodes, metadataNodes, qaNodes, preservationNodes, distributionNodes, + keywordNodes, personalDataNodes, securityAndPrivacyNodes, sensitiveDataNodes, technicalResourceNodes).flatMap(Collection::stream).collect(Collectors.toList()); + templateIdsToValues.entrySet().forEach(entry -> { + boolean isFound = foundNodes.stream().anyMatch(node -> node.get("id").asText().equals(entry.getKey())); + if (!isFound && entry.getValue() != null && !entry.getValue().toString().isEmpty()) { + rda.setAdditionalProperty(entry.getKey(), entry.getValue()); + } + }); } catch (Exception e) { @@ -93,4 +114,87 @@ public class DatasetRDAMapper { return rda; } + + + public eu.eudat.data.entities.Dataset toEntity(Dataset rda) { + eu.eudat.data.entities.Dataset entity = new eu.eudat.data.entities.Dataset(); + entity.setLabel(rda.getTitle()); + entity.setDescription(rda.getDescription()); + try { + DatasetProfile profile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(rda.getAdditionalProperties().get("template").toString())); + entity.setProfile(profile); + }catch(Exception e) { + logger.warn(e.getMessage(), e); + } + try { + Map properties = new HashMap<>(); + DatasetWizardModel datasetWizardModel = new DatasetWizardModel(); + datasetWizardModel.setProfile(entity.getProfile().getId()); + datasetWizardModel.setDatasetProfileDefinition(datasetManager.getPagedProfile(datasetWizardModel, entity)); + ObjectMapper mapper = new ObjectMapper(); + String datasetDescriptionJson = mapper.writeValueAsString(datasetWizardModel.getDatasetProfileDefinition()); + JsonNode datasetDescriptionObj = mapper.readTree(datasetDescriptionJson); + + List typeNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.type"); + if (!typeNodes.isEmpty()) { + properties.put(typeNodes.get(0).get("id").asText(), rda.getType()); + } + + List languageNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.language"); + if (!languageNodes.isEmpty()) { + properties.put(languageNodes.get(0).get("id").asText(), rda.getLanguage().value()); + } + + if (rda.getMetadata() != null) { + properties.putAll(MetadataRDAMapper.toProperties(rda.getMetadata())); + } + + List qaIds = rda.getAdditionalProperties().entrySet().stream().filter(entry -> entry.getKey().startsWith("qa")).map(entry -> entry.getValue().toString()).collect(Collectors.toList()); + for (int i = 0; i < qaIds.size(); i++) { + properties.put(qaIds.get(i), rda.getDataQualityAssurance().get(i)); + } + + List preservationNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.preservation_statement"); + if (!preservationNodes.isEmpty()) { + properties.put(preservationNodes.get(0).get("id").asText(), rda.getPreservationStatement()); + } + + if (rda.getDistribution() != null) { + properties.putAll(DistributionRDAMapper.toProperties(rda.getDistribution())); + } + + List keywordIds = rda.getAdditionalProperties().entrySet().stream().filter(entry -> entry.getKey().startsWith("keyword")).map(entry -> entry.getValue().toString()).collect(Collectors.toList()); + for (int i = 0; i < keywordIds.size(); i++) { + properties.put(keywordIds.get(i), rda.getKeyword().get(i)); + } + + List personalDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.personal_data"); + if (!personalDataNodes.isEmpty()) { + properties.put(personalDataNodes.get(0).get("id").asText(), rda.getPersonalData().value()); + } + + if (rda.getSecurityAndPrivacy() != null) { + properties.putAll(SecurityAndPrivacyRDAMapper.toProperties(rda.getSecurityAndPrivacy())); + } + + List sensitiveDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.sensitive_data"); + if (!sensitiveDataNodes.isEmpty()) { + properties.put(sensitiveDataNodes.get(0).get("id").asText(), rda.getSensitiveData().value()); + } + + if (rda.getTechnicalResource() != null) { + properties.putAll(TechnicalResourceRDAMapper.toProperties(rda.getTechnicalResource())); + } + + rda.getAdditionalProperties().entrySet().stream() + .filter(entry -> !entry.getKey().equals("template") && !entry.getKey().startsWith("qa") && !entry.getKey().startsWith("keyword")) + .forEach(entry -> properties.put(entry.getKey(), entry.getValue())); + entity.setProperties(new ObjectMapper().writeValueAsString(properties)); + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + + + return entity; + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java index 98cb6960b..566288452 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java @@ -1,13 +1,17 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; +import com.lowagie.text.ExceptionConverter; import eu.eudat.logic.utilities.helpers.MyStringUtils; import eu.eudat.models.rda.Distribution; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.net.URI; import java.util.*; public class DistributionRDAMapper { + private static final Logger logger = LoggerFactory.getLogger(DistributionRDAMapper.class); public static List toRDAList(List nodes) { Map rdaMap = new HashMap<>(); @@ -19,35 +23,43 @@ public class DistributionRDAMapper { if (!rdaMap.containsValue(rda)) { rdaMap.put(node.get("numbering").asText(), rda); } - for (PropertyName propertyName : PropertyName.values()) { - if (rdaProperty.contains(propertyName.getName())) { - switch (propertyName) { + for (ExportPropertyName exportPropertyName : ExportPropertyName.values()) { + if (rdaProperty.contains(exportPropertyName.getName())) { + switch (exportPropertyName) { case ACCESS_URL: rda.setAccessUrl(rdaValue); + rda.setAdditionalProperty(ImportPropertyName.ACCESS_URL.getName(), node.get("id").asText()); break; case AVAILABLE_UTIL: rda.setAvailableUntil(rdaValue); + rda.setAdditionalProperty(ImportPropertyName.AVAILABLE_UTIL.getName(), node.get("id").asText()); break; case DOWNLOAD_URL: rda.setDownloadUrl(URI.create(rdaValue)); + rda.setAdditionalProperty(ImportPropertyName.DOWNLOAD_URL.getName(), node.get("id").asText()); break; case DESCRIPTION: rda.setDescription(rdaValue); + rda.setAdditionalProperty(ImportPropertyName.DESCRIPTION.getName(), node.get("id").asText()); break; case DATA_ACCESS: rda.setDataAccess(Distribution.DataAccess.fromValue(rdaValue)); + rda.setAdditionalProperty(ImportPropertyName.DATA_ACCESS.getName(), node.get("id").asText()); break; case BYTE_SIZE: rda.setByteSize(Integer.parseInt(rdaValue)); + rda.setAdditionalProperty(ImportPropertyName.BYTE_SIZE.getName(), node.get("id").asText()); break; case LICENSE: rda.setLicense(Collections.singletonList(LicenseRDAMapper.toRDA(node))); break; case FORMAT: rda.setFormat(Collections.singletonList(rdaValue)); + rda.setAdditionalProperty(ImportPropertyName.FORMAT.getName(), node.get("id").asText()); break; case TITLE: rda.setTitle(rdaValue); + rda.setAdditionalProperty(ImportPropertyName.TITLE.getName(), node.get("id").asText()); break; case HOST: rda.setHost(HostRDAMapper.toRDA(nodes, node.get("numbering").asText())); @@ -60,6 +72,49 @@ public class DistributionRDAMapper { return new ArrayList<>(rdaMap.values()); } + public static Map toProperties(List rdas) { + Map properties = new HashMap<>(); + + rdas.forEach(rda -> { + rda.getAdditionalProperties().entrySet().forEach(entry -> { + try { + ImportPropertyName importPropertyName = ImportPropertyName.fromString(entry.getKey()); + switch (importPropertyName) { + case ACCESS_URL: + properties.put(entry.getValue().toString(), rda.getAccessUrl()); + break; + case TITLE: + properties.put(entry.getValue().toString(), rda.getTitle()); + break; + case DESCRIPTION: + properties.put(entry.getValue().toString(), rda.getDescription()); + break; + case FORMAT: + properties.put(entry.getValue().toString(), rda.getFormat().get(0)); + break; + case BYTE_SIZE: + properties.put(entry.getValue().toString(), rda.getByteSize().toString()); + break; + case DATA_ACCESS: + properties.put(entry.getValue().toString(), rda.getDataAccess().value()); + break; + case DOWNLOAD_URL: + properties.put(entry.getValue().toString(), rda.getDownloadUrl().toString()); + break; + case AVAILABLE_UTIL: + properties.put(entry.getValue().toString(), rda.getAvailableUntil()); + break; + } + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + + }); + }); + + return properties; + } + public static Distribution toRDA(JsonNode node) { Distribution rda = new Distribution(); String rdaProperty = node.get("rdaProperty").asText(); @@ -95,7 +150,7 @@ public class DistributionRDAMapper { .max(Comparator.comparingInt(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering))).map(Map.Entry::getValue).orElse(new Distribution()); } - private enum PropertyName { + private enum ExportPropertyName { ACCESS_URL("access_url"), AVAILABLE_UTIL("available_util"), BYTE_SIZE("byte_size"), @@ -109,7 +164,7 @@ public class DistributionRDAMapper { private final String name; - PropertyName(String name) { + ExportPropertyName(String name) { this.name = name; } @@ -117,4 +172,36 @@ public class DistributionRDAMapper { return name; } } + + private enum ImportPropertyName { + ACCESS_URL("accessurlId"), + AVAILABLE_UTIL("availableUtilId"), + BYTE_SIZE("byteSizeId"), + DATA_ACCESS("dataAccessId"), + DESCRIPTION("descriptionId"), + DOWNLOAD_URL("downloadUrlId"), + FORMAT("formatId"), + /*HOST("host"), + LICENSE("license"),*/ + TITLE("titleId"); + + private final String name; + + ImportPropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public static ImportPropertyName fromString(String name) throws Exception { + for (ImportPropertyName importPropertyName: ImportPropertyName.values()) { + if (importPropertyName.getName().equals(name)) { + return importPropertyName; + } + } + throw new Exception("No name available"); + } + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java index 620229a27..7176f3b8d 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java @@ -1,24 +1,26 @@ package eu.eudat.models.rda.mapper; -import eu.eudat.data.entities.DMP; -import eu.eudat.data.entities.UserDMP; -import eu.eudat.data.entities.UserInfo; +import eu.eudat.data.entities.*; +import eu.eudat.logic.services.ApiContext; import eu.eudat.models.rda.Dmp; +import eu.eudat.models.rda.DmpId; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import javax.transaction.Transactional; -import java.util.Collections; +import java.util.*; import java.util.stream.Collectors; @Component public class DmpRDAMapper { private DatasetRDAMapper datasetRDAMapper; + private ApiContext apiContext; @Autowired - public DmpRDAMapper(DatasetRDAMapper datasetRDAMapper) { + public DmpRDAMapper(DatasetRDAMapper datasetRDAMapper, ApiContext apiContext) { this.datasetRDAMapper = datasetRDAMapper; + this.apiContext = apiContext; } @Transactional @@ -44,8 +46,28 @@ public class DmpRDAMapper { rda.setContributor(dmp.getUsers().stream().map(ContributorRDAMapper::toRDA).collect(Collectors.toList())); rda.setDataset(dmp.getDataset().stream().map(dataset -> datasetRDAMapper.toRDA(dataset)).collect(Collectors.toList())); rda.setProject(Collections.singletonList(ProjectRDAMapper.toRDA(dmp.getProject(), dmp.getGrant()))); - - + rda.setAdditionalProperty("templates", dmp.getAssociatedDmps().stream().map(datasetProfile -> datasetProfile.getId().toString()).toArray()); return rda; } + + public DMP toEntity(Dmp rda) { + DMP entity = new DMP(); + entity.setLabel(rda.getTitle()); + if (rda.getDmpId().getType() == DmpId.Type.DOI) { + entity.setDoi(rda.getDmpId().getIdentifier()); + } + entity.setCreated(rda.getCreated()); + entity.setModified(rda.getModified()); + entity.setDescription(rda.getDescription()); + entity.setDataset(rda.getDataset().stream().map(rda1 -> datasetRDAMapper.toEntity(rda1)).collect(Collectors.toSet())); + Map result = ProjectRDAMapper.toEntity(rda.getProject().get(0), apiContext); + entity.setProject((Project) result.get("project")); + result.entrySet().stream().filter(entry -> entry.getKey().startsWith("grant")).forEach(entry -> entity.setGrant((Grant) entry.getValue())); + entity.setAssociatedDmps(((List) rda.getAdditionalProperties().get("templates")).stream().map(this::getProfile).collect(Collectors.toSet())); + return entity; + } + + private DatasetProfile getProfile(String id) { + return apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id)); + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java index e0b8fbe65..2dd3f6cc2 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java @@ -1,7 +1,8 @@ package eu.eudat.models.rda.mapper; -import eu.eudat.data.entities.Funder; +import eu.eudat.data.dao.criteria.GrantCriteria; import eu.eudat.data.entities.Grant; +import eu.eudat.logic.services.ApiContext; import eu.eudat.models.rda.Funding; public class FundingRDAMapper { @@ -22,4 +23,10 @@ public class FundingRDAMapper { rda.setGrantId(GrantIdRDAMapper.toRDA(shortReference)); return rda; } + + public static Grant toEntity(Funding rda, ApiContext apiContext) { + GrantCriteria criteria = new GrantCriteria(); + criteria.setReference(rda.getGrantId().getIdentifier()); + return apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().getWithCriteria(criteria).getSingle(); + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java index c7e3ba35f..49bbbb527 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java @@ -11,6 +11,7 @@ import org.slf4j.LoggerFactory; import java.io.IOException; import java.util.*; +import java.util.stream.Collectors; public class MetadataRDAMapper { private static final Logger logger = LoggerFactory.getLogger(MetadataRDAMapper.class); @@ -36,6 +37,7 @@ public class MetadataRDAMapper { rdas.add(new Metadatum()); rdas.get(rdas.size() - 1).setMetadataStandardId(MetadataStandardIdRDAMapper.toRDA(data.get("uri").asText())); rdas.get(rdas.size() - 1).setDescription(data.get("label").asText()); + rdas.get(rdas.size() - 1).setAdditionalProperty("fieldId", node.get("id").asText()); rdaMap.put(data.get("uri").asText(), node.get("numbering").asText()); } } @@ -45,6 +47,7 @@ public class MetadataRDAMapper { } else if (rdaValue instanceof TextNode && rdaProperty.contains("identifier") && !rdaValue.asText().isEmpty()) { rdas.add(new Metadatum()); rdas.get(rdas.size() - 1).setMetadataStandardId(MetadataStandardIdRDAMapper.toRDA(rdaValue.asText())); + rdas.get(rdas.size() - 1).setAdditionalProperty("identifierId", node.get("id").asText()); rdaMap.put(rdaValue.asText(), node.get("numbering").asText()); } break; @@ -53,6 +56,7 @@ public class MetadataRDAMapper { Metadatum rda = getRelative(rdas, rdaMap, node.get("numbering").asText()); if (rda != null) { rda.setDescription(rdaValue.asText()); + rda.setAdditionalProperty("descriptionId", node.get("id").asText()); } else { rdas.stream().filter(rda1 -> rda1.getDescription() == null || rda1.getDescription().isEmpty()).forEach(rda1 -> rda1.setDescription(rdaValue.asText())); } @@ -64,6 +68,7 @@ public class MetadataRDAMapper { Metadatum rda = getRelative(rdas, rdaMap, node.get("numbering").asText()); if (rda != null) { rda.setLanguage(lang); + rda.setAdditionalProperty("languageId", node.get("id").asText()); } else { rdas.forEach(rda1 -> rda1.setLanguage(lang)); } @@ -77,6 +82,40 @@ public class MetadataRDAMapper { return rdas; } + public static Map toProperties(List rdas) { + Map properties = new HashMap<>(); + List standardIds = new ArrayList<>(); + ObjectMapper mapper = new ObjectMapper(); + rdas.forEach(rda -> { + rda.getAdditionalProperties().entrySet().forEach(entry -> { + try { + switch (entry.getKey()) { + case "fieldId": + Map metadata = toMap(rda); + standardIds.add(metadata); + properties.put(entry.getValue().toString(), mapper.writeValueAsString(standardIds)); + break; + case "identifierId": + properties.put(entry.getValue().toString(), rda.getMetadataStandardId().getIdentifier()); + break; + case "descriptionId": + properties.put(entry.getValue().toString(), rda.getDescription()); + break; + case "languageId": + if (rda.getLanguage() != null) { + properties.put(entry.getValue().toString(), rda.getLanguage().value()); + } + break; + } + }catch (Exception e) { + logger.error(e.getMessage(), e); + } + }); + }); + + return properties; + } + public static Metadatum toRDA(JsonNode node) { Metadatum rda = new Metadatum(); String rdaProperty = node.get("rdaProperty").asText(); @@ -122,4 +161,31 @@ public class MetadataRDAMapper { return name; } } + + private static Map toMap(Metadatum rda) { + Map result = new HashMap<>(); + + ObjectMapper mapper = new ObjectMapper(); + + Map metadata = mapper.convertValue(rda, Map.class); + + Map metadataStandardId = mapper.convertValue(metadata.get("metadata_standard_id"), Map.class); + + String url = metadataStandardId.remove("identifier"); + metadataStandardId.remove("type"); + metadataStandardId.put("uri", url); + + metadata.remove("additional_properties"); + metadata.remove("metadata_standard_id"); + + Map newMetadata = metadata.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue().toString())); + + String label = newMetadata.remove("description"); + newMetadata.put("label", label); + + result.putAll(newMetadata); + result.putAll(metadataStandardId); + + return result; + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java index d97eace4a..b21a9403c 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java @@ -2,9 +2,10 @@ package eu.eudat.models.rda.mapper; import eu.eudat.data.entities.Funder; import eu.eudat.data.entities.Grant; +import eu.eudat.logic.services.ApiContext; import eu.eudat.models.rda.Project; -import java.util.Collections; +import java.util.*; public class ProjectRDAMapper { @@ -22,4 +23,23 @@ public class ProjectRDAMapper { return rda; } + + public static Map toEntity(Project rda, ApiContext apiContext) { + Map entities = new HashMap<>(); + + entities.put("project", new eu.eudat.data.entities.Project()); + ((eu.eudat.data.entities.Project) entities.get("project")).setLabel(rda.getTitle()); + ((eu.eudat.data.entities.Project) entities.get("project")).setDescription(rda.getDescription()); + ((eu.eudat.data.entities.Project) entities.get("project")).setId(UUID.randomUUID()); + ((eu.eudat.data.entities.Project) entities.get("project")).setStatus((short)1); + ((eu.eudat.data.entities.Project) entities.get("project")).setCreated(new Date()); + ((eu.eudat.data.entities.Project) entities.get("project")).setModified(new Date()); + ((eu.eudat.data.entities.Project) entities.get("project")).setType(0); + apiContext.getOperationsContext().getDatabaseRepository().getProjectDao().createOrUpdate(((eu.eudat.data.entities.Project) entities.get("project"))); + for (int i = 0; i < rda.getFunding().size(); i++) { + entities.put("grant" + (i + 1), FundingRDAMapper.toEntity(rda.getFunding().get(i), apiContext)); + } + + return entities; + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java index fc44cc182..3b5d28649 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java @@ -3,10 +3,13 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; import eu.eudat.logic.utilities.helpers.MyStringUtils; import eu.eudat.models.rda.SecurityAndPrivacy; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.*; public class SecurityAndPrivacyRDAMapper { + private static final Logger logger = LoggerFactory.getLogger(SecurityAndPrivacyRDAMapper.class); public static List toRDAList(List nodes) { Map rdaMap = new HashMap<>(); @@ -19,14 +22,16 @@ public class SecurityAndPrivacyRDAMapper { if (!rdaMap.containsValue(rda)) { rdaMap.put(node.get("numbering").asText(), rda); } - for (PropertyName propertyName: PropertyName.values()) { - if (rdaProperty.contains(propertyName.getName())) { - switch (propertyName) { + for (ExportPropertyName exportPropertyName : ExportPropertyName.values()) { + if (rdaProperty.contains(exportPropertyName.getName())) { + switch (exportPropertyName) { case TITLE: rda.setTitle(rdaValue); + rda.getAdditionalProperties().put(ImportPropertyName.TITLE.getName(), node.get("id").asText()); break; case DESCRIPTION: rda.setDescription(rdaValue); + rda.getAdditionalProperties().put(ImportPropertyName.DESCRIPTION.getName(), node.get("id").asText()); break; } } @@ -36,6 +41,27 @@ public class SecurityAndPrivacyRDAMapper { return new ArrayList<>(rdaMap.values()); } + public static Map toProperties(List rdas) { + Map properties = new HashMap<>(); + rdas.forEach(rda -> rda.getAdditionalProperties().entrySet().forEach(entry -> { + try { + ImportPropertyName importPropertyName = ImportPropertyName.fromString(entry.getKey()); + switch(importPropertyName) { + case TITLE: + properties.put(entry.getValue().toString(), rda.getTitle()); + break; + case DESCRIPTION: + properties.put(entry.getValue().toString(), rda.getDescription()); + break; + } + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + })); + + return properties; + } + public static SecurityAndPrivacy toRDA(JsonNode node) { SecurityAndPrivacy rda = new SecurityAndPrivacy(); String rdaProperty = node.get("rdaProperty").asText(); @@ -55,13 +81,13 @@ public class SecurityAndPrivacyRDAMapper { .max(Comparator.comparingInt(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering))).map(Map.Entry::getValue).orElse(new SecurityAndPrivacy()); } - private enum PropertyName { + private enum ExportPropertyName { TITLE("title"), DESCRIPTION("description"); private String name; - PropertyName(String name) { + ExportPropertyName(String name) { this.name = name; } @@ -69,4 +95,28 @@ public class SecurityAndPrivacyRDAMapper { return name; } } + + private enum ImportPropertyName { + TITLE("titleId"), + DESCRIPTION("descriptionId"); + + private String name; + + ImportPropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public static ImportPropertyName fromString(String name) throws Exception { + for (ImportPropertyName importPropertyName: ImportPropertyName.values()) { + if (importPropertyName.getName().equals(name)) { + return importPropertyName; + } + } + throw new Exception("Property not available"); + } + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java index c48f93cae..cd764c302 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java @@ -2,12 +2,14 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; import eu.eudat.logic.utilities.helpers.MyStringUtils; -import eu.eudat.models.rda.SecurityAndPrivacy; import eu.eudat.models.rda.TechnicalResource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.*; public class TechnicalResourceRDAMapper { + private static final Logger logger = LoggerFactory.getLogger(TechnicalResourceRDAMapper.class); public static List toRDAList(List nodes) { Map rdaMap = new HashMap<>(); @@ -20,14 +22,16 @@ public class TechnicalResourceRDAMapper { if (!rdaMap.containsValue(rda)) { rdaMap.put(node.get("numbering").asText(), rda); } - for (PropertyName propertyName: PropertyName.values()) { - if (rdaProperty.contains(propertyName.getName())) { - switch (propertyName) { + for (ExportPropertyName exportPropertyName : ExportPropertyName.values()) { + if (rdaProperty.contains(exportPropertyName.getName())) { + switch (exportPropertyName) { case NAME: rda.setName(rdaValue); + rda.setAdditionalProperty(ImportPropertyName.NAME.getName(), node.get("id").asText()); break; case DESCRIPTION: rda.setDescription(rdaValue); + rda.setAdditionalProperty(ImportPropertyName.DESCRIPTION.getName(), node.get("id").asText()); break; } } @@ -37,6 +41,28 @@ public class TechnicalResourceRDAMapper { return new ArrayList<>(rdaMap.values()); } + public static Map toProperties(List rdas) { + Map properties = new HashMap<>(); + + rdas.forEach(rda -> rda.getAdditionalProperties().entrySet().forEach(entry -> { + try { + ImportPropertyName importPropertyName = ImportPropertyName.fromString(entry.getKey()); + switch(importPropertyName) { + case DESCRIPTION: + properties.put(entry.getValue().toString(), rda.getDescription()); + break; + case NAME: + properties.put(entry.getValue().toString(), rda.getName()); + break; + } + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + })); + + return properties; + } + public static TechnicalResource toRDA(JsonNode node) { TechnicalResource rda = new TechnicalResource(); String rdaProperty = node.get("rdaProperty").asText(); @@ -56,13 +82,13 @@ public class TechnicalResourceRDAMapper { .max(Comparator.comparingInt(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering))).map(Map.Entry::getValue).orElse(new TechnicalResource()); } - private enum PropertyName { + private enum ExportPropertyName { NAME("name"), DESCRIPTION("description"); private String name; - PropertyName(String name) { + ExportPropertyName(String name) { this.name = name; } @@ -70,4 +96,28 @@ public class TechnicalResourceRDAMapper { return name; } } + + private enum ImportPropertyName { + NAME("nameId"), + DESCRIPTION("descriptionId"); + + private String name; + + ImportPropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public static ImportPropertyName fromString(String name) throws Exception { + for (ImportPropertyName importPropertyName: ImportPropertyName.values()) { + if (importPropertyName.getName().equals(name)) { + return importPropertyName; + } + } + throw new Exception("Property name not available"); + } + } } diff --git a/dmp-frontend/src/app/ui/dmp/listing/upload-dialogue/dmp-upload-dialogue.component.html b/dmp-frontend/src/app/ui/dmp/listing/upload-dialogue/dmp-upload-dialogue.component.html index 81779fadc..f9669094e 100644 --- a/dmp-frontend/src/app/ui/dmp/listing/upload-dialogue/dmp-upload-dialogue.component.html +++ b/dmp-frontend/src/app/ui/dmp/listing/upload-dialogue/dmp-upload-dialogue.component.html @@ -7,7 +7,7 @@ - +
From 50d7bc6d28bafffb67e1c4002d13f2df5549c9dc Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Fri, 27 Mar 2020 10:50:37 +0200 Subject: [PATCH 14/20] Small bugfix for RDA Import --- .../java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java index 90aa4ec7c..eef6eb6ed 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java @@ -63,7 +63,7 @@ public class DatasetRDAMapper { if (!qaNodes.isEmpty()) { rda.setDataQualityAssurance(qaNodes.stream().map(qaNode -> qaNode.get("value").asText()).collect(Collectors.toList())); for (int i = 0; i < qaNodes.size(); i++) { - rda.setAdditionalProperty("qa" + (i + 1), qaNodes.get(i).get("id").asText()); + rda.setAdditionalProperty("qaId" + (i + 1), qaNodes.get(i).get("id").asText()); } } List preservationNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.preservation_statement"); @@ -149,7 +149,7 @@ public class DatasetRDAMapper { properties.putAll(MetadataRDAMapper.toProperties(rda.getMetadata())); } - List qaIds = rda.getAdditionalProperties().entrySet().stream().filter(entry -> entry.getKey().startsWith("qa")).map(entry -> entry.getValue().toString()).collect(Collectors.toList()); + List qaIds = rda.getAdditionalProperties().entrySet().stream().filter(entry -> entry.getKey().startsWith("qaId")).map(entry -> entry.getValue().toString()).collect(Collectors.toList()); for (int i = 0; i < qaIds.size(); i++) { properties.put(qaIds.get(i), rda.getDataQualityAssurance().get(i)); } @@ -187,7 +187,7 @@ public class DatasetRDAMapper { } rda.getAdditionalProperties().entrySet().stream() - .filter(entry -> !entry.getKey().equals("template") && !entry.getKey().startsWith("qa") && !entry.getKey().startsWith("keyword")) + .filter(entry -> !entry.getKey().equals("template") && !entry.getKey().startsWith("qaId") && !entry.getKey().startsWith("keyword")) .forEach(entry -> properties.put(entry.getKey(), entry.getValue())); entity.setProperties(new ObjectMapper().writeValueAsString(properties)); } catch (Exception e) { From a36b98535c8d9a056194d8db066780261e67db81 Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Fri, 20 Mar 2020 18:20:22 +0200 Subject: [PATCH 15/20] Add new RDA exporter --- .../managers/DataManagementPlanManager.java | 13 +- .../logic/managers/DatasetProfileManager.java | 4 +- .../eu/eudat/logic/managers/RDAManager.java | 38 + .../logic/utilities/json/JsonSearcher.java | 32 + .../commons/datafield/AutoCompleteData.java | 2 + .../commons/datafield/ComboBoxData.java | 11 + .../ExternalAutocompleteFieldModel.java | 12 +- .../data/rda/DatasetRDAExportModel.java | 3 +- .../java/eu/eudat/models/rda/Contact.java | 146 +++ .../java/eu/eudat/models/rda/ContactId.java | 154 ++++ .../java/eu/eudat/models/rda/Contributor.java | 181 ++++ .../eu/eudat/models/rda/ContributorId.java | 155 ++++ .../main/java/eu/eudat/models/rda/Cost.java | 374 ++++++++ .../java/eu/eudat/models/rda/Dataset.java | 839 ++++++++++++++++++ .../java/eu/eudat/models/rda/DatasetId.java | 156 ++++ .../eu/eudat/models/rda/Distribution.java | 412 +++++++++ .../main/java/eu/eudat/models/rda/Dmp.java | 774 ++++++++++++++++ .../main/java/eu/eudat/models/rda/DmpId.java | 156 ++++ .../java/eu/eudat/models/rda/FunderId.java | 154 ++++ .../java/eu/eudat/models/rda/Funding.java | 187 ++++ .../java/eu/eudat/models/rda/GrantId.java | 153 ++++ .../main/java/eu/eudat/models/rda/Host.java | 775 ++++++++++++++++ .../java/eu/eudat/models/rda/License.java | 113 +++ .../eudat/models/rda/MetadataStandardId.java | 153 ++++ .../java/eu/eudat/models/rda/Metadatum.java | 368 ++++++++ .../java/eu/eudat/models/rda/PidSystem.java | 63 ++ .../java/eu/eudat/models/rda/Project.java | 212 +++++ .../java/eu/eudat/models/rda/RDAModel.java | 58 ++ .../eudat/models/rda/SecurityAndPrivacy.java | 109 +++ .../eudat/models/rda/TechnicalResource.java | 109 +++ .../models/rda/mapper/ContactIdRDAMapper.java | 15 + .../models/rda/mapper/ContactRDAMapper.java | 16 + .../rda/mapper/ContributorIdRDAMapper.java | 16 + .../rda/mapper/ContributorRDAMapper.java | 20 + .../models/rda/mapper/DatasetIdRDAMapper.java | 17 + .../models/rda/mapper/DatasetRDAMapper.java | 100 +++ .../rda/mapper/DistributionRDAMapper.java | 39 + .../models/rda/mapper/DmpIdRDAMapper.java | 19 + .../eudat/models/rda/mapper/DmpRDAMapper.java | 51 ++ .../models/rda/mapper/FunderIdRDAMapper.java | 19 + .../models/rda/mapper/FundingRDAMapper.java | 25 + .../models/rda/mapper/GrantIdRDAMapper.java | 13 + .../models/rda/mapper/HostRDAMapper.java | 41 + .../models/rda/mapper/LicenseRDAMapper.java | 23 + .../models/rda/mapper/MetadataRDAMapper.java | 44 + .../mapper/MetadataStandardIdRDAMapper.java | 13 + .../models/rda/mapper/ProjectRDAMapper.java | 25 + .../mapper/SecurityAndPrivacyRDAMapper.java | 21 + .../mapper/TechnicalResourceRDAMapper.java | 21 + 49 files changed, 6447 insertions(+), 7 deletions(-) create mode 100644 dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Contact.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/ContactId.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Contributor.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/ContributorId.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Cost.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/DatasetId.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/DmpId.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/FunderId.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Funding.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/GrantId.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Host.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/License.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/MetadataStandardId.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/PidSystem.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Project.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/RDAModel.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorIdRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetIdRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpIdRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FunderIdRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/GrantIdRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataStandardIdRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java index e88e48524..2710ec60c 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java @@ -105,14 +105,16 @@ public class DataManagementPlanManager { private UtilitiesService utilitiesService; private DatabaseRepository databaseRepository; private Environment environment; + private RDAManager rdaManager; @Autowired - public DataManagementPlanManager(ApiContext apiContext, DatasetManager datasetManager, Environment environment) { + public DataManagementPlanManager(ApiContext apiContext, DatasetManager datasetManager, Environment environment, RDAManager rdaManager) { this.apiContext = apiContext; this.datasetManager = datasetManager; this.utilitiesService = apiContext.getUtilitiesService(); this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository(); this.environment = environment; + this.rdaManager = rdaManager; } public DataTableData getPaged(DataManagementPlanTableRequest dataManagementPlanTableRequest, Principal principal, String fieldsGroup) throws Exception { @@ -1129,15 +1131,20 @@ public class DataManagementPlanManager { eu.eudat.data.entities.DMP dmp = databaseRepository.getDmpDao().find(UUID.fromString(id)); if (!dmp.isPublic() && dmp.getUsers().stream().noneMatch(userInfo -> userInfo.getUser().getId() == principal.getId())) throw new UnauthorisedException(); - RDAExportModel rdaExportModel = new RDAExportModel().fromDataModel(dmp, datasetManager, principal); +// RDAExportModel rdaExportModel = new RDAExportModel().fromDataModel(dmp, datasetManager, principal); + String result = rdaManager.convertToRDA(dmp); ObjectMapper mapper = new ObjectMapper(); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); String fileName = dmp.getLabel(); fileName = fileName.replaceAll("[^a-zA-Z0-9+ ]", ""); File file = new File(fileName + ".json"); + OutputStream output = new FileOutputStream(file); try { - mapper.writeValue(file, rdaExportModel); +// mapper.writeValue(file, rdaExportModel); + output.write(result.getBytes()); + output.flush(); + output.close(); } catch (IOException e) { logger.error(e.getMessage(), e); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetProfileManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetProfileManager.java index 079359827..81693e917 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetProfileManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetProfileManager.java @@ -113,8 +113,8 @@ public class DatasetProfileManager { ResponseEntity response = restTemplate.exchange(data.getUrl() + "?search=" + like, HttpMethod.GET, entity, Object.class); DocumentContext jsonContext = JsonPath.parse(response.getBody()); - List> jsonItems = jsonContext.read(data.getOptionsRoot() + "['" + data.getAutoCompleteOptions().getLabel() + "','" + data.getAutoCompleteOptions().getValue() + "','" + data.getAutoCompleteOptions().getSource() + "']"); - jsonItems.forEach(item -> result.add(new ExternalAutocompleteFieldModel(item.get(data.getAutoCompleteOptions().getValue()), item.get(data.getAutoCompleteOptions().getLabel()), item.get(data.getAutoCompleteOptions().getSource())))); + List> jsonItems = jsonContext.read(data.getOptionsRoot() + "['" + data.getAutoCompleteOptions().getLabel() + "','" + data.getAutoCompleteOptions().getValue() + "','" + data.getAutoCompleteOptions().getSource() + "','" + "uri" + "']"); + jsonItems.forEach(item -> result.add(new ExternalAutocompleteFieldModel(item.get(data.getAutoCompleteOptions().getValue()), item.get(data.getAutoCompleteOptions().getLabel()), item.get(data.getAutoCompleteOptions().getSource()), item.get("uri")))); return result; } diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java new file mode 100644 index 000000000..eb10fd753 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java @@ -0,0 +1,38 @@ +package eu.eudat.logic.managers; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import eu.eudat.data.entities.DMP; +import eu.eudat.models.rda.Dmp; +import eu.eudat.models.rda.RDAModel; +import eu.eudat.models.rda.mapper.DmpRDAMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.transaction.Transactional; +import java.text.SimpleDateFormat; + +@Component +public class RDAManager { + + private DmpRDAMapper dmpRDAMapper; + + @Autowired + public RDAManager(DmpRDAMapper dmpRDAMapper) { + this.dmpRDAMapper = dmpRDAMapper; + } + + @Transactional + public String convertToRDA(DMP dmp) throws JsonProcessingException { + String result = ""; + + Dmp rdaDmp = dmpRDAMapper.toRDA(dmp); + + ObjectMapper mapper = new ObjectMapper(); + mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")); + + result = mapper.writeValueAsString(rdaDmp); + + return result; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java new file mode 100644 index 000000000..ca2372b91 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java @@ -0,0 +1,32 @@ +package eu.eudat.logic.utilities.json; + +import com.fasterxml.jackson.databind.JsonNode; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +public class JsonSearcher { + + public static List findNodes(JsonNode root, String key, String value) { + List nodes = new ArrayList<>(); + for (Iterator it = root.elements(); it.hasNext(); ) { + JsonNode node = it.next(); + int found = 0; + for (Iterator iter = node.fieldNames(); iter.hasNext(); ) { + String fieldName = iter.next(); + if (fieldName.equals(key)) { + if (node.get(fieldName).asText().equals(value) || node.get(fieldName).asText().startsWith(value)) { + nodes.add(node); + found++; + } + } + + } + if (found == 0) { + nodes.addAll(findNodes(node, key, value)); + } + } + return nodes; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/AutoCompleteData.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/AutoCompleteData.java index 8fbedc873..5b33f115d 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/AutoCompleteData.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/AutoCompleteData.java @@ -64,6 +64,7 @@ public class AutoCompleteData extends ComboBoxData { this.autoCompleteOptions.setLabel(optionElement.getAttribute("label")); this.autoCompleteOptions.setValue(optionElement.getAttribute("value")); this.autoCompleteOptions.setSource(optionElement.getAttribute("source")); + this.autoCompleteOptions.setUri(optionElement.getAttribute("uri")); } return this; } @@ -81,6 +82,7 @@ public class AutoCompleteData extends ComboBoxData { this.autoCompleteOptions.setLabel(options.get("label")); this.autoCompleteOptions.setValue(options.get("value")); this.autoCompleteOptions.setSource(options.get("source")); + this.autoCompleteOptions.setUri(options.get("uri")); } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/ComboBoxData.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/ComboBoxData.java index db67ea301..59bc6ea79 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/ComboBoxData.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/ComboBoxData.java @@ -12,6 +12,7 @@ public abstract class ComboBoxData extends FieldData { private String label; private String value; private String source; + private String uri; public String getLabel() { return label; @@ -34,12 +35,21 @@ public abstract class ComboBoxData extends FieldData { this.source = source; } + public String getUri() { + return uri; + } + + public void setUri(String uri) { + this.uri = uri; + } + @Override public Element toXml(Document doc) { Element option = doc.createElement("option"); option.setAttribute("label", this.label); option.setAttribute("value", this.value); option.setAttribute("source", this.source); + option.setAttribute("uri", this.uri); return option; } @@ -48,6 +58,7 @@ public abstract class ComboBoxData extends FieldData { this.label = item.getAttribute("label"); this.value = item.getAttribute("value"); this.source = item.getAttribute("source"); + this.uri = item.getAttribute("uri"); return this; } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/externaldataset/ExternalAutocompleteFieldModel.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/externaldataset/ExternalAutocompleteFieldModel.java index d57605a72..039c63acd 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/externaldataset/ExternalAutocompleteFieldModel.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/externaldataset/ExternalAutocompleteFieldModel.java @@ -4,11 +4,13 @@ public class ExternalAutocompleteFieldModel { private String id; private String label; private String source; + private String uri; - public ExternalAutocompleteFieldModel(String id, String label, String source) { + public ExternalAutocompleteFieldModel(String id, String label, String source, String uri) { this.id = id; this.label = label; this.source = source; + this.uri = uri; } public String getId() { @@ -31,4 +33,12 @@ public class ExternalAutocompleteFieldModel { public void setSource(String source) { this.source = source; } + + public String getUri() { + return uri; + } + + public void setUri(String uri) { + this.uri = uri; + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/rda/DatasetRDAExportModel.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/rda/DatasetRDAExportModel.java index c9f509020..ccd79971f 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/rda/DatasetRDAExportModel.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/rda/DatasetRDAExportModel.java @@ -321,7 +321,8 @@ public class DatasetRDAExportModel { JSONObject jsonObject = jsonArray.getJSONObject(i); Map jsonObjectMap = jsonObject.toMap(); DatasetMetadataRDAExportModel metadataRda1 = new DatasetMetadataRDAExportModel(); - metadataRda1.setMetadata_standard_id(new IdRDAExportModel(jsonObjectMap.get("label").toString(), jsonObjectMap.get("source").toString())); +// metadataRda1.setMetadata_standard_id(new IdRDAExportModel(jsonObjectMap.get("label").toString(), jsonObjectMap.get("source").toString())); + metadataRda1.setMetadata_standard_id(new IdRDAExportModel(jsonObjectMap.get("uri").toString(), "url")); metadataRDAExportModelList.add(metadataRda1); } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Contact.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Contact.java new file mode 100644 index 000000000..606a3ae2c --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Contact.java @@ -0,0 +1,146 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * The DMP Contact Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "contact_id", + "mbox", + "name" +}) +public class Contact implements Serializable +{ + + /** + * The Contact ID Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contact_id") + private ContactId contactId; + /** + * The Mailbox Schema + *

+ * Contact Person's E-mail address + * (Required) + * + */ + @JsonProperty("mbox") + @JsonPropertyDescription("Contact Person's E-mail address") + private String mbox; + /** + * The Name Schema + *

+ * Name of the contact person + * (Required) + * + */ + @JsonProperty("name") + @JsonPropertyDescription("Name of the contact person") + private String name; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -2062619884605400321L; + + /** + * The Contact ID Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contact_id") + public ContactId getContactId() { + return contactId; + } + + /** + * The Contact ID Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contact_id") + public void setContactId(ContactId contactId) { + this.contactId = contactId; + } + + /** + * The Mailbox Schema + *

+ * Contact Person's E-mail address + * (Required) + * + */ + @JsonProperty("mbox") + public String getMbox() { + return mbox; + } + + /** + * The Mailbox Schema + *

+ * Contact Person's E-mail address + * (Required) + * + */ + @JsonProperty("mbox") + public void setMbox(String mbox) { + this.mbox = mbox; + } + + /** + * The Name Schema + *

+ * Name of the contact person + * (Required) + * + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * The Name Schema + *

+ * Name of the contact person + * (Required) + * + */ + @JsonProperty("name") + public void setName(String name) { + this.name = name; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/ContactId.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/ContactId.java new file mode 100644 index 000000000..60454ea6c --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/ContactId.java @@ -0,0 +1,154 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Contact ID Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "identifier", + "type" +}) +public class ContactId implements Serializable +{ + + /** + * The DMP Contact Identifier Schema + *

+ * + * (Required) + * + */ + @JsonProperty("identifier") + private String identifier; + /** + * The DMP Contact Identifier Type Schema + *

+ * Identifier type. Allowed values: orcid, isni, openid, other + * (Required) + * + */ + @JsonProperty("type") + @JsonPropertyDescription("Identifier type. Allowed values: orcid, isni, openid, other") + private ContactId.Type type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -7066973565810615822L; + + /** + * The DMP Contact Identifier Schema + *

+ * + * (Required) + * + */ + @JsonProperty("identifier") + public String getIdentifier() { + return identifier; + } + + /** + * The DMP Contact Identifier Schema + *

+ * + * (Required) + * + */ + @JsonProperty("identifier") + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + * The DMP Contact Identifier Type Schema + *

+ * Identifier type. Allowed values: orcid, isni, openid, other + * (Required) + * + */ + @JsonProperty("type") + public ContactId.Type getType() { + return type; + } + + /** + * The DMP Contact Identifier Type Schema + *

+ * Identifier type. Allowed values: orcid, isni, openid, other + * (Required) + * + */ + @JsonProperty("type") + public void setType(ContactId.Type type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Type { + + ORCID("orcid"), + ISNI("isni"), + OPENID("openid"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (ContactId.Type c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Type(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static ContactId.Type fromValue(String value) { + ContactId.Type constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Contributor.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Contributor.java new file mode 100644 index 000000000..21dfe68c8 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Contributor.java @@ -0,0 +1,181 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + + +/** + * The Contributor Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "contributor_id", + "mbox", + "name", + "role" +}) +public class Contributor implements Serializable +{ + + /** + * The Contributor_id Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contributor_id") + private ContributorId contributorId; + /** + * The Contributor Mailbox Schema + *

+ * Contributor Mail address + * + */ + @JsonProperty("mbox") + @JsonPropertyDescription("Contributor Mail address") + private String mbox; + /** + * The Name Schema + *

+ * Name of the contributor + * (Required) + * + */ + @JsonProperty("name") + @JsonPropertyDescription("Name of the contributor") + private String name; + /** + * The Role Schema + *

+ * Type of contributor + * (Required) + * + */ + @JsonProperty("role") + @JsonDeserialize(as = java.util.LinkedHashSet.class) + @JsonPropertyDescription("Type of contributor") + private Set role = null; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 3452606902359513114L; + + /** + * The Contributor_id Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contributor_id") + public ContributorId getContributorId() { + return contributorId; + } + + /** + * The Contributor_id Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contributor_id") + public void setContributorId(ContributorId contributorId) { + this.contributorId = contributorId; + } + + /** + * The Contributor Mailbox Schema + *

+ * Contributor Mail address + * + */ + @JsonProperty("mbox") + public String getMbox() { + return mbox; + } + + /** + * The Contributor Mailbox Schema + *

+ * Contributor Mail address + * + */ + @JsonProperty("mbox") + public void setMbox(String mbox) { + this.mbox = mbox; + } + + /** + * The Name Schema + *

+ * Name of the contributor + * (Required) + * + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * The Name Schema + *

+ * Name of the contributor + * (Required) + * + */ + @JsonProperty("name") + public void setName(String name) { + this.name = name; + } + + /** + * The Role Schema + *

+ * Type of contributor + * (Required) + * + */ + @JsonProperty("role") + public Set getRole() { + return role; + } + + /** + * The Role Schema + *

+ * Type of contributor + * (Required) + * + */ + @JsonProperty("role") + public void setRole(Set role) { + this.role = role; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/ContributorId.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/ContributorId.java new file mode 100644 index 000000000..4045f5e0e --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/ContributorId.java @@ -0,0 +1,155 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Contributor_id Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "identifier", + "type" +}) +public class ContributorId implements Serializable +{ + + /** + * The Contributor Identifier Schema + *

+ * Identifier for a contact person + * (Required) + * + */ + @JsonProperty("identifier") + @JsonPropertyDescription("Identifier for a contact person") + private String identifier; + /** + * The Contributor Identifier Type Schema + *

+ * Identifier type. Allowed values: orcid, isni, openid, other + * (Required) + * + */ + @JsonProperty("type") + @JsonPropertyDescription("Identifier type. Allowed values: orcid, isni, openid, other") + private ContributorId.Type type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 3089650417960767482L; + + /** + * The Contributor Identifier Schema + *

+ * Identifier for a contact person + * (Required) + * + */ + @JsonProperty("identifier") + public String getIdentifier() { + return identifier; + } + + /** + * The Contributor Identifier Schema + *

+ * Identifier for a contact person + * (Required) + * + */ + @JsonProperty("identifier") + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + * The Contributor Identifier Type Schema + *

+ * Identifier type. Allowed values: orcid, isni, openid, other + * (Required) + * + */ + @JsonProperty("type") + public ContributorId.Type getType() { + return type; + } + + /** + * The Contributor Identifier Type Schema + *

+ * Identifier type. Allowed values: orcid, isni, openid, other + * (Required) + * + */ + @JsonProperty("type") + public void setType(ContributorId.Type type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Type { + + ORCID("orcid"), + ISNI("isni"), + OPENID("openid"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (ContributorId.Type c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Type(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static ContributorId.Type fromValue(String value) { + ContributorId.Type constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Cost.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Cost.java new file mode 100644 index 000000000..db32ff641 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Cost.java @@ -0,0 +1,374 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Cost Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "currency_code", + "description", + "title", + "value" +}) +public class Cost implements Serializable +{ + + /** + * The Cost Currency Code Schema + *

+ * Allowed values defined by ISO 4217 + * + */ + @JsonProperty("currency_code") + @JsonPropertyDescription("Allowed values defined by ISO 4217") + private Cost.CurrencyCode currencyCode; + /** + * The Cost Description Schema + *

+ * Cost(s) Description + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Cost(s) Description") + private String description; + /** + * The Cost Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + @JsonPropertyDescription("Title") + private String title; + /** + * The Cost Value Schema + *

+ * Value + * + */ + @JsonProperty("value") + @JsonPropertyDescription("Value") + private Double value; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -322637784848035165L; + + /** + * The Cost Currency Code Schema + *

+ * Allowed values defined by ISO 4217 + * + */ + @JsonProperty("currency_code") + public Cost.CurrencyCode getCurrencyCode() { + return currencyCode; + } + + /** + * The Cost Currency Code Schema + *

+ * Allowed values defined by ISO 4217 + * + */ + @JsonProperty("currency_code") + public void setCurrencyCode(Cost.CurrencyCode currencyCode) { + this.currencyCode = currencyCode; + } + + /** + * The Cost Description Schema + *

+ * Cost(s) Description + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The Cost Description Schema + *

+ * Cost(s) Description + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The Cost Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * The Cost Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } + + /** + * The Cost Value Schema + *

+ * Value + * + */ + @JsonProperty("value") + public Double getValue() { + return value; + } + + /** + * The Cost Value Schema + *

+ * Value + * + */ + @JsonProperty("value") + public void setValue(Double value) { + this.value = value; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum CurrencyCode { + + AED("AED"), + AFN("AFN"), + ALL("ALL"), + AMD("AMD"), + ANG("ANG"), + AOA("AOA"), + ARS("ARS"), + AUD("AUD"), + AWG("AWG"), + AZN("AZN"), + BAM("BAM"), + BBD("BBD"), + BDT("BDT"), + BGN("BGN"), + BHD("BHD"), + BIF("BIF"), + BMD("BMD"), + BND("BND"), + BOB("BOB"), + BRL("BRL"), + BSD("BSD"), + BTN("BTN"), + BWP("BWP"), + BYN("BYN"), + BZD("BZD"), + CAD("CAD"), + CDF("CDF"), + CHF("CHF"), + CLP("CLP"), + CNY("CNY"), + COP("COP"), + CRC("CRC"), + CUC("CUC"), + CUP("CUP"), + CVE("CVE"), + CZK("CZK"), + DJF("DJF"), + DKK("DKK"), + DOP("DOP"), + DZD("DZD"), + EGP("EGP"), + ERN("ERN"), + ETB("ETB"), + EUR("EUR"), + FJD("FJD"), + FKP("FKP"), + GBP("GBP"), + GEL("GEL"), + GGP("GGP"), + GHS("GHS"), + GIP("GIP"), + GMD("GMD"), + GNF("GNF"), + GTQ("GTQ"), + GYD("GYD"), + HKD("HKD"), + HNL("HNL"), + HRK("HRK"), + HTG("HTG"), + HUF("HUF"), + IDR("IDR"), + ILS("ILS"), + IMP("IMP"), + INR("INR"), + IQD("IQD"), + IRR("IRR"), + ISK("ISK"), + JEP("JEP"), + JMD("JMD"), + JOD("JOD"), + JPY("JPY"), + KES("KES"), + KGS("KGS"), + KHR("KHR"), + KMF("KMF"), + KPW("KPW"), + KRW("KRW"), + KWD("KWD"), + KYD("KYD"), + KZT("KZT"), + LAK("LAK"), + LBP("LBP"), + LKR("LKR"), + LRD("LRD"), + LSL("LSL"), + LYD("LYD"), + MAD("MAD"), + MDL("MDL"), + MGA("MGA"), + MKD("MKD"), + MMK("MMK"), + MNT("MNT"), + MOP("MOP"), + MRU("MRU"), + MUR("MUR"), + MVR("MVR"), + MWK("MWK"), + MXN("MXN"), + MYR("MYR"), + MZN("MZN"), + NAD("NAD"), + NGN("NGN"), + NIO("NIO"), + NOK("NOK"), + NPR("NPR"), + NZD("NZD"), + OMR("OMR"), + PAB("PAB"), + PEN("PEN"), + PGK("PGK"), + PHP("PHP"), + PKR("PKR"), + PLN("PLN"), + PYG("PYG"), + QAR("QAR"), + RON("RON"), + RSD("RSD"), + RUB("RUB"), + RWF("RWF"), + SAR("SAR"), + SBD("SBD"), + SCR("SCR"), + SDG("SDG"), + SEK("SEK"), + SGD("SGD"), + SHP("SHP"), + SLL("SLL"), + SOS("SOS"), + SPL("SPL*"), + SRD("SRD"), + STN("STN"), + SVC("SVC"), + SYP("SYP"), + SZL("SZL"), + THB("THB"), + TJS("TJS"), + TMT("TMT"), + TND("TND"), + TOP("TOP"), + TRY("TRY"), + TTD("TTD"), + TVD("TVD"), + TWD("TWD"), + TZS("TZS"), + UAH("UAH"), + UGX("UGX"), + USD("USD"), + UYU("UYU"), + UZS("UZS"), + VEF("VEF"), + VND("VND"), + VUV("VUV"), + WST("WST"), + XAF("XAF"), + XCD("XCD"), + XDR("XDR"), + XOF("XOF"), + XPF("XPF"), + YER("YER"), + ZAR("ZAR"), + ZMW("ZMW"), + ZWD("ZWD"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Cost.CurrencyCode c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private CurrencyCode(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Cost.CurrencyCode fromValue(String value) { + Cost.CurrencyCode constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java new file mode 100644 index 000000000..43a7ac0cd --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java @@ -0,0 +1,839 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Dataset Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "data_quality_assurance", + "dataset_id", + "description", + "distribution", + "issued", + "keyword", + "language", + "metadata", + "personal_data", + "preservation_statement", + "security_and_privacy", + "sensitive_data", + "technical_resource", + "title", + "type" +}) +public class Dataset implements Serializable +{ + + /** + * The Data Quality Assurance Schema + *

+ * Data Quality Assurance + * + */ + @JsonProperty("data_quality_assurance") + @JsonPropertyDescription("Data Quality Assurance") + private List dataQualityAssurance = null; + /** + * The Dataset ID Schema + *

+ * Dataset ID + * (Required) + * + */ + @JsonProperty("dataset_id") + @JsonPropertyDescription("Dataset ID") + private DatasetId datasetId; + /** + * The Dataset Description Schema + *

+ * Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file.") + private String description; + /** + * The Dataset Distribution Schema + *

+ * To provide technical information on a specific instance of data. + * + */ + @JsonProperty("distribution") + @JsonPropertyDescription("To provide technical information on a specific instance of data.") + private List distribution = null; + /** + * The Dataset Date of Issue Schema + *

+ * Date of Issue + * + */ + @JsonProperty("issued") + @JsonPropertyDescription("Date of Issue") + private String issued; + /** + * The Dataset Keyword(s) Schema + *

+ * Keywords + * + */ + @JsonProperty("keyword") + @JsonPropertyDescription("Keywords") + private List keyword = null; + /** + * The Dataset Language Schema + *

+ * Language of the dataset expressed using ISO 639-3. + * + */ + @JsonProperty("language") + @JsonPropertyDescription("Language of the dataset expressed using ISO 639-3.") + private Dataset.Language language; + /** + * The Dataset Metadata Schema + *

+ * To describe metadata standards used. + * + */ + @JsonProperty("metadata") + @JsonPropertyDescription("To describe metadata standards used.") + private List metadata = null; + /** + * The Dataset Personal Data Schema + *

+ * If any personal data is contained. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("personal_data") + @JsonPropertyDescription("If any personal data is contained. Allowed values: yes, no, unknown") + private Dataset.PersonalData personalData; + /** + * The Dataset Preservation Statement Schema + *

+ * Preservation Statement + * + */ + @JsonProperty("preservation_statement") + @JsonPropertyDescription("Preservation Statement") + private String preservationStatement; + /** + * The Dataset Security and Policy Schema + *

+ * To list all issues and requirements related to security and privacy + * + */ + @JsonProperty("security_and_privacy") + @JsonPropertyDescription("To list all issues and requirements related to security and privacy") + private List securityAndPrivacy = null; + /** + * The Dataset Sensitive Data Schema + *

+ * If any sensitive data is contained. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("sensitive_data") + @JsonPropertyDescription("If any sensitive data is contained. Allowed values: yes, no, unknown") + private Dataset.SensitiveData sensitiveData; + /** + * The Dataset Technical Resource Schema + *

+ * To list all technical resources needed to implement a DMP + * + */ + @JsonProperty("technical_resource") + @JsonPropertyDescription("To list all technical resources needed to implement a DMP") + private List technicalResource = null; + /** + * The Dataset Title Schema + *

+ * Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * (Required) + * + */ + @JsonProperty("title") + @JsonPropertyDescription("Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file.") + private String title; + /** + * The Dataset Type Schema + *

+ * If appropriate, type according to: DataCite and/or COAR dictionary. Otherwise use the common name for the type, e.g. raw data, software, survey, etc. https://schema.datacite.org/meta/kernel-4.1/doc/DataCite-MetadataKernel_v4.1.pdf http://vocabularies.coar-repositories.org/pubby/resource_type.html + * + */ + @JsonProperty("type") + @JsonPropertyDescription("If appropriate, type according to: DataCite and/or COAR dictionary. Otherwise use the common name for the type, e.g. raw data, software, survey, etc. https://schema.datacite.org/meta/kernel-4.1/doc/DataCite-MetadataKernel_v4.1.pdf http://vocabularies.coar-repositories.org/pubby/resource_type.html") + private String type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -6931119120629009399L; + + /** + * The Data Quality Assurance Schema + *

+ * Data Quality Assurance + * + */ + @JsonProperty("data_quality_assurance") + public List getDataQualityAssurance() { + return dataQualityAssurance; + } + + /** + * The Data Quality Assurance Schema + *

+ * Data Quality Assurance + * + */ + @JsonProperty("data_quality_assurance") + public void setDataQualityAssurance(List dataQualityAssurance) { + this.dataQualityAssurance = dataQualityAssurance; + } + + /** + * The Dataset ID Schema + *

+ * Dataset ID + * (Required) + * + */ + @JsonProperty("dataset_id") + public DatasetId getDatasetId() { + return datasetId; + } + + /** + * The Dataset ID Schema + *

+ * Dataset ID + * (Required) + * + */ + @JsonProperty("dataset_id") + public void setDatasetId(DatasetId datasetId) { + this.datasetId = datasetId; + } + + /** + * The Dataset Description Schema + *

+ * Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The Dataset Description Schema + *

+ * Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The Dataset Distribution Schema + *

+ * To provide technical information on a specific instance of data. + * + */ + @JsonProperty("distribution") + public List getDistribution() { + return distribution; + } + + /** + * The Dataset Distribution Schema + *

+ * To provide technical information on a specific instance of data. + * + */ + @JsonProperty("distribution") + public void setDistribution(List distribution) { + this.distribution = distribution; + } + + /** + * The Dataset Date of Issue Schema + *

+ * Date of Issue + * + */ + @JsonProperty("issued") + public String getIssued() { + return issued; + } + + /** + * The Dataset Date of Issue Schema + *

+ * Date of Issue + * + */ + @JsonProperty("issued") + public void setIssued(String issued) { + this.issued = issued; + } + + /** + * The Dataset Keyword(s) Schema + *

+ * Keywords + * + */ + @JsonProperty("keyword") + public List getKeyword() { + return keyword; + } + + /** + * The Dataset Keyword(s) Schema + *

+ * Keywords + * + */ + @JsonProperty("keyword") + public void setKeyword(List keyword) { + this.keyword = keyword; + } + + /** + * The Dataset Language Schema + *

+ * Language of the dataset expressed using ISO 639-3. + * + */ + @JsonProperty("language") + public Dataset.Language getLanguage() { + return language; + } + + /** + * The Dataset Language Schema + *

+ * Language of the dataset expressed using ISO 639-3. + * + */ + @JsonProperty("language") + public void setLanguage(Dataset.Language language) { + this.language = language; + } + + /** + * The Dataset Metadata Schema + *

+ * To describe metadata standards used. + * + */ + @JsonProperty("metadata") + public List getMetadata() { + return metadata; + } + + /** + * The Dataset Metadata Schema + *

+ * To describe metadata standards used. + * + */ + @JsonProperty("metadata") + public void setMetadata(List metadata) { + this.metadata = metadata; + } + + /** + * The Dataset Personal Data Schema + *

+ * If any personal data is contained. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("personal_data") + public Dataset.PersonalData getPersonalData() { + return personalData; + } + + /** + * The Dataset Personal Data Schema + *

+ * If any personal data is contained. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("personal_data") + public void setPersonalData(Dataset.PersonalData personalData) { + this.personalData = personalData; + } + + /** + * The Dataset Preservation Statement Schema + *

+ * Preservation Statement + * + */ + @JsonProperty("preservation_statement") + public String getPreservationStatement() { + return preservationStatement; + } + + /** + * The Dataset Preservation Statement Schema + *

+ * Preservation Statement + * + */ + @JsonProperty("preservation_statement") + public void setPreservationStatement(String preservationStatement) { + this.preservationStatement = preservationStatement; + } + + /** + * The Dataset Security and Policy Schema + *

+ * To list all issues and requirements related to security and privacy + * + */ + @JsonProperty("security_and_privacy") + public List getSecurityAndPrivacy() { + return securityAndPrivacy; + } + + /** + * The Dataset Security and Policy Schema + *

+ * To list all issues and requirements related to security and privacy + * + */ + @JsonProperty("security_and_privacy") + public void setSecurityAndPrivacy(List securityAndPrivacy) { + this.securityAndPrivacy = securityAndPrivacy; + } + + /** + * The Dataset Sensitive Data Schema + *

+ * If any sensitive data is contained. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("sensitive_data") + public Dataset.SensitiveData getSensitiveData() { + return sensitiveData; + } + + /** + * The Dataset Sensitive Data Schema + *

+ * If any sensitive data is contained. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("sensitive_data") + public void setSensitiveData(Dataset.SensitiveData sensitiveData) { + this.sensitiveData = sensitiveData; + } + + /** + * The Dataset Technical Resource Schema + *

+ * To list all technical resources needed to implement a DMP + * + */ + @JsonProperty("technical_resource") + public List getTechnicalResource() { + return technicalResource; + } + + /** + * The Dataset Technical Resource Schema + *

+ * To list all technical resources needed to implement a DMP + * + */ + @JsonProperty("technical_resource") + public void setTechnicalResource(List technicalResource) { + this.technicalResource = technicalResource; + } + + /** + * The Dataset Title Schema + *

+ * Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * (Required) + * + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * The Dataset Title Schema + *

+ * Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * (Required) + * + */ + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } + + /** + * The Dataset Type Schema + *

+ * If appropriate, type according to: DataCite and/or COAR dictionary. Otherwise use the common name for the type, e.g. raw data, software, survey, etc. https://schema.datacite.org/meta/kernel-4.1/doc/DataCite-MetadataKernel_v4.1.pdf http://vocabularies.coar-repositories.org/pubby/resource_type.html + * + */ + @JsonProperty("type") + public String getType() { + return type; + } + + /** + * The Dataset Type Schema + *

+ * If appropriate, type according to: DataCite and/or COAR dictionary. Otherwise use the common name for the type, e.g. raw data, software, survey, etc. https://schema.datacite.org/meta/kernel-4.1/doc/DataCite-MetadataKernel_v4.1.pdf http://vocabularies.coar-repositories.org/pubby/resource_type.html + * + */ + @JsonProperty("type") + public void setType(String type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Language { + + AAR("aar"), + ABK("abk"), + AFR("afr"), + AKA("aka"), + AMH("amh"), + ARA("ara"), + ARG("arg"), + ASM("asm"), + AVA("ava"), + AVE("ave"), + AYM("aym"), + AZE("aze"), + BAK("bak"), + BAM("bam"), + BEL("bel"), + BEN("ben"), + BIH("bih"), + BIS("bis"), + BOD("bod"), + BOS("bos"), + BRE("bre"), + BUL("bul"), + CAT("cat"), + CES("ces"), + CHA("cha"), + CHE("che"), + CHU("chu"), + CHV("chv"), + COR("cor"), + COS("cos"), + CRE("cre"), + CYM("cym"), + DAN("dan"), + DEU("deu"), + DIV("div"), + DZO("dzo"), + ELL("ell"), + ENG("eng"), + EPO("epo"), + EST("est"), + EUS("eus"), + EWE("ewe"), + FAO("fao"), + FAS("fas"), + FIJ("fij"), + FIN("fin"), + FRA("fra"), + FRY("fry"), + FUL("ful"), + GLA("gla"), + GLE("gle"), + GLG("glg"), + GLV("glv"), + GRN("grn"), + GUJ("guj"), + HAT("hat"), + HAU("hau"), + HBS("hbs"), + HEB("heb"), + HER("her"), + HIN("hin"), + HMO("hmo"), + HRV("hrv"), + HUN("hun"), + HYE("hye"), + IBO("ibo"), + IDO("ido"), + III("iii"), + IKU("iku"), + ILE("ile"), + INA("ina"), + IND("ind"), + IPK("ipk"), + ISL("isl"), + ITA("ita"), + JAV("jav"), + JPN("jpn"), + KAL("kal"), + KAN("kan"), + KAS("kas"), + KAT("kat"), + KAU("kau"), + KAZ("kaz"), + KHM("khm"), + KIK("kik"), + KIN("kin"), + KIR("kir"), + KOM("kom"), + KON("kon"), + KOR("kor"), + KUA("kua"), + KUR("kur"), + LAO("lao"), + LAT("lat"), + LAV("lav"), + LIM("lim"), + LIN("lin"), + LIT("lit"), + LTZ("ltz"), + LUB("lub"), + LUG("lug"), + MAH("mah"), + MAL("mal"), + MAR("mar"), + MKD("mkd"), + MLG("mlg"), + MLT("mlt"), + MON("mon"), + MRI("mri"), + MSA("msa"), + MYA("mya"), + NAU("nau"), + NAV("nav"), + NBL("nbl"), + NDE("nde"), + NDO("ndo"), + NEP("nep"), + NLD("nld"), + NNO("nno"), + NOB("nob"), + NOR("nor"), + NYA("nya"), + OCI("oci"), + OJI("oji"), + ORI("ori"), + ORM("orm"), + OSS("oss"), + PAN("pan"), + PLI("pli"), + POL("pol"), + POR("por"), + PUS("pus"), + QUE("que"), + ROH("roh"), + RON("ron"), + RUN("run"), + RUS("rus"), + SAG("sag"), + SAN("san"), + SIN("sin"), + SLK("slk"), + SLV("slv"), + SME("sme"), + SMO("smo"), + SNA("sna"), + SND("snd"), + SOM("som"), + SOT("sot"), + SPA("spa"), + SQI("sqi"), + SRD("srd"), + SRP("srp"), + SSW("ssw"), + SUN("sun"), + SWA("swa"), + SWE("swe"), + TAH("tah"), + TAM("tam"), + TAT("tat"), + TEL("tel"), + TGK("tgk"), + TGL("tgl"), + THA("tha"), + TIR("tir"), + TON("ton"), + TSN("tsn"), + TSO("tso"), + TUK("tuk"), + TUR("tur"), + TWI("twi"), + UIG("uig"), + UKR("ukr"), + URD("urd"), + UZB("uzb"), + VEN("ven"), + VIE("vie"), + VOL("vol"), + WLN("wln"), + WOL("wol"), + XHO("xho"), + YID("yid"), + YOR("yor"), + ZHA("zha"), + ZHO("zho"), + ZUL("zul"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Dataset.Language c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Language(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Dataset.Language fromValue(String value) { + Dataset.Language constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + + public enum PersonalData { + + YES("yes"), + NO("no"), + UNKNOWN("unknown"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Dataset.PersonalData c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private PersonalData(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Dataset.PersonalData fromValue(String value) { + Dataset.PersonalData constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + + public enum SensitiveData { + + YES("yes"), + NO("no"), + UNKNOWN("unknown"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Dataset.SensitiveData c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private SensitiveData(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Dataset.SensitiveData fromValue(String value) { + Dataset.SensitiveData constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/DatasetId.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/DatasetId.java new file mode 100644 index 000000000..c1cc1e57a --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/DatasetId.java @@ -0,0 +1,156 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Dataset ID Schema + *

+ * Dataset ID + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "identifier", + "type" +}) +public class DatasetId implements Serializable +{ + + /** + * The Dataset Identifier Schema + *

+ * Identifier for a dataset + * (Required) + * + */ + @JsonProperty("identifier") + @JsonPropertyDescription("Identifier for a dataset") + private String identifier; + /** + * The Dataset Identifier Type Schema + *

+ * Dataset identifier type. Allowed values: handle, doi, ark, url, other + * (Required) + * + */ + @JsonProperty("type") + @JsonPropertyDescription("Dataset identifier type. Allowed values: handle, doi, ark, url, other") + private DatasetId.Type type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -6295164005851378031L; + + /** + * The Dataset Identifier Schema + *

+ * Identifier for a dataset + * (Required) + * + */ + @JsonProperty("identifier") + public String getIdentifier() { + return identifier; + } + + /** + * The Dataset Identifier Schema + *

+ * Identifier for a dataset + * (Required) + * + */ + @JsonProperty("identifier") + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + * The Dataset Identifier Type Schema + *

+ * Dataset identifier type. Allowed values: handle, doi, ark, url, other + * (Required) + * + */ + @JsonProperty("type") + public DatasetId.Type getType() { + return type; + } + + /** + * The Dataset Identifier Type Schema + *

+ * Dataset identifier type. Allowed values: handle, doi, ark, url, other + * (Required) + * + */ + @JsonProperty("type") + public void setType(DatasetId.Type type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Type { + + HANDLE("handle"), + DOI("doi"), + ARK("ark"), + URL("url"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (DatasetId.Type c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Type(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static DatasetId.Type fromValue(String value) { + DatasetId.Type constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java new file mode 100644 index 000000000..d005e7564 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java @@ -0,0 +1,412 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.net.URI; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Dataset Distribution Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "access_url", + "available_until", + "byte_size", + "data_access", + "description", + "download_url", + "format", + "host", + "license", + "title" +}) +public class Distribution implements Serializable +{ + + /** + * The Dataset Distribution Access URL Schema + *

+ * A URL of the resource that gives access to a distribution of the dataset. e.g. landing page. + * + */ + @JsonProperty("access_url") + @JsonPropertyDescription("A URL of the resource that gives access to a distribution of the dataset. e.g. landing page.") + private String accessUrl; + /** + * The Dataset Distribution Available Until Schema + *

+ * Indicates how long this distribution will be / should be available. + * + */ + @JsonProperty("available_until") + @JsonPropertyDescription("Indicates how long this distribution will be / should be available.") + private String availableUntil; + /** + * The Dataset Distribution Byte Size Schema + *

+ * Size in bytes. + * + */ + @JsonProperty("byte_size") + @JsonPropertyDescription("Size in bytes.") + private Integer byteSize; + /** + * The Dataset Distribution Data Access Schema + *

+ * Indicates access mode for data. Allowed values: open, shared, closed + * (Required) + * + */ + @JsonProperty("data_access") + @JsonPropertyDescription("Indicates access mode for data. Allowed values: open, shared, closed") + private Distribution.DataAccess dataAccess; + /** + * The Dataset Distribution Description Schema + *

+ * Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file.") + private String description; + /** + * The Dataset Distribution Download URL Schema + *

+ * The URL of the downloadable file in a given format. E.g. CSV file or RDF file. + * + */ + @JsonProperty("download_url") + @JsonPropertyDescription("The URL of the downloadable file in a given format. E.g. CSV file or RDF file.") + private URI downloadUrl; + /** + * The Dataset Distribution Format Schema + *

+ * Format according to: https://www.iana.org/assignments/media-types/media-types.xhtml if appropriate, otherwise use the common name for this format. + * + */ + @JsonProperty("format") + @JsonPropertyDescription("Format according to: https://www.iana.org/assignments/media-types/media-types.xhtml if appropriate, otherwise use the common name for this format.") + private List format = null; + /** + * The Dataset Distribution Host Schema + *

+ * To provide information on quality of service provided by infrastructure (e.g. repository) where data is stored. + * + */ + @JsonProperty("host") + @JsonPropertyDescription("To provide information on quality of service provided by infrastructure (e.g. repository) where data is stored.") + private Host host; + /** + * The Dataset Distribution License(s) Schema + *

+ * To list all licenses applied to a specific distribution of data. + * + */ + @JsonProperty("license") + @JsonPropertyDescription("To list all licenses applied to a specific distribution of data.") + private List license = null; + /** + * The Dataset Distribution Title Schema + *

+ * Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * (Required) + * + */ + @JsonProperty("title") + @JsonPropertyDescription("Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file.") + private String title; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -6018365280419917902L; + + /** + * The Dataset Distribution Access URL Schema + *

+ * A URL of the resource that gives access to a distribution of the dataset. e.g. landing page. + * + */ + @JsonProperty("access_url") + public String getAccessUrl() { + return accessUrl; + } + + /** + * The Dataset Distribution Access URL Schema + *

+ * A URL of the resource that gives access to a distribution of the dataset. e.g. landing page. + * + */ + @JsonProperty("access_url") + public void setAccessUrl(String accessUrl) { + this.accessUrl = accessUrl; + } + + /** + * The Dataset Distribution Available Until Schema + *

+ * Indicates how long this distribution will be / should be available. + * + */ + @JsonProperty("available_until") + public String getAvailableUntil() { + return availableUntil; + } + + /** + * The Dataset Distribution Available Until Schema + *

+ * Indicates how long this distribution will be / should be available. + * + */ + @JsonProperty("available_until") + public void setAvailableUntil(String availableUntil) { + this.availableUntil = availableUntil; + } + + /** + * The Dataset Distribution Byte Size Schema + *

+ * Size in bytes. + * + */ + @JsonProperty("byte_size") + public Integer getByteSize() { + return byteSize; + } + + /** + * The Dataset Distribution Byte Size Schema + *

+ * Size in bytes. + * + */ + @JsonProperty("byte_size") + public void setByteSize(Integer byteSize) { + this.byteSize = byteSize; + } + + /** + * The Dataset Distribution Data Access Schema + *

+ * Indicates access mode for data. Allowed values: open, shared, closed + * (Required) + * + */ + @JsonProperty("data_access") + public Distribution.DataAccess getDataAccess() { + return dataAccess; + } + + /** + * The Dataset Distribution Data Access Schema + *

+ * Indicates access mode for data. Allowed values: open, shared, closed + * (Required) + * + */ + @JsonProperty("data_access") + public void setDataAccess(Distribution.DataAccess dataAccess) { + this.dataAccess = dataAccess; + } + + /** + * The Dataset Distribution Description Schema + *

+ * Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The Dataset Distribution Description Schema + *

+ * Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The Dataset Distribution Download URL Schema + *

+ * The URL of the downloadable file in a given format. E.g. CSV file or RDF file. + * + */ + @JsonProperty("download_url") + public URI getDownloadUrl() { + return downloadUrl; + } + + /** + * The Dataset Distribution Download URL Schema + *

+ * The URL of the downloadable file in a given format. E.g. CSV file or RDF file. + * + */ + @JsonProperty("download_url") + public void setDownloadUrl(URI downloadUrl) { + this.downloadUrl = downloadUrl; + } + + /** + * The Dataset Distribution Format Schema + *

+ * Format according to: https://www.iana.org/assignments/media-types/media-types.xhtml if appropriate, otherwise use the common name for this format. + * + */ + @JsonProperty("format") + public List getFormat() { + return format; + } + + /** + * The Dataset Distribution Format Schema + *

+ * Format according to: https://www.iana.org/assignments/media-types/media-types.xhtml if appropriate, otherwise use the common name for this format. + * + */ + @JsonProperty("format") + public void setFormat(List format) { + this.format = format; + } + + /** + * The Dataset Distribution Host Schema + *

+ * To provide information on quality of service provided by infrastructure (e.g. repository) where data is stored. + * + */ + @JsonProperty("host") + public Host getHost() { + return host; + } + + /** + * The Dataset Distribution Host Schema + *

+ * To provide information on quality of service provided by infrastructure (e.g. repository) where data is stored. + * + */ + @JsonProperty("host") + public void setHost(Host host) { + this.host = host; + } + + /** + * The Dataset Distribution License(s) Schema + *

+ * To list all licenses applied to a specific distribution of data. + * + */ + @JsonProperty("license") + public List getLicense() { + return license; + } + + /** + * The Dataset Distribution License(s) Schema + *

+ * To list all licenses applied to a specific distribution of data. + * + */ + @JsonProperty("license") + public void setLicense(List license) { + this.license = license; + } + + /** + * The Dataset Distribution Title Schema + *

+ * Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * (Required) + * + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * The Dataset Distribution Title Schema + *

+ * Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * (Required) + * + */ + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum DataAccess { + + OPEN("open"), + SHARED("shared"), + CLOSED("closed"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Distribution.DataAccess c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private DataAccess(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Distribution.DataAccess fromValue(String value) { + Distribution.DataAccess constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java new file mode 100644 index 000000000..7cac25d62 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java @@ -0,0 +1,774 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.net.URI; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The DMP Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "contact", + "contributor", + "cost", + "created", + "dataset", + "description", + "dmp_id", + "ethical_issues_description", + "ethical_issues_exist", + "ethical_issues_report", + "language", + "modified", + "project", + "title" +}) +public class Dmp implements Serializable +{ + + /** + * The DMP Contact Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contact") + private Contact contact; + /** + * The Contributor Schema + *

+ * + * + */ + @JsonProperty("contributor") + private List contributor = null; + /** + * The Cost Schema + *

+ * + * + */ + @JsonProperty("cost") + private List cost = null; + /** + * The DMP Creation Schema + *

+ * + * + */ + @JsonProperty("created") + @JsonPropertyDescription("") + private Date created; + /** + * The Dataset Schema + *

+ * + * (Required) + * + */ + @JsonProperty("dataset") + private List dataset = null; + /** + * The DMP Description Schema + *

+ * To provide any free-form text information on a DMP + * + */ + @JsonProperty("description") + @JsonPropertyDescription("To provide any free-form text information on a DMP") + private String description; + /** + * The DMP Identifier Schema + *

+ * Identifier for the DMP itself + * (Required) + * + */ + @JsonProperty("dmp_id") + @JsonPropertyDescription("Identifier for the DMP itself") + private DmpId dmpId; + /** + * The DMP Ethical Issues Description Schema + *

+ * To describe ethical issues directly in a DMP + * + */ + @JsonProperty("ethical_issues_description") + @JsonPropertyDescription("To describe ethical issues directly in a DMP") + private String ethicalIssuesDescription; + /** + * The DMP Ethical Issues Exist Schema + *

+ * To indicate whether there are ethical issues related to data that this DMP describes. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("ethical_issues_exist") + @JsonPropertyDescription("To indicate whether there are ethical issues related to data that this DMP describes. Allowed values: yes, no, unknown") + private Dmp.EthicalIssuesExist ethicalIssuesExist; + /** + * The DMP Ethical Issues Report Schema + *

+ * To indicate where a protocol from a meeting with an ethical commitee can be found + * + */ + @JsonProperty("ethical_issues_report") + @JsonPropertyDescription("To indicate where a protocol from a meeting with an ethical commitee can be found") + private URI ethicalIssuesReport; + /** + * The DMP Language Schema + *

+ * Language of the DMP expressed using ISO 639-3. + * (Required) + * + */ + @JsonProperty("language") + @JsonPropertyDescription("Language of the DMP expressed using ISO 639-3.") + private Dmp.Language language; + /** + * The DMP Modification Schema + *

+ * Must be set each time DMP is modified. Indicates DMP version. + * (Required) + * + */ + @JsonProperty("modified") + @JsonPropertyDescription("Must be set each time DMP is modified. Indicates DMP version.") + private Date modified; + /** + * The DMP Project Schema + *

+ * Project related to a DMP + * + */ + @JsonProperty("project") + @JsonPropertyDescription("Project related to a DMP") + private List project = null; + /** + * The DMP Title Schema + *

+ * Title of a DMP + * (Required) + * + */ + @JsonProperty("title") + @JsonPropertyDescription("Title of a DMP") + private String title; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 4599713332472772292L; + + /** + * The DMP Contact Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contact") + public Contact getContact() { + return contact; + } + + /** + * The DMP Contact Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contact") + public void setContact(Contact contact) { + this.contact = contact; + } + + /** + * The Contributor Schema + *

+ * + * + */ + @JsonProperty("contributor") + public List getContributor() { + return contributor; + } + + /** + * The Contributor Schema + *

+ * + * + */ + @JsonProperty("contributor") + public void setContributor(List contributor) { + this.contributor = contributor; + } + + /** + * The Cost Schema + *

+ * + * + */ + @JsonProperty("cost") + public List getCost() { + return cost; + } + + /** + * The Cost Schema + *

+ * + * + */ + @JsonProperty("cost") + public void setCost(List cost) { + this.cost = cost; + } + + /** + * The DMP Creation Schema + *

+ * + * + */ + @JsonProperty("created") + public Date getCreated() { + return created; + } + + /** + * The DMP Creation Schema + *

+ * + * + */ + @JsonProperty("created") + public void setCreated(Date created) { + this.created = created; + } + + /** + * The Dataset Schema + *

+ * + * (Required) + * + */ + @JsonProperty("dataset") + public List getDataset() { + return dataset; + } + + /** + * The Dataset Schema + *

+ * + * (Required) + * + */ + @JsonProperty("dataset") + public void setDataset(List dataset) { + this.dataset = dataset; + } + + /** + * The DMP Description Schema + *

+ * To provide any free-form text information on a DMP + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The DMP Description Schema + *

+ * To provide any free-form text information on a DMP + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The DMP Identifier Schema + *

+ * Identifier for the DMP itself + * (Required) + * + */ + @JsonProperty("dmp_id") + public DmpId getDmpId() { + return dmpId; + } + + /** + * The DMP Identifier Schema + *

+ * Identifier for the DMP itself + * (Required) + * + */ + @JsonProperty("dmp_id") + public void setDmpId(DmpId dmpId) { + this.dmpId = dmpId; + } + + /** + * The DMP Ethical Issues Description Schema + *

+ * To describe ethical issues directly in a DMP + * + */ + @JsonProperty("ethical_issues_description") + public String getEthicalIssuesDescription() { + return ethicalIssuesDescription; + } + + /** + * The DMP Ethical Issues Description Schema + *

+ * To describe ethical issues directly in a DMP + * + */ + @JsonProperty("ethical_issues_description") + public void setEthicalIssuesDescription(String ethicalIssuesDescription) { + this.ethicalIssuesDescription = ethicalIssuesDescription; + } + + /** + * The DMP Ethical Issues Exist Schema + *

+ * To indicate whether there are ethical issues related to data that this DMP describes. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("ethical_issues_exist") + public Dmp.EthicalIssuesExist getEthicalIssuesExist() { + return ethicalIssuesExist; + } + + /** + * The DMP Ethical Issues Exist Schema + *

+ * To indicate whether there are ethical issues related to data that this DMP describes. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("ethical_issues_exist") + public void setEthicalIssuesExist(Dmp.EthicalIssuesExist ethicalIssuesExist) { + this.ethicalIssuesExist = ethicalIssuesExist; + } + + /** + * The DMP Ethical Issues Report Schema + *

+ * To indicate where a protocol from a meeting with an ethical commitee can be found + * + */ + @JsonProperty("ethical_issues_report") + public URI getEthicalIssuesReport() { + return ethicalIssuesReport; + } + + /** + * The DMP Ethical Issues Report Schema + *

+ * To indicate where a protocol from a meeting with an ethical commitee can be found + * + */ + @JsonProperty("ethical_issues_report") + public void setEthicalIssuesReport(URI ethicalIssuesReport) { + this.ethicalIssuesReport = ethicalIssuesReport; + } + + /** + * The DMP Language Schema + *

+ * Language of the DMP expressed using ISO 639-3. + * (Required) + * + */ + @JsonProperty("language") + public Dmp.Language getLanguage() { + return language; + } + + /** + * The DMP Language Schema + *

+ * Language of the DMP expressed using ISO 639-3. + * (Required) + * + */ + @JsonProperty("language") + public void setLanguage(Dmp.Language language) { + this.language = language; + } + + /** + * The DMP Modification Schema + *

+ * Must be set each time DMP is modified. Indicates DMP version. + * (Required) + * + */ + @JsonProperty("modified") + public Date getModified() { + return modified; + } + + /** + * The DMP Modification Schema + *

+ * Must be set each time DMP is modified. Indicates DMP version. + * (Required) + * + */ + @JsonProperty("modified") + public void setModified(Date modified) { + this.modified = modified; + } + + /** + * The DMP Project Schema + *

+ * Project related to a DMP + * + */ + @JsonProperty("project") + public List getProject() { + return project; + } + + /** + * The DMP Project Schema + *

+ * Project related to a DMP + * + */ + @JsonProperty("project") + public void setProject(List project) { + this.project = project; + } + + /** + * The DMP Title Schema + *

+ * Title of a DMP + * (Required) + * + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * The DMP Title Schema + *

+ * Title of a DMP + * (Required) + * + */ + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum EthicalIssuesExist { + + YES("yes"), + NO("no"), + UNKNOWN("unknown"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Dmp.EthicalIssuesExist c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private EthicalIssuesExist(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Dmp.EthicalIssuesExist fromValue(String value) { + Dmp.EthicalIssuesExist constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + + public enum Language { + + AAR("aar"), + ABK("abk"), + AFR("afr"), + AKA("aka"), + AMH("amh"), + ARA("ara"), + ARG("arg"), + ASM("asm"), + AVA("ava"), + AVE("ave"), + AYM("aym"), + AZE("aze"), + BAK("bak"), + BAM("bam"), + BEL("bel"), + BEN("ben"), + BIH("bih"), + BIS("bis"), + BOD("bod"), + BOS("bos"), + BRE("bre"), + BUL("bul"), + CAT("cat"), + CES("ces"), + CHA("cha"), + CHE("che"), + CHU("chu"), + CHV("chv"), + COR("cor"), + COS("cos"), + CRE("cre"), + CYM("cym"), + DAN("dan"), + DEU("deu"), + DIV("div"), + DZO("dzo"), + ELL("ell"), + ENG("eng"), + EPO("epo"), + EST("est"), + EUS("eus"), + EWE("ewe"), + FAO("fao"), + FAS("fas"), + FIJ("fij"), + FIN("fin"), + FRA("fra"), + FRY("fry"), + FUL("ful"), + GLA("gla"), + GLE("gle"), + GLG("glg"), + GLV("glv"), + GRN("grn"), + GUJ("guj"), + HAT("hat"), + HAU("hau"), + HBS("hbs"), + HEB("heb"), + HER("her"), + HIN("hin"), + HMO("hmo"), + HRV("hrv"), + HUN("hun"), + HYE("hye"), + IBO("ibo"), + IDO("ido"), + III("iii"), + IKU("iku"), + ILE("ile"), + INA("ina"), + IND("ind"), + IPK("ipk"), + ISL("isl"), + ITA("ita"), + JAV("jav"), + JPN("jpn"), + KAL("kal"), + KAN("kan"), + KAS("kas"), + KAT("kat"), + KAU("kau"), + KAZ("kaz"), + KHM("khm"), + KIK("kik"), + KIN("kin"), + KIR("kir"), + KOM("kom"), + KON("kon"), + KOR("kor"), + KUA("kua"), + KUR("kur"), + LAO("lao"), + LAT("lat"), + LAV("lav"), + LIM("lim"), + LIN("lin"), + LIT("lit"), + LTZ("ltz"), + LUB("lub"), + LUG("lug"), + MAH("mah"), + MAL("mal"), + MAR("mar"), + MKD("mkd"), + MLG("mlg"), + MLT("mlt"), + MON("mon"), + MRI("mri"), + MSA("msa"), + MYA("mya"), + NAU("nau"), + NAV("nav"), + NBL("nbl"), + NDE("nde"), + NDO("ndo"), + NEP("nep"), + NLD("nld"), + NNO("nno"), + NOB("nob"), + NOR("nor"), + NYA("nya"), + OCI("oci"), + OJI("oji"), + ORI("ori"), + ORM("orm"), + OSS("oss"), + PAN("pan"), + PLI("pli"), + POL("pol"), + POR("por"), + PUS("pus"), + QUE("que"), + ROH("roh"), + RON("ron"), + RUN("run"), + RUS("rus"), + SAG("sag"), + SAN("san"), + SIN("sin"), + SLK("slk"), + SLV("slv"), + SME("sme"), + SMO("smo"), + SNA("sna"), + SND("snd"), + SOM("som"), + SOT("sot"), + SPA("spa"), + SQI("sqi"), + SRD("srd"), + SRP("srp"), + SSW("ssw"), + SUN("sun"), + SWA("swa"), + SWE("swe"), + TAH("tah"), + TAM("tam"), + TAT("tat"), + TEL("tel"), + TGK("tgk"), + TGL("tgl"), + THA("tha"), + TIR("tir"), + TON("ton"), + TSN("tsn"), + TSO("tso"), + TUK("tuk"), + TUR("tur"), + TWI("twi"), + UIG("uig"), + UKR("ukr"), + URD("urd"), + UZB("uzb"), + VEN("ven"), + VIE("vie"), + VOL("vol"), + WLN("wln"), + WOL("wol"), + XHO("xho"), + YID("yid"), + YOR("yor"), + ZHA("zha"), + ZHO("zho"), + ZUL("zul"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Dmp.Language c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Language(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Dmp.Language fromValue(String value) { + Dmp.Language constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/DmpId.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/DmpId.java new file mode 100644 index 000000000..7240efaa4 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/DmpId.java @@ -0,0 +1,156 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The DMP Identifier Schema + *

+ * Identifier for the DMP itself + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "identifier", + "type" +}) +public class DmpId implements Serializable +{ + + /** + * The DMP Identifier Value Schema + *

+ * Identifier for a DMP + * (Required) + * + */ + @JsonProperty("identifier") + @JsonPropertyDescription("Identifier for a DMP") + private String identifier; + /** + * The DMP Identifier Type Schema + *

+ * The DMP Identifier Type. Allowed values: handle, doi, ark, url, other + * (Required) + * + */ + @JsonProperty("type") + @JsonPropertyDescription("The DMP Identifier Type. Allowed values: handle, doi, ark, url, other") + private DmpId.Type type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -6059908070202476841L; + + /** + * The DMP Identifier Value Schema + *

+ * Identifier for a DMP + * (Required) + * + */ + @JsonProperty("identifier") + public String getIdentifier() { + return identifier; + } + + /** + * The DMP Identifier Value Schema + *

+ * Identifier for a DMP + * (Required) + * + */ + @JsonProperty("identifier") + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + * The DMP Identifier Type Schema + *

+ * The DMP Identifier Type. Allowed values: handle, doi, ark, url, other + * (Required) + * + */ + @JsonProperty("type") + public DmpId.Type getType() { + return type; + } + + /** + * The DMP Identifier Type Schema + *

+ * The DMP Identifier Type. Allowed values: handle, doi, ark, url, other + * (Required) + * + */ + @JsonProperty("type") + public void setType(DmpId.Type type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Type { + + HANDLE("handle"), + DOI("doi"), + ARK("ark"), + URL("url"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (DmpId.Type c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Type(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static DmpId.Type fromValue(String value) { + DmpId.Type constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/FunderId.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/FunderId.java new file mode 100644 index 000000000..12b8bb8f7 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/FunderId.java @@ -0,0 +1,154 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Funder ID Schema + *

+ * Funder ID of the associated project + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "identifier", + "type" +}) +public class FunderId implements Serializable +{ + + /** + * The Funder ID Value Schema + *

+ * Funder ID, recommended to use CrossRef Funder Registry. See: https://www.crossref.org/services/funder-registry/ + * (Required) + * + */ + @JsonProperty("identifier") + @JsonPropertyDescription("Funder ID, recommended to use CrossRef Funder Registry. See: https://www.crossref.org/services/funder-registry/") + private String identifier; + /** + * The Funder ID Type Schema + *

+ * Identifier type. Allowed values: fundref, url, other + * (Required) + * + */ + @JsonProperty("type") + @JsonPropertyDescription("Identifier type. Allowed values: fundref, url, other") + private FunderId.Type type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 1783349151334366078L; + + /** + * The Funder ID Value Schema + *

+ * Funder ID, recommended to use CrossRef Funder Registry. See: https://www.crossref.org/services/funder-registry/ + * (Required) + * + */ + @JsonProperty("identifier") + public String getIdentifier() { + return identifier; + } + + /** + * The Funder ID Value Schema + *

+ * Funder ID, recommended to use CrossRef Funder Registry. See: https://www.crossref.org/services/funder-registry/ + * (Required) + * + */ + @JsonProperty("identifier") + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + * The Funder ID Type Schema + *

+ * Identifier type. Allowed values: fundref, url, other + * (Required) + * + */ + @JsonProperty("type") + public FunderId.Type getType() { + return type; + } + + /** + * The Funder ID Type Schema + *

+ * Identifier type. Allowed values: fundref, url, other + * (Required) + * + */ + @JsonProperty("type") + public void setType(FunderId.Type type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Type { + + FUNDREF("fundref"), + URL("url"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (FunderId.Type c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Type(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static FunderId.Type fromValue(String value) { + FunderId.Type constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Funding.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Funding.java new file mode 100644 index 000000000..0cc378e7c --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Funding.java @@ -0,0 +1,187 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The DMP Project Funding Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "funder_id", + "funding_status", + "grant_id" +}) +public class Funding implements Serializable +{ + + /** + * The Funder ID Schema + *

+ * Funder ID of the associated project + * (Required) + * + */ + @JsonProperty("funder_id") + @JsonPropertyDescription("Funder ID of the associated project") + private FunderId funderId; + /** + * The Funding Status Schema + *

+ * To express different phases of project lifecycle. Allowed values: planned, applied, granted, rejected + * + */ + @JsonProperty("funding_status") + @JsonPropertyDescription("To express different phases of project lifecycle. Allowed values: planned, applied, granted, rejected") + private Funding.FundingStatus fundingStatus; + /** + * The Funding Grant ID Schema + *

+ * Grant ID of the associated project + * (Required) + * + */ + @JsonProperty("grant_id") + @JsonPropertyDescription("Grant ID of the associated project") + private GrantId grantId; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 8962229321225336165L; + + /** + * The Funder ID Schema + *

+ * Funder ID of the associated project + * (Required) + * + */ + @JsonProperty("funder_id") + public FunderId getFunderId() { + return funderId; + } + + /** + * The Funder ID Schema + *

+ * Funder ID of the associated project + * (Required) + * + */ + @JsonProperty("funder_id") + public void setFunderId(FunderId funderId) { + this.funderId = funderId; + } + + /** + * The Funding Status Schema + *

+ * To express different phases of project lifecycle. Allowed values: planned, applied, granted, rejected + * + */ + @JsonProperty("funding_status") + public Funding.FundingStatus getFundingStatus() { + return fundingStatus; + } + + /** + * The Funding Status Schema + *

+ * To express different phases of project lifecycle. Allowed values: planned, applied, granted, rejected + * + */ + @JsonProperty("funding_status") + public void setFundingStatus(Funding.FundingStatus fundingStatus) { + this.fundingStatus = fundingStatus; + } + + /** + * The Funding Grant ID Schema + *

+ * Grant ID of the associated project + * (Required) + * + */ + @JsonProperty("grant_id") + public GrantId getGrantId() { + return grantId; + } + + /** + * The Funding Grant ID Schema + *

+ * Grant ID of the associated project + * (Required) + * + */ + @JsonProperty("grant_id") + public void setGrantId(GrantId grantId) { + this.grantId = grantId; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum FundingStatus { + + PLANNED("planned"), + APPLIED("applied"), + GRANTED("granted"), + REJECTED("rejected"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Funding.FundingStatus c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private FundingStatus(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Funding.FundingStatus fromValue(String value) { + Funding.FundingStatus constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/GrantId.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/GrantId.java new file mode 100644 index 000000000..cb994a0ba --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/GrantId.java @@ -0,0 +1,153 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Funding Grant ID Schema + *

+ * Grant ID of the associated project + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "identifier", + "type" +}) +public class GrantId implements Serializable +{ + + /** + * The Funding Grant ID Value Schema + *

+ * Grant ID + * (Required) + * + */ + @JsonProperty("identifier") + @JsonPropertyDescription("Grant ID") + private String identifier; + /** + * The Funding Grant ID Type Schema + *

+ * Identifier type. Allowed values: url, other + * (Required) + * + */ + @JsonProperty("type") + @JsonPropertyDescription("Identifier type. Allowed values: url, other") + private GrantId.Type type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -7738072672837592065L; + + /** + * The Funding Grant ID Value Schema + *

+ * Grant ID + * (Required) + * + */ + @JsonProperty("identifier") + public String getIdentifier() { + return identifier; + } + + /** + * The Funding Grant ID Value Schema + *

+ * Grant ID + * (Required) + * + */ + @JsonProperty("identifier") + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + * The Funding Grant ID Type Schema + *

+ * Identifier type. Allowed values: url, other + * (Required) + * + */ + @JsonProperty("type") + public GrantId.Type getType() { + return type; + } + + /** + * The Funding Grant ID Type Schema + *

+ * Identifier type. Allowed values: url, other + * (Required) + * + */ + @JsonProperty("type") + public void setType(GrantId.Type type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Type { + + URL("url"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (GrantId.Type c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Type(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static GrantId.Type fromValue(String value) { + GrantId.Type constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Host.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Host.java new file mode 100644 index 000000000..bfa6ec615 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Host.java @@ -0,0 +1,775 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.net.URI; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Dataset Distribution Host Schema + *

+ * To provide information on quality of service provided by infrastructure (e.g. repository) where data is stored. + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "availability", + "backup_frequency", + "backup_type", + "certified_with", + "description", + "geo_location", + "pid_system", + "storage_type", + "support_versioning", + "title", + "url" +}) +public class Host implements Serializable +{ + + /** + * The Dataset Distribution Host Availability Schema + *

+ * Availability + * + */ + @JsonProperty("availability") + @JsonPropertyDescription("Availability") + private String availability; + /** + * The Dataset Distribution Host Backup Frequency Schema + *

+ * Backup Frequency + * + */ + @JsonProperty("backup_frequency") + @JsonPropertyDescription("Backup Frequency") + private String backupFrequency; + /** + * The Dataset Distribution Host Backup Type Schema + *

+ * Backup Type + * + */ + @JsonProperty("backup_type") + @JsonPropertyDescription("Backup Type") + private String backupType; + /** + * The Dataset Distribution Host Certification Type Schema + *

+ * Repository certified to a recognised standard. Allowed values: din31644, dini-zertifikat, dsa, iso16363, iso16919, trac, wds, coretrustseal + * + */ + @JsonProperty("certified_with") + @JsonPropertyDescription("Repository certified to a recognised standard. Allowed values: din31644, dini-zertifikat, dsa, iso16363, iso16919, trac, wds, coretrustseal") + private Host.CertifiedWith certifiedWith; + /** + * The Dataset Distribution Host Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Description") + private String description; + /** + * The Dataset Distribution Host Geographical Location Schema + *

+ * Physical location of the data expressed using ISO 3166-1 country code. + * + */ + @JsonProperty("geo_location") + @JsonPropertyDescription("Physical location of the data expressed using ISO 3166-1 country code.") + private Host.GeoLocation geoLocation; + /** + * The Dataset Distribution Host PID System Schema + *

+ * PID system(s). Allowed values: ark, arxiv, bibcode, doi, ean13, eissn, handle, igsn, isbn, issn, istc, lissn, lsid, pmid, purl, upc, url, urn, other + * + */ + @JsonProperty("pid_system") + @JsonPropertyDescription("PID system(s). Allowed values: ark, arxiv, bibcode, doi, ean13, eissn, handle, igsn, isbn, issn, istc, lissn, lsid, pmid, purl, upc, url, urn, other") + private List pidSystem = null; + /** + * The Dataset Distribution Host Storage Type Schema + *

+ * The type of storage required + * + */ + @JsonProperty("storage_type") + @JsonPropertyDescription("The type of storage required") + private String storageType; + /** + * The Dataset Distribution Host Support Versioning Schema + *

+ * If host supports versioning. Allowed values: yes, no, unknown + * + */ + @JsonProperty("support_versioning") + @JsonPropertyDescription("If host supports versioning. Allowed values: yes, no, unknown") + private Host.SupportVersioning supportVersioning; + /** + * The Dataset Distribution Host Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + @JsonPropertyDescription("Title") + private String title; + /** + * The Dataset Distribution Host Title Schema + *

+ * The URL of the system hosting a distribution of a dataset + * (Required) + * + */ + @JsonProperty("url") + @JsonPropertyDescription("The URL of the system hosting a distribution of a dataset") + private URI url; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 8564338806797654115L; + + /** + * The Dataset Distribution Host Availability Schema + *

+ * Availability + * + */ + @JsonProperty("availability") + public String getAvailability() { + return availability; + } + + /** + * The Dataset Distribution Host Availability Schema + *

+ * Availability + * + */ + @JsonProperty("availability") + public void setAvailability(String availability) { + this.availability = availability; + } + + /** + * The Dataset Distribution Host Backup Frequency Schema + *

+ * Backup Frequency + * + */ + @JsonProperty("backup_frequency") + public String getBackupFrequency() { + return backupFrequency; + } + + /** + * The Dataset Distribution Host Backup Frequency Schema + *

+ * Backup Frequency + * + */ + @JsonProperty("backup_frequency") + public void setBackupFrequency(String backupFrequency) { + this.backupFrequency = backupFrequency; + } + + /** + * The Dataset Distribution Host Backup Type Schema + *

+ * Backup Type + * + */ + @JsonProperty("backup_type") + public String getBackupType() { + return backupType; + } + + /** + * The Dataset Distribution Host Backup Type Schema + *

+ * Backup Type + * + */ + @JsonProperty("backup_type") + public void setBackupType(String backupType) { + this.backupType = backupType; + } + + /** + * The Dataset Distribution Host Certification Type Schema + *

+ * Repository certified to a recognised standard. Allowed values: din31644, dini-zertifikat, dsa, iso16363, iso16919, trac, wds, coretrustseal + * + */ + @JsonProperty("certified_with") + public Host.CertifiedWith getCertifiedWith() { + return certifiedWith; + } + + /** + * The Dataset Distribution Host Certification Type Schema + *

+ * Repository certified to a recognised standard. Allowed values: din31644, dini-zertifikat, dsa, iso16363, iso16919, trac, wds, coretrustseal + * + */ + @JsonProperty("certified_with") + public void setCertifiedWith(Host.CertifiedWith certifiedWith) { + this.certifiedWith = certifiedWith; + } + + /** + * The Dataset Distribution Host Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The Dataset Distribution Host Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The Dataset Distribution Host Geographical Location Schema + *

+ * Physical location of the data expressed using ISO 3166-1 country code. + * + */ + @JsonProperty("geo_location") + public Host.GeoLocation getGeoLocation() { + return geoLocation; + } + + /** + * The Dataset Distribution Host Geographical Location Schema + *

+ * Physical location of the data expressed using ISO 3166-1 country code. + * + */ + @JsonProperty("geo_location") + public void setGeoLocation(Host.GeoLocation geoLocation) { + this.geoLocation = geoLocation; + } + + /** + * The Dataset Distribution Host PID System Schema + *

+ * PID system(s). Allowed values: ark, arxiv, bibcode, doi, ean13, eissn, handle, igsn, isbn, issn, istc, lissn, lsid, pmid, purl, upc, url, urn, other + * + */ + @JsonProperty("pid_system") + public List getPidSystem() { + return pidSystem; + } + + /** + * The Dataset Distribution Host PID System Schema + *

+ * PID system(s). Allowed values: ark, arxiv, bibcode, doi, ean13, eissn, handle, igsn, isbn, issn, istc, lissn, lsid, pmid, purl, upc, url, urn, other + * + */ + @JsonProperty("pid_system") + public void setPidSystem(List pidSystem) { + this.pidSystem = pidSystem; + } + + /** + * The Dataset Distribution Host Storage Type Schema + *

+ * The type of storage required + * + */ + @JsonProperty("storage_type") + public String getStorageType() { + return storageType; + } + + /** + * The Dataset Distribution Host Storage Type Schema + *

+ * The type of storage required + * + */ + @JsonProperty("storage_type") + public void setStorageType(String storageType) { + this.storageType = storageType; + } + + /** + * The Dataset Distribution Host Support Versioning Schema + *

+ * If host supports versioning. Allowed values: yes, no, unknown + * + */ + @JsonProperty("support_versioning") + public Host.SupportVersioning getSupportVersioning() { + return supportVersioning; + } + + /** + * The Dataset Distribution Host Support Versioning Schema + *

+ * If host supports versioning. Allowed values: yes, no, unknown + * + */ + @JsonProperty("support_versioning") + public void setSupportVersioning(Host.SupportVersioning supportVersioning) { + this.supportVersioning = supportVersioning; + } + + /** + * The Dataset Distribution Host Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * The Dataset Distribution Host Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } + + /** + * The Dataset Distribution Host Title Schema + *

+ * The URL of the system hosting a distribution of a dataset + * (Required) + * + */ + @JsonProperty("url") + public URI getUrl() { + return url; + } + + /** + * The Dataset Distribution Host Title Schema + *

+ * The URL of the system hosting a distribution of a dataset + * (Required) + * + */ + @JsonProperty("url") + public void setUrl(URI url) { + this.url = url; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum CertifiedWith { + + DIN_31644("din31644"), + DINI_ZERTIFIKAT("dini-zertifikat"), + DSA("dsa"), + ISO_16363("iso16363"), + ISO_16919("iso16919"), + TRAC("trac"), + WDS("wds"), + CORETRUSTSEAL("coretrustseal"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Host.CertifiedWith c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private CertifiedWith(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Host.CertifiedWith fromValue(String value) { + Host.CertifiedWith constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + + public enum GeoLocation { + + AD("AD"), + AE("AE"), + AF("AF"), + AG("AG"), + AI("AI"), + AL("AL"), + AM("AM"), + AO("AO"), + AQ("AQ"), + AR("AR"), + AS("AS"), + AT("AT"), + AU("AU"), + AW("AW"), + AX("AX"), + AZ("AZ"), + BA("BA"), + BB("BB"), + BD("BD"), + BE("BE"), + BF("BF"), + BG("BG"), + BH("BH"), + BI("BI"), + BJ("BJ"), + BL("BL"), + BM("BM"), + BN("BN"), + BO("BO"), + BQ("BQ"), + BR("BR"), + BS("BS"), + BT("BT"), + BV("BV"), + BW("BW"), + BY("BY"), + BZ("BZ"), + CA("CA"), + CC("CC"), + CD("CD"), + CF("CF"), + CG("CG"), + CH("CH"), + CI("CI"), + CK("CK"), + CL("CL"), + CM("CM"), + CN("CN"), + CO("CO"), + CR("CR"), + CU("CU"), + CV("CV"), + CW("CW"), + CX("CX"), + CY("CY"), + CZ("CZ"), + DE("DE"), + DJ("DJ"), + DK("DK"), + DM("DM"), + DO("DO"), + DZ("DZ"), + EC("EC"), + EE("EE"), + EG("EG"), + EH("EH"), + ER("ER"), + ES("ES"), + ET("ET"), + FI("FI"), + FJ("FJ"), + FK("FK"), + FM("FM"), + FO("FO"), + FR("FR"), + GA("GA"), + GB("GB"), + GD("GD"), + GE("GE"), + GF("GF"), + GG("GG"), + GH("GH"), + GI("GI"), + GL("GL"), + GM("GM"), + GN("GN"), + GP("GP"), + GQ("GQ"), + GR("GR"), + GS("GS"), + GT("GT"), + GU("GU"), + GW("GW"), + GY("GY"), + HK("HK"), + HM("HM"), + HN("HN"), + HR("HR"), + HT("HT"), + HU("HU"), + ID("ID"), + IE("IE"), + IL("IL"), + IM("IM"), + IN("IN"), + IO("IO"), + IQ("IQ"), + IR("IR"), + IS("IS"), + IT("IT"), + JE("JE"), + JM("JM"), + JO("JO"), + JP("JP"), + KE("KE"), + KG("KG"), + KH("KH"), + KI("KI"), + KM("KM"), + KN("KN"), + KP("KP"), + KR("KR"), + KW("KW"), + KY("KY"), + KZ("KZ"), + LA("LA"), + LB("LB"), + LC("LC"), + LI("LI"), + LK("LK"), + LR("LR"), + LS("LS"), + LT("LT"), + LU("LU"), + LV("LV"), + LY("LY"), + MA("MA"), + MC("MC"), + MD("MD"), + ME("ME"), + MF("MF"), + MG("MG"), + MH("MH"), + MK("MK"), + ML("ML"), + MM("MM"), + MN("MN"), + MO("MO"), + MP("MP"), + MQ("MQ"), + MR("MR"), + MS("MS"), + MT("MT"), + MU("MU"), + MV("MV"), + MW("MW"), + MX("MX"), + MY("MY"), + MZ("MZ"), + NA("NA"), + NC("NC"), + NE("NE"), + NF("NF"), + NG("NG"), + NI("NI"), + NL("NL"), + NO("NO"), + NP("NP"), + NR("NR"), + NU("NU"), + NZ("NZ"), + OM("OM"), + PA("PA"), + PE("PE"), + PF("PF"), + PG("PG"), + PH("PH"), + PK("PK"), + PL("PL"), + PM("PM"), + PN("PN"), + PR("PR"), + PS("PS"), + PT("PT"), + PW("PW"), + PY("PY"), + QA("QA"), + RE("RE"), + RO("RO"), + RS("RS"), + RU("RU"), + RW("RW"), + SA("SA"), + SB("SB"), + SC("SC"), + SD("SD"), + SE("SE"), + SG("SG"), + SH("SH"), + SI("SI"), + SJ("SJ"), + SK("SK"), + SL("SL"), + SM("SM"), + SN("SN"), + SO("SO"), + SR("SR"), + SS("SS"), + ST("ST"), + SV("SV"), + SX("SX"), + SY("SY"), + SZ("SZ"), + TC("TC"), + TD("TD"), + TF("TF"), + TG("TG"), + TH("TH"), + TJ("TJ"), + TK("TK"), + TL("TL"), + TM("TM"), + TN("TN"), + TO("TO"), + TR("TR"), + TT("TT"), + TV("TV"), + TW("TW"), + TZ("TZ"), + UA("UA"), + UG("UG"), + UM("UM"), + US("US"), + UY("UY"), + UZ("UZ"), + VA("VA"), + VC("VC"), + VE("VE"), + VG("VG"), + VI("VI"), + VN("VN"), + VU("VU"), + WF("WF"), + WS("WS"), + YE("YE"), + YT("YT"), + ZA("ZA"), + ZM("ZM"), + ZW("ZW"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Host.GeoLocation c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private GeoLocation(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Host.GeoLocation fromValue(String value) { + Host.GeoLocation constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + + public enum SupportVersioning { + + YES("yes"), + NO("no"), + UNKNOWN("unknown"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Host.SupportVersioning c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private SupportVersioning(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Host.SupportVersioning fromValue(String value) { + Host.SupportVersioning constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/License.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/License.java new file mode 100644 index 000000000..1527f5503 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/License.java @@ -0,0 +1,113 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.net.URI; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * The Dataset Distribution License Items + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "license_ref", + "start_date" +}) +public class License implements Serializable +{ + + /** + * The Dataset Distribution License Reference Schema + *

+ * Link to license document. + * (Required) + * + */ + @JsonProperty("license_ref") + @JsonPropertyDescription("Link to license document.") + private URI licenseRef; + /** + * The Dataset Distribution License Start Date Schema + *

+ * Starting date of license. If date is set in the future, it indicates embargo period. + * (Required) + * + */ + @JsonProperty("start_date") + @JsonPropertyDescription("Starting date of license. If date is set in the future, it indicates embargo period.") + private String startDate; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 4148207295817559010L; + + /** + * The Dataset Distribution License Reference Schema + *

+ * Link to license document. + * (Required) + * + */ + @JsonProperty("license_ref") + public URI getLicenseRef() { + return licenseRef; + } + + /** + * The Dataset Distribution License Reference Schema + *

+ * Link to license document. + * (Required) + * + */ + @JsonProperty("license_ref") + public void setLicenseRef(URI licenseRef) { + this.licenseRef = licenseRef; + } + + /** + * The Dataset Distribution License Start Date Schema + *

+ * Starting date of license. If date is set in the future, it indicates embargo period. + * (Required) + * + */ + @JsonProperty("start_date") + public String getStartDate() { + return startDate; + } + + /** + * The Dataset Distribution License Start Date Schema + *

+ * Starting date of license. If date is set in the future, it indicates embargo period. + * (Required) + * + */ + @JsonProperty("start_date") + public void setStartDate(String startDate) { + this.startDate = startDate; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/MetadataStandardId.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/MetadataStandardId.java new file mode 100644 index 000000000..06b54a1f1 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/MetadataStandardId.java @@ -0,0 +1,153 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Dataset Metadata Standard ID Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "identifier", + "type" +}) +public class MetadataStandardId implements Serializable +{ + + /** + * The Dataset Metadata Standard Identifier Value Schema + *

+ * Identifier for the metadata standard used. + * (Required) + * + */ + @JsonProperty("identifier") + @JsonPropertyDescription("Identifier for the metadata standard used.") + private String identifier; + /** + * The Dataset Metadata Standard Identifier Type Schema + *

+ * Identifier type. Allowed values: url, other + * (Required) + * + */ + @JsonProperty("type") + @JsonPropertyDescription("Identifier type. Allowed values: url, other") + private MetadataStandardId.Type type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -7641042701935397947L; + + /** + * The Dataset Metadata Standard Identifier Value Schema + *

+ * Identifier for the metadata standard used. + * (Required) + * + */ + @JsonProperty("identifier") + public String getIdentifier() { + return identifier; + } + + /** + * The Dataset Metadata Standard Identifier Value Schema + *

+ * Identifier for the metadata standard used. + * (Required) + * + */ + @JsonProperty("identifier") + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + * The Dataset Metadata Standard Identifier Type Schema + *

+ * Identifier type. Allowed values: url, other + * (Required) + * + */ + @JsonProperty("type") + public MetadataStandardId.Type getType() { + return type; + } + + /** + * The Dataset Metadata Standard Identifier Type Schema + *

+ * Identifier type. Allowed values: url, other + * (Required) + * + */ + @JsonProperty("type") + public void setType(MetadataStandardId.Type type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Type { + + URL("url"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (MetadataStandardId.Type c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Type(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static MetadataStandardId.Type fromValue(String value) { + MetadataStandardId.Type constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java new file mode 100644 index 000000000..d6057ca62 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java @@ -0,0 +1,368 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Dataset Metadata Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "description", + "language", + "metadata_standard_id" +}) +public class Metadatum implements Serializable +{ + + /** + * The Dataset Metadata Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Description") + private String description; + /** + * The Dataset Metadata Language Schema + *

+ * Language of the metadata expressed using ISO 639-3. + * (Required) + * + */ + @JsonProperty("language") + @JsonPropertyDescription("Language of the metadata expressed using ISO 639-3.") + private Metadatum.Language language; + /** + * The Dataset Metadata Standard ID Schema + *

+ * + * (Required) + * + */ + @JsonProperty("metadata_standard_id") + private MetadataStandardId metadataStandardId; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 6511312853153406190L; + + /** + * The Dataset Metadata Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The Dataset Metadata Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The Dataset Metadata Language Schema + *

+ * Language of the metadata expressed using ISO 639-3. + * (Required) + * + */ + @JsonProperty("language") + public Metadatum.Language getLanguage() { + return language; + } + + /** + * The Dataset Metadata Language Schema + *

+ * Language of the metadata expressed using ISO 639-3. + * (Required) + * + */ + @JsonProperty("language") + public void setLanguage(Metadatum.Language language) { + this.language = language; + } + + /** + * The Dataset Metadata Standard ID Schema + *

+ * + * (Required) + * + */ + @JsonProperty("metadata_standard_id") + public MetadataStandardId getMetadataStandardId() { + return metadataStandardId; + } + + /** + * The Dataset Metadata Standard ID Schema + *

+ * + * (Required) + * + */ + @JsonProperty("metadata_standard_id") + public void setMetadataStandardId(MetadataStandardId metadataStandardId) { + this.metadataStandardId = metadataStandardId; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Language { + + AAR("aar"), + ABK("abk"), + AFR("afr"), + AKA("aka"), + AMH("amh"), + ARA("ara"), + ARG("arg"), + ASM("asm"), + AVA("ava"), + AVE("ave"), + AYM("aym"), + AZE("aze"), + BAK("bak"), + BAM("bam"), + BEL("bel"), + BEN("ben"), + BIH("bih"), + BIS("bis"), + BOD("bod"), + BOS("bos"), + BRE("bre"), + BUL("bul"), + CAT("cat"), + CES("ces"), + CHA("cha"), + CHE("che"), + CHU("chu"), + CHV("chv"), + COR("cor"), + COS("cos"), + CRE("cre"), + CYM("cym"), + DAN("dan"), + DEU("deu"), + DIV("div"), + DZO("dzo"), + ELL("ell"), + ENG("eng"), + EPO("epo"), + EST("est"), + EUS("eus"), + EWE("ewe"), + FAO("fao"), + FAS("fas"), + FIJ("fij"), + FIN("fin"), + FRA("fra"), + FRY("fry"), + FUL("ful"), + GLA("gla"), + GLE("gle"), + GLG("glg"), + GLV("glv"), + GRN("grn"), + GUJ("guj"), + HAT("hat"), + HAU("hau"), + HBS("hbs"), + HEB("heb"), + HER("her"), + HIN("hin"), + HMO("hmo"), + HRV("hrv"), + HUN("hun"), + HYE("hye"), + IBO("ibo"), + IDO("ido"), + III("iii"), + IKU("iku"), + ILE("ile"), + INA("ina"), + IND("ind"), + IPK("ipk"), + ISL("isl"), + ITA("ita"), + JAV("jav"), + JPN("jpn"), + KAL("kal"), + KAN("kan"), + KAS("kas"), + KAT("kat"), + KAU("kau"), + KAZ("kaz"), + KHM("khm"), + KIK("kik"), + KIN("kin"), + KIR("kir"), + KOM("kom"), + KON("kon"), + KOR("kor"), + KUA("kua"), + KUR("kur"), + LAO("lao"), + LAT("lat"), + LAV("lav"), + LIM("lim"), + LIN("lin"), + LIT("lit"), + LTZ("ltz"), + LUB("lub"), + LUG("lug"), + MAH("mah"), + MAL("mal"), + MAR("mar"), + MKD("mkd"), + MLG("mlg"), + MLT("mlt"), + MON("mon"), + MRI("mri"), + MSA("msa"), + MYA("mya"), + NAU("nau"), + NAV("nav"), + NBL("nbl"), + NDE("nde"), + NDO("ndo"), + NEP("nep"), + NLD("nld"), + NNO("nno"), + NOB("nob"), + NOR("nor"), + NYA("nya"), + OCI("oci"), + OJI("oji"), + ORI("ori"), + ORM("orm"), + OSS("oss"), + PAN("pan"), + PLI("pli"), + POL("pol"), + POR("por"), + PUS("pus"), + QUE("que"), + ROH("roh"), + RON("ron"), + RUN("run"), + RUS("rus"), + SAG("sag"), + SAN("san"), + SIN("sin"), + SLK("slk"), + SLV("slv"), + SME("sme"), + SMO("smo"), + SNA("sna"), + SND("snd"), + SOM("som"), + SOT("sot"), + SPA("spa"), + SQI("sqi"), + SRD("srd"), + SRP("srp"), + SSW("ssw"), + SUN("sun"), + SWA("swa"), + SWE("swe"), + TAH("tah"), + TAM("tam"), + TAT("tat"), + TEL("tel"), + TGK("tgk"), + TGL("tgl"), + THA("tha"), + TIR("tir"), + TON("ton"), + TSN("tsn"), + TSO("tso"), + TUK("tuk"), + TUR("tur"), + TWI("twi"), + UIG("uig"), + UKR("ukr"), + URD("urd"), + UZB("uzb"), + VEN("ven"), + VIE("vie"), + VOL("vol"), + WLN("wln"), + WOL("wol"), + XHO("xho"), + YID("yid"), + YOR("yor"), + ZHA("zha"), + ZHO("zho"), + ZUL("zul"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Metadatum.Language c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Language(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Metadatum.Language fromValue(String value) { + Metadatum.Language constant = CONSTANTS.get(value); + if (constant == null) { + return null; +// throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/PidSystem.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/PidSystem.java new file mode 100644 index 000000000..0e29d1153 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/PidSystem.java @@ -0,0 +1,63 @@ + +package eu.eudat.models.rda; + +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public enum PidSystem { + + ARK("ark"), + ARXIV("arxiv"), + BIBCODE("bibcode"), + DOI("doi"), + EAN_13("ean13"), + EISSN("eissn"), + HANDLE("handle"), + IGSN("igsn"), + ISBN("isbn"), + ISSN("issn"), + ISTC("istc"), + LISSN("lissn"), + LSID("lsid"), + PMID("pmid"), + PURL("purl"), + UPC("upc"), + URL("url"), + URN("urn"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (PidSystem c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private PidSystem(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static PidSystem fromValue(String value) { + PidSystem constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Project.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Project.java new file mode 100644 index 000000000..09c231ca3 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Project.java @@ -0,0 +1,212 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * The DMP Project Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "description", + "end", + "funding", + "start", + "title" +}) +public class Project implements Serializable +{ + + /** + * The DMP Project Description Schema + *

+ * Project description + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Project description") + private String description; + /** + * The DMP Project End Date Schema + *

+ * Project end date + * (Required) + * + */ + @JsonProperty("end") + @JsonPropertyDescription("Project end date") + private String end; + /** + * The DMP Project Funding Schema + *

+ * Funding related with a project + * + */ + @JsonProperty("funding") + @JsonPropertyDescription("Funding related with a project") + private List funding = null; + /** + * The DMP Project Start Date Schema + *

+ * Project start date + * (Required) + * + */ + @JsonProperty("start") + @JsonPropertyDescription("Project start date") + private String start; + /** + * The DMP Project Title Schema + *

+ * Project title + * (Required) + * + */ + @JsonProperty("title") + @JsonPropertyDescription("Project title") + private String title; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 1437619307195890472L; + + /** + * The DMP Project Description Schema + *

+ * Project description + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The DMP Project Description Schema + *

+ * Project description + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The DMP Project End Date Schema + *

+ * Project end date + * (Required) + * + */ + @JsonProperty("end") + public String getEnd() { + return end; + } + + /** + * The DMP Project End Date Schema + *

+ * Project end date + * (Required) + * + */ + @JsonProperty("end") + public void setEnd(String end) { + this.end = end; + } + + /** + * The DMP Project Funding Schema + *

+ * Funding related with a project + * + */ + @JsonProperty("funding") + public List getFunding() { + return funding; + } + + /** + * The DMP Project Funding Schema + *

+ * Funding related with a project + * + */ + @JsonProperty("funding") + public void setFunding(List funding) { + this.funding = funding; + } + + /** + * The DMP Project Start Date Schema + *

+ * Project start date + * (Required) + * + */ + @JsonProperty("start") + public String getStart() { + return start; + } + + /** + * The DMP Project Start Date Schema + *

+ * Project start date + * (Required) + * + */ + @JsonProperty("start") + public void setStart(String start) { + this.start = start; + } + + /** + * The DMP Project Title Schema + *

+ * Project title + * (Required) + * + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * The DMP Project Title Schema + *

+ * Project title + * (Required) + * + */ + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/RDAModel.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/RDAModel.java new file mode 100644 index 000000000..61df61b32 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/RDAModel.java @@ -0,0 +1,58 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * RDA DMP Common Standard Schema + *

+ * JSON Schema for the RDA DMP Common Standard + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "dmp" +}) +public class RDAModel implements Serializable +{ + + /** + * The DMP Schema + *

+ * + * (Required) + * + */ + @JsonProperty("dmp") + private Dmp dmp; + private final static long serialVersionUID = 7331666133368350998L; + + /** + * The DMP Schema + *

+ * + * (Required) + * + */ + @JsonProperty("dmp") + public Dmp getDmp() { + return dmp; + } + + /** + * The DMP Schema + *

+ * + * (Required) + * + */ + @JsonProperty("dmp") + public void setDmp(Dmp dmp) { + this.dmp = dmp; + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java new file mode 100644 index 000000000..0486df588 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java @@ -0,0 +1,109 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * The Dataset Security & Policy Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "description", + "title" +}) +public class SecurityAndPrivacy implements Serializable +{ + + /** + * The Dataset Security & Policy Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Description") + private String description; + /** + * The Dataset Security & Policy Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + @JsonPropertyDescription("Title") + private String title; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 7863747935827682977L; + + /** + * The Dataset Security & Policy Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The Dataset Security & Policy Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The Dataset Security & Policy Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * The Dataset Security & Policy Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java new file mode 100644 index 000000000..eac85da72 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java @@ -0,0 +1,109 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * The Dataset Technical Resource Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "description", + "name" +}) +public class TechnicalResource implements Serializable +{ + + /** + * The Dataset Technical Resource Description Schema + *

+ * Description of the technical resource + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Description of the technical resource") + private String description; + /** + * The Dataset Technical Resource Name Schema + *

+ * Name of the technical resource + * (Required) + * + */ + @JsonProperty("name") + @JsonPropertyDescription("Name of the technical resource") + private String name; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -7451757227129483110L; + + /** + * The Dataset Technical Resource Description Schema + *

+ * Description of the technical resource + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The Dataset Technical Resource Description Schema + *

+ * Description of the technical resource + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The Dataset Technical Resource Name Schema + *

+ * Name of the technical resource + * (Required) + * + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * The Dataset Technical Resource Name Schema + *

+ * Name of the technical resource + * (Required) + * + */ + @JsonProperty("name") + public void setName(String name) { + this.name = name; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java new file mode 100644 index 000000000..48549d75a --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java @@ -0,0 +1,15 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.models.rda.ContactId; + +import java.util.UUID; + +public class ContactIdRDAMapper { + + public static ContactId toRDA(UUID id) { + ContactId rda = new ContactId(); + rda.setIdentifier(id.toString()); + rda.setType(ContactId.Type.OTHER); + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java new file mode 100644 index 000000000..69ea2310e --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java @@ -0,0 +1,16 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.data.entities.UserInfo; +import eu.eudat.models.rda.Contact; +import eu.eudat.models.rda.ContactId; + +public class ContactRDAMapper { + + public static Contact toRDA(UserInfo creator) { + Contact rda = new Contact(); + rda.setName(creator.getName()); + rda.setMbox(creator.getEmail()); + rda.setContactId(ContactIdRDAMapper.toRDA(creator.getId())); + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorIdRDAMapper.java new file mode 100644 index 000000000..107dfb996 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorIdRDAMapper.java @@ -0,0 +1,16 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.models.rda.Contributor; +import eu.eudat.models.rda.ContributorId; + +import java.util.UUID; + +public class ContributorIdRDAMapper { + + public static ContributorId toRDA(UUID id) { + ContributorId rda = new ContributorId(); + rda.setIdentifier(id.toString()); + rda.setType(ContributorId.Type.OTHER); + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorRDAMapper.java new file mode 100644 index 000000000..681d98940 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorRDAMapper.java @@ -0,0 +1,20 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.data.entities.UserDMP; +import eu.eudat.models.rda.Contributor; + +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; + +public class ContributorRDAMapper { + + public static Contributor toRDA(UserDMP userDMP) { + Contributor rda = new Contributor(); + rda.setContributorId(ContributorIdRDAMapper.toRDA(userDMP.getUser().getId())); + rda.setName(userDMP.getUser().getName()); + rda.setMbox(userDMP.getUser().getEmail()); + rda.setRole(new HashSet<>(Arrays.asList(UserDMP.UserDMPRoles.fromInteger(userDMP.getRole()).name()))); + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetIdRDAMapper.java new file mode 100644 index 000000000..ab791e215 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetIdRDAMapper.java @@ -0,0 +1,17 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.databind.ObjectMapper; +import eu.eudat.models.rda.DatasetId; + +import java.util.UUID; + +public class DatasetIdRDAMapper { + + public static DatasetId toRDA(UUID id) { + DatasetId rda = new DatasetId(); + rda.setIdentifier(id.toString()); + rda.setType(DatasetId.Type.OTHER); + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java new file mode 100644 index 000000000..103ba72c6 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java @@ -0,0 +1,100 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import eu.eudat.logic.managers.DatasetManager; +import eu.eudat.logic.utilities.json.JsonSearcher; +import eu.eudat.models.data.datasetwizard.DatasetWizardModel; +import eu.eudat.models.rda.Dataset; +import org.json.JSONObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.transaction.Transactional; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.stream.Collectors; + +@Component +public class DatasetRDAMapper { + private static final Logger logger = LoggerFactory.getLogger(DatasetRDAMapper.class); + + private DatasetManager datasetManager; + + @Autowired + public DatasetRDAMapper(DatasetManager datasetManager) { + this.datasetManager = datasetManager; + } + + @Transactional + public Dataset toRDA(eu.eudat.data.entities.Dataset dataset) { + Dataset rda = new Dataset(); + rda.setDatasetId(DatasetIdRDAMapper.toRDA(dataset.getId())); + rda.setTitle(dataset.getLabel()); + rda.setDescription(dataset.getDescription()); + try { + + DatasetWizardModel datasetWizardModel = new DatasetWizardModel().fromDataModel(dataset); + datasetWizardModel.setDatasetProfileDefinition(datasetManager.getPagedProfile(datasetWizardModel, dataset)); + ObjectMapper mapper = new ObjectMapper(); + JsonNode properties = mapper.readTree(dataset.getProperties()); + String datasetDescriptionJson = mapper.writeValueAsString(datasetWizardModel.getDatasetProfileDefinition()); + JsonNode datasetDescriptionObj = mapper.readTree(datasetDescriptionJson); + List typeNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.type"); + if (!typeNodes.isEmpty()) { + rda.setType(properties.get(typeNodes.get(0).get("id").asText()).asText()); + } + List languageNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.language"); + if (!languageNodes.isEmpty()) { + rda.setLanguage(Dataset.Language.fromValue(properties.get(languageNodes.get(0).get("id").asText()).asText())); + } + List metadataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.metadata"); + if (!metadataNodes.isEmpty()) { + rda.setMetadata(metadataNodes.stream().map(node -> MetadataRDAMapper.toRDA(node, properties)).collect(Collectors.toList())); + } + List qaNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.data_quality_assurance"); + if (!qaNodes.isEmpty()) { + rda.setDataQualityAssurance(qaNodes.stream().map(qaNode -> properties.get(qaNode.get("id").asText()).asText()).collect(Collectors.toList())); + } + List preservationNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.preservation_statement"); + if (!preservationNodes.isEmpty()) { + rda.setDataQualityAssurance(preservationNodes.stream().map(preservationNode -> properties.get(preservationNode.get("id").asText()).asText()).collect(Collectors.toList())); + } + List distributionNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.distribution"); + if (!distributionNodes.isEmpty()) { + rda.setDistribution(distributionNodes.stream().map(distributionNode -> DistributionRDAMapper.toRDA(distributionNode, properties)).collect(Collectors.toList())); + } + List keywordNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.keyword"); + if (!keywordNodes.isEmpty()) { + rda.setKeyword(keywordNodes.stream().map(keywordNode -> properties.get(keywordNode.get("id").asText()).asText()).collect(Collectors.toList())); + } + List personalDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.personal_data"); + if (!personalDataNodes.isEmpty()) { + rda.setPersonalData(personalDataNodes.stream().map(personalDataNode -> Dataset.PersonalData.fromValue(properties.get(personalDataNode.get("id").asText()).asText())).findFirst().get()); + } + List securityAndPrivacyNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.security_and_privacy"); + if (!securityAndPrivacyNodes.isEmpty()) { + rda.setSecurityAndPrivacy(securityAndPrivacyNodes.stream().map(securityAndPrivacyNode -> SecurityAndPrivacyRDAMapper.toRDA(securityAndPrivacyNode, properties)).collect(Collectors.toList())); + } + List sensitiveDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.sensitive_data"); + if (!sensitiveDataNodes.isEmpty()) { + rda.setSensitiveData(securityAndPrivacyNodes.stream().map(sensitiveDataNode -> Dataset.SensitiveData.fromValue(properties.get(sensitiveDataNode.get("id").asText()).asText())).findFirst().get()); + } + List technicalResourceNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.technical_resource"); + if (!technicalResourceNodes.isEmpty()) { + rda.setTechnicalResource(technicalResourceNodes.stream().map(technicalResourceNode -> TechnicalResourceRDAMapper.toRDA(technicalResourceNode, properties)).collect(Collectors.toList())); + } + + + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java new file mode 100644 index 000000000..513affd98 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java @@ -0,0 +1,39 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.models.rda.Distribution; + +import java.net.URI; +import java.util.Collections; + +public class DistributionRDAMapper { + + public static Distribution toRDA(JsonNode structure, JsonNode properties) { + Distribution rda = new Distribution(); + String rdaProperty = structure.get("rdaProperty").asText(); + if (rdaProperty.contains("access_url")) { + rda.setAccessUrl(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("available_util")) { + rda.setAvailableUntil(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("byte_size")) { + rda.setByteSize(properties.get(structure.get("id").asText()).asInt()); + } else if (rdaProperty.contains("data_access")) { + rda.setDataAccess(Distribution.DataAccess.fromValue(properties.get(structure.get("id").asText()).asText())); + } else if (rdaProperty.contains("description")) { + rda.setDescription(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("download_url")) { + rda.setDownloadUrl(URI.create(properties.get(structure.get("id").asText()).asText())); + } else if (rdaProperty.contains("format")) { + rda.setFormat(Collections.singletonList(properties.get(structure.get("id").asText()).asText())); + } else if (rdaProperty.contains("host")) { + rda.setHost(HostRDAMapper.toRDA(structure, properties)); + } else if (rdaProperty.contains("license")) { + rda.setLicense(Collections.singletonList(LicenseRDAMapper.toRDA(structure, properties))); + } else if (rdaProperty.contains("title")) { + rda.setTitle(properties.get(structure.get("id").asText()).asText()); + } + + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpIdRDAMapper.java new file mode 100644 index 000000000..095c26e11 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpIdRDAMapper.java @@ -0,0 +1,19 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.models.rda.DmpId; + +import java.util.UUID; + +public class DmpIdRDAMapper { + + public static DmpId toRDA(Object id) { + DmpId rda = new DmpId(); + rda.setIdentifier(id.toString()); + if (id instanceof UUID) { + rda.setType(DmpId.Type.OTHER); + } else { + rda.setType(DmpId.Type.DOI); + } + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java new file mode 100644 index 000000000..620229a27 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java @@ -0,0 +1,51 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.data.entities.DMP; +import eu.eudat.data.entities.UserDMP; +import eu.eudat.data.entities.UserInfo; +import eu.eudat.models.rda.Dmp; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.transaction.Transactional; +import java.util.Collections; +import java.util.stream.Collectors; + +@Component +public class DmpRDAMapper { + + private DatasetRDAMapper datasetRDAMapper; + + @Autowired + public DmpRDAMapper(DatasetRDAMapper datasetRDAMapper) { + this.datasetRDAMapper = datasetRDAMapper; + } + + @Transactional + public Dmp toRDA(DMP dmp) { + Dmp rda = new Dmp(); + if (dmp.getDoi() != null && !dmp.getDoi().isEmpty()) { + rda.setDmpId(DmpIdRDAMapper.toRDA(dmp.getDoi())); + } else { + rda.setDmpId(DmpIdRDAMapper.toRDA(dmp.getId())); + } + rda.setCreated(dmp.getCreated()); + rda.setDescription(dmp.getDescription()); + rda.setModified(dmp.getModified()); + rda.setTitle(dmp.getLabel()); + + UserInfo creator; + if (dmp.getCreator() != null) { + creator = dmp.getCreator(); + } else { + creator = dmp.getUsers().stream().filter(userDMP -> userDMP.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())).map(UserDMP::getUser).findFirst().orElse(new UserInfo()); + } + rda.setContact(ContactRDAMapper.toRDA(creator)); + rda.setContributor(dmp.getUsers().stream().map(ContributorRDAMapper::toRDA).collect(Collectors.toList())); + rda.setDataset(dmp.getDataset().stream().map(dataset -> datasetRDAMapper.toRDA(dataset)).collect(Collectors.toList())); + rda.setProject(Collections.singletonList(ProjectRDAMapper.toRDA(dmp.getProject(), dmp.getGrant()))); + + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FunderIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FunderIdRDAMapper.java new file mode 100644 index 000000000..f0dc5ff4a --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FunderIdRDAMapper.java @@ -0,0 +1,19 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.models.rda.FunderId; + +import java.util.UUID; + +public class FunderIdRDAMapper { + + public static FunderId toRDA(Object id) { + FunderId rda = new FunderId(); + rda.setIdentifier(id.toString()); + if (id instanceof UUID) { + rda.setType(FunderId.Type.OTHER); + } else { + rda.setType(FunderId.Type.FUNDREF); + } + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java new file mode 100644 index 000000000..e0b8fbe65 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java @@ -0,0 +1,25 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.data.entities.Funder; +import eu.eudat.data.entities.Grant; +import eu.eudat.models.rda.Funding; + +public class FundingRDAMapper { + + public static Funding toRDA(Grant grant) { + Funding rda = new Funding(); + String referencePrefix; + String shortReference; + if (grant.getFunder().getReference() != null) { + referencePrefix = grant.getFunder().getReference().split(":")[0]; + shortReference = grant.getFunder().getReference().substring(referencePrefix.length() + 1); + rda.setFunderId(FunderIdRDAMapper.toRDA(shortReference)); + } else { + rda.setFunderId(FunderIdRDAMapper.toRDA(grant.getFunder().getId())); + } + referencePrefix = grant.getReference().split(":")[0]; + shortReference = grant.getReference().substring(referencePrefix.length() + 1); + rda.setGrantId(GrantIdRDAMapper.toRDA(shortReference)); + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/GrantIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/GrantIdRDAMapper.java new file mode 100644 index 000000000..d05ec5d02 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/GrantIdRDAMapper.java @@ -0,0 +1,13 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.models.rda.GrantId; + +public class GrantIdRDAMapper { + + public static GrantId toRDA(String id) { + GrantId rda = new GrantId(); + rda.setIdentifier(id); + rda.setType(GrantId.Type.OTHER); + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java new file mode 100644 index 000000000..9a32cc697 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java @@ -0,0 +1,41 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.models.rda.Host; +import eu.eudat.models.rda.PidSystem; + +import java.net.URI; +import java.util.Collections; + +public class HostRDAMapper { + + public static Host toRDA(JsonNode structure, JsonNode properties) { + Host rda = new Host(); + String rdaProperty = structure.get("rdaProperties").asText(); + if (rdaProperty.contains("availability")) { + rda.setAvailability(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("backup_frequency")) { + rda.setBackupFrequency(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("backup_type")) { + rda.setBackupType(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("certified_with")) { + rda.setCertifiedWith(Host.CertifiedWith.fromValue(properties.get(structure.get("id").asText()).asText())); + } else if (rdaProperty.contains("description")) { + rda.setDescription(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("geo_location")) { + rda.setGeoLocation(Host.GeoLocation.fromValue(properties.get(structure.get("id").asText()).asText())); + } else if (rdaProperty.contains("pid_system")) { + rda.setPidSystem(Collections.singletonList(PidSystem.fromValue(properties.get(structure.get("id").asText()).asText()))); + } else if (rdaProperty.contains("storage_type")) { + rda.setStorageType(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("support_versioning")) { + rda.setSupportVersioning(Host.SupportVersioning.fromValue(properties.get(structure.get("id").asText()).asText())); + } else if (rdaProperty.contains("title")) { + rda.setTitle(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("url")) { + rda.setUrl(URI.create(properties.get(structure.get("id").asText()).asText())); + } + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java new file mode 100644 index 000000000..68817bd3d --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java @@ -0,0 +1,23 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.models.rda.License; + +import java.net.URI; + +public class LicenseRDAMapper { + + public static License toRDA(JsonNode structure, JsonNode properties) { + License rda = new License(); + String rdaProperty = structure.get("rdaProperty").asText(); + String value = properties.get(structure.get("id").asText()).asText(); + + if (rdaProperty.contains("license_ref")) { + rda.setLicenseRef(URI.create(value)); + } else if (rdaProperty.contains("start_date")) { + rda.setStartDate(value); + } + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java new file mode 100644 index 000000000..fa638d3e3 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java @@ -0,0 +1,44 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import eu.eudat.models.rda.Metadatum; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.util.Iterator; + +public class MetadataRDAMapper { + private static final Logger logger = LoggerFactory.getLogger(MetadataRDAMapper.class); + + public static Metadatum toRDA(JsonNode structure, JsonNode properties) { + Metadatum rda = new Metadatum(); + JsonNode dataNode = null; + String rdaProperty = structure.get("rdaProperty").asText(); + if (rdaProperty.contains("metadata_standard_id")) { + try { + String jsonText = properties.get(structure.get("id").asText()).asText(); + if (jsonText != null && !jsonText.isEmpty()) { + dataNode = new ObjectMapper().readTree(jsonText); + for (Iterator it = dataNode.elements(); it.hasNext(); ) { + JsonNode data = it.next(); + if (data.get("uri") != null) { + rda.setMetadataStandardId(MetadataStandardIdRDAMapper.toRDA(data.get("uri").asText())); + } + } + } + } catch (IOException e) { + logger.error(e.getMessage(), e); + } + } else if (rdaProperty.contains("description")) { + rda.setDescription(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("language")) { + String language = properties.get(structure.get("id").asText()).asText(); + Metadatum.Language lang = Metadatum.Language.fromValue(language); + rda.setLanguage(lang); + } + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataStandardIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataStandardIdRDAMapper.java new file mode 100644 index 000000000..586446e02 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataStandardIdRDAMapper.java @@ -0,0 +1,13 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.models.rda.MetadataStandardId; + +public class MetadataStandardIdRDAMapper { + + public static MetadataStandardId toRDA(String uri) { + MetadataStandardId rda = new MetadataStandardId(); + rda.setIdentifier(uri); + rda.setType(MetadataStandardId.Type.URL); + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java new file mode 100644 index 000000000..d97eace4a --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java @@ -0,0 +1,25 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.data.entities.Funder; +import eu.eudat.data.entities.Grant; +import eu.eudat.models.rda.Project; + +import java.util.Collections; + +public class ProjectRDAMapper { + + public static Project toRDA(eu.eudat.data.entities.Project project, Grant grant) { + Project rda = new Project(); + rda.setTitle(project.getLabel()); + rda.setDescription(project.getDescription()); + if (project.getStartdate() != null) { + rda.setStart(project.getStartdate().toString()); + } + if (project.getEnddate() != null) { + rda.setEnd(project.getEnddate().toString()); + } + rda.setFunding(Collections.singletonList(FundingRDAMapper.toRDA(grant))); + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java new file mode 100644 index 000000000..f7f95633f --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java @@ -0,0 +1,21 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.models.rda.SecurityAndPrivacy; + +public class SecurityAndPrivacyRDAMapper { + + public static SecurityAndPrivacy toRDA(JsonNode structure, JsonNode properties) { + SecurityAndPrivacy rda = new SecurityAndPrivacy(); + String rdaProperty = structure.get("rdaProperty").asText(); + String value = properties.get(structure.get("id").asText()).asText(); + + if (rdaProperty.contains("description")) { + rda.setDescription(value); + } else if (rdaProperty.contains("title")) { + rda.setTitle(value); + } + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java new file mode 100644 index 000000000..b2652901a --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java @@ -0,0 +1,21 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.models.rda.TechnicalResource; + +public class TechnicalResourceRDAMapper { + + public static TechnicalResource toRDA(JsonNode structure, JsonNode properties) { + TechnicalResource rda = new TechnicalResource(); + String rdaProperty = structure.get("rdaProperty").asText(); + String value = properties.get(structure.get("id").asText()).asText(); + + if (rdaProperty.contains("description")) { + rda.setDescription(value); + } else if (rdaProperty.contains("name")) { + rda.setName(value); + } + + return rda; + } +} From 19ccef69911c69dcf8fae72d5ab88b3044e9d5dd Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Mon, 23 Mar 2020 18:09:31 +0200 Subject: [PATCH 16/20] Improved object coupling for various objects on the dataset form --- .../utilities/helpers/MyStringUtils.java | 21 ++++ .../logic/utilities/json/JsonSearcher.java | 1 + .../user/components/datasetprofile/Field.java | 6 +- .../components/datasetprofile/FieldSet.java | 9 +- .../models/rda/mapper/DatasetRDAMapper.java | 27 ++-- .../rda/mapper/DistributionRDAMapper.java | 107 ++++++++++++++-- .../models/rda/mapper/HostRDAMapper.java | 98 +++++++++++---- .../models/rda/mapper/LicenseRDAMapper.java | 6 +- .../models/rda/mapper/MetadataRDAMapper.java | 119 +++++++++++++++--- .../mapper/SecurityAndPrivacyRDAMapper.java | 57 ++++++++- .../mapper/TechnicalResourceRDAMapper.java | 58 ++++++++- .../dataset-description-form.model.ts | 2 +- 12 files changed, 424 insertions(+), 87 deletions(-) create mode 100644 dmp-backend/web/src/main/java/eu/eudat/logic/utilities/helpers/MyStringUtils.java diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/helpers/MyStringUtils.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/helpers/MyStringUtils.java new file mode 100644 index 000000000..1a071e04c --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/helpers/MyStringUtils.java @@ -0,0 +1,21 @@ +package eu.eudat.logic.utilities.helpers; + +public class MyStringUtils { + + public static int getFirstDifference(String s1, String s2) { + char[] s1ar = s1.toCharArray(); + char[] s2ar = s2.toCharArray(); + + for(int i = 0; i < s1ar.length; i++) { + if (s2ar.length > i) { + if (s1ar[i] != s2ar[i]) { + return i; + } + } else { + return i; + } + } + + return -1; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java index ca2372b91..979053830 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java @@ -1,6 +1,7 @@ package eu.eudat.logic.utilities.json; import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.ObjectNode; import java.util.ArrayList; import java.util.Iterator; diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/Field.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/Field.java index 4950261c4..1c735e1a9 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/Field.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/Field.java @@ -149,7 +149,7 @@ public class Field implements Comparable, PropertiesModelBuilder, ViewStyleDefin this.rdaProperty = rdaProperty; } - Field cloneForMultiplicity(String key, Map properties) { + Field cloneForMultiplicity(String key, Map properties, int index) { Field newField = new Field(); newField.id = key; newField.ordinal = this.ordinal; @@ -161,6 +161,7 @@ public class Field implements Comparable, PropertiesModelBuilder, ViewStyleDefin newField.data = this.data; newField.validations = this.validations; newField.rdaProperty = this.rdaProperty; + newField.numbering = "mult" + index + "_" + this.numbering; return newField; } @@ -204,8 +205,9 @@ public class Field implements Comparable, PropertiesModelBuilder, ViewStyleDefin } 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)); + this.multiplicityItems.add(this.cloneForMultiplicity(key, properties, index)); } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/FieldSet.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/FieldSet.java index 51663ddaf..277534d16 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/FieldSet.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/FieldSet.java @@ -163,16 +163,18 @@ public class FieldSet implements Comparable, PropertiesModelBuilder, ViewStyleDe }); 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)); + 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){ + private FieldSet CloneForMultiplicity2(List key, Map properties,String[] ids, int index){ FieldSet newFieldSet = new FieldSet(); newFieldSet.id = ids[0]+"_"+ids[1]+"_"+ids[2]; newFieldSet.description = this.description; @@ -181,8 +183,9 @@ public class FieldSet implements Comparable, PropertiesModelBuilder, ViewStyleDe newFieldSet.title = this.title; newFieldSet.ordinal = this.ordinal; newFieldSet.fields = new LinkedList(); + for (Field field: this.fields) { - newFieldSet.fields.add(field.cloneForMultiplicity(newFieldSet.id + "_" + field.getId(), properties)); + newFieldSet.fields.add(field.cloneForMultiplicity(newFieldSet.id + "_" + field.getId(), properties, index)); } return newFieldSet; } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java index 103ba72c6..5eb9cc685 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java @@ -1,21 +1,17 @@ package eu.eudat.models.rda.mapper; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import eu.eudat.logic.managers.DatasetManager; import eu.eudat.logic.utilities.json.JsonSearcher; import eu.eudat.models.data.datasetwizard.DatasetWizardModel; import eu.eudat.models.rda.Dataset; -import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import javax.transaction.Transactional; -import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import java.util.stream.Collectors; @@ -41,52 +37,51 @@ public class DatasetRDAMapper { DatasetWizardModel datasetWizardModel = new DatasetWizardModel().fromDataModel(dataset); datasetWizardModel.setDatasetProfileDefinition(datasetManager.getPagedProfile(datasetWizardModel, dataset)); ObjectMapper mapper = new ObjectMapper(); - JsonNode properties = mapper.readTree(dataset.getProperties()); String datasetDescriptionJson = mapper.writeValueAsString(datasetWizardModel.getDatasetProfileDefinition()); JsonNode datasetDescriptionObj = mapper.readTree(datasetDescriptionJson); List typeNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.type"); if (!typeNodes.isEmpty()) { - rda.setType(properties.get(typeNodes.get(0).get("id").asText()).asText()); + rda.setType(typeNodes.get(0).get("value").asText()); } List languageNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.language"); if (!languageNodes.isEmpty()) { - rda.setLanguage(Dataset.Language.fromValue(properties.get(languageNodes.get(0).get("id").asText()).asText())); + rda.setLanguage(Dataset.Language.fromValue(languageNodes.get(0).get("value").asText())); } List metadataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.metadata"); if (!metadataNodes.isEmpty()) { - rda.setMetadata(metadataNodes.stream().map(node -> MetadataRDAMapper.toRDA(node, properties)).collect(Collectors.toList())); + rda.setMetadata(MetadataRDAMapper.toRDAList(metadataNodes)); } List qaNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.data_quality_assurance"); if (!qaNodes.isEmpty()) { - rda.setDataQualityAssurance(qaNodes.stream().map(qaNode -> properties.get(qaNode.get("id").asText()).asText()).collect(Collectors.toList())); + rda.setDataQualityAssurance(qaNodes.stream().map(qaNode -> qaNode.get("value").asText()).collect(Collectors.toList())); } List preservationNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.preservation_statement"); if (!preservationNodes.isEmpty()) { - rda.setDataQualityAssurance(preservationNodes.stream().map(preservationNode -> properties.get(preservationNode.get("id").asText()).asText()).collect(Collectors.toList())); + rda.setDataQualityAssurance(preservationNodes.stream().map(preservationNode -> preservationNode.get("value").asText()).collect(Collectors.toList())); } List distributionNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.distribution"); if (!distributionNodes.isEmpty()) { - rda.setDistribution(distributionNodes.stream().map(distributionNode -> DistributionRDAMapper.toRDA(distributionNode, properties)).collect(Collectors.toList())); + rda.setDistribution(DistributionRDAMapper.toRDAList(distributionNodes)); } List keywordNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.keyword"); if (!keywordNodes.isEmpty()) { - rda.setKeyword(keywordNodes.stream().map(keywordNode -> properties.get(keywordNode.get("id").asText()).asText()).collect(Collectors.toList())); + rda.setKeyword(keywordNodes.stream().map(keywordNode -> keywordNode.get("value").asText()).collect(Collectors.toList())); } List personalDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.personal_data"); if (!personalDataNodes.isEmpty()) { - rda.setPersonalData(personalDataNodes.stream().map(personalDataNode -> Dataset.PersonalData.fromValue(properties.get(personalDataNode.get("id").asText()).asText())).findFirst().get()); + rda.setPersonalData(personalDataNodes.stream().map(personalDataNode -> Dataset.PersonalData.fromValue(personalDataNode.get("value").asText())).findFirst().get()); } List securityAndPrivacyNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.security_and_privacy"); if (!securityAndPrivacyNodes.isEmpty()) { - rda.setSecurityAndPrivacy(securityAndPrivacyNodes.stream().map(securityAndPrivacyNode -> SecurityAndPrivacyRDAMapper.toRDA(securityAndPrivacyNode, properties)).collect(Collectors.toList())); + rda.setSecurityAndPrivacy(SecurityAndPrivacyRDAMapper.toRDAList(securityAndPrivacyNodes)); } List sensitiveDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.sensitive_data"); if (!sensitiveDataNodes.isEmpty()) { - rda.setSensitiveData(securityAndPrivacyNodes.stream().map(sensitiveDataNode -> Dataset.SensitiveData.fromValue(properties.get(sensitiveDataNode.get("id").asText()).asText())).findFirst().get()); + rda.setSensitiveData(securityAndPrivacyNodes.stream().map(sensitiveDataNode -> Dataset.SensitiveData.fromValue(sensitiveDataNode.get("value").asText())).findFirst().get()); } List technicalResourceNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.technical_resource"); if (!technicalResourceNodes.isEmpty()) { - rda.setTechnicalResource(technicalResourceNodes.stream().map(technicalResourceNode -> TechnicalResourceRDAMapper.toRDA(technicalResourceNode, properties)).collect(Collectors.toList())); + rda.setTechnicalResource(TechnicalResourceRDAMapper.toRDAList(technicalResourceNodes)); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java index 513affd98..98cb6960b 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java @@ -1,39 +1,120 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.logic.utilities.helpers.MyStringUtils; import eu.eudat.models.rda.Distribution; import java.net.URI; -import java.util.Collections; +import java.util.*; public class DistributionRDAMapper { - public static Distribution toRDA(JsonNode structure, JsonNode properties) { + public static List toRDAList(List nodes) { + Map rdaMap = new HashMap<>(); + + for (JsonNode node: nodes) { + String rdaProperty = node.get("rdaProperty").asText(); + String rdaValue = node.get("value").asText(); + Distribution rda = getRelative(rdaMap, node.get("numbering").asText()); + if (!rdaMap.containsValue(rda)) { + rdaMap.put(node.get("numbering").asText(), rda); + } + for (PropertyName propertyName : PropertyName.values()) { + if (rdaProperty.contains(propertyName.getName())) { + switch (propertyName) { + case ACCESS_URL: + rda.setAccessUrl(rdaValue); + break; + case AVAILABLE_UTIL: + rda.setAvailableUntil(rdaValue); + break; + case DOWNLOAD_URL: + rda.setDownloadUrl(URI.create(rdaValue)); + break; + case DESCRIPTION: + rda.setDescription(rdaValue); + break; + case DATA_ACCESS: + rda.setDataAccess(Distribution.DataAccess.fromValue(rdaValue)); + break; + case BYTE_SIZE: + rda.setByteSize(Integer.parseInt(rdaValue)); + break; + case LICENSE: + rda.setLicense(Collections.singletonList(LicenseRDAMapper.toRDA(node))); + break; + case FORMAT: + rda.setFormat(Collections.singletonList(rdaValue)); + break; + case TITLE: + rda.setTitle(rdaValue); + break; + case HOST: + rda.setHost(HostRDAMapper.toRDA(nodes, node.get("numbering").asText())); + break; + } + } + } + } + + return new ArrayList<>(rdaMap.values()); + } + + public static Distribution toRDA(JsonNode node) { Distribution rda = new Distribution(); - String rdaProperty = structure.get("rdaProperty").asText(); + String rdaProperty = node.get("rdaProperty").asText(); + String rdaValue = node.get("value").asText(); if (rdaProperty.contains("access_url")) { - rda.setAccessUrl(properties.get(structure.get("id").asText()).asText()); + rda.setAccessUrl(rdaValue); } else if (rdaProperty.contains("available_util")) { - rda.setAvailableUntil(properties.get(structure.get("id").asText()).asText()); + rda.setAvailableUntil(rdaValue); } else if (rdaProperty.contains("byte_size")) { - rda.setByteSize(properties.get(structure.get("id").asText()).asInt()); + rda.setByteSize(Integer.parseInt(rdaValue)); } else if (rdaProperty.contains("data_access")) { - rda.setDataAccess(Distribution.DataAccess.fromValue(properties.get(structure.get("id").asText()).asText())); + rda.setDataAccess(Distribution.DataAccess.fromValue(rdaValue)); } else if (rdaProperty.contains("description")) { - rda.setDescription(properties.get(structure.get("id").asText()).asText()); + rda.setDescription(rdaValue); } else if (rdaProperty.contains("download_url")) { - rda.setDownloadUrl(URI.create(properties.get(structure.get("id").asText()).asText())); + rda.setDownloadUrl(URI.create(rdaValue)); } else if (rdaProperty.contains("format")) { - rda.setFormat(Collections.singletonList(properties.get(structure.get("id").asText()).asText())); + rda.setFormat(Collections.singletonList(rdaValue)); } else if (rdaProperty.contains("host")) { - rda.setHost(HostRDAMapper.toRDA(structure, properties)); +// rda.setHost(HostRDAMapper.toRDA(node)); } else if (rdaProperty.contains("license")) { - rda.setLicense(Collections.singletonList(LicenseRDAMapper.toRDA(structure, properties))); + rda.setLicense(Collections.singletonList(LicenseRDAMapper.toRDA(node))); } else if (rdaProperty.contains("title")) { - rda.setTitle(properties.get(structure.get("id").asText()).asText()); + rda.setTitle(rdaValue); } return rda; } + + private static Distribution getRelative( Map rdaMap, String numbering) { + return rdaMap.entrySet().stream().filter(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering) > 0) + .max(Comparator.comparingInt(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering))).map(Map.Entry::getValue).orElse(new Distribution()); + } + + private enum PropertyName { + ACCESS_URL("access_url"), + AVAILABLE_UTIL("available_util"), + BYTE_SIZE("byte_size"), + DATA_ACCESS("data_access"), + DESCRIPTION("description"), + DOWNLOAD_URL("download_url"), + FORMAT("format"), + HOST("host"), + LICENSE("license"), + TITLE("title"); + + private final String name; + + PropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java index 9a32cc697..0983f3d3b 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java @@ -1,41 +1,91 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.logic.utilities.helpers.MyStringUtils; import eu.eudat.models.rda.Host; import eu.eudat.models.rda.PidSystem; import java.net.URI; import java.util.Collections; +import java.util.List; public class HostRDAMapper { - public static Host toRDA(JsonNode structure, JsonNode properties) { + public static Host toRDA(List nodes, String numbering) { Host rda = new Host(); - String rdaProperty = structure.get("rdaProperties").asText(); - if (rdaProperty.contains("availability")) { - rda.setAvailability(properties.get(structure.get("id").asText()).asText()); - } else if (rdaProperty.contains("backup_frequency")) { - rda.setBackupFrequency(properties.get(structure.get("id").asText()).asText()); - } else if (rdaProperty.contains("backup_type")) { - rda.setBackupType(properties.get(structure.get("id").asText()).asText()); - } else if (rdaProperty.contains("certified_with")) { - rda.setCertifiedWith(Host.CertifiedWith.fromValue(properties.get(structure.get("id").asText()).asText())); - } else if (rdaProperty.contains("description")) { - rda.setDescription(properties.get(structure.get("id").asText()).asText()); - } else if (rdaProperty.contains("geo_location")) { - rda.setGeoLocation(Host.GeoLocation.fromValue(properties.get(structure.get("id").asText()).asText())); - } else if (rdaProperty.contains("pid_system")) { - rda.setPidSystem(Collections.singletonList(PidSystem.fromValue(properties.get(structure.get("id").asText()).asText()))); - } else if (rdaProperty.contains("storage_type")) { - rda.setStorageType(properties.get(structure.get("id").asText()).asText()); - } else if (rdaProperty.contains("support_versioning")) { - rda.setSupportVersioning(Host.SupportVersioning.fromValue(properties.get(structure.get("id").asText()).asText())); - } else if (rdaProperty.contains("title")) { - rda.setTitle(properties.get(structure.get("id").asText()).asText()); - } else if (rdaProperty.contains("url")) { - rda.setUrl(URI.create(properties.get(structure.get("id").asText()).asText())); + for (JsonNode node: nodes) { + String rdaProperty = node.get("rdaProperties").asText(); + if (rdaProperty.contains("host")) { + int firstDiff = MyStringUtils.getFirstDifference(numbering, node.get("numbering").asText()); + if (firstDiff == -1 || firstDiff > 2) { + String rdaValue = node.get("value").asText(); + for (PropertyName propertyName: PropertyName.values()) { + if (rdaProperty.contains(propertyName.getName())) { + switch (propertyName) { + case AVAILABILITY: + rda.setAvailability(rdaValue); + break; + case BACKUP_FREQUENCY: + rda.setBackupFrequency(rdaValue); + break; + case BACKUP_TYPE: + rda.setBackupType(rdaValue); + break; + case CERTIFIED_WITH: + rda.setCertifiedWith(Host.CertifiedWith.fromValue(rdaValue)); + break; + case DESCRIPTION: + rda.setDescription(rdaValue); + break; + case GEO_LOCATION: + rda.setGeoLocation(Host.GeoLocation.fromValue(rdaValue)); + break; + case PID_SYSTEM: + rda.setPidSystem(Collections.singletonList(PidSystem.fromValue(rdaValue))); + break; + case STORAGE_TYPE: + rda.setStorageType(rdaValue); + break; + case SUPPORT_VERSIONING: + rda.setSupportVersioning(Host.SupportVersioning.fromValue(rdaValue)); + break; + case TITLE: + rda.setTitle(rdaValue); + break; + case URL: + rda.setUrl(URI.create(rdaValue)); + break; + } + } + } + } + } } return rda; } + + private enum PropertyName { + AVAILABILITY("availability"), + BACKUP_FREQUENCY("backup_frequency"), + BACKUP_TYPE("backup_type"), + CERTIFIED_WITH("certified_with"), + DESCRIPTION("description"), + GEO_LOCATION("geo_location"), + PID_SYSTEM("pid_system"), + STORAGE_TYPE("storage_type"), + SUPPORT_VERSIONING("support_versioning"), + TITLE("title"), + URL("url"); + + private final String name; + + PropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java index 68817bd3d..6f94a73c4 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java @@ -7,10 +7,10 @@ import java.net.URI; public class LicenseRDAMapper { - public static License toRDA(JsonNode structure, JsonNode properties) { + public static License toRDA(JsonNode node) { License rda = new License(); - String rdaProperty = structure.get("rdaProperty").asText(); - String value = properties.get(structure.get("id").asText()).asText(); + String rdaProperty = node.get("rdaProperty").asText(); + String value = node.get("value").asText(); if (rdaProperty.contains("license_ref")) { rda.setLicenseRef(URI.create(value)); diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java index fa638d3e3..c7e3ba35f 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java @@ -2,43 +2,124 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.TextNode; +import eu.eudat.logic.utilities.helpers.MyStringUtils; import eu.eudat.models.rda.Metadatum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.IOException; -import java.util.Iterator; +import java.util.*; public class MetadataRDAMapper { private static final Logger logger = LoggerFactory.getLogger(MetadataRDAMapper.class); - public static Metadatum toRDA(JsonNode structure, JsonNode properties) { - Metadatum rda = new Metadatum(); - JsonNode dataNode = null; - String rdaProperty = structure.get("rdaProperty").asText(); - if (rdaProperty.contains("metadata_standard_id")) { - try { - String jsonText = properties.get(structure.get("id").asText()).asText(); - if (jsonText != null && !jsonText.isEmpty()) { - dataNode = new ObjectMapper().readTree(jsonText); - for (Iterator it = dataNode.elements(); it.hasNext(); ) { - JsonNode data = it.next(); - if (data.get("uri") != null) { - rda.setMetadataStandardId(MetadataStandardIdRDAMapper.toRDA(data.get("uri").asText())); - } + public static List toRDAList(List nodes) { + Map rdaMap = new HashMap<>(); + List rdas = new ArrayList<>(); + for (JsonNode node: nodes) { + String rdaProperty = node.get("rdaProperty").asText(); + JsonNode rdaValue = node.get("value"); + + for (PropertyName propertyName: PropertyName.values()) { + if (rdaProperty.contains(propertyName.getName())) { + switch (propertyName) { + case METADATA_STANDARD_ID: + if (rdaValue instanceof ArrayNode) { + try { + ObjectMapper mapper = new ObjectMapper(); + for (Iterator it = rdaValue.elements(); it.hasNext(); ) { + JsonNode data = null; + data = mapper.readTree(it.next().asText()); + if (data.get("uri") != null) { + rdas.add(new Metadatum()); + rdas.get(rdas.size() - 1).setMetadataStandardId(MetadataStandardIdRDAMapper.toRDA(data.get("uri").asText())); + rdas.get(rdas.size() - 1).setDescription(data.get("label").asText()); + rdaMap.put(data.get("uri").asText(), node.get("numbering").asText()); + } + } + } catch (IOException e) { + logger.error(e.getMessage(), e); + } + } else if (rdaValue instanceof TextNode && rdaProperty.contains("identifier") && !rdaValue.asText().isEmpty()) { + rdas.add(new Metadatum()); + rdas.get(rdas.size() - 1).setMetadataStandardId(MetadataStandardIdRDAMapper.toRDA(rdaValue.asText())); + rdaMap.put(rdaValue.asText(), node.get("numbering").asText()); + } + break; + case DESCRIPTION: + if (!rdaValue.asText().isEmpty()) { + Metadatum rda = getRelative(rdas, rdaMap, node.get("numbering").asText()); + if (rda != null) { + rda.setDescription(rdaValue.asText()); + } else { + rdas.stream().filter(rda1 -> rda1.getDescription() == null || rda1.getDescription().isEmpty()).forEach(rda1 -> rda1.setDescription(rdaValue.asText())); + } + } + break; + case LANGUAGE: + String language = rdaValue.asText(); + Metadatum.Language lang = Metadatum.Language.fromValue(language); + Metadatum rda = getRelative(rdas, rdaMap, node.get("numbering").asText()); + if (rda != null) { + rda.setLanguage(lang); + } else { + rdas.forEach(rda1 -> rda1.setLanguage(lang)); + } + break; + } + } + } + + } + + return rdas; + } + + public static Metadatum toRDA(JsonNode node) { + Metadatum rda = new Metadatum(); + String rdaProperty = node.get("rdaProperty").asText(); + JsonNode rdaValue = node.get("value"); + if (rdaProperty.contains("metadata_standard_id")) { + if (rdaValue instanceof ArrayNode) { + for (Iterator it = rdaValue.elements(); it.hasNext(); ) { + JsonNode data = it.next(); + if (data.get("uri") != null) { + rda.setMetadataStandardId(MetadataStandardIdRDAMapper.toRDA(data.get("uri").asText())); } } - } catch (IOException e) { - logger.error(e.getMessage(), e); } } else if (rdaProperty.contains("description")) { - rda.setDescription(properties.get(structure.get("id").asText()).asText()); + rda.setDescription(rdaValue.asText()); } else if (rdaProperty.contains("language")) { - String language = properties.get(structure.get("id").asText()).asText(); + String language = rdaValue.asText(); Metadatum.Language lang = Metadatum.Language.fromValue(language); rda.setLanguage(lang); } return rda; } + + private static Metadatum getRelative(List rdas, Map rdaMap, String numbering) { + String target = rdaMap.entrySet().stream().filter(entry -> MyStringUtils.getFirstDifference(entry.getValue(), numbering) > 0) + .max(Comparator.comparingInt(entry -> MyStringUtils.getFirstDifference(entry.getValue(), numbering))).map(Map.Entry::getKey).orElse(""); + return rdas.stream().filter(rda -> rda.getMetadataStandardId().getIdentifier().equals(target)).distinct().findFirst().orElse(null); + } + + private enum PropertyName { + METADATA_STANDARD_ID("metadata_standard_id"), + DESCRIPTION("description"), + LANGUAGE("language"); + + private final String name; + + PropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java index f7f95633f..fc44cc182 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java @@ -1,14 +1,45 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.logic.utilities.helpers.MyStringUtils; import eu.eudat.models.rda.SecurityAndPrivacy; +import java.util.*; + public class SecurityAndPrivacyRDAMapper { - public static SecurityAndPrivacy toRDA(JsonNode structure, JsonNode properties) { + public static List toRDAList(List nodes) { + Map rdaMap = new HashMap<>(); + + for (JsonNode node: nodes) { + String rdaProperty = node.get("rdaProperty").asText(); + String rdaValue = node.get("value").asText(); + + SecurityAndPrivacy rda = getRelative(rdaMap, node.get("numbering").asText()); + if (!rdaMap.containsValue(rda)) { + rdaMap.put(node.get("numbering").asText(), rda); + } + for (PropertyName propertyName: PropertyName.values()) { + if (rdaProperty.contains(propertyName.getName())) { + switch (propertyName) { + case TITLE: + rda.setTitle(rdaValue); + break; + case DESCRIPTION: + rda.setDescription(rdaValue); + break; + } + } + } + } + + return new ArrayList<>(rdaMap.values()); + } + + public static SecurityAndPrivacy toRDA(JsonNode node) { SecurityAndPrivacy rda = new SecurityAndPrivacy(); - String rdaProperty = structure.get("rdaProperty").asText(); - String value = properties.get(structure.get("id").asText()).asText(); + String rdaProperty = node.get("rdaProperty").asText(); + String value =node.get("value").asText(); if (rdaProperty.contains("description")) { rda.setDescription(value); @@ -18,4 +49,24 @@ public class SecurityAndPrivacyRDAMapper { return rda; } + + private static SecurityAndPrivacy getRelative(Map rdaMap, String numbering) { + return rdaMap.entrySet().stream().filter(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering) > 0) + .max(Comparator.comparingInt(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering))).map(Map.Entry::getValue).orElse(new SecurityAndPrivacy()); + } + + private enum PropertyName { + TITLE("title"), + DESCRIPTION("description"); + + private String name; + + PropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java index b2652901a..c48f93cae 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java @@ -1,14 +1,46 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.logic.utilities.helpers.MyStringUtils; +import eu.eudat.models.rda.SecurityAndPrivacy; import eu.eudat.models.rda.TechnicalResource; +import java.util.*; + public class TechnicalResourceRDAMapper { - public static TechnicalResource toRDA(JsonNode structure, JsonNode properties) { + public static List toRDAList(List nodes) { + Map rdaMap = new HashMap<>(); + + for (JsonNode node: nodes) { + String rdaProperty = node.get("rdaProperty").asText(); + String rdaValue = node.get("value").asText(); + + TechnicalResource rda = getRelative(rdaMap, node.get("numbering").asText()); + if (!rdaMap.containsValue(rda)) { + rdaMap.put(node.get("numbering").asText(), rda); + } + for (PropertyName propertyName: PropertyName.values()) { + if (rdaProperty.contains(propertyName.getName())) { + switch (propertyName) { + case NAME: + rda.setName(rdaValue); + break; + case DESCRIPTION: + rda.setDescription(rdaValue); + break; + } + } + } + } + + return new ArrayList<>(rdaMap.values()); + } + + public static TechnicalResource toRDA(JsonNode node) { TechnicalResource rda = new TechnicalResource(); - String rdaProperty = structure.get("rdaProperty").asText(); - String value = properties.get(structure.get("id").asText()).asText(); + String rdaProperty = node.get("rdaProperty").asText(); + String value = node.get("value").asText(); if (rdaProperty.contains("description")) { rda.setDescription(value); @@ -18,4 +50,24 @@ public class TechnicalResourceRDAMapper { return rda; } + + private static TechnicalResource getRelative(Map rdaMap, String numbering) { + return rdaMap.entrySet().stream().filter(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering) > 0) + .max(Comparator.comparingInt(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering))).map(Map.Entry::getValue).orElse(new TechnicalResource()); + } + + private enum PropertyName { + NAME("name"), + DESCRIPTION("description"); + + private String name; + + PropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + } } diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description-form.model.ts b/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description-form.model.ts index c4b8153b8..fd8824ba3 100644 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description-form.model.ts +++ b/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description-form.model.ts @@ -338,4 +338,4 @@ export class DatasetDescriptionDefaultValueEditorModel extends BaseFormModel { }); return formGroup; } -} \ No newline at end of file +} From 41d0b10725dbb9c2d76be726f50f813507249bc5 Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Tue, 24 Mar 2020 11:26:17 +0200 Subject: [PATCH 17/20] Minor bug fixes on the exporter --- .../src/main/java/eu/eudat/logic/managers/RDAManager.java | 2 +- .../java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java index eb10fd753..3a9f2f7a8 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java @@ -29,7 +29,7 @@ public class RDAManager { Dmp rdaDmp = dmpRDAMapper.toRDA(dmp); ObjectMapper mapper = new ObjectMapper(); - mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")); + mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss Z")); result = mapper.writeValueAsString(rdaDmp); diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java index 5eb9cc685..da04fe043 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java @@ -32,6 +32,7 @@ public class DatasetRDAMapper { rda.setDatasetId(DatasetIdRDAMapper.toRDA(dataset.getId())); rda.setTitle(dataset.getLabel()); rda.setDescription(dataset.getDescription()); +// rda.setAdditionalProperty("template", dataset.getProfile().getId()); try { DatasetWizardModel datasetWizardModel = new DatasetWizardModel().fromDataModel(dataset); @@ -57,7 +58,7 @@ public class DatasetRDAMapper { } List preservationNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.preservation_statement"); if (!preservationNodes.isEmpty()) { - rda.setDataQualityAssurance(preservationNodes.stream().map(preservationNode -> preservationNode.get("value").asText()).collect(Collectors.toList())); + rda.setPreservationStatement(preservationNodes.get(0).get("value").asText()); } List distributionNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.distribution"); if (!distributionNodes.isEmpty()) { @@ -77,7 +78,7 @@ public class DatasetRDAMapper { } List sensitiveDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.sensitive_data"); if (!sensitiveDataNodes.isEmpty()) { - rda.setSensitiveData(securityAndPrivacyNodes.stream().map(sensitiveDataNode -> Dataset.SensitiveData.fromValue(sensitiveDataNode.get("value").asText())).findFirst().get()); + rda.setSensitiveData(sensitiveDataNodes.stream().map(sensitiveDataNode -> Dataset.SensitiveData.fromValue(sensitiveDataNode.get("value").asText())).findFirst().get()); } List technicalResourceNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.technical_resource"); if (!technicalResourceNodes.isEmpty()) { From c80e8bb4ba801df831fafc4cda15a6a79c5843d1 Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Thu, 26 Mar 2020 18:39:25 +0200 Subject: [PATCH 18/20] Add RDA Import --- .../main/java/eu/eudat/controllers/DMPs.java | 11 +- .../managers/DataManagementPlanManager.java | 35 ++++++ .../eu/eudat/logic/managers/RDAManager.java | 9 ++ .../java/eu/eudat/models/rda/Dataset.java | 9 +- .../eu/eudat/models/rda/Distribution.java | 9 +- .../main/java/eu/eudat/models/rda/Dmp.java | 9 +- .../java/eu/eudat/models/rda/Metadatum.java | 9 +- .../eudat/models/rda/SecurityAndPrivacy.java | 9 +- .../eudat/models/rda/TechnicalResource.java | 9 +- .../models/rda/mapper/ContactIdRDAMapper.java | 4 + .../models/rda/mapper/ContactRDAMapper.java | 8 ++ .../models/rda/mapper/DatasetRDAMapper.java | 112 +++++++++++++++++- .../rda/mapper/DistributionRDAMapper.java | 97 ++++++++++++++- .../eudat/models/rda/mapper/DmpRDAMapper.java | 36 ++++-- .../models/rda/mapper/FundingRDAMapper.java | 9 +- .../models/rda/mapper/MetadataRDAMapper.java | 66 +++++++++++ .../models/rda/mapper/ProjectRDAMapper.java | 22 +++- .../mapper/SecurityAndPrivacyRDAMapper.java | 60 +++++++++- .../mapper/TechnicalResourceRDAMapper.java | 62 +++++++++- .../dmp-upload-dialogue.component.html | 2 +- 20 files changed, 531 insertions(+), 56 deletions(-) diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java index c87ce4590..0e25b98f6 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java @@ -53,6 +53,9 @@ import java.util.List; import java.util.Map; import java.util.UUID; +import static org.springframework.http.MediaType.APPLICATION_ATOM_XML; +import static org.springframework.http.MediaType.APPLICATION_JSON; + @RestController @CrossOrigin @@ -224,8 +227,12 @@ public class DMPs extends BaseController { } @RequestMapping(method = RequestMethod.POST, value = {"/upload"}) - public ResponseEntity dmpXmlUpload(@RequestParam("file") MultipartFile[] files, Principal principal) throws Exception { - this.dataManagementPlanManager.createDmpFromXml(this.getApiContext(), files, principal); + public ResponseEntity dmpUpload(@RequestParam("file") MultipartFile[] files, Principal principal) throws Exception { + if (files[0].getContentType().equals(APPLICATION_JSON.toString())) { + this.dataManagementPlanManager.createFromRDA(files, principal); + } else if (files[0].getContentType().equals(APPLICATION_ATOM_XML.toString())) { + this.dataManagementPlanManager.createDmpFromXml(this.getApiContext(), files, principal); + } return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem() .status(ApiMessageCode.SUCCESS_MESSAGE)); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java index 2710ec60c..c8dee4802 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java @@ -131,6 +131,13 @@ public class DataManagementPlanManager { if (fieldsGroup.equals("listing")) { itemsFuture = pagedItems.withHint(HintedModelFactory.getHint(DataManagementPlanListingModel.class)) .selectAsync(item -> { + if (item.getUsers().stream().noneMatch(userDMP -> userDMP.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue()))) { + for (UserDMP userDMP: item.getUsers()) { + userDMP.setRole(UserDMP.UserDMPRoles.OWNER.getValue()); + databaseRepository.getUserDmpDao().createOrUpdate(userDMP); + break; + } + } item.setDataset( item.getDataset().stream() .filter(dataset -> !dataset.getStatus().equals(Dataset.Status.DELETED.getValue()) && !dataset.getStatus().equals(Dataset.Status.CANCELED.getValue())).collect(Collectors.toList()).stream() @@ -1329,6 +1336,34 @@ public class DataManagementPlanManager { return dataManagementPlans; } + public List createFromRDA(MultipartFile[] files, Principal principal) throws IOException { + if (principal.getId() == null) { + throw new UnauthorisedException("No user is logged in"); + } + List result = new ArrayList<>(); + for (MultipartFile file: files) { + DMP dmp = rdaManager.convertToEntity(new String(file.getBytes(), "UTF-8")); + UserInfo me = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId()); + dmp.setModified(new Date()); + dmp.setCreator(me); + dmp.setVersion(0); + dmp.setStatus((short)0); + dmp.setGroupId(UUID.randomUUID()); + databaseRepository.getDmpDao().createOrUpdate(dmp); + assignUser(dmp, me); + dmp.getDataset().forEach(dataset -> { + dataset.setStatus(Dataset.Status.SAVED.getValue()); + dataset.setCreated(new Date()); + dataset.setModified(new Date()); + dataset.setDmp(dmp); + databaseRepository.getDatasetDao().createOrUpdate(dataset); + }); + result.add(dmp); + } + + return result; + } + public DataTableData getDatasetProfilesUsedByDMP(DatasetProfileTableRequestItem datasetProfileTableRequestItem, Principal principal) { datasetProfileTableRequestItem.getCriteria().setFilter(DatasetProfileCriteria.DatasetProfileFilter.DMPs.getValue()); datasetProfileTableRequestItem.getCriteria().setUserId(principal.getId()); diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java index 3a9f2f7a8..ff194455e 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java @@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import javax.transaction.Transactional; +import java.io.IOException; import java.text.SimpleDateFormat; @Component @@ -35,4 +36,12 @@ public class RDAManager { return result; } + + public DMP convertToEntity(String json) throws IOException { + ObjectMapper mapper = new ObjectMapper(); + mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss Z")); + + Dmp rda = mapper.readValue(json, Dmp.class); + return dmpRDAMapper.toEntity(rda); + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java index 43a7ac0cd..3c064965e 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java @@ -38,7 +38,8 @@ import com.fasterxml.jackson.annotation.JsonValue; "sensitive_data", "technical_resource", "title", - "type" + "type", + "additional_properties" }) public class Dataset implements Serializable { @@ -182,7 +183,7 @@ public class Dataset implements Serializable @JsonProperty("type") @JsonPropertyDescription("If appropriate, type according to: DataCite and/or COAR dictionary. Otherwise use the common name for the type, e.g. raw data, software, survey, etc. https://schema.datacite.org/meta/kernel-4.1/doc/DataCite-MetadataKernel_v4.1.pdf http://vocabularies.coar-repositories.org/pubby/resource_type.html") private String type; - @JsonIgnore + @JsonProperty("additional_properties") private Map additionalProperties = new HashMap(); private final static long serialVersionUID = -6931119120629009399L; @@ -524,12 +525,12 @@ public class Dataset implements Serializable this.type = type; } - @JsonAnyGetter + @JsonProperty("additional_properties") public Map getAdditionalProperties() { return this.additionalProperties; } - @JsonAnySetter + @JsonProperty("additional_properties") public void setAdditionalProperty(String name, Object value) { this.additionalProperties.put(name, value); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java index d005e7564..176931e9e 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java @@ -34,7 +34,8 @@ import com.fasterxml.jackson.annotation.JsonValue; "format", "host", "license", - "title" + "title", + "additional_properties" }) public class Distribution implements Serializable { @@ -131,7 +132,7 @@ public class Distribution implements Serializable @JsonProperty("title") @JsonPropertyDescription("Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file.") private String title; - @JsonIgnore + @JsonProperty("additional_properties") private Map additionalProperties = new HashMap(); private final static long serialVersionUID = -6018365280419917902L; @@ -359,12 +360,12 @@ public class Distribution implements Serializable this.title = title; } - @JsonAnyGetter + @JsonProperty("additional_properties") public Map getAdditionalProperties() { return this.additionalProperties; } - @JsonAnySetter + @JsonProperty("additional_properties") public void setAdditionalProperty(String name, Object value) { this.additionalProperties.put(name, value); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java index 7cac25d62..b53d26147 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java @@ -39,7 +39,8 @@ import com.fasterxml.jackson.annotation.JsonValue; "language", "modified", "project", - "title" + "title", + "additional_properties" }) public class Dmp implements Serializable { @@ -173,7 +174,7 @@ public class Dmp implements Serializable @JsonProperty("title") @JsonPropertyDescription("Title of a DMP") private String title; - @JsonIgnore + @JsonProperty("additional_properties") private Map additionalProperties = new HashMap(); private final static long serialVersionUID = 4599713332472772292L; @@ -499,12 +500,12 @@ public class Dmp implements Serializable this.title = title; } - @JsonAnyGetter + @JsonProperty("additional_properties") public Map getAdditionalProperties() { return this.additionalProperties; } - @JsonAnySetter + @JsonProperty("additional_properties") public void setAdditionalProperty(String name, Object value) { this.additionalProperties.put(name, value); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java index d6057ca62..56bee437d 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java @@ -25,7 +25,8 @@ import com.fasterxml.jackson.annotation.JsonValue; @JsonPropertyOrder({ "description", "language", - "metadata_standard_id" + "metadata_standard_id", + "additional_properties" }) public class Metadatum implements Serializable { @@ -58,7 +59,7 @@ public class Metadatum implements Serializable */ @JsonProperty("metadata_standard_id") private MetadataStandardId metadataStandardId; - @JsonIgnore + @JsonProperty("additional_properties") private Map additionalProperties = new HashMap(); private final static long serialVersionUID = 6511312853153406190L; @@ -132,12 +133,12 @@ public class Metadatum implements Serializable this.metadataStandardId = metadataStandardId; } - @JsonAnyGetter + @JsonProperty("additional_properties") public Map getAdditionalProperties() { return this.additionalProperties; } - @JsonAnySetter + @JsonProperty("additional_properties") public void setAdditionalProperty(String name, Object value) { this.additionalProperties.put(name, value); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java index 0486df588..245d202d0 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java @@ -22,7 +22,8 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonPropertyOrder({ "description", - "title" + "title", + "additional_properties" }) public class SecurityAndPrivacy implements Serializable { @@ -46,7 +47,7 @@ public class SecurityAndPrivacy implements Serializable @JsonProperty("title") @JsonPropertyDescription("Title") private String title; - @JsonIgnore + @JsonProperty("additional_properties") private Map additionalProperties = new HashMap(); private final static long serialVersionUID = 7863747935827682977L; @@ -96,12 +97,12 @@ public class SecurityAndPrivacy implements Serializable this.title = title; } - @JsonAnyGetter + @JsonProperty("additional_properties") public Map getAdditionalProperties() { return this.additionalProperties; } - @JsonAnySetter + @JsonProperty("additional_properties") public void setAdditionalProperty(String name, Object value) { this.additionalProperties.put(name, value); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java index eac85da72..c7bd2b055 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java @@ -22,7 +22,8 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonPropertyOrder({ "description", - "name" + "name", + "additional_properties" }) public class TechnicalResource implements Serializable { @@ -46,7 +47,7 @@ public class TechnicalResource implements Serializable @JsonProperty("name") @JsonPropertyDescription("Name of the technical resource") private String name; - @JsonIgnore + @JsonProperty("additional_properties") private Map additionalProperties = new HashMap(); private final static long serialVersionUID = -7451757227129483110L; @@ -96,12 +97,12 @@ public class TechnicalResource implements Serializable this.name = name; } - @JsonAnyGetter + @JsonProperty("additional_properties") public Map getAdditionalProperties() { return this.additionalProperties; } - @JsonAnySetter + @JsonProperty("additional_properties") public void setAdditionalProperty(String name, Object value) { this.additionalProperties.put(name, value); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java index 48549d75a..c9eac2009 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java @@ -12,4 +12,8 @@ public class ContactIdRDAMapper { rda.setType(ContactId.Type.OTHER); return rda; } + + public static UUID toEntity(ContactId rda) { + return UUID.fromString(rda.getIdentifier()); + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java index 69ea2310e..957fef8d4 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java @@ -13,4 +13,12 @@ public class ContactRDAMapper { rda.setContactId(ContactIdRDAMapper.toRDA(creator.getId())); return rda; } + + public static UserInfo toEntity(Contact rda) { + UserInfo entity = new UserInfo(); + entity.setId(ContactIdRDAMapper.toEntity(rda.getContactId())); + entity.setName(rda.getName()); + entity.setEmail(rda.getMbox()); + return entity; + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java index da04fe043..90aa4ec7c 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java @@ -2,28 +2,34 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import eu.eudat.data.entities.DatasetProfile; import eu.eudat.logic.managers.DatasetManager; +import eu.eudat.logic.services.ApiContext; import eu.eudat.logic.utilities.json.JsonSearcher; import eu.eudat.models.data.datasetwizard.DatasetWizardModel; import eu.eudat.models.rda.Dataset; +import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import javax.transaction.Transactional; -import java.util.List; +import java.util.*; import java.util.stream.Collectors; +import java.util.stream.Stream; @Component public class DatasetRDAMapper { private static final Logger logger = LoggerFactory.getLogger(DatasetRDAMapper.class); private DatasetManager datasetManager; + private ApiContext apiContext; @Autowired - public DatasetRDAMapper(DatasetManager datasetManager) { + public DatasetRDAMapper(DatasetManager datasetManager, ApiContext apiContext) { this.datasetManager = datasetManager; + this.apiContext = apiContext; } @Transactional @@ -32,9 +38,10 @@ public class DatasetRDAMapper { rda.setDatasetId(DatasetIdRDAMapper.toRDA(dataset.getId())); rda.setTitle(dataset.getLabel()); rda.setDescription(dataset.getDescription()); -// rda.setAdditionalProperty("template", dataset.getProfile().getId()); + rda.setAdditionalProperty("template", dataset.getProfile().getId()); try { - + JSONObject jObject = new JSONObject(dataset.getProperties()); + Map templateIdsToValues = jObject.toMap(); DatasetWizardModel datasetWizardModel = new DatasetWizardModel().fromDataModel(dataset); datasetWizardModel.setDatasetProfileDefinition(datasetManager.getPagedProfile(datasetWizardModel, dataset)); ObjectMapper mapper = new ObjectMapper(); @@ -55,6 +62,9 @@ public class DatasetRDAMapper { List qaNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.data_quality_assurance"); if (!qaNodes.isEmpty()) { rda.setDataQualityAssurance(qaNodes.stream().map(qaNode -> qaNode.get("value").asText()).collect(Collectors.toList())); + for (int i = 0; i < qaNodes.size(); i++) { + rda.setAdditionalProperty("qa" + (i + 1), qaNodes.get(i).get("id").asText()); + } } List preservationNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.preservation_statement"); if (!preservationNodes.isEmpty()) { @@ -67,6 +77,9 @@ public class DatasetRDAMapper { List keywordNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.keyword"); if (!keywordNodes.isEmpty()) { rda.setKeyword(keywordNodes.stream().map(keywordNode -> keywordNode.get("value").asText()).collect(Collectors.toList())); + for (int i = 0; i < keywordNodes.size(); i++) { + rda.setAdditionalProperty("keyword" + (i + 1), keywordNodes.get(i).get("id").asText()); + } } List personalDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.personal_data"); if (!personalDataNodes.isEmpty()) { @@ -84,6 +97,14 @@ public class DatasetRDAMapper { if (!technicalResourceNodes.isEmpty()) { rda.setTechnicalResource(TechnicalResourceRDAMapper.toRDAList(technicalResourceNodes)); } + List foundNodes = Stream.of(typeNodes, languageNodes, metadataNodes, qaNodes, preservationNodes, distributionNodes, + keywordNodes, personalDataNodes, securityAndPrivacyNodes, sensitiveDataNodes, technicalResourceNodes).flatMap(Collection::stream).collect(Collectors.toList()); + templateIdsToValues.entrySet().forEach(entry -> { + boolean isFound = foundNodes.stream().anyMatch(node -> node.get("id").asText().equals(entry.getKey())); + if (!isFound && entry.getValue() != null && !entry.getValue().toString().isEmpty()) { + rda.setAdditionalProperty(entry.getKey(), entry.getValue()); + } + }); } catch (Exception e) { @@ -93,4 +114,87 @@ public class DatasetRDAMapper { return rda; } + + + public eu.eudat.data.entities.Dataset toEntity(Dataset rda) { + eu.eudat.data.entities.Dataset entity = new eu.eudat.data.entities.Dataset(); + entity.setLabel(rda.getTitle()); + entity.setDescription(rda.getDescription()); + try { + DatasetProfile profile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(rda.getAdditionalProperties().get("template").toString())); + entity.setProfile(profile); + }catch(Exception e) { + logger.warn(e.getMessage(), e); + } + try { + Map properties = new HashMap<>(); + DatasetWizardModel datasetWizardModel = new DatasetWizardModel(); + datasetWizardModel.setProfile(entity.getProfile().getId()); + datasetWizardModel.setDatasetProfileDefinition(datasetManager.getPagedProfile(datasetWizardModel, entity)); + ObjectMapper mapper = new ObjectMapper(); + String datasetDescriptionJson = mapper.writeValueAsString(datasetWizardModel.getDatasetProfileDefinition()); + JsonNode datasetDescriptionObj = mapper.readTree(datasetDescriptionJson); + + List typeNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.type"); + if (!typeNodes.isEmpty()) { + properties.put(typeNodes.get(0).get("id").asText(), rda.getType()); + } + + List languageNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.language"); + if (!languageNodes.isEmpty()) { + properties.put(languageNodes.get(0).get("id").asText(), rda.getLanguage().value()); + } + + if (rda.getMetadata() != null) { + properties.putAll(MetadataRDAMapper.toProperties(rda.getMetadata())); + } + + List qaIds = rda.getAdditionalProperties().entrySet().stream().filter(entry -> entry.getKey().startsWith("qa")).map(entry -> entry.getValue().toString()).collect(Collectors.toList()); + for (int i = 0; i < qaIds.size(); i++) { + properties.put(qaIds.get(i), rda.getDataQualityAssurance().get(i)); + } + + List preservationNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.preservation_statement"); + if (!preservationNodes.isEmpty()) { + properties.put(preservationNodes.get(0).get("id").asText(), rda.getPreservationStatement()); + } + + if (rda.getDistribution() != null) { + properties.putAll(DistributionRDAMapper.toProperties(rda.getDistribution())); + } + + List keywordIds = rda.getAdditionalProperties().entrySet().stream().filter(entry -> entry.getKey().startsWith("keyword")).map(entry -> entry.getValue().toString()).collect(Collectors.toList()); + for (int i = 0; i < keywordIds.size(); i++) { + properties.put(keywordIds.get(i), rda.getKeyword().get(i)); + } + + List personalDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.personal_data"); + if (!personalDataNodes.isEmpty()) { + properties.put(personalDataNodes.get(0).get("id").asText(), rda.getPersonalData().value()); + } + + if (rda.getSecurityAndPrivacy() != null) { + properties.putAll(SecurityAndPrivacyRDAMapper.toProperties(rda.getSecurityAndPrivacy())); + } + + List sensitiveDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.sensitive_data"); + if (!sensitiveDataNodes.isEmpty()) { + properties.put(sensitiveDataNodes.get(0).get("id").asText(), rda.getSensitiveData().value()); + } + + if (rda.getTechnicalResource() != null) { + properties.putAll(TechnicalResourceRDAMapper.toProperties(rda.getTechnicalResource())); + } + + rda.getAdditionalProperties().entrySet().stream() + .filter(entry -> !entry.getKey().equals("template") && !entry.getKey().startsWith("qa") && !entry.getKey().startsWith("keyword")) + .forEach(entry -> properties.put(entry.getKey(), entry.getValue())); + entity.setProperties(new ObjectMapper().writeValueAsString(properties)); + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + + + return entity; + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java index 98cb6960b..566288452 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java @@ -1,13 +1,17 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; +import com.lowagie.text.ExceptionConverter; import eu.eudat.logic.utilities.helpers.MyStringUtils; import eu.eudat.models.rda.Distribution; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.net.URI; import java.util.*; public class DistributionRDAMapper { + private static final Logger logger = LoggerFactory.getLogger(DistributionRDAMapper.class); public static List toRDAList(List nodes) { Map rdaMap = new HashMap<>(); @@ -19,35 +23,43 @@ public class DistributionRDAMapper { if (!rdaMap.containsValue(rda)) { rdaMap.put(node.get("numbering").asText(), rda); } - for (PropertyName propertyName : PropertyName.values()) { - if (rdaProperty.contains(propertyName.getName())) { - switch (propertyName) { + for (ExportPropertyName exportPropertyName : ExportPropertyName.values()) { + if (rdaProperty.contains(exportPropertyName.getName())) { + switch (exportPropertyName) { case ACCESS_URL: rda.setAccessUrl(rdaValue); + rda.setAdditionalProperty(ImportPropertyName.ACCESS_URL.getName(), node.get("id").asText()); break; case AVAILABLE_UTIL: rda.setAvailableUntil(rdaValue); + rda.setAdditionalProperty(ImportPropertyName.AVAILABLE_UTIL.getName(), node.get("id").asText()); break; case DOWNLOAD_URL: rda.setDownloadUrl(URI.create(rdaValue)); + rda.setAdditionalProperty(ImportPropertyName.DOWNLOAD_URL.getName(), node.get("id").asText()); break; case DESCRIPTION: rda.setDescription(rdaValue); + rda.setAdditionalProperty(ImportPropertyName.DESCRIPTION.getName(), node.get("id").asText()); break; case DATA_ACCESS: rda.setDataAccess(Distribution.DataAccess.fromValue(rdaValue)); + rda.setAdditionalProperty(ImportPropertyName.DATA_ACCESS.getName(), node.get("id").asText()); break; case BYTE_SIZE: rda.setByteSize(Integer.parseInt(rdaValue)); + rda.setAdditionalProperty(ImportPropertyName.BYTE_SIZE.getName(), node.get("id").asText()); break; case LICENSE: rda.setLicense(Collections.singletonList(LicenseRDAMapper.toRDA(node))); break; case FORMAT: rda.setFormat(Collections.singletonList(rdaValue)); + rda.setAdditionalProperty(ImportPropertyName.FORMAT.getName(), node.get("id").asText()); break; case TITLE: rda.setTitle(rdaValue); + rda.setAdditionalProperty(ImportPropertyName.TITLE.getName(), node.get("id").asText()); break; case HOST: rda.setHost(HostRDAMapper.toRDA(nodes, node.get("numbering").asText())); @@ -60,6 +72,49 @@ public class DistributionRDAMapper { return new ArrayList<>(rdaMap.values()); } + public static Map toProperties(List rdas) { + Map properties = new HashMap<>(); + + rdas.forEach(rda -> { + rda.getAdditionalProperties().entrySet().forEach(entry -> { + try { + ImportPropertyName importPropertyName = ImportPropertyName.fromString(entry.getKey()); + switch (importPropertyName) { + case ACCESS_URL: + properties.put(entry.getValue().toString(), rda.getAccessUrl()); + break; + case TITLE: + properties.put(entry.getValue().toString(), rda.getTitle()); + break; + case DESCRIPTION: + properties.put(entry.getValue().toString(), rda.getDescription()); + break; + case FORMAT: + properties.put(entry.getValue().toString(), rda.getFormat().get(0)); + break; + case BYTE_SIZE: + properties.put(entry.getValue().toString(), rda.getByteSize().toString()); + break; + case DATA_ACCESS: + properties.put(entry.getValue().toString(), rda.getDataAccess().value()); + break; + case DOWNLOAD_URL: + properties.put(entry.getValue().toString(), rda.getDownloadUrl().toString()); + break; + case AVAILABLE_UTIL: + properties.put(entry.getValue().toString(), rda.getAvailableUntil()); + break; + } + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + + }); + }); + + return properties; + } + public static Distribution toRDA(JsonNode node) { Distribution rda = new Distribution(); String rdaProperty = node.get("rdaProperty").asText(); @@ -95,7 +150,7 @@ public class DistributionRDAMapper { .max(Comparator.comparingInt(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering))).map(Map.Entry::getValue).orElse(new Distribution()); } - private enum PropertyName { + private enum ExportPropertyName { ACCESS_URL("access_url"), AVAILABLE_UTIL("available_util"), BYTE_SIZE("byte_size"), @@ -109,7 +164,7 @@ public class DistributionRDAMapper { private final String name; - PropertyName(String name) { + ExportPropertyName(String name) { this.name = name; } @@ -117,4 +172,36 @@ public class DistributionRDAMapper { return name; } } + + private enum ImportPropertyName { + ACCESS_URL("accessurlId"), + AVAILABLE_UTIL("availableUtilId"), + BYTE_SIZE("byteSizeId"), + DATA_ACCESS("dataAccessId"), + DESCRIPTION("descriptionId"), + DOWNLOAD_URL("downloadUrlId"), + FORMAT("formatId"), + /*HOST("host"), + LICENSE("license"),*/ + TITLE("titleId"); + + private final String name; + + ImportPropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public static ImportPropertyName fromString(String name) throws Exception { + for (ImportPropertyName importPropertyName: ImportPropertyName.values()) { + if (importPropertyName.getName().equals(name)) { + return importPropertyName; + } + } + throw new Exception("No name available"); + } + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java index 620229a27..7176f3b8d 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java @@ -1,24 +1,26 @@ package eu.eudat.models.rda.mapper; -import eu.eudat.data.entities.DMP; -import eu.eudat.data.entities.UserDMP; -import eu.eudat.data.entities.UserInfo; +import eu.eudat.data.entities.*; +import eu.eudat.logic.services.ApiContext; import eu.eudat.models.rda.Dmp; +import eu.eudat.models.rda.DmpId; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import javax.transaction.Transactional; -import java.util.Collections; +import java.util.*; import java.util.stream.Collectors; @Component public class DmpRDAMapper { private DatasetRDAMapper datasetRDAMapper; + private ApiContext apiContext; @Autowired - public DmpRDAMapper(DatasetRDAMapper datasetRDAMapper) { + public DmpRDAMapper(DatasetRDAMapper datasetRDAMapper, ApiContext apiContext) { this.datasetRDAMapper = datasetRDAMapper; + this.apiContext = apiContext; } @Transactional @@ -44,8 +46,28 @@ public class DmpRDAMapper { rda.setContributor(dmp.getUsers().stream().map(ContributorRDAMapper::toRDA).collect(Collectors.toList())); rda.setDataset(dmp.getDataset().stream().map(dataset -> datasetRDAMapper.toRDA(dataset)).collect(Collectors.toList())); rda.setProject(Collections.singletonList(ProjectRDAMapper.toRDA(dmp.getProject(), dmp.getGrant()))); - - + rda.setAdditionalProperty("templates", dmp.getAssociatedDmps().stream().map(datasetProfile -> datasetProfile.getId().toString()).toArray()); return rda; } + + public DMP toEntity(Dmp rda) { + DMP entity = new DMP(); + entity.setLabel(rda.getTitle()); + if (rda.getDmpId().getType() == DmpId.Type.DOI) { + entity.setDoi(rda.getDmpId().getIdentifier()); + } + entity.setCreated(rda.getCreated()); + entity.setModified(rda.getModified()); + entity.setDescription(rda.getDescription()); + entity.setDataset(rda.getDataset().stream().map(rda1 -> datasetRDAMapper.toEntity(rda1)).collect(Collectors.toSet())); + Map result = ProjectRDAMapper.toEntity(rda.getProject().get(0), apiContext); + entity.setProject((Project) result.get("project")); + result.entrySet().stream().filter(entry -> entry.getKey().startsWith("grant")).forEach(entry -> entity.setGrant((Grant) entry.getValue())); + entity.setAssociatedDmps(((List) rda.getAdditionalProperties().get("templates")).stream().map(this::getProfile).collect(Collectors.toSet())); + return entity; + } + + private DatasetProfile getProfile(String id) { + return apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id)); + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java index e0b8fbe65..2dd3f6cc2 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java @@ -1,7 +1,8 @@ package eu.eudat.models.rda.mapper; -import eu.eudat.data.entities.Funder; +import eu.eudat.data.dao.criteria.GrantCriteria; import eu.eudat.data.entities.Grant; +import eu.eudat.logic.services.ApiContext; import eu.eudat.models.rda.Funding; public class FundingRDAMapper { @@ -22,4 +23,10 @@ public class FundingRDAMapper { rda.setGrantId(GrantIdRDAMapper.toRDA(shortReference)); return rda; } + + public static Grant toEntity(Funding rda, ApiContext apiContext) { + GrantCriteria criteria = new GrantCriteria(); + criteria.setReference(rda.getGrantId().getIdentifier()); + return apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().getWithCriteria(criteria).getSingle(); + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java index c7e3ba35f..49bbbb527 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java @@ -11,6 +11,7 @@ import org.slf4j.LoggerFactory; import java.io.IOException; import java.util.*; +import java.util.stream.Collectors; public class MetadataRDAMapper { private static final Logger logger = LoggerFactory.getLogger(MetadataRDAMapper.class); @@ -36,6 +37,7 @@ public class MetadataRDAMapper { rdas.add(new Metadatum()); rdas.get(rdas.size() - 1).setMetadataStandardId(MetadataStandardIdRDAMapper.toRDA(data.get("uri").asText())); rdas.get(rdas.size() - 1).setDescription(data.get("label").asText()); + rdas.get(rdas.size() - 1).setAdditionalProperty("fieldId", node.get("id").asText()); rdaMap.put(data.get("uri").asText(), node.get("numbering").asText()); } } @@ -45,6 +47,7 @@ public class MetadataRDAMapper { } else if (rdaValue instanceof TextNode && rdaProperty.contains("identifier") && !rdaValue.asText().isEmpty()) { rdas.add(new Metadatum()); rdas.get(rdas.size() - 1).setMetadataStandardId(MetadataStandardIdRDAMapper.toRDA(rdaValue.asText())); + rdas.get(rdas.size() - 1).setAdditionalProperty("identifierId", node.get("id").asText()); rdaMap.put(rdaValue.asText(), node.get("numbering").asText()); } break; @@ -53,6 +56,7 @@ public class MetadataRDAMapper { Metadatum rda = getRelative(rdas, rdaMap, node.get("numbering").asText()); if (rda != null) { rda.setDescription(rdaValue.asText()); + rda.setAdditionalProperty("descriptionId", node.get("id").asText()); } else { rdas.stream().filter(rda1 -> rda1.getDescription() == null || rda1.getDescription().isEmpty()).forEach(rda1 -> rda1.setDescription(rdaValue.asText())); } @@ -64,6 +68,7 @@ public class MetadataRDAMapper { Metadatum rda = getRelative(rdas, rdaMap, node.get("numbering").asText()); if (rda != null) { rda.setLanguage(lang); + rda.setAdditionalProperty("languageId", node.get("id").asText()); } else { rdas.forEach(rda1 -> rda1.setLanguage(lang)); } @@ -77,6 +82,40 @@ public class MetadataRDAMapper { return rdas; } + public static Map toProperties(List rdas) { + Map properties = new HashMap<>(); + List standardIds = new ArrayList<>(); + ObjectMapper mapper = new ObjectMapper(); + rdas.forEach(rda -> { + rda.getAdditionalProperties().entrySet().forEach(entry -> { + try { + switch (entry.getKey()) { + case "fieldId": + Map metadata = toMap(rda); + standardIds.add(metadata); + properties.put(entry.getValue().toString(), mapper.writeValueAsString(standardIds)); + break; + case "identifierId": + properties.put(entry.getValue().toString(), rda.getMetadataStandardId().getIdentifier()); + break; + case "descriptionId": + properties.put(entry.getValue().toString(), rda.getDescription()); + break; + case "languageId": + if (rda.getLanguage() != null) { + properties.put(entry.getValue().toString(), rda.getLanguage().value()); + } + break; + } + }catch (Exception e) { + logger.error(e.getMessage(), e); + } + }); + }); + + return properties; + } + public static Metadatum toRDA(JsonNode node) { Metadatum rda = new Metadatum(); String rdaProperty = node.get("rdaProperty").asText(); @@ -122,4 +161,31 @@ public class MetadataRDAMapper { return name; } } + + private static Map toMap(Metadatum rda) { + Map result = new HashMap<>(); + + ObjectMapper mapper = new ObjectMapper(); + + Map metadata = mapper.convertValue(rda, Map.class); + + Map metadataStandardId = mapper.convertValue(metadata.get("metadata_standard_id"), Map.class); + + String url = metadataStandardId.remove("identifier"); + metadataStandardId.remove("type"); + metadataStandardId.put("uri", url); + + metadata.remove("additional_properties"); + metadata.remove("metadata_standard_id"); + + Map newMetadata = metadata.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue().toString())); + + String label = newMetadata.remove("description"); + newMetadata.put("label", label); + + result.putAll(newMetadata); + result.putAll(metadataStandardId); + + return result; + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java index d97eace4a..b21a9403c 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java @@ -2,9 +2,10 @@ package eu.eudat.models.rda.mapper; import eu.eudat.data.entities.Funder; import eu.eudat.data.entities.Grant; +import eu.eudat.logic.services.ApiContext; import eu.eudat.models.rda.Project; -import java.util.Collections; +import java.util.*; public class ProjectRDAMapper { @@ -22,4 +23,23 @@ public class ProjectRDAMapper { return rda; } + + public static Map toEntity(Project rda, ApiContext apiContext) { + Map entities = new HashMap<>(); + + entities.put("project", new eu.eudat.data.entities.Project()); + ((eu.eudat.data.entities.Project) entities.get("project")).setLabel(rda.getTitle()); + ((eu.eudat.data.entities.Project) entities.get("project")).setDescription(rda.getDescription()); + ((eu.eudat.data.entities.Project) entities.get("project")).setId(UUID.randomUUID()); + ((eu.eudat.data.entities.Project) entities.get("project")).setStatus((short)1); + ((eu.eudat.data.entities.Project) entities.get("project")).setCreated(new Date()); + ((eu.eudat.data.entities.Project) entities.get("project")).setModified(new Date()); + ((eu.eudat.data.entities.Project) entities.get("project")).setType(0); + apiContext.getOperationsContext().getDatabaseRepository().getProjectDao().createOrUpdate(((eu.eudat.data.entities.Project) entities.get("project"))); + for (int i = 0; i < rda.getFunding().size(); i++) { + entities.put("grant" + (i + 1), FundingRDAMapper.toEntity(rda.getFunding().get(i), apiContext)); + } + + return entities; + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java index fc44cc182..3b5d28649 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java @@ -3,10 +3,13 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; import eu.eudat.logic.utilities.helpers.MyStringUtils; import eu.eudat.models.rda.SecurityAndPrivacy; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.*; public class SecurityAndPrivacyRDAMapper { + private static final Logger logger = LoggerFactory.getLogger(SecurityAndPrivacyRDAMapper.class); public static List toRDAList(List nodes) { Map rdaMap = new HashMap<>(); @@ -19,14 +22,16 @@ public class SecurityAndPrivacyRDAMapper { if (!rdaMap.containsValue(rda)) { rdaMap.put(node.get("numbering").asText(), rda); } - for (PropertyName propertyName: PropertyName.values()) { - if (rdaProperty.contains(propertyName.getName())) { - switch (propertyName) { + for (ExportPropertyName exportPropertyName : ExportPropertyName.values()) { + if (rdaProperty.contains(exportPropertyName.getName())) { + switch (exportPropertyName) { case TITLE: rda.setTitle(rdaValue); + rda.getAdditionalProperties().put(ImportPropertyName.TITLE.getName(), node.get("id").asText()); break; case DESCRIPTION: rda.setDescription(rdaValue); + rda.getAdditionalProperties().put(ImportPropertyName.DESCRIPTION.getName(), node.get("id").asText()); break; } } @@ -36,6 +41,27 @@ public class SecurityAndPrivacyRDAMapper { return new ArrayList<>(rdaMap.values()); } + public static Map toProperties(List rdas) { + Map properties = new HashMap<>(); + rdas.forEach(rda -> rda.getAdditionalProperties().entrySet().forEach(entry -> { + try { + ImportPropertyName importPropertyName = ImportPropertyName.fromString(entry.getKey()); + switch(importPropertyName) { + case TITLE: + properties.put(entry.getValue().toString(), rda.getTitle()); + break; + case DESCRIPTION: + properties.put(entry.getValue().toString(), rda.getDescription()); + break; + } + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + })); + + return properties; + } + public static SecurityAndPrivacy toRDA(JsonNode node) { SecurityAndPrivacy rda = new SecurityAndPrivacy(); String rdaProperty = node.get("rdaProperty").asText(); @@ -55,13 +81,13 @@ public class SecurityAndPrivacyRDAMapper { .max(Comparator.comparingInt(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering))).map(Map.Entry::getValue).orElse(new SecurityAndPrivacy()); } - private enum PropertyName { + private enum ExportPropertyName { TITLE("title"), DESCRIPTION("description"); private String name; - PropertyName(String name) { + ExportPropertyName(String name) { this.name = name; } @@ -69,4 +95,28 @@ public class SecurityAndPrivacyRDAMapper { return name; } } + + private enum ImportPropertyName { + TITLE("titleId"), + DESCRIPTION("descriptionId"); + + private String name; + + ImportPropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public static ImportPropertyName fromString(String name) throws Exception { + for (ImportPropertyName importPropertyName: ImportPropertyName.values()) { + if (importPropertyName.getName().equals(name)) { + return importPropertyName; + } + } + throw new Exception("Property not available"); + } + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java index c48f93cae..cd764c302 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java @@ -2,12 +2,14 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; import eu.eudat.logic.utilities.helpers.MyStringUtils; -import eu.eudat.models.rda.SecurityAndPrivacy; import eu.eudat.models.rda.TechnicalResource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.*; public class TechnicalResourceRDAMapper { + private static final Logger logger = LoggerFactory.getLogger(TechnicalResourceRDAMapper.class); public static List toRDAList(List nodes) { Map rdaMap = new HashMap<>(); @@ -20,14 +22,16 @@ public class TechnicalResourceRDAMapper { if (!rdaMap.containsValue(rda)) { rdaMap.put(node.get("numbering").asText(), rda); } - for (PropertyName propertyName: PropertyName.values()) { - if (rdaProperty.contains(propertyName.getName())) { - switch (propertyName) { + for (ExportPropertyName exportPropertyName : ExportPropertyName.values()) { + if (rdaProperty.contains(exportPropertyName.getName())) { + switch (exportPropertyName) { case NAME: rda.setName(rdaValue); + rda.setAdditionalProperty(ImportPropertyName.NAME.getName(), node.get("id").asText()); break; case DESCRIPTION: rda.setDescription(rdaValue); + rda.setAdditionalProperty(ImportPropertyName.DESCRIPTION.getName(), node.get("id").asText()); break; } } @@ -37,6 +41,28 @@ public class TechnicalResourceRDAMapper { return new ArrayList<>(rdaMap.values()); } + public static Map toProperties(List rdas) { + Map properties = new HashMap<>(); + + rdas.forEach(rda -> rda.getAdditionalProperties().entrySet().forEach(entry -> { + try { + ImportPropertyName importPropertyName = ImportPropertyName.fromString(entry.getKey()); + switch(importPropertyName) { + case DESCRIPTION: + properties.put(entry.getValue().toString(), rda.getDescription()); + break; + case NAME: + properties.put(entry.getValue().toString(), rda.getName()); + break; + } + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + })); + + return properties; + } + public static TechnicalResource toRDA(JsonNode node) { TechnicalResource rda = new TechnicalResource(); String rdaProperty = node.get("rdaProperty").asText(); @@ -56,13 +82,13 @@ public class TechnicalResourceRDAMapper { .max(Comparator.comparingInt(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering))).map(Map.Entry::getValue).orElse(new TechnicalResource()); } - private enum PropertyName { + private enum ExportPropertyName { NAME("name"), DESCRIPTION("description"); private String name; - PropertyName(String name) { + ExportPropertyName(String name) { this.name = name; } @@ -70,4 +96,28 @@ public class TechnicalResourceRDAMapper { return name; } } + + private enum ImportPropertyName { + NAME("nameId"), + DESCRIPTION("descriptionId"); + + private String name; + + ImportPropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public static ImportPropertyName fromString(String name) throws Exception { + for (ImportPropertyName importPropertyName: ImportPropertyName.values()) { + if (importPropertyName.getName().equals(name)) { + return importPropertyName; + } + } + throw new Exception("Property name not available"); + } + } } diff --git a/dmp-frontend/src/app/ui/dmp/listing/upload-dialogue/dmp-upload-dialogue.component.html b/dmp-frontend/src/app/ui/dmp/listing/upload-dialogue/dmp-upload-dialogue.component.html index 81779fadc..f9669094e 100644 --- a/dmp-frontend/src/app/ui/dmp/listing/upload-dialogue/dmp-upload-dialogue.component.html +++ b/dmp-frontend/src/app/ui/dmp/listing/upload-dialogue/dmp-upload-dialogue.component.html @@ -7,7 +7,7 @@ - +
From 9a56d55fb784bf9fb3348d97d7df0bb59512b306 Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Fri, 27 Mar 2020 10:50:37 +0200 Subject: [PATCH 19/20] Small bugfix for RDA Import --- .../java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java index 90aa4ec7c..eef6eb6ed 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java @@ -63,7 +63,7 @@ public class DatasetRDAMapper { if (!qaNodes.isEmpty()) { rda.setDataQualityAssurance(qaNodes.stream().map(qaNode -> qaNode.get("value").asText()).collect(Collectors.toList())); for (int i = 0; i < qaNodes.size(); i++) { - rda.setAdditionalProperty("qa" + (i + 1), qaNodes.get(i).get("id").asText()); + rda.setAdditionalProperty("qaId" + (i + 1), qaNodes.get(i).get("id").asText()); } } List preservationNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.preservation_statement"); @@ -149,7 +149,7 @@ public class DatasetRDAMapper { properties.putAll(MetadataRDAMapper.toProperties(rda.getMetadata())); } - List qaIds = rda.getAdditionalProperties().entrySet().stream().filter(entry -> entry.getKey().startsWith("qa")).map(entry -> entry.getValue().toString()).collect(Collectors.toList()); + List qaIds = rda.getAdditionalProperties().entrySet().stream().filter(entry -> entry.getKey().startsWith("qaId")).map(entry -> entry.getValue().toString()).collect(Collectors.toList()); for (int i = 0; i < qaIds.size(); i++) { properties.put(qaIds.get(i), rda.getDataQualityAssurance().get(i)); } @@ -187,7 +187,7 @@ public class DatasetRDAMapper { } rda.getAdditionalProperties().entrySet().stream() - .filter(entry -> !entry.getKey().equals("template") && !entry.getKey().startsWith("qa") && !entry.getKey().startsWith("keyword")) + .filter(entry -> !entry.getKey().equals("template") && !entry.getKey().startsWith("qaId") && !entry.getKey().startsWith("keyword")) .forEach(entry -> properties.put(entry.getKey(), entry.getValue())); entity.setProperties(new ObjectMapper().writeValueAsString(properties)); } catch (Exception e) { From 2654e56d9fa5aeec7406947f2a4c59d5fa7e078c Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Fri, 27 Mar 2020 14:31:06 +0200 Subject: [PATCH 20/20] Added Host and License RDA imports & (not functional yet) dataset indexing --- .../managers/DataManagementPlanManager.java | 20 +++- .../rda/mapper/DistributionRDAMapper.java | 7 +- .../models/rda/mapper/HostRDAMapper.java | 103 +++++++++++++++++- .../models/rda/mapper/LicenseRDAMapper.java | 25 +++++ 4 files changed, 150 insertions(+), 5 deletions(-) diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java index c8dee4802..7d3cc1b03 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java @@ -1356,7 +1356,25 @@ public class DataManagementPlanManager { dataset.setCreated(new Date()); dataset.setModified(new Date()); dataset.setDmp(dmp); - databaseRepository.getDatasetDao().createOrUpdate(dataset); + dataset = databaseRepository.getDatasetDao().createOrUpdate(dataset); + dataset.setRegistries(new HashSet<>()); + dataset.setDatasetDataRepositories(new HashSet<>()); + dataset.setDatasetExternalDatasets(new HashSet<>()); + dataset.setServices(new HashSet<>()); + if (dmp.getOrganisations() == null) { + dmp.setOrganisations(new HashSet<>()); + } + if (dmp.getResearchers() == null) { + dmp.setResearchers(new HashSet<>()); + } + dmp.setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), dmp.getId())).toList())); + try { + DatasetWizardModel model = new DatasetWizardModel().fromDataModel(dataset); + model.setDatasetProfileDefinition(datasetManager.getPagedProfile(model, dataset)); + datasetManager.updateTags(apiContext.getOperationsContext().getDatasetRepository(), model); + } catch (Exception e) { + logger.error(e.getMessage(), e); + } }); result.add(dmp); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java index 566288452..ac63cb22c 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java @@ -1,7 +1,6 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; -import com.lowagie.text.ExceptionConverter; import eu.eudat.logic.utilities.helpers.MyStringUtils; import eu.eudat.models.rda.Distribution; import org.slf4j.Logger; @@ -110,6 +109,12 @@ public class DistributionRDAMapper { } }); + if (rda.getHost() != null) { + properties.putAll(HostRDAMapper.toProperties(rda.getHost())); + } + if (rda.getLicense() != null && !rda.getLicense().isEmpty()) { + properties.putAll(LicenseRDAMapper.toProperties(rda.getLicense())); + } }); return properties; diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java index 0983f3d3b..cd66b8ffc 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java @@ -4,12 +4,17 @@ import com.fasterxml.jackson.databind.JsonNode; import eu.eudat.logic.utilities.helpers.MyStringUtils; import eu.eudat.models.rda.Host; import eu.eudat.models.rda.PidSystem; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.net.URI; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; public class HostRDAMapper { + private static final Logger logger = LoggerFactory.getLogger(HostRDAMapper.class); public static Host toRDA(List nodes, String numbering) { Host rda = new Host(); @@ -19,41 +24,51 @@ public class HostRDAMapper { int firstDiff = MyStringUtils.getFirstDifference(numbering, node.get("numbering").asText()); if (firstDiff == -1 || firstDiff > 2) { String rdaValue = node.get("value").asText(); - for (PropertyName propertyName: PropertyName.values()) { + for (ExportPropertyName propertyName: ExportPropertyName.values()) { if (rdaProperty.contains(propertyName.getName())) { switch (propertyName) { case AVAILABILITY: rda.setAvailability(rdaValue); + rda.setAdditionalProperty(ImportPropertyName.AVAILABILITY.getName(), node.get("id").asText()); break; case BACKUP_FREQUENCY: rda.setBackupFrequency(rdaValue); + rda.setAdditionalProperty(ImportPropertyName.BACKUP_FREQUENCY.getName(), node.get("id").asText()); break; case BACKUP_TYPE: rda.setBackupType(rdaValue); break; case CERTIFIED_WITH: rda.setCertifiedWith(Host.CertifiedWith.fromValue(rdaValue)); + rda.setAdditionalProperty(ImportPropertyName.CERTIFIED_WITH.getName(), node.get("id").asText()); break; case DESCRIPTION: rda.setDescription(rdaValue); + rda.setAdditionalProperty(ImportPropertyName.DESCRIPTION.getName(), node.get("id").asText()); break; case GEO_LOCATION: rda.setGeoLocation(Host.GeoLocation.fromValue(rdaValue)); + rda.setAdditionalProperty(ImportPropertyName.GEO_LOCATION.getName(), node.get("id").asText()); break; case PID_SYSTEM: rda.setPidSystem(Collections.singletonList(PidSystem.fromValue(rdaValue))); + rda.setAdditionalProperty(ImportPropertyName.PID_SYSTEM.getName(), node.get("id").asText()); break; case STORAGE_TYPE: rda.setStorageType(rdaValue); + rda.setAdditionalProperty(ImportPropertyName.STORAGE_TYPE.getName(), node.get("id").asText()); break; case SUPPORT_VERSIONING: rda.setSupportVersioning(Host.SupportVersioning.fromValue(rdaValue)); + rda.setAdditionalProperty(ImportPropertyName.SUPPORT_VERSIONING.getName(), node.get("id").asText()); break; case TITLE: rda.setTitle(rdaValue); + rda.setAdditionalProperty(ImportPropertyName.TITLE.getName(), node.get("id").asText()); break; case URL: rda.setUrl(URI.create(rdaValue)); + rda.setAdditionalProperty(ImportPropertyName.URL.getName(), node.get("id").asText()); break; } } @@ -65,7 +80,56 @@ public class HostRDAMapper { return rda; } - private enum PropertyName { + public static Map toProperties(Host rda) { + Map properties = new HashMap<>(); + rda.getAdditionalProperties().entrySet().forEach(entry -> { + try { + ImportPropertyName importPropertyName = ImportPropertyName.fromString(entry.getKey()); + switch (importPropertyName) { + case AVAILABILITY: + properties.put(entry.getValue().toString(), rda.getAvailability()); + break; + case TITLE: + properties.put(entry.getValue().toString(), rda.getTitle()); + break; + case DESCRIPTION: + properties.put(entry.getValue().toString(), rda.getDescription()); + break; + case BACKUP_FREQUENCY: + properties.put(entry.getValue().toString(), rda.getBackupFrequency()); + break; + case BACKUP_TYPE: + properties.put(entry.getValue().toString(), rda.getBackupType()); + break; + case CERTIFIED_WITH: + properties.put(entry.getValue().toString(), rda.getCertifiedWith().value()); + break; + case GEO_LOCATION: + properties.put(entry.getValue().toString(), rda.getGeoLocation().value()); + break; + case PID_SYSTEM: + properties.put(entry.getValue().toString(), rda.getPidSystem().get(0).value()); + break; + case STORAGE_TYPE: + properties.put(entry.getValue().toString(), rda.getStorageType()); + break; + case SUPPORT_VERSIONING: + properties.put(entry.getValue().toString(), rda.getSupportVersioning().value()); + break; + case URL: + properties.put(entry.getValue().toString(), rda.getUrl().toString()); + break; + } + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + + }); + + return properties; + } + + private enum ExportPropertyName { AVAILABILITY("availability"), BACKUP_FREQUENCY("backup_frequency"), BACKUP_TYPE("backup_type"), @@ -80,7 +144,7 @@ public class HostRDAMapper { private final String name; - PropertyName(String name) { + ExportPropertyName(String name) { this.name = name; } @@ -88,4 +152,37 @@ public class HostRDAMapper { return name; } } + + private enum ImportPropertyName { + AVAILABILITY("availabilityId"), + BACKUP_FREQUENCY("backup_frequencyId"), + BACKUP_TYPE("backup_typeId"), + CERTIFIED_WITH("certified_withId"), + DESCRIPTION("descriptionId"), + GEO_LOCATION("geo_locationId"), + PID_SYSTEM("pid_systemId"), + STORAGE_TYPE("storage_typeId"), + SUPPORT_VERSIONING("support_versioningId"), + TITLE("titleId"), + URL("urlId"); + + private final String name; + + ImportPropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public static ImportPropertyName fromString(String name) throws Exception { + for (ImportPropertyName importPropertyName: ImportPropertyName.values()) { + if (importPropertyName.getName().equals(name)) { + return importPropertyName; + } + } + throw new Exception("No name available"); + } + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java index 6f94a73c4..5705caecf 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java @@ -4,6 +4,9 @@ import com.fasterxml.jackson.databind.JsonNode; import eu.eudat.models.rda.License; import java.net.URI; +import java.util.HashMap; +import java.util.List; +import java.util.Map; public class LicenseRDAMapper { @@ -14,10 +17,32 @@ public class LicenseRDAMapper { if (rdaProperty.contains("license_ref")) { rda.setLicenseRef(URI.create(value)); + rda.setAdditionalProperty("license_refId", node.get("id").asText()); } else if (rdaProperty.contains("start_date")) { rda.setStartDate(value); + rda.setAdditionalProperty("start_dateId", node.get("id").asText()); } return rda; } + + public static Map toProperties(List rdas) { + Map properties = new HashMap<>(); + + rdas.forEach(rda -> { + rda.getAdditionalProperties().entrySet().forEach(entry -> { + switch (entry.getKey()) { + case "license_refId": + properties.put(entry.getValue().toString(), rda.getLicenseRef().toString()); + break; + case "start_dateId": + properties.put(entry.getValue().toString(), rda.getStartDate()); + break; + } + + }); + }); + + return properties; + } }