-
Notifications
You must be signed in to change notification settings - Fork 534
adding type and dvObject to dataverse featured items #11499
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
Merged
ofahimIQSS
merged 28 commits into
develop
from
11414-add-dvobject-type-to-featured-items
Jun 3, 2025
Merged
Changes from 18 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
4a4c4f4
adding type and dvObject to dataverse featured items
stevenwinship 8c471f5
fix checkstyle
stevenwinship f6d6af5
fix
stevenwinship 0f89799
fix unit test
stevenwinship d81129d
add back a test
stevenwinship 35c6935
Merge branch 'develop' into 11414-add-dvobject-type-to-featured-items
stevenwinship 7eb2f4c
Merge branch 'develop' into 11414-add-dvobject-type-to-featured-items
stevenwinship 4134f22
comment fixes
stevenwinship de4ada4
adding user permission check
stevenwinship de2c6ce
Update src/main/java/propertyFiles/Bundle.properties
stevenwinship ebf37b8
Update src/test/java/edu/harvard/iq/dataverse/api/DataversesIT.java
stevenwinship a3ef7c1
Update src/test/java/edu/harvard/iq/dataverse/api/DataversesIT.java
stevenwinship f8d515e
Update src/main/java/edu/harvard/iq/dataverse/dataverse/featured/Data…
stevenwinship 95c0cd9
Update src/main/java/edu/harvard/iq/dataverse/dataverse/featured/Data…
stevenwinship 19f8997
Update doc/release-notes/11414-add-dvobject-type-to-featured-items.md
stevenwinship 88c5162
Update src/test/java/edu/harvard/iq/dataverse/engine/command/impl/Cre…
stevenwinship f640917
fixed mismatch error and added test
stevenwinship def04e9
add happy test
stevenwinship 88a7dab
refactor
stevenwinship 0b20ecd
Merge branch 'develop' into 11414-add-dvobject-type-to-featured-items
stevenwinship 5b01135
Update src/main/java/propertyFiles/Bundle.properties
stevenwinship 2b98b14
allow content to be null if not type custom
stevenwinship ba2ab06
remove filter code and delete item if restricted or deaccessioned
stevenwinship efefc4b
fix unit test
stevenwinship 16e6582
fix unit test
stevenwinship c372496
fix test with content null
stevenwinship d6bc940
rename findByDvoOrDie to include the type check
stevenwinship 0b14812
rename findByDvoOrDie to include the type check
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
7 changes: 7 additions & 0 deletions
7
doc/release-notes/11414-add-dvobject-type-to-featured-items.md
This file contains hidden or 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,7 @@ | ||
| ### Feature: Added dvObject and type fields to Featured Items | ||
|
|
||
| Dataverse Featured Items can now be linked to Dataverses, Datasets, or Datafiles. | ||
|
|
||
| Pre-existing featured items as well as new items without dvObjects will be defaulted to type=custom. | ||
|
|
||
| Featured Items with dvObjects will be filtered out of lists if the dvObject should not be viewed (i.e. datafiles that are restricted or datasets that are deaccessioned) |
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -1218,9 +1218,13 @@ The ``file`` parameter must be specified for each image we want to attach to fea | |
|
|
||
| The ``id`` parameter must be ``0`` for new items or set to the item's identifier for updates. The ``fileName`` parameter should be empty to exclude an image or match the name of a file sent in a ``file`` parameter to set a new image. ``keepFile`` must always be set to ``false``, unless it's an update to a featured item where we want to preserve the existing image, if one exists. | ||
|
|
||
| The ``type`` and ``dvObject`` parameters are optional. These allow you to link the featured item to a Dataverse, Dataset, or Datafile. | ||
| The ``dvObject`` can be passed as the id or the persistent identifier and the ``type`` must be passed as either "dataverse", "dataset", or "datafile", depending on the type of object. | ||
| If no ``dvObject`` is passed the ``type`` will default to "custom" designating no linked object. | ||
|
|
||
| Note that any existing featured item not included in the call with its associated identifier and corresponding properties will be removed from the collection. | ||
|
|
||
| The following example creates two featured items, with an image assigned to the second one: | ||
| The following example creates two featured items, with an image and a dataset assigned to the second one: | ||
|
|
||
| .. code-block:: bash | ||
|
|
||
|
|
@@ -1234,6 +1238,8 @@ The following example creates two featured items, with an image assigned to the | |
| export SECOND_ITEM_IMAGE_FILENAME='image.png' | ||
| export SECOND_ITEM_CONTENT='Content 2' | ||
| export SECOND_ITEM_DISPLAY_ORDER=2 | ||
| export SECOND_ITEM_TYPE="dataset" | ||
| export SECOND_ITEM_DVOBJECT="doi:ZZ7/MOSEISLEYDB94" | ||
|
|
||
| curl -H "X-Dataverse-key:$API_TOKEN" \ | ||
| -X PUT \ | ||
|
|
@@ -1243,6 +1249,8 @@ The following example creates two featured items, with an image assigned to the | |
| -F "fileName=" -F "fileName=$SECOND_ITEM_IMAGE_FILENAME" \ | ||
| -F "keepFile=false" -F "keepFile=false" \ | ||
| -F "file=@$SECOND_ITEM_IMAGE_FILENAME" \ | ||
| -F "type=" -F "type=@$SECOND_ITEM_TYPE" \ | ||
| -F "dvObject=" -F "dvObject=@$SECOND_ITEM_DVOBJECT" \ | ||
| "$SERVER_URL/api/dataverses/$ID/featuredItems" | ||
|
|
||
|
|
||
|
|
@@ -1258,9 +1266,11 @@ The fully expanded example above (without environment variables) looks like this | |
| -F "fileName=" -F "fileName=image.png" \ | ||
| -F "keepFile=false" -F "keepFile=false" \ | ||
| -F "[email protected]" \ | ||
| -F "type=" -F "type=dataset" \ | ||
| -F "dvObject=" -F "dvObject=doi:ZZ7/MOSEISLEYDB94" \ | ||
| "https://demo.dataverse.org/api/dataverses/root/featuredItems" | ||
|
|
||
| The following example creates one featured item and updates a second one, keeping the existing image it may have had: | ||
| The following example creates one featured item and updates a second one, keeping the existing image it may have had but removes the dataset link and defaults the type to "custom": | ||
|
|
||
| .. code-block:: bash | ||
|
|
||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
63 changes: 63 additions & 0 deletions
63
src/main/java/edu/harvard/iq/dataverse/api/dto/AbstractDataverseFeaturedItemDTO.java
This file contains hidden or 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,63 @@ | ||
| package edu.harvard.iq.dataverse.api.dto; | ||
|
|
||
| import edu.harvard.iq.dataverse.DataFile; | ||
| import edu.harvard.iq.dataverse.Dataset; | ||
| import edu.harvard.iq.dataverse.Dataverse; | ||
| import edu.harvard.iq.dataverse.DvObject; | ||
| import edu.harvard.iq.dataverse.dataverse.featured.DataverseFeaturedItem; | ||
|
|
||
| import java.io.InputStream; | ||
|
|
||
| public abstract class AbstractDataverseFeaturedItemDTO { | ||
| protected String content; | ||
| protected int displayOrder; | ||
| protected InputStream imageFileInputStream; | ||
| protected String imageFileName; | ||
| protected String type; | ||
| protected DvObject dvObject; | ||
|
|
||
| public void setContent(String content) { | ||
| this.content = content; | ||
| } | ||
|
|
||
| public String getContent() { | ||
| return content; | ||
| } | ||
|
|
||
| public void setDisplayOrder(int displayOrder) { | ||
| this.displayOrder = displayOrder; | ||
| } | ||
|
|
||
| public int getDisplayOrder() { | ||
| return displayOrder; | ||
| } | ||
|
|
||
| public void setImageFileInputStream(InputStream imageFileInputStream) { | ||
| this.imageFileInputStream = imageFileInputStream; | ||
| } | ||
|
|
||
| public InputStream getImageFileInputStream() { | ||
| return imageFileInputStream; | ||
| } | ||
|
|
||
| public void setImageFileName(String imageFileName) { | ||
| this.imageFileName = imageFileName; | ||
| } | ||
|
|
||
| public String getImageFileName() { | ||
| return imageFileName; | ||
| } | ||
|
|
||
| public void setType(String type) { | ||
| this.type = type; | ||
| } | ||
| public String getType() { | ||
| return type; | ||
| } | ||
| public void setDvObject(DvObject dvObject) { | ||
| this.dvObject = dvObject; | ||
| } | ||
| public DvObject getDvObject() { | ||
| return dvObject; | ||
| } | ||
| } |
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.
This method mixes two responsibilities: searching for a dvObject and validating the related featured item type. I'm not asking you to refactor it right now, but at least, please rename the method.
findDvoOrDiesounds too generic — it's specific to featured items and could easily be accidentally used outside the scope of featured items.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.
renamed