From 98d2a6e129628c8ae3fd6016419514aa4cca580d Mon Sep 17 00:00:00 2001 From: Etienne LESOT Date: Thu, 21 Aug 2025 10:58:55 +0200 Subject: [PATCH 01/19] get all voltage level connections Signed-off-by: Etienne LESOT --- .../network/map/NetworkMapController.java | 10 ++++++++ .../network/map/NetworkMapService.java | 22 ++++++++++++++++ .../map/dto/ElementInfosWithConnection.java | 25 +++++++++++++++++++ .../map/dto/mapper/ElementInfosMapper.java | 14 +++++++++++ 4 files changed, 71 insertions(+) create mode 100644 src/main/java/org/gridsuite/network/map/dto/ElementInfosWithConnection.java diff --git a/src/main/java/org/gridsuite/network/map/NetworkMapController.java b/src/main/java/org/gridsuite/network/map/NetworkMapController.java index 5dce4984..7042b1bd 100644 --- a/src/main/java/org/gridsuite/network/map/NetworkMapController.java +++ b/src/main/java/org/gridsuite/network/map/NetworkMapController.java @@ -131,6 +131,16 @@ public List getVoltageLevelEquipments(@Parameter(description = "Ne return networkMapService.getVoltageLevelEquipments(networkUuid, voltageLevelId, variantId); } + @GetMapping(value = "/networks/{networkUuid}/voltage-levels/{voltageLevelId}/connections", produces = APPLICATION_JSON_VALUE) + @Operation(summary = "Get Voltage level connections") + @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "Voltage level equipments")}) + public List getVoltageLevelConnections(@Parameter(description = "Network UUID") @PathVariable("networkUuid") UUID networkUuid, + @Parameter(description = "Voltage level id") @PathVariable("voltageLevelId") String voltageLevelId, + @Parameter(description = "Variant Id") @RequestParam(name = "variantId", required = false) String variantId) { + return networkMapService.getVoltageLevelConnections(networkUuid, voltageLevelId, variantId); + } + + @GetMapping(value = "/networks/{networkUuid}/branch-or-3wt/{equipmentId}/voltage-level-id", produces = APPLICATION_JSON_VALUE) @Operation(summary = "Get the voltage level id for a branch or a 3wt side") @ApiResponses(value = { diff --git a/src/main/java/org/gridsuite/network/map/NetworkMapService.java b/src/main/java/org/gridsuite/network/map/NetworkMapService.java index 3ab0dd7d..d036089d 100644 --- a/src/main/java/org/gridsuite/network/map/NetworkMapService.java +++ b/src/main/java/org/gridsuite/network/map/NetworkMapService.java @@ -7,7 +7,9 @@ package org.gridsuite.network.map; import com.powsybl.commons.PowsyblException; +import com.powsybl.commons.report.ReportNode; import com.powsybl.iidm.network.*; +import com.powsybl.iidm.network.extensions.ConnectablePosition; import com.powsybl.network.store.client.NetworkStoreService; import com.powsybl.network.store.client.PreloadingStrategy; import org.gridsuite.network.map.dto.*; @@ -25,6 +27,8 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import static com.powsybl.iidm.modification.topology.TopologyModificationUtils.getFeedersByConnectable; + /** * @author Geoffroy Jamgotchian * @author Franck Lecuyer @@ -95,6 +99,24 @@ public List getVoltageLevelEquipments(UUID networkUuid, String vol .collect(Collectors.toList()); } + public List getVoltageLevelConnections(UUID networkUuid, String voltageLevelId, String variantId) { + Network network = getNetwork(networkUuid, PreloadingStrategy.NONE, variantId); + VoltageLevel voltageLevel = network.getVoltageLevel(voltageLevelId); + Map> feedersMap = getFeedersByConnectable(voltageLevel); + return network.getVoltageLevel(voltageLevelId).getConnectableStream() + .filter(connectable -> !(connectable instanceof BusbarSection)) + .flatMap(connectable -> { + if (!feedersMap.containsKey(connectable.getId())) { + return Stream.of(ElementInfosWithConnection.builder() + .id(connectable.getId()) + .name((String) connectable.getOptionalName().orElse("")) + .build()); + } + return feedersMap.get(connectable.getId()).stream().map(feeder -> ElementInfosMapper.toInfosWithConnection(connectable, feeder)); + }) + .collect(Collectors.toList()); + } + public List getVoltageLevelBusesOrBusbarSections(UUID networkUuid, String voltageLevelId, String variantId) { Network network = getNetwork(networkUuid, PreloadingStrategy.NONE, variantId); TopologyKind topologyKind = network.getVoltageLevel(voltageLevelId).getTopologyKind(); diff --git a/src/main/java/org/gridsuite/network/map/dto/ElementInfosWithConnection.java b/src/main/java/org/gridsuite/network/map/dto/ElementInfosWithConnection.java new file mode 100644 index 00000000..03a1a62a --- /dev/null +++ b/src/main/java/org/gridsuite/network/map/dto/ElementInfosWithConnection.java @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2025, RTE (http://www.rte-france.com) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +package org.gridsuite.network.map.dto; + +import com.powsybl.iidm.network.extensions.ConnectablePosition; +import lombok.Getter; +import lombok.experimental.SuperBuilder; + +/** + * @author Etienne Lesot + */ +@SuperBuilder +@Getter +public class ElementInfosWithConnection extends ElementInfos { + private String connectionLabel; + + private Integer connectionOrder; + + private ConnectablePosition.Direction connectionDirection; + +} diff --git a/src/main/java/org/gridsuite/network/map/dto/mapper/ElementInfosMapper.java b/src/main/java/org/gridsuite/network/map/dto/mapper/ElementInfosMapper.java index 44ee38cd..e4707d46 100644 --- a/src/main/java/org/gridsuite/network/map/dto/mapper/ElementInfosMapper.java +++ b/src/main/java/org/gridsuite/network/map/dto/mapper/ElementInfosMapper.java @@ -6,8 +6,11 @@ */ package org.gridsuite.network.map.dto.mapper; +import com.powsybl.iidm.network.Connectable; import com.powsybl.iidm.network.Identifiable; +import com.powsybl.iidm.network.extensions.ConnectablePosition; import org.gridsuite.network.map.dto.ElementInfos; +import org.gridsuite.network.map.dto.ElementInfosWithConnection; import org.gridsuite.network.map.dto.ElementInfosWithOperatingStatus; import org.gridsuite.network.map.dto.ElementInfosWithType; @@ -42,4 +45,15 @@ public static ElementInfosWithOperatingStatus toInfosWithOperatingStatus(Identif .operatingStatus(toOperatingStatus(identifiable)) .build(); } + + public static ElementInfosWithConnection toInfosWithConnection(Connectable connectable, ConnectablePosition.Feeder feeder) { + if (feeder == null) {} + return ElementInfosWithConnection.builder() + .id(connectable.getId()) + .name(connectable.getOptionalName().orElse(null)) + .connectionLabel(feeder.getName().orElse(connectable.getId())) + .connectionDirection(feeder.getDirection()) + .connectionOrder(feeder.getOrder().orElse(null)) + .build(); + } } From 884a6647fcee722f2c0a20054acf8a810c4eaf0d Mon Sep 17 00:00:00 2001 From: Etienne LESOT Date: Thu, 21 Aug 2025 11:06:33 +0200 Subject: [PATCH 02/19] fix Signed-off-by: Etienne LESOT --- .../java/org/gridsuite/network/map/NetworkMapController.java | 1 - src/main/java/org/gridsuite/network/map/NetworkMapService.java | 1 - .../org/gridsuite/network/map/dto/mapper/ElementInfosMapper.java | 1 - 3 files changed, 3 deletions(-) diff --git a/src/main/java/org/gridsuite/network/map/NetworkMapController.java b/src/main/java/org/gridsuite/network/map/NetworkMapController.java index 7042b1bd..525a77c2 100644 --- a/src/main/java/org/gridsuite/network/map/NetworkMapController.java +++ b/src/main/java/org/gridsuite/network/map/NetworkMapController.java @@ -140,7 +140,6 @@ public List getVoltageLevelConnections(@Parameter(description = "N return networkMapService.getVoltageLevelConnections(networkUuid, voltageLevelId, variantId); } - @GetMapping(value = "/networks/{networkUuid}/branch-or-3wt/{equipmentId}/voltage-level-id", produces = APPLICATION_JSON_VALUE) @Operation(summary = "Get the voltage level id for a branch or a 3wt side") @ApiResponses(value = { diff --git a/src/main/java/org/gridsuite/network/map/NetworkMapService.java b/src/main/java/org/gridsuite/network/map/NetworkMapService.java index d036089d..99476ed2 100644 --- a/src/main/java/org/gridsuite/network/map/NetworkMapService.java +++ b/src/main/java/org/gridsuite/network/map/NetworkMapService.java @@ -7,7 +7,6 @@ package org.gridsuite.network.map; import com.powsybl.commons.PowsyblException; -import com.powsybl.commons.report.ReportNode; import com.powsybl.iidm.network.*; import com.powsybl.iidm.network.extensions.ConnectablePosition; import com.powsybl.network.store.client.NetworkStoreService; diff --git a/src/main/java/org/gridsuite/network/map/dto/mapper/ElementInfosMapper.java b/src/main/java/org/gridsuite/network/map/dto/mapper/ElementInfosMapper.java index e4707d46..ac28b847 100644 --- a/src/main/java/org/gridsuite/network/map/dto/mapper/ElementInfosMapper.java +++ b/src/main/java/org/gridsuite/network/map/dto/mapper/ElementInfosMapper.java @@ -47,7 +47,6 @@ public static ElementInfosWithOperatingStatus toInfosWithOperatingStatus(Identif } public static ElementInfosWithConnection toInfosWithConnection(Connectable connectable, ConnectablePosition.Feeder feeder) { - if (feeder == null) {} return ElementInfosWithConnection.builder() .id(connectable.getId()) .name(connectable.getOptionalName().orElse(null)) From 732185ba2d2df6de4211730d288dba8a4b71495f Mon Sep 17 00:00:00 2001 From: Etienne LESOT Date: Fri, 22 Aug 2025 10:26:48 +0200 Subject: [PATCH 03/19] refactor Signed-off-by: Etienne LESOT --- .../network/map/NetworkMapController.java | 12 ++++----- .../network/map/NetworkMapService.java | 19 +++++++------- .../map/dto/ElementInfosWithConnection.java | 25 ------------------- .../map/dto/mapper/ElementInfosMapper.java | 12 ++++----- 4 files changed, 20 insertions(+), 48 deletions(-) delete mode 100644 src/main/java/org/gridsuite/network/map/dto/ElementInfosWithConnection.java diff --git a/src/main/java/org/gridsuite/network/map/NetworkMapController.java b/src/main/java/org/gridsuite/network/map/NetworkMapController.java index 525a77c2..32f50ba3 100644 --- a/src/main/java/org/gridsuite/network/map/NetworkMapController.java +++ b/src/main/java/org/gridsuite/network/map/NetworkMapController.java @@ -14,14 +14,12 @@ import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; import org.gridsuite.network.map.dto.*; +import org.gridsuite.network.map.dto.definition.extension.ConnectablePositionInfos; import org.gridsuite.network.map.dto.definition.hvdc.HvdcShuntCompensatorsInfos; import org.springframework.context.annotation.ComponentScan; import org.springframework.web.bind.annotation.*; -import java.util.Comparator; -import java.util.List; -import java.util.Optional; -import java.util.UUID; +import java.util.*; import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; @@ -134,9 +132,9 @@ public List getVoltageLevelEquipments(@Parameter(description = "Ne @GetMapping(value = "/networks/{networkUuid}/voltage-levels/{voltageLevelId}/connections", produces = APPLICATION_JSON_VALUE) @Operation(summary = "Get Voltage level connections") @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "Voltage level equipments")}) - public List getVoltageLevelConnections(@Parameter(description = "Network UUID") @PathVariable("networkUuid") UUID networkUuid, - @Parameter(description = "Voltage level id") @PathVariable("voltageLevelId") String voltageLevelId, - @Parameter(description = "Variant Id") @RequestParam(name = "variantId", required = false) String variantId) { + public Map getVoltageLevelConnections(@Parameter(description = "Network UUID") @PathVariable("networkUuid") UUID networkUuid, + @Parameter(description = "Voltage level id") @PathVariable("voltageLevelId") String voltageLevelId, + @Parameter(description = "Variant Id") @RequestParam(name = "variantId", required = false) String variantId) { return networkMapService.getVoltageLevelConnections(networkUuid, voltageLevelId, variantId); } diff --git a/src/main/java/org/gridsuite/network/map/NetworkMapService.java b/src/main/java/org/gridsuite/network/map/NetworkMapService.java index 99476ed2..fbf2d0bf 100644 --- a/src/main/java/org/gridsuite/network/map/NetworkMapService.java +++ b/src/main/java/org/gridsuite/network/map/NetworkMapService.java @@ -12,6 +12,7 @@ import com.powsybl.network.store.client.NetworkStoreService; import com.powsybl.network.store.client.PreloadingStrategy; import org.gridsuite.network.map.dto.*; +import org.gridsuite.network.map.dto.definition.extension.ConnectablePositionInfos; import org.gridsuite.network.map.dto.definition.hvdc.HvdcShuntCompensatorsInfos; import org.gridsuite.network.map.dto.mapper.ElementInfosMapper; import org.gridsuite.network.map.dto.mapper.HvdcInfosMapper; @@ -98,22 +99,22 @@ public List getVoltageLevelEquipments(UUID networkUuid, String vol .collect(Collectors.toList()); } - public List getVoltageLevelConnections(UUID networkUuid, String voltageLevelId, String variantId) { + public Map getVoltageLevelConnections(UUID networkUuid, String voltageLevelId, String variantId) { Network network = getNetwork(networkUuid, PreloadingStrategy.NONE, variantId); VoltageLevel voltageLevel = network.getVoltageLevel(voltageLevelId); Map> feedersMap = getFeedersByConnectable(voltageLevel); - return network.getVoltageLevel(voltageLevelId).getConnectableStream() + Map connections = new HashMap<>(); + network.getVoltageLevel(voltageLevelId).getConnectableStream() .filter(connectable -> !(connectable instanceof BusbarSection)) - .flatMap(connectable -> { + .forEach(connectable -> { if (!feedersMap.containsKey(connectable.getId())) { - return Stream.of(ElementInfosWithConnection.builder() - .id(connectable.getId()) - .name((String) connectable.getOptionalName().orElse("")) + connections.put(connectable.getId(), ConnectablePositionInfos.builder() .build()); } - return feedersMap.get(connectable.getId()).stream().map(feeder -> ElementInfosMapper.toInfosWithConnection(connectable, feeder)); - }) - .collect(Collectors.toList()); + feedersMap.get(connectable.getId()).forEach(feeder -> + connections.put(connectable.getId(), ElementInfosMapper.toConnectablePositionInfos(connectable, feeder))); + }); + return connections; } public List getVoltageLevelBusesOrBusbarSections(UUID networkUuid, String voltageLevelId, String variantId) { diff --git a/src/main/java/org/gridsuite/network/map/dto/ElementInfosWithConnection.java b/src/main/java/org/gridsuite/network/map/dto/ElementInfosWithConnection.java deleted file mode 100644 index 03a1a62a..00000000 --- a/src/main/java/org/gridsuite/network/map/dto/ElementInfosWithConnection.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Copyright (c) 2025, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package org.gridsuite.network.map.dto; - -import com.powsybl.iidm.network.extensions.ConnectablePosition; -import lombok.Getter; -import lombok.experimental.SuperBuilder; - -/** - * @author Etienne Lesot - */ -@SuperBuilder -@Getter -public class ElementInfosWithConnection extends ElementInfos { - private String connectionLabel; - - private Integer connectionOrder; - - private ConnectablePosition.Direction connectionDirection; - -} diff --git a/src/main/java/org/gridsuite/network/map/dto/mapper/ElementInfosMapper.java b/src/main/java/org/gridsuite/network/map/dto/mapper/ElementInfosMapper.java index ac28b847..9852198c 100644 --- a/src/main/java/org/gridsuite/network/map/dto/mapper/ElementInfosMapper.java +++ b/src/main/java/org/gridsuite/network/map/dto/mapper/ElementInfosMapper.java @@ -10,9 +10,9 @@ import com.powsybl.iidm.network.Identifiable; import com.powsybl.iidm.network.extensions.ConnectablePosition; import org.gridsuite.network.map.dto.ElementInfos; -import org.gridsuite.network.map.dto.ElementInfosWithConnection; import org.gridsuite.network.map.dto.ElementInfosWithOperatingStatus; import org.gridsuite.network.map.dto.ElementInfosWithType; +import org.gridsuite.network.map.dto.definition.extension.ConnectablePositionInfos; import static org.gridsuite.network.map.dto.utils.ElementUtils.toOperatingStatus; @@ -46,13 +46,11 @@ public static ElementInfosWithOperatingStatus toInfosWithOperatingStatus(Identif .build(); } - public static ElementInfosWithConnection toInfosWithConnection(Connectable connectable, ConnectablePosition.Feeder feeder) { - return ElementInfosWithConnection.builder() - .id(connectable.getId()) - .name(connectable.getOptionalName().orElse(null)) - .connectionLabel(feeder.getName().orElse(connectable.getId())) + public static ConnectablePositionInfos toConnectablePositionInfos(Connectable connectable, ConnectablePosition.Feeder feeder) { + return ConnectablePositionInfos.builder() + .connectionPosition(feeder.getOrder().orElse(null)) .connectionDirection(feeder.getDirection()) - .connectionOrder(feeder.getOrder().orElse(null)) + .connectionName(feeder.getName().orElse(connectable.getId())) .build(); } } From 46700f8d0dabb605899383746e0f055f2d5a9a40 Mon Sep 17 00:00:00 2001 From: Etienne LESOT Date: Fri, 22 Aug 2025 15:05:36 +0200 Subject: [PATCH 04/19] refactor everything Signed-off-by: Etienne LESOT --- .../network/map/NetworkMapController.java | 15 +-- .../network/map/NetworkMapService.java | 22 ----- .../extension/ConnectablePositionInfos.java | 6 ++ .../voltagelevel/FeederBayInfos.java | 14 +++ .../voltagelevel/VoltageLevelFormInfos.java | 3 + .../map/dto/mapper/ElementInfosMapper.java | 11 --- .../dto/mapper/VoltageLevelInfosMapper.java | 28 +++++- .../network/map/dto/utils/ElementUtils.java | 12 ++- .../network/map/NetworkMapControllerTest.java | 3 +- src/test/resources/substations-form-data.json | 53 +++++++---- .../resources/voltage-level-form-data.json | 32 ++++++- .../resources/voltage-levels-form-data.json | 93 ++++++++++++------- 12 files changed, 185 insertions(+), 107 deletions(-) create mode 100644 src/main/java/org/gridsuite/network/map/dto/definition/voltagelevel/FeederBayInfos.java diff --git a/src/main/java/org/gridsuite/network/map/NetworkMapController.java b/src/main/java/org/gridsuite/network/map/NetworkMapController.java index 32f50ba3..5dce4984 100644 --- a/src/main/java/org/gridsuite/network/map/NetworkMapController.java +++ b/src/main/java/org/gridsuite/network/map/NetworkMapController.java @@ -14,12 +14,14 @@ import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; import org.gridsuite.network.map.dto.*; -import org.gridsuite.network.map.dto.definition.extension.ConnectablePositionInfos; import org.gridsuite.network.map.dto.definition.hvdc.HvdcShuntCompensatorsInfos; import org.springframework.context.annotation.ComponentScan; import org.springframework.web.bind.annotation.*; -import java.util.*; +import java.util.Comparator; +import java.util.List; +import java.util.Optional; +import java.util.UUID; import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; @@ -129,15 +131,6 @@ public List getVoltageLevelEquipments(@Parameter(description = "Ne return networkMapService.getVoltageLevelEquipments(networkUuid, voltageLevelId, variantId); } - @GetMapping(value = "/networks/{networkUuid}/voltage-levels/{voltageLevelId}/connections", produces = APPLICATION_JSON_VALUE) - @Operation(summary = "Get Voltage level connections") - @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "Voltage level equipments")}) - public Map getVoltageLevelConnections(@Parameter(description = "Network UUID") @PathVariable("networkUuid") UUID networkUuid, - @Parameter(description = "Voltage level id") @PathVariable("voltageLevelId") String voltageLevelId, - @Parameter(description = "Variant Id") @RequestParam(name = "variantId", required = false) String variantId) { - return networkMapService.getVoltageLevelConnections(networkUuid, voltageLevelId, variantId); - } - @GetMapping(value = "/networks/{networkUuid}/branch-or-3wt/{equipmentId}/voltage-level-id", produces = APPLICATION_JSON_VALUE) @Operation(summary = "Get the voltage level id for a branch or a 3wt side") @ApiResponses(value = { diff --git a/src/main/java/org/gridsuite/network/map/NetworkMapService.java b/src/main/java/org/gridsuite/network/map/NetworkMapService.java index fbf2d0bf..3ab0dd7d 100644 --- a/src/main/java/org/gridsuite/network/map/NetworkMapService.java +++ b/src/main/java/org/gridsuite/network/map/NetworkMapService.java @@ -8,11 +8,9 @@ import com.powsybl.commons.PowsyblException; import com.powsybl.iidm.network.*; -import com.powsybl.iidm.network.extensions.ConnectablePosition; import com.powsybl.network.store.client.NetworkStoreService; import com.powsybl.network.store.client.PreloadingStrategy; import org.gridsuite.network.map.dto.*; -import org.gridsuite.network.map.dto.definition.extension.ConnectablePositionInfos; import org.gridsuite.network.map.dto.definition.hvdc.HvdcShuntCompensatorsInfos; import org.gridsuite.network.map.dto.mapper.ElementInfosMapper; import org.gridsuite.network.map.dto.mapper.HvdcInfosMapper; @@ -27,8 +25,6 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import static com.powsybl.iidm.modification.topology.TopologyModificationUtils.getFeedersByConnectable; - /** * @author Geoffroy Jamgotchian * @author Franck Lecuyer @@ -99,24 +95,6 @@ public List getVoltageLevelEquipments(UUID networkUuid, String vol .collect(Collectors.toList()); } - public Map getVoltageLevelConnections(UUID networkUuid, String voltageLevelId, String variantId) { - Network network = getNetwork(networkUuid, PreloadingStrategy.NONE, variantId); - VoltageLevel voltageLevel = network.getVoltageLevel(voltageLevelId); - Map> feedersMap = getFeedersByConnectable(voltageLevel); - Map connections = new HashMap<>(); - network.getVoltageLevel(voltageLevelId).getConnectableStream() - .filter(connectable -> !(connectable instanceof BusbarSection)) - .forEach(connectable -> { - if (!feedersMap.containsKey(connectable.getId())) { - connections.put(connectable.getId(), ConnectablePositionInfos.builder() - .build()); - } - feedersMap.get(connectable.getId()).forEach(feeder -> - connections.put(connectable.getId(), ElementInfosMapper.toConnectablePositionInfos(connectable, feeder))); - }); - return connections; - } - public List getVoltageLevelBusesOrBusbarSections(UUID networkUuid, String voltageLevelId, String variantId) { Network network = getNetwork(networkUuid, PreloadingStrategy.NONE, variantId); TopologyKind topologyKind = network.getVoltageLevel(voltageLevelId).getTopologyKind(); diff --git a/src/main/java/org/gridsuite/network/map/dto/definition/extension/ConnectablePositionInfos.java b/src/main/java/org/gridsuite/network/map/dto/definition/extension/ConnectablePositionInfos.java index d40f37a6..29af5a6b 100644 --- a/src/main/java/org/gridsuite/network/map/dto/definition/extension/ConnectablePositionInfos.java +++ b/src/main/java/org/gridsuite/network/map/dto/definition/extension/ConnectablePositionInfos.java @@ -1,3 +1,9 @@ +/** + * Copyright (c) 2024, RTE (http://www.rte-france.com) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ package org.gridsuite.network.map.dto.definition.extension; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/src/main/java/org/gridsuite/network/map/dto/definition/voltagelevel/FeederBayInfos.java b/src/main/java/org/gridsuite/network/map/dto/definition/voltagelevel/FeederBayInfos.java new file mode 100644 index 00000000..1aa3ed44 --- /dev/null +++ b/src/main/java/org/gridsuite/network/map/dto/definition/voltagelevel/FeederBayInfos.java @@ -0,0 +1,14 @@ +/** + * Copyright (c) 2025, RTE (http://www.rte-france.com) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +package org.gridsuite.network.map.dto.definition.voltagelevel; + +import org.gridsuite.network.map.dto.definition.extension.ConnectablePositionInfos; + +/** + * @author Etienne Lesot + */ +public record FeederBayInfos(String busbarId, ConnectablePositionInfos connectablePositionInfos) { } diff --git a/src/main/java/org/gridsuite/network/map/dto/definition/voltagelevel/VoltageLevelFormInfos.java b/src/main/java/org/gridsuite/network/map/dto/definition/voltagelevel/VoltageLevelFormInfos.java index 3da69853..fa61e9d6 100644 --- a/src/main/java/org/gridsuite/network/map/dto/definition/voltagelevel/VoltageLevelFormInfos.java +++ b/src/main/java/org/gridsuite/network/map/dto/definition/voltagelevel/VoltageLevelFormInfos.java @@ -57,4 +57,7 @@ public class VoltageLevelFormInfos extends ElementInfosWithProperties { @JsonInclude(JsonInclude.Include.NON_NULL) Map> busBarSectionInfos; + @JsonInclude(JsonInclude.Include.NON_NULL) + Map> connectablePositionInfos; + } diff --git a/src/main/java/org/gridsuite/network/map/dto/mapper/ElementInfosMapper.java b/src/main/java/org/gridsuite/network/map/dto/mapper/ElementInfosMapper.java index 9852198c..44ee38cd 100644 --- a/src/main/java/org/gridsuite/network/map/dto/mapper/ElementInfosMapper.java +++ b/src/main/java/org/gridsuite/network/map/dto/mapper/ElementInfosMapper.java @@ -6,13 +6,10 @@ */ package org.gridsuite.network.map.dto.mapper; -import com.powsybl.iidm.network.Connectable; import com.powsybl.iidm.network.Identifiable; -import com.powsybl.iidm.network.extensions.ConnectablePosition; import org.gridsuite.network.map.dto.ElementInfos; import org.gridsuite.network.map.dto.ElementInfosWithOperatingStatus; import org.gridsuite.network.map.dto.ElementInfosWithType; -import org.gridsuite.network.map.dto.definition.extension.ConnectablePositionInfos; import static org.gridsuite.network.map.dto.utils.ElementUtils.toOperatingStatus; @@ -45,12 +42,4 @@ public static ElementInfosWithOperatingStatus toInfosWithOperatingStatus(Identif .operatingStatus(toOperatingStatus(identifiable)) .build(); } - - public static ConnectablePositionInfos toConnectablePositionInfos(Connectable connectable, ConnectablePosition.Feeder feeder) { - return ConnectablePositionInfos.builder() - .connectionPosition(feeder.getOrder().orElse(null)) - .connectionDirection(feeder.getDirection()) - .connectionName(feeder.getName().orElse(connectable.getId())) - .build(); - } } diff --git a/src/main/java/org/gridsuite/network/map/dto/mapper/VoltageLevelInfosMapper.java b/src/main/java/org/gridsuite/network/map/dto/mapper/VoltageLevelInfosMapper.java index 57d950da..77b8bdad 100644 --- a/src/main/java/org/gridsuite/network/map/dto/mapper/VoltageLevelInfosMapper.java +++ b/src/main/java/org/gridsuite/network/map/dto/mapper/VoltageLevelInfosMapper.java @@ -13,6 +13,7 @@ import org.gridsuite.network.map.dto.ElementInfos; import org.gridsuite.network.map.dto.InfoTypeParameters; import org.gridsuite.network.map.dto.definition.busbarsection.BusBarSectionFormInfos; +import org.gridsuite.network.map.dto.definition.voltagelevel.FeederBayInfos; import org.gridsuite.network.map.dto.definition.voltagelevel.VoltageLevelFormInfos; import org.gridsuite.network.map.dto.definition.voltagelevel.VoltageLevelMapInfos; import org.gridsuite.network.map.dto.definition.voltagelevel.VoltageLevelTabInfos; @@ -83,7 +84,7 @@ public static VoltageLevelTopologyInfos getTopologyInfos(VoltageLevel voltageLev return topologyInfos; } - protected static VoltageLevelFormInfos toFormInfos(Identifiable identifiable) { + static VoltageLevelFormInfos toFormInfos(Identifiable identifiable) { VoltageLevel voltageLevel = (VoltageLevel) identifiable; VoltageLevelFormInfos.VoltageLevelFormInfosBuilder builder = VoltageLevelFormInfos.builder() .name(voltageLevel.getOptionalName().orElse(null)) @@ -102,6 +103,7 @@ protected static VoltageLevelFormInfos toFormInfos(Identifiable identifiable) builder.switchKinds(vlTopologyInfos.getSwitchKinds()); builder.isRetrievedBusbarSections(vlTopologyInfos.isRetrievedBusbarSections()); builder.busBarSectionInfos(vlTopologyInfos.getBusBarSectionInfosGrouped()); + builder.connectablePositionInfos(getConnectionInfos(voltageLevel)); } builder.identifiableShortCircuit(toIdentifiableShortCircuit(voltageLevel)); @@ -109,6 +111,30 @@ protected static VoltageLevelFormInfos toFormInfos(Identifiable identifiable) return builder.build(); } + private static Map> getConnectionInfos(VoltageLevel voltageLevel) { + Map> connections = new HashMap<>(); + voltageLevel.getConnectableStream() + .filter(connectable -> !(connectable instanceof BusbarSection)) + .forEach(connectable -> { + switch (connectable) { + case Injection injection -> connections.put(injection.getId(), List.of(new FeederBayInfos(getBusOrBusbarSection(injection.getTerminal()), + toMapConnectablePosition(injection, 0)))); + case Branch branch -> { + List branchConnections = new ArrayList<>(); + if (branch.getTerminal1().getVoltageLevel().getId().equals(voltageLevel.getId())) { + branchConnections.add(new FeederBayInfos(getBusOrBusbarSection(branch.getTerminal1()), toMapConnectablePosition(branch, 1))); + } + if (branch.getTerminal2().getVoltageLevel().getId().equals(voltageLevel.getId())) { + branchConnections.add(new FeederBayInfos(getBusOrBusbarSection(branch.getTerminal1()), toMapConnectablePosition(branch, 2))); + } + connections.put(branch.getId(), branchConnections); + } + default -> throw new IllegalArgumentException("connectable type: " + connectable.getClass() + " not supported"); + } + }); + return connections; + } + protected static VoltageLevelMapInfos toMapInfos(Identifiable identifiable) { VoltageLevel voltageLevel = (VoltageLevel) identifiable; return VoltageLevelMapInfos.builder() diff --git a/src/main/java/org/gridsuite/network/map/dto/utils/ElementUtils.java b/src/main/java/org/gridsuite/network/map/dto/utils/ElementUtils.java index 7dae13ce..235b69b0 100644 --- a/src/main/java/org/gridsuite/network/map/dto/utils/ElementUtils.java +++ b/src/main/java/org/gridsuite/network/map/dto/utils/ElementUtils.java @@ -53,13 +53,17 @@ private static ConnectablePosition.Feeder getFeederInfos(Identifiable identif } } - public static ConnectablePositionInfos toMapConnectablePosition(Identifiable branch, int index) { + public static ConnectablePositionInfos toMapConnectablePosition(Identifiable identifiable, int index) { + ConnectablePosition.Feeder feeder = getFeederInfos(identifiable, index); + return convertFeederToConnectablePositionInfos(feeder); + } + + public static ConnectablePositionInfos convertFeederToConnectablePositionInfos(ConnectablePosition.Feeder feeder) { ConnectablePositionInfos.ConnectablePositionInfosBuilder builder = ConnectablePositionInfos.builder(); - ConnectablePosition.Feeder feeder = getFeederInfos(branch, index); if (feeder != null) { builder.connectionDirection(feeder.getDirection() == null ? null : feeder.getDirection()) - .connectionPosition(feeder.getOrder().orElse(null)) - .connectionName(feeder.getName().orElse(null)); + .connectionPosition(feeder.getOrder().orElse(null)) + .connectionName(feeder.getName().orElse(null)); } return builder.build(); } diff --git a/src/test/java/org/gridsuite/network/map/NetworkMapControllerTest.java b/src/test/java/org/gridsuite/network/map/NetworkMapControllerTest.java index b35fbd55..f8a392f5 100644 --- a/src/test/java/org/gridsuite/network/map/NetworkMapControllerTest.java +++ b/src/test/java/org/gridsuite/network/map/NetworkMapControllerTest.java @@ -1352,7 +1352,7 @@ private void succeedingTestForElementInfosWithElementId(UUID networkUuid, String ) .andExpect(status().isOk()) .andReturn(); - + System.out.println(res.getResponse().getContentAsString()); JSONAssert.assertEquals(expectedJson, res.getResponse().getContentAsString(), JSONCompareMode.NON_EXTENSIBLE); } @@ -1412,7 +1412,6 @@ private void succeedingTestForElementsInfos(UUID networkUuid, String variantId, ) .andExpect(status().isOk()) .andReturn(); - JSONAssert.assertEquals(expectedJson, mvcResult.getResponse().getContentAsString(), JSONCompareMode.NON_EXTENSIBLE); } diff --git a/src/test/resources/substations-form-data.json b/src/test/resources/substations-form-data.json index 19cb44f6..6a1a2c7d 100644 --- a/src/test/resources/substations-form-data.json +++ b/src/test/resources/substations-form-data.json @@ -1,9 +1,4 @@ [ - { - "id": "P0", - "country": "FR", - "voltageLevels": [] - }, { "id": "P1", "name": "P1_Name", @@ -14,18 +9,18 @@ "voltageLevels": [ { "id": "VLGEN", + "name": "VLGEN_Name", + "properties": { + "Country": "FR" + }, "topologyKind": "BUS_BREAKER", "substationId": "P1", "nominalV": 24.0, - "name": "VLGEN_Name", "lowVoltageLimit": 200.0, "highVoltageLimit": 400.0, "identifiableShortCircuit": { "ipMin": 10.0, "ipMax": 120.0 - }, - "properties": { - "Country": "FR" } }, { @@ -36,12 +31,12 @@ }, { "id": "VLNEW2", - "topologyKind": "BUS_BREAKER", - "substationId": "P1", - "nominalV": 225.0, "properties": { "Country": "FR" - } + }, + "topologyKind": "BUS_BREAKER", + "substationId": "P1", + "nominalV": 225.0 } ] }, @@ -62,6 +57,11 @@ } ] }, + { + "id": "P0", + "country": "FR", + "voltageLevels": [] + }, { "id": "P3", "properties": { @@ -104,8 +104,28 @@ "DISCONNECTOR" ], "isRetrievedBusbarSections": true, - "busBarSectionInfos" : { - "1" : ["NGEN4"] + "busBarSectionInfos": { + "1": [ + "NGEN4" + ] + }, + "connectablePositionInfos": { + "SHUNT_VLNB": [ + { + "busbarId": "NGEN4", + "connectablePositionInfos": { + "connectionDirection": null + } + } + ], + "SHUNT_NON_LINEAR": [ + { + "busbarId": null, + "connectablePositionInfos": { + "connectionDirection": null + } + } + ] } } ] @@ -129,7 +149,8 @@ "sectionCount": 1, "switchKinds": [], "isRetrievedBusbarSections": false, - "busBarSectionInfos" : { } + "busBarSectionInfos": {}, + "connectablePositionInfos": {} } ] } diff --git a/src/test/resources/voltage-level-form-data.json b/src/test/resources/voltage-level-form-data.json index 7cb2e6dd..389bdb01 100644 --- a/src/test/resources/voltage-level-form-data.json +++ b/src/test/resources/voltage-level-form-data.json @@ -1,13 +1,35 @@ { "id": "VLGEN4", + "topologyKind": "NODE_BREAKER", "substationId": "P4", "nominalV": 24.0, - "topologyKind": "NODE_BREAKER", "busbarCount": 1, "sectionCount": 2, - "switchKinds": ["DISCONNECTOR"], + "switchKinds": [ + "DISCONNECTOR" + ], "isRetrievedBusbarSections": true, - "busBarSectionInfos" : { - "1" : [ "NGEN4"] + "busBarSectionInfos": { + "1": [ + "NGEN4" + ] + }, + "connectablePositionInfos": { + "SHUNT_VLNB": [ + { + "busbarId": "NGEN4", + "connectablePositionInfos": { + "connectionDirection": null + } + } + ], + "SHUNT_NON_LINEAR": [ + { + "busbarId": null, + "connectablePositionInfos": { + "connectionDirection": null + } + } + ] } -} +} \ No newline at end of file diff --git a/src/test/resources/voltage-levels-form-data.json b/src/test/resources/voltage-levels-form-data.json index a557f050..ceae968b 100644 --- a/src/test/resources/voltage-levels-form-data.json +++ b/src/test/resources/voltage-levels-form-data.json @@ -1,74 +1,103 @@ [ - { - "id": "VL", - "name":"VL", - "nominalV": 24.0, - "topologyKind": "BUS_BREAKER" - }, { "id": "VLGEN", + "name": "VLGEN_Name", + "properties": { + "Country": "FR" + }, + "topologyKind": "BUS_BREAKER", "substationId": "P1", "nominalV": 24.0, - "topologyKind": "BUS_BREAKER", - "name": "VLGEN_Name", "lowVoltageLimit": 200.0, "highVoltageLimit": 400.0, "identifiableShortCircuit": { "ipMin": 10.0, "ipMax": 120.0 - }, - "properties": { - "Country": "FR" } }, { "id": "VLHV1", + "topologyKind": "BUS_BREAKER", "substationId": "P1", - "nominalV": 380.0, - "topologyKind": "BUS_BREAKER" + "nominalV": 380.0 }, { "id": "VLHV2", + "topologyKind": "BUS_BREAKER", "substationId": "P2", - "nominalV": 380.0, - "topologyKind": "BUS_BREAKER" + "nominalV": 380.0 }, { "id": "VLLOAD", + "topologyKind": "BUS_BREAKER", "substationId": "P2", - "nominalV": 150.0, - "topologyKind": "BUS_BREAKER" + "nominalV": 150.0 }, { "id": "VLNEW2", - "substationId": "P1", - "nominalV": 225.0, - "topologyKind": "BUS_BREAKER", "properties": { "Country": "FR" - } + }, + "topologyKind": "BUS_BREAKER", + "substationId": "P1", + "nominalV": 225.0 }, { "id": "VLGEN3", + "topologyKind": "BUS_BREAKER", "substationId": "P3", - "nominalV": 24.0, - "topologyKind": "BUS_BREAKER" + "nominalV": 24.0 + }, + { + "id": "VLGEN6", + "topologyKind": "BUS_BREAKER", + "substationId": "P6", + "nominalV": 24.0 + }, + { + "id": "VL", + "name": "VL", + "topologyKind": "BUS_BREAKER", + "nominalV": 24.0 }, { "id": "VLGEN4", + "topologyKind": "NODE_BREAKER", "substationId": "P4", "nominalV": 24.0, - "topologyKind": "NODE_BREAKER", "busbarCount": 1, "sectionCount": 2, - "switchKinds": ["DISCONNECTOR"], + "switchKinds": [ + "DISCONNECTOR" + ], "isRetrievedBusbarSections": true, - "busBarSectionInfos" : { - "1" : [ "NGEN4" ] + "busBarSectionInfos": { + "1": [ + "NGEN4" + ] + }, + "connectablePositionInfos": { + "SHUNT_VLNB": [ + { + "busbarId": "NGEN4", + "connectablePositionInfos": { + "connectionDirection": null + } + } + ], + "SHUNT_NON_LINEAR": [ + { + "busbarId": null, + "connectablePositionInfos": { + "connectionDirection": null + } + } + ] } }, { "id": "VLGEN5", + "topologyKind": "NODE_BREAKER", "substationId": "P5", "nominalV": 24.0, "lowVoltageLimit": 20.0, @@ -77,17 +106,11 @@ "ipMin": 0.0, "ipMax": 100.0 }, - "topologyKind": "NODE_BREAKER", "busbarCount": 1, "sectionCount": 1, "switchKinds": [], "isRetrievedBusbarSections": false, - "busBarSectionInfos" : { } - }, - { - "id": "VLGEN6", - "topologyKind": "BUS_BREAKER", - "substationId": "P6", - "nominalV": 24.0 + "busBarSectionInfos": {}, + "connectablePositionInfos": {} } ] \ No newline at end of file From 6b9b5a49b1c4ac83890b7b0f30cb3a6e446e9831 Mon Sep 17 00:00:00 2001 From: Etienne LESOT Date: Fri, 22 Aug 2025 15:06:34 +0200 Subject: [PATCH 05/19] fix Signed-off-by: Etienne LESOT --- .../java/org/gridsuite/network/map/NetworkMapControllerTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test/java/org/gridsuite/network/map/NetworkMapControllerTest.java b/src/test/java/org/gridsuite/network/map/NetworkMapControllerTest.java index f8a392f5..3bf67872 100644 --- a/src/test/java/org/gridsuite/network/map/NetworkMapControllerTest.java +++ b/src/test/java/org/gridsuite/network/map/NetworkMapControllerTest.java @@ -1352,7 +1352,6 @@ private void succeedingTestForElementInfosWithElementId(UUID networkUuid, String ) .andExpect(status().isOk()) .andReturn(); - System.out.println(res.getResponse().getContentAsString()); JSONAssert.assertEquals(expectedJson, res.getResponse().getContentAsString(), JSONCompareMode.NON_EXTENSIBLE); } From 6d0e15efefe5c5edd83e303923e0b860d6d6afc0 Mon Sep 17 00:00:00 2001 From: Etienne LESOT Date: Fri, 22 Aug 2025 15:11:15 +0200 Subject: [PATCH 06/19] fix Signed-off-by: Etienne LESOT --- .../network/map/dto/mapper/VoltageLevelInfosMapper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/gridsuite/network/map/dto/mapper/VoltageLevelInfosMapper.java b/src/main/java/org/gridsuite/network/map/dto/mapper/VoltageLevelInfosMapper.java index 77b8bdad..fbe545f3 100644 --- a/src/main/java/org/gridsuite/network/map/dto/mapper/VoltageLevelInfosMapper.java +++ b/src/main/java/org/gridsuite/network/map/dto/mapper/VoltageLevelInfosMapper.java @@ -125,7 +125,7 @@ private static Map> getConnectionInfos(VoltageLevel branchConnections.add(new FeederBayInfos(getBusOrBusbarSection(branch.getTerminal1()), toMapConnectablePosition(branch, 1))); } if (branch.getTerminal2().getVoltageLevel().getId().equals(voltageLevel.getId())) { - branchConnections.add(new FeederBayInfos(getBusOrBusbarSection(branch.getTerminal1()), toMapConnectablePosition(branch, 2))); + branchConnections.add(new FeederBayInfos(getBusOrBusbarSection(branch.getTerminal2()), toMapConnectablePosition(branch, 2))); } connections.put(branch.getId(), branchConnections); } From 01cbb742c6084b14060f5a93853d5cf2e3669bc1 Mon Sep 17 00:00:00 2001 From: Etienne LESOT Date: Wed, 27 Aug 2025 15:29:52 +0200 Subject: [PATCH 07/19] fix Signed-off-by: Etienne LESOT --- .../dto/definition/voltagelevel/VoltageLevelFormInfos.java | 2 +- .../network/map/dto/mapper/VoltageLevelInfosMapper.java | 2 +- src/test/resources/substations-form-data.json | 4 ++-- src/test/resources/voltage-level-form-data.json | 2 +- src/test/resources/voltage-levels-form-data.json | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/gridsuite/network/map/dto/definition/voltagelevel/VoltageLevelFormInfos.java b/src/main/java/org/gridsuite/network/map/dto/definition/voltagelevel/VoltageLevelFormInfos.java index fa61e9d6..df9ca6bb 100644 --- a/src/main/java/org/gridsuite/network/map/dto/definition/voltagelevel/VoltageLevelFormInfos.java +++ b/src/main/java/org/gridsuite/network/map/dto/definition/voltagelevel/VoltageLevelFormInfos.java @@ -58,6 +58,6 @@ public class VoltageLevelFormInfos extends ElementInfosWithProperties { Map> busBarSectionInfos; @JsonInclude(JsonInclude.Include.NON_NULL) - Map> connectablePositionInfos; + Map> feederBaysInfos; } diff --git a/src/main/java/org/gridsuite/network/map/dto/mapper/VoltageLevelInfosMapper.java b/src/main/java/org/gridsuite/network/map/dto/mapper/VoltageLevelInfosMapper.java index fbe545f3..233b8e76 100644 --- a/src/main/java/org/gridsuite/network/map/dto/mapper/VoltageLevelInfosMapper.java +++ b/src/main/java/org/gridsuite/network/map/dto/mapper/VoltageLevelInfosMapper.java @@ -103,7 +103,7 @@ static VoltageLevelFormInfos toFormInfos(Identifiable identifiable) { builder.switchKinds(vlTopologyInfos.getSwitchKinds()); builder.isRetrievedBusbarSections(vlTopologyInfos.isRetrievedBusbarSections()); builder.busBarSectionInfos(vlTopologyInfos.getBusBarSectionInfosGrouped()); - builder.connectablePositionInfos(getConnectionInfos(voltageLevel)); + builder.feederBaysInfos(getConnectionInfos(voltageLevel)); } builder.identifiableShortCircuit(toIdentifiableShortCircuit(voltageLevel)); diff --git a/src/test/resources/substations-form-data.json b/src/test/resources/substations-form-data.json index 6a1a2c7d..83a2e6b3 100644 --- a/src/test/resources/substations-form-data.json +++ b/src/test/resources/substations-form-data.json @@ -109,7 +109,7 @@ "NGEN4" ] }, - "connectablePositionInfos": { + "feederBaysInfos": { "SHUNT_VLNB": [ { "busbarId": "NGEN4", @@ -150,7 +150,7 @@ "switchKinds": [], "isRetrievedBusbarSections": false, "busBarSectionInfos": {}, - "connectablePositionInfos": {} + "feederBaysInfos": {} } ] } diff --git a/src/test/resources/voltage-level-form-data.json b/src/test/resources/voltage-level-form-data.json index 389bdb01..8dbae7b1 100644 --- a/src/test/resources/voltage-level-form-data.json +++ b/src/test/resources/voltage-level-form-data.json @@ -14,7 +14,7 @@ "NGEN4" ] }, - "connectablePositionInfos": { + "feederBaysInfos": { "SHUNT_VLNB": [ { "busbarId": "NGEN4", diff --git a/src/test/resources/voltage-levels-form-data.json b/src/test/resources/voltage-levels-form-data.json index ceae968b..fe6791d9 100644 --- a/src/test/resources/voltage-levels-form-data.json +++ b/src/test/resources/voltage-levels-form-data.json @@ -76,7 +76,7 @@ "NGEN4" ] }, - "connectablePositionInfos": { + "feederBaysInfos": { "SHUNT_VLNB": [ { "busbarId": "NGEN4", @@ -111,6 +111,6 @@ "switchKinds": [], "isRetrievedBusbarSections": false, "busBarSectionInfos": {}, - "connectablePositionInfos": {} + "feederBaysInfos": {} } ] \ No newline at end of file From 77746349d575979359fa5a080d5543e082707ea0 Mon Sep 17 00:00:00 2001 From: Etienne LESOT Date: Wed, 27 Aug 2025 15:56:50 +0200 Subject: [PATCH 08/19] fix Signed-off-by: Etienne LESOT --- .../network/map/dto/utils/ElementUtils.java | 32 ++++++++++------- src/test/resources/substations-form-data.json | 5 ++- ...vel-non-symmetrical-busbars-form-data.json | 3 +- .../resources/voltage-levels-form-data.json | 34 ++++++------------- 4 files changed, 36 insertions(+), 38 deletions(-) diff --git a/src/main/java/org/gridsuite/network/map/dto/utils/ElementUtils.java b/src/main/java/org/gridsuite/network/map/dto/utils/ElementUtils.java index 04862c3c..aa24f94c 100644 --- a/src/main/java/org/gridsuite/network/map/dto/utils/ElementUtils.java +++ b/src/main/java/org/gridsuite/network/map/dto/utils/ElementUtils.java @@ -6,22 +6,24 @@ */ package org.gridsuite.network.map.dto.utils; +import com.powsybl.commons.extensions.Extendable; import com.powsybl.iidm.network.*; +import com.powsybl.iidm.network.extensions.*; import com.powsybl.math.graph.TraversalType; -import org.gridsuite.network.map.dto.common.ReactiveCapabilityCurveMapData; -import org.gridsuite.network.map.dto.common.TapChangerData; -import org.gridsuite.network.map.dto.common.TapChangerStepData; -import org.gridsuite.network.map.dto.definition.extension.BusbarSectionFinderTraverser; -import org.springframework.lang.NonNull; - -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Optional; +import jakarta.annotation.Nullable; +import lombok.NonNull; +import org.apache.commons.collections4.CollectionUtils; +import org.gridsuite.network.map.dto.common.*; +import org.gridsuite.network.map.dto.definition.extension.*; + +import java.util.*; +import java.util.function.Consumer; import java.util.function.DoubleConsumer; import java.util.function.Function; import java.util.stream.Collectors; +import static org.gridsuite.network.map.dto.common.CurrentLimitsData.Applicability.*; + /** * @author Slimane Amar */ @@ -33,6 +35,12 @@ public static Double nullIfNan(double d) { return Double.isNaN(d) ? null : d; } + public static void setIfNotNan(@NonNull final DoubleConsumer setter, final double value) { + if (!Double.isNaN(value)) { + setter.accept(value); + } + } + private static ConnectablePosition.Feeder getFeederInfos(Identifiable identifiable, int index) { var connectablePosition = identifiable.getExtension(ConnectablePosition.class); if (connectablePosition == null) { @@ -92,7 +100,7 @@ public static void buildCurrentLimits(Collection current } } - private static CurrentLimitsData copyCurrentLimitsData(CurrentLimitsData currentLimitsData, Applicability applicability) { + private static CurrentLimitsData copyCurrentLimitsData(CurrentLimitsData currentLimitsData, CurrentLimitsData.Applicability applicability) { return CurrentLimitsData.builder() .id(currentLimitsData.getId()) .applicability(applicability) @@ -255,7 +263,7 @@ public static CurrentLimitsData operationalLimitsGroupToMapDataCurrentLimits(Ope } @Nullable - public static CurrentLimitsData operationalLimitsGroupToMapDataCurrentLimits(OperationalLimitsGroup operationalLimitsGroup, Applicability applicability) { + public static CurrentLimitsData operationalLimitsGroupToMapDataCurrentLimits(OperationalLimitsGroup operationalLimitsGroup, CurrentLimitsData.Applicability applicability) { if (operationalLimitsGroup == null || operationalLimitsGroup.getCurrentLimits().isEmpty()) { return null; } diff --git a/src/test/resources/substations-form-data.json b/src/test/resources/substations-form-data.json index 1b4030cf..53737f6d 100644 --- a/src/test/resources/substations-form-data.json +++ b/src/test/resources/substations-form-data.json @@ -151,7 +151,10 @@ "switchKinds": [], "isRetrievedBusbarSections": false, "isBusbarSectionPositionFound": true, - "busBarSectionInfos": {}, + "busBarSectionInfos" : { + "1" : [ "NGEN5"], + "2" : [ "NGEN5_2"] + }, "feederBaysInfos": {} } ] diff --git a/src/test/resources/voltage-level-non-symmetrical-busbars-form-data.json b/src/test/resources/voltage-level-non-symmetrical-busbars-form-data.json index 4b83258b..ab46dd28 100644 --- a/src/test/resources/voltage-level-non-symmetrical-busbars-form-data.json +++ b/src/test/resources/voltage-level-non-symmetrical-busbars-form-data.json @@ -17,5 +17,6 @@ "busBarSectionInfos" : { "1" : [ "NGEN5"], "2" : [ "NGEN5_2"] - } + }, + "feederBaysInfos": {} } diff --git a/src/test/resources/voltage-levels-form-data.json b/src/test/resources/voltage-levels-form-data.json index 530fb4da..d8d948ed 100644 --- a/src/test/resources/voltage-levels-form-data.json +++ b/src/test/resources/voltage-levels-form-data.json @@ -111,29 +111,15 @@ "sectionCount": 1, "switchKinds": [], "isRetrievedBusbarSections": false, -<<<<<<< HEAD - "busBarSectionInfos": {}, - "feederBaysInfos": {} -||||||| 0742433 - "busBarSectionInfos" : { } - }, - { - "id": "VLGEN6", - "topologyKind": "BUS_BREAKER", - "substationId": "P6", - "nominalV": 24.0 -======= "isBusbarSectionPositionFound": true, - "busBarSectionInfos" : { - "1" : [ "NGEN5"], - "2" : [ "NGEN5_2"] - } - }, - { - "id": "VLGEN6", - "topologyKind": "BUS_BREAKER", - "substationId": "P6", - "nominalV": 24.0 ->>>>>>> main + "busBarSectionInfos": { + "1": [ + "NGEN5" + ], + "2": [ + "NGEN5_2" + ] + }, + "feederBaysInfos": {} } -] \ No newline at end of file +] From 0305db95ed3bf31a63349cf09cee7e8c0ece4f56 Mon Sep 17 00:00:00 2001 From: Etienne LESOT Date: Wed, 27 Aug 2025 16:02:55 +0200 Subject: [PATCH 09/19] remove error from merge Signed-off-by: Etienne LESOT --- .../network/map/dto/utils/ElementUtils.java | 221 ------------------ 1 file changed, 221 deletions(-) diff --git a/src/main/java/org/gridsuite/network/map/dto/utils/ElementUtils.java b/src/main/java/org/gridsuite/network/map/dto/utils/ElementUtils.java index aa24f94c..d03b725f 100644 --- a/src/main/java/org/gridsuite/network/map/dto/utils/ElementUtils.java +++ b/src/main/java/org/gridsuite/network/map/dto/utils/ElementUtils.java @@ -74,227 +74,6 @@ public static ConnectablePositionInfos convertFeederToConnectablePositionInfos(C return builder.build(); } - public static Optional toHvdcAngleDroopActivePowerControlIdentifiable(HvdcLine hvdcLine) { - HvdcAngleDroopActivePowerControl hvdcAngleDroopActivePowerControl = hvdcLine.getExtension(HvdcAngleDroopActivePowerControl.class); - return hvdcAngleDroopActivePowerControl == null ? Optional.empty() : - Optional.of(HvdcAngleDroopActivePowerControlInfos.builder() - .droop(hvdcAngleDroopActivePowerControl.getDroop()) - .isEnabled(hvdcAngleDroopActivePowerControl.isEnabled()) - .p0(hvdcAngleDroopActivePowerControl.getP0()).build()); - } - - public static Optional toHvdcOperatorActivePowerRange(HvdcLine hvdcLine) { - HvdcOperatorActivePowerRange hvdcOperatorActivePowerRange = hvdcLine.getExtension(HvdcOperatorActivePowerRange.class); - return hvdcOperatorActivePowerRange == null ? Optional.empty() : - Optional.of(HvdcOperatorActivePowerRangeInfos.builder() - .oprFromCS1toCS2(hvdcOperatorActivePowerRange.getOprFromCS1toCS2()) - .oprFromCS2toCS1(hvdcOperatorActivePowerRange.getOprFromCS2toCS1()).build()); - } - - public static void buildCurrentLimits(Collection currentLimits, Consumer> build) { - List currentLimitsData = currentLimits.stream() - .map(ElementUtils::operationalLimitsGroupToMapDataCurrentLimits) - .toList(); - if (!currentLimitsData.isEmpty()) { - build.accept(currentLimitsData); - } - } - - private static CurrentLimitsData copyCurrentLimitsData(CurrentLimitsData currentLimitsData, CurrentLimitsData.Applicability applicability) { - return CurrentLimitsData.builder() - .id(currentLimitsData.getId()) - .applicability(applicability) - .temporaryLimits(currentLimitsData.getTemporaryLimits()) - .permanentLimit(currentLimitsData.getPermanentLimit()).build(); - } - - /** - * @return id of the selected operation limits group 1 and 2 if they have been renamed - */ - public static void mergeCurrentLimits(Collection operationalLimitsGroups1, - Collection operationalLimitsGroups2, - Consumer> build) { - List mergedLimitsData = new ArrayList<>(); - - // Build temporary limit from side 1 and 2 - List currentLimitsData1 = operationalLimitsGroups1.stream() - .map(currentLimitsData -> ElementUtils.operationalLimitsGroupToMapDataCurrentLimits(currentLimitsData, SIDE1)) - .filter(Objects::nonNull) - .toList(); - ArrayList currentLimitsData2 = new ArrayList<>(operationalLimitsGroups2.stream() - .map(currentLimitsData -> ElementUtils.operationalLimitsGroupToMapDataCurrentLimits(currentLimitsData, SIDE2)) - .filter(Objects::nonNull) - .toList()); - - // combine 2 sides in one list - - // simple case: one of the arrays are empty - if (currentLimitsData2.isEmpty() && !currentLimitsData1.isEmpty()) { - mergedLimitsData.addAll(currentLimitsData1); - build.accept(mergedLimitsData); - return; - } - if (currentLimitsData1.isEmpty() && !currentLimitsData2.isEmpty()) { - mergedLimitsData.addAll(currentLimitsData2); - build.accept(mergedLimitsData); - return; - } - - // more complex case - for (CurrentLimitsData limitsData : currentLimitsData1) { - Optional l2 = currentLimitsData2.stream().filter(l -> l.getId().equals(limitsData.getId())).findFirst(); - if (l2.isPresent()) { - CurrentLimitsData limitsData2 = l2.get(); - // both sides have limits and limits are equals - if (limitsData.limitsEquals(limitsData2)) { - mergedLimitsData.add(copyCurrentLimitsData(limitsData, EQUIPMENT)); - // both sides have limits and are different: create 2 different limit sets - } else { - // Side 1 - mergedLimitsData.add(limitsData); - // Side 2 - mergedLimitsData.add(limitsData2); - } - // remove processed limits from side 2 - currentLimitsData2.remove(l2.get()); - } else { - // only one side has limits - mergedLimitsData.add(limitsData); - } - } - - // add remaining limits from side 2 - mergedLimitsData.addAll(currentLimitsData2); - - if (!mergedLimitsData.isEmpty()) { - build.accept(mergedLimitsData); - } - } - - public static Optional toStandbyAutomaton(StaticVarCompensator staticVarCompensator) { - StandbyAutomaton standbyAutomatonInfos = staticVarCompensator.getExtension(StandbyAutomaton.class); - return standbyAutomatonInfos == null ? Optional.empty() : - Optional.of(StandbyAutomatonInfos.builder() - .standby(standbyAutomatonInfos.isStandby()) - .b0(nullIfNan(standbyAutomatonInfos.getB0())) - .lowVoltageSetpoint(nullIfNan(standbyAutomatonInfos.getLowVoltageSetpoint())) - .highVoltageSetpoint(nullIfNan(standbyAutomatonInfos.getHighVoltageSetpoint())) - .highVoltageThreshold(nullIfNan(standbyAutomatonInfos.getHighVoltageThreshold())) - .lowVoltageThreshold(nullIfNan(standbyAutomatonInfos.getLowVoltageThreshold())).build()); - } - - public static Optional toActivePowerControl(Identifiable identifiable) { - var activePowerControl = identifiable.getExtension(ActivePowerControl.class); - if (activePowerControl == null) { - return Optional.empty(); - } else { - return Optional.of(ActivePowerControlInfos.builder() - .participate(activePowerControl.isParticipate()) - .droop(activePowerControl.getDroop()) - .maxTargetP(activePowerControl.getMaxTargetP().isPresent() ? activePowerControl.getMaxTargetP().getAsDouble() : null) - .build()); - } - } - - public static String toOperatingStatus(Extendable extendable) { - if (extendable instanceof Branch - || extendable instanceof ThreeWindingsTransformer - || extendable instanceof HvdcLine - || extendable instanceof BusbarSection) { - var operatingStatus = extendable.getExtension(OperatingStatus.class); - return operatingStatus == null ? null : operatingStatus.getStatus().name(); - } - return null; - } - - public static Optional toGeneratorShortCircuit(Generator generator) { - GeneratorShortCircuit generatorShortCircuit = generator.getExtension(GeneratorShortCircuit.class); - return generatorShortCircuit == null ? Optional.empty() : - Optional.of(GeneratorShortCircuitInfos.builder() - .directTransX(generatorShortCircuit.getDirectTransX()) - .stepUpTransformerX(generatorShortCircuit.getStepUpTransformerX()).build()); - } - - public static CoordinatedReactiveControlInfos toCoordinatedReactiveControl(Generator generator) { - CoordinatedReactiveControlInfos.CoordinatedReactiveControlInfosBuilder builder = CoordinatedReactiveControlInfos.builder(); - CoordinatedReactiveControl coordinatedReactiveControl = generator.getExtension(CoordinatedReactiveControl.class); - if (coordinatedReactiveControl != null) { - builder.qPercent(coordinatedReactiveControl.getQPercent()); - } else { - builder.qPercent(Double.NaN); - } - return builder.build(); - } - - public static Optional toGeneratorStartup(Generator generator) { - GeneratorStartup generatorStartup = generator.getExtension(GeneratorStartup.class); - return generatorStartup == null ? Optional.empty() : - Optional.of(GeneratorStartupInfos.builder() - .plannedActivePowerSetPoint(nullIfNan(generatorStartup.getPlannedActivePowerSetpoint())) - .marginalCost(nullIfNan(generatorStartup.getMarginalCost())) - .plannedOutageRate(nullIfNan(generatorStartup.getPlannedOutageRate())) - .forcedOutageRate(nullIfNan(generatorStartup.getForcedOutageRate())).build()); - } - - public static Optional toIdentifiableShortCircuit(VoltageLevel voltageLevel) { - IdentifiableShortCircuit identifiableShortCircuit = voltageLevel.getExtension(IdentifiableShortCircuit.class); - return identifiableShortCircuit == null ? Optional.empty() : - Optional.of(IdentifiableShortCircuitInfos.builder() - .ipMin(identifiableShortCircuit.getIpMin()) - .ipMax(identifiableShortCircuit.getIpMax()).build()); - } - - public static CurrentLimitsData toMapDataCurrentLimits(CurrentLimits limits) { - CurrentLimitsData.CurrentLimitsDataBuilder builder = CurrentLimitsData.builder(); - boolean empty = true; - if (!Double.isNaN(limits.getPermanentLimit())) { - builder.permanentLimit(limits.getPermanentLimit()); - empty = false; - } - if (!CollectionUtils.isEmpty(limits.getTemporaryLimits())) { - builder.temporaryLimits(toMapDataTemporaryLimit(limits.getTemporaryLimits())); - empty = false; - } - return empty ? null : builder.build(); - } - - public static CurrentLimitsData operationalLimitsGroupToMapDataCurrentLimits(OperationalLimitsGroup operationalLimitsGroup) { - return operationalLimitsGroupToMapDataCurrentLimits(operationalLimitsGroup, null); - } - - @Nullable - public static CurrentLimitsData operationalLimitsGroupToMapDataCurrentLimits(OperationalLimitsGroup operationalLimitsGroup, CurrentLimitsData.Applicability applicability) { - if (operationalLimitsGroup == null || operationalLimitsGroup.getCurrentLimits().isEmpty()) { - return null; - } - CurrentLimitsData.CurrentLimitsDataBuilder builder = CurrentLimitsData.builder(); - boolean containsLimitsData = false; - - CurrentLimits currentLimits = operationalLimitsGroup.getCurrentLimits().get(); - builder.id(operationalLimitsGroup.getId()); - if (!Double.isNaN(currentLimits.getPermanentLimit())) { - builder.permanentLimit(currentLimits.getPermanentLimit()); - containsLimitsData = true; - } - if (!CollectionUtils.isEmpty(currentLimits.getTemporaryLimits())) { - builder.temporaryLimits(toMapDataTemporaryLimit(currentLimits.getTemporaryLimits())); - containsLimitsData = true; - } - builder.applicability(applicability); - - return containsLimitsData ? builder.build() : null; - } - - private static List toMapDataTemporaryLimit(Collection limits) { - return limits.stream() - .map(l -> TemporaryLimitData.builder() - .name(l.getName()) - .acceptableDuration(l.getAcceptableDuration() == Integer.MAX_VALUE ? null : l.getAcceptableDuration()) - .value(l.getValue() == Double.MAX_VALUE ? null : l.getValue()) - .build()) - .collect(Collectors.toList()); - } - public static String getBusOrBusbarSection(Terminal terminal) { if (terminal.getVoltageLevel().getTopologyKind().equals(TopologyKind.BUS_BREAKER)) { if (terminal.isConnected()) { From 84cff314fc42ed26294bb7be6a20dd2d95ae0093 Mon Sep 17 00:00:00 2001 From: Etienne LESOT Date: Wed, 27 Aug 2025 16:07:27 +0200 Subject: [PATCH 10/19] checkstyle Signed-off-by: Etienne LESOT --- .../network/map/dto/utils/ElementUtils.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/gridsuite/network/map/dto/utils/ElementUtils.java b/src/main/java/org/gridsuite/network/map/dto/utils/ElementUtils.java index d03b725f..00711ab9 100644 --- a/src/main/java/org/gridsuite/network/map/dto/utils/ElementUtils.java +++ b/src/main/java/org/gridsuite/network/map/dto/utils/ElementUtils.java @@ -6,24 +6,24 @@ */ package org.gridsuite.network.map.dto.utils; -import com.powsybl.commons.extensions.Extendable; import com.powsybl.iidm.network.*; -import com.powsybl.iidm.network.extensions.*; +import com.powsybl.iidm.network.extensions.ConnectablePosition; import com.powsybl.math.graph.TraversalType; -import jakarta.annotation.Nullable; import lombok.NonNull; -import org.apache.commons.collections4.CollectionUtils; -import org.gridsuite.network.map.dto.common.*; -import org.gridsuite.network.map.dto.definition.extension.*; - -import java.util.*; -import java.util.function.Consumer; +import org.gridsuite.network.map.dto.common.ReactiveCapabilityCurveMapData; +import org.gridsuite.network.map.dto.common.TapChangerData; +import org.gridsuite.network.map.dto.common.TapChangerStepData; +import org.gridsuite.network.map.dto.definition.extension.BusbarSectionFinderTraverser; +import org.gridsuite.network.map.dto.definition.extension.ConnectablePositionInfos; + +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Optional; import java.util.function.DoubleConsumer; import java.util.function.Function; import java.util.stream.Collectors; -import static org.gridsuite.network.map.dto.common.CurrentLimitsData.Applicability.*; - /** * @author Slimane Amar */ From 1e5770b82ff8b3725eb425daf7325c0e4758e0b2 Mon Sep 17 00:00:00 2001 From: Etienne LESOT Date: Wed, 3 Sep 2025 13:45:53 +0200 Subject: [PATCH 11/19] add tests Signed-off-by: Etienne LESOT --- .../network/map/NetworkMapControllerTest.java | 73 +++++++++++--- src/test/resources/all-data-in-variant.json | 77 +++++++++++++++ src/test/resources/all-data.json | 69 +++++++++++++- .../resources/bus-bar-section-form-data.json | 4 + .../resources/bus-bar-section-list-data.json | 4 + ...bus-bar-section-operating-status-data.json | 6 +- src/test/resources/lines-form-data.json | 94 ++++++++++++------- src/test/resources/lines-list-data.json | 5 +- src/test/resources/lines-map-data.json | 7 ++ .../lines-operating-status-data.json | 13 ++- src/test/resources/substations-form-data.json | 53 ++++++++++- src/test/resources/substations-map-data.json | 37 ++++---- .../substations-map-data_without_vl.json | 25 +++-- src/test/resources/substations-tab-data.json | 32 ++++--- .../resources/switches-data-in-variant.json | 8 ++ src/test/resources/switches-data.json | 8 ++ .../voltage-level-form-data-feederbays.json | 27 ++++++ .../resources/voltage-level-form-data.json | 10 ++ ...vel-non-symmetrical-busbars-form-data.json | 2 +- .../resources/voltage-levels-form-data.json | 38 +++++++- .../resources/voltage-levels-list-data.json | 17 ++-- .../resources/voltage-levels-map-data.json | 21 +++-- 22 files changed, 515 insertions(+), 115 deletions(-) create mode 100644 src/test/resources/voltage-level-form-data-feederbays.json diff --git a/src/test/java/org/gridsuite/network/map/NetworkMapControllerTest.java b/src/test/java/org/gridsuite/network/map/NetworkMapControllerTest.java index 32515a38..9c7831ef 100644 --- a/src/test/java/org/gridsuite/network/map/NetworkMapControllerTest.java +++ b/src/test/java/org/gridsuite/network/map/NetworkMapControllerTest.java @@ -18,8 +18,8 @@ import com.powsybl.network.store.iidm.impl.NetworkFactoryImpl; import org.gridsuite.network.map.dto.ElementInfos.InfoType; import org.gridsuite.network.map.dto.ElementType; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.Mockito; @@ -1154,6 +1154,48 @@ void setUp() { .withDirection(ConnectablePosition.Direction.TOP).add() .add(); + // add line between vlgen4 et vlgen 5 for feederBays Infos + VoltageLevel vlgen7 = p5.newVoltageLevel() + .setId("VLGEN7") + .setNominalV(24.0) + .setHighVoltageLimit(30) + .setLowVoltageLimit(20) + .setTopologyKind(TopologyKind.NODE_BREAKER) + .add(); + vlgen7.getNodeBreakerView().newBusbarSection() + .setId("NGEN7") + .setName("NGEN7") + .setNode(0) + .add(); + createSwitch(vlgen4, "b4", SwitchKind.DISCONNECTOR, false, 0, 10); + createSwitch(vlgen4, "br11", SwitchKind.BREAKER, false, 10, 11); + createSwitch(vlgen7, "b5", SwitchKind.DISCONNECTOR, false, 0, 1); + createSwitch(vlgen7, "br21", SwitchKind.BREAKER, false, 1, 2); + network.newLine() + .setId("LINE7") + .setVoltageLevel1("VLGEN4") + .setNode1(11) + .setVoltageLevel2("VLGEN7") + .setNode2(2) + .setR(3.0) + .setX(33.0) + .setG1(0.0) + .setB1(386E-6 / 2) + .setG2(0.0) + .setB2(386E-6 / 2) + .add(); + Line line7 = network.getLine("LINE7"); + line7.newExtension(ConnectablePositionAdder.class) + .newFeeder1() + .withName("LINE7_Side_VLGEN4") + .withOrder(5) + .withDirection(ConnectablePosition.Direction.BOTTOM).add() + .newFeeder2() + .withName("LINE7_Side_VLGEN8") + .withOrder(3) + .withDirection(ConnectablePosition.Direction.TOP).add() + .add(); + // Add new variant network.getVariantManager().cloneVariant(VariantManagerConstants.INITIAL_VARIANT_ID, VARIANT_ID); network.getVariantManager().setWorkingVariant(VARIANT_ID); @@ -1184,7 +1226,6 @@ void setUp() { .withOrder(0) .withDirection(ConnectablePosition.Direction.TOP).add() .add(); - network.getVariantManager().setWorkingVariant(VariantManagerConstants.INITIAL_VARIANT_ID); // Add new variant 2 @@ -1512,7 +1553,6 @@ private void succeedingTestForEquipmentsInfos(UUID networkUuid, String variantId MvcResult mvcResult = mvc.perform(get("/v1/networks/{networkUuid}/{equipmentPath}", networkUuid, equipmentPath).queryParams(queryParams)) .andExpect(status().isOk()) .andReturn(); - JSONAssert.assertEquals(expectedJson, mvcResult.getResponse().getContentAsString(), JSONCompareMode.NON_EXTENSIBLE); } @@ -1679,10 +1719,10 @@ void shouldReturnLinesOperatingStatusData() throws Exception { @Test void shouldReturnLinesIds() throws Exception { - succeedingTestForElementsIds(NETWORK_UUID, null, List.of("NHV1_NHV2_1", "NHV1_NHV2_2", "LINE3", "LINE4").toString(), ElementType.LINE, null, null); - succeedingTestForElementsIds(NETWORK_UUID, null, List.of("NHV1_NHV2_1", "NHV1_NHV2_2", "LINE3", "LINE4").toString(), ElementType.LINE, null, List.of(24.0, 380.0)); - succeedingTestForElementsIds(NETWORK_UUID, VARIANT_ID, List.of("NHV1_NHV2_1", "NHV1_NHV2_2", "LINE3", "LINE4").toString(), ElementType.LINE, null, null); - succeedingTestForElementsIds(NETWORK_UUID, VARIANT_ID, List.of("NHV1_NHV2_1", "NHV1_NHV2_2", "LINE3", "LINE4").toString(), ElementType.LINE, null, List.of(24.0, 380.0)); + succeedingTestForElementsIds(NETWORK_UUID, null, List.of("NHV1_NHV2_1", "NHV1_NHV2_2", "LINE3", "LINE4", "LINE7").toString(), ElementType.LINE, null, null); + succeedingTestForElementsIds(NETWORK_UUID, null, List.of("NHV1_NHV2_1", "NHV1_NHV2_2", "LINE3", "LINE4", "LINE7").toString(), ElementType.LINE, null, List.of(24.0, 380.0)); + succeedingTestForElementsIds(NETWORK_UUID, VARIANT_ID, List.of("NHV1_NHV2_1", "NHV1_NHV2_2", "LINE3", "LINE4", "LINE7").toString(), ElementType.LINE, null, null); + succeedingTestForElementsIds(NETWORK_UUID, VARIANT_ID, List.of("NHV1_NHV2_1", "NHV1_NHV2_2", "LINE3", "LINE4", "LINE7").toString(), ElementType.LINE, null, List.of(24.0, 380.0)); succeedingTestForElementsIds(NETWORK_UUID, VARIANT_ID, List.of("NHV1_NHV2_1", "NHV1_NHV2_2", "LINE3").toString(), ElementType.LINE, List.of("P1"), null); succeedingTestForElementsIds(NETWORK_UUID, VARIANT_ID, List.of("NHV1_NHV2_1", "NHV1_NHV2_2", "LINE3").toString(), ElementType.LINE, List.of("P1"), List.of(24.0, 380.0)); succeedingTestForElementsIds(NETWORK_UUID, VARIANT_ID, List.of().toString(), ElementType.LINE, List.of("P1"), List.of(225.0)); @@ -2196,12 +2236,12 @@ void shouldReturnVotlageLevelsMapData() throws Exception { @Test void shouldReturnVoltageLevelsIds() throws Exception { - succeedingTestForElementsIds(NETWORK_UUID, null, List.of("VL", "VLGEN", "VLHV1", "VLHV2", "VLLOAD", "VLNEW2", "VLGEN3", "VLGEN4", "VLGEN5", "VLGEN6").toString(), ElementType.VOLTAGE_LEVEL, null, null); - succeedingTestForElementsIds(NETWORK_UUID, null, List.of("VL", "VLGEN", "VLHV1", "VLHV2", "VLLOAD", "VLNEW2", "VLGEN3", "VLGEN4", "VLGEN5", "VLGEN6").toString(), ElementType.VOLTAGE_LEVEL, null, List.of(24.0, 150.0, 225.0, 380.0)); - succeedingTestForElementsIds(NETWORK_UUID, VARIANT_ID, List.of("VL", "VLGEN", "VLHV1", "VLHV2", "VLLOAD", "VLNEW2", "VLGEN3", "VLGEN4", "VLGEN5", "VLGEN6").toString(), ElementType.VOLTAGE_LEVEL, null, null); - succeedingTestForElementsIds(NETWORK_UUID, VARIANT_ID, List.of("VL", "VLGEN", "VLHV1", "VLHV2", "VLLOAD", "VLNEW2", "VLGEN3", "VLGEN4", "VLGEN5", "VLGEN6").toString(), ElementType.VOLTAGE_LEVEL, null, List.of(24.0, 150.0, 225.0, 380.0)); - succeedingTestForElementsIds(NETWORK_UUID, VARIANT_ID, List.of("VLGEN", "VLHV1", "VLHV2", "VLLOAD", "VLNEW2", "VLGEN3", "VLGEN4", "VLGEN5", "VLGEN6").toString(), ElementType.VOLTAGE_LEVEL, List.of("P1", "P2", "P3", "P4", "P5", "P6"), null); - succeedingTestForElementsIds(NETWORK_UUID, VARIANT_ID, List.of("VLGEN", "VLHV1", "VLHV2", "VLLOAD", "VLNEW2", "VLGEN3", "VLGEN4", "VLGEN5", "VLGEN6").toString(), ElementType.VOLTAGE_LEVEL, List.of("P1", "P2", "P3", "P4", "P5", "P6"), List.of(24.0, 150.0, 225.0, 380.0)); + succeedingTestForElementsIds(NETWORK_UUID, null, List.of("VL", "VLGEN", "VLHV1", "VLHV2", "VLLOAD", "VLNEW2", "VLGEN3", "VLGEN4", "VLGEN5", "VLGEN6", "VLGEN7").toString(), ElementType.VOLTAGE_LEVEL, null, null); + succeedingTestForElementsIds(NETWORK_UUID, null, List.of("VL", "VLGEN", "VLHV1", "VLHV2", "VLLOAD", "VLNEW2", "VLGEN3", "VLGEN4", "VLGEN5", "VLGEN6", "VLGEN7").toString(), ElementType.VOLTAGE_LEVEL, null, List.of(24.0, 150.0, 225.0, 380.0)); + succeedingTestForElementsIds(NETWORK_UUID, VARIANT_ID, List.of("VL", "VLGEN", "VLHV1", "VLHV2", "VLLOAD", "VLNEW2", "VLGEN3", "VLGEN4", "VLGEN5", "VLGEN6", "VLGEN7").toString(), ElementType.VOLTAGE_LEVEL, null, null); + succeedingTestForElementsIds(NETWORK_UUID, VARIANT_ID, List.of("VL", "VLGEN", "VLHV1", "VLHV2", "VLLOAD", "VLNEW2", "VLGEN3", "VLGEN4", "VLGEN5", "VLGEN6", "VLGEN7").toString(), ElementType.VOLTAGE_LEVEL, null, List.of(24.0, 150.0, 225.0, 380.0)); + succeedingTestForElementsIds(NETWORK_UUID, VARIANT_ID, List.of("VLGEN", "VLHV1", "VLHV2", "VLLOAD", "VLNEW2", "VLGEN3", "VLGEN4", "VLGEN5", "VLGEN6", "VLGEN7").toString(), ElementType.VOLTAGE_LEVEL, List.of("P1", "P2", "P3", "P4", "P5", "P6"), null); + succeedingTestForElementsIds(NETWORK_UUID, VARIANT_ID, List.of("VLGEN", "VLHV1", "VLHV2", "VLLOAD", "VLNEW2", "VLGEN3", "VLGEN4", "VLGEN5", "VLGEN6", "VLGEN7").toString(), ElementType.VOLTAGE_LEVEL, List.of("P1", "P2", "P3", "P4", "P5", "P6"), List.of(24.0, 150.0, 225.0, 380.0)); } @Test @@ -2219,11 +2259,16 @@ void shouldReturnNotFoundInsteadOfVoltageLevelsMapData() throws Exception { } @Test - void shouldReturnVotlageLevelFormData() throws Exception { + void shouldReturnVoltageLevelFormData() throws Exception { succeedingTestForElementInfosWithElementId(NETWORK_UUID, null, ElementType.VOLTAGE_LEVEL, InfoType.FORM, "VLGEN4", resourceToString("/voltage-level-form-data.json")); succeedingTestForElementInfosWithElementId(NETWORK_UUID, VARIANT_ID, ElementType.VOLTAGE_LEVEL, InfoType.FORM, "VLGEN4", resourceToString("/voltage-level-form-data.json")); } + @Test + void shouldReturnVoltageLevelFormDataWithFeederBaysInfos() throws Exception { + succeedingTestForElementInfosWithElementId(NETWORK_UUID, null, ElementType.VOLTAGE_LEVEL, InfoType.FORM, "VLGEN5", resourceToString("/voltage-level-form-data-feederbays.json")); + } + @Test void shouldReturnVotlageLevelNonSymmetricalBusbarsFormData() throws Exception { succeedingTestForElementInfosWithElementId(NETWORK_UUID, null, ElementType.VOLTAGE_LEVEL, InfoType.FORM, "VLGEN5", resourceToString("/voltage-level-non-symmetrical-busbars-form-data.json")); diff --git a/src/test/resources/all-data-in-variant.json b/src/test/resources/all-data-in-variant.json index 97b24cf9..e643666e 100644 --- a/src/test/resources/all-data-in-variant.json +++ b/src/test/resources/all-data-in-variant.json @@ -115,6 +115,14 @@ { "id": "P5", "voltageLevels": [ + { + "id": "VLGEN7", + "substationId": "P5", + "nominalV": 24.0, + "country": "FR", + "lowVoltageLimit": 20.0, + "highVoltageLimit": 30.0 + }, { "id": "VLGEN5", "substationId": "P5", @@ -219,6 +227,14 @@ "ipMin": 0.0, "ipMax": 100.0 } + }, + { + "id": "VLGEN7", + "substationId": "P5", + "nominalV": 24.0, + "country": "FR", + "lowVoltageLimit": 20.0, + "highVoltageLimit": 30.0 } ], "lines": [ @@ -502,6 +518,26 @@ "b1": 1.93E-4, "g2": 0.0, "b2": 1.93E-4 + }, + { + "id": "LINE7", + "type": "LINE", + "voltageLevelId1": "VLGEN4", + "voltageLevelId2": "VLGEN7", + "nominalVoltage1": 24.0, + "nominalVoltage2": 24.0, + "substationId1": "P4", + "substationId2": "P5", + "country1": "FR", + "country2": "FR", + "terminal1Connected": true, + "terminal2Connected": true, + "r": 3.0, + "x": 33.0, + "g1": 0.0, + "b1": 1.93E-4, + "g2": 0.0, + "b2": 1.93E-4 } ], "hvdcLines": [ @@ -2345,6 +2381,26 @@ "voltageLevelId": "VLGEN6", "nominalVoltage": 24.0, "country": "FR" + }, + { + "id": "VLGEN4_0", + "v": "NaN", + "angle": "NaN", + "synchronousComponentNum": 1, + "connectedComponentNum": 1, + "voltageLevelId": "VLGEN4", + "nominalVoltage": 24.0, + "country": "FR" + }, + { + "id": "VLGEN7_0", + "v": "NaN", + "angle": "NaN", + "synchronousComponentNum": 1, + "connectedComponentNum": 1, + "voltageLevelId": "VLGEN7", + "nominalVoltage": 24.0, + "country": "FR" } ], "busbarSections": [ @@ -2375,6 +2431,11 @@ "id": "NGEN5_2_2", "name": "NGEN5_2_2", "voltageLevelId": "VLGEN5" + }, + { + "id": "NGEN7", + "name": "NGEN7", + "voltageLevelId": "VLGEN7" } ], "branches": [ @@ -2643,6 +2704,22 @@ "Country": "FR" } }, + { + "id": "LINE7", + "type": "LINE", + "voltageLevelId1": "VLGEN4", + "voltageLevelId2": "VLGEN7", + "nominalVoltage1": 24.0, + "nominalVoltage2": 24.0, + "substationId1": "P4", + "substationId2": "P5", + "country1": "FR", + "country2": "FR", + "terminal1Connected": true, + "terminal2Connected": true, + "r": 3.0, + "x": 33.0 + }, { "id": "NGEN_NHV1", "type": "TWO_WINDINGS_TRANSFORMER", diff --git a/src/test/resources/all-data.json b/src/test/resources/all-data.json index dc639143..06c2ec42 100644 --- a/src/test/resources/all-data.json +++ b/src/test/resources/all-data.json @@ -126,6 +126,14 @@ "ipMin": 0.0, "ipMax": 100.0 } + }, + { + "id": "VLGEN7", + "substationId": "P5", + "nominalV": 24.0, + "country": "FR", + "lowVoltageLimit": 20.0, + "highVoltageLimit": 30.0 } ], "country": "FR" @@ -219,6 +227,14 @@ "ipMin": 0.0, "ipMax": 100.0 } + }, + { + "id": "VLGEN7", + "substationId": "P5", + "nominalV": 24.0, + "country": "FR", + "lowVoltageLimit": 20.0, + "highVoltageLimit": 30.0 } ], "lines": [ @@ -502,6 +518,26 @@ "b1": 1.93E-4, "g2": 0.0, "b2": 1.93E-4 + }, + { + "id": "LINE7", + "type": "LINE", + "voltageLevelId1": "VLGEN4", + "voltageLevelId2": "VLGEN7", + "nominalVoltage1": 24.0, + "nominalVoltage2": 24.0, + "substationId1": "P4", + "substationId2": "P5", + "country1": "FR", + "country2": "FR", + "terminal1Connected": true, + "terminal2Connected": true, + "r": 3.0, + "x": 33.0, + "g1": 0.0, + "b1": 1.93E-4, + "g2": 0.0, + "b2": 1.93E-4 } ], "hvdcLines": [ @@ -2333,6 +2369,16 @@ "voltageLevelId": "VLGEN4", "nominalVoltage": 24.0, "country": "FR" + }, + { + "id": "VLGEN7_0", + "v": "NaN", + "angle": "NaN", + "synchronousComponentNum": 1, + "connectedComponentNum": 1, + "voltageLevelId": "VLGEN7", + "nominalVoltage": 24.0, + "country": "FR" } ], "busbarSections": [ @@ -2363,6 +2409,11 @@ "id": "NGEN5_2_2", "name": "NGEN5_2_2", "voltageLevelId": "VLGEN5" + }, + { + "id": "NGEN7", + "name": "NGEN7", + "voltageLevelId": "VLGEN7" } ], "branches": [ @@ -2631,6 +2682,22 @@ "Country": "FR" } }, + { + "id": "LINE7", + "type": "LINE", + "voltageLevelId1": "VLGEN4", + "voltageLevelId2": "VLGEN7", + "nominalVoltage1": 24.0, + "nominalVoltage2": 24.0, + "substationId1": "P4", + "substationId2": "P5", + "country1": "FR", + "country2": "FR", + "terminal1Connected": true, + "terminal2Connected": true, + "r": 3.0, + "x": 33.0 + }, { "id": "NGEN_NHV1", "type": "TWO_WINDINGS_TRANSFORMER", @@ -2816,4 +2883,4 @@ } } ] -} \ No newline at end of file +} diff --git a/src/test/resources/bus-bar-section-form-data.json b/src/test/resources/bus-bar-section-form-data.json index 5a9a8efa..66240fc4 100644 --- a/src/test/resources/bus-bar-section-form-data.json +++ b/src/test/resources/bus-bar-section-form-data.json @@ -22,5 +22,9 @@ "name": "NGEN5_2_2", "vertPos": 2, "horizPos": 2 + }, + { + "id": "NGEN7", + "name": "NGEN7" } ] \ No newline at end of file diff --git a/src/test/resources/bus-bar-section-list-data.json b/src/test/resources/bus-bar-section-list-data.json index ce64cf17..d75cc789 100644 --- a/src/test/resources/bus-bar-section-list-data.json +++ b/src/test/resources/bus-bar-section-list-data.json @@ -14,5 +14,9 @@ { "id": "NGEN5_2_2", "name": "NGEN5_2_2" + }, + { + "id": "NGEN7", + "name": "NGEN7" } ] \ No newline at end of file diff --git a/src/test/resources/bus-bar-section-operating-status-data.json b/src/test/resources/bus-bar-section-operating-status-data.json index 77ffd3f6..902a6f1a 100644 --- a/src/test/resources/bus-bar-section-operating-status-data.json +++ b/src/test/resources/bus-bar-section-operating-status-data.json @@ -8,12 +8,16 @@ "name": "NGEN5", "operatingStatus": "FORCED_OUTAGE" }, - { + { "id": "NGEN5_2_1", "name": "NGEN5_2_1" }, { "id": "NGEN5_2_2", "name": "NGEN5_2_2" + }, + { + "id": "NGEN7", + "name": "NGEN7" } ] \ No newline at end of file diff --git a/src/test/resources/lines-form-data.json b/src/test/resources/lines-form-data.json index 45906df5..abe5bc75 100644 --- a/src/test/resources/lines-form-data.json +++ b/src/test/resources/lines-form-data.json @@ -9,7 +9,7 @@ "q1": 2.2, "p2": 3.33, "q2": 4.44, - "currentLimits1": [ + "currentLimits": [ { "id": "limit set 1", "permanentLimit": 700.4, @@ -20,10 +20,8 @@ "acceptableDuration": 300 } ], - "applicability": null - } - ], - "currentLimits2": [ + "applicability": "SIDE1" + }, { "id": "limit set 1", "permanentLimit": 800.8, @@ -39,10 +37,10 @@ "acceptableDuration": 600 } ], - "applicability": null + "applicability": "SIDE2" } ], - "currentLimits": [ + "currentLimits1": [ { "id": "limit set 1", "permanentLimit": 700.4, @@ -53,8 +51,10 @@ "acceptableDuration": 300 } ], - "applicability": "SIDE1" - }, + "applicability": null + } + ], + "currentLimits2": [ { "id": "limit set 1", "permanentLimit": 800.8, @@ -70,7 +70,7 @@ "acceptableDuration": 600 } ], - "applicability": "SIDE2" + "applicability": null } ], "selectedOperationalLimitsGroup1": "limit set 1", @@ -100,7 +100,7 @@ "voltageLevelId2": "VLHV2", "terminal1Connected": true, "terminal2Connected": true, - "currentLimits1": [ + "currentLimits": [ { "id": "group2", "permanentLimit": 250.0, @@ -111,7 +111,7 @@ "acceptableDuration": 200 } ], - "applicability": null + "applicability": "SIDE1" }, { "id": "group1", @@ -128,10 +128,8 @@ "acceptableDuration": 100 } ], - "applicability": null - } - ], - "currentLimits2": [ + "applicability": "SIDE1" + }, { "id": "group4", "permanentLimit": 320.0, @@ -142,7 +140,7 @@ "acceptableDuration": 200 } ], - "applicability": null + "applicability": "SIDE2" }, { "id": "group3", @@ -154,10 +152,10 @@ "acceptableDuration": 150 } ], - "applicability": null + "applicability": "SIDE2" } ], - "currentLimits": [ + "currentLimits1": [ { "id": "group2", "permanentLimit": 250.0, @@ -168,7 +166,7 @@ "acceptableDuration": 200 } ], - "applicability": "SIDE1" + "applicability": null }, { "id": "group1", @@ -185,8 +183,10 @@ "acceptableDuration": 100 } ], - "applicability": "SIDE1" - }, + "applicability": null + } + ], + "currentLimits2": [ { "id": "group4", "permanentLimit": 320.0, @@ -197,7 +197,7 @@ "acceptableDuration": 200 } ], - "applicability": "SIDE2" + "applicability": null }, { "id": "group3", @@ -209,10 +209,9 @@ "acceptableDuration": 150 } ], - "applicability": "SIDE2" + "applicability": null } ], - "selectedOperationalLimitsGroup1": "group1", "selectedOperationalLimitsGroup2": "group4", "r": 3.0, @@ -237,7 +236,9 @@ "voltageLevelId2": "VLGEN3", "terminal1Connected": true, "terminal2Connected": true, - "currentLimits1": [ + "p1": 200.0, + "p2": 100.0, + "currentLimits": [ { "id": "group1", "permanentLimit": 220.0, @@ -253,10 +254,10 @@ "acceptableDuration": 100 } ], - "applicability": null + "applicability": "SIDE1" } ], - "currentLimits": [ + "currentLimits1": [ { "id": "group1", "permanentLimit": 220.0, @@ -272,12 +273,10 @@ "acceptableDuration": 100 } ], - "applicability": "SIDE1" + "applicability": null } ], "selectedOperationalLimitsGroup1": "group1", - "p1": 200.0, - "p2": 100.0, "operatingStatus": "PLANNED_OUTAGE", "r": 3.0, "x": 33.0, @@ -316,7 +315,7 @@ "voltageLevelId2": "VLGEN3", "terminal1Connected": true, "terminal2Connected": true, - "currentLimits2": [ + "currentLimits": [ { "id": "group1", "permanentLimit": 220.0, @@ -332,10 +331,10 @@ "acceptableDuration": 100 } ], - "applicability": null + "applicability": "SIDE2" } ], - "currentLimits": [ + "currentLimits2": [ { "id": "group1", "permanentLimit": 220.0, @@ -351,7 +350,7 @@ "acceptableDuration": 100 } ], - "applicability": "SIDE2" + "applicability": null } ], "selectedOperationalLimitsGroup2": "group1", @@ -369,5 +368,30 @@ }, "busOrBusbarSectionId1": "NGEN6", "busOrBusbarSectionId2": "NGEN3" + }, + { + "id": "LINE7", + "voltageLevelId1": "VLGEN4", + "voltageLevelId2": "VLGEN7", + "terminal1Connected": true, + "terminal2Connected": true, + "r": 3.0, + "x": 33.0, + "g1": 0.0, + "b1": 1.93E-4, + "g2": 0.0, + "b2": 1.93E-4, + "connectablePosition1": { + "connectionDirection": "BOTTOM", + "connectionPosition": 5, + "connectionName": "LINE7_Side_VLGEN4" + }, + "connectablePosition2": { + "connectionDirection": "TOP", + "connectionPosition": 3, + "connectionName": "LINE7_Side_VLGEN8" + }, + "busOrBusbarSectionId1": "NGEN4", + "busOrBusbarSectionId2": "NGEN7" } ] \ No newline at end of file diff --git a/src/test/resources/lines-list-data.json b/src/test/resources/lines-list-data.json index 22dbe3b8..4be80a8a 100644 --- a/src/test/resources/lines-list-data.json +++ b/src/test/resources/lines-list-data.json @@ -10,5 +10,8 @@ }, { "id": "LINE4" + }, + { + "id": "LINE7" } -] +] \ No newline at end of file diff --git a/src/test/resources/lines-map-data.json b/src/test/resources/lines-map-data.json index 28836e21..860959f8 100644 --- a/src/test/resources/lines-map-data.json +++ b/src/test/resources/lines-map-data.json @@ -32,5 +32,12 @@ "voltageLevelId2": "VLGEN3", "terminal1Connected": true, "terminal2Connected": true + }, + { + "id": "LINE7", + "voltageLevelId1": "VLGEN4", + "voltageLevelId2": "VLGEN7", + "terminal1Connected": true, + "terminal2Connected": true } ] \ No newline at end of file diff --git a/src/test/resources/lines-operating-status-data.json b/src/test/resources/lines-operating-status-data.json index 0d655cd7..b80b9aa8 100644 --- a/src/test/resources/lines-operating-status-data.json +++ b/src/test/resources/lines-operating-status-data.json @@ -15,12 +15,12 @@ }, { "id": "LINE3", + "operatingStatus": "PLANNED_OUTAGE", "voltageLevelId1": "VLGEN", "voltageLevelName1": "VLGEN_Name", "voltageLevelId2": "VLGEN3", "terminal1Connected": true, - "terminal2Connected": true, - "operatingStatus": "PLANNED_OUTAGE" + "terminal2Connected": true }, { "id": "LINE4", @@ -28,5 +28,12 @@ "voltageLevelId2": "VLGEN3", "terminal1Connected": true, "terminal2Connected": true + }, + { + "id": "LINE7", + "voltageLevelId1": "VLGEN4", + "voltageLevelId2": "VLGEN7", + "terminal1Connected": true, + "terminal2Connected": true } -] +] \ No newline at end of file diff --git a/src/test/resources/substations-form-data.json b/src/test/resources/substations-form-data.json index 1ea775c4..9a81c672 100644 --- a/src/test/resources/substations-form-data.json +++ b/src/test/resources/substations-form-data.json @@ -100,7 +100,9 @@ "nominalV": 24.0, "busbarCount": 1, "sectionCount": 2, - "switchKinds": ["DISCONNECTOR"], + "switchKinds": [ + "DISCONNECTOR" + ], "isRetrievedBusbarSections": true, "isBusbarSectionPositionFound": true, "busBarSectionInfos": { @@ -117,6 +119,16 @@ } } ], + "LINE7": [ + { + "busbarId": "NGEN4", + "connectablePositionInfos": { + "connectionDirection": "BOTTOM", + "connectionPosition": 5, + "connectionName": "LINE7_Side_VLGEN4" + } + } + ], "SHUNT_NON_LINEAR": [ { "busbarId": null, @@ -149,12 +161,43 @@ "switchKinds": [], "isRetrievedBusbarSections": false, "isBusbarSectionPositionFound": true, - "busBarSectionInfos" : { - "1" : [ "NGEN5"], - "2" : [ "NGEN5_2_1", "NGEN5_2_2"] + "busBarSectionInfos": { + "1": [ + "NGEN5" + ], + "2": [ + "NGEN5_2_1", + "NGEN5_2_2" + ] }, "feederBaysInfos": {} + }, + { + "id": "VLGEN7", + "topologyKind": "NODE_BREAKER", + "substationId": "P5", + "nominalV": 24.0, + "lowVoltageLimit": 20.0, + "highVoltageLimit": 30.0, + "busbarCount": 1, + "sectionCount": 1, + "switchKinds": [], + "isRetrievedBusbarSections": false, + "isBusbarSectionPositionFound": false, + "busBarSectionInfos": {}, + "feederBaysInfos": { + "LINE7": [ + { + "busbarId": "NGEN7", + "connectablePositionInfos": { + "connectionDirection": "TOP", + "connectionPosition": 3, + "connectionName": "LINE7_Side_VLGEN8" + } + } + ] + } } ] } -] \ No newline at end of file +] diff --git a/src/test/resources/substations-map-data.json b/src/test/resources/substations-map-data.json index 59c61307..a2302382 100644 --- a/src/test/resources/substations-map-data.json +++ b/src/test/resources/substations-map-data.json @@ -4,20 +4,20 @@ "name": "P1_Name", "voltageLevels": [ { - "id": "VLGEN", + "id": "VLNEW2", "substationId": "P1", - "nominalV": 24.0, - "name": "VLGEN_Name" + "nominalV": 225.0 }, { - "id": "VLHV1", + "id": "VLGEN", + "name": "VLGEN_Name", "substationId": "P1", - "nominalV": 380.0 + "nominalV": 24.0 }, { - "id": "VLNEW2", + "id": "VLHV1", "substationId": "P1", - "nominalV": 225.0 + "nominalV": 380.0 } ] }, @@ -47,31 +47,36 @@ ] }, { - "id": "P4", + "id": "P6", "voltageLevels": [ { - "id": "VLGEN4", - "substationId": "P4", + "id": "VLGEN6", + "substationId": "P6", "nominalV": 24.0 } ] }, { - "id": "P5", + "id": "P4", "voltageLevels": [ { - "id": "VLGEN5", - "substationId": "P5", + "id": "VLGEN4", + "substationId": "P4", "nominalV": 24.0 } ] }, { - "id": "P6", + "id": "P5", "voltageLevels": [ { - "id": "VLGEN6", - "substationId": "P6", + "id": "VLGEN7", + "substationId": "P5", + "nominalV": 24.0 + }, + { + "id": "VLGEN5", + "substationId": "P5", "nominalV": 24.0 } ] diff --git a/src/test/resources/substations-map-data_without_vl.json b/src/test/resources/substations-map-data_without_vl.json index 9502c827..462a22b1 100644 --- a/src/test/resources/substations-map-data_without_vl.json +++ b/src/test/resources/substations-map-data_without_vl.json @@ -5,9 +5,9 @@ "voltageLevels": [ { "id": "VLGEN", + "name": "VLGEN_Name", "substationId": "P1", - "nominalV": 24.0, - "name": "VLGEN_Name" + "nominalV": 24.0 }, { "id": "VLHV1", @@ -50,6 +50,16 @@ } ] }, + { + "id": "P6", + "voltageLevels": [ + { + "id": "VLGEN6", + "substationId": "P6", + "nominalV": 24.0 + } + ] + }, { "id": "P4", "voltageLevels": [ @@ -67,15 +77,10 @@ "id": "VLGEN5", "substationId": "P5", "nominalV": 24.0 - } - ] - }, - { - "id": "P6", - "voltageLevels": [ + }, { - "id": "VLGEN6", - "substationId": "P6", + "id": "VLGEN7", + "substationId": "P5", "nominalV": 24.0 } ] diff --git a/src/test/resources/substations-tab-data.json b/src/test/resources/substations-tab-data.json index f3b52a69..5e8ba82d 100644 --- a/src/test/resources/substations-tab-data.json +++ b/src/test/resources/substations-tab-data.json @@ -1,9 +1,4 @@ [ - { - "id": "P0", - "voltageLevels": [], - "country": "FR" - }, { "id": "P1", "name": "P1_Name", @@ -13,19 +8,19 @@ "voltageLevels": [ { "id": "VLGEN", + "name": "VLGEN_Name", + "properties": { + "Country": "FR" + }, "substationId": "P1", "nominalV": 24.0, "country": "FR", - "name": "VLGEN_Name", "lowVoltageLimit": 200.0, "highVoltageLimit": 400.0, "identifiableShortCircuit": { "ipMin": 10.0, "ipMax": 120.0 }, - "properties": { - "Country": "FR" - }, "substationProperties": { "Country": "FR" } @@ -41,12 +36,12 @@ }, { "id": "VLNEW2", - "substationId": "P1", - "nominalV": 225.0, - "country": "FR", "properties": { "Country": "FR" }, + "substationId": "P1", + "nominalV": 225.0, + "country": "FR", "substationProperties": { "Country": "FR" } @@ -69,6 +64,11 @@ } ] }, + { + "id": "P0", + "voltageLevels": [], + "country": "FR" + }, { "id": "P3", "properties": { @@ -125,6 +125,14 @@ "ipMin": 0.0, "ipMax": 100.0 } + }, + { + "id": "VLGEN7", + "substationId": "P5", + "nominalV": 24.0, + "country": "FR", + "lowVoltageLimit": 20.0, + "highVoltageLimit": 30.0 } ], "country": "FR" diff --git a/src/test/resources/switches-data-in-variant.json b/src/test/resources/switches-data-in-variant.json index e6a9eb9a..f5eae0c7 100644 --- a/src/test/resources/switches-data-in-variant.json +++ b/src/test/resources/switches-data-in-variant.json @@ -3,8 +3,16 @@ "id": "VL4_BBS_SHUNT_DISCONNECTOR", "open": false }, + { + "id": "b4", + "open": false + }, { "id": "VL4_SHUNT_BREAKER", "open": true + }, + { + "id": "br11", + "open": false } ] \ No newline at end of file diff --git a/src/test/resources/switches-data.json b/src/test/resources/switches-data.json index 2848d225..af40ffad 100644 --- a/src/test/resources/switches-data.json +++ b/src/test/resources/switches-data.json @@ -6,5 +6,13 @@ { "id": "VL4_SHUNT_BREAKER", "open": false + }, + { + "id": "b4", + "open": false + }, + { + "id": "br11", + "open": false } ] \ No newline at end of file diff --git a/src/test/resources/voltage-level-form-data-feederbays.json b/src/test/resources/voltage-level-form-data-feederbays.json new file mode 100644 index 00000000..5c2833b7 --- /dev/null +++ b/src/test/resources/voltage-level-form-data-feederbays.json @@ -0,0 +1,27 @@ +{ + "id": "VLGEN5", + "topologyKind": "NODE_BREAKER", + "substationId": "P5", + "nominalV": 24.0, + "lowVoltageLimit": 20.0, + "highVoltageLimit": 30.0, + "identifiableShortCircuit": { + "ipMin": 0.0, + "ipMax": 100.0 + }, + "busbarCount": 1, + "sectionCount": 1, + "switchKinds": [], + "isRetrievedBusbarSections": false, + "isBusbarSectionPositionFound": true, + "busBarSectionInfos": { + "1": [ + "NGEN5" + ], + "2": [ + "NGEN5_2_1", + "NGEN5_2_2" + ] + }, + "feederBaysInfos": {} +} \ No newline at end of file diff --git a/src/test/resources/voltage-level-form-data.json b/src/test/resources/voltage-level-form-data.json index e9dc33b0..b29c06ab 100644 --- a/src/test/resources/voltage-level-form-data.json +++ b/src/test/resources/voltage-level-form-data.json @@ -24,6 +24,16 @@ } } ], + "LINE7": [ + { + "busbarId": "NGEN4", + "connectablePositionInfos": { + "connectionDirection": "BOTTOM", + "connectionPosition": 5, + "connectionName": "LINE7_Side_VLGEN4" + } + } + ], "SHUNT_NON_LINEAR": [ { "busbarId": null, diff --git a/src/test/resources/voltage-level-non-symmetrical-busbars-form-data.json b/src/test/resources/voltage-level-non-symmetrical-busbars-form-data.json index e1cde5e7..5c2833b7 100644 --- a/src/test/resources/voltage-level-non-symmetrical-busbars-form-data.json +++ b/src/test/resources/voltage-level-non-symmetrical-busbars-form-data.json @@ -24,4 +24,4 @@ ] }, "feederBaysInfos": {} -} +} \ No newline at end of file diff --git a/src/test/resources/voltage-levels-form-data.json b/src/test/resources/voltage-levels-form-data.json index aee4b2fa..051da533 100644 --- a/src/test/resources/voltage-levels-form-data.json +++ b/src/test/resources/voltage-levels-form-data.json @@ -86,6 +86,16 @@ } } ], + "LINE7": [ + { + "busbarId": "NGEN4", + "connectablePositionInfos": { + "connectionDirection": "BOTTOM", + "connectionPosition": 5, + "connectionName": "LINE7_Side_VLGEN4" + } + } + ], "SHUNT_NON_LINEAR": [ { "busbarId": null, @@ -122,5 +132,31 @@ ] }, "feederBaysInfos": {} + }, + { + "id": "VLGEN7", + "topologyKind": "NODE_BREAKER", + "substationId": "P5", + "nominalV": 24.0, + "lowVoltageLimit": 20.0, + "highVoltageLimit": 30.0, + "busbarCount": 1, + "sectionCount": 1, + "switchKinds": [], + "isRetrievedBusbarSections": false, + "isBusbarSectionPositionFound": false, + "busBarSectionInfos": {}, + "feederBaysInfos": { + "LINE7": [ + { + "busbarId": "NGEN7", + "connectablePositionInfos": { + "connectionDirection": "TOP", + "connectionPosition": 3, + "connectionName": "LINE7_Side_VLGEN8" + } + } + ] + } } -] +] \ No newline at end of file diff --git a/src/test/resources/voltage-levels-list-data.json b/src/test/resources/voltage-levels-list-data.json index 6705164a..4356f7da 100644 --- a/src/test/resources/voltage-levels-list-data.json +++ b/src/test/resources/voltage-levels-list-data.json @@ -1,11 +1,7 @@ [ - { - "id": "VL", - "name":"VL" - }, { "id": "VLGEN", - "name":"VLGEN_Name" + "name": "VLGEN_Name" }, { "id": "VLHV1" @@ -22,6 +18,13 @@ { "id": "VLGEN3" }, + { + "id": "VLGEN6" + }, + { + "id": "VL", + "name": "VL" + }, { "id": "VLGEN4" }, @@ -29,6 +32,6 @@ "id": "VLGEN5" }, { - "id": "VLGEN6" + "id": "VLGEN7" } -] +] \ No newline at end of file diff --git a/src/test/resources/voltage-levels-map-data.json b/src/test/resources/voltage-levels-map-data.json index 8f77d945..baeeac1d 100644 --- a/src/test/resources/voltage-levels-map-data.json +++ b/src/test/resources/voltage-levels-map-data.json @@ -1,14 +1,9 @@ [ - { - "id": "VL", - "name":"VL", - "nominalV": 24.0 - }, { "id": "VLGEN", + "name": "VLGEN_Name", "substationId": "P1", - "nominalV": 24.0, - "name": "VLGEN_Name" + "nominalV": 24.0 }, { "id": "VLHV1", @@ -40,6 +35,11 @@ "substationId": "P6", "nominalV": 24.0 }, + { + "id": "VL", + "name": "VL", + "nominalV": 24.0 + }, { "id": "VLGEN4", "substationId": "P4", @@ -49,5 +49,10 @@ "id": "VLGEN5", "substationId": "P5", "nominalV": 24.0 + }, + { + "id": "VLGEN7", + "substationId": "P5", + "nominalV": 24.0 } -] +] \ No newline at end of file From f63c963670396e272abc88d32f1cecd14db204e9 Mon Sep 17 00:00:00 2001 From: Etienne LESOT Date: Fri, 5 Sep 2025 09:19:06 +0200 Subject: [PATCH 12/19] add side for branches Signed-off-by: Etienne LESOT --- .../definition/voltagelevel/FeederBayInfos.java | 2 +- .../map/dto/mapper/VoltageLevelInfosMapper.java | 6 +++--- src/test/resources/substations-form-data.json | 14 +++++++++----- src/test/resources/voltage-level-form-data.json | 9 ++++++--- src/test/resources/voltage-levels-form-data.json | 12 ++++++++---- 5 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/gridsuite/network/map/dto/definition/voltagelevel/FeederBayInfos.java b/src/main/java/org/gridsuite/network/map/dto/definition/voltagelevel/FeederBayInfos.java index 1aa3ed44..bed1d4d1 100644 --- a/src/main/java/org/gridsuite/network/map/dto/definition/voltagelevel/FeederBayInfos.java +++ b/src/main/java/org/gridsuite/network/map/dto/definition/voltagelevel/FeederBayInfos.java @@ -11,4 +11,4 @@ /** * @author Etienne Lesot */ -public record FeederBayInfos(String busbarId, ConnectablePositionInfos connectablePositionInfos) { } +public record FeederBayInfos(String busbarId, ConnectablePositionInfos connectablePositionInfos, Integer side) { } diff --git a/src/main/java/org/gridsuite/network/map/dto/mapper/VoltageLevelInfosMapper.java b/src/main/java/org/gridsuite/network/map/dto/mapper/VoltageLevelInfosMapper.java index 00a4b6f4..37fceed8 100644 --- a/src/main/java/org/gridsuite/network/map/dto/mapper/VoltageLevelInfosMapper.java +++ b/src/main/java/org/gridsuite/network/map/dto/mapper/VoltageLevelInfosMapper.java @@ -122,14 +122,14 @@ private static Map> getConnectionInfos(VoltageLevel .forEach(connectable -> { switch (connectable) { case Injection injection -> connections.put(injection.getId(), List.of(new FeederBayInfos(getBusOrBusbarSection(injection.getTerminal()), - toMapConnectablePosition(injection, 0)))); + toMapConnectablePosition(injection, 0), null))); case Branch branch -> { List branchConnections = new ArrayList<>(); if (branch.getTerminal1().getVoltageLevel().getId().equals(voltageLevel.getId())) { - branchConnections.add(new FeederBayInfos(getBusOrBusbarSection(branch.getTerminal1()), toMapConnectablePosition(branch, 1))); + branchConnections.add(new FeederBayInfos(getBusOrBusbarSection(branch.getTerminal1()), toMapConnectablePosition(branch, 1), 1)); } if (branch.getTerminal2().getVoltageLevel().getId().equals(voltageLevel.getId())) { - branchConnections.add(new FeederBayInfos(getBusOrBusbarSection(branch.getTerminal2()), toMapConnectablePosition(branch, 2))); + branchConnections.add(new FeederBayInfos(getBusOrBusbarSection(branch.getTerminal2()), toMapConnectablePosition(branch, 2), 2)); } connections.put(branch.getId(), branchConnections); } diff --git a/src/test/resources/substations-form-data.json b/src/test/resources/substations-form-data.json index 9a81c672..c6702144 100644 --- a/src/test/resources/substations-form-data.json +++ b/src/test/resources/substations-form-data.json @@ -116,7 +116,8 @@ "busbarId": "NGEN4", "connectablePositionInfos": { "connectionDirection": null - } + }, + "side": null } ], "LINE7": [ @@ -126,7 +127,8 @@ "connectionDirection": "BOTTOM", "connectionPosition": 5, "connectionName": "LINE7_Side_VLGEN4" - } + }, + "side": 1 } ], "SHUNT_NON_LINEAR": [ @@ -134,7 +136,8 @@ "busbarId": null, "connectablePositionInfos": { "connectionDirection": null - } + }, + "side": null } ] } @@ -193,11 +196,12 @@ "connectionDirection": "TOP", "connectionPosition": 3, "connectionName": "LINE7_Side_VLGEN8" - } + }, + "side": 2 } ] } } ] } -] +] \ No newline at end of file diff --git a/src/test/resources/voltage-level-form-data.json b/src/test/resources/voltage-level-form-data.json index b29c06ab..df2ed728 100644 --- a/src/test/resources/voltage-level-form-data.json +++ b/src/test/resources/voltage-level-form-data.json @@ -21,7 +21,8 @@ "busbarId": "NGEN4", "connectablePositionInfos": { "connectionDirection": null - } + }, + "side": null } ], "LINE7": [ @@ -31,7 +32,8 @@ "connectionDirection": "BOTTOM", "connectionPosition": 5, "connectionName": "LINE7_Side_VLGEN4" - } + }, + "side": 1 } ], "SHUNT_NON_LINEAR": [ @@ -39,7 +41,8 @@ "busbarId": null, "connectablePositionInfos": { "connectionDirection": null - } + }, + "side": null } ] } diff --git a/src/test/resources/voltage-levels-form-data.json b/src/test/resources/voltage-levels-form-data.json index 051da533..5a281dba 100644 --- a/src/test/resources/voltage-levels-form-data.json +++ b/src/test/resources/voltage-levels-form-data.json @@ -83,7 +83,8 @@ "busbarId": "NGEN4", "connectablePositionInfos": { "connectionDirection": null - } + }, + "side": null } ], "LINE7": [ @@ -93,7 +94,8 @@ "connectionDirection": "BOTTOM", "connectionPosition": 5, "connectionName": "LINE7_Side_VLGEN4" - } + }, + "side": 1 } ], "SHUNT_NON_LINEAR": [ @@ -101,7 +103,8 @@ "busbarId": null, "connectablePositionInfos": { "connectionDirection": null - } + }, + "side": null } ] } @@ -154,7 +157,8 @@ "connectionDirection": "TOP", "connectionPosition": 3, "connectionName": "LINE7_Side_VLGEN8" - } + }, + "side": 2 } ] } From 7e6fd6b49755a395faa6faf515efbda10051b374 Mon Sep 17 00:00:00 2001 From: Rehili Ghazwa Date: Fri, 5 Sep 2025 11:05:15 +0200 Subject: [PATCH 13/19] add side --- .../map/dto/definition/voltagelevel/FeederBayInfos.java | 3 ++- .../network/map/dto/mapper/VoltageLevelInfosMapper.java | 4 ++-- src/test/resources/substations-form-data.json | 4 ++-- src/test/resources/voltage-level-form-data.json | 2 +- src/test/resources/voltage-levels-form-data.json | 4 ++-- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/gridsuite/network/map/dto/definition/voltagelevel/FeederBayInfos.java b/src/main/java/org/gridsuite/network/map/dto/definition/voltagelevel/FeederBayInfos.java index bed1d4d1..1021183e 100644 --- a/src/main/java/org/gridsuite/network/map/dto/definition/voltagelevel/FeederBayInfos.java +++ b/src/main/java/org/gridsuite/network/map/dto/definition/voltagelevel/FeederBayInfos.java @@ -6,9 +6,10 @@ */ package org.gridsuite.network.map.dto.definition.voltagelevel; +import com.powsybl.iidm.network.ThreeSides; import org.gridsuite.network.map.dto.definition.extension.ConnectablePositionInfos; /** * @author Etienne Lesot */ -public record FeederBayInfos(String busbarId, ConnectablePositionInfos connectablePositionInfos, Integer side) { } +public record FeederBayInfos(String busbarId, ConnectablePositionInfos connectablePositionInfos, ThreeSides side) { } diff --git a/src/main/java/org/gridsuite/network/map/dto/mapper/VoltageLevelInfosMapper.java b/src/main/java/org/gridsuite/network/map/dto/mapper/VoltageLevelInfosMapper.java index 37fceed8..d7781a58 100644 --- a/src/main/java/org/gridsuite/network/map/dto/mapper/VoltageLevelInfosMapper.java +++ b/src/main/java/org/gridsuite/network/map/dto/mapper/VoltageLevelInfosMapper.java @@ -126,10 +126,10 @@ private static Map> getConnectionInfos(VoltageLevel case Branch branch -> { List branchConnections = new ArrayList<>(); if (branch.getTerminal1().getVoltageLevel().getId().equals(voltageLevel.getId())) { - branchConnections.add(new FeederBayInfos(getBusOrBusbarSection(branch.getTerminal1()), toMapConnectablePosition(branch, 1), 1)); + branchConnections.add(new FeederBayInfos(getBusOrBusbarSection(branch.getTerminal1()), toMapConnectablePosition(branch, 1), ThreeSides.ONE)); } if (branch.getTerminal2().getVoltageLevel().getId().equals(voltageLevel.getId())) { - branchConnections.add(new FeederBayInfos(getBusOrBusbarSection(branch.getTerminal2()), toMapConnectablePosition(branch, 2), 2)); + branchConnections.add(new FeederBayInfos(getBusOrBusbarSection(branch.getTerminal2()), toMapConnectablePosition(branch, 2), ThreeSides.TWO)); } connections.put(branch.getId(), branchConnections); } diff --git a/src/test/resources/substations-form-data.json b/src/test/resources/substations-form-data.json index c6702144..879e3178 100644 --- a/src/test/resources/substations-form-data.json +++ b/src/test/resources/substations-form-data.json @@ -128,7 +128,7 @@ "connectionPosition": 5, "connectionName": "LINE7_Side_VLGEN4" }, - "side": 1 + "side": "ONE" } ], "SHUNT_NON_LINEAR": [ @@ -197,7 +197,7 @@ "connectionPosition": 3, "connectionName": "LINE7_Side_VLGEN8" }, - "side": 2 + "side": "TWO" } ] } diff --git a/src/test/resources/voltage-level-form-data.json b/src/test/resources/voltage-level-form-data.json index df2ed728..82c1e283 100644 --- a/src/test/resources/voltage-level-form-data.json +++ b/src/test/resources/voltage-level-form-data.json @@ -33,7 +33,7 @@ "connectionPosition": 5, "connectionName": "LINE7_Side_VLGEN4" }, - "side": 1 + "side": "ONE" } ], "SHUNT_NON_LINEAR": [ diff --git a/src/test/resources/voltage-levels-form-data.json b/src/test/resources/voltage-levels-form-data.json index 5a281dba..cedbb51e 100644 --- a/src/test/resources/voltage-levels-form-data.json +++ b/src/test/resources/voltage-levels-form-data.json @@ -95,7 +95,7 @@ "connectionPosition": 5, "connectionName": "LINE7_Side_VLGEN4" }, - "side": 1 + "side": "ONE" } ], "SHUNT_NON_LINEAR": [ @@ -158,7 +158,7 @@ "connectionPosition": 3, "connectionName": "LINE7_Side_VLGEN8" }, - "side": 2 + "side": "TWO" } ] } From c966b59d42d459c25b1dc4df99391a752f00fd42 Mon Sep 17 00:00:00 2001 From: Rehili Ghazwa Date: Sun, 7 Sep 2025 18:24:27 +0200 Subject: [PATCH 14/19] rename side to connectionSide --- .../definition/voltagelevel/FeederBayInfos.java | 2 +- src/test/resources/substations-form-data.json | 16 ++++++++-------- src/test/resources/voltage-level-form-data.json | 12 ++++++------ src/test/resources/voltage-levels-form-data.json | 16 ++++++++-------- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/main/java/org/gridsuite/network/map/dto/definition/voltagelevel/FeederBayInfos.java b/src/main/java/org/gridsuite/network/map/dto/definition/voltagelevel/FeederBayInfos.java index 1021183e..e4d0b330 100644 --- a/src/main/java/org/gridsuite/network/map/dto/definition/voltagelevel/FeederBayInfos.java +++ b/src/main/java/org/gridsuite/network/map/dto/definition/voltagelevel/FeederBayInfos.java @@ -12,4 +12,4 @@ /** * @author Etienne Lesot */ -public record FeederBayInfos(String busbarId, ConnectablePositionInfos connectablePositionInfos, ThreeSides side) { } +public record FeederBayInfos(String busOrBusbarSectionId, ConnectablePositionInfos connectablePositionInfos, ThreeSides connectionSide) { } diff --git a/src/test/resources/substations-form-data.json b/src/test/resources/substations-form-data.json index 879e3178..d439efde 100644 --- a/src/test/resources/substations-form-data.json +++ b/src/test/resources/substations-form-data.json @@ -113,31 +113,31 @@ "feederBaysInfos": { "SHUNT_VLNB": [ { - "busbarId": "NGEN4", + "busOrBusbarSectionId": "NGEN4", "connectablePositionInfos": { "connectionDirection": null }, - "side": null + "connectionSide": null } ], "LINE7": [ { - "busbarId": "NGEN4", + "busOrBusbarSectionId": "NGEN4", "connectablePositionInfos": { "connectionDirection": "BOTTOM", "connectionPosition": 5, "connectionName": "LINE7_Side_VLGEN4" }, - "side": "ONE" + "connectionSide": "ONE" } ], "SHUNT_NON_LINEAR": [ { - "busbarId": null, + "busOrBusbarSectionId": null, "connectablePositionInfos": { "connectionDirection": null }, - "side": null + "connectionSide": null } ] } @@ -191,13 +191,13 @@ "feederBaysInfos": { "LINE7": [ { - "busbarId": "NGEN7", + "busOrBusbarSectionId": "NGEN7", "connectablePositionInfos": { "connectionDirection": "TOP", "connectionPosition": 3, "connectionName": "LINE7_Side_VLGEN8" }, - "side": "TWO" + "connectionSide": "TWO" } ] } diff --git a/src/test/resources/voltage-level-form-data.json b/src/test/resources/voltage-level-form-data.json index 82c1e283..02f49e03 100644 --- a/src/test/resources/voltage-level-form-data.json +++ b/src/test/resources/voltage-level-form-data.json @@ -18,31 +18,31 @@ "feederBaysInfos": { "SHUNT_VLNB": [ { - "busbarId": "NGEN4", + "busOrBusbarSectionId": "NGEN4", "connectablePositionInfos": { "connectionDirection": null }, - "side": null + "connectionSide": null } ], "LINE7": [ { - "busbarId": "NGEN4", + "busOrBusbarSectionId": "NGEN4", "connectablePositionInfos": { "connectionDirection": "BOTTOM", "connectionPosition": 5, "connectionName": "LINE7_Side_VLGEN4" }, - "side": "ONE" + "connectionSide": "ONE" } ], "SHUNT_NON_LINEAR": [ { - "busbarId": null, + "busOrBusbarSectionId": null, "connectablePositionInfos": { "connectionDirection": null }, - "side": null + "connectionSide": null } ] } diff --git a/src/test/resources/voltage-levels-form-data.json b/src/test/resources/voltage-levels-form-data.json index cedbb51e..4d9bc619 100644 --- a/src/test/resources/voltage-levels-form-data.json +++ b/src/test/resources/voltage-levels-form-data.json @@ -80,31 +80,31 @@ "feederBaysInfos": { "SHUNT_VLNB": [ { - "busbarId": "NGEN4", + "busOrBusbarSectionId": "NGEN4", "connectablePositionInfos": { "connectionDirection": null }, - "side": null + "connectionSide": null } ], "LINE7": [ { - "busbarId": "NGEN4", + "busOrBusbarSectionId": "NGEN4", "connectablePositionInfos": { "connectionDirection": "BOTTOM", "connectionPosition": 5, "connectionName": "LINE7_Side_VLGEN4" }, - "side": "ONE" + "connectionSide": "ONE" } ], "SHUNT_NON_LINEAR": [ { - "busbarId": null, + "busOrBusbarSectionId": null, "connectablePositionInfos": { "connectionDirection": null }, - "side": null + "connectionSide": null } ] } @@ -152,13 +152,13 @@ "feederBaysInfos": { "LINE7": [ { - "busbarId": "NGEN7", + "busOrBusbarSectionId": "NGEN7", "connectablePositionInfos": { "connectionDirection": "TOP", "connectionPosition": 3, "connectionName": "LINE7_Side_VLGEN8" }, - "side": "TWO" + "connectionSide": "TWO" } ] } From c2a535ea6b331653af981455d6c6f62f8ce0e761 Mon Sep 17 00:00:00 2001 From: Rehili Ghazwa Date: Sun, 7 Sep 2025 19:12:30 +0200 Subject: [PATCH 15/19] fix naming --- .../map/dto/definition/voltagelevel/FeederBayInfos.java | 2 +- src/test/resources/substations-form-data.json | 8 ++++---- src/test/resources/voltage-level-form-data.json | 6 +++--- src/test/resources/voltage-levels-form-data.json | 8 ++++---- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/gridsuite/network/map/dto/definition/voltagelevel/FeederBayInfos.java b/src/main/java/org/gridsuite/network/map/dto/definition/voltagelevel/FeederBayInfos.java index e4d0b330..c14dbcb5 100644 --- a/src/main/java/org/gridsuite/network/map/dto/definition/voltagelevel/FeederBayInfos.java +++ b/src/main/java/org/gridsuite/network/map/dto/definition/voltagelevel/FeederBayInfos.java @@ -12,4 +12,4 @@ /** * @author Etienne Lesot */ -public record FeederBayInfos(String busOrBusbarSectionId, ConnectablePositionInfos connectablePositionInfos, ThreeSides connectionSide) { } +public record FeederBayInfos(String busbarSectionId, ConnectablePositionInfos connectablePositionInfos, ThreeSides connectionSide) { } diff --git a/src/test/resources/substations-form-data.json b/src/test/resources/substations-form-data.json index d439efde..1bfcc78f 100644 --- a/src/test/resources/substations-form-data.json +++ b/src/test/resources/substations-form-data.json @@ -113,7 +113,7 @@ "feederBaysInfos": { "SHUNT_VLNB": [ { - "busOrBusbarSectionId": "NGEN4", + "busbarSectionId": "NGEN4", "connectablePositionInfos": { "connectionDirection": null }, @@ -122,7 +122,7 @@ ], "LINE7": [ { - "busOrBusbarSectionId": "NGEN4", + "busbarSectionId": "NGEN4", "connectablePositionInfos": { "connectionDirection": "BOTTOM", "connectionPosition": 5, @@ -133,7 +133,7 @@ ], "SHUNT_NON_LINEAR": [ { - "busOrBusbarSectionId": null, + "busbarSectionId": null, "connectablePositionInfos": { "connectionDirection": null }, @@ -191,7 +191,7 @@ "feederBaysInfos": { "LINE7": [ { - "busOrBusbarSectionId": "NGEN7", + "busbarSectionId": "NGEN7", "connectablePositionInfos": { "connectionDirection": "TOP", "connectionPosition": 3, diff --git a/src/test/resources/voltage-level-form-data.json b/src/test/resources/voltage-level-form-data.json index 02f49e03..e6cfd78a 100644 --- a/src/test/resources/voltage-level-form-data.json +++ b/src/test/resources/voltage-level-form-data.json @@ -18,7 +18,7 @@ "feederBaysInfos": { "SHUNT_VLNB": [ { - "busOrBusbarSectionId": "NGEN4", + "busbarSectionId": "NGEN4", "connectablePositionInfos": { "connectionDirection": null }, @@ -27,7 +27,7 @@ ], "LINE7": [ { - "busOrBusbarSectionId": "NGEN4", + "busbarSectionId": "NGEN4", "connectablePositionInfos": { "connectionDirection": "BOTTOM", "connectionPosition": 5, @@ -38,7 +38,7 @@ ], "SHUNT_NON_LINEAR": [ { - "busOrBusbarSectionId": null, + "busbarSectionId": null, "connectablePositionInfos": { "connectionDirection": null }, diff --git a/src/test/resources/voltage-levels-form-data.json b/src/test/resources/voltage-levels-form-data.json index 4d9bc619..143878b1 100644 --- a/src/test/resources/voltage-levels-form-data.json +++ b/src/test/resources/voltage-levels-form-data.json @@ -80,7 +80,7 @@ "feederBaysInfos": { "SHUNT_VLNB": [ { - "busOrBusbarSectionId": "NGEN4", + "busbarSectionId": "NGEN4", "connectablePositionInfos": { "connectionDirection": null }, @@ -89,7 +89,7 @@ ], "LINE7": [ { - "busOrBusbarSectionId": "NGEN4", + "busbarSectionId": "NGEN4", "connectablePositionInfos": { "connectionDirection": "BOTTOM", "connectionPosition": 5, @@ -100,7 +100,7 @@ ], "SHUNT_NON_LINEAR": [ { - "busOrBusbarSectionId": null, + "busbarSectionId": null, "connectablePositionInfos": { "connectionDirection": null }, @@ -152,7 +152,7 @@ "feederBaysInfos": { "LINE7": [ { - "busOrBusbarSectionId": "NGEN7", + "busbarSectionId": "NGEN7", "connectablePositionInfos": { "connectionDirection": "TOP", "connectionPosition": 3, From 12d9d9fb886459ab20f24df35d18308a6874568a Mon Sep 17 00:00:00 2001 From: Rehili Ghazwa Date: Mon, 8 Sep 2025 21:30:04 +0200 Subject: [PATCH 16/19] renaming --- .../network/map/dto/mapper/VoltageLevelInfosMapper.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/gridsuite/network/map/dto/mapper/VoltageLevelInfosMapper.java b/src/main/java/org/gridsuite/network/map/dto/mapper/VoltageLevelInfosMapper.java index d7781a58..0983a7b4 100644 --- a/src/main/java/org/gridsuite/network/map/dto/mapper/VoltageLevelInfosMapper.java +++ b/src/main/java/org/gridsuite/network/map/dto/mapper/VoltageLevelInfosMapper.java @@ -107,7 +107,7 @@ static VoltageLevelFormInfos toFormInfos(Identifiable identifiable) { builder.isRetrievedBusbarSections(vlTopologyInfos.isRetrievedBusbarSections()); builder.isBusbarSectionPositionFound(vlTopologyInfos.isBusbarSectionPositionFound()); builder.busBarSectionInfos(vlTopologyInfos.getBusBarSectionInfosGrouped()); - builder.feederBaysInfos(getConnectionInfos(voltageLevel)); + builder.feederBaysInfos(getFeederBaysInfos(voltageLevel)); } builder.identifiableShortCircuit(ExtensionUtils.toIdentifiableShortCircuit(voltageLevel)); @@ -115,7 +115,7 @@ static VoltageLevelFormInfos toFormInfos(Identifiable identifiable) { return builder.build(); } - private static Map> getConnectionInfos(VoltageLevel voltageLevel) { + private static Map> getFeederBaysInfos(VoltageLevel voltageLevel) { Map> connections = new HashMap<>(); voltageLevel.getConnectableStream() .filter(connectable -> !(connectable instanceof BusbarSection)) From fed0ec8393d3ad4849ad99eac81d27b890ad0ccb Mon Sep 17 00:00:00 2001 From: Rehili Ghazwa Date: Sun, 14 Sep 2025 17:21:47 +0200 Subject: [PATCH 17/19] fix for BusbarSectionFinderTraverser --- .../BusbarSectionFinderTraverser.java | 68 +++++++++++++++---- .../dto/mapper/VoltageLevelInfosMapper.java | 13 ++++ .../network/map/dto/utils/ElementUtils.java | 7 +- .../network/map/dto/utils/ExtensionUtils.java | 1 + 4 files changed, 73 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/gridsuite/network/map/dto/definition/extension/BusbarSectionFinderTraverser.java b/src/main/java/org/gridsuite/network/map/dto/definition/extension/BusbarSectionFinderTraverser.java index 2faa6c7d..0391051a 100644 --- a/src/main/java/org/gridsuite/network/map/dto/definition/extension/BusbarSectionFinderTraverser.java +++ b/src/main/java/org/gridsuite/network/map/dto/definition/extension/BusbarSectionFinderTraverser.java @@ -8,40 +8,82 @@ import com.powsybl.iidm.network.IdentifiableType; import com.powsybl.iidm.network.Switch; +import com.powsybl.iidm.network.SwitchKind; import com.powsybl.iidm.network.Terminal; import com.powsybl.math.graph.TraverseResult; +import lombok.Getter; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; /** * @author Slimane Amar */ public class BusbarSectionFinderTraverser implements Terminal.TopologyTraverser { - private final boolean onlyConnectedBbs; - - private String firstTraversedBbsId; - - public BusbarSectionFinderTraverser(boolean onlyConnectedBbs) { - this.onlyConnectedBbs = onlyConnectedBbs; - } + private final List busbarCandidates = new ArrayList<>(); + private final Set visitedTerminals = new HashSet<>(); + private static final int MAX_VISITED = 50; @Override public TraverseResult traverse(Terminal terminal, boolean connected) { - if (terminal.getConnectable().getType() == IdentifiableType.BUSBAR_SECTION) { - firstTraversedBbsId = terminal.getConnectable().getId(); + String terminalId = terminal.getConnectable().getId(); + if (visitedTerminals.contains(terminalId)) { + return TraverseResult.TERMINATE_PATH; + } + visitedTerminals.add(terminalId); + if (visitedTerminals.size() > MAX_VISITED) { return TraverseResult.TERMINATE_TRAVERSER; } + + // If a busbar section is found, add it as a candidate + if (terminal.getConnectable().getType() == IdentifiableType.BUSBAR_SECTION) { + busbarCandidates.add(new BusbarCandidate(terminalId, connected)); + // CONTINUE to explore other paths to other busbars + return TraverseResult.CONTINUE; + } return TraverseResult.CONTINUE; } @Override public TraverseResult traverse(Switch aSwitch) { - if (onlyConnectedBbs && aSwitch.isOpen()) { - return TraverseResult.TERMINATE_PATH; + if (visitedTerminals.size() > MAX_VISITED) { + return TraverseResult.TERMINATE_TRAVERSER; + } + + // KEY: Open disconnectors end this path but not the overall traversal + // They block access to this busbar but not to the others + if (aSwitch.isOpen() && aSwitch.getKind() == SwitchKind.DISCONNECTOR) { + return TraverseResult.TERMINATE_PATH; // Ends this path, not the whole traversal } return TraverseResult.CONTINUE; } - public String getFirstTraversedBbsId() { - return firstTraversedBbsId; + public String getBusbarWithClosedDisconnector() { + // Search for a connected busbar (disconnector closed) + for (BusbarCandidate candidate : busbarCandidates) { + if (candidate.isConnected()) { + return candidate.getId(); + } + } + + // If none is connected, return the first one found (fallback) + if (!busbarCandidates.isEmpty()) { + return busbarCandidates.getFirst().getId(); + } + return null; + } + + @Getter + private static class BusbarCandidate { + private final String id; + private final boolean connected; + + public BusbarCandidate(String id, boolean connected) { + this.id = id; + this.connected = connected; + } } } diff --git a/src/main/java/org/gridsuite/network/map/dto/mapper/VoltageLevelInfosMapper.java b/src/main/java/org/gridsuite/network/map/dto/mapper/VoltageLevelInfosMapper.java index 0983a7b4..b8c93b7b 100644 --- a/src/main/java/org/gridsuite/network/map/dto/mapper/VoltageLevelInfosMapper.java +++ b/src/main/java/org/gridsuite/network/map/dto/mapper/VoltageLevelInfosMapper.java @@ -133,6 +133,19 @@ private static Map> getFeederBaysInfos(VoltageLevel } connections.put(branch.getId(), branchConnections); } + case ThreeWindingsTransformer threeWindingsTransformer -> { + List threeWTConnections = new ArrayList<>(); + if (threeWindingsTransformer.getLeg1().getTerminal().getVoltageLevel().getId().equals(voltageLevel.getId())) { + threeWTConnections.add(new FeederBayInfos(getBusOrBusbarSection(threeWindingsTransformer.getLeg1().getTerminal()), toMapConnectablePosition(threeWindingsTransformer, 1), ThreeSides.ONE)); + } + if (threeWindingsTransformer.getLeg2().getTerminal().getVoltageLevel().getId().equals(voltageLevel.getId())) { + threeWTConnections.add(new FeederBayInfos(getBusOrBusbarSection(threeWindingsTransformer.getLeg2().getTerminal()), toMapConnectablePosition(threeWindingsTransformer, 2), ThreeSides.TWO)); + } + if (threeWindingsTransformer.getLeg3().getTerminal().getVoltageLevel().getId().equals(voltageLevel.getId())) { + threeWTConnections.add(new FeederBayInfos(getBusOrBusbarSection(threeWindingsTransformer.getLeg3().getTerminal()), toMapConnectablePosition(threeWindingsTransformer, 3), ThreeSides.THREE)); + } + connections.put(threeWindingsTransformer.getId(), threeWTConnections); + } default -> throw new IllegalArgumentException("connectable type: " + connectable.getClass() + " not supported"); } }); diff --git a/src/main/java/org/gridsuite/network/map/dto/utils/ElementUtils.java b/src/main/java/org/gridsuite/network/map/dto/utils/ElementUtils.java index 00711ab9..2462cdab 100644 --- a/src/main/java/org/gridsuite/network/map/dto/utils/ElementUtils.java +++ b/src/main/java/org/gridsuite/network/map/dto/utils/ElementUtils.java @@ -82,9 +82,10 @@ public static String getBusOrBusbarSection(Terminal terminal) { return terminal.getBusBreakerView().getConnectableBus().getId(); } } else { - final BusbarSectionFinderTraverser connectedBusbarSectionFinder = new BusbarSectionFinderTraverser(terminal.isConnected()); - terminal.traverse(connectedBusbarSectionFinder, TraversalType.BREADTH_FIRST); - return connectedBusbarSectionFinder.getFirstTraversedBbsId(); + // NODE_BREAKER: explore all paths and choose the busbar with the closed disconnector + BusbarSectionFinderTraverser finder = new BusbarSectionFinderTraverser(); + terminal.traverse(finder, TraversalType.BREADTH_FIRST); + return finder.getBusbarWithClosedDisconnector(); } } diff --git a/src/main/java/org/gridsuite/network/map/dto/utils/ExtensionUtils.java b/src/main/java/org/gridsuite/network/map/dto/utils/ExtensionUtils.java index 0e977dcc..098a9da0 100644 --- a/src/main/java/org/gridsuite/network/map/dto/utils/ExtensionUtils.java +++ b/src/main/java/org/gridsuite/network/map/dto/utils/ExtensionUtils.java @@ -20,6 +20,7 @@ public static ConnectablePositionInfos toMapConnectablePosition(@NonNull final I case 0 -> connectablePosition.getFeeder(); case 1 -> connectablePosition.getFeeder1(); case 2 -> connectablePosition.getFeeder2(); + case 3 -> connectablePosition.getFeeder3(); default -> throw new IllegalArgumentException("Invalid feeder index: " + index); }) .ifPresent(feeder -> builder From 34b31cc97f9b93471644261a225f5d603673364e Mon Sep 17 00:00:00 2001 From: Rehili Ghazwa Date: Fri, 19 Sep 2025 11:17:25 +0200 Subject: [PATCH 18/19] code review remarks part 1 --- .../dto/mapper/VoltageLevelInfosMapper.java | 48 +++++++------------ .../network/map/dto/utils/ElementUtils.java | 6 +-- 2 files changed, 20 insertions(+), 34 deletions(-) diff --git a/src/main/java/org/gridsuite/network/map/dto/mapper/VoltageLevelInfosMapper.java b/src/main/java/org/gridsuite/network/map/dto/mapper/VoltageLevelInfosMapper.java index b8c93b7b..2f77b029 100644 --- a/src/main/java/org/gridsuite/network/map/dto/mapper/VoltageLevelInfosMapper.java +++ b/src/main/java/org/gridsuite/network/map/dto/mapper/VoltageLevelInfosMapper.java @@ -24,6 +24,7 @@ import java.util.*; import java.util.stream.Collectors; +import static com.powsybl.iidm.network.Terminal.getConnectableSide; import static org.gridsuite.network.map.dto.utils.ElementUtils.*; /** @@ -116,40 +117,25 @@ static VoltageLevelFormInfos toFormInfos(Identifiable identifiable) { } private static Map> getFeederBaysInfos(VoltageLevel voltageLevel) { - Map> connections = new HashMap<>(); + Map> feederBayInfos = new HashMap<>(); + String currentVoltageLevelId = voltageLevel.getId(); voltageLevel.getConnectableStream() - .filter(connectable -> !(connectable instanceof BusbarSection)) - .forEach(connectable -> { - switch (connectable) { - case Injection injection -> connections.put(injection.getId(), List.of(new FeederBayInfos(getBusOrBusbarSection(injection.getTerminal()), - toMapConnectablePosition(injection, 0), null))); - case Branch branch -> { - List branchConnections = new ArrayList<>(); - if (branch.getTerminal1().getVoltageLevel().getId().equals(voltageLevel.getId())) { - branchConnections.add(new FeederBayInfos(getBusOrBusbarSection(branch.getTerminal1()), toMapConnectablePosition(branch, 1), ThreeSides.ONE)); + .filter(connectable -> !(connectable instanceof BusbarSection)) + .forEach(connectable -> { + List connections = new ArrayList<>(); + for (Object obj : connectable.getTerminals()) { + Terminal terminal = (Terminal) obj; + if (terminal.getVoltageLevel().getId().equals(currentVoltageLevelId)) { + connections.add(new FeederBayInfos( + getBusOrBusbarSection(terminal), + getConnectablePosition(connectable, getConnectableSide(terminal).map(ThreeSides::getNum).orElse(0)), + getConnectableSide(terminal).orElse(null) + )); } - if (branch.getTerminal2().getVoltageLevel().getId().equals(voltageLevel.getId())) { - branchConnections.add(new FeederBayInfos(getBusOrBusbarSection(branch.getTerminal2()), toMapConnectablePosition(branch, 2), ThreeSides.TWO)); - } - connections.put(branch.getId(), branchConnections); - } - case ThreeWindingsTransformer threeWindingsTransformer -> { - List threeWTConnections = new ArrayList<>(); - if (threeWindingsTransformer.getLeg1().getTerminal().getVoltageLevel().getId().equals(voltageLevel.getId())) { - threeWTConnections.add(new FeederBayInfos(getBusOrBusbarSection(threeWindingsTransformer.getLeg1().getTerminal()), toMapConnectablePosition(threeWindingsTransformer, 1), ThreeSides.ONE)); - } - if (threeWindingsTransformer.getLeg2().getTerminal().getVoltageLevel().getId().equals(voltageLevel.getId())) { - threeWTConnections.add(new FeederBayInfos(getBusOrBusbarSection(threeWindingsTransformer.getLeg2().getTerminal()), toMapConnectablePosition(threeWindingsTransformer, 2), ThreeSides.TWO)); - } - if (threeWindingsTransformer.getLeg3().getTerminal().getVoltageLevel().getId().equals(voltageLevel.getId())) { - threeWTConnections.add(new FeederBayInfos(getBusOrBusbarSection(threeWindingsTransformer.getLeg3().getTerminal()), toMapConnectablePosition(threeWindingsTransformer, 3), ThreeSides.THREE)); - } - connections.put(threeWindingsTransformer.getId(), threeWTConnections); } - default -> throw new IllegalArgumentException("connectable type: " + connectable.getClass() + " not supported"); - } - }); - return connections; + feederBayInfos.put(connectable.getId(), connections); + }); + return feederBayInfos; } protected static VoltageLevelMapInfos toMapInfos(Identifiable identifiable) { diff --git a/src/main/java/org/gridsuite/network/map/dto/utils/ElementUtils.java b/src/main/java/org/gridsuite/network/map/dto/utils/ElementUtils.java index 2462cdab..4284ed45 100644 --- a/src/main/java/org/gridsuite/network/map/dto/utils/ElementUtils.java +++ b/src/main/java/org/gridsuite/network/map/dto/utils/ElementUtils.java @@ -59,12 +59,12 @@ private static ConnectablePosition.Feeder getFeederInfos(Identifiable identif } } - public static ConnectablePositionInfos toMapConnectablePosition(Identifiable identifiable, int index) { + public static ConnectablePositionInfos getConnectablePosition(Identifiable identifiable, int index) { ConnectablePosition.Feeder feeder = getFeederInfos(identifiable, index); - return convertFeederToConnectablePositionInfos(feeder); + return buildConnectablePositionInfos(feeder); } - public static ConnectablePositionInfos convertFeederToConnectablePositionInfos(ConnectablePosition.Feeder feeder) { + public static ConnectablePositionInfos buildConnectablePositionInfos(ConnectablePosition.Feeder feeder) { ConnectablePositionInfos.ConnectablePositionInfosBuilder builder = ConnectablePositionInfos.builder(); if (feeder != null) { builder.connectionDirection(feeder.getDirection() == null ? null : feeder.getDirection()) From 5a615ba89e4cad80af44c4e7490dc02e85bc1a94 Mon Sep 17 00:00:00 2001 From: Rehili Ghazwa Date: Fri, 19 Sep 2025 11:20:40 +0200 Subject: [PATCH 19/19] code review remarks part 2 --- .../BusbarSectionFinderTraverser.java | 68 ++++--------------- .../network/map/dto/utils/ElementUtils.java | 7 +- 2 files changed, 16 insertions(+), 59 deletions(-) diff --git a/src/main/java/org/gridsuite/network/map/dto/definition/extension/BusbarSectionFinderTraverser.java b/src/main/java/org/gridsuite/network/map/dto/definition/extension/BusbarSectionFinderTraverser.java index 0391051a..2faa6c7d 100644 --- a/src/main/java/org/gridsuite/network/map/dto/definition/extension/BusbarSectionFinderTraverser.java +++ b/src/main/java/org/gridsuite/network/map/dto/definition/extension/BusbarSectionFinderTraverser.java @@ -8,82 +8,40 @@ import com.powsybl.iidm.network.IdentifiableType; import com.powsybl.iidm.network.Switch; -import com.powsybl.iidm.network.SwitchKind; import com.powsybl.iidm.network.Terminal; import com.powsybl.math.graph.TraverseResult; -import lombok.Getter; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; /** * @author Slimane Amar */ public class BusbarSectionFinderTraverser implements Terminal.TopologyTraverser { - private final List busbarCandidates = new ArrayList<>(); - private final Set visitedTerminals = new HashSet<>(); - private static final int MAX_VISITED = 50; + private final boolean onlyConnectedBbs; + + private String firstTraversedBbsId; + + public BusbarSectionFinderTraverser(boolean onlyConnectedBbs) { + this.onlyConnectedBbs = onlyConnectedBbs; + } @Override public TraverseResult traverse(Terminal terminal, boolean connected) { - String terminalId = terminal.getConnectable().getId(); - if (visitedTerminals.contains(terminalId)) { - return TraverseResult.TERMINATE_PATH; - } - visitedTerminals.add(terminalId); - if (visitedTerminals.size() > MAX_VISITED) { - return TraverseResult.TERMINATE_TRAVERSER; - } - - // If a busbar section is found, add it as a candidate if (terminal.getConnectable().getType() == IdentifiableType.BUSBAR_SECTION) { - busbarCandidates.add(new BusbarCandidate(terminalId, connected)); - // CONTINUE to explore other paths to other busbars - return TraverseResult.CONTINUE; + firstTraversedBbsId = terminal.getConnectable().getId(); + return TraverseResult.TERMINATE_TRAVERSER; } return TraverseResult.CONTINUE; } @Override public TraverseResult traverse(Switch aSwitch) { - if (visitedTerminals.size() > MAX_VISITED) { - return TraverseResult.TERMINATE_TRAVERSER; - } - - // KEY: Open disconnectors end this path but not the overall traversal - // They block access to this busbar but not to the others - if (aSwitch.isOpen() && aSwitch.getKind() == SwitchKind.DISCONNECTOR) { - return TraverseResult.TERMINATE_PATH; // Ends this path, not the whole traversal + if (onlyConnectedBbs && aSwitch.isOpen()) { + return TraverseResult.TERMINATE_PATH; } return TraverseResult.CONTINUE; } - public String getBusbarWithClosedDisconnector() { - // Search for a connected busbar (disconnector closed) - for (BusbarCandidate candidate : busbarCandidates) { - if (candidate.isConnected()) { - return candidate.getId(); - } - } - - // If none is connected, return the first one found (fallback) - if (!busbarCandidates.isEmpty()) { - return busbarCandidates.getFirst().getId(); - } - return null; - } - - @Getter - private static class BusbarCandidate { - private final String id; - private final boolean connected; - - public BusbarCandidate(String id, boolean connected) { - this.id = id; - this.connected = connected; - } + public String getFirstTraversedBbsId() { + return firstTraversedBbsId; } } diff --git a/src/main/java/org/gridsuite/network/map/dto/utils/ElementUtils.java b/src/main/java/org/gridsuite/network/map/dto/utils/ElementUtils.java index 4284ed45..c1ddc791 100644 --- a/src/main/java/org/gridsuite/network/map/dto/utils/ElementUtils.java +++ b/src/main/java/org/gridsuite/network/map/dto/utils/ElementUtils.java @@ -82,10 +82,9 @@ public static String getBusOrBusbarSection(Terminal terminal) { return terminal.getBusBreakerView().getConnectableBus().getId(); } } else { - // NODE_BREAKER: explore all paths and choose the busbar with the closed disconnector - BusbarSectionFinderTraverser finder = new BusbarSectionFinderTraverser(); - terminal.traverse(finder, TraversalType.BREADTH_FIRST); - return finder.getBusbarWithClosedDisconnector(); + final BusbarSectionFinderTraverser connectedBusbarSectionFinder = new BusbarSectionFinderTraverser(terminal.isConnected()); + terminal.traverse(connectedBusbarSectionFinder, TraversalType.BREADTH_FIRST); + return connectedBusbarSectionFinder.getFirstTraversedBbsId(); } }