Skip to content

Commit 8ba0040

Browse files
committed
resolving conflicts
2 parents ca84d42 + 9f9bef0 commit 8ba0040

40 files changed

+704
-730
lines changed

src/main/java/org/gridsuite/network/map/dto/common/CurrentLimitsData.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
@EqualsAndHashCode
2525
@ToString
2626
public class CurrentLimitsData {
27-
// may be null in case we just need the selected limit set and don't really need its name/id
2827
@JsonInclude(JsonInclude.Include.NON_NULL)
2928
private String id;
3029

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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.network.map.dto.definition.voltagelevel;
8+
9+
import com.powsybl.iidm.network.TwoSides;
10+
import org.gridsuite.network.map.dto.definition.extension.ConnectablePositionInfos;
11+
12+
/**
13+
* @author Etienne Lesot <etienne.lesot at rte-france.com>
14+
*/
15+
public record FeederBayInfos(String busbarSectionId, ConnectablePositionInfos connectablePositionInfos, TwoSides connectionSide) { }

src/main/java/org/gridsuite/network/map/dto/definition/voltagelevel/VoltageLevelFormInfos.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,7 @@ public class VoltageLevelFormInfos extends ElementInfosWithProperties {
5959

6060
@JsonInclude(JsonInclude.Include.NON_NULL)
6161
private Map<String, List<String>> busBarSectionInfos;
62+
63+
@JsonInclude(JsonInclude.Include.NON_NULL)
64+
private Map<String, List<FeederBayInfos>> feederBaysInfos;
6265
}

src/main/java/org/gridsuite/network/map/dto/mapper/BranchInfosMapper.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,13 @@ public static ElementInfos toData(@NonNull final Identifiable<?> identifiable,
7373
final Terminal terminal1 = branch.getTerminal1();
7474
final Terminal terminal2 = branch.getTerminal2();
7575

76-
branch.getSelectedOperationalLimitsGroup1()
77-
.flatMap(OperationalLimitsGroup::getCurrentLimits)
78-
.map(cl -> builder.selectedOperationalLimitsGroup1(toMapDataCurrentLimits(cl, null, null)));
79-
branch.getSelectedOperationalLimitsGroupId1().map(name -> builder.selectedOperationalLimitsGroup1Name(name));
80-
branch.getSelectedOperationalLimitsGroup2()
81-
.flatMap(OperationalLimitsGroup::getCurrentLimits)
82-
.map(cl -> builder.selectedOperationalLimitsGroup2(toMapDataCurrentLimits(cl, null, null)));
83-
branch.getSelectedOperationalLimitsGroupId2().map(name -> builder.selectedOperationalLimitsGroup2Name(name));
76+
branch.getSelectedOperationalLimitsGroup1().ifPresent(limitGrp ->
77+
limitGrp.getCurrentLimits().ifPresent(cl -> builder.selectedOperationalLimitsGroup1(toMapDataCurrentLimits(cl, limitGrp.getId(), null))));
78+
branch.getSelectedOperationalLimitsGroupId1().ifPresent(builder::selectedOperationalLimitsGroup1Name);
79+
80+
branch.getSelectedOperationalLimitsGroup2().ifPresent(limitGrp ->
81+
limitGrp.getCurrentLimits().ifPresent(cl -> builder.selectedOperationalLimitsGroup2(toMapDataCurrentLimits(cl, limitGrp.getId(), null))));
82+
branch.getSelectedOperationalLimitsGroupId2().ifPresent(builder::selectedOperationalLimitsGroup2Name);
8483

8584
if (loadOperationalLimitGroups) {
8685
final Map<String, CurrentLimitsData> mapOperationalLimitsGroup1 = buildCurrentLimitsMap(branch.getOperationalLimitsGroups1());
@@ -133,7 +132,7 @@ private static Map<String, CurrentLimitsData> buildCurrentLimitsMap(@NonNull fin
133132
}
134133
Map<String, CurrentLimitsData> res = HashMap.newHashMap(operationalLimitsGroups.size());
135134
operationalLimitsGroups.forEach(operationalLimitsGroup -> operationalLimitsGroup.getCurrentLimits()
136-
.ifPresent(limits -> res.put(operationalLimitsGroup.getId(), toMapDataCurrentLimits(limits, null, null))));
135+
.ifPresent(limits -> res.put(operationalLimitsGroup.getId(), toMapDataCurrentLimits(limits, operationalLimitsGroup.getId(), null))));
137136
return res;
138137
}
139138

src/main/java/org/gridsuite/network/map/dto/mapper/LineInfosMapper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ private static LineTooltipInfos toTooltipInfos(Identifiable<?> identifiable, Dou
162162
.b1(line.getB1())
163163
.b2(line.getB2());
164164

165-
line.getCurrentLimits1().ifPresent(limits1 -> builder.currentLimits1(toMapDataCurrentLimits(limits1, null, null)));
166-
line.getCurrentLimits2().ifPresent(limits2 -> builder.currentLimits2(toMapDataCurrentLimits(limits2, null, null)));
165+
line.getSelectedOperationalLimitsGroup1().ifPresent(limitsGrp -> limitsGrp.getCurrentLimits().ifPresent(limits -> builder.currentLimits1(toMapDataCurrentLimits(limits, limitsGrp.getId(), null))));
166+
line.getSelectedOperationalLimitsGroup2().ifPresent(limitsGrp -> limitsGrp.getCurrentLimits().ifPresent(limits -> builder.currentLimits2(toMapDataCurrentLimits(limits, limitsGrp.getId(), null))));
167167

168168
return builder.build();
169169
}

src/main/java/org/gridsuite/network/map/dto/mapper/TieLineInfosMapper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ private static TieLineMapInfos toMapInfos(Identifiable<?> identifiable, Double d
5858
.i2(nullIfNan(computeIntensity(terminal2, dcPowerFactor)))
5959
.operatingStatus(ExtensionUtils.toOperatingStatus(tieLine));
6060

61-
tieLine.getCurrentLimits1().ifPresent(limits1 -> builder.currentLimits1(toMapDataCurrentLimits(limits1, null, null)));
62-
tieLine.getCurrentLimits2().ifPresent(limits2 -> builder.currentLimits2(toMapDataCurrentLimits(limits2, null, null)));
61+
tieLine.getSelectedOperationalLimitsGroup1().ifPresent(limitsGrp -> limitsGrp.getCurrentLimits().ifPresent(limits -> builder.currentLimits1(toMapDataCurrentLimits(limits, limitsGrp.getId(), null))));
62+
tieLine.getSelectedOperationalLimitsGroup2().ifPresent(limitsGrp -> limitsGrp.getCurrentLimits().ifPresent(limits -> builder.currentLimits2(toMapDataCurrentLimits(limits, limitsGrp.getId(), null))));
6363

6464
return builder.build();
6565
}

src/main/java/org/gridsuite/network/map/dto/mapper/TwoWindingsTransformerInfosMapper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ private static TwoWindingsTransformerTooltipInfos toTooltipInfos(Identifiable<?>
165165
.x(twoWindingsTransformer.getX())
166166
.b(twoWindingsTransformer.getB());
167167

168-
twoWindingsTransformer.getCurrentLimits1().ifPresent(limits1 -> builder.currentLimits1(toMapDataCurrentLimits(limits1, null, null)));
169-
twoWindingsTransformer.getCurrentLimits2().ifPresent(limits2 -> builder.currentLimits2(toMapDataCurrentLimits(limits2, null, null)));
168+
twoWindingsTransformer.getSelectedOperationalLimitsGroup1().ifPresent(limitsGrp -> limitsGrp.getCurrentLimits().ifPresent(limits -> builder.currentLimits1(toMapDataCurrentLimits(limits, limitsGrp.getId(), null))));
169+
twoWindingsTransformer.getSelectedOperationalLimitsGroup2().ifPresent(limitsGrp -> limitsGrp.getCurrentLimits().ifPresent(limits -> builder.currentLimits2(toMapDataCurrentLimits(limits, limitsGrp.getId(), null))));
170170

171171
return builder.build();
172172
}

src/main/java/org/gridsuite/network/map/dto/mapper/VoltageLevelInfosMapper.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import org.gridsuite.network.map.dto.ElementInfos;
1515
import org.gridsuite.network.map.dto.InfoTypeParameters;
1616
import org.gridsuite.network.map.dto.definition.busbarsection.BusBarSectionFormInfos;
17+
import org.gridsuite.network.map.dto.definition.voltagelevel.FeederBayInfos;
1718
import org.gridsuite.network.map.dto.definition.voltagelevel.VoltageLevelFormInfos;
1819
import org.gridsuite.network.map.dto.definition.voltagelevel.VoltageLevelMapInfos;
1920
import org.gridsuite.network.map.dto.definition.voltagelevel.VoltageLevelTabInfos;
@@ -23,6 +24,7 @@
2324
import java.util.*;
2425
import java.util.stream.Collectors;
2526

27+
import static com.powsybl.iidm.network.Terminal.getConnectableSide;
2628
import static org.gridsuite.network.map.dto.utils.ElementUtils.*;
2729

2830
/**
@@ -106,13 +108,36 @@ static VoltageLevelFormInfos toFormInfos(Identifiable<?> identifiable) {
106108
builder.isRetrievedBusbarSections(vlTopologyInfos.isRetrievedBusbarSections());
107109
builder.isBusbarSectionPositionFound(vlTopologyInfos.isBusbarSectionPositionFound());
108110
builder.busBarSectionInfos(vlTopologyInfos.getBusBarSectionInfosGrouped());
111+
builder.feederBaysInfos(getFeederBaysInfos(voltageLevel));
109112
}
110113

111114
builder.identifiableShortCircuit(ExtensionUtils.toIdentifiableShortCircuit(voltageLevel));
112115

113116
return builder.build();
114117
}
115118

119+
private static Map<String, List<FeederBayInfos>> getFeederBaysInfos(VoltageLevel voltageLevel) {
120+
Map<String, List<FeederBayInfos>> feederBayInfos = new HashMap<>();
121+
String currentVoltageLevelId = voltageLevel.getId();
122+
voltageLevel.getConnectableStream()
123+
.filter(connectable -> !(connectable instanceof BusbarSection))
124+
.forEach(connectable -> {
125+
List<FeederBayInfos> connections = new ArrayList<>();
126+
for (Object obj : connectable.getTerminals()) {
127+
Terminal terminal = (Terminal) obj;
128+
if (terminal.getVoltageLevel().getId().equals(currentVoltageLevelId)) {
129+
connections.add(new FeederBayInfos(
130+
getBusOrBusbarSection(terminal),
131+
getConnectablePosition(connectable, FeederSide.from(getConnectableSide(terminal))),
132+
getConnectableSide(terminal).map(ThreeSides::toTwoSides).orElse(null)
133+
));
134+
}
135+
}
136+
feederBayInfos.put(connectable.getId(), connections);
137+
});
138+
return feederBayInfos;
139+
}
140+
116141
static VoltageLevelMapInfos toMapInfos(Identifiable<?> identifiable) {
117142
VoltageLevel voltageLevel = (VoltageLevel) identifiable;
118143
return VoltageLevelMapInfos.builder()

src/main/java/org/gridsuite/network/map/dto/utils/ElementUtils.java

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@
77
package org.gridsuite.network.map.dto.utils;
88

99
import com.powsybl.iidm.network.*;
10+
import com.powsybl.iidm.network.extensions.ConnectablePosition;
11+
import com.powsybl.math.graph.TraversalType;
1012
import org.gridsuite.network.map.dto.common.ReactiveCapabilityCurveMapData;
1113
import org.gridsuite.network.map.dto.common.TapChangerData;
1214
import org.gridsuite.network.map.dto.common.TapChangerStepData;
1315
import org.gridsuite.network.map.dto.definition.extension.BusbarSectionFinderTraverser;
16+
import org.gridsuite.network.map.dto.definition.extension.ConnectablePositionInfos;
1417
import org.springframework.lang.NonNull;
1518

1619
import java.util.Collection;
@@ -38,6 +41,49 @@ public static void setIfNotNan(@NonNull final DoubleConsumer setter, final doubl
3841
}
3942
}
4043

44+
public enum FeederSide {
45+
INJECTION_SINGLE_SIDE,
46+
BRANCH_SIDE_ONE,
47+
BRANCH_SIDE_TWO;
48+
49+
public static FeederSide from(Optional<ThreeSides> connectableSide) {
50+
return connectableSide.map(threeSides -> threeSides == ThreeSides.ONE ? BRANCH_SIDE_ONE : BRANCH_SIDE_TWO).orElse(INJECTION_SINGLE_SIDE);
51+
}
52+
}
53+
54+
private static ConnectablePosition.Feeder getFeederInfos(Identifiable<?> identifiable, FeederSide side) {
55+
ConnectablePosition<?> connectablePosition = (ConnectablePosition<?>) identifiable.getExtension(ConnectablePosition.class);
56+
if (connectablePosition == null) {
57+
return null;
58+
}
59+
60+
switch (side) {
61+
case INJECTION_SINGLE_SIDE:
62+
return connectablePosition.getFeeder();
63+
case BRANCH_SIDE_ONE:
64+
return connectablePosition.getFeeder1();
65+
case BRANCH_SIDE_TWO:
66+
return connectablePosition.getFeeder2();
67+
default:
68+
throw new IllegalArgumentException("Invalid feeder side: " + side);
69+
}
70+
}
71+
72+
public static ConnectablePositionInfos getConnectablePosition(Identifiable<?> identifiable, FeederSide side) {
73+
ConnectablePosition.Feeder feeder = getFeederInfos(identifiable, side);
74+
return buildConnectablePositionInfos(feeder);
75+
}
76+
77+
public static ConnectablePositionInfos buildConnectablePositionInfos(ConnectablePosition.Feeder feeder) {
78+
ConnectablePositionInfos.ConnectablePositionInfosBuilder builder = ConnectablePositionInfos.builder();
79+
if (feeder != null) {
80+
builder.connectionDirection(feeder.getDirection() == null ? null : feeder.getDirection())
81+
.connectionPosition(feeder.getOrder().orElse(null))
82+
.connectionName(feeder.getName().orElse(null));
83+
}
84+
return builder.build();
85+
}
86+
4187
public static String getBusOrBusbarSection(Terminal terminal) {
4288
if (terminal.getVoltageLevel().getTopologyKind().equals(TopologyKind.BUS_BREAKER)) {
4389
if (terminal.isConnected()) {

0 commit comments

Comments
 (0)