Skip to content

Set node column position when creation#995

Open
SlimaneAmar wants to merge 3 commits into
mainfrom
set_node_column_position_when_creation
Open

Set node column position when creation#995
SlimaneAmar wants to merge 3 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

Warning

Rate limit exceeded

@SlimaneAmar has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 40 minutes and 28 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: f98e8926-cacb-4f1f-8344-5143a42c7611

📥 Commits

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

📒 Files selected for processing (1)
  • src/main/java/org/gridsuite/study/server/service/NetworkModificationTreeService.java
📝 Walkthrough

Walkthrough

This PR adds column position tracking for network modification tree nodes. Repository queries retrieve column positions and child UUIDs. The service now manages column positions during node insertion (CHILD/BEFORE/AFTER modes) and adjusts sibling positions as needed. Tests verify column position behavior across insertion, cut/paste, and duplication operations.

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

  • Meklo
  • AbdelHedhili
🚥 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 (only placeholder text), providing no meaningful information about the changeset. Add a detailed description explaining what changed, why it was needed, and any important implementation notes for reviewers.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Set node column position when creation' directly aligns with 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

@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