-
Notifications
You must be signed in to change notification settings - Fork 490
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
Add API endpoint for comparing Dataset Versions #10945
Merged
ofahimIQSS
merged 9 commits into
develop
from
10888-add-api-for-comparing-dataset-versions
Nov 22, 2024
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f2430c5
Add API endpoint for comparing Dataset Versions
stevenwinship c12932f
updaing json format
stevenwinship 842f04b
fixes for json output
stevenwinship c5adf92
fixes for json output
stevenwinship d957f60
fixes for json output
stevenwinship d26fb06
Merge branch 'develop' into 10888-add-api-for-comparing-dataset-versions
stevenwinship fa0389d
adding check for dataset order incorrect
stevenwinship 91fef44
adding check for dataset order incorrect
stevenwinship 558577e
Merge branch 'develop' into 10888-add-api-for-comparing-dataset-versions
stevenwinship File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
doc/release-notes/10888-add-api-for-comparing-dataset-versions.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The following API have been added: | ||
|
||
/api/datasets/{persistentId}/versions/{versionId0}/compare/{versionId1} | ||
|
||
This API lists the changes between 2 dataset versions. The Json response shows the changes per field within the Metadata block and the Terms Of Access. Also listed are the files that have been added or removed. Files that have been modified will also display the new file data plus the fields that have been modified. | ||
When compare includes an unpublished/draft version the api token must be associated with a user having view unpublished privileges | ||
An error will be returned if VERSION0 was not created before VERSION1 | ||
|
||
Example of Metadata Block field change: | ||
```json | ||
{ | ||
"blockName": "Life Sciences Metadata", | ||
"changed": [ | ||
{ | ||
"fieldName": "Design Type", | ||
"oldValue": "", | ||
"newValue": "Parallel Group Design; Nested Case Control Design" | ||
} | ||
] | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2992,6 +2992,26 @@ public Response cleanStorage(@Context ContainerRequestContext crc, @PathParam("i | |
|
||
} | ||
|
||
@GET | ||
@AuthRequired | ||
@Path("{id}/versions/{versionId1}/compare/{versionId2}") | ||
public Response getCompareVersions(@Context ContainerRequestContext crc, @PathParam("id") String id, | ||
@PathParam("versionId1") String versionId1, | ||
@PathParam("versionId2") String versionId2, | ||
@Context UriInfo uriInfo, @Context HttpHeaders headers) { | ||
try { | ||
DataverseRequest req = createDataverseRequest(getRequestUser(crc)); | ||
DatasetVersion dsv1 = getDatasetVersionOrDie(req, versionId1, findDatasetOrDie(id), uriInfo, headers); | ||
DatasetVersion dsv2 = getDatasetVersionOrDie(req, versionId2, findDatasetOrDie(id), uriInfo, headers); | ||
if (dsv1.getCreateTime().getTime() > dsv2.getCreateTime().getTime()) { | ||
return error(BAD_REQUEST, BundleUtil.getStringFromBundle("dataset.version.compare.incorrect.order")); | ||
} | ||
return ok(DatasetVersion.compareVersions(dsv1, dsv2)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should there be a test to make sure that the versions are considered in the correct order? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added check. return 400 if not in proper order |
||
} catch (WrappedResponse wr) { | ||
return wr.getResponse(); | ||
} | ||
} | ||
|
||
private static Set<String> getDatasetFilenames(Dataset dataset) { | ||
Set<String> files = new HashSet<>(); | ||
for (DataFile dataFile: dataset.getFiles()) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should say that you need to provide an api token with view unpublished privileges to compare draft version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated