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 f42cd8f2..3da69853 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 @@ -15,6 +15,7 @@ import org.gridsuite.network.map.dto.definition.extension.IdentifiableShortCircuitInfos; import java.util.List; +import java.util.Map; import java.util.Optional; /** @@ -53,4 +54,7 @@ public class VoltageLevelFormInfos extends ElementInfosWithProperties { @JsonInclude(JsonInclude.Include.NON_NULL) private Boolean isRetrievedBusbarSections; + @JsonInclude(JsonInclude.Include.NON_NULL) + Map> busBarSectionInfos; + } 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 7d573476..57d950da 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 @@ -12,15 +12,14 @@ import lombok.Setter; 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.VoltageLevelFormInfos; import org.gridsuite.network.map.dto.definition.voltagelevel.VoltageLevelMapInfos; import org.gridsuite.network.map.dto.definition.voltagelevel.VoltageLevelTabInfos; import org.gridsuite.network.map.dto.utils.ElementUtils; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; +import java.util.stream.Collectors; import static org.gridsuite.network.map.dto.utils.ElementUtils.*; @@ -49,6 +48,7 @@ public static ElementInfos toData(Identifiable identifiable, InfoTypeParamete public static VoltageLevelTopologyInfos getTopologyInfos(VoltageLevel voltageLevel) { VoltageLevelTopologyInfos topologyInfos = new VoltageLevelTopologyInfos(); Map nbSectionsPerBusbar = new HashMap<>(); + List busbarSectionInfos = new ArrayList<>(); for (BusbarSection bbs : voltageLevel.getNodeBreakerView().getBusbarSections()) { var extension = bbs.getExtension(BusbarSectionPosition.class); if (extension != null) { @@ -62,6 +62,12 @@ public static VoltageLevelTopologyInfos getTopologyInfos(VoltageLevel voltageLev if (extension.getSectionIndex() > nbSectionsPerBusbar.get(extension.getBusbarIndex())) { nbSectionsPerBusbar.put(extension.getBusbarIndex(), extension.getSectionIndex()); } + BusBarSectionFormInfos busbarSectionInfo = BusBarSectionFormInfos.builder() + .id(bbs.getId()) + .vertPos(extension.getSectionIndex()) + .horizPos(extension.getBusbarIndex()) + .build(); + busbarSectionInfos.add(busbarSectionInfo); } else { return new VoltageLevelTopologyInfos(); } @@ -72,6 +78,7 @@ public static VoltageLevelTopologyInfos getTopologyInfos(VoltageLevel voltageLev topologyInfos.setRetrievedBusbarSections(true); topologyInfos.setSwitchKinds(Collections.nCopies(topologyInfos.getSectionCount() - 1, SwitchKind.DISCONNECTOR)); + topologyInfos.setBusbarSections(busbarSectionInfos); return topologyInfos; } @@ -94,6 +101,7 @@ protected static VoltageLevelFormInfos toFormInfos(Identifiable identifiable) builder.sectionCount(vlTopologyInfos.getSectionCount()); builder.switchKinds(vlTopologyInfos.getSwitchKinds()); builder.isRetrievedBusbarSections(vlTopologyInfos.isRetrievedBusbarSections()); + builder.busBarSectionInfos(vlTopologyInfos.getBusBarSectionInfosGrouped()); } builder.identifiableShortCircuit(toIdentifiableShortCircuit(voltageLevel)); @@ -132,9 +140,24 @@ protected static VoltageLevelTabInfos toTabInfos(Identifiable identifiable) { @Getter @Setter public static class VoltageLevelTopologyInfos { + List busbarSections = List.of(); boolean isRetrievedBusbarSections = false; int busbarCount = 1; int sectionCount = 1; List switchKinds = List.of(); + + public Map> getBusBarSectionInfosGrouped() { + return busbarSections.stream() + .collect(Collectors.groupingBy( + section -> String.valueOf(section.getHorizPos()), + Collectors.collectingAndThen( + Collectors.toList(), + list -> list.stream() + .sorted(Comparator.comparing(BusBarSectionFormInfos::getVertPos)) + .map(BusBarSectionFormInfos::getId) + .toList() + ) + )); + } } } diff --git a/src/test/resources/substations-form-data.json b/src/test/resources/substations-form-data.json index 5ad4f8ee..19cb44f6 100644 --- a/src/test/resources/substations-form-data.json +++ b/src/test/resources/substations-form-data.json @@ -103,7 +103,10 @@ "switchKinds": [ "DISCONNECTOR" ], - "isRetrievedBusbarSections": true + "isRetrievedBusbarSections": true, + "busBarSectionInfos" : { + "1" : ["NGEN4"] + } } ] }, @@ -125,7 +128,8 @@ "busbarCount": 1, "sectionCount": 1, "switchKinds": [], - "isRetrievedBusbarSections": false + "isRetrievedBusbarSections": false, + "busBarSectionInfos" : { } } ] } diff --git a/src/test/resources/voltage-level-form-data.json b/src/test/resources/voltage-level-form-data.json index 7d752ca8..7cb2e6dd 100644 --- a/src/test/resources/voltage-level-form-data.json +++ b/src/test/resources/voltage-level-form-data.json @@ -6,5 +6,8 @@ "busbarCount": 1, "sectionCount": 2, "switchKinds": ["DISCONNECTOR"], - "isRetrievedBusbarSections": true + "isRetrievedBusbarSections": true, + "busBarSectionInfos" : { + "1" : [ "NGEN4"] + } } diff --git a/src/test/resources/voltage-levels-form-data.json b/src/test/resources/voltage-levels-form-data.json index c6bf9925..a557f050 100644 --- a/src/test/resources/voltage-levels-form-data.json +++ b/src/test/resources/voltage-levels-form-data.json @@ -62,7 +62,10 @@ "busbarCount": 1, "sectionCount": 2, "switchKinds": ["DISCONNECTOR"], - "isRetrievedBusbarSections": true + "isRetrievedBusbarSections": true, + "busBarSectionInfos" : { + "1" : [ "NGEN4" ] + } }, { "id": "VLGEN5", @@ -78,7 +81,8 @@ "busbarCount": 1, "sectionCount": 1, "switchKinds": [], - "isRetrievedBusbarSections": false + "isRetrievedBusbarSections": false, + "busBarSectionInfos" : { } }, { "id": "VLGEN6",