Skip to content

Commit 8ea7a25

Browse files
authored
Merge branch 'main' into fix-busbar-section-finder-traverser
2 parents dab0cf8 + 2ad53fb commit 8ea7a25

File tree

9 files changed

+46
-35
lines changed

9 files changed

+46
-35
lines changed

src/main/java/org/gridsuite/network/map/dto/InfoTypeParameters.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public class InfoTypeParameters {
1616
public static final String QUERY_PARAM_DC_POWERFACTOR = "dcPowerFactor";
1717
public static final String QUERY_PARAM_LOAD_OPERATIONAL_LIMIT_GROUPS = "loadOperationalLimitGroups";
1818
public static final String QUERY_PARAM_LOAD_REGULATING_TERMINALS = "loadRegulatingTerminals";
19+
public static final String QUERY_PARAM_LOAD_NETWORK_COMPONENTS = "loadNetworkComponents";
1920

2021
public static final InfoTypeParameters TAB = new InfoTypeParameters(ElementInfos.InfoType.TAB, null);
2122

src/main/java/org/gridsuite/network/map/dto/definition/bus/BusTabInfos.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ public class BusTabInfos extends ElementInfosWithProperties {
2525

2626
private Double angle;
2727

28+
@JsonInclude(JsonInclude.Include.NON_NULL)
2829
private Integer synchronousComponentNum;
2930

31+
@JsonInclude(JsonInclude.Include.NON_NULL)
3032
private Integer connectedComponentNum;
3133

3234
private String voltageLevelId;

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

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
import org.gridsuite.network.map.dto.definition.bus.BusTabInfos;
1414
import org.gridsuite.network.map.dto.utils.ElementUtils;
1515

16+
import java.util.Optional;
17+
18+
import static org.gridsuite.network.map.dto.InfoTypeParameters.QUERY_PARAM_LOAD_NETWORK_COMPONENTS;
1619
import static org.gridsuite.network.map.dto.utils.ElementUtils.getProperties;
1720
import static org.gridsuite.network.map.dto.utils.ElementUtils.mapCountry;
1821

@@ -25,27 +28,34 @@ private BusInfosMapper() {
2528
}
2629

2730
public static ElementInfos toData(Identifiable<?> identifiable, InfoTypeParameters infoTypeParameters) {
31+
boolean shouldLoadNetworkComponents = Optional.ofNullable(infoTypeParameters.getOptionalParameters().get(QUERY_PARAM_LOAD_NETWORK_COMPONENTS))
32+
.map(Boolean::valueOf)
33+
.orElse(false);
2834
return switch (infoTypeParameters.getInfoType()) {
2935
case LIST -> ElementInfosMapper.toListInfos(identifiable);
30-
case TAB -> toTabInfos(identifiable);
36+
case TAB -> toTabInfos(identifiable, shouldLoadNetworkComponents);
3137
default -> throw new UnsupportedOperationException("TODO");
3238
};
3339
}
3440

35-
private static BusTabInfos toTabInfos(Identifiable<?> identifiable) {
41+
private static BusTabInfos toTabInfos(Identifiable<?> identifiable, boolean shouldLoadNetworkComponents) {
3642
Bus bus = (Bus) identifiable;
3743
BusTabInfos.BusTabInfosBuilder<?, ?> builder = BusTabInfos.builder().id(bus.getId())
3844
.angle(bus.getAngle())
3945
.v(bus.getV())
4046
.voltageLevelId(bus.getVoltageLevel().getId())
4147
.nominalVoltage(bus.getVoltageLevel().getNominalV())
4248
.country(mapCountry(bus.getVoltageLevel().getSubstation().orElse(null)))
43-
.synchronousComponentNum(bus.getSynchronousComponent().getNum())
4449
.properties(getProperties(bus))
45-
.connectedComponentNum(bus.getConnectedComponent().getNum())
4650
.substationProperties(bus.getVoltageLevel().getSubstation().map(ElementUtils::getProperties).orElse(null))
4751
.voltageLevelProperties(getProperties(bus.getVoltageLevel()));
4852

53+
if (shouldLoadNetworkComponents) {
54+
builder
55+
.synchronousComponentNum(bus.getSynchronousComponent().getNum())
56+
.connectedComponentNum(bus.getConnectedComponent().getNum());
57+
}
58+
4959
return builder.build();
5060
}
5161
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ private static LineMapInfos toMapInfos(Identifiable<?> identifiable, Double dcPo
115115
Terminal terminal1 = line.getTerminal1();
116116
Terminal terminal2 = line.getTerminal2();
117117

118-
LineMapInfos.LineMapInfosBuilder<?, ?> builder = LineMapInfos.builder()
118+
return LineMapInfos.builder()
119119
.id(line.getId())
120120
.name(line.getOptionalName().orElse(null))
121121
.terminal1Connected(terminal1.isConnected())
@@ -127,10 +127,10 @@ private static LineMapInfos toMapInfos(Identifiable<?> identifiable, Double dcPo
127127
.p1(nullIfNan(terminal1.getP()))
128128
.p2(nullIfNan(terminal2.getP()))
129129
.i1(nullIfNan(computeIntensity(terminal1, dcPowerFactor)))
130-
.i2(nullIfNan(computeIntensity(terminal2, dcPowerFactor)));
131-
builder.operatingStatus(ExtensionUtils.toOperatingStatus(line));
132-
133-
return builder.build();
130+
.i2(nullIfNan(computeIntensity(terminal2, dcPowerFactor)))
131+
// TODO - lock and strip are hidden on map temporarly
132+
//.operatingStatus(ExtensionUtils.toOperatingStatus(line))
133+
.build();
134134
}
135135

136136
private static LineTabInfos toTabInfos(Identifiable<?> identifiable, Double dcPowerFactor, boolean loadOperationalLimitGroups) {

src/main/java/org/gridsuite/network/map/services/NetworkMapService.java

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
import java.util.*;
2727
import java.util.stream.Collectors;
2828
import java.util.stream.Stream;
29+
import java.util.stream.StreamSupport;
30+
31+
import static org.gridsuite.network.map.dto.InfoTypeParameters.QUERY_PARAM_LOAD_NETWORK_COMPONENTS;
2932

3033
/**
3134
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
@@ -62,7 +65,16 @@ private List<String> getSubstationsIds(UUID networkUuid, String variantId, List<
6265
}
6366

6467
public AllElementsInfos getAllElementsInfos(UUID networkUuid, String variantId, @NonNull List<String> substationsId, Map<String, Map<String, String>> additionalParametersByType) {
65-
Network network = getNetwork(networkUuid, PreloadingStrategy.ALL_COLLECTIONS_NEEDED_FOR_BUS_VIEW, variantId);
68+
// With network components we have to traverse almost all the network to recompute so we can switch to
69+
// ALL_COLLECTIONS_NEEDED_FOR_BUS_VIEW directly
70+
boolean shouldLoadNetworkComponents = Optional.ofNullable(additionalParametersByType.get(ElementType.BUS.toString()))
71+
.map(map -> map.get(QUERY_PARAM_LOAD_NETWORK_COMPONENTS))
72+
.map(Boolean::valueOf)
73+
.orElse(false);
74+
PreloadingStrategy preloadingStrategy = shouldLoadNetworkComponents || substationsId.size() >= 5 ?
75+
PreloadingStrategy.ALL_COLLECTIONS_NEEDED_FOR_BUS_VIEW :
76+
PreloadingStrategy.NONE;
77+
Network network = getNetwork(networkUuid, preloadingStrategy, variantId);
6678
return AllElementsInfos.builder()
6779
.substations(getSubstationsInfos(network, substationsId, getInfoTypeParameters(additionalParametersByType, ElementType.SUBSTATION), null))
6880
.voltageLevels(getVoltageLevelsInfos(network, substationsId, getInfoTypeParameters(additionalParametersByType, ElementType.VOLTAGE_LEVEL), null))
@@ -253,10 +265,11 @@ private List<ElementInfos> getTieLinesInfos(Network network, @NonNull List<Strin
253265

254266
private List<ElementInfos> getBusesInfos(Network network, @NonNull List<String> substationsId, InfoTypeParameters infoTypeParameters) {
255267
Stream<Bus> buses = substationsId.isEmpty() ? network.getBusView().getBusStream() :
256-
network.getBusView().getBusStream()
257-
.filter(Objects::nonNull)
258-
.filter(bus -> bus.getVoltageLevel().getSubstation().stream().anyMatch(substation -> substationsId.contains(substation.getId())))
259-
.distinct();
268+
substationsId
269+
.stream()
270+
.flatMap(id -> network.getSubstation(id).getVoltageLevelStream())
271+
.flatMap(vl -> StreamSupport.stream(vl.getBusView().getBuses().spliterator(), false));
272+
260273
return buses
261274
.map(c -> ElementType.BUS.getInfosGetter().apply(c, infoTypeParameters))
262275
.distinct()

src/test/java/org/gridsuite/network/map/NetworkMapControllerTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ class NetworkMapControllerTest {
7676
public static final String QUERY_PARAM_DC_POWER_FACTOR = "dcPowerFactor";
7777
public static final String QUERY_PARAM_LOAD_OPERATIONAL_LIMIT_GROUPS = "loadOperationalLimitGroups";
7878
public static final String QUERY_PARAM_LOAD_REGULATING_TERMINALS = "loadRegulatingTerminals";
79+
public static final String QUERY_PARAM_LOAD_NETWORK_COMPONENTS = "loadNetworkComponents";
7980
public static final String QUERY_PARAM_NOMINAL_VOLTAGES = "nominalVoltages";
8081

8182
@Autowired
@@ -1641,6 +1642,7 @@ private void succeedingTestForElementsInfos(UUID networkUuid, String variantId,
16411642
if (withOptionalLoading) {
16421643
queryParams.add(String.format(QUERY_FORMAT_ADDITIONAL_PARAMS, QUERY_PARAM_LOAD_OPERATIONAL_LIMIT_GROUPS), String.valueOf(true));
16431644
queryParams.add(String.format(QUERY_FORMAT_ADDITIONAL_PARAMS, QUERY_PARAM_LOAD_REGULATING_TERMINALS), String.valueOf(true));
1645+
queryParams.add(String.format(QUERY_FORMAT_ADDITIONAL_PARAMS, QUERY_PARAM_LOAD_NETWORK_COMPONENTS), String.valueOf(true));
16441646
}
16451647
MvcResult mvcResult = mvc.perform(post("/v1/networks/{networkUuid}/elements", networkUuid)
16461648
.queryParams(queryParams)
@@ -1727,7 +1729,8 @@ private void succeedingTestForAllEquipmentsInfos(UUID networkUuid, String varian
17271729
String.valueOf(ElementType.BRANCH), Map.of(QUERY_PARAM_LOAD_OPERATIONAL_LIMIT_GROUPS, String.valueOf(true)),
17281730
String.valueOf(ElementType.LINE), Map.of(QUERY_PARAM_LOAD_OPERATIONAL_LIMIT_GROUPS, String.valueOf(true)),
17291731
String.valueOf(ElementType.TWO_WINDINGS_TRANSFORMER), Map.of(QUERY_PARAM_LOAD_OPERATIONAL_LIMIT_GROUPS, String.valueOf(true)),
1730-
String.valueOf(ElementType.GENERATOR), Map.of(QUERY_PARAM_LOAD_REGULATING_TERMINALS, String.valueOf(true))
1732+
String.valueOf(ElementType.GENERATOR), Map.of(QUERY_PARAM_LOAD_REGULATING_TERMINALS, String.valueOf(true)),
1733+
String.valueOf(ElementType.BUS), Map.of(QUERY_PARAM_LOAD_NETWORK_COMPONENTS, String.valueOf(true))
17311734
);
17321735
} else {
17331736
body = Map.of();

src/test/resources/all-data-without-optionals.json

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2244,8 +2244,6 @@
22442244
"id": "VLGEN_0",
22452245
"v": "NaN",
22462246
"angle": "NaN",
2247-
"synchronousComponentNum": 0,
2248-
"connectedComponentNum": 0,
22492247
"voltageLevelId": "VLGEN",
22502248
"nominalVoltage": 24.0,
22512249
"country": "FR",
@@ -2260,8 +2258,6 @@
22602258
"id": "VLHV1_0",
22612259
"v": "NaN",
22622260
"angle": "NaN",
2263-
"synchronousComponentNum": 0,
2264-
"connectedComponentNum": 0,
22652261
"voltageLevelId": "VLHV1",
22662262
"nominalVoltage": 380.0,
22672263
"country": "FR",
@@ -2273,26 +2269,20 @@
22732269
"id": "VLHV2_0",
22742270
"v": "NaN",
22752271
"angle": "NaN",
2276-
"synchronousComponentNum": 0,
2277-
"connectedComponentNum": 0,
22782272
"voltageLevelId": "VLHV2",
22792273
"nominalVoltage": 380.0
22802274
},
22812275
{
22822276
"id": "VLLOAD_0",
22832277
"v": "NaN",
22842278
"angle": "NaN",
2285-
"synchronousComponentNum": 0,
2286-
"connectedComponentNum": 0,
22872279
"voltageLevelId": "VLLOAD",
22882280
"nominalVoltage": 150.0
22892281
},
22902282
{
22912283
"id": "VLNEW2_0",
22922284
"v": "NaN",
22932285
"angle": "NaN",
2294-
"synchronousComponentNum": 0,
2295-
"connectedComponentNum": 0,
22962286
"voltageLevelId": "VLNEW2",
22972287
"nominalVoltage": 225.0,
22982288
"country": "FR",
@@ -2307,8 +2297,6 @@
23072297
"id": "VLGEN3_0",
23082298
"v": "NaN",
23092299
"angle": "NaN",
2310-
"synchronousComponentNum": 0,
2311-
"connectedComponentNum": 0,
23122300
"voltageLevelId": "VLGEN3",
23132301
"nominalVoltage": 24.0,
23142302
"country": "FR",
@@ -2320,8 +2308,6 @@
23202308
"id": "VLGEN6_0",
23212309
"v": "NaN",
23222310
"angle": "NaN",
2323-
"synchronousComponentNum": 0,
2324-
"connectedComponentNum": 0,
23252311
"voltageLevelId": "VLGEN6",
23262312
"nominalVoltage": 24.0,
23272313
"country": "FR"
@@ -2330,8 +2316,6 @@
23302316
"id": "VLGEN4_0",
23312317
"v": "NaN",
23322318
"angle": "NaN",
2333-
"synchronousComponentNum": 1,
2334-
"connectedComponentNum": 1,
23352319
"voltageLevelId": "VLGEN4",
23362320
"nominalVoltage": 24.0,
23372321
"country": "FR"

src/test/resources/lines-map-data.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
"terminal1Connected": true,
2424
"terminal2Connected": true,
2525
"p1": 200.0,
26-
"p2": 100.0,
27-
"operatingStatus": "PLANNED_OUTAGE"
26+
"p2": 100.0
2827
},
2928
{
3029
"id": "LINE4",

src/test/resources/partial-lines-map-data.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
"terminal1Connected": true,
88
"terminal2Connected": true,
99
"p1": 200.0,
10-
"p2": 100.0,
11-
"operatingStatus": "PLANNED_OUTAGE"
10+
"p2": 100.0
1211
},
1312
{
1413
"id": "NHV1_NHV2_2",

0 commit comments

Comments
 (0)