-
Notifications
You must be signed in to change notification settings - Fork 0
Add Line segments infos into database for line creation #787
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
basseche
wants to merge
1
commit into
main
Choose a base branch
from
add_LineSegments_LineCreation
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
...java/org/gridsuite/modification/server/entities/equipment/creation/LineSegmentEntity.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| package org.gridsuite.modification.server.entities.equipment.creation; | ||
|
|
||
| import jakarta.persistence.Column; | ||
| import jakarta.persistence.Entity; | ||
| import jakarta.persistence.GeneratedValue; | ||
| import jakarta.persistence.GenerationType; | ||
| import jakarta.persistence.Id; | ||
| import jakarta.persistence.Table; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
| import org.apache.commons.collections4.CollectionUtils; | ||
| import org.gridsuite.modification.dto.LineSegmentInfos; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
| import java.util.UUID; | ||
|
|
||
| /** | ||
| * @author El Cheikh Bassel <bassel.el-cheikh_externe at rte-france.com> | ||
| */ | ||
|
|
||
| @NoArgsConstructor | ||
| @Getter | ||
| @Entity | ||
| @Table(name = "line_segments") | ||
| @AllArgsConstructor | ||
| public class LineSegmentEntity { | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.AUTO) | ||
| @Column(name = "uuid") | ||
| private UUID uuid; | ||
|
|
||
| @Column(name = "segment_type_id") | ||
| private String segmentTypeId; | ||
|
|
||
| @Column(name = "segment_distance_value") | ||
| private Integer segmentDistanceValue; | ||
|
|
||
| @Column(name = "area") | ||
| private String area; | ||
|
|
||
| @Column(name = "temperature") | ||
| private String temperature; | ||
|
|
||
| @Column(name = "shape_factor") | ||
| private Integer shapeFactor; | ||
|
|
||
| public static List<LineSegmentEntity> toLineSegmentEntities(List<LineSegmentInfos> lineSegmentInfos) { | ||
| List<LineSegmentEntity> lineSegments = new ArrayList<>(); | ||
| if (CollectionUtils.isEmpty(lineSegmentInfos)) { | ||
| return lineSegments; | ||
| } | ||
| for (LineSegmentInfos segment : lineSegmentInfos) { | ||
| lineSegments.add(new LineSegmentEntity(null, | ||
| segment.segmentTypeId(), | ||
| segment.segmentDistanceValue(), | ||
| segment.area(), | ||
| segment.temperature(), | ||
| segment.shapeFactor())); | ||
| } | ||
| return lineSegments; | ||
| } | ||
|
|
||
| public static List<LineSegmentInfos> fromLineSegmentsEntity(List<LineSegmentEntity> lineSegmentEntities) { | ||
| List<LineSegmentInfos> lineSegments = new ArrayList<>(); | ||
| if (CollectionUtils.isEmpty(lineSegmentEntities)) { | ||
| return lineSegments; | ||
| } | ||
| for (LineSegmentEntity entity : lineSegmentEntities) { | ||
| lineSegments.add( | ||
| new LineSegmentInfos(entity.segmentTypeId, | ||
| entity.segmentDistanceValue, | ||
| entity.area, entity.temperature, | ||
| entity.shapeFactor)); | ||
| } | ||
| return lineSegments; | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
34 changes: 34 additions & 0 deletions
34
src/main/resources/db/changelog/changesets/changelog_20260324T101024Z.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| <?xml version="1.1" encoding="UTF-8" standalone="no"?> | ||
| <databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:pro="http://www.liquibase.org/xml/ns/pro" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-latest.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd"> | ||
| <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> | ||
| </changeSet> | ||
| <changeSet author="elcheikhbas (generated)" id="1774347058503-16"> | ||
| <createTable tableName="line_segments"> | ||
| <column name="uuid" type="UUID"> | ||
| <constraints nullable="false" primaryKey="true" primaryKeyName="line_segmentsPK"/> | ||
| </column> | ||
| <column name="area" type="VARCHAR(255)"/> | ||
| <column name="segment_distance_value" type="INT"/> | ||
| <column name="segment_type_id" type="VARCHAR(255)"/> | ||
| <column name="shape_factor" type="INT"/> | ||
| <column name="temperature" type="VARCHAR(255)"/> | ||
| </createTable> | ||
| </changeSet> | ||
| <changeSet author="elcheikhbas (generated)" id="1774347058503-17"> | ||
| <addUniqueConstraint columnNames="line_segments_id" constraintName="line_creation_line_segments_uk" tableName="line_creation_line_segments"/> | ||
| </changeSet> | ||
| <changeSet author="elcheikhbas (generated)" id="1774347058503-18"> | ||
| <addForeignKeyConstraint baseColumnNames="line_id" baseTableName="line_creation_line_segments" constraintName="line_id_fk" deferrable="false" initiallyDeferred="false" referencedColumnNames="id" referencedTableName="line_creation" validate="true"/> | ||
| </changeSet> | ||
| <changeSet author="elcheikhbas (generated)" id="1774347058503-19"> | ||
| <addForeignKeyConstraint baseColumnNames="line_segments_id" baseTableName="line_creation_line_segments" constraintName="line_segments_id_fk" deferrable="false" initiallyDeferred="false" referencedColumnNames="uuid" referencedTableName="line_segments" validate="true"/> | ||
| </changeSet> | ||
| </databaseChangeLog> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.