import shared composites#830
Conversation
…ion-server into shared-modification
…ion-server into shared-modification
…ion-server into shared-modification
…ion-server into shared-modification
Signed-off-by: Mathieu DEHARBE <mathieu.deharbe@rte-france.com>
This comment was marked as low quality.
This comment was marked as low quality.
Signed-off-by: Mathieu DEHARBE <mathieu.deharbe@rte-france.com>
…ion-server into shared-modification
Signed-off-by: Mathieu DEHARBE <mathieu.deharbe@rte-france.com>
Signed-off-by: Mathieu DEHARBE <mathieu.deharbe@rte-france.com>
Signed-off-by: Mathieu DEHARBE <mathieu.deharbe@rte-france.com>
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
src/main/java/org/gridsuite/modification/server/repositories/NetworkModificationRepository.java (1)
717-723: ⚡ Quick winBatch-load references data instead of issuing one query per UUID.
Line 719–723 performs one
findByIdcall per UUID, which creates an N+1 query pattern for large requests. This endpoint is list-based; loading once withfindAllByIdIn(...)and then filtering in-memory will reduce DB round-trips.🤖 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/server/repositories/NetworkModificationRepository.java` around lines 717 - 723, The getReferencesData method is experiencing an N+1 query problem where each iteration of the loop calls findById on the modificationRepository for individual UUIDs. Instead of looping through modificationUuids and making separate findById calls, refactor this to use a single batch query by calling findAllByIdIn with the entire modificationUuids list. After retrieving all records at once, filter the results in-memory to identify which ones are not found (throw the exception if expected records are missing), and then apply the existing filtering logic checking for stashed status and ModificationReferenceEntity type. This approach reduces database round-trips from N queries to a single query.src/test/java/org/gridsuite/modification/server/service/ModificationIndexationTest.java (1)
311-318: ⚡ Quick winAdd coverage for the new shared-reference path.
This test only exercises
isShared=false(split behavior). The new shared insertion branch and reference lookup flow remain untested, so regressions in the new feature can pass unnoticed.🤖 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/test/java/org/gridsuite/modification/server/service/ModificationIndexationTest.java` around lines 311 - 318, The test in ModificationIndexationTest currently only covers the case where isShared is set to false in the CompositesToBeInserted constructor, leaving the new shared insertion branch and reference lookup flow untested. Add an additional test case or extend the existing test to also exercise the isShared=true path by creating another CompositesToBeInserted instance with isShared set to true, and verify that the splitCompositeModifications method correctly handles the shared reference behavior. This ensures that both the split behavior (isShared=false) and the shared insertion/reference lookup behavior (isShared=true) are properly tested to catch potential regressions.
🤖 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/modification/server/NetworkModificationController.java`:
- Around line 266-269: The issue is that the getNetworkModifications call on
line 266 only retrieves root-level modifications, missing references inside
composite children. To fix this, you need to modify the logic to include nested
modifications from composites in the netModUuids list before passing it to
getReferencesData. Either adjust the parameters passed to
getNetworkModifications to include composite children modifications, or add
logic to extract and collect all nested modification UUIDs from composite
modifications in addition to the root ones, ensuring that all modification UUIDs
(root and nested) are included in the referencesData mapping.
In
`@src/main/java/org/gridsuite/modification/server/repositories/NetworkModificationRepository.java`:
- Around line 967-994: The code casts to CompositeModificationInfos without type
validation on lines 972 and 986, which can cause ClassCastException if the UUID
refers to a non-composite modification. Additionally, when composite
modifications are not found, the shared branch silently skips them while the
non-shared branch only logs, both allowing partial inserts to succeed. Add
instanceof checks before both cast operations to validate the type, and throw an
exception (instead of returning null or continuing silently) when a required
composite modification cannot be found to ensure the operation fails completely
rather than succeeding partially.
---
Nitpick comments:
In
`@src/main/java/org/gridsuite/modification/server/repositories/NetworkModificationRepository.java`:
- Around line 717-723: The getReferencesData method is experiencing an N+1 query
problem where each iteration of the loop calls findById on the
modificationRepository for individual UUIDs. Instead of looping through
modificationUuids and making separate findById calls, refactor this to use a
single batch query by calling findAllByIdIn with the entire modificationUuids
list. After retrieving all records at once, filter the results in-memory to
identify which ones are not found (throw the exception if expected records are
missing), and then apply the existing filtering logic checking for stashed
status and ModificationReferenceEntity type. This approach reduces database
round-trips from N queries to a single query.
In
`@src/test/java/org/gridsuite/modification/server/service/ModificationIndexationTest.java`:
- Around line 311-318: The test in ModificationIndexationTest currently only
covers the case where isShared is set to false in the CompositesToBeInserted
constructor, leaving the new shared insertion branch and reference lookup flow
untested. Add an additional test case or extend the existing test to also
exercise the isShared=true path by creating another CompositesToBeInserted
instance with isShared set to true, and verify that the
splitCompositeModifications method correctly handles the shared reference
behavior. This ensures that both the split behavior (isShared=false) and the
shared insertion/reference lookup behavior (isShared=true) are properly tested
to catch potential regressions.
🪄 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: 3f451ef4-e13e-4818-895a-466c1eb11f5d
📒 Files selected for processing (6)
src/main/java/org/gridsuite/modification/server/CompositeController.javasrc/main/java/org/gridsuite/modification/server/NetworkModificationController.javasrc/main/java/org/gridsuite/modification/server/dto/CompositesToBeInserted.javasrc/main/java/org/gridsuite/modification/server/repositories/NetworkModificationRepository.javasrc/main/java/org/gridsuite/modification/server/service/NetworkModificationService.javasrc/test/java/org/gridsuite/modification/server/service/ModificationIndexationTest.java
Signed-off-by: Mathieu DEHARBE <mathieu.deharbe@rte-france.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/test/java/org/gridsuite/modification/server/CompositeControllerTest.java (1)
206-207: ⚡ Quick winAdd one
isShared=trueinsertion test to cover the new shared branch.In this file, updated insertion payloads only exercise
new CompositesToBeInserted(..., false). Adding oneINSERTcase withisShared=truewould directly lock behavior for shared composite imports and reference creation.🤖 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/test/java/org/gridsuite/modification/server/CompositeControllerTest.java` around lines 206 - 207, The current test cases for composite insertions in the CompositeControllerTest only exercise the isShared=false path when creating CompositesToBeInserted objects. Add a new INSERT test case that creates a composite modification payload using getJsonBodyModificationCompositeToBeInserted with CompositesToBeInserted constructed with isShared=true parameter instead of false, to ensure the shared composite import and reference creation logic is properly tested and locked.
🤖 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/test/java/org/gridsuite/modification/server/ModificationControllerTest.java`:
- Around line 1818-1819: In the CompositesToBeInserted constructor call on line
1818, replace the hardcoded string "composite" with the name parameter that is
passed to this helper method. This ensures the helper properly uses its name
argument and allows the call site to accurately validate that the name is being
propagated correctly through the composite insertion path.
---
Nitpick comments:
In
`@src/test/java/org/gridsuite/modification/server/CompositeControllerTest.java`:
- Around line 206-207: The current test cases for composite insertions in the
CompositeControllerTest only exercise the isShared=false path when creating
CompositesToBeInserted objects. Add a new INSERT test case that creates a
composite modification payload using
getJsonBodyModificationCompositeToBeInserted with CompositesToBeInserted
constructed with isShared=true parameter instead of false, to ensure the shared
composite import and reference creation logic is properly tested and locked.
🪄 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: 02c61ce7-0ec9-4c59-a433-46d1b55ae8c5
📒 Files selected for processing (4)
src/main/java/org/gridsuite/modification/server/NetworkModificationController.javasrc/test/java/org/gridsuite/modification/server/CompositeControllerTest.javasrc/test/java/org/gridsuite/modification/server/ModificationControllerTest.javasrc/test/java/org/gridsuite/modification/server/utils/TestUtils.java
🚧 Files skipped from review as they are similar to previous changes (1)
- src/main/java/org/gridsuite/modification/server/NetworkModificationController.java
Signed-off-by: Mathieu DEHARBE <mathieu.deharbe@rte-france.com>
Signed-off-by: Mathieu DEHARBE <mathieu.deharbe@rte-france.com>
Signed-off-by: Mathieu DEHARBE <mathieu.deharbe@rte-france.com>
Signed-off-by: Mathieu DEHARBE <mathieu.deharbe@rte-france.com>
|



Uh oh!
There was an error while loading. Please reload this page.