Skip to content

Populate element names for result's variation id#171

Open
thangqp wants to merge 11 commits into
mainfrom
populate_element_names_result_variation_id
Open

Populate element names for result's variation id#171
thangqp wants to merge 11 commits into
mainfrom
populate_element_names_result_variation_id

Conversation

@thangqp
Copy link
Copy Markdown

@thangqp thangqp commented May 13, 2026

PR Summary

Back to the solution which uses the directory client service to resolve element names for the variationId in the result

[uuid1, uuid2] (REGULAR) => [name1, name2] (REGULAR)

Signed-off-by: Thang PHAM <phamthang37@gmail.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 13, 2026

Review Change Stack

Warning

Rate limit exceeded

@thangqp has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 16 minutes and 12 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 07dce196-9e8d-44db-a71b-e92cd024a308

📥 Commits

Reviewing files that changed from the base of the PR and between 8eebba5 and 608b38b.

📒 Files selected for processing (3)
  • src/main/java/org/gridsuite/sensitivityanalysis/server/service/DirectoryService.java
  • src/main/java/org/gridsuite/sensitivityanalysis/server/util/ResultUtils.java
  • src/test/java/org/gridsuite/sensitivityanalysis/server/service/DirectoryServiceTest.java
📝 Walkthrough

Walkthrough

Adds ResultUtils for UUID extraction/formatting/resolution, a DirectoryService to fetch element names, applies a varId setter on SensitivityOfTo, refactors builder usage to call ResultUtils, and integrates UUID→name resolution into SensitivityAnalysisService result population.

Changes

UUID Resolution and Variation ID Formatting

Layer / File(s) Summary
Variation ID utility methods
src/main/java/org/gridsuite/sensitivityanalysis/server/util/ResultUtils.java, src/test/java/org/gridsuite/sensitivityanalysis/server/util/ResultUtilsTest.java
ResultUtils adds regex-based UUID extraction, resolveForVariationId to replace UUIDs with names from a map, formatVariationId and joinToStringIds; tests cover extraction, resolution, formatting, joining, and round-trip behavior.
SensitivityOfTo varId setter
src/main/java/org/gridsuite/sensitivityanalysis/server/dto/SensitivityOfTo.java
Adds Lombok @Setter to the varId field to permit writing resolved names into DTOs.
Directory service for element name lookup
src/main/java/org/gridsuite/sensitivityanalysis/server/service/DirectoryService.java, src/main/resources/application-local.yaml
New Spring @Service that calls GET {baseUri}/v1/elements/names with ids and strictMode=false, returning Map<UUID,String> or an empty map on errors/empty input; local config provides a base-uri.
SensitivityAnalysisInputBuilderService variation ID formatting
src/main/java/org/gridsuite/sensitivityanalysis/server/service/SensitivityAnalysisInputBuilderService.java
Refactors to use ResultUtils.formatVariationId and joinToStringIds; intermediate grouping now carries List<UUID> filter IDs instead of preformatted strings.
SensitivityAnalysisService UUID resolution integration
src/main/java/org/gridsuite/sensitivityanalysis/server/service/SensitivityAnalysisService.java
Constructor now accepts DirectoryService; new private helper extracts UUIDs from sensitivities, fetches names via DirectoryService, and rewrites varIds using ResultUtils.resolveForVariationId; helper is invoked in getRunResult.

Sequence Diagrams

sequenceDiagram
  participant Client
  participant SensitivityAnalysisService
  participant Repository as Result Repository
  participant ResultUtils
  participant DirectoryService
  Client->>SensitivityAnalysisService: getRunResult(runId)
  SensitivityAnalysisService->>Repository: fetch SensitivityRunQueryResult
  Repository-->>SensitivityAnalysisService: SensitivityRunQueryResult
  SensitivityAnalysisService->>ResultUtils: extractUuidsFromVariationId(varId)
  ResultUtils-->>SensitivityAnalysisService: List<UUID>
  SensitivityAnalysisService->>DirectoryService: getElementNames(uuids)
  DirectoryService-->>SensitivityAnalysisService: Map<UUID,String> names
  SensitivityAnalysisService->>ResultUtils: resolveForVariationId(varId, names)
  ResultUtils-->>SensitivityAnalysisService: resolved varId
  SensitivityAnalysisService-->>Client: return enriched result
Loading

Suggested reviewers

  • antoinebhs
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 30.56% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and accurately describes the main change: populating element names for the result's variation ID, which aligns with the changeset's core objective.
Description check ✅ Passed The description is directly related to the changeset, explaining the transformation from UUID lists to element names while preserving variation types.
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.

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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: 2

🤖 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/DirectoryService.java`:
- Around line 61-71: The directory lookup currently catches only
HttpClientErrorException and assumes restTemplate.exchange(...).getBody() is
non-null; update the try/catch in DirectoryService around the
restTemplate.exchange call to catch RestClientException (the common base for
HttpClientErrorException, HttpServerErrorException, ResourceAccessException,
etc.) and after calling getBody() check for null—if getBody() is null or an
exception is thrown, return Map.of() to preserve the graceful fallback behavior.

In
`@src/main/java/org/gridsuite/sensitivityanalysis/server/service/SensitivityAnalysisService.java`:
- Line 175: The call to populateResultWithElementNames is duplicating work
because getRunResult already enriches the result with element names; remove the
redundant populateResultWithElementNames invocation in the CSV export path (the
call at the location where you currently call populateResultWithElementNames
after getRunResult) so the export uses the already-enriched result returned by
getRunResult, or alternatively guard the call so it only runs when getRunResult
did not perform enrichment.
🪄 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: b3a97fe4-ed5f-4135-aa18-73cb7b4d84f1

📥 Commits

Reviewing files that changed from the base of the PR and between 5e64f1f and 46b3786.

📒 Files selected for processing (6)
  • src/main/java/org/gridsuite/sensitivityanalysis/server/dto/SensitivityOfTo.java
  • src/main/java/org/gridsuite/sensitivityanalysis/server/service/DirectoryService.java
  • src/main/java/org/gridsuite/sensitivityanalysis/server/service/SensitivityAnalysisInputBuilderService.java
  • src/main/java/org/gridsuite/sensitivityanalysis/server/service/SensitivityAnalysisService.java
  • src/main/java/org/gridsuite/sensitivityanalysis/server/util/ResultUtils.java
  • src/main/resources/application-local.yaml

thangqp and others added 10 commits May 13, 2026 22:39
Signed-off-by: Thang PHAM <phamthang37@gmail.com>
Signed-off-by: Thang PHAM <phamthang37@gmail.com>
…/DirectoryService.java


Good for me

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
…/SensitivityAnalysisService.java


Good for me

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Signed-off-by: Thang PHAM <phamthang37@gmail.com>
Signed-off-by: Thang PHAM <phamthang37@gmail.com>
Removed UUID_REGEX constant from SensitivityAnalysisService.
…riation_id' into populate_element_names_result_variation_id
Signed-off-by: Thang PHAM <phamthang37@gmail.com>
@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.

1 participant