Skip to content

feat: default access form selection implementation#1127

Open
ChrisiSailer wants to merge 5 commits into
masterfrom
fix/solve_access_form_assignment_to_new_resources
Open

feat: default access form selection implementation#1127
ChrisiSailer wants to merge 5 commits into
masterfrom
fix/solve_access_form_assignment_to_new_resources

Conversation

@ChrisiSailer
Copy link
Copy Markdown
Contributor

@ChrisiSailer ChrisiSailer commented Mar 27, 2026

Description:

This change allows users to use a default access form during resource registration, based on the most commonly used form within the selected organization.

Checklist:

Make sure you tick all the boxes below if they are true or do not apply before you ask for review

Required for all pull requests:

  • I have performed a self-review of my code
  • I have made my code as simple as possible
  • I have removed all commented code
  • I have described the PR and added a meaningful title in the Conventional Commits format
    If applicable to this PR:
  • I have added relevant tests for my changes and the code coverage has not dropped substantially
  • I have updated the documentation in all relevant places (Javadoc, Swagger, MDs...)

@ChrisiSailer ChrisiSailer self-assigned this Mar 27, 2026
Copilot AI review requested due to automatic review settings March 27, 2026 15:10
Copy link
Copy Markdown
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

Implements backend-driven defaulting of accessForm during resource registration (using the organization’s most common access form, with a system fallback), and surfaces the chosen access form in the organization resource list UI.

Changes:

  • Make “Access Form” optional in the resource creation modal (frontend).
  • Default accessForm on resource creation when omitted, backed by a new repository query (backend).
  • Expose accessForm on resource representations used in organization/network resource listings and add integration tests.

Reviewed changes

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

Show a summary per file
File Description
frontend/src/components/governance/CreateResourceModal.vue Removes “required” semantics for Access Form so submission can rely on backend defaulting.
frontend/src/components/OrganizationListItem.vue Displays the access form name (or “None assigned”) for each resource.
backend/src/test/java/eu/bbmri_eric/negotiator/governance/resource/ResourceControllerTests.java Adds integration tests covering default access form behavior.
backend/src/main/java/eu/bbmri_eric/negotiator/governance/resource/dto/ResourceWithRepsDTO.java Adds accessForm field to resource DTO used in expanded org/network views.
backend/src/main/java/eu/bbmri_eric/negotiator/governance/resource/dto/ResourceCreateDTO.java Makes accessFormId optional by removing @NotNull.
backend/src/main/java/eu/bbmri_eric/negotiator/governance/resource/ResourceServiceImpl.java Applies defaulting logic when accessFormId is missing/zero.
backend/src/main/java/eu/bbmri_eric/negotiator/form/repository/AccessFormRepository.java Adds native query to find the most common access form per organization.

Comment thread frontend/src/components/governance/CreateResourceModal.vue
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.06%. Comparing base (21c6431) to head (377a5db).

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1127      +/-   ##
============================================
+ Coverage     86.04%   86.06%   +0.01%     
- Complexity     2312     2316       +4     
============================================
  Files           291      291              
  Lines          6442     6450       +8     
  Branches        402      402              
============================================
+ Hits           5543     5551       +8     
  Misses          645      645              
  Partials        254      254              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@konradlang konradlang linked an issue Mar 30, 2026 that may be closed by this pull request
.orElseThrow(
() -> new AccessFormNotFoundException(DEFAULT_ACCESS_FORM_ID)));
} else {
accessForm =
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If we could try to reduce the queries to the database that would be great as well. This logic could be in a loop of lots of resources with a relatively small amount of access forms and organizations, but they are queried all the time. I see that this behavior was preexisting and we could address it in a separate issue as well.
Code for improving the performance here could look something like:

...
    Map<Long, AccessForm> accessFormById = new HashMap<>();
    Map<Long, AccessForm> fallbackAccessFormByOrganization = new HashMap<>();
    Map<Long, DiscoveryService> discoveryServiceById = new HashMap<>();

    for (ResourceCreateDTO resDTO : resourcesCreateDTO) {
      DiscoveryService discoveryService = discoveryServiceById.computeIfAbsent(resDTO.getDiscoveryServiceId(),
          id ->
            discoveryServiceRepository
                .findById(id)
                .orElseThrow(
                    () -> new DiscoveryServiceNotFoundException(id)));
      AccessForm accessForm;
      if (resDTO.getAccessFormId() == null) {
        accessForm = fallbackAccessFormByOrganization.computeIfAbsent(
              resDTO.getOrganizationId(),
              orgId ->
                  accessFormRepository
                      .findFirstMostCommonAccessFormByOrganization(orgId)
                      .orElseGet(() -> getAccessFormById(accessFormById, DEFAULT_ACCESS_FORM_ID));
      } else {
        accessForm = getAccessFormById(accessFormById, resDTO.getAccessFormId());
      }
...

Comment thread frontend/src/components/governance/CreateResourceModal.vue Outdated
@sonarqubecloud
Copy link
Copy Markdown

@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown
Collaborator

@stetsche stetsche left a comment

Choose a reason for hiding this comment

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

Looking good now @ChrisiSailer ! Just some minor comments.

+ "ORDER BY COUNT(r.id) DESC "
+ "LIMIT 1",
nativeQuery = true)
Optional<AccessForm> findFirstMostCommonAccessFormByOrganization(Long organizationId);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Some unit tests for the repository to test more cases then covered in the integration test would be great, but not a blocker.

@sonarqubecloud
Copy link
Copy Markdown

@sonarqubecloud
Copy link
Copy Markdown

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Solve access form assignment to new resources

4 participants