Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Bug ##

API GET /api/datasets/{id}/metadata now returns all multivalued fields as arrays instead of String for 1 entry and Array for more than 1 entry. This consistancy makes parsing the JSON easier for users of the API.
6 changes: 3 additions & 3 deletions src/main/java/edu/harvard/iq/dataverse/util/bagit/OREMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class OREMap {
public static final String NAME = "OREMap";

//NOTE: Update this value whenever the output of this class is changed
private static final String DATAVERSE_ORE_FORMAT_VERSION = "Dataverse OREMap Format v1.0.3";
private static final String DATAVERSE_ORE_FORMAT_VERSION = "Dataverse OREMap Format v1.0.4";
//v1.0.1 - added versionNote
private static final String DATAVERSE_SOFTWARE_NAME = "Dataverse";
private static final String DATAVERSE_SOFTWARE_URL = "https://github.com/iqss/dataverse";
Expand Down Expand Up @@ -490,9 +490,9 @@ public static JsonValue getJsonLDForField(DatasetField field, Boolean excludeEma
vals.add(child);
}
}
// Add metadata value to aggregation, suppress array when only one value
// Add metadata value to aggregation, suppress array when multiples not allowed
JsonArray valArray = vals.build();
return (valArray.size() != 1) ? valArray : valArray.get(0);
return (dfType.isAllowMultiples()) ? valArray : valArray.get(0);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you make changes to the OREMap, you need to update the version as noted at

//NOTE: Update this value whenever the output of this class is changed
private static final String DATAVERSE_ORE_FORMAT_VERSION = "Dataverse OREMap Format v1.0.3";
. This could also break archiving and tools such as DVUploader that can read archival bags to restore datasets. Hopefully those are robust enough to this change, but they presumably have code to parse single values that will now be obsolete.

@stevenwinship stevenwinship Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will update the version (even though the output really doesn't change) and check DVUploader. DVUploader and anyone using the API should have no issue with the array since it is there when more than 1 entry is there.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like DVUploader expects an array. When it finds a String it converts it to an array so I believe this code is not affected by this change.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for checking. Thinking some more, I think most of the places we read the ORE map, we use json-ld tools and canonicalize the format before parsing, which probably managed the conversion already. (That would probably be a best practice for json-ld in general.)

}

private static void addCvocValue(String val, JsonArrayBuilder vals, JsonObject cvocEntry,
Expand Down
2 changes: 2 additions & 0 deletions src/test/java/edu/harvard/iq/dataverse/api/DatasetsIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -3658,6 +3658,7 @@ public void testSemanticMetadataAPIs() {

// Get the metadata with the semantic api
Response response = UtilIT.getDatasetJsonLDMetadata(datasetId, apiToken);
response.prettyPrint();
response.then().assertThat().statusCode(OK.getStatusCode());
// Compare the metadata with an expected value - the metadatablock entries
// should be the same but there will be additional fields with values related to
Expand Down Expand Up @@ -3822,6 +3823,7 @@ public void testReCreateDataset() {

// Get the semantic metadata
Response response = UtilIT.getDatasetJsonLDMetadata(datasetId, apiToken);
response.prettyPrint();
response.then().assertThat().statusCode(OK.getStatusCode());
response.prettyPeek();
String expectedString = getData(response.getBody().asString());
Expand Down
Loading