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

Updates the updateDataverse API endpoint to support cases where an "inherit from parent" configuration is desired #11026

Merged
merged 8 commits into from
Nov 26, 2024

Conversation

GPortas
Copy link
Contributor

@GPortas GPortas commented Nov 18, 2024

What this PR does / why we need it:

The updateDataverse API endpoint has been updated to support an "inherit from parent" configuration for metadata blocks, facets, and input levels.

When it comes to omitting any of these fields in the request JSON:

  • Omitting facetIds or metadataBlockNames causes the Dataverse collection to inherit the corresponding configuration from its parent.
  • Omitting inputLevels removes any existing input levels in the Dataverse collection.

Previously, not setting these fields meant keeping the existing ones in the Dataverse.

Which issue(s) this PR closes:

Special notes for your reviewer:

I have applied this behavior only to the updateDataverse endpoint, preserving the previous behavior of the UpdateDataverseCommand in other places for backwards compatibility.

Suggestions on how to test this:

  1. Create a Dataverse.
  2. Download https://github.com/IQSS/dataverse/blob/develop/doc/sphinx-guides/source/_static/api/dataverse-complete-optional-params.json
  3. Test updating the created Dataverse by submitting different versions of the previous JSON. (Including the fields mentioned above / not including them)

curl -H "X-Dataverse-key:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -X PUT "http://localhost:8080/api/dataverses/dvAlias" --upload-file update-dataverse.json
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

This comment has been minimized.

@GPortas GPortas changed the title Update Dataverse API relations reset when passing null metadata blocks and/or facets and/or input levels Fixes updateDataverse API endpoint when metadata blocks, facets, or input levels are not set in the request body Nov 18, 2024

This comment has been minimized.

@GPortas GPortas changed the title Fixes updateDataverse API endpoint when metadata blocks, facets, or input levels are not set in the request body Updates the updateDataverse API endpoint to support cases where an "inherit from parent" configuration is desired Nov 18, 2024

This comment has been minimized.

@GPortas GPortas added User Role: API User Makes use of APIs Size: 3 A percentage of a sprint. 2.1 hours. SPA These changes are required for the Dataverse SPA GREI Re-arch Issues related to the GREI Dataverse rearchitecture Original size: 3 SPA.Q4.3 Edit Collection Page labels Nov 18, 2024
@GPortas GPortas marked this pull request as ready for review November 18, 2024 16:49

This comment has been minimized.

@@ -118,11 +118,18 @@ The fully expanded example above (without environment variables) looks like this

You should expect an HTTP 200 response and JSON beginning with "status":"OK" followed by a representation of the updated Dataverse collection.

Same as in :ref:`create-dataverse-api`, the request JSON supports an optional ``metadataBlocks`` object, with the following supported sub-objects:
Same as in :ref:`create-dataverse-api`, the request JSON supports a ``metadataBlocks`` object, with the following supported sub-objects:
Copy link
Contributor

Choose a reason for hiding this comment

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

Can I omit the metadataBlocks object now? (just wondering why you took out the optional here.) And if so, how would that be handled?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, thanks for noticing because it wasn’t properly explained. I’ve mentioned again that it’s optional and added a note explaining what happens if metadataBlocks is not sent in the JSON.


private void processInputLevels(CommandContext ctxt) {
if (inputLevels != null) {
if (!inputLevels.isEmpty()) {
dataverse.addInputLevelsMetadataBlocksIfNotPresent(inputLevels);
}
ctxt.fieldTypeInputLevels().deleteFacetsFor(dataverse);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we deleting facets in process input levels?

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 name of the method is a bit tricky. They are not search facets, but input levels. Also, this behavior is the same as before; I have just relocated the code (See current develop: https://github.com/IQSS/dataverse/blob/develop/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/AbstractWriteDataverseCommand.java#L74).

}
});
} else if (resetRelationsOnNullValues) {
ctxt.fieldTypeInputLevels().deleteFacetsFor(dataverse);
Copy link
Contributor

Choose a reason for hiding this comment

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

Same question - does this belong in process input levels?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Answered in the comment above!

When it comes to omitting any of these fields in the request JSON:

- Omitting ``facetIds`` or ``metadataBlockNames`` causes the Dataverse collection to inherit the corresponding configuration from its parent.
- Omitting ``inputLevels`` removes any existing input levels in the Dataverse collection.
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be better to say "removes any existing custom input levels" or "restores default input levels"?

@GPortas GPortas self-assigned this Nov 19, 2024
@GPortas GPortas added the FY25 Sprint 10 FY25 Sprint 10 (2024-11-06 - 2024-11-20) label Nov 19, 2024

This comment has been minimized.

This comment has been minimized.

@GPortas GPortas removed their assignment Nov 21, 2024

This comment has been minimized.

1 similar comment
Copy link

📦 Pushed preview images as

ghcr.io/gdcc/dataverse:11018-update-dataverse-fix
ghcr.io/gdcc/configbaker:11018-update-dataverse-fix

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

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.

Thanks for the updates/clarifications.

@sekmiller sekmiller removed their assignment Nov 21, 2024
@cmbz cmbz added the FY25 Sprint 11 FY25 Sprint 11 (2024-11-20 - 2024-12-04) label Nov 21, 2024
@ofahimIQSS ofahimIQSS self-assigned this Nov 21, 2024
@cmbz cmbz added this to the 6.5 milestone Nov 21, 2024
@ofahimIQSS
Copy link
Contributor

Testing of 11026.docx

No issues found during testing, Merging PR

@ofahimIQSS ofahimIQSS merged commit 1c17c3e into develop Nov 26, 2024
12 checks passed
@ofahimIQSS ofahimIQSS deleted the 11018-update-dataverse-fix branch November 26, 2024 17:48
@ofahimIQSS ofahimIQSS removed their assignment Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FY25 Sprint 10 FY25 Sprint 10 (2024-11-06 - 2024-11-20) FY25 Sprint 11 FY25 Sprint 11 (2024-11-20 - 2024-12-04) GREI Re-arch Issues related to the GREI Dataverse rearchitecture Original size: 3 Size: 3 A percentage of a sprint. 2.1 hours. SPA.Q4.3 Edit Collection Page SPA These changes are required for the Dataverse SPA User Role: API User Makes use of APIs
Projects
Status: Done 🧹
Development

Successfully merging this pull request may close these issues.

Update Dataverse API endpoint unexpected behavior
4 participants