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

Extend Dataverse metadatablocks API to retrieve metadata fields configured as required in the General Information page #10498

Merged
merged 24 commits into from
May 13, 2024

Conversation

GPortas
Copy link
Contributor

@GPortas GPortas commented Apr 16, 2024

What this PR does / why we need it:

Changed api/dataverses/{id}/metadatablocks so that setting the query parameter onlyDisplayedOnCreate=true also returns metadata blocks with dataset field type input levels configured as required on the General Information page of the collection, in addition to the metadata blocks and their fields with the property displayOnCreate=true (which was the original behavior).

A new endpoint api/dataverses/{id}/inputLevels has been created for updating the dataset field type input levels of a collection via API.

Which issue(s) this PR closes:

Special notes for your reviewer:

In api/dataverses/{id}/inputLevels, if one of the input levels corresponds to a dataset field type belonging to a metadata block that does not exist in the collection, the metadata block will be added to the collection. See: https://github.com/IQSS/dataverse/pull/10498/files#diff-fdb2c1fe72d58100303ed72894e5a2e26af2159463e7a2bf29ebca700dd64d45R36

I have created the UpdateDataverseInputLevelsCommand command that wraps the UpdateDataverseCommand command by adding the metadata block update logic, since UpdateDataverseCommand does not include metadata block updates for the new input levels.

Currently in develop the only UpdateDataverseCommand call that included input levels in the constructor (not null) is made in the DatasetPage and before calling the command the dataverse metadata blocks are updated, as can be seen here: https://github.com/IQSS/dataverse/blob/develop/src/main/java/edu/harvard/iq/dataverse/DataversePage.java#L673

A different approach to the new command could have been to modify UpdateDataverseCommand to update the dataverse metadata blocks within it. But I ultimately decided not to modify the command and instead create a new one, in order to reduce the risk of impacting existing behaviors.

The api/dataverses/{id}/inputLevels endpoint has been mainly created for the setup of integration tests that require prior updating of input levels. It is possible that this endpoint requires future extension to be consumed by the SPA.

Suggestions on how to test this:

Integration tests

The /metadatablocks endpoint tests have been updated and new tests have been created for the new /inputLevels endpoint.

Manual testing

  1. Go to the General Information page of the collection you want to modify.
  2. Set new metadata blocks and required fields.
  3. Save the information
  4. Call the api/dataverses/{id}/metadatablocks endpoint:

curl -H "X-Dataverse-key:$API_TOKEN" "$SERVER_URL/api/dataverses/$ID/metadatablocks?returnDatasetFieldTypes=true&onlyDisplayedOnCreate=true"

  1. Check that the metadata block that you added to the collection with only its required fields are returned, alongside the citation metadata block and its fields.

  2. Repeat the same process but now updating the input levels via API:

Please note that this endpoint overwrites all the input levels of the collection page, so if you want to keep the existing ones, you will need to add them to the JSON request body.

curl -X PUT -H "X-Dataverse-key:$API_TOKEN" -H "Content-Type:application/json" "$SERVER_URL/api/dataverses/root/inputLevels" -d '[{"datasetFieldTypeName":"geographicCoverage", "required":true, "include":true}, {"datasetFieldTypeName":"country", "required":true, "include":true}]'

Does this PR introduce a user interface change? If mockups are available, please link/include them here:

No

Is there a release notes update needed for this change?:

Yes. Attached.

Additional documentation:

None

@GPortas GPortas changed the title Extended Dataverse metadatablocks API to retrieve metadata fields configured as required in the General Information pag page Extended Dataverse metadatablocks API to retrieve metadata fields configured as required in the General Information page Apr 16, 2024
@GPortas GPortas changed the title Extended Dataverse metadatablocks API to retrieve metadata fields configured as required in the General Information page Extend Dataverse metadatablocks API to retrieve metadata fields configured as required in the General Information page Apr 16, 2024

This comment has been minimized.

2 similar comments

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

@coveralls
Copy link

coveralls commented Apr 18, 2024

Coverage Status

coverage: 20.579% (-0.01%) from 20.593%
when pulling 4bedbbd on 10477-dataset-fields-on-create-extension
into 3867cfe on develop.

This comment has been minimized.

1 similar comment

This comment has been minimized.

This comment has been minimized.

3 similar comments

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

@GPortas GPortas self-assigned this Apr 18, 2024
@GPortas GPortas added pm.GREI-d-2.7.2 NIH, yr2, aim7, task2: Implement UI modules for creating datasets and publishing workflows SPA These changes are required for the Dataverse SPA labels Apr 18, 2024
@GPortas GPortas removed their assignment Apr 18, 2024

This comment has been minimized.

1 similar comment

This comment has been minimized.

@sekmiller sekmiller self-assigned this Apr 18, 2024
@@ -0,0 +1,50 @@
package edu.harvard.iq.dataverse.engine.command.impl;
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of adding this new command can you use the original UpdateDataverseCommand and pass in the inputlevel list?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The UpdateDataverseInputLevelsCommand command wraps the UpdateDataverseCommand command by adding the metadata block update logic, which is not included in the UpdateDataverseCommand.

I explain this in more detail in the PR description section: Special notes for your reviewer

throw new CommandException("Exception while updating dataverse input levels: Input level list cannot be null", this);
}
addInputLevelMetadataBlocks();
return ctxt.engine().submit(new UpdateDataverseCommand(dataverse, null, null, getRequest(), inputLevelList));
Copy link
Contributor

Choose a reason for hiding this comment

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

Also you need to set isMetadataBlockRoot to true so that the Dataverse knows that it not inheriting its MetadataBlocks from its parent - that is it has a different input level, etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just added that line and also check that the input list is not empty

@GPortas GPortas requested a review from sekmiller April 22, 2024 10:13

This comment has been minimized.

1 similar comment

This comment has been minimized.

Copy link
Contributor

@sekmiller sekmiller left a comment

Choose a reason for hiding this comment

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

There's one change that needs to be made with respect to updating isMetadataBlockRoot. Also suggesting that you might not need the new command.

This comment has been minimized.

@sekmiller sekmiller removed their assignment Apr 23, 2024

This comment has been minimized.

Copy link

📦 Pushed preview images as

ghcr.io/gdcc/dataverse:10477-dataset-fields-on-create-extension
ghcr.io/gdcc/configbaker:10477-dataset-fields-on-create-extension

🚢 See on GHCR. Use by referencing with full name as printed above, mind the registry name.

@stevenwinship stevenwinship self-assigned this May 13, 2024
@stevenwinship stevenwinship merged commit dae5ca7 into develop May 13, 2024
20 checks passed
@stevenwinship stevenwinship removed their assignment May 13, 2024
@pdurbin pdurbin added this to the 6.3 milestone May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pm.GREI-d-2.7.1 NIH, yr2, aim7, task1: R&D UI modules for creating datasets and supporting publishing workflows pm.GREI-d-2.7.2 NIH, yr2, aim7, task2: Implement UI modules for creating datasets and publishing workflows Size: 10 A percentage of a sprint. 7 hours. SPA These changes are required for the Dataverse SPA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extend the API to expose the dataset creation fields configured in the General Information page
5 participants