Skip to content

Set node column position when creation#995

Open
SlimaneAmar wants to merge 5 commits into
mainfrom
set_node_column_position_when_creation
Open

Set node column position when creation#995
SlimaneAmar wants to merge 5 commits into
mainfrom
set_node_column_position_when_creation

Conversation

@SlimaneAmar
Copy link
Copy Markdown
Contributor

PR Summary

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 20, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 22dfe04e-9b64-424e-a789-dd8394f98813

📥 Commits

Reviewing files that changed from the base of the PR and between ca9a746 and 065ac86.

📒 Files selected for processing (1)
  • src/main/java/org/gridsuite/study/server/service/NetworkModificationTreeService.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/java/org/gridsuite/study/server/service/NetworkModificationTreeService.java

📝 Walkthrough

Walkthrough

Adds column-position tracking: repository queries expose column positions and child UUIDs; service returns node-info and computes/assigns columnPosition for CHILD/BEFORE/AFTER insertions; tests updated to assert columnPosition across insertion, cut/paste, and duplication flows.

Changes

Column Position Tracking for Network Modification Nodes

Layer / File(s) Summary
Repository Queries for Column Positions
src/main/java/org/gridsuite/study/server/repository/networkmodificationtree/NetworkModificationNodeInfoRepository.java, src/main/java/org/gridsuite/study/server/repository/networkmodificationtree/NodeRepository.java
Add findColumnPositionsByUuidIn() JPQL query and findChildrenUuids() native SQL query to support column position lookups and sibling enumeration during node operations.
Service Refactoring: Node Creation and Insertion with Column Positions
src/main/java/org/gridsuite/study/server/service/NetworkModificationTreeService.java
Refactor createNetworkModificationNode() to return the node-info entity after persisting it. Rewrite createAndInsertNode() to compute and assign column positions based on insert mode (CHILD, BEFORE, AFTER) and adjust referenced/sibling positions. Introduce getNextColumnPosition() helper and update duplicateNode() call signature.
Test Infrastructure and Unit Tests
src/test/java/org/gridsuite/study/server/studycontroller/StudyTestBase.java, src/test/java/org/gridsuite/study/server/NetworkModificationTreeTest.java
Update StudyTestBase.createNetworkModificationNode() to return freshly fetched node instead of constructed instance. Add unit test assertions in testNodeInsertion() and testInsertAfter() to verify column position sets before/after insertions and across node hierarchies.
Integration Tests: Cut/Paste and Duplication
src/test/java/org/gridsuite/study/server/studycontroller/NodeControllerTest.java
Update all cut/paste and duplication test cases to use getAllStudyNodesByUuid() and verify columnPosition values, replacing prior parent/child stream filtering. Adjust expected tree diagrams and assertions to match new column-position layout verification across testCutAndPasteNode(), testCutAndPasteSubtree(), testDuplicateNode(), and testDuplicateSubtree().

Suggested Reviewers

  • flomillot
  • Meklo
🚥 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 pull request description is empty (only contains a placeholder), providing no actual information about the changes. Add a meaningful description explaining what the PR does, why it was needed, and any important notes for reviewers.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Set node column position when creation' directly describes the main change: implementing column position assignment during node creation and duplication.
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

🤖 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/study/server/service/NetworkModificationTreeService.java`:
- Around line 151-159: getNextColumnPosition currently computes next sibling
columnPosition in-memory using
networkModificationNodeInfoRepository.findColumnPositionsByUuidIn(nodesRepository.findChildrenUuids(parentNodeId))
and returns max+1, which is race-prone; change it to perform the max calculation
inside a single transactional DB operation (e.g. a repository method that runs
SELECT MAX(column_position) FROM ... WHERE parent_id = :parentNodeId FOR UPDATE
or an equivalent DB-side atomic increment) or add a unique constraint on
(parent_id, column_position) and implement a retry-on-constraint-violation
strategy; ensure the new repository method is used in getNextColumnPosition and
that the surrounding service call is annotated/handled with a transaction to
prevent concurrent duplicates.
🪄 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: 243a4303-d277-4f19-a49a-beb510f44a97

📥 Commits

Reviewing files that changed from the base of the PR and between b07c75b and ca9a746.

📒 Files selected for processing (6)
  • src/main/java/org/gridsuite/study/server/repository/networkmodificationtree/NetworkModificationNodeInfoRepository.java
  • src/main/java/org/gridsuite/study/server/repository/networkmodificationtree/NodeRepository.java
  • src/main/java/org/gridsuite/study/server/service/NetworkModificationTreeService.java
  • src/test/java/org/gridsuite/study/server/NetworkModificationTreeTest.java
  • src/test/java/org/gridsuite/study/server/studycontroller/NodeControllerTest.java
  • src/test/java/org/gridsuite/study/server/studycontroller/StudyTestBase.java

@ayolab ayolab self-requested a review May 26, 2026 06:16
Slimane AMAR added 2 commits June 1, 2026 14:31
…into set_node_column_position_when_creation
…into set_node_column_position_when_creation
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Jun 3, 2026

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