Skip to content

Commit 9f9bef0

Browse files
Always set the 'id' field in CurrentLimitsData dto (#291)
* Always set the 'id' field in CurrentLimitsData dto with the operational limits group id Signed-off-by: Franck LECUYER <[email protected]>
1 parent 40b2103 commit 9f9bef0

16 files changed

+211
-38
lines changed

src/main/java/org/gridsuite/network/map/dto/common/CurrentLimitsData.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
@EqualsAndHashCode
2525
@ToString
2626
public class CurrentLimitsData {
27-
// may be null in case we just need the selected limit set and don't really need its name/id
2827
@JsonInclude(JsonInclude.Include.NON_NULL)
2928
private String id;
3029

src/main/java/org/gridsuite/network/map/dto/mapper/BranchInfosMapper.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,13 @@ public static ElementInfos toData(@NonNull final Identifiable<?> identifiable,
7373
final Terminal terminal1 = branch.getTerminal1();
7474
final Terminal terminal2 = branch.getTerminal2();
7575

76-
branch.getSelectedOperationalLimitsGroup1()
77-
.flatMap(OperationalLimitsGroup::getCurrentLimits)
78-
.map(cl -> builder.selectedOperationalLimitsGroup1(toMapDataCurrentLimits(cl, null, null)));
79-
branch.getSelectedOperationalLimitsGroupId1().map(name -> builder.selectedOperationalLimitsGroup1Name(name));
80-
branch.getSelectedOperationalLimitsGroup2()
81-
.flatMap(OperationalLimitsGroup::getCurrentLimits)
82-
.map(cl -> builder.selectedOperationalLimitsGroup2(toMapDataCurrentLimits(cl, null, null)));
83-
branch.getSelectedOperationalLimitsGroupId2().map(name -> builder.selectedOperationalLimitsGroup2Name(name));
76+
branch.getSelectedOperationalLimitsGroup1().ifPresent(limitGrp ->
77+
limitGrp.getCurrentLimits().ifPresent(cl -> builder.selectedOperationalLimitsGroup1(toMapDataCurrentLimits(cl, limitGrp.getId(), null))));
78+
branch.getSelectedOperationalLimitsGroupId1().ifPresent(builder::selectedOperationalLimitsGroup1Name);
79+
80+
branch.getSelectedOperationalLimitsGroup2().ifPresent(limitGrp ->
81+
limitGrp.getCurrentLimits().ifPresent(cl -> builder.selectedOperationalLimitsGroup2(toMapDataCurrentLimits(cl, limitGrp.getId(), null))));
82+
branch.getSelectedOperationalLimitsGroupId2().ifPresent(builder::selectedOperationalLimitsGroup2Name);
8483

8584
if (loadOperationalLimitGroups) {
8685
final Map<String, CurrentLimitsData> mapOperationalLimitsGroup1 = buildCurrentLimitsMap(branch.getOperationalLimitsGroups1());
@@ -133,7 +132,7 @@ private static Map<String, CurrentLimitsData> buildCurrentLimitsMap(@NonNull fin
133132
}
134133
Map<String, CurrentLimitsData> res = HashMap.newHashMap(operationalLimitsGroups.size());
135134
operationalLimitsGroups.forEach(operationalLimitsGroup -> operationalLimitsGroup.getCurrentLimits()
136-
.ifPresent(limits -> res.put(operationalLimitsGroup.getId(), toMapDataCurrentLimits(limits, null, null))));
135+
.ifPresent(limits -> res.put(operationalLimitsGroup.getId(), toMapDataCurrentLimits(limits, operationalLimitsGroup.getId(), null))));
137136
return res;
138137
}
139138

src/main/java/org/gridsuite/network/map/dto/mapper/LineInfosMapper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ private static LineTooltipInfos toTooltipInfos(Identifiable<?> identifiable, Dou
162162
.b1(line.getB1())
163163
.b2(line.getB2());
164164

165-
line.getCurrentLimits1().ifPresent(limits1 -> builder.currentLimits1(toMapDataCurrentLimits(limits1, null, null)));
166-
line.getCurrentLimits2().ifPresent(limits2 -> builder.currentLimits2(toMapDataCurrentLimits(limits2, null, null)));
165+
line.getSelectedOperationalLimitsGroup1().ifPresent(limitsGrp -> limitsGrp.getCurrentLimits().ifPresent(limits -> builder.currentLimits1(toMapDataCurrentLimits(limits, limitsGrp.getId(), null))));
166+
line.getSelectedOperationalLimitsGroup2().ifPresent(limitsGrp -> limitsGrp.getCurrentLimits().ifPresent(limits -> builder.currentLimits2(toMapDataCurrentLimits(limits, limitsGrp.getId(), null))));
167167

168168
return builder.build();
169169
}

src/main/java/org/gridsuite/network/map/dto/mapper/TieLineInfosMapper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ private static TieLineMapInfos toMapInfos(Identifiable<?> identifiable, Double d
5858
.i2(nullIfNan(computeIntensity(terminal2, dcPowerFactor)))
5959
.operatingStatus(ExtensionUtils.toOperatingStatus(tieLine));
6060

61-
tieLine.getCurrentLimits1().ifPresent(limits1 -> builder.currentLimits1(toMapDataCurrentLimits(limits1, null, null)));
62-
tieLine.getCurrentLimits2().ifPresent(limits2 -> builder.currentLimits2(toMapDataCurrentLimits(limits2, null, null)));
61+
tieLine.getSelectedOperationalLimitsGroup1().ifPresent(limitsGrp -> limitsGrp.getCurrentLimits().ifPresent(limits -> builder.currentLimits1(toMapDataCurrentLimits(limits, limitsGrp.getId(), null))));
62+
tieLine.getSelectedOperationalLimitsGroup2().ifPresent(limitsGrp -> limitsGrp.getCurrentLimits().ifPresent(limits -> builder.currentLimits2(toMapDataCurrentLimits(limits, limitsGrp.getId(), null))));
6363

6464
return builder.build();
6565
}

src/main/java/org/gridsuite/network/map/dto/mapper/TwoWindingsTransformerInfosMapper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ private static TwoWindingsTransformerTooltipInfos toTooltipInfos(Identifiable<?>
165165
.x(twoWindingsTransformer.getX())
166166
.b(twoWindingsTransformer.getB());
167167

168-
twoWindingsTransformer.getCurrentLimits1().ifPresent(limits1 -> builder.currentLimits1(toMapDataCurrentLimits(limits1, null, null)));
169-
twoWindingsTransformer.getCurrentLimits2().ifPresent(limits2 -> builder.currentLimits2(toMapDataCurrentLimits(limits2, null, null)));
168+
twoWindingsTransformer.getSelectedOperationalLimitsGroup1().ifPresent(limitsGrp -> limitsGrp.getCurrentLimits().ifPresent(limits -> builder.currentLimits1(toMapDataCurrentLimits(limits, limitsGrp.getId(), null))));
169+
twoWindingsTransformer.getSelectedOperationalLimitsGroup2().ifPresent(limitsGrp -> limitsGrp.getCurrentLimits().ifPresent(limits -> builder.currentLimits2(toMapDataCurrentLimits(limits, limitsGrp.getId(), null))));
170170

171171
return builder.build();
172172
}

src/test/resources/2-windings-transformer-tooltip-data.json

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,35 @@
33
"voltageLevelId1": "VLGEN",
44
"voltageLevelId2": "VLHV1",
55
"currentLimits1": {
6+
"id": "limit set 1",
67
"permanentLimit": 750.4,
78
"temporaryLimits": [
8-
{ "name": "IT5", "value": 300.0, "acceptableDuration": 2087 }
9+
{
10+
"name": "IT5",
11+
"value": 300.0,
12+
"acceptableDuration": 2087
13+
}
914
],
1015
"applicability": null
1116
},
1217
"currentLimits2": {
18+
"id": "limit set 1",
1319
"permanentLimit": 780.6,
1420
"temporaryLimits": [
15-
{ "name": "IT20", "value": 1200.0, "acceptableDuration": 961 },
16-
{ "name": "N/A", "value": 2.147483647e9, "acceptableDuration": 664 }
21+
{
22+
"name": "IT20",
23+
"value": 1200.0,
24+
"acceptableDuration": 961
25+
},
26+
{
27+
"name": "N/A",
28+
"value": 2.147483647E9,
29+
"acceptableDuration": 664
30+
}
1731
],
1832
"applicability": null
1933
},
2034
"r": 0.26658461538461536,
2135
"x": 11.104492831516762,
2236
"b": 0.0
23-
}
37+
}

src/test/resources/2-windings-transformers-tab-data-without-optionals.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"r": 0.26658461538461536,
2121
"x": 11.104492831516762,
2222
"selectedOperationalLimitsGroup1": {
23+
"id": "limit set 1",
2324
"permanentLimit": 750.4,
2425
"temporaryLimits": [
2526
{
@@ -32,6 +33,7 @@
3233
},
3334
"selectedOperationalLimitsGroup1Name": "limit set 1",
3435
"selectedOperationalLimitsGroup2": {
36+
"id": "limit set 1",
3537
"permanentLimit": 780.6,
3638
"temporaryLimits": [
3739
{
@@ -194,6 +196,7 @@
194196
"r": 47.0,
195197
"x": 23.0,
196198
"selectedOperationalLimitsGroup1": {
199+
"id": "DEFAULT",
197200
"permanentLimit": 300.4,
198201
"temporaryLimits": [
199202
{
@@ -206,6 +209,7 @@
206209
},
207210
"selectedOperationalLimitsGroup1Name": "DEFAULT",
208211
"selectedOperationalLimitsGroup2": {
212+
"id": "DEFAULT",
209213
"permanentLimit": 280.6,
210214
"temporaryLimits": [
211215
{

src/test/resources/2-windings-transformers-tab-data.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"x": 11.104492831516762,
2222
"operationalLimitsGroup1": {
2323
"limit set 1": {
24+
"id": "limit set 1",
2425
"permanentLimit": 750.4,
2526
"temporaryLimits": [
2627
{
@@ -36,6 +37,7 @@
3637
"limit set 1"
3738
],
3839
"selectedOperationalLimitsGroup1": {
40+
"id": "limit set 1",
3941
"permanentLimit": 750.4,
4042
"temporaryLimits": [
4143
{
@@ -49,6 +51,7 @@
4951
"selectedOperationalLimitsGroup1Name": "limit set 1",
5052
"operationalLimitsGroup2": {
5153
"limit set 1": {
54+
"id": "limit set 1",
5255
"permanentLimit": 780.6,
5356
"temporaryLimits": [
5457
{
@@ -69,6 +72,7 @@
6972
"limit set 1"
7073
],
7174
"selectedOperationalLimitsGroup2": {
75+
"id": "limit set 1",
7276
"permanentLimit": 780.6,
7377
"temporaryLimits": [
7478
{
@@ -232,6 +236,7 @@
232236
"x": 23.0,
233237
"operationalLimitsGroup1": {
234238
"DEFAULT": {
239+
"id": "DEFAULT",
235240
"permanentLimit": 300.4,
236241
"temporaryLimits": [
237242
{
@@ -247,6 +252,7 @@
247252
"DEFAULT"
248253
],
249254
"selectedOperationalLimitsGroup1": {
255+
"id": "DEFAULT",
250256
"permanentLimit": 300.4,
251257
"temporaryLimits": [
252258
{
@@ -260,6 +266,7 @@
260266
"selectedOperationalLimitsGroup1Name": "DEFAULT",
261267
"operationalLimitsGroup2": {
262268
"DEFAULT": {
269+
"id": "DEFAULT",
263270
"permanentLimit": 280.6,
264271
"temporaryLimits": [
265272
{
@@ -275,6 +282,7 @@
275282
"DEFAULT"
276283
],
277284
"selectedOperationalLimitsGroup2": {
285+
"id": "DEFAULT",
278286
"permanentLimit": 280.6,
279287
"temporaryLimits": [
280288
{

0 commit comments

Comments
 (0)