@@ -85,79 +85,31 @@ public static Optional<HvdcOperatorActivePowerRangeInfos> toHvdcOperatorActivePo
85
85
.oprFromCS2toCS1 (hvdcOperatorActivePowerRange .getOprFromCS2toCS1 ()).build ());
86
86
}
87
87
88
- public static void buildCurrentLimits (Collection <OperationalLimitsGroup > currentLimits , String oldSelected , String newSelected , Consumer <List <CurrentLimitsData >> build ) {
88
+ public static void buildCurrentLimits (Collection <OperationalLimitsGroup > currentLimits , Consumer <List <CurrentLimitsData >> build ) {
89
89
90
90
ArrayList <CurrentLimitsData > currentLimitsData = new ArrayList <>(currentLimits .stream ()
91
91
.map (ElementUtils ::operationalLimitsGroupToMapDataCurrentLimits )
92
92
.toList ());
93
93
94
- // if selected operationalLimitsGroups renamed, rename it also here
95
- if (!newSelected .isEmpty ()) {
96
- Optional <CurrentLimitsData > limitsGroup = currentLimitsData .stream ().filter (l -> l .getId ().equals (oldSelected )).findFirst ();
97
- if (limitsGroup .isPresent ()) {
98
- CurrentLimitsData current = copyCurrentLimitsData (limitsGroup .get (), newSelected );
99
- currentLimitsData .remove (limitsGroup .get ());
100
- currentLimitsData .add (current );
101
- }
102
- }
103
-
104
94
if (!currentLimitsData .isEmpty ()) {
105
95
build .accept (currentLimitsData );
106
96
}
107
97
}
108
98
109
- private static String generateSetName (String basicName , String suffix , List <CurrentLimitsData > mergedList , List <CurrentLimitsData > otherList ) {
110
-
111
- boolean nameUsed ;
112
- String strIncrement = "" ;
113
- int increment = 1 ;
114
-
115
- do {
116
- String currentId = basicName + suffix + strIncrement ;
117
- if (!mergedList .stream ().filter (l -> l .getId ().equals (currentId )).toList ().isEmpty ()
118
- || !otherList .stream ().filter (l -> l .getId ().equals (currentId )).toList ().isEmpty ()) {
119
- nameUsed = true ;
120
- increment ++;
121
- strIncrement = "(" + increment + ")" ;
122
- } else {
123
- nameUsed = false ;
124
- }
125
- } while (nameUsed );
126
-
127
- return basicName + suffix + strIncrement ;
128
- }
129
-
130
- private static CurrentLimitsData copyCurrentLimitsData (CurrentLimitsData currentLimitsData , CurrentLimitsData .Applicability applicability , String id ) {
131
- return CurrentLimitsData .builder ()
132
- .id (id .isEmpty () ? currentLimitsData .getId () : id )
133
- .applicability (applicability )
134
- .temporaryLimits (currentLimitsData .getTemporaryLimits ())
135
- .permanentLimit (currentLimitsData .getPermanentLimit ()).build ();
136
- }
137
-
138
99
private static CurrentLimitsData copyCurrentLimitsData (CurrentLimitsData currentLimitsData , CurrentLimitsData .Applicability applicability ) {
139
- return copyCurrentLimitsData (currentLimitsData , applicability , "" );
140
- }
141
-
142
- private static CurrentLimitsData copyCurrentLimitsData (CurrentLimitsData currentLimitsData , String id ) {
143
100
return CurrentLimitsData .builder ()
144
- .id (id . isEmpty () ? currentLimitsData .getId () : id )
145
- .applicability (currentLimitsData . getApplicability () )
101
+ .id (currentLimitsData .getId ())
102
+ .applicability (applicability )
146
103
.temporaryLimits (currentLimitsData .getTemporaryLimits ())
147
104
.permanentLimit (currentLimitsData .getPermanentLimit ()).build ();
148
105
}
149
106
150
107
/**
151
108
* @return id of the selected operation limits group 1 and 2 if they have been renamed
152
109
*/
153
- public static Pair < String , String > mergeCurrentLimits (Collection <OperationalLimitsGroup > operationalLimitsGroups1 ,
110
+ public static void mergeCurrentLimits (Collection <OperationalLimitsGroup > operationalLimitsGroups1 ,
154
111
Collection <OperationalLimitsGroup > operationalLimitsGroups2 ,
155
- String selectedLimitsGroup1 , String selectedLimitsGroup2 ,
156
112
Consumer <List <CurrentLimitsData >> build ) {
157
- final String orSuffix = "_OR" ;
158
- final String exSuffix = "_EX" ;
159
- String changedSelectedLimitsGroup1 = "" ;
160
- String changedSelectedLimitsGroup2 = "" ;
161
113
List <CurrentLimitsData > mergedLimitsData = new ArrayList <>();
162
114
163
115
// Build temporary limit from side 1 and 2
@@ -174,13 +126,13 @@ public static Pair<String, String> mergeCurrentLimits(Collection<OperationalLimi
174
126
mergedLimitsData .add (copyCurrentLimitsData (currentLimitsData , SIDE1 ));
175
127
}
176
128
build .accept (mergedLimitsData );
177
- return Pair . of ( "" , "" ) ;
129
+ return ;
178
130
} else if (currentLimitsData1 .isEmpty () && !currentLimitsData2 .isEmpty ()) {
179
131
for (CurrentLimitsData currentLimitsData : currentLimitsData2 ) {
180
132
mergedLimitsData .add (copyCurrentLimitsData (currentLimitsData , SIDE2 ));
181
133
}
182
134
build .accept (mergedLimitsData );
183
- return Pair . of ( "" , "" ) ;
135
+ return ;
184
136
}
185
137
186
138
// more complex case
@@ -199,23 +151,12 @@ public static Pair<String, String> mergeCurrentLimits(Collection<OperationalLimi
199
151
// both sides have limits and limits are equals
200
152
if (limitsData .limitsEquals (limitsData2 )) {
201
153
mergedLimitsData .add (copyCurrentLimitsData (limitsData , EQUIPMENT ));
202
- // both side have limits and they are differents : create 2 differents limitset with basename_Or and _Ex
154
+ // both side have limits and they are different : create 2 different limit sets with basename_Or and _Ex
203
155
} else {
204
- String currentLimitId = limitsData .getId ();
205
156
// Side 1
206
- String limitId = generateSetName (currentLimitId , orSuffix , mergedLimitsData , currentLimitsData2 );
207
- mergedLimitsData .add (copyCurrentLimitsData (limitsData , SIDE1 , limitId ));
208
- // if name changed and is active limit set change also selected limit set
209
- if (selectedLimitsGroup1 .equals (currentLimitId )) {
210
- changedSelectedLimitsGroup1 = limitId ;
211
- }
157
+ mergedLimitsData .add (copyCurrentLimitsData (limitsData , SIDE1 ));
212
158
// Side 2
213
- limitId = generateSetName (currentLimitId , exSuffix , mergedLimitsData , currentLimitsData2 );
214
- mergedLimitsData .add (copyCurrentLimitsData (limitsData2 , SIDE2 , limitId ));
215
- // if name changed and is active limit set change also selected limit set
216
- if (selectedLimitsGroup2 .equals (currentLimitId )) {
217
- changedSelectedLimitsGroup2 = limitId ;
218
- }
159
+ mergedLimitsData .add (copyCurrentLimitsData (limitsData2 , SIDE2 ));
219
160
}
220
161
}
221
162
// remove processed limits from side 2
@@ -233,8 +174,6 @@ public static Pair<String, String> mergeCurrentLimits(Collection<OperationalLimi
233
174
if (!mergedLimitsData .isEmpty ()) {
234
175
build .accept (mergedLimitsData );
235
176
}
236
-
237
- return Pair .of (changedSelectedLimitsGroup1 , changedSelectedLimitsGroup2 );
238
177
}
239
178
240
179
public static Optional <StandbyAutomatonInfos > toStandbyAutomaton (StaticVarCompensator staticVarCompensator ) {
0 commit comments