Skip to content

Conversation

@jp-tosca
Copy link
Contributor

What this PR does / why we need it:

Which issue(s) this PR closes:

Special notes for your reviewer:

Suggestions on how to test this:

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

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

Additional documentation:

@github-actions github-actions bot added Feature: API FY26 Sprint 10 FY26 Sprint 10 (2025-11-05 - 2025-11-19) FY26 Sprint 9 FY26 Sprint 9 (2025-10-22 - 2025-11-05) GREI Re-arch Issues related to the GREI Dataverse rearchitecture Original size: 10 Size: 10 A percentage of a sprint. 7 hours. SPA These changes are required for the Dataverse SPA SPA.Q3.2025.12 Dataset Templates Type: Feature a feature request labels Nov 18, 2025
@github-actions

This comment has been minimized.

@jp-tosca jp-tosca requested a review from Copilot November 18, 2025 17:56
@jp-tosca jp-tosca moved this to In Progress 💻 in IQSS Dataverse Project Nov 18, 2025
@jp-tosca jp-tosca self-assigned this Nov 18, 2025
Copilot finished reviewing on behalf of jp-tosca November 18, 2025 17:59
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements API endpoints to set and remove the default template for a dataverse collection, addressing issue #11914.

Key Changes:

  • Added POST /api/dataverses/{id}/templates/default/{templateId} endpoint to set a default template
  • Added DELETE /api/dataverses/{id}/templates/default endpoint to remove the default template
  • Added test coverage for the set default template endpoint with permission checks

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 9 comments.

File Description
src/main/java/edu/harvard/iq/dataverse/api/Dataverses.java Implements two new endpoints for setting and removing default templates
src/test/java/edu/harvard/iq/dataverse/api/UtilIT.java Adds helper methods setDefaultTemplate() and removeDefaultTemplate() for testing
src/test/java/edu/harvard/iq/dataverse/api/DataversesIT.java Updates testCreateAndGetTemplates() to test setting default template with authorization checks
doc/release-notes/11914-set-template-default-api.md Documents the new endpoints and their functionality

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jp-tosca jp-tosca requested a review from Copilot November 21, 2025 17:46
Copilot finished reviewing on behalf of jp-tosca November 21, 2025 17:48
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 7 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


### Functionality
- Sets the default template of the given dataverse collection.
- You must have edit dataset permission in the collection in order to use this endpoint.
Copy link

Copilot AI Nov 21, 2025

Choose a reason for hiding this comment

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

The permission requirement is incorrectly stated as "edit dataset permission" but should be "edit dataverse permission" or "edit collection permission". The command uses @RequiredPermissions(Permission.EditDataverse), not edit dataset permission.

Copilot uses AI. Check for mistakes.

### Functionality
- Removes the default template of the given dataverse collection.
- You must have edit dataset permission in the collection in order to use this endpoint.
Copy link

Copilot AI Nov 21, 2025

Choose a reason for hiding this comment

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

The permission requirement is incorrectly stated as "edit dataset permission" but should be "edit dataverse permission" or "edit collection permission". The command uses @RequiredPermissions(Permission.EditDataverse), not edit dataset permission.

Copilot uses AI. Check for mistakes.

@Override
public Template execute(CommandContext ctxt) throws CommandException {
dataverse.setDefaultTemplate(template);
Copy link

Copilot AI Nov 21, 2025

Choose a reason for hiding this comment

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

The command modifies the dataverse but doesn't persist the changes to the database. After calling dataverse.setDefaultTemplate(template), you should merge the dataverse entity using ctxt.em().merge(dataverse) to ensure the changes are persisted. See similar commands like CreateTemplateCommand (line 55) for reference.

Suggested change
dataverse.setDefaultTemplate(template);
dataverse.setDefaultTemplate(template);
ctxt.em().merge(dataverse);

Copilot uses AI. Check for mistakes.
@Override
public Dataverse execute(CommandContext ctxt) throws CommandException {
dataverse.setDefaultTemplate(null);
return dataverse;
Copy link

Copilot AI Nov 21, 2025

Choose a reason for hiding this comment

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

The command modifies the dataverse but doesn't persist the changes to the database. After calling dataverse.setDefaultTemplate(null), you should merge the dataverse entity using ctxt.em().merge(dataverse) to ensure the changes are persisted. See similar commands like CreateTemplateCommand (line 55) for reference.

Suggested change
return dataverse;
Dataverse mergedDataverse = ctxt.em().merge(dataverse);
return mergedDataverse;

Copilot uses AI. Check for mistakes.
- Sets the default template of the given dataverse collection.
- You must have edit dataset permission in the collection in order to use this endpoint.

## New Endpoint: DELETE `/dataverses/{id}/template/default`
Copy link

Copilot AI Nov 21, 2025

Choose a reason for hiding this comment

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

The endpoint path in the documentation uses /template/default (singular "template"), but based on the actual implementation in Dataverses.java the path is /templates/default (plural "templates"). Update the documentation to use the correct plural form: /dataverses/{id}/templates/default.

Copilot uses AI. Check for mistakes.
@cmbz cmbz added the FY26 Sprint 11 FY26 Sprint 11 (2025-11-20 - 2025-12-03) label Nov 22, 2025
@jp-tosca jp-tosca moved this from In Progress 💻 to Ready for Review ⏩ in IQSS Dataverse Project Nov 24, 2025
@jp-tosca jp-tosca removed their assignment Nov 24, 2025
@jp-tosca jp-tosca marked this pull request as ready for review November 24, 2025 18:46
@coveralls
Copy link

Coverage Status

coverage: 24.029% (-0.008%) from 24.037%
when pulling 924da37 on 11914-set-template-default
into b8f5c1e on develop.

@github-actions
Copy link

📦 Pushed preview images as

ghcr.io/gdcc/dataverse:11914-set-template-default
ghcr.io/gdcc/configbaker:11914-set-template-default

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

@sekmiller sekmiller self-assigned this Nov 25, 2025
@sekmiller sekmiller moved this from Ready for Review ⏩ to In Review 🔎 in IQSS Dataverse Project Nov 25, 2025

protected Template findTemplateOrDie(Long templateId, Dataverse dataverse) throws WrappedResponse {

Template template = dataverse.getTemplates().stream()
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need to take into account whether the dataverse is inheriting templates from its parents.

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.

@jp-tosca looks good generally - can you take a look at the handling of inherited templates in the find template or die method? thanks!

@cmbz cmbz added the FY26 Sprint 12 FY26 Sprint 12 (2025-12-03 - 2025-12-17) label Dec 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature: API FY26 Sprint 9 FY26 Sprint 9 (2025-10-22 - 2025-11-05) FY26 Sprint 10 FY26 Sprint 10 (2025-11-05 - 2025-11-19) FY26 Sprint 11 FY26 Sprint 11 (2025-11-20 - 2025-12-03) FY26 Sprint 12 FY26 Sprint 12 (2025-12-03 - 2025-12-17) GREI Re-arch Issues related to the GREI Dataverse rearchitecture Original size: 10 Size: 10 A percentage of a sprint. 7 hours. SPA.Q3.2025.12 Dataset Templates SPA These changes are required for the Dataverse SPA Type: Feature a feature request

Projects

Status: In Review 🔎

Development

Successfully merging this pull request may close these issues.

Add a new API to set a template as default

5 participants