Skip to content

add filter names in results#173

Draft
carojeandat wants to merge 1 commit into
mainfrom
add-filters-names-in-results
Draft

add filter names in results#173
carojeandat wants to merge 1 commit into
mainfrom
add-filters-names-in-results

Conversation

@carojeandat
Copy link
Copy Markdown
Contributor

PR Summary

@carojeandat carojeandat marked this pull request as draft May 22, 2026 13:50
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 22, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

This PR enhances the sensitivity analysis server to surface and use human-readable names for contingencies and filters in reports. A new service method aggregates available contingency lists and filter identifiers, a new controller endpoint exposes them, the input builder threads these names through all sensitivity construction paths to replace raw IDs in reports, and the REST API now accepts and passes the names map to the builder.

Changes

Sensitivity Analysis Naming Enhancement

Layer / File(s) Summary
Filter aggregation service
src/main/java/org/gridsuite/sensitivityanalysis/server/service/SensitivityAnalysisParametersService.java, src/main/java/org/gridsuite/sensitivityanalysis/server/SensitivityAnalysisParametersController.java
New getContingencyListsAndFiltersParameters(UUID) service method collects contingency lists and monitor identifiers from all defined sensitivity sections and returns them as a combined list. New GET /{uuid}/contingency-lists-and-filters controller endpoint exposes this via REST.
Input builder names map threading
src/main/java/org/gridsuite/sensitivityanalysis/server/service/SensitivityAnalysisInputBuilderService.java
Public build(...) method now accepts contingencyListNamesMap parameter and propagates it through all internal builder methods (buildSensitivityInjectionsSets, buildSensitivityInjections, buildSensitivityHVDCs, buildSensitivityPSTs, buildSensitivityNodes) so contingency-related reporting remains consistent.
Contingency and filter naming logic
src/main/java/org/gridsuite/sensitivityanalysis/server/service/SensitivityAnalysisInputBuilderService.java
Contingency and identifiables lookup helpers accept the names map to resolve IDs to human-readable names. Filter naming refactored from joinToStringIds to getFilterNames, producing bracketed resolved names. Report nodes now attach resolved names under the NAME key instead of raw ID strings, and warnings in filter and monitored-equipment translation paths use the resolved names.
REST endpoint parameter
src/main/java/org/gridsuite/sensitivityanalysis/server/SensitivityAnalysisController.java
Run-and-save endpoint now accepts elementNamesMap request parameter of type Map<UUID, String>. Added java.util.Map import.
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The PR description is empty with no content provided, making it impossible to assess whether it relates to the changeset. Provide a meaningful description explaining the motivation, approach, and impact of adding filter names in results for reviewers.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'add filter names in results' is directly related to the main change, which involves threading contingencyListNamesMap through the codebase to enrich report nodes with human-readable filter and contingency names.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/main/java/org/gridsuite/sensitivityanalysis/server/SensitivityAnalysisController.java (1)

112-124: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

elementNamesMap is accepted but never propagated.

At Line 112 the endpoint accepts the names map, but it is not used in Line 114-124. This makes the new contract ineffective and breaks the intended end-to-end name enrichment for run-and-save.

🧩 Suggested direction
- UUID resultUuid = service.runAndSaveResult(runContext);
+ UUID resultUuid = service.runAndSaveResult(runContext, elementNamesMap);

(plus corresponding signature propagation in downstream service/context layers)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/main/java/org/gridsuite/sensitivityanalysis/server/SensitivityAnalysisController.java`
around lines 112 - 124, The endpoint accepts elementNamesMap but never forwards
it into the run context; update SensitivityAnalysisController to pass
elementNamesMap into sensitivityAnalysisParametersService.createRunContext (and
then into SensitivityAnalysisRunContext), and propagate that new field through
any downstream methods (e.g.,
SensitivityAnalysisParametersService.createRunContext,
SensitivityAnalysisRunContext constructor/fields and service.runAndSaveResult)
by adding the parameter to their signatures and using it when building the
context so the name enrichment flows end-to-end.
🧹 Nitpick comments (2)
src/main/java/org/gridsuite/sensitivityanalysis/server/service/SensitivityAnalysisInputBuilderService.java (1)

286-286: ⚡ Quick win

Remove temporary/debug comments before merge.

Line 286 and Line 313 contain temporary/debug notes that should not stay in production code.

Also applies to: 313-313

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/main/java/org/gridsuite/sensitivityanalysis/server/service/SensitivityAnalysisInputBuilderService.java`
at line 286, Remove the temporary/debug comments left in the
SensitivityAnalysisInputBuilderService source (the French notes about "vérifier
ce qu'il y a dans les varaibleSets" and the other debug note around the same
area) before merging; locate them inside the
SensitivityAnalysisInputBuilderService class (the method building or validating
input sets) and delete those inline comments or replace them with a concise,
production-ready TODO or proper Javadoc if a follow-up task is required.
src/main/java/org/gridsuite/sensitivityanalysis/server/service/SensitivityAnalysisParametersService.java (1)

165-197: ⚡ Quick win

Deduplicate aggregated UUIDs before returning.

The current aggregation can return duplicates, which adds avoidable payload and redundant downstream name-resolution calls.

♻️ Suggested change
-        List<UUID> contingencyListsAndFiltersUuids = new ArrayList<>();
+        Set<UUID> contingencyListsAndFiltersUuids = new LinkedHashSet<>();
...
-        return contingencyListsAndFiltersUuids;
+        return new ArrayList<>(contingencyListsAndFiltersUuids);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/main/java/org/gridsuite/sensitivityanalysis/server/service/SensitivityAnalysisParametersService.java`
around lines 165 - 197, The aggregated UUID list contingencyListsAndFiltersUuids
in SensitivityAnalysisParametersService can contain duplicates; change the
aggregation to deduplicate before returning by either collecting into a
LinkedHashSet (to preserve insertion order) instead of an ArrayList or by
converting the List to a stream and applying distinct() (e.g.,
contingencyListsAndFiltersUuids.stream().distinct().collect(...)); ensure the
returned collection remains a List<UUID> if callers expect it (convert the Set
back to a List) and keep references to the same variables:
contingencyListsAndFiltersUuids and the parameter sources like
getSensitivityInjectionsSet(), getSensitivityInjection(), getSensitivityHVDC(),
getSensitivityPST(), getSensitivityNodes().
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@src/main/java/org/gridsuite/sensitivityanalysis/server/service/SensitivityAnalysisParametersService.java`:
- Around line 162-164: The method getContingencyListsAndFiltersParameters in
SensitivityAnalysisParametersService currently throws IllegalArgumentException
when no parameters are found; change this to throw a
SensitivityAnalysisException with the appropriate business code (e.g.,
FILTERS_OR_CONTINGENCIES_LISTS_NOT_FOUND or a new NOT_FOUND code) and a
descriptive message so the existing SensitivityAnalysisExceptionHandler maps it
to a 404; locate the empty-check for parameters in
SensitivityAnalysisParametersService and replace the IllegalArgumentException
with a SensitivityAnalysisException instance carrying the correct business code
and message.

---

Outside diff comments:
In
`@src/main/java/org/gridsuite/sensitivityanalysis/server/SensitivityAnalysisController.java`:
- Around line 112-124: The endpoint accepts elementNamesMap but never forwards
it into the run context; update SensitivityAnalysisController to pass
elementNamesMap into sensitivityAnalysisParametersService.createRunContext (and
then into SensitivityAnalysisRunContext), and propagate that new field through
any downstream methods (e.g.,
SensitivityAnalysisParametersService.createRunContext,
SensitivityAnalysisRunContext constructor/fields and service.runAndSaveResult)
by adding the parameter to their signatures and using it when building the
context so the name enrichment flows end-to-end.

---

Nitpick comments:
In
`@src/main/java/org/gridsuite/sensitivityanalysis/server/service/SensitivityAnalysisInputBuilderService.java`:
- Line 286: Remove the temporary/debug comments left in the
SensitivityAnalysisInputBuilderService source (the French notes about "vérifier
ce qu'il y a dans les varaibleSets" and the other debug note around the same
area) before merging; locate them inside the
SensitivityAnalysisInputBuilderService class (the method building or validating
input sets) and delete those inline comments or replace them with a concise,
production-ready TODO or proper Javadoc if a follow-up task is required.

In
`@src/main/java/org/gridsuite/sensitivityanalysis/server/service/SensitivityAnalysisParametersService.java`:
- Around line 165-197: The aggregated UUID list contingencyListsAndFiltersUuids
in SensitivityAnalysisParametersService can contain duplicates; change the
aggregation to deduplicate before returning by either collecting into a
LinkedHashSet (to preserve insertion order) instead of an ArrayList or by
converting the List to a stream and applying distinct() (e.g.,
contingencyListsAndFiltersUuids.stream().distinct().collect(...)); ensure the
returned collection remains a List<UUID> if callers expect it (convert the Set
back to a List) and keep references to the same variables:
contingencyListsAndFiltersUuids and the parameter sources like
getSensitivityInjectionsSet(), getSensitivityInjection(), getSensitivityHVDC(),
getSensitivityPST(), getSensitivityNodes().
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: dff692d3-0c13-41c3-8ddc-cd78d7587149

📥 Commits

Reviewing files that changed from the base of the PR and between ee2259b and e51ae17.

📒 Files selected for processing (4)
  • src/main/java/org/gridsuite/sensitivityanalysis/server/SensitivityAnalysisController.java
  • src/main/java/org/gridsuite/sensitivityanalysis/server/SensitivityAnalysisParametersController.java
  • src/main/java/org/gridsuite/sensitivityanalysis/server/service/SensitivityAnalysisInputBuilderService.java
  • src/main/java/org/gridsuite/sensitivityanalysis/server/service/SensitivityAnalysisParametersService.java

Comment on lines +162 to +164
if (parameters.isEmpty()) {
throw new IllegalArgumentException("No parameters found for parametersUuid: " + parametersUuid);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify whether IllegalArgumentException is mapped to HTTP 404 in this codebase
rg -n --type=java "(`@ControllerAdvice`|`@ExceptionHandler`|IllegalArgumentException|HttpStatus\.NOT_FOUND|ResponseStatusException)"

Repository: gridsuite/sensitivity-analysis-server

Length of output: 2014


Throw a semantic “not found” exception for missing parametersUuid instead of IllegalArgumentException.

SensitivityAnalysisParametersService#getContingencyListsAndFiltersParameters throws IllegalArgumentException when parameters is empty (line 163). SensitivityAnalysisExceptionHandler is the only @ControllerAdvice hit and it maps only SensitivityAnalysisException business codes (including FILTERS_OR_CONTINGENCIES_LISTS_NOT_FOUND → 404); there is no handler mapping IllegalArgumentException to HTTP 404. Use SensitivityAnalysisException (or a dedicated not-found code) for missing parametersUuid to align with the endpoint’s 404 behavior.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/main/java/org/gridsuite/sensitivityanalysis/server/service/SensitivityAnalysisParametersService.java`
around lines 162 - 164, The method getContingencyListsAndFiltersParameters in
SensitivityAnalysisParametersService currently throws IllegalArgumentException
when no parameters are found; change this to throw a
SensitivityAnalysisException with the appropriate business code (e.g.,
FILTERS_OR_CONTINGENCIES_LISTS_NOT_FOUND or a new NOT_FOUND code) and a
descriptive message so the existing SensitivityAnalysisExceptionHandler maps it
to a 404; locate the empty-check for parameters in
SensitivityAnalysisParametersService and replace the IllegalArgumentException
with a SensitivityAnalysisException instance carrying the correct business code
and message.

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.

1 participant