Skip to content

Conversation

@Saixel
Copy link
Contributor

@Saixel Saixel commented Feb 6, 2025

Please note: this pull request was reverted by #11306. Stay tuned for a new pull request that implements similar functionality.

What this PR does / why we need it:

This PR introduces the displayOnCreate property to the DataverseFieldTypeInputLevel class, allowing administrators to configure metadata fields to appear during dataset creation, even if they are not required.

Previously, metadata fields selected for a collection would only appear during dataset creation if they were marked as required (or displayOnCreate by default). This change grants collection administrators control over metadata visibility, improving metadata completeness and discoverability.

Which issue(s) this PR closes:

Special notes for your reviewer:

This PR implements the functionality for displayOnCreate, but the UI implementation is not included yet.

The implementation includes:

  • New property displayOnCreate in DataverseFieldTypeInputLevel
  • API endpoint to update the displayOnCreate setting
  • Integration tests to verify the functionality

Testing via API:

  1. Create a test collection:
curl -X POST -H "X-Dataverse-key: YOUR_API_KEY" -H "Content-Type: application/json" \
-d '{
  "name": "Test Collection",
  "alias": "test-collection",
  "dataverseContacts": [{"contactEmail": "[email protected]"}],
  "metadataBlockIds": ["citation", "socialscience"]
}' \
http://localhost:8080/api/dataverses/:root
  1. Configure a field to display on create:
curl -X PUT -H "X-Dataverse-key: YOUR_API_KEY" -H "Content-Type: application/json" \
-d '[
  {
    "datasetFieldTypeName": "unitOfAnalysis",
    "required": false,
    "include": true,
    "displayOnCreate": true
  }
]' \
http://localhost:8080/api/dataverses/test-collection/inputLevels
  1. Create a dataset in the collection and verify that the field appears in the creation form.

Automated Tests:

Run the integration test:

mvn test -Dtest=DataversesIT#testUpdateInputLevelDisplayOnCreate

Does this PR introduce a user interface change?:

No UI changes in this PR. A separate issue will track the UI implementation.

Additional documentation:

image
image

Preview docs at https://dataverse-guide--11224.org.readthedocs.build/en/11224/api/native-api.html#update-collection-input-levels

- Added updateDisplayOnCreate method to DataversePage
- Added displayOnCreate handling in DataverseServiceBean
- Added displayOnCreate checkbox to dataverse.xhtml
- Added displayOnCreate field to DataverseFieldTypeInputLevel
- Remove javadoc comment from updateDisplayOnCreate method in DataversePage.java
- Remove inline comment from displayOnCreate setter in DataverseServiceBean.java
- Remove selector changes from dataverse.xhtml as they will be implemented in a separate task focusing on UI improvements
@Saixel Saixel added NIH CAFE Issues related to and/or funded by the NIH CAFE project FY25 Sprint 16 FY25 Sprint 16 (2025-01-29 - 2025-02-12) labels Feb 6, 2025
@coveralls
Copy link

coveralls commented Feb 6, 2025

Coverage Status

coverage: 22.724% (-0.01%) from 22.736%
when pulling 4625a3a on 10476-display-on-create-field-option
into 2210d16 on develop.

@github-actions

This comment has been minimized.

@stevenwinship stevenwinship self-assigned this Feb 11, 2025
@cmbz cmbz added the FY25 Sprint 17 FY25 Sprint 17 (2025-02-12 - 2025-02-26) label Feb 12, 2025
…ructor

- Modified constructor to require displayOnCreate parameter
- Updated all constructor calls to pass the correct displayOnCreate value
@github-actions

This comment has been minimized.

- Update displayOnCreate handling in MetadataBlockServiceBean
- Refactor predicates for better input level handling
- Add default value handling for displayOnCreate
- Update service methods to consider input level configuration
- Add displayOnCreate check method in Dataverse
- Update displayOnCreate handling in DatasetPage
- Add save method for input levels in service
- Update template handling for displayOnCreate
- Improve code formatting
@stevenwinship
Copy link
Contributor

Please address the merge conflicts along with the review comments. Thanks

@ofahimIQSS
Copy link
Contributor

This PR has a merge conflict.

@github-actions

This comment has been minimized.

@Saixel
Copy link
Contributor Author

Saixel commented Feb 21, 2025

@stevenwinship @ofahimIQSS I have added all the adjustments and the test.
I have also finished resolving the conflicts.
Let me know if any adjustments are needed!

@ofahimIQSS ofahimIQSS self-assigned this Feb 24, 2025
@cmbz cmbz added this to the 6.6 milestone Feb 26, 2025
@ofahimIQSS
Copy link
Contributor

This PR has branch conflicts - can you please resolve. Thanks!

Copy link
Member

@pdurbin pdurbin left a comment

Choose a reason for hiding this comment

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

I'm late to reviewing this but @Saixel please take a look.

@cmbz cmbz added the FY25 Sprint 18 FY25 Sprint 18 (2025-02-26 - 2025-03-12) label Feb 27, 2025
- Add release note snippet for displayOnCreate field feature
- Update API documentation to clarify displayOnCreate behavior
@github-actions

This comment has been minimized.

Copy link
Member

@pdurbin pdurbin 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 docs! Some more feedback for you.

@github-actions

This comment has been minimized.

1 similar comment
@github-actions
Copy link

📦 Pushed preview images as

ghcr.io/gdcc/dataverse:10476-display-on-create-field-option
ghcr.io/gdcc/configbaker:10476-display-on-create-field-option

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

@ofahimIQSS
Copy link
Contributor

no issues found during testing - merging PR

@ofahimIQSS ofahimIQSS merged commit 55d53dd into develop Feb 27, 2025
11 of 12 checks passed
@github-project-automation github-project-automation bot moved this from QA ✅ to Merged 🚀 in IQSS Dataverse Project Feb 27, 2025
@ofahimIQSS ofahimIQSS deleted the 10476-display-on-create-field-option branch February 27, 2025 18:49
@qqmyers qqmyers restored the 10476-display-on-create-field-option branch February 27, 2025 21:27
@scolapasta scolapasta moved this from Merged 🚀 to Done 🧹 in IQSS Dataverse Project Mar 4, 2025
@pdurbin
Copy link
Member

pdurbin commented Mar 4, 2025

Flyway script added in this PR:


boolean required = inputLevel.getBoolean("required");
boolean include = inputLevel.getBoolean("include");
boolean displayOnCreate = inputLevel.getBoolean("displayOnCreate", false);
Copy link
Member

Choose a reason for hiding this comment

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

If the input JSON doesn't have displayOnCreate, then the field will be set to not displayOnCreate regardless of the default setting? Should this default to null, and the subquery in MetadataBlockServiceBean line 66 get adjusted to only return 1 if displayOnCreate is not null? Otherwise, I think a call to this method that doesn't set displayOnCreate explicitly will cause the default to be overridden. (Not sure I see if/how this could be affecting the tests though).

@Saixel
Copy link
Contributor Author

Saixel commented Mar 5, 2025

Hey team! I executed the tests related to the displayOnCreate functionality and found some discrepancies between the reported errors (#11298) and what I am currently seeing.

Originally Reported Failed Tests:

  1. DatasetTypesIT.testLinkInstrumentToAstro:

    • Error: data[0].name expected "citation" but is "astrophysics"
  2. DatasetTypesIT.testUpdateDatasetTypeLinksWithMetadataBlocks:

    • Error: data[0].name expected "citation" but is null
  3. DataversesIT.testListMetadataBlocks:

    • Error: data[0].fields.size() expected 10 but is 5
  4. DataversesIT.testUpdateInputLevelDisplayOnCreate:

    • Error: data.size() expected 1 but is 0
  5. MetadataBlocksIT.testListMetadataBlocks:

    • Error: data[0].displayName expected "Citation Metadata" but is null

Failed Tests We Are Currently Seeing:

  1. DatasetTypesIT.testLinkInstrumentToAstro:

    • Error: data[1].fields.astroInstrument.displayOnCreate expected true but is null
    • Context: The test expects the astroInstrument field in the astrophysics metadata block to have displayOnCreate set to true, but it's returning null. Looking at the astrophysics.tsv file, we can see that this field is defined with displayoncreate=FALSE. The test seems to expect this to be true, but the implementation is respecting the value from the TSV file.
  2. DatasetTypesIT.testUpdateDatasetTypeLinksWithMetadataBlocks and DataversesIT.testListMetadataBlocks:

    • Error: data[0].fields.size() expected 10 but is 5
    • Context: Both tests expect 10 fields in the metadata block, but only 5 are being returned. Looking at the response, we can see that only the following Required by Dataverse fields are present:
      • title
      • author
      • datasetContact
      • dsDescription
      • subject
    • The implementation is currently only returning fields that have displayOnCreate=true. This is happening because the query in MetadataBlockServiceBean.listMetadataBlocksDisplayedOnCreate() is filtering fields based on this property. We need to confirm if:
      a) The endpoint should return all fields of the block, regardless of their displayOnCreate value
      b) Or if it should only return fields with displayOnCreate=true (current behavior)
    • If the endpoint should return all fields, we need to identify which additional fields should be included in the response
    • If the current behavior is correct, we need to update the tests to expect only the fields with displayOnCreate=true
  3. DataversesIT.testUpdateInputLevelDisplayOnCreate:

    • Error: data.size() expected 1 but is 0
    • Context: The test expects at least one metadata block to be returned when querying with displayOnCreate=true, but no blocks are being returned. This suggests that either:
      a) No blocks have any fields with displayOnCreate=true
      b) The filtering logic in MetadataBlockServiceBean.listMetadataBlocksDisplayedOnCreate() is not working as expected
      c) The test's expectations about which blocks should be returned need to be adjusted
  4. MetadataBlocksIT.testListMetadataBlocks:

    • Error: data.size() expected 1 but is 2
    • Context: The test expects only one metadata block to be returned, but we're getting two blocks:
      • citation (with fields)
      • geospatial (with empty fields)
    • The implementation is returning all metadata blocks, but the test seems to expect only blocks with displayOnCreate=true or with specific criteria.

Identified Discrepancies:

  1. The errors related to the order and presence of the "citation" block are not reproducing
  2. The errors we are seeing are more related to:
    • The size of fields in metadata blocks
    • The displayOnCreate property of the astroInstrument field
    • The total number of metadata blocks being returned

Questions:

  1. Regarding astroInstrument.displayOnCreate:

    • Should this field be displayed on create by default?
    • Should we modify the astrophysics.tsv file to set displayoncreate=TRUE?
    • Or should the test be updated to expect FALSE?
  2. Regarding the number of fields (5 vs 10):

    • Is the current filtering of fields intentional?
    • Should we include all fields regardless of their properties?
    • Are there specific criteria that determine which fields should be included?
  3. Regarding testUpdateInputLevelDisplayOnCreate:

    • What is the expected behavior when no blocks have displayOnCreate=true?
    • Should we modify the filtering logic or update the test expectations?
  4. Regarding testListMetadataBlocks:

    • Should we return all metadata blocks or only those with specific criteria?
    • What determines which blocks should be included in the response?

@pdurbin
Copy link
Member

pdurbin commented Mar 5, 2025

  1. Should we modify the astrophysics.tsv file to set displayoncreate=TRUE?

No, it's being changed in the database by this line:

// displayOnCreate will only be true for fields that are set this way in the database.
// We set it here so we can make assertions below.
UtilIT.setDisplayOnCreate("astroInstrument", true);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

FY25 Sprint 16 FY25 Sprint 16 (2025-01-29 - 2025-02-12) FY25 Sprint 17 FY25 Sprint 17 (2025-02-12 - 2025-02-26) FY25 Sprint 18 FY25 Sprint 18 (2025-02-26 - 2025-03-12) NIH CAFE Issues related to and/or funded by the NIH CAFE project

Projects

Status: Done 🧹

Development

Successfully merging this pull request may close these issues.

Ensure Visibility of Non-Required Metadata Blocks on Dataset Creation

8 participants