dataverse
dataverse copied to clipboard
addDataverse API endpoint extension for input levels and facet list setup
What this PR does / why we need it:
The addDataverse (/api/dataverses/{identifier}
) API endpoint has been extended to allow adding metadata blocks, input levels and facet ids at creation time, as the Dataverse page in create mode does in JSF.
Which issue(s) this PR closes:
- Closes #10633
Special notes for your reviewer:
I had to modify the CreateDataverseCommand
to add the logic for adding metadata blocks, as well as other logic related to the Dataverse instance and its input levels and facets. I also had to reorder the code for persisting the dataverse collection with all the changes.
The logic I had to add to the command was previously handled in JSF from the Dataverse Page before calling the command, and without these modifications, calling the command from the API with input levels and/or facet ids resulted in an inconsistent state for the created Dataverse. The API was sending facetIds and inputLevels as null, since they were not supported in the endpoint request body, so these issues went unnoticed.
I have implemented the changes in such a way that they do not interfere with the current behavior of JSF, as the command is still consumed in the same way in JSF and I have not made any changes to the DataversePage.class. I have performed several manual tests with logging to ensure that there is no impact on the behavior of JSF, but due to the lack of test coverage in this area, I recommend an analysis of possible implications by the PR reviewer.
Suggestions on how to test this:
IT tests have been implemented, covering cases where metadata blocks, input levels, or facet IDs are set in the dataverse collection. However, I recommend performing manual tests by calling the endpoint and verifying the correct persistence of the dataverse, its metadata blocks, input levels, and facets.
Create JSON file following the new example provided in the docs: https://github.com/IQSS/dataverse/blob/e65eb9f947beec06ddbfc6f0bfb73f7ecaf60d28/doc/sphinx-guides/source/_static/api/dataverse-complete-optional-params.json
Call the endoint as described in the docs:
curl -H "X-Dataverse-key:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -X POST "https://demo.dataverse.org/api/dataverses/root" --upload-file dataverse-complete-optional-params.json
Now you need to verify that all necessary information about the new dataverse collection, its metadata blocks, input levels, and facet IDs has been correctly persisted.
We can confirm that the information has been correctly persisted if, after entering the dataverse collection page, the input levels and facets sections have the fields set in the JSON.
Input levels:
Facet ids:
As an additional verification, we can check the persisted information in the related database tables.
-
dataverse_metadatablock
table -
dataversefieldtypeinputlevel
table -
dataversefacet
table
Does this PR introduce a user interface change? If mockups are available, please link/include them here: None
Is there a release notes update needed for this change?: Yes, attached
Additional documentation: None