Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expose dataset ID and DOI/Handle in version response #6397 #6511

Merged
merged 3 commits into from
Jan 21, 2020
Merged
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
2 changes: 1 addition & 1 deletion doc/sphinx-guides/source/api/native-api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ List Versions of a Dataset
Get Version of a Dataset
~~~~~~~~~~~~~~~~~~~~~~~~

|CORS| Show a version of the dataset. The Dataset also include any metadata blocks the data might have::
|CORS| Show a version of the dataset. The output includes any metadata blocks the dataset might have::

GET http://$SERVER/api/datasets/$id/versions/$versionNumber?key=$apiKey

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,8 @@ public static JsonObjectBuilder json(Dataset ds) {
public static JsonObjectBuilder json(DatasetVersion dsv) {
JsonObjectBuilder bld = jsonObjectBuilder()
.add("id", dsv.getId())
.add("datasetId", dsv.getDataset().getId())
.add("datasetPersistentId", dsv.getDataset().getGlobalId().asString())
.add("storageIdentifier", dsv.getDataset().getStorageIdentifier())
.add("versionNumber", dsv.getVersionNumber())
.add("versionMinorNumber", dsv.getMinorVersionNumber())
Expand Down
7 changes: 7 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 @@ -406,6 +406,13 @@ public void testCreatePublishDestroyDataset() {
assertTrue(datasetContactFromExport.toString().contains("finch@mailinator.com"));
assertTrue(firstValue.toString().contains("finch@mailinator.com"));

Response getDatasetVersion = UtilIT.getDatasetVersion(datasetPersistentId, ":latest-published", apiToken);
getDatasetVersion.prettyPrint();
getDatasetVersion.then().assertThat()
.body("data.datasetId", equalTo(datasetId))
.body("data.datasetPersistentId", equalTo(datasetPersistentId))
.statusCode(OK.getStatusCode());

Response citationBlock = UtilIT.getMetadataBlockFromDatasetVersion(datasetPersistentId, null, null, apiToken);
citationBlock.prettyPrint();
citationBlock.then().assertThat()
Expand Down
6 changes: 6 additions & 0 deletions src/test/java/edu/harvard/iq/dataverse/api/UtilIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,12 @@ static Response nativeGetUsingPersistentId(String persistentId, String apiToken)
return response;
}

static Response getDatasetVersion(String persistentId, String versionNumber, String apiToken) {
return given()
.header(API_TOKEN_HTTP_HEADER, apiToken)
.get("/api/datasets/:persistentId/versions/" + versionNumber + "?persistentId=" + persistentId);
}

static Response getMetadataBlockFromDatasetVersion(String persistentId, String versionNumber, String metadataBlock, String apiToken) {
return given()
.header(API_TOKEN_HTTP_HEADER, apiToken)
Expand Down