Add Line segments infos into database for line creation#787
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughA new JPA entity Changes
Sequence Diagram(s)mermaid 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@src/main/java/org/gridsuite/modification/server/entities/equipment/creation/LineCreationEntity.java`:
- Around line 44-49: LineCreationEntity currently maps the
List<LineSegmentEntity> lineSegments without preserving order; update the
mapping on lineSegments to add an `@OrderColumn` (e.g., `@OrderColumn`(name =
"line_segments_order") or similar) so the list index is persisted and round-trip
order is stable, and explicitly set the join table name in the `@JoinTable` (e.g.,
name = "line_creation_line_segments") rather than relying on Hibernate defaults
so Liquibase schema matches; keep the existing joinColumns, inverseJoinColumns
and uniqueConstraints but move them into the explicitly named `@JoinTable` and
ensure the OrderColumn column name does not conflict with existing constraints.
In
`@src/main/java/org/gridsuite/modification/server/entities/equipment/creation/LineSegmentEntity.java`:
- Around line 66-75: fromLineSegmentsEntity currently dereferences its input
list and will NPE if lineSegmentEntities is null; make it null-safe by returning
Collections.emptyList() (or new ArrayList<>()) when lineSegmentEntities is null,
otherwise map each LineSegmentEntity to a LineSegmentInfos as it does now,
updating the method body in fromLineSegmentsEntity to check for null before
iterating; this mirrors the null-safety in toLineSegmentEntities and avoids
breaking LineCreationEntity.toLineCreationInfosBuilder.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: e37c68b4-5f4e-4f48-8d9e-95d0b0d7429d
📒 Files selected for processing (4)
pom.xmlsrc/main/java/org/gridsuite/modification/server/entities/equipment/creation/LineCreationEntity.javasrc/main/java/org/gridsuite/modification/server/entities/equipment/creation/LineSegmentEntity.javasrc/main/resources/db/changelog/db.changelog-master.yaml
Signed-off-by: basseche <bassel.el-cheikh_externe@rte-france.com>
c09f515 to
5ff3748
Compare
There was a problem hiding this comment.
♻️ Duplicate comments (1)
src/main/java/org/gridsuite/modification/server/entities/equipment/creation/LineCreationEntity.java (1)
44-49:⚠️ Potential issue | 🟠 MajorPersist
lineSegmentsorder.This is still mapped as an ordered
List, but the association does not store any index. After a save/reload cycle, segment order is unspecified and the reconstructedLineCreationInfoscan change. Add an@OrderColumnhere and the matching column inline_creation_line_segments.Suggested change
`@OneToMany`(cascade = CascadeType.ALL, orphanRemoval = true) + `@OrderColumn`(name = "segment_index") `@JoinTable`( joinColumns = `@JoinColumn`(name = "line_id"), foreignKey = `@ForeignKey`(name = "line_id_fk"), inverseJoinColumns = `@JoinColumn`(name = "line_segments_id"), inverseForeignKey = `@ForeignKey`(name = "line_segments_id_fk"), uniqueConstraints = `@UniqueConstraint`(name = "line_creation_line_segments_uk", columnNames = {"line_segments_id"})) private List<LineSegmentEntity> lineSegments;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/main/java/org/gridsuite/modification/server/entities/equipment/creation/LineCreationEntity.java` around lines 44 - 49, The lineSegments List in LineCreationEntity is not persisted with an order index; add `@OrderColumn` to the lineSegments field (e.g., `@OrderColumn`(name = "segment_order")) and update the join table definition for line_creation_line_segments to include the matching index column (segment_order) so JPA will persist and restore the List element order; ensure the column is included in the JoinTable DDL/migration and name matches the `@OrderColumn` value.
🧹 Nitpick comments (1)
src/main/resources/db/changelog/changesets/changelog_20260324T101024Z.xml (1)
4-11: Indexline_creation_line_segments.line_id.
LineCreationEntity.lineSegmentswill be read and cleaned up throughline_id, but the schema only gets an index online_segments_idvia the unique constraint. Add a parent-side index here to avoid full scans and expensive FK checks once this join table grows.Suggested change
<changeSet author="elcheikhbas (generated)" id="1774347058503-15"> <createTable tableName="line_creation_line_segments"> <column name="line_id" type="UUID"> <constraints nullable="false"/> </column> <column name="line_segments_id" type="UUID"> <constraints nullable="false"/> </column> </createTable> + <createIndex indexName="line_creation_line_segments_line_id_idx" + tableName="line_creation_line_segments"> + <column name="line_id"/> + </createIndex> </changeSet>🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/main/resources/db/changelog/changesets/changelog_20260324T101024Z.xml` around lines 4 - 11, Add a non-unique index on the parent column to avoid full scans: modify the changeset that creates the join table line_creation_line_segments to add an index for column "line_id" (in addition to the existing unique constraint on "line_segments_id"); update the XML to include an <createIndex> (or equivalent index element) targeting tableName="line_creation_line_segments" and column name="line_id" so lookups from LineCreationEntity.lineSegments use the indexed parent key.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In
`@src/main/java/org/gridsuite/modification/server/entities/equipment/creation/LineCreationEntity.java`:
- Around line 44-49: The lineSegments List in LineCreationEntity is not
persisted with an order index; add `@OrderColumn` to the lineSegments field (e.g.,
`@OrderColumn`(name = "segment_order")) and update the join table definition for
line_creation_line_segments to include the matching index column (segment_order)
so JPA will persist and restore the List element order; ensure the column is
included in the JoinTable DDL/migration and name matches the `@OrderColumn` value.
---
Nitpick comments:
In `@src/main/resources/db/changelog/changesets/changelog_20260324T101024Z.xml`:
- Around line 4-11: Add a non-unique index on the parent column to avoid full
scans: modify the changeset that creates the join table
line_creation_line_segments to add an index for column "line_id" (in addition to
the existing unique constraint on "line_segments_id"); update the XML to include
an <createIndex> (or equivalent index element) targeting
tableName="line_creation_line_segments" and column name="line_id" so lookups
from LineCreationEntity.lineSegments use the indexed parent key.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 15fbc59c-757c-495e-972a-c80ba2170599
📒 Files selected for processing (5)
pom.xmlsrc/main/java/org/gridsuite/modification/server/entities/equipment/creation/LineCreationEntity.javasrc/main/java/org/gridsuite/modification/server/entities/equipment/creation/LineSegmentEntity.javasrc/main/resources/db/changelog/changesets/changelog_20260324T101024Z.xmlsrc/main/resources/db/changelog/db.changelog-master.yaml
✅ Files skipped from review due to trivial changes (2)
- src/main/resources/db/changelog/db.changelog-master.yaml
- pom.xml
🚧 Files skipped from review as they are similar to previous changes (1)
- src/main/java/org/gridsuite/modification/server/entities/equipment/creation/LineSegmentEntity.java
flomillot
left a comment
There was a problem hiding this comment.
No tests ? DTO conversion etc
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/test/java/org/gridsuite/modification/server/modifications/LineCreationInNodeBreakerTest.java (1)
324-325: Consider extracting a shared line-segment test fixture.The same
lineSegments(List.of(...))literal now appears across multiple integration tests; a shared helper/fixture would reduce drift when the segment DTO evolves.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/test/java/org/gridsuite/modification/server/modifications/LineCreationInNodeBreakerTest.java` around lines 324 - 325, The repeated inline List.of(new LineSegmentInfos(...)) literal across tests (seen in LineCreationInNodeBreakerTest) should be extracted into a shared test fixture helper; add a static factory method (e.g., TestFixtures.defaultLineSegments() or a helper in LineCreationInNodeBreakerTest like createDefaultLineSegments()) that returns the List<LineSegmentInfos> with the two populated segments, replace all inline occurrences with calls to that helper, and update imports/usages so tests reference the single source of truth (class name references: LineCreationInNodeBreakerTest, LineSegmentInfos, and any other test classes using the literal).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In
`@src/test/java/org/gridsuite/modification/server/modifications/LineCreationInNodeBreakerTest.java`:
- Around line 324-325: The repeated inline List.of(new LineSegmentInfos(...))
literal across tests (seen in LineCreationInNodeBreakerTest) should be extracted
into a shared test fixture helper; add a static factory method (e.g.,
TestFixtures.defaultLineSegments() or a helper in LineCreationInNodeBreakerTest
like createDefaultLineSegments()) that returns the List<LineSegmentInfos> with
the two populated segments, replace all inline occurrences with calls to that
helper, and update imports/usages so tests reference the single source of truth
(class name references: LineCreationInNodeBreakerTest, LineSegmentInfos, and any
other test classes using the literal).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 17e8b534-a703-4538-a923-6563e8217f3c
📒 Files selected for processing (3)
src/test/java/org/gridsuite/modification/server/modifications/LineCreationInBusBreakerTest.javasrc/test/java/org/gridsuite/modification/server/modifications/LineCreationInMixedTypologyTest.javasrc/test/java/org/gridsuite/modification/server/modifications/LineCreationInNodeBreakerTest.java
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/test/java/org/gridsuite/modification/server/modifications/LineCreationInBusBreakerTest.java (1)
255-256: Use deterministic IDs in test fixturesUsing
UUID.randomUUID()in test payloads makes failures less reproducible and fixture diffs noisier. Prefer stable, explicit identifiers forsegmentTypeIdin tests.♻️ Proposed change
- .lineSegments(List.of(new LineSegmentInfos(UUID.randomUUID().toString(), 1, "1", "50", null), - new LineSegmentInfos(UUID.randomUUID().toString(), 1, "1", null, 0.95))) + .lineSegments(List.of(new LineSegmentInfos("segmentType-1", 1, "1", "50", null), + new LineSegmentInfos("segmentType-2", 1, "1", null, 0.95)))🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/test/java/org/gridsuite/modification/server/modifications/LineCreationInBusBreakerTest.java` around lines 255 - 256, Tests use UUID.randomUUID() for LineSegmentInfos.segmentTypeId which makes fixtures non-deterministic; replace those calls in the test (LineCreationInBusBreakerTest) with stable, explicit IDs (e.g., "segment-1", "segment-2") when constructing LineSegmentInfos so the payloads are reproducible and diffs are stable.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In
`@src/test/java/org/gridsuite/modification/server/modifications/LineCreationInBusBreakerTest.java`:
- Around line 255-256: Tests use UUID.randomUUID() for
LineSegmentInfos.segmentTypeId which makes fixtures non-deterministic; replace
those calls in the test (LineCreationInBusBreakerTest) with stable, explicit IDs
(e.g., "segment-1", "segment-2") when constructing LineSegmentInfos so the
payloads are reproducible and diffs are stable.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: cef9e991-203e-4596-90e2-f064086081fb
📒 Files selected for processing (2)
src/test/java/org/gridsuite/modification/server/modifications/LineCreationInBusBreakerTest.javasrc/test/java/org/gridsuite/modification/server/modifications/LineCreationInNodeBreakerTest.java
✅ Files skipped from review due to trivial changes (1)
- src/test/java/org/gridsuite/modification/server/modifications/LineCreationInNodeBreakerTest.java
Signed-off-by: basseche <bassel.el-cheikh_externe@rte-france.com>
|



PR Summary
Add Line segments entity table related to line creation