Skip to content

Commit 978a980

Browse files
authored
new modification MoveVoltageLevelFeederBays (#678)
Signed-off-by: Rehili Ghazwa <[email protected]> Co-authored-by: Etienne LESOT <[email protected]>
1 parent f67c862 commit 978a980

File tree

6 files changed

+400
-0
lines changed

6 files changed

+400
-0
lines changed

src/main/java/org/gridsuite/modification/server/entities/EntityRegistry.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ private EntityRegistry() {
7474
register(VoltageLevelTopologyModificationInfos.class, VoltageLevelTopologyModificationEntity.class);
7575
register(CreateCouplingDeviceInfos.class, CreateCouplingDeviceEntity.class);
7676
register(CreateVoltageLevelTopologyInfos.class, CreateVoltageLevelTopologyEntity.class);
77+
register(MoveVoltageLevelFeederBaysInfos.class, MoveVoltageLevelFeederBaysEntity.class);
7778

7879
// // attatching and splitting
7980
register(LineAttachToVoltageLevelInfos.class, LineAttachToVoltageLevelEntity.class);
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/**
2+
* Copyright (c) 2025, RTE (http://www.rte-france.com)
3+
* This Source Code Form is subject to the terms of the Mozilla Public
4+
* License, v. 2.0. If a copy of the MPL was not distributed with this
5+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
*/
7+
package org.gridsuite.modification.server.entities.equipment.modification;
8+
9+
import com.powsybl.iidm.network.extensions.ConnectablePosition;
10+
import io.swagger.v3.oas.annotations.media.Schema;
11+
import jakarta.persistence.Column;
12+
import jakarta.persistence.Embeddable;
13+
import lombok.AllArgsConstructor;
14+
import lombok.Getter;
15+
import lombok.NoArgsConstructor;
16+
import org.gridsuite.modification.dto.MoveFeederBayInfos;
17+
18+
/**
19+
* @author Etienne Lesot <etienne.lesot at rte-france.com>
20+
*/
21+
@NoArgsConstructor
22+
@AllArgsConstructor
23+
@Getter
24+
@Embeddable
25+
public class MoveFeederBayEmbeddable {
26+
@Column(name = "equipment_id")
27+
private String equipmentId;
28+
29+
@Column(name = "busbar_section_id")
30+
private String busbarSectionId;
31+
32+
@Schema(description = "connection_side")
33+
private String connectionSide;
34+
35+
@Schema(description = "connection_position")
36+
private Integer connectionPosition;
37+
38+
@Schema(description = "connection_name")
39+
private String connectionName;
40+
41+
@Schema(description = "connection_direction")
42+
private ConnectablePosition.Direction connectionDirection;
43+
44+
MoveFeederBayInfos toConnectablePositionModificationInfos() {
45+
return MoveFeederBayInfos.builder()
46+
.equipmentId(equipmentId)
47+
.busbarSectionId(busbarSectionId)
48+
.connectionSide(connectionSide)
49+
.connectionPosition(connectionPosition)
50+
.connectionName(connectionName)
51+
.connectionDirection(connectionDirection)
52+
.build();
53+
}
54+
55+
static MoveFeederBayEmbeddable toConnectablePositionModificationEmbeddable(MoveFeederBayInfos moveFeederBayInfos) {
56+
return new MoveFeederBayEmbeddable(moveFeederBayInfos.getEquipmentId(),
57+
moveFeederBayInfos.getBusbarSectionId(),
58+
moveFeederBayInfos.getConnectionSide(),
59+
moveFeederBayInfos.getConnectionPosition(),
60+
moveFeederBayInfos.getConnectionName(),
61+
moveFeederBayInfos.getConnectionDirection());
62+
}
63+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/**
2+
* Copyright (c) 2025, RTE (http://www.rte-france.com)
3+
* This Source Code Form is subject to the terms of the Mozilla Public
4+
* License, v. 2.0. If a copy of the MPL was not distributed with this
5+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
*/
7+
package org.gridsuite.modification.server.entities.equipment.modification;
8+
9+
import jakarta.persistence.*;
10+
import lombok.Getter;
11+
import lombok.NoArgsConstructor;
12+
import lombok.NonNull;
13+
import org.gridsuite.modification.dto.ModificationInfos;
14+
import org.gridsuite.modification.dto.MoveVoltageLevelFeederBaysInfos;
15+
import org.gridsuite.modification.server.entities.ModificationEntity;
16+
17+
import java.util.ArrayList;
18+
import java.util.List;
19+
20+
/**
21+
* @author Etienne Lesot <etienne.lesot at rte-france.com>
22+
*/
23+
@NoArgsConstructor
24+
@Getter
25+
@Entity
26+
@Table(name = "move_voltage_level_feeder_bays")
27+
@PrimaryKeyJoinColumn(name = "id", foreignKey = @ForeignKey(name = "move_voltage_level_feeder_bays_id_fk_constraint"))
28+
public class MoveVoltageLevelFeederBaysEntity extends ModificationEntity {
29+
30+
@Column(name = "voltage_level_id")
31+
private String voltageLevelId;
32+
33+
@ElementCollection
34+
@CollectionTable(
35+
name = "move_feeder_bay",
36+
joinColumns = @JoinColumn(name = "modification_id"),
37+
foreignKey = @ForeignKey(name = "move_feeder_bay_modification_id_fk_constraint")
38+
)
39+
private List<MoveFeederBayEmbeddable> moveFeederBays;
40+
41+
public MoveVoltageLevelFeederBaysEntity(MoveVoltageLevelFeederBaysInfos moveVoltageLevelFeederBaysInfos) {
42+
super(moveVoltageLevelFeederBaysInfos);
43+
assignAttributes(moveVoltageLevelFeederBaysInfos);
44+
}
45+
46+
@Override
47+
public void update(@NonNull ModificationInfos modificationInfos) {
48+
super.update(modificationInfos);
49+
assignAttributes((MoveVoltageLevelFeederBaysInfos) modificationInfos);
50+
}
51+
52+
private void assignAttributes(MoveVoltageLevelFeederBaysInfos moveVoltageLevelFeederBaysInfos) {
53+
if (this.moveFeederBays == null) {
54+
this.moveFeederBays = new ArrayList<>();
55+
} else {
56+
this.moveFeederBays.clear();
57+
}
58+
this.voltageLevelId = moveVoltageLevelFeederBaysInfos.getVoltageLevelId();
59+
this.moveFeederBays.addAll(moveVoltageLevelFeederBaysInfos.getFeederBays().stream()
60+
.map(MoveFeederBayEmbeddable::toConnectablePositionModificationEmbeddable)
61+
.toList());
62+
}
63+
64+
@Override
65+
public MoveVoltageLevelFeederBaysInfos toModificationInfos() {
66+
return toMoveVoltageLevelFeederBaysInfosBuilder().build();
67+
}
68+
69+
private MoveVoltageLevelFeederBaysInfos.MoveVoltageLevelFeederBaysInfosBuilder<?, ?> toMoveVoltageLevelFeederBaysInfosBuilder() {
70+
return MoveVoltageLevelFeederBaysInfos.builder()
71+
.uuid(getId())
72+
.date(getDate())
73+
.stashed(getStashed())
74+
.activated(getActivated())
75+
.voltageLevelId(voltageLevelId)
76+
.feederBays(moveFeederBays.stream()
77+
.map(MoveFeederBayEmbeddable::toConnectablePositionModificationInfos).toList());
78+
}
79+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
2+
<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">
3+
<changeSet author="rehiligha (generated)" id="1758467689080-35">
4+
<createTable tableName="move_feeder_bay">
5+
<column name="modification_id" type="UUID">
6+
<constraints nullable="false"/>
7+
</column>
8+
<column name="busbar_section_id" type="VARCHAR(255)"/>
9+
<column name="connection_direction" type="SMALLINT"/>
10+
<column name="connection_name" type="VARCHAR(255)"/>
11+
<column name="connection_position" type="INT"/>
12+
<column name="connection_side" type="VARCHAR(255)"/>
13+
<column name="equipment_id" type="VARCHAR(255)"/>
14+
</createTable>
15+
</changeSet>
16+
<changeSet author="rehiligha (generated)" id="1758467689080-36">
17+
<createTable tableName="move_voltage_level_feeder_bays">
18+
<column name="voltage_level_id" type="VARCHAR(255)"/>
19+
<column name="id" type="UUID">
20+
<constraints nullable="false" primaryKey="true" primaryKeyName="move_voltage_level_feeder_baysPK"/>
21+
</column>
22+
</createTable>
23+
</changeSet>
24+
<changeSet author="rehiligha (generated)" id="1758467689080-47">
25+
<addForeignKeyConstraint baseColumnNames="id" baseTableName="move_voltage_level_feeder_bays" constraintName="move_voltage_level_feeder_bays_id_fk_constraint" deferrable="false" initiallyDeferred="false" referencedColumnNames="id" referencedTableName="modification" validate="true"/>
26+
</changeSet>
27+
<changeSet author="rehiligha (generated)" id="1758467689080-51">
28+
<addForeignKeyConstraint baseColumnNames="modification_id" baseTableName="move_feeder_bay" constraintName="move_feeder_bay_modification_id_fk_constraint" deferrable="false" initiallyDeferred="false" referencedColumnNames="id" referencedTableName="move_voltage_level_feeder_bays" validate="true"/>
29+
</changeSet>
30+
</databaseChangeLog>

src/main/resources/db/changelog/db.changelog-master.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,3 +408,6 @@ databaseChangeLog:
408408
- include:
409409
file: changesets/changelog_20250822T115310Z.xml
410410
relativeToChangelogFile: true
411+
- include:
412+
file: changesets/changelog_20250921T151431Z.xml
413+
relativeToChangelogFile: true

0 commit comments

Comments
 (0)