Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class InfoTypeParameters {
public static final String QUERY_PARAM_DC_POWERFACTOR = "dcPowerFactor";
public static final String QUERY_PARAM_LOAD_OPERATIONAL_LIMIT_GROUPS = "loadOperationalLimitGroups";
public static final String QUERY_PARAM_LOAD_REGULATING_TERMINALS = "loadRegulatingTerminals";
public static final String QUERY_PARAM_LOAD_NETWORK_COMPONENTS = "loadNetworkComponents";

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ public class BusTabInfos extends ElementInfosWithProperties {

private Double angle;

@JsonInclude(JsonInclude.Include.NON_NULL)
private Integer synchronousComponentNum;

@JsonInclude(JsonInclude.Include.NON_NULL)
private Integer connectedComponentNum;

private String voltageLevelId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
import org.gridsuite.network.map.dto.definition.bus.BusTabInfos;
import org.gridsuite.network.map.dto.utils.ElementUtils;

import java.util.Optional;

import static org.gridsuite.network.map.dto.InfoTypeParameters.QUERY_PARAM_LOAD_NETWORK_COMPONENTS;
import static org.gridsuite.network.map.dto.utils.ElementUtils.getProperties;
import static org.gridsuite.network.map.dto.utils.ElementUtils.mapCountry;

Expand All @@ -25,27 +28,34 @@ private BusInfosMapper() {
}

public static ElementInfos toData(Identifiable<?> identifiable, InfoTypeParameters infoTypeParameters) {
boolean shouldLoadNetworkComponents = Optional.ofNullable(infoTypeParameters.getOptionalParameters().get(QUERY_PARAM_LOAD_NETWORK_COMPONENTS))
.map(Boolean::valueOf)
.orElse(false);
return switch (infoTypeParameters.getInfoType()) {
case LIST -> ElementInfosMapper.toListInfos(identifiable);
case TAB -> toTabInfos(identifiable);
case TAB -> toTabInfos(identifiable, shouldLoadNetworkComponents);
default -> throw new UnsupportedOperationException("TODO");
};
}

private static BusTabInfos toTabInfos(Identifiable<?> identifiable) {
private static BusTabInfos toTabInfos(Identifiable<?> identifiable, boolean shouldLoadNetworkComponents) {
Bus bus = (Bus) identifiable;
BusTabInfos.BusTabInfosBuilder<?, ?> builder = BusTabInfos.builder().id(bus.getId())
.angle(bus.getAngle())
.v(bus.getV())
.voltageLevelId(bus.getVoltageLevel().getId())
.nominalVoltage(bus.getVoltageLevel().getNominalV())
.country(mapCountry(bus.getVoltageLevel().getSubstation().orElse(null)))
.synchronousComponentNum(bus.getSynchronousComponent().getNum())
.properties(getProperties(bus))
.connectedComponentNum(bus.getConnectedComponent().getNum())
.substationProperties(bus.getVoltageLevel().getSubstation().map(ElementUtils::getProperties).orElse(null))
.voltageLevelProperties(getProperties(bus.getVoltageLevel()));

if (shouldLoadNetworkComponents) {
builder
.synchronousComponentNum(bus.getSynchronousComponent().getNum())
.connectedComponentNum(bus.getConnectedComponent().getNum());
}

return builder.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class NetworkMapControllerTest {
public static final String QUERY_PARAM_DC_POWER_FACTOR = "dcPowerFactor";
public static final String QUERY_PARAM_LOAD_OPERATIONAL_LIMIT_GROUPS = "loadOperationalLimitGroups";
public static final String QUERY_PARAM_LOAD_REGULATING_TERMINALS = "loadRegulatingTerminals";
public static final String QUERY_PARAM_LOAD_NETWORK_COMPONENTS = "loadNetworkComponents";
public static final String QUERY_PARAM_NOMINAL_VOLTAGES = "nominalVoltages";

@Autowired
Expand Down Expand Up @@ -1443,6 +1444,7 @@ private void succeedingTestForElementsInfos(UUID networkUuid, String variantId,
if (withOptionalLoading) {
queryParams.add(String.format(QUERY_FORMAT_ADDITIONAL_PARAMS, QUERY_PARAM_LOAD_OPERATIONAL_LIMIT_GROUPS), String.valueOf(true));
queryParams.add(String.format(QUERY_FORMAT_ADDITIONAL_PARAMS, QUERY_PARAM_LOAD_REGULATING_TERMINALS), String.valueOf(true));
queryParams.add(String.format(QUERY_FORMAT_ADDITIONAL_PARAMS, QUERY_PARAM_LOAD_NETWORK_COMPONENTS), String.valueOf(true));
}
MvcResult mvcResult = mvc.perform(post("/v1/networks/{networkUuid}/elements", networkUuid)
.queryParams(queryParams)
Expand Down Expand Up @@ -1529,7 +1531,8 @@ private void succeedingTestForAllEquipmentsInfos(UUID networkUuid, String varian
String.valueOf(ElementType.BRANCH), Map.of(QUERY_PARAM_LOAD_OPERATIONAL_LIMIT_GROUPS, String.valueOf(true)),
String.valueOf(ElementType.LINE), Map.of(QUERY_PARAM_LOAD_OPERATIONAL_LIMIT_GROUPS, String.valueOf(true)),
String.valueOf(ElementType.TWO_WINDINGS_TRANSFORMER), Map.of(QUERY_PARAM_LOAD_OPERATIONAL_LIMIT_GROUPS, String.valueOf(true)),
String.valueOf(ElementType.GENERATOR), Map.of(QUERY_PARAM_LOAD_REGULATING_TERMINALS, String.valueOf(true))
String.valueOf(ElementType.GENERATOR), Map.of(QUERY_PARAM_LOAD_REGULATING_TERMINALS, String.valueOf(true)),
String.valueOf(ElementType.BUS), Map.of(QUERY_PARAM_LOAD_NETWORK_COMPONENTS, String.valueOf(true))
);
} else {
body = Map.of();
Expand Down
16 changes: 0 additions & 16 deletions src/test/resources/all-data-without-optionals.json
Original file line number Diff line number Diff line change
Expand Up @@ -2165,8 +2165,6 @@
"id": "VLGEN_0",
"v": "NaN",
"angle": "NaN",
"synchronousComponentNum": 0,
"connectedComponentNum": 0,
"voltageLevelId": "VLGEN",
"nominalVoltage": 24.0,
"country": "FR",
Expand All @@ -2181,8 +2179,6 @@
"id": "VLHV1_0",
"v": "NaN",
"angle": "NaN",
"synchronousComponentNum": 0,
"connectedComponentNum": 0,
"voltageLevelId": "VLHV1",
"nominalVoltage": 380.0,
"country": "FR",
Expand All @@ -2194,26 +2190,20 @@
"id": "VLHV2_0",
"v": "NaN",
"angle": "NaN",
"synchronousComponentNum": 0,
"connectedComponentNum": 0,
"voltageLevelId": "VLHV2",
"nominalVoltage": 380.0
},
{
"id": "VLLOAD_0",
"v": "NaN",
"angle": "NaN",
"synchronousComponentNum": 0,
"connectedComponentNum": 0,
"voltageLevelId": "VLLOAD",
"nominalVoltage": 150.0
},
{
"id": "VLNEW2_0",
"v": "NaN",
"angle": "NaN",
"synchronousComponentNum": 0,
"connectedComponentNum": 0,
"voltageLevelId": "VLNEW2",
"nominalVoltage": 225.0,
"country": "FR",
Expand All @@ -2228,8 +2218,6 @@
"id": "VLGEN3_0",
"v": "NaN",
"angle": "NaN",
"synchronousComponentNum": 0,
"connectedComponentNum": 0,
"voltageLevelId": "VLGEN3",
"nominalVoltage": 24.0,
"country": "FR",
Expand All @@ -2241,8 +2229,6 @@
"id": "VLGEN6_0",
"v": "NaN",
"angle": "NaN",
"synchronousComponentNum": 0,
"connectedComponentNum": 0,
"voltageLevelId": "VLGEN6",
"nominalVoltage": 24.0,
"country": "FR"
Expand All @@ -2251,8 +2237,6 @@
"id": "VLGEN4_0",
"v": "NaN",
"angle": "NaN",
"synchronousComponentNum": 1,
"connectedComponentNum": 1,
"voltageLevelId": "VLGEN4",
"nominalVoltage": 24.0,
"country": "FR"
Expand Down