-
Notifications
You must be signed in to change notification settings - Fork 500
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
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2664077
Added: new resetRelationsOnNullValues boolean flag to AbstractWriteDa…
GPortas 2e71045
Added: IT cases for updateDataverse API endpoint
GPortas 6b908e8
Added: docs for #11018
GPortas 8c3cdaa
Added: release notes for #11018
GPortas e487241
Changed: docs and release note tweak for input levels
GPortas c28ece0
Merge branch 'develop' of github.com:IQSS/dataverse into 11018-update…
GPortas c7da932
Added: doc tweak related to excluding metadataBlocks in updateDataverse
GPortas b63b1ff
Added: doc tweak explaining metadataBlocks is optional in updateDatav…
GPortas 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
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,8 @@ | ||
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 custom input levels in the Dataverse collection. | ||
|
||
Previously, not setting these fields meant keeping the existing ones in the Dataverse. |
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 |
---|---|---|
|
@@ -19,13 +19,15 @@ abstract class AbstractWriteDataverseCommand extends AbstractCommand<Dataverse> | |
private final List<DataverseFieldTypeInputLevel> inputLevels; | ||
private final List<DatasetFieldType> facets; | ||
protected final List<MetadataBlock> metadataBlocks; | ||
private final boolean resetRelationsOnNullValues; | ||
|
||
public AbstractWriteDataverseCommand(Dataverse dataverse, | ||
Dataverse affectedDataverse, | ||
DataverseRequest request, | ||
List<DatasetFieldType> facets, | ||
List<DataverseFieldTypeInputLevel> inputLevels, | ||
List<MetadataBlock> metadataBlocks) { | ||
List<MetadataBlock> metadataBlocks, | ||
boolean resetRelationsOnNullValues) { | ||
super(request, affectedDataverse); | ||
this.dataverse = dataverse; | ||
if (facets != null) { | ||
|
@@ -43,42 +45,60 @@ public AbstractWriteDataverseCommand(Dataverse dataverse, | |
} else { | ||
this.metadataBlocks = null; | ||
} | ||
this.resetRelationsOnNullValues = resetRelationsOnNullValues; | ||
} | ||
|
||
@Override | ||
public Dataverse execute(CommandContext ctxt) throws CommandException { | ||
dataverse = innerExecute(ctxt); | ||
|
||
processMetadataBlocks(); | ||
processFacets(ctxt); | ||
processInputLevels(ctxt); | ||
|
||
return ctxt.dataverses().save(dataverse); | ||
} | ||
|
||
private void processMetadataBlocks() { | ||
if (metadataBlocks != null && !metadataBlocks.isEmpty()) { | ||
dataverse.setMetadataBlockRoot(true); | ||
dataverse.setMetadataBlocks(metadataBlocks); | ||
} else if (resetRelationsOnNullValues) { | ||
dataverse.setMetadataBlockRoot(false); | ||
dataverse.clearMetadataBlocks(); | ||
} | ||
} | ||
|
||
private void processFacets(CommandContext ctxt) { | ||
if (facets != null) { | ||
ctxt.facets().deleteFacetsFor(dataverse); | ||
|
||
if (!facets.isEmpty()) { | ||
dataverse.setFacetRoot(true); | ||
} | ||
|
||
int i = 0; | ||
for (DatasetFieldType df : facets) { | ||
ctxt.facets().create(i++, df, dataverse); | ||
for (int i = 0; i < facets.size(); i++) { | ||
ctxt.facets().create(i, facets.get(i), dataverse); | ||
} | ||
} else if (resetRelationsOnNullValues) { | ||
ctxt.facets().deleteFacetsFor(dataverse); | ||
dataverse.setFacetRoot(false); | ||
} | ||
} | ||
|
||
private void processInputLevels(CommandContext ctxt) { | ||
if (inputLevels != null) { | ||
if (!inputLevels.isEmpty()) { | ||
dataverse.addInputLevelsMetadataBlocksIfNotPresent(inputLevels); | ||
} | ||
ctxt.fieldTypeInputLevels().deleteFacetsFor(dataverse); | ||
for (DataverseFieldTypeInputLevel inputLevel : inputLevels) { | ||
inputLevels.forEach(inputLevel -> { | ||
inputLevel.setDataverse(dataverse); | ||
ctxt.fieldTypeInputLevels().create(inputLevel); | ||
} | ||
}); | ||
} else if (resetRelationsOnNullValues) { | ||
ctxt.fieldTypeInputLevels().deleteFacetsFor(dataverse); | ||
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. Same question - does this belong in process input levels? 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. Answered in the comment above! |
||
} | ||
|
||
return ctxt.dataverses().save(dataverse); | ||
} | ||
|
||
abstract protected Dataverse innerExecute(CommandContext ctxt) throws IllegalCommandException; | ||
|
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.
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.
Why are we deleting facets in process input levels?
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.
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).