In preparing to add File Level metadata to Dataverse these are notes on several places where experience has shown that the API could be improved.
newDatasetVersion.addEmailContact("[email protected]");
- high barrier of entry to collaborators
- time-consuming
- hard to maintain
DatasetFieldType emailDatasetFieldType = datasetFieldService.findByNameOpt(DatasetFieldConstant.datasetContact);
DatasetField emailDatasetField = DatasetField.createNewEmptyDatasetField(emailDatasetFieldType, datasetVersion);
for (DatasetField childField : emailDatasetField.getDatasetFieldCompoundValues().get(0).getChildDatasetFields()) {
if (DatasetFieldConstant.datasetContactEmail.equals(childField.getDatasetFieldType().getName())) {
childField.getSingleValue().setValue(user.getDisplayInfo().getEmailAddress());
}
}
datasetVersion.getDatasetFields().add(emailDatasetField);
This example shows the JSON required for adding two authors and their affilations
{
"author": [
{
"authorName": "Smith, Robert",
"authorAffiliation": "The Smiths",
},
{
"authorName": "Kew, Susie",
"authorAffiliation": "Creedence Clearwater Revival",
}
]
}
This is what the JSON looks like for adding two authors and their affiliations.
No one uses this because of the complexity
- Note: This was written as a favor to the Dataverse team to help them save test data when the DB was dropped
{
"typeName": "author",
"multiple": true,
"typeClass": "compound",
"value": [
{
"authorName": {
"typeName": "authorName",
"multiple": false,
"typeClass": "primitive",
"value": "Smith, Robert"
},
"authorAffiliation": {
"typeName": "authorAffiliation",
"multiple": false,
"typeClass": "primitive",
"value": "The Smiths"
}
},
{
"authorName": {
"typeName": "authorName",
"multiple": false,
"typeClass": "primitive",
"value": "Kew, Susie"
},
"authorAffiliation": {
"typeName": "authorAffiliation",
"multiple": false,
"typeClass": "primitive",
"value": "Creedence Clearwater Revival"
}
}]
References:
- sample data:https://github.com/IQSS/dataverse/blob/develop/scripts/api/data/dataset-create-new.json)
- parsing program for JSON -> Relational DB: https://github.com/IQSS/dataverse/blob/28758208bef3fb713c903450067a47c0814655b1/src/main/java/edu/harvard/iq/dataverse/util/json/JsonParser.java
Java code to create JSON output
-
Not so bad for metadata. But if stored as JSON, this wouldn't be necessary
-
Also, the output is confusing--more data than user would want--it's the same as this JSON: