Skip to content

Commit cfc1222

Browse files
feat: partial load on bus network components
Signed-off-by: Joris Mancini <[email protected]>
1 parent f6ba471 commit cfc1222

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
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/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
}

0 commit comments

Comments
 (0)