Skip to content

Commit 7819704

Browse files
author
LE SAULNIER Kevin
committed
fix: PR remarks
Signed-off-by: LE SAULNIER Kevin <[email protected]>
1 parent 2cd3ce6 commit 7819704

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/main/java/org/gridsuite/securityanalysis/server/entities/AbstractLimitViolationEntity.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import lombok.experimental.FieldNameConstants;
1818
import lombok.experimental.SuperBuilder;
1919

20+
import java.util.Collection;
2021
import java.util.Iterator;
2122
import java.util.Optional;
2223
import java.util.UUID;
@@ -84,7 +85,7 @@ protected static Double getPatlLimit(LimitViolation limitViolation, Network netw
8485
return null;
8586
}
8687

87-
Optional<CurrentLimits> currentLimits = limitViolationSide.name().equals(TwoSides.ONE.name()) ? branch.getCurrentLimits1() : branch.getCurrentLimits2();
88+
Optional<CurrentLimits> currentLimits = branch.getCurrentLimits(limitViolationSide.toTwoSides());
8889
if (currentLimits.isPresent()) {
8990
return currentLimits.get().getPermanentLimit();
9091
}
@@ -109,16 +110,17 @@ private static LoadingLimits.TemporaryLimit getNextTemporaryLimit(Branch<?> bran
109110
return null;
110111
}
111112

112-
Optional<CurrentLimits> currentLimits = limitViolationSide.name().equals(TwoSides.ONE.name()) ? branch.getCurrentLimits1() : branch.getCurrentLimits2();
113+
Optional<CurrentLimits> currentLimits = branch.getCurrentLimits(limitViolationSide.toTwoSides());
113114
if (currentLimits.isEmpty()) {
114115
return null;
115116
}
116117

118+
Collection<LoadingLimits.TemporaryLimit> temporaryLimits = currentLimits.get().getTemporaryLimits();
117119
if (limitName.equals(LimitViolationUtils.PERMANENT_LIMIT_NAME)) {
118-
return currentLimits.get().getTemporaryLimits().stream().findFirst().orElse(null);
120+
return temporaryLimits.stream().findFirst().orElse(null);
119121
}
120122

121-
Iterator<LoadingLimits.TemporaryLimit> temporaryLimitIterator = currentLimits.get().getTemporaryLimits().iterator();
123+
Iterator<LoadingLimits.TemporaryLimit> temporaryLimitIterator = temporaryLimits.iterator();
122124
while (temporaryLimitIterator.hasNext()) {
123125
LoadingLimits.TemporaryLimit currentTemporaryLimit = temporaryLimitIterator.next();
124126
if (currentTemporaryLimit.getName().equals(limitViolation.getLimitName())) {

src/test/java/org/gridsuite/securityanalysis/server/ContingencyLimitViolationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright (c) 2023, RTE (http://www.rte-france.com)
2+
* Copyright (c) 2025, RTE (http://www.rte-france.com)
33
* This Source Code Form is subject to the terms of the Mozilla Public
44
* License, v. 2.0. If a copy of the MPL was not distributed with this
55
* file, You can obtain one at http://mozilla.org/MPL/2.0/.

0 commit comments

Comments
 (0)