12
12
import lombok .Setter ;
13
13
import org .gridsuite .network .map .dto .ElementInfos ;
14
14
import org .gridsuite .network .map .dto .InfoTypeParameters ;
15
+ import org .gridsuite .network .map .dto .definition .busbarsection .BusBarSectionFormInfos ;
15
16
import org .gridsuite .network .map .dto .definition .voltagelevel .VoltageLevelFormInfos ;
16
17
import org .gridsuite .network .map .dto .definition .voltagelevel .VoltageLevelMapInfos ;
17
18
import org .gridsuite .network .map .dto .definition .voltagelevel .VoltageLevelTabInfos ;
18
19
import org .gridsuite .network .map .dto .utils .ElementUtils ;
19
20
20
- import java .util .Collections ;
21
- import java .util .HashMap ;
22
- import java .util .List ;
23
- import java .util .Map ;
21
+ import java .util .*;
22
+ import java .util .stream .Collectors ;
24
23
25
24
import static org .gridsuite .network .map .dto .utils .ElementUtils .*;
26
25
@@ -49,6 +48,7 @@ public static ElementInfos toData(Identifiable<?> identifiable, InfoTypeParamete
49
48
public static VoltageLevelTopologyInfos getTopologyInfos (VoltageLevel voltageLevel ) {
50
49
VoltageLevelTopologyInfos topologyInfos = new VoltageLevelTopologyInfos ();
51
50
Map <Integer , Integer > nbSectionsPerBusbar = new HashMap <>();
51
+ List <BusBarSectionFormInfos > busbarSectionInfos = new ArrayList <>();
52
52
for (BusbarSection bbs : voltageLevel .getNodeBreakerView ().getBusbarSections ()) {
53
53
var extension = bbs .getExtension (BusbarSectionPosition .class );
54
54
if (extension != null ) {
@@ -62,6 +62,12 @@ public static VoltageLevelTopologyInfos getTopologyInfos(VoltageLevel voltageLev
62
62
if (extension .getSectionIndex () > nbSectionsPerBusbar .get (extension .getBusbarIndex ())) {
63
63
nbSectionsPerBusbar .put (extension .getBusbarIndex (), extension .getSectionIndex ());
64
64
}
65
+ BusBarSectionFormInfos busbarSectionInfo = BusBarSectionFormInfos .builder ()
66
+ .id (bbs .getId ())
67
+ .vertPos (extension .getSectionIndex ())
68
+ .horizPos (extension .getBusbarIndex ())
69
+ .build ();
70
+ busbarSectionInfos .add (busbarSectionInfo );
65
71
} else {
66
72
return new VoltageLevelTopologyInfos ();
67
73
}
@@ -72,6 +78,7 @@ public static VoltageLevelTopologyInfos getTopologyInfos(VoltageLevel voltageLev
72
78
73
79
topologyInfos .setRetrievedBusbarSections (true );
74
80
topologyInfos .setSwitchKinds (Collections .nCopies (topologyInfos .getSectionCount () - 1 , SwitchKind .DISCONNECTOR ));
81
+ topologyInfos .setBusbarSections (busbarSectionInfos );
75
82
76
83
return topologyInfos ;
77
84
}
@@ -94,6 +101,7 @@ protected static VoltageLevelFormInfos toFormInfos(Identifiable<?> identifiable)
94
101
builder .sectionCount (vlTopologyInfos .getSectionCount ());
95
102
builder .switchKinds (vlTopologyInfos .getSwitchKinds ());
96
103
builder .isRetrievedBusbarSections (vlTopologyInfos .isRetrievedBusbarSections ());
104
+ builder .busBarSectionInfos (vlTopologyInfos .getBusBarSectionInfosGrouped ());
97
105
}
98
106
99
107
builder .identifiableShortCircuit (toIdentifiableShortCircuit (voltageLevel ));
@@ -132,9 +140,24 @@ protected static VoltageLevelTabInfos toTabInfos(Identifiable<?> identifiable) {
132
140
@ Getter
133
141
@ Setter
134
142
public static class VoltageLevelTopologyInfos {
143
+ List <BusBarSectionFormInfos > busbarSections = List .of ();
135
144
boolean isRetrievedBusbarSections = false ;
136
145
int busbarCount = 1 ;
137
146
int sectionCount = 1 ;
138
147
List <SwitchKind > switchKinds = List .of ();
148
+
149
+ public Map <String , List <String >> getBusBarSectionInfosGrouped () {
150
+ return busbarSections .stream ()
151
+ .collect (Collectors .groupingBy (
152
+ section -> String .valueOf (section .getHorizPos ()),
153
+ Collectors .collectingAndThen (
154
+ Collectors .toList (),
155
+ list -> list .stream ()
156
+ .sorted (Comparator .comparing (BusBarSectionFormInfos ::getVertPos ))
157
+ .map (BusBarSectionFormInfos ::getId )
158
+ .toList ()
159
+ )
160
+ ));
161
+ }
139
162
}
140
163
}
0 commit comments