From 42930a0a1d5fb82d4c1f625a6296746b96a0a55f Mon Sep 17 00:00:00 2001 From: Mathieu DEHARBE Date: Tue, 10 Sep 2024 11:43:55 +0200 Subject: [PATCH] use of attributesGetter Signed-off-by: Mathieu DEHARBE --- .../store/iidm/impl/TerminalBusBreakerViewImpl.java | 12 ++++-------- .../store/iidm/impl/TerminalNodeBreakerViewImpl.java | 11 ++++------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/TerminalBusBreakerViewImpl.java b/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/TerminalBusBreakerViewImpl.java index 28611dcf2..c29e41a76 100644 --- a/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/TerminalBusBreakerViewImpl.java +++ b/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/TerminalBusBreakerViewImpl.java @@ -146,15 +146,11 @@ public void moveConnectable(String busId, boolean connected) { throw new PowsyblException("Trying to move connectable " + attributes.getResource().getId() + " to bus " + busId + " of voltage level " + bus.getVoltageLevel().getId() + ", which is a node breaker voltage level"); } - //attributes.setConnectableBus(busId); - //attributes.setBus(connected ? busId : null); - //attributes.setVoltageLevelId(voltageLevel.getId()); - //index.updateResource(getAbstractIdentifiable().getResource(), null); getAbstractIdentifiable().updateResource(res -> { - attributes.setConnectableBus(busId); - attributes.setBus(connected ? busId : null); - attributes.setNode(null); - attributes.setVoltageLevelId(voltageLevel.getId()); + attributesGetter.apply(res).setConnectableBus(busId); + attributesGetter.apply(res).setBus(connected ? busId : null); + attributesGetter.apply(res).setNode(null); + attributesGetter.apply(res).setVoltageLevelId(voltageLevel.getId()); }); voltageLevel.invalidateCalculatedBuses(); } diff --git a/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/TerminalNodeBreakerViewImpl.java b/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/TerminalNodeBreakerViewImpl.java index b1fe59b4a..5c3bf31c9 100644 --- a/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/TerminalNodeBreakerViewImpl.java +++ b/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/TerminalNodeBreakerViewImpl.java @@ -70,14 +70,11 @@ public void moveConnectable(int node, String voltageLevelId) { throw new ValidationException(attributes.getResource(), "an equipment (" + terminal.getConnectable().getId() + ") is already connected to node " + node + " of voltage level " + voltageLevelId); } - //attributes.setNode(node); - //attributes.setVoltageLevelId(voltageLevelId); - //index.updateResource(getAbstractIdentifiable().getResource(), null); getAbstractIdentifiable().updateResource(res -> { - attributes.setConnectableBus(null); - attributes.setBus(null); - attributes.setNode(node); - attributes.setVoltageLevelId(voltageLevelId); + attributesGetter.apply(res).setConnectableBus(null); + attributesGetter.apply(res).setBus(null); + attributesGetter.apply(res).setNode(node); + attributesGetter.apply(res).setVoltageLevelId(voltageLevelId); }); voltageLevel.invalidateCalculatedBuses(); }