Skip to content

Import export study#194

Open
ghazwarhili wants to merge 4 commits into
mainfrom
import-export-study
Open

Import export study#194
ghazwarhili wants to merge 4 commits into
mainfrom
import-export-study

Conversation

@ghazwarhili

Copy link
Copy Markdown
Contributor

PR Summary

@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Modification DTOs gain support for extracting referenced filter and load-flow-parameter UUIDs and embedding their resolved content for export. ModificationInfos provides default no-op implementations; BalancesAdjustmentModificationInfos, ByFormulaModificationInfos, and ModificationByAssignmentInfos override them. FilterInfos gains a filterContent field, and tests are updated for its expanded constructor.

Changes

Referenced data embedding

Layer / File(s) Summary
Base contract and embedded field definitions
src/main/java/org/gridsuite/modification/dto/ModificationInfos.java, src/main/java/org/gridsuite/modification/dto/FilterInfos.java
ModificationInfos adds default @JsonIgnore methods getReferencedFilterUuids(), getReferencedLoadFlowParametersUuids() (empty lists) and a no-op embedReferencedData(...); FilterInfos adds a filterContent field serialized only when non-null.
BalancesAdjustmentModificationInfos overrides
src/main/java/org/gridsuite/modification/dto/BalancesAdjustmentModificationInfos.java
Adds a loadFlowParameters field and overrides to expose the referenced load-flow-parameters UUID and populate loadFlowParameters from a supplied map.
ByFormulaModificationInfos overrides
src/main/java/org/gridsuite/modification/dto/ByFormulaModificationInfos.java
Overrides traverse formulaInfosList and nested filters to collect referenced filter UUIDs and set each filter's content from a supplied map, handling null lists safely.
ModificationByAssignmentInfos overrides and test fixture updates
src/main/java/org/gridsuite/modification/dto/ModificationByAssignmentInfos.java, src/test/java/.../AbstractModificationByAssignmentTest.java, src/test/java/.../GeneratorModificationByAssignmentTest.java, src/test/java/.../AbstractByFormulaModificationTest.java
Overrides traverse assignmentInfosList and nested filters to collect referenced filter UUIDs and embed filter content; related tests updated to use the new three-argument FilterInfos constructor.

Suggested reviewers: benrejebmoh, Mathieu-Deharbe

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title is very generic and does not describe the specific code changes in the pull request. Use a concise title that names the main change, such as adding import/export support for referenced data in modification DTOs.
Description check ❓ Inconclusive The description is only a placeholder template and does not meaningfully describe the changeset. Replace the template text with a short summary of what changed and why, including the main affected DTOs and tests.
✅ Passed checks (3 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

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.

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

♻️ Duplicate comments (2)
src/main/java/org/gridsuite/modification/dto/ByFormulaModificationInfos.java (1)

74-87: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Same NPE risk on filters map as flagged on the base contract.

filters.get(ref.getId()) (Line 84) assumes filters is non-null.

🤖 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/modification/dto/ByFormulaModificationInfos.java`
around lines 74 - 87, The embedReferencedData method in
ByFormulaModificationInfos still assumes the filters map is non-null when
resolving references. Update the stream/forEach logic to guard against a null
filters argument before calling filters.get(ref.getId()), or skip setting
filterContent when the map is absent, while keeping the existing
formulaInfosList and getFilters() null checks intact.
src/main/java/org/gridsuite/modification/dto/BalancesAdjustmentModificationInfos.java (1)

95-106: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

NPE risk if lfParams is null.

lfParams.get(loadFlowParametersId) (Line 104) will throw NullPointerException if the caller passes a null map, since only the presence of loadFlowParametersId is checked, not lfParams itself. This mirrors the same pattern flagged in ModificationInfos.embedReferencedData — see that comment for the base-contract concern.

🤖 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/modification/dto/BalancesAdjustmentModificationInfos.java`
around lines 95 - 106, The embedReferencedData method in
BalancesAdjustmentModificationInfos can throw a NullPointerException because it
dereferences lfParams without checking it first. Update embedReferencedData to
guard both loadFlowParametersId and lfParams before calling lfParams.get(...),
and only assign loadFlowParameters when the map is present. Keep the behavior
consistent with the base embedReferencedData contract and the null-safe pattern
used elsewhere in ModificationInfos.
🧹 Nitpick comments (2)
src/main/java/org/gridsuite/modification/dto/FilterInfos.java (1)

35-37: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider excluding filterContent from toString().

FilterInfos carries @ToString (class-level), and filterContent can hold a full nested AbstractFilter payload. Since ByFormulaModificationInfos/ModificationByAssignmentInfos use @ToString(callSuper = true) and nest FilterInfos inside lists, any incidental toString() call (e.g., in exception messages or debug logs) could produce very large/verbose output once this field is populated during export.

♻️ Suggested exclusion
     `@JsonInclude`(JsonInclude.Include.NON_NULL)
     `@Schema`(description = "embedded filter content (populated only on export)")
+    `@ToString.Exclude`
     private AbstractFilter filterContent;
🤖 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/modification/dto/FilterInfos.java` around lines
35 - 37, `FilterInfos` currently includes `filterContent` in the
Lombok-generated `toString()`, which can make logs and exception messages
extremely verbose when nested under `ByFormulaModificationInfos` or
`ModificationByAssignmentInfos`. Update the class-level `@ToString` handling on
`FilterInfos` so `filterContent` is excluded from the generated string output,
while keeping the field itself intact for export serialization.
src/main/java/org/gridsuite/modification/dto/ByFormulaModificationInfos.java (1)

64-87: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicate traversal logic with ModificationByAssignmentInfos.

getReferencedFilterUuids()/embedReferencedData() here are structurally identical to the overrides in ModificationByAssignmentInfos (stream → flatMap over a null-safe filter list → extract/set on FilterInfos). Consider extracting a shared static helper (e.g., in ModificationInfos or a new utility) parameterized by a Function that maps an element to its List<FilterInfos>, to avoid maintaining two copies of the same logic.

♻️ Example shared helper sketch
// e.g. in ModificationInfos or a shared utility class
protected static <T> List<UUID> extractFilterUuids(List<T> items, Function<T, List<FilterInfos>> filtersGetter) {
    return items == null ? List.of() : items.stream()
            .flatMap(i -> filtersGetter.apply(i) == null ? Stream.empty() : filtersGetter.apply(i).stream())
            .map(FilterInfos::getId)
            .filter(Objects::nonNull)
            .toList();
}

protected static <T> void embedFilterContent(List<T> items, Function<T, List<FilterInfos>> filtersGetter, Map<UUID, AbstractFilter> filters) {
    if (items == null) {
        return;
    }
    items.stream()
            .flatMap(i -> filtersGetter.apply(i) == null ? Stream.empty() : filtersGetter.apply(i).stream())
            .forEach(ref -> {
                if (ref.getId() != null) {
                    ref.setFilterContent(filters.get(ref.getId()));
                }
            });
}
🤖 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/modification/dto/ByFormulaModificationInfos.java`
around lines 64 - 87, Both getReferencedFilterUuids() and embedReferencedData()
in ByFormulaModificationInfos duplicate the same null-safe filter traversal
logic already present in ModificationByAssignmentInfos. Extract that
stream/flatMap/map/embed behavior into a shared helper in ModificationInfos or a
small utility, parameterized by a Function that returns each item’s
List<FilterInfos>, and update both overrides to delegate to it so the two
classes stay consistent and only one copy of the traversal needs maintenance.
🤖 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.

Duplicate comments:
In
`@src/main/java/org/gridsuite/modification/dto/BalancesAdjustmentModificationInfos.java`:
- Around line 95-106: The embedReferencedData method in
BalancesAdjustmentModificationInfos can throw a NullPointerException because it
dereferences lfParams without checking it first. Update embedReferencedData to
guard both loadFlowParametersId and lfParams before calling lfParams.get(...),
and only assign loadFlowParameters when the map is present. Keep the behavior
consistent with the base embedReferencedData contract and the null-safe pattern
used elsewhere in ModificationInfos.

In
`@src/main/java/org/gridsuite/modification/dto/ByFormulaModificationInfos.java`:
- Around line 74-87: The embedReferencedData method in
ByFormulaModificationInfos still assumes the filters map is non-null when
resolving references. Update the stream/forEach logic to guard against a null
filters argument before calling filters.get(ref.getId()), or skip setting
filterContent when the map is absent, while keeping the existing
formulaInfosList and getFilters() null checks intact.

---

Nitpick comments:
In
`@src/main/java/org/gridsuite/modification/dto/ByFormulaModificationInfos.java`:
- Around line 64-87: Both getReferencedFilterUuids() and embedReferencedData()
in ByFormulaModificationInfos duplicate the same null-safe filter traversal
logic already present in ModificationByAssignmentInfos. Extract that
stream/flatMap/map/embed behavior into a shared helper in ModificationInfos or a
small utility, parameterized by a Function that returns each item’s
List<FilterInfos>, and update both overrides to delegate to it so the two
classes stay consistent and only one copy of the traversal needs maintenance.

In `@src/main/java/org/gridsuite/modification/dto/FilterInfos.java`:
- Around line 35-37: `FilterInfos` currently includes `filterContent` in the
Lombok-generated `toString()`, which can make logs and exception messages
extremely verbose when nested under `ByFormulaModificationInfos` or
`ModificationByAssignmentInfos`. Update the class-level `@ToString` handling on
`FilterInfos` so `filterContent` is excluded from the generated string output,
while keeping the field itself intact for export serialization.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 183fb5bf-a8ab-4db1-894e-0032520c121e

📥 Commits

Reviewing files that changed from the base of the PR and between 08e5f73 and dfd41ff.

📒 Files selected for processing (8)
  • src/main/java/org/gridsuite/modification/dto/BalancesAdjustmentModificationInfos.java
  • src/main/java/org/gridsuite/modification/dto/ByFormulaModificationInfos.java
  • src/main/java/org/gridsuite/modification/dto/FilterInfos.java
  • src/main/java/org/gridsuite/modification/dto/ModificationByAssignmentInfos.java
  • src/main/java/org/gridsuite/modification/dto/ModificationInfos.java
  • src/test/java/org/gridsuite/modification/modifications/byfilter/assignment/AbstractModificationByAssignmentTest.java
  • src/test/java/org/gridsuite/modification/modifications/byfilter/assignment/GeneratorModificationByAssignmentTest.java
  • src/test/java/org/gridsuite/modification/modifications/byfilter/formula/AbstractByFormulaModificationTest.java

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