From c2d54d97c5215e8b30a4d54b7578217ce183346e Mon Sep 17 00:00:00 2001 From: Rehili Ghazwa Date: Tue, 29 Jul 2025 16:53:59 +0200 Subject: [PATCH 1/7] get busbarb sections infos --- .../voltagelevel/VoltageLevelFormInfos.java | 10 ++-- .../dto/mapper/VoltageLevelInfosMapper.java | 48 ++++++++++++------- 2 files changed, 36 insertions(+), 22 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 f42cd8f2..6b40116e 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 @@ -12,6 +12,7 @@ import lombok.Getter; import lombok.experimental.SuperBuilder; import org.gridsuite.network.map.dto.ElementInfosWithProperties; +import org.gridsuite.network.map.dto.definition.busbarsection.BusBarSectionFormInfos; import org.gridsuite.network.map.dto.definition.extension.IdentifiableShortCircuitInfos; import java.util.List; @@ -41,16 +42,13 @@ public class VoltageLevelFormInfos extends ElementInfosWithProperties { @JsonInclude(JsonInclude.Include.NON_ABSENT) private Optional identifiableShortCircuit; - @JsonInclude(JsonInclude.Include.NON_NULL) - private Integer busbarCount; - - @JsonInclude(JsonInclude.Include.NON_NULL) - private Integer sectionCount; - @JsonInclude(JsonInclude.Include.NON_NULL) private List switchKinds; @JsonInclude(JsonInclude.Include.NON_NULL) private Boolean isRetrievedBusbarSections; + @JsonInclude(JsonInclude.Include.NON_NULL) + List 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..479cab39 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,13 @@ 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 static org.gridsuite.network.map.dto.utils.ElementUtils.*; @@ -48,30 +46,34 @@ public static ElementInfos toData(Identifiable identifiable, InfoTypeParamete public static VoltageLevelTopologyInfos getTopologyInfos(VoltageLevel voltageLevel) { VoltageLevelTopologyInfos topologyInfos = new VoltageLevelTopologyInfos(); + List busbarSectionInfos = new ArrayList<>(); Map nbSectionsPerBusbar = new HashMap<>(); + for (BusbarSection bbs : voltageLevel.getNodeBreakerView().getBusbarSections()) { var extension = bbs.getExtension(BusbarSectionPosition.class); + BusbarSectionInfos busbarSectionInfo = new BusbarSectionInfos(); if (extension != null) { - if (extension.getBusbarIndex() > topologyInfos.getBusbarCount()) { - topologyInfos.setBusbarCount(extension.getBusbarIndex()); + busbarSectionInfo.setBusbarSectionId(bbs.getId()); + if (extension.getBusbarIndex() > busbarSectionInfo.busbarCount) { + busbarSectionInfo.setBusbarCount(extension.getBusbarIndex()); } - if (extension.getSectionIndex() > topologyInfos.getSectionCount()) { - topologyInfos.setSectionCount(extension.getSectionIndex()); + if (extension.getSectionIndex() > busbarSectionInfo.sectionCount) { + busbarSectionInfo.setSectionCount(extension.getSectionIndex()); } + busbarSectionInfos.add(busbarSectionInfo); nbSectionsPerBusbar.putIfAbsent(extension.getBusbarIndex(), 1); if (extension.getSectionIndex() > nbSectionsPerBusbar.get(extension.getBusbarIndex())) { nbSectionsPerBusbar.put(extension.getBusbarIndex(), extension.getSectionIndex()); } + } else if (nbSectionsPerBusbar.values().stream().anyMatch(v -> v != busbarSectionInfo.sectionCount)) { // Non-symmetrical busbars (nb sections) + return new VoltageLevelTopologyInfos(); } else { return new VoltageLevelTopologyInfos(); } + topologyInfos.setSwitchKinds(Collections.nCopies(busbarSectionInfo.getSectionCount() - 1, SwitchKind.DISCONNECTOR)); } - if (nbSectionsPerBusbar.values().stream().anyMatch(v -> v != topologyInfos.sectionCount)) { // Non-symmetrical busbars (nb sections) - return new VoltageLevelTopologyInfos(); - } - topologyInfos.setRetrievedBusbarSections(true); - topologyInfos.setSwitchKinds(Collections.nCopies(topologyInfos.getSectionCount() - 1, SwitchKind.DISCONNECTOR)); + topologyInfos.setBusbarSections(busbarSectionInfos); return topologyInfos; } @@ -90,8 +92,15 @@ protected static VoltageLevelFormInfos toFormInfos(Identifiable identifiable) if (voltageLevel.getTopologyKind().equals(TopologyKind.NODE_BREAKER)) { VoltageLevelTopologyInfos vlTopologyInfos = getTopologyInfos(voltageLevel); - builder.busbarCount(vlTopologyInfos.getBusbarCount()); - builder.sectionCount(vlTopologyInfos.getSectionCount()); + builder.busBarSectionInfos((List) vlTopologyInfos.getBusbarSections().stream() + .map(bbsInfo -> { + return BusBarSectionFormInfos.builder() + .id(bbsInfo.getBusbarSectionId()) + .horizPos(bbsInfo.getBusbarCount()) + .vertPos(bbsInfo.getSectionCount()) + .build(); + }) + .toList()); builder.switchKinds(vlTopologyInfos.getSwitchKinds()); builder.isRetrievedBusbarSections(vlTopologyInfos.isRetrievedBusbarSections()); } @@ -132,9 +141,16 @@ protected static VoltageLevelTabInfos toTabInfos(Identifiable identifiable) { @Getter @Setter public static class VoltageLevelTopologyInfos { + List busbarSections = List.of(); boolean isRetrievedBusbarSections = false; + List switchKinds = List.of(); + } + + @Getter + @Setter + public static class BusbarSectionInfos { + private String busbarSectionId; int busbarCount = 1; int sectionCount = 1; - List switchKinds = List.of(); } } From 53787f0af55817a4ce6994b01c49cc06949a5778 Mon Sep 17 00:00:00 2001 From: Rehili Ghazwa Date: Thu, 31 Jul 2025 10:38:31 +0200 Subject: [PATCH 2/7] fix --- .../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 479cab39..2517928e 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 @@ -96,8 +96,8 @@ protected static VoltageLevelFormInfos toFormInfos(Identifiable identifiable) .map(bbsInfo -> { return BusBarSectionFormInfos.builder() .id(bbsInfo.getBusbarSectionId()) - .horizPos(bbsInfo.getBusbarCount()) - .vertPos(bbsInfo.getSectionCount()) + .horizPos(bbsInfo.getSectionCount()) + .vertPos(bbsInfo.getBusbarCount()) .build(); }) .toList()); From 79604cdeca5157a0fa44e8b02b487757e468f699 Mon Sep 17 00:00:00 2001 From: Rehili Ghazwa Date: Mon, 4 Aug 2025 08:53:35 +0200 Subject: [PATCH 3/7] add busBarSectionInfos --- .../voltagelevel/VoltageLevelFormInfos.java | 10 ++- .../dto/mapper/VoltageLevelInfosMapper.java | 64 ++++++++++--------- 2 files changed, 43 insertions(+), 31 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 6b40116e..f7d98c24 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 @@ -12,10 +12,10 @@ import lombok.Getter; import lombok.experimental.SuperBuilder; import org.gridsuite.network.map.dto.ElementInfosWithProperties; -import org.gridsuite.network.map.dto.definition.busbarsection.BusBarSectionFormInfos; import org.gridsuite.network.map.dto.definition.extension.IdentifiableShortCircuitInfos; import java.util.List; +import java.util.Map; import java.util.Optional; /** @@ -42,6 +42,12 @@ public class VoltageLevelFormInfos extends ElementInfosWithProperties { @JsonInclude(JsonInclude.Include.NON_ABSENT) private Optional identifiableShortCircuit; + @JsonInclude(JsonInclude.Include.NON_NULL) + private Integer busbarCount; + + @JsonInclude(JsonInclude.Include.NON_NULL) + private Integer sectionCount; + @JsonInclude(JsonInclude.Include.NON_NULL) private List switchKinds; @@ -49,6 +55,6 @@ public class VoltageLevelFormInfos extends ElementInfosWithProperties { private Boolean isRetrievedBusbarSections; @JsonInclude(JsonInclude.Include.NON_NULL) - List busBarSectionInfos; + 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 2517928e..9036b166 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 @@ -19,6 +19,7 @@ import org.gridsuite.network.map.dto.utils.ElementUtils; import java.util.*; +import java.util.stream.Collectors; import static org.gridsuite.network.map.dto.utils.ElementUtils.*; @@ -46,33 +47,37 @@ public static ElementInfos toData(Identifiable identifiable, InfoTypeParamete public static VoltageLevelTopologyInfos getTopologyInfos(VoltageLevel voltageLevel) { VoltageLevelTopologyInfos topologyInfos = new VoltageLevelTopologyInfos(); - List busbarSectionInfos = new ArrayList<>(); Map nbSectionsPerBusbar = new HashMap<>(); - + List busbarSectionInfos = new ArrayList<>(); for (BusbarSection bbs : voltageLevel.getNodeBreakerView().getBusbarSections()) { var extension = bbs.getExtension(BusbarSectionPosition.class); - BusbarSectionInfos busbarSectionInfo = new BusbarSectionInfos(); if (extension != null) { - busbarSectionInfo.setBusbarSectionId(bbs.getId()); - if (extension.getBusbarIndex() > busbarSectionInfo.busbarCount) { - busbarSectionInfo.setBusbarCount(extension.getBusbarIndex()); + if (extension.getBusbarIndex() > topologyInfos.getBusbarCount()) { + topologyInfos.setBusbarCount(extension.getBusbarIndex()); } - if (extension.getSectionIndex() > busbarSectionInfo.sectionCount) { - busbarSectionInfo.setSectionCount(extension.getSectionIndex()); + if (extension.getSectionIndex() > topologyInfos.getSectionCount()) { + topologyInfos.setSectionCount(extension.getSectionIndex()); } - busbarSectionInfos.add(busbarSectionInfo); nbSectionsPerBusbar.putIfAbsent(extension.getBusbarIndex(), 1); if (extension.getSectionIndex() > nbSectionsPerBusbar.get(extension.getBusbarIndex())) { nbSectionsPerBusbar.put(extension.getBusbarIndex(), extension.getSectionIndex()); } - } else if (nbSectionsPerBusbar.values().stream().anyMatch(v -> v != busbarSectionInfo.sectionCount)) { // Non-symmetrical busbars (nb sections) - return new VoltageLevelTopologyInfos(); + BusBarSectionFormInfos busbarSectionInfo = BusBarSectionFormInfos.builder() + .id(bbs.getId()) + .vertPos(topologyInfos.getSectionCount()) + .horizPos(topologyInfos.getBusbarCount()) + .build(); + busbarSectionInfos.add(busbarSectionInfo); } else { return new VoltageLevelTopologyInfos(); } - topologyInfos.setSwitchKinds(Collections.nCopies(busbarSectionInfo.getSectionCount() - 1, SwitchKind.DISCONNECTOR)); } + if (nbSectionsPerBusbar.values().stream().anyMatch(v -> v != topologyInfos.sectionCount)) { // Non-symmetrical busbars (nb sections) + return new VoltageLevelTopologyInfos(); + } + topologyInfos.setRetrievedBusbarSections(true); + topologyInfos.setSwitchKinds(Collections.nCopies(topologyInfos.getSectionCount() - 1, SwitchKind.DISCONNECTOR)); topologyInfos.setBusbarSections(busbarSectionInfos); return topologyInfos; @@ -92,17 +97,11 @@ protected static VoltageLevelFormInfos toFormInfos(Identifiable identifiable) if (voltageLevel.getTopologyKind().equals(TopologyKind.NODE_BREAKER)) { VoltageLevelTopologyInfos vlTopologyInfos = getTopologyInfos(voltageLevel); - builder.busBarSectionInfos((List) vlTopologyInfos.getBusbarSections().stream() - .map(bbsInfo -> { - return BusBarSectionFormInfos.builder() - .id(bbsInfo.getBusbarSectionId()) - .horizPos(bbsInfo.getSectionCount()) - .vertPos(bbsInfo.getBusbarCount()) - .build(); - }) - .toList()); + builder.busbarCount(vlTopologyInfos.getBusbarCount()); + builder.sectionCount(vlTopologyInfos.getSectionCount()); builder.switchKinds(vlTopologyInfos.getSwitchKinds()); builder.isRetrievedBusbarSections(vlTopologyInfos.isRetrievedBusbarSections()); + builder.busBarSectionInfos(vlTopologyInfos.getBusBarSectionInfosGrouped()); } builder.identifiableShortCircuit(toIdentifiableShortCircuit(voltageLevel)); @@ -141,16 +140,23 @@ protected static VoltageLevelTabInfos toTabInfos(Identifiable identifiable) { @Getter @Setter public static class VoltageLevelTopologyInfos { - List busbarSections = List.of(); + List busbarSections = List.of(); boolean isRetrievedBusbarSections = false; - List switchKinds = List.of(); - } - - @Getter - @Setter - public static class BusbarSectionInfos { - private String busbarSectionId; int busbarCount = 1; int sectionCount = 1; + List switchKinds = List.of(); + + public Map>> getBusBarSectionInfosGrouped() { + return busbarSections.stream() + .collect(Collectors.groupingBy( + section -> "horizPos:" + section.getHorizPos(), + Collectors.mapping(section -> { + Map map = new HashMap<>(); + map.put("id", section.getId()); + map.put("vertPos", section.getVertPos()); + return map; + }, Collectors.toList()) + )); + } } } From 01dadd38b1334c9194974ac36737df9ff020cba5 Mon Sep 17 00:00:00 2001 From: Rehili Ghazwa Date: Mon, 4 Aug 2025 16:02:00 +0200 Subject: [PATCH 4/7] update test --- src/test/resources/substations-form-data.json | 11 +++++++++-- src/test/resources/voltage-level-form-data.json | 8 +++++++- src/test/resources/voltage-levels-form-data.json | 11 +++++++++-- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/test/resources/substations-form-data.json b/src/test/resources/substations-form-data.json index 5ad4f8ee..99e1878f 100644 --- a/src/test/resources/substations-form-data.json +++ b/src/test/resources/substations-form-data.json @@ -103,7 +103,13 @@ "switchKinds": [ "DISCONNECTOR" ], - "isRetrievedBusbarSections": true + "isRetrievedBusbarSections": true, + "busBarSectionInfos" : { + "horizPos:1" : [ { + "vertPos" : 2, + "id" : "NGEN4" + } ] + } } ] }, @@ -125,7 +131,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..31b00c72 100644 --- a/src/test/resources/voltage-level-form-data.json +++ b/src/test/resources/voltage-level-form-data.json @@ -6,5 +6,11 @@ "busbarCount": 1, "sectionCount": 2, "switchKinds": ["DISCONNECTOR"], - "isRetrievedBusbarSections": true + "isRetrievedBusbarSections": true, + "busBarSectionInfos" : { + "horizPos:1" : [ { + "vertPos" : 2, + "id" : "NGEN4" + } ] + } } diff --git a/src/test/resources/voltage-levels-form-data.json b/src/test/resources/voltage-levels-form-data.json index c6bf9925..ecc564f8 100644 --- a/src/test/resources/voltage-levels-form-data.json +++ b/src/test/resources/voltage-levels-form-data.json @@ -62,7 +62,13 @@ "busbarCount": 1, "sectionCount": 2, "switchKinds": ["DISCONNECTOR"], - "isRetrievedBusbarSections": true + "isRetrievedBusbarSections": true, + "busBarSectionInfos" : { + "horizPos:1" : [ { + "vertPos" : 2, + "id" : "NGEN4" + } ] + } }, { "id": "VLGEN5", @@ -78,7 +84,8 @@ "busbarCount": 1, "sectionCount": 1, "switchKinds": [], - "isRetrievedBusbarSections": false + "isRetrievedBusbarSections": false, + "busBarSectionInfos" : { } }, { "id": "VLGEN6", From 013884a3025d7ddf82780843e053ae5c69c2443c Mon Sep 17 00:00:00 2001 From: Rehili Ghazwa Date: Tue, 5 Aug 2025 18:06:25 +0200 Subject: [PATCH 5/7] fix Non-symmetrical busbars case --- .../map/dto/mapper/VoltageLevelInfosMapper.java | 12 ++++++++++-- 1 file changed, 10 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 9036b166..047df385 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 @@ -69,11 +69,11 @@ public static VoltageLevelTopologyInfos getTopologyInfos(VoltageLevel voltageLev .build(); busbarSectionInfos.add(busbarSectionInfo); } else { - return new VoltageLevelTopologyInfos(); + return new VoltageLevelTopologyInfos(busbarSectionInfos); } } if (nbSectionsPerBusbar.values().stream().anyMatch(v -> v != topologyInfos.sectionCount)) { // Non-symmetrical busbars (nb sections) - return new VoltageLevelTopologyInfos(); + return new VoltageLevelTopologyInfos(busbarSectionInfos); } topologyInfos.setRetrievedBusbarSections(true); @@ -146,6 +146,14 @@ public static class VoltageLevelTopologyInfos { int sectionCount = 1; List switchKinds = List.of(); + public VoltageLevelTopologyInfos() { + // Default constructor for empty topology + } + + public VoltageLevelTopologyInfos(List busbarSectionInfos) { + this.busbarSections = busbarSectionInfos; + } + public Map>> getBusBarSectionInfosGrouped() { return busbarSections.stream() .collect(Collectors.groupingBy( From 9111885668daef02935e8908a510539d54e63461 Mon Sep 17 00:00:00 2001 From: Rehili Ghazwa Date: Tue, 12 Aug 2025 20:58:46 +0200 Subject: [PATCH 6/7] fix --- .../map/dto/mapper/VoltageLevelInfosMapper.java | 16 ++++------------ 1 file changed, 4 insertions(+), 12 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 047df385..f707c63c 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 @@ -64,16 +64,16 @@ public static VoltageLevelTopologyInfos getTopologyInfos(VoltageLevel voltageLev } BusBarSectionFormInfos busbarSectionInfo = BusBarSectionFormInfos.builder() .id(bbs.getId()) - .vertPos(topologyInfos.getSectionCount()) - .horizPos(topologyInfos.getBusbarCount()) + .vertPos(extension.getSectionIndex()) + .horizPos(extension.getBusbarIndex()) .build(); busbarSectionInfos.add(busbarSectionInfo); } else { - return new VoltageLevelTopologyInfos(busbarSectionInfos); + return new VoltageLevelTopologyInfos(); } } if (nbSectionsPerBusbar.values().stream().anyMatch(v -> v != topologyInfos.sectionCount)) { // Non-symmetrical busbars (nb sections) - return new VoltageLevelTopologyInfos(busbarSectionInfos); + return new VoltageLevelTopologyInfos(); } topologyInfos.setRetrievedBusbarSections(true); @@ -146,14 +146,6 @@ public static class VoltageLevelTopologyInfos { int sectionCount = 1; List switchKinds = List.of(); - public VoltageLevelTopologyInfos() { - // Default constructor for empty topology - } - - public VoltageLevelTopologyInfos(List busbarSectionInfos) { - this.busbarSections = busbarSectionInfos; - } - public Map>> getBusBarSectionInfosGrouped() { return busbarSections.stream() .collect(Collectors.groupingBy( From 4a8398a22447bde61f8fa32e11434a59c79e53eb Mon Sep 17 00:00:00 2001 From: Rehili Ghazwa Date: Thu, 14 Aug 2025 07:58:55 +0200 Subject: [PATCH 7/7] remove vertPos and horizPos --- .../voltagelevel/VoltageLevelFormInfos.java | 2 +- .../map/dto/mapper/VoltageLevelInfosMapper.java | 17 +++++++++-------- src/test/resources/substations-form-data.json | 5 +---- src/test/resources/voltage-level-form-data.json | 5 +---- .../resources/voltage-levels-form-data.json | 5 +---- 5 files changed, 13 insertions(+), 21 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 f7d98c24..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 @@ -55,6 +55,6 @@ public class VoltageLevelFormInfos extends ElementInfosWithProperties { private Boolean isRetrievedBusbarSections; @JsonInclude(JsonInclude.Include.NON_NULL) - Map>> busBarSectionInfos; + 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 f707c63c..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 @@ -146,16 +146,17 @@ public static class VoltageLevelTopologyInfos { int sectionCount = 1; List switchKinds = List.of(); - public Map>> getBusBarSectionInfosGrouped() { + public Map> getBusBarSectionInfosGrouped() { return busbarSections.stream() .collect(Collectors.groupingBy( - section -> "horizPos:" + section.getHorizPos(), - Collectors.mapping(section -> { - Map map = new HashMap<>(); - map.put("id", section.getId()); - map.put("vertPos", section.getVertPos()); - return map; - }, Collectors.toList()) + 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 99e1878f..19cb44f6 100644 --- a/src/test/resources/substations-form-data.json +++ b/src/test/resources/substations-form-data.json @@ -105,10 +105,7 @@ ], "isRetrievedBusbarSections": true, "busBarSectionInfos" : { - "horizPos:1" : [ { - "vertPos" : 2, - "id" : "NGEN4" - } ] + "1" : ["NGEN4"] } } ] diff --git a/src/test/resources/voltage-level-form-data.json b/src/test/resources/voltage-level-form-data.json index 31b00c72..7cb2e6dd 100644 --- a/src/test/resources/voltage-level-form-data.json +++ b/src/test/resources/voltage-level-form-data.json @@ -8,9 +8,6 @@ "switchKinds": ["DISCONNECTOR"], "isRetrievedBusbarSections": true, "busBarSectionInfos" : { - "horizPos:1" : [ { - "vertPos" : 2, - "id" : "NGEN4" - } ] + "1" : [ "NGEN4"] } } diff --git a/src/test/resources/voltage-levels-form-data.json b/src/test/resources/voltage-levels-form-data.json index ecc564f8..a557f050 100644 --- a/src/test/resources/voltage-levels-form-data.json +++ b/src/test/resources/voltage-levels-form-data.json @@ -64,10 +64,7 @@ "switchKinds": ["DISCONNECTOR"], "isRetrievedBusbarSections": true, "busBarSectionInfos" : { - "horizPos:1" : [ { - "vertPos" : 2, - "id" : "NGEN4" - } ] + "1" : [ "NGEN4" ] } }, {