Skip to content

Commit 97a779b

Browse files
authored
ignore non existant feederBays for move modification (#143)
Signed-off-by: Etienne LESOT <[email protected]>
1 parent c64d453 commit 97a779b

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

src/main/java/org/gridsuite/modification/modifications/MoveVoltageLevelFeederBays.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
package org.gridsuite.modification.modifications;
88

99
import com.powsybl.commons.report.ReportNode;
10+
import com.powsybl.commons.report.TypedValue;
1011
import com.powsybl.iidm.network.*;
1112
import com.powsybl.iidm.network.extensions.ConnectablePosition;
1213
import com.powsybl.iidm.network.extensions.ConnectablePositionAdder;
@@ -24,7 +25,6 @@
2425
*/
2526
public class MoveVoltageLevelFeederBays extends AbstractModification {
2627
private static final String VOLTAGE_LEVEL_NOT_FOUND = "Voltage level %s is not found";
27-
private static final String CONNECTABLE_NOT_FOUND = "Connectable %s not found";
2828
private static final String BUSBAR_NOT_FOUND = "Bus or busbar section %s where connectable %s is supposed to be is not found in voltage level %s";
2929
private static final String UNSUPPORTED_CONNECTABLE = "MoveVoltageLevelFeederBays is not implemented for %s";
3030
private static final String INVALID_CONNECTION_SIDE = "Invalid connection side: %s for branch %s";
@@ -64,9 +64,6 @@ private void checkBusOrBusbarSectionExist(VoltageLevel voltageLevel, MoveFeederB
6464

6565
private void checkConnectable(Network network, MoveFeederBayInfos info) {
6666
Connectable<?> connectable = network.getConnectable(info.getEquipmentId());
67-
if (connectable == null) {
68-
throw new NetworkModificationException(MOVE_VOLTAGE_LEVEL_FEEDER_BAYS_ERROR, String.format(CONNECTABLE_NOT_FOUND, info.getEquipmentId()));
69-
}
7067
if (connectable instanceof BusbarSection || connectable instanceof ThreeWindingsTransformer) {
7168
throw new NetworkModificationException(MOVE_VOLTAGE_LEVEL_FEEDER_BAYS_ERROR, String.format(UNSUPPORTED_CONNECTABLE, connectable.getClass()));
7269
}
@@ -76,7 +73,15 @@ private void checkConnectable(Network network, MoveFeederBayInfos info) {
7673
public void apply(Network network, ReportNode subReportNode) {
7774
for (MoveFeederBayInfos info : modificationInfos.getFeederBays()) {
7875
Connectable<?> connectable = network.getConnectable(info.getEquipmentId());
79-
modifyConnectablePosition(network, connectable, info, subReportNode);
76+
if (connectable != null) {
77+
modifyConnectablePosition(network, connectable, info, subReportNode);
78+
} else {
79+
subReportNode.newReportNode()
80+
.withMessageTemplate("network.modification.moveFeederBaysConnectableNotFoundWarning")
81+
.withUntypedValue("id", info.getEquipmentId())
82+
.withSeverity(TypedValue.WARN_SEVERITY)
83+
.add();
84+
}
8085
}
8186
}
8287

src/main/resources/org/gridsuite/modification/reports.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,3 +345,4 @@ network.modification.operationalLimitsGroup.creation = Creation of ${operational
345345
network.modification.operationalLimitsGroupPropertyValueNotFoundError = Cannot modify equipment ${id} : missing limit set applicable on side ${side} with property named ${propertyName} and with value ${propertyValue} : equipment ignored
346346
network.modification.operationalLimitsGroupPropertyValueMultipleError = Cannot modify equipment ${id} : multiple limit sets applicable on side ${side} with property named ${propertyName} and with value ${propertyValue} : equipment ignored
347347
network.modification.missingFiltersInGenerationDispatch = The modification points to at least ${nb} filter${isPlural} that does not exist anymore
348+
network.modification.moveFeederBaysConnectableNotFoundWarning = When moving feeder bays, the equipment with id ${id} was not found and has been ignored.

src/test/java/org/gridsuite/modification/modifications/MoveVoltageLevelFeederBaysTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,7 @@ private void testConnectableNotFound(Network network) {
150150
.feederBays(moveFeederBayInfos)
151151
.build();
152152
MoveVoltageLevelFeederBays moveVoltageLevelFeederBays = (MoveVoltageLevelFeederBays) moveVoltageLevelFeederBaysInfos.toModification();
153-
String message = assertThrows(NetworkModificationException.class, () -> moveVoltageLevelFeederBays.check(network)).getMessage();
154-
assertEquals("MOVE_VOLTAGE_LEVEL_FEEDER_BAYS_ERROR : Connectable notFound not found", message);
153+
assertDoesNotThrow(() -> moveVoltageLevelFeederBays.check(network));
155154
}
156155

157156
private void testConnectableNotInjectionOrBranch(Network network) {

0 commit comments

Comments
 (0)