From e8ac836724922f96d49993d23e87a23af3e052c1 Mon Sep 17 00:00:00 2001 From: Sophie Frasnedo <93923177+So-Fras@users.noreply.github.com> Date: Tue, 12 Dec 2023 13:08:37 +0100 Subject: [PATCH] Bump core 610 (#569) * Bump to powsybl-core 6.1.0 * Remove joda-time library * Change artifact name from xml-converter to serde * BranchStatus renamed OperatingStatus * TwoSides and ThreeSides used instead of Branch.Side and ThreeWindingsTransformer.Side * Remove remaining ThreeWindingsTransformer.Side * Deal with change of package name xml -> serde * Replace readUntilEndElement function (that does not exist anymore) by readSubElements (1 test failing) * Update reading metadata following XmlUtil changes * Fix unit test * Rename methods to clarify use * Fix comparing to have the diff in the logs * Fix checkstyle * Following review comments: use ThreeSides functions to refactor code * Fix code smell regarding lambda / method reference * Revert "Fix comparing to have the diff in the logs" (This reverts commit 35551ec9f32e6052a4a92179f161d913f4ba9612.) * Revert "Fix checkstyle" (This reverts commit 67a07d96d1d413104998963c0f10c5cb64ad1075.) * Improve getNextSideNum(...) function --------- Signed-off-by: Sophie Frasnedo Co-authored-by: Florian Dupuy --- .../com/powsybl/diagram/test/Networks.java | 56 +++++++++---------- .../nad/build/iidm/NetworkGraphBuilder.java | 47 ++++++---------- .../nad/build/iidm/VoltageLevelFilter.java | 24 ++++---- .../nad/svg/metadata/BusNodeMetadata.java | 13 ++++- .../nad/svg/metadata/DiagramMetadata.java | 40 ++++++------- .../nad/svg/metadata/EdgeMetadata.java | 16 +++++- .../nad/svg/metadata/NodeMetadata.java | 16 +++++- .../com/powsybl/nad/utils/iidm/IidmUtils.java | 28 +++++----- .../powsybl/nad/svg/DiagramMetadataTest.java | 42 +++++++------- .../nad/svg/NominalVoltageStyleTest.java | 4 +- .../nad/svg/ThreeWindingTransformerTest.java | 6 +- pom.xml | 2 +- .../sld/cgmes/layout/CgmesZoneLayoutTest.java | 23 ++++---- .../LayoutToCgmesDlExporterToolTest.java | 2 +- .../layout/LayoutToCgmesExtensionsTest.java | 15 +++-- .../single-line-diagram-core/pom.xml | 2 +- .../sld/builders/NetworkGraphBuilder.java | 28 +++++----- .../powsybl/sld/svg/DefaultLabelProvider.java | 16 +++--- .../iidm/HighlightLineStateStyleProvider.java | 14 ++--- .../sld/SingleLineDiagramToolTest.java | 2 +- .../TestDisconnectedComponentsBusBreaker.java | 10 ++-- .../com/powsybl/sld/iidm/TestSVGWriter.java | 10 ++-- .../com/powsybl/sld/model/ZoneGraphTest.java | 8 +-- 23 files changed, 220 insertions(+), 204 deletions(-) diff --git a/diagram-test/src/main/java/com/powsybl/diagram/test/Networks.java b/diagram-test/src/main/java/com/powsybl/diagram/test/Networks.java index f41650a4f..35cd92ff5 100644 --- a/diagram-test/src/main/java/com/powsybl/diagram/test/Networks.java +++ b/diagram-test/src/main/java/com/powsybl/diagram/test/Networks.java @@ -9,8 +9,8 @@ import com.powsybl.commons.extensions.Extendable; import com.powsybl.iidm.network.*; import com.powsybl.iidm.network.extensions.*; -import org.joda.time.DateTime; +import java.time.ZonedDateTime; import java.util.Optional; /** @@ -65,7 +65,7 @@ private Networks() { public static Network createNetworkWithBusbar() { Network network = Network.create(NETWORK_ID, "test"); - network.setCaseDate(DateTime.parse(CASE_DATE)); + network.setCaseDate(ZonedDateTime.parse(CASE_DATE)); Substation substation = network.newSubstation() .setId(SUBSTATION_ID) .setCountry(Country.FR) @@ -84,7 +84,7 @@ public static Network createNetworkWithBusbar() { public static Network createNetworkWithBus() { Network network = Network.create(NETWORK_ID, "test"); - network.setCaseDate(DateTime.parse(CASE_DATE)); + network.setCaseDate(ZonedDateTime.parse(CASE_DATE)); Substation substation = network.newSubstation() .setId(SUBSTATION_ID) .setCountry(Country.FR) @@ -102,7 +102,7 @@ public static Network createNetworkWithBus() { public static Network createNetworkWithGenerator() { Network network = Network.create("test", "test"); - network.setCaseDate(DateTime.parse(CASE_DATE)); + network.setCaseDate(ZonedDateTime.parse(CASE_DATE)); Substation substation = network.newSubstation() .setId(SUBSTATION_ID) .setCountry(Country.FR) @@ -130,7 +130,7 @@ public static Network createNetworkWithGenerator() { public static Network createNetworkWithLine() { Network network = Network.create(NETWORK_ID, "test"); - network.setCaseDate(DateTime.parse(CASE_DATE)); + network.setCaseDate(ZonedDateTime.parse(CASE_DATE)); Substation substation1 = network.newSubstation() .setId(SUBSTATION_1_ID) .setCountry(Country.FR) @@ -175,7 +175,7 @@ public static Network createNetworkWithLine() { public static Network createNetworkWithLoad() { Network network = Network.create("test", "test"); - network.setCaseDate(DateTime.parse(CASE_DATE)); + network.setCaseDate(ZonedDateTime.parse(CASE_DATE)); Substation substation = network.newSubstation() .setId(SUBSTATION_ID) .setCountry(Country.FR) @@ -200,7 +200,7 @@ public static Network createNetworkWithLoad() { public static Network createNetworkWithShuntCompensator() { Network network = Network.create("test", "test"); - network.setCaseDate(DateTime.parse(CASE_DATE)); + network.setCaseDate(ZonedDateTime.parse(CASE_DATE)); Substation substation = network.newSubstation() .setId(SUBSTATION_ID) .setCountry(Country.FR) @@ -228,7 +228,7 @@ public static Network createNetworkWithShuntCompensator() { public static Network createNetworkWithStaticVarCompensator() { Network network = Network.create("test", "test"); - network.setCaseDate(DateTime.parse(CASE_DATE)); + network.setCaseDate(ZonedDateTime.parse(CASE_DATE)); Substation substation = network.newSubstation() .setId(SUBSTATION_ID) .setCountry(Country.FR) @@ -256,7 +256,7 @@ public static Network createNetworkWithStaticVarCompensator() { public static Network createNetworkWithSwitch() { Network network = Network.create(NETWORK_ID, "test"); - network.setCaseDate(DateTime.parse(CASE_DATE)); + network.setCaseDate(ZonedDateTime.parse(CASE_DATE)); Substation substation = network.newSubstation() .setId(SUBSTATION_ID) .setCountry(Country.FR) @@ -283,7 +283,7 @@ public static Network createNetworkWithSwitch() { public static Network createNetworkWithThreeWindingsTransformer() { Network network = Network.create(NETWORK_ID, "test"); - network.setCaseDate(DateTime.parse(CASE_DATE)); + network.setCaseDate(ZonedDateTime.parse(CASE_DATE)); Substation substation = network.newSubstation() .setId(SUBSTATION_ID) .setCountry(Country.FR) @@ -343,7 +343,7 @@ public static Network createNetworkWithThreeWindingsTransformer() { public static Network createNetworkWithTwoWindingsTransformer() { Network network = Network.create(NETWORK_ID, "test"); - network.setCaseDate(DateTime.parse(CASE_DATE)); + network.setCaseDate(ZonedDateTime.parse(CASE_DATE)); Substation substation = network.newSubstation() .setId(SUBSTATION_ID) .setCountry(Country.FR) @@ -385,7 +385,7 @@ public static Network createNetworkWithTwoWindingsTransformer() { public static Network createNetworkWithDanglingLine() { Network network = Network.create(NETWORK_ID, "test"); - network.setCaseDate(DateTime.parse(CASE_DATE)); + network.setCaseDate(ZonedDateTime.parse(CASE_DATE)); Substation substation = network.newSubstation() .setId(SUBSTATION_ID) .setCountry(Country.FR) @@ -417,7 +417,7 @@ public static Network createNetworkWithHvdcLine() { public static Network createNetworkWithHvdcLine(String vsc1Id, String vsc2Id) { Network network = Network.create(NETWORK_ID, "test"); - network.setCaseDate(DateTime.parse(CASE_DATE)); + network.setCaseDate(ZonedDateTime.parse(CASE_DATE)); Substation substation1 = network.newSubstation() .setId(SUBSTATION_1_ID) .setCountry(Country.FR) @@ -519,7 +519,7 @@ public static Network createNetworkWithHvdcLines() { public static Network createNetworkWithBusbarAndSwitch() { Network network = Network.create(NETWORK_ID, "test"); - network.setCaseDate(DateTime.parse(CASE_DATE)); + network.setCaseDate(ZonedDateTime.parse(CASE_DATE)); Substation s = network.newSubstation() .setId("S") .setCountry(Country.FR) @@ -647,7 +647,7 @@ public static Network createNetworkWithPhaseShiftTransformer() { public static Network createNetworkWithBridge() { Network network = NetworkFactory.findDefault().createNetwork(NETWORK_ID, "test"); - network.setCaseDate(DateTime.parse("2020-01-01T00:30:00.000+01:00")); + network.setCaseDate(ZonedDateTime.parse("2020-01-01T00:30:00.000+01:00")); Substation substation = network.newSubstation() .setId("S") @@ -1197,13 +1197,13 @@ public static Network createBusBreakerNetworkWithBranchStatus(String id, String } private static void createStatusExtensions(Network network) { - network.getLine("L11").newExtension(BranchStatusAdder.class).withStatus(BranchStatus.Status.PLANNED_OUTAGE).add(); - network.getLine("L12").newExtension(BranchStatusAdder.class).withStatus(BranchStatus.Status.FORCED_OUTAGE).add(); + network.getLine("L11").newExtension(OperatingStatusAdder.class).withStatus(OperatingStatus.Status.PLANNED_OUTAGE).add(); + network.getLine("L12").newExtension(OperatingStatusAdder.class).withStatus(OperatingStatus.Status.FORCED_OUTAGE).add(); - network.getTwoWindingsTransformer("T11").newExtension(BranchStatusAdder.class).withStatus(BranchStatus.Status.PLANNED_OUTAGE).add(); - network.getTwoWindingsTransformer("T12").newExtension(BranchStatusAdder.class).withStatus(BranchStatus.Status.FORCED_OUTAGE).add(); + network.getTwoWindingsTransformer("T11").newExtension(OperatingStatusAdder.class).withStatus(OperatingStatus.Status.PLANNED_OUTAGE).add(); + network.getTwoWindingsTransformer("T12").newExtension(OperatingStatusAdder.class).withStatus(OperatingStatus.Status.FORCED_OUTAGE).add(); - network.getThreeWindingsTransformer(THREE_WINDING_TRANSFORMER_12_ID).newExtension(BranchStatusAdder.class).withStatus(BranchStatus.Status.FORCED_OUTAGE).add(); + network.getThreeWindingsTransformer(THREE_WINDING_TRANSFORMER_12_ID).newExtension(OperatingStatusAdder.class).withStatus(OperatingStatus.Status.FORCED_OUTAGE).add(); } public static Network createNodeBreakerNetworkWithInternalBranches(String id, String sourceFormat) { @@ -1272,10 +1272,10 @@ public static Network createNodeBreakerNetworkWithInternalBranches(String id, St "T11", null, ConnectablePosition.Direction.TOP); TwoWindingsTransformer twoWindingsTransformer = network.getTwoWindingsTransformer("T11"); - twoWindingsTransformer.getTerminal(Branch.Side.ONE).setP(375); - twoWindingsTransformer.getTerminal(Branch.Side.TWO).setP(375); - twoWindingsTransformer.getTerminal(Branch.Side.ONE).setQ(48); - twoWindingsTransformer.getTerminal(Branch.Side.TWO).setQ(48); + twoWindingsTransformer.getTerminal(TwoSides.ONE).setP(375); + twoWindingsTransformer.getTerminal(TwoSides.TWO).setP(375); + twoWindingsTransformer.getTerminal(TwoSides.ONE).setQ(48); + twoWindingsTransformer.getTerminal(TwoSides.TWO).setQ(48); createSwitch(vl1, "D27", "D27", SwitchKind.DISCONNECTOR, false, false, false, 20, 27); createSwitch(vl1, "BR28", "BR28", SwitchKind.BREAKER, false, false, false, 27, 28); @@ -1289,10 +1289,10 @@ public static Network createNodeBreakerNetworkWithInternalBranches(String id, St "T12", null, ConnectablePosition.Direction.TOP); twoWindingsTransformer = network.getTwoWindingsTransformer("T12"); - twoWindingsTransformer.getTerminal(Branch.Side.ONE).setP(375); - twoWindingsTransformer.getTerminal(Branch.Side.TWO).setP(375); - twoWindingsTransformer.getTerminal(Branch.Side.ONE).setQ(48); - twoWindingsTransformer.getTerminal(Branch.Side.TWO).setQ(48); + twoWindingsTransformer.getTerminal(TwoSides.ONE).setP(375); + twoWindingsTransformer.getTerminal(TwoSides.TWO).setP(375); + twoWindingsTransformer.getTerminal(TwoSides.ONE).setQ(48); + twoWindingsTransformer.getTerminal(TwoSides.TWO).setQ(48); createSwitch(vl1, "D19", "D19", SwitchKind.DISCONNECTOR, false, false, false, 10, 19); createSwitch(vl1, "BR20", "BR20", SwitchKind.BREAKER, false, false, false, 19, 190); diff --git a/network-area-diagram/src/main/java/com/powsybl/nad/build/iidm/NetworkGraphBuilder.java b/network-area-diagram/src/main/java/com/powsybl/nad/build/iidm/NetworkGraphBuilder.java index 58359a1aa..866802e34 100644 --- a/network-area-diagram/src/main/java/com/powsybl/nad/build/iidm/NetworkGraphBuilder.java +++ b/network-area-diagram/src/main/java/com/powsybl/nad/build/iidm/NetworkGraphBuilder.java @@ -13,6 +13,7 @@ import com.powsybl.nad.model.*; import com.powsybl.nad.utils.iidm.IidmUtils; +import java.util.Arrays; import java.util.Comparator; import java.util.List; import java.util.Objects; @@ -99,16 +100,12 @@ private void visitThreeWindingsTransformer(VoltageLevel vl, ThreeWindingsTransfo ThreeWtNode tn = new ThreeWtNode(idProvider.createId(thwt), thwt.getId(), thwt.getNameOrId()); graph.addNode(tn); - ThreeWindingsTransformer.Side side; - if (thwt.getLeg1().getTerminal().getVoltageLevel() == vl) { - side = ThreeWindingsTransformer.Side.ONE; - } else if (thwt.getLeg2().getTerminal().getVoltageLevel() == vl) { - side = ThreeWindingsTransformer.Side.TWO; - } else { - side = ThreeWindingsTransformer.Side.THREE; - } + ThreeSides side = Arrays.stream(ThreeSides.values()) + .filter(streamedSide -> thwt.getLeg(streamedSide).getTerminal().getVoltageLevel() == vl) + .findFirst() + .orElseThrow(IllegalStateException::new); - for (ThreeWindingsTransformer.Side s : getSidesArray(side)) { + for (ThreeSides s : getSidesArray(side)) { addThreeWtEdge(graph, thwt, tn, s); } } @@ -136,17 +133,17 @@ private void visitHvdcConverterStation(HvdcConverterStation converterStation, return; } - HvdcLine.Side otherSide = (hvdcLine.getConverterStation1().getId().equals(converterStation.getId())) - ? HvdcLine.Side.TWO : HvdcLine.Side.ONE; + TwoSides otherSide = (hvdcLine.getConverterStation1().getId().equals(converterStation.getId())) + ? TwoSides.TWO : TwoSides.ONE; Terminal terminal = converterStation.getTerminal(); Terminal otherSideTerminal = hvdcLine.getConverterStation(otherSide).getTerminal(); - addEdge(graph, terminal, otherSideTerminal, hvdcLine, BranchEdge.HVDC_LINE_EDGE, otherSide == HvdcLine.Side.ONE); + addEdge(graph, terminal, otherSideTerminal, hvdcLine, BranchEdge.HVDC_LINE_EDGE, otherSide == TwoSides.ONE); } private void addEdge(Graph graph, Branch branch, VoltageLevel vl, String edgeType) { - Branch.Side side = branch.getTerminal(Branch.Side.ONE).getVoltageLevel() == vl ? Branch.Side.ONE : Branch.Side.TWO; + TwoSides side = branch.getTerminal(TwoSides.ONE).getVoltageLevel() == vl ? TwoSides.ONE : TwoSides.TWO; // check if the edge was not already added (at the other side of the transformer) if (graph.containsEdge(branch.getId())) { return; @@ -155,7 +152,7 @@ private void addEdge(Graph graph, Branch branch, VoltageLevel vl, String edge Terminal terminalA = branch.getTerminal(side); Terminal terminalB = branch.getTerminal(IidmUtils.getOpposite(side)); - addEdge(graph, terminalA, terminalB, branch, edgeType, side == Branch.Side.TWO); + addEdge(graph, terminalA, terminalB, branch, edgeType, side == TwoSides.TWO); } private void addEdge(Graph graph, Terminal terminalA, Terminal terminalB, Identifiable identifiable, String edgeType, boolean terminalsInReversedOrder) { @@ -173,7 +170,7 @@ private void addEdge(Graph graph, Terminal terminalA, Terminal terminalB, Identi } } - private void addThreeWtEdge(Graph graph, ThreeWindingsTransformer twt, ThreeWtNode tn, ThreeWindingsTransformer.Side side) { + private void addThreeWtEdge(Graph graph, ThreeWindingsTransformer twt, ThreeWtNode tn, ThreeSides side) { Terminal terminal = twt.getTerminal(side); VoltageLevelNode vlNode = getVoltageLevelNode(graph, terminal); ThreeWtEdge edge = new ThreeWtEdge(idProvider.createId(IidmUtils.get3wtLeg(twt, side)), @@ -203,19 +200,11 @@ private VoltageLevelNode getVoltageLevelNode(Graph graph, Terminal terminal) { .orElseThrow(() -> new PowsyblException("Cannot add edge, corresponding voltage level is unknown: '" + terminal.getVoltageLevel().getId() + "'")); } - private ThreeWindingsTransformer.Side[] getSidesArray(ThreeWindingsTransformer.Side sideA) { - ThreeWindingsTransformer.Side sideB; - ThreeWindingsTransformer.Side sideC; - if (sideA == ThreeWindingsTransformer.Side.ONE) { - sideB = ThreeWindingsTransformer.Side.TWO; - sideC = ThreeWindingsTransformer.Side.THREE; - } else if (sideA == ThreeWindingsTransformer.Side.TWO) { - sideB = ThreeWindingsTransformer.Side.ONE; - sideC = ThreeWindingsTransformer.Side.THREE; - } else { - sideB = ThreeWindingsTransformer.Side.ONE; - sideC = ThreeWindingsTransformer.Side.TWO; - } - return new ThreeWindingsTransformer.Side[] {sideA, sideB, sideC}; + private ThreeSides[] getSidesArray(ThreeSides sideA) { + return new ThreeSides[] {sideA, ThreeSides.valueOf(getNextSideNum(sideA.getNum(), 1)), ThreeSides.valueOf(getNextSideNum(sideA.getNum(), 2))}; + } + + private int getNextSideNum(int sideNum, int steps) { + return (sideNum + steps + 2) % 3 + 1; } } diff --git a/network-area-diagram/src/main/java/com/powsybl/nad/build/iidm/VoltageLevelFilter.java b/network-area-diagram/src/main/java/com/powsybl/nad/build/iidm/VoltageLevelFilter.java index 66d24b108..6743e134e 100644 --- a/network-area-diagram/src/main/java/com/powsybl/nad/build/iidm/VoltageLevelFilter.java +++ b/network-area-diagram/src/main/java/com/powsybl/nad/build/iidm/VoltageLevelFilter.java @@ -138,26 +138,26 @@ public VlVisitor(Set nextDepthVoltageLevels, Set vis } @Override - public void visitLine(Line line, Branch.Side side) { + public void visitLine(Line line, TwoSides side) { visitBranch(line, side); } @Override - public void visitTwoWindingsTransformer(TwoWindingsTransformer twt, Branch.Side side) { + public void visitTwoWindingsTransformer(TwoWindingsTransformer twt, TwoSides side) { visitBranch(twt, side); } @Override - public void visitThreeWindingsTransformer(ThreeWindingsTransformer twt, ThreeWindingsTransformer.Side side) { - if (side == ThreeWindingsTransformer.Side.ONE) { - visitTerminal(twt.getTerminal(ThreeWindingsTransformer.Side.TWO)); - visitTerminal(twt.getTerminal(ThreeWindingsTransformer.Side.THREE)); - } else if (side == ThreeWindingsTransformer.Side.TWO) { - visitTerminal(twt.getTerminal(ThreeWindingsTransformer.Side.ONE)); - visitTerminal(twt.getTerminal(ThreeWindingsTransformer.Side.THREE)); + public void visitThreeWindingsTransformer(ThreeWindingsTransformer twt, ThreeSides side) { + if (side == ThreeSides.ONE) { + visitTerminal(twt.getTerminal(ThreeSides.TWO)); + visitTerminal(twt.getTerminal(ThreeSides.THREE)); + } else if (side == ThreeSides.TWO) { + visitTerminal(twt.getTerminal(ThreeSides.ONE)); + visitTerminal(twt.getTerminal(ThreeSides.THREE)); } else { - visitTerminal(twt.getTerminal(ThreeWindingsTransformer.Side.ONE)); - visitTerminal(twt.getTerminal(ThreeWindingsTransformer.Side.TWO)); + visitTerminal(twt.getTerminal(ThreeSides.ONE)); + visitTerminal(twt.getTerminal(ThreeSides.TWO)); } } @@ -166,7 +166,7 @@ public void visitHvdcConverterStation(HvdcConverterStation converterStation) converterStation.getOtherConverterStation().ifPresent(c -> visitTerminal(c.getTerminal())); } - private void visitBranch(Branch branch, Branch.Side side) { + private void visitBranch(Branch branch, TwoSides side) { visitTerminal(branch.getTerminal(IidmUtils.getOpposite(side))); } diff --git a/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/BusNodeMetadata.java b/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/BusNodeMetadata.java index 7a25a426e..92f4655bc 100644 --- a/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/BusNodeMetadata.java +++ b/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/BusNodeMetadata.java @@ -6,6 +6,10 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +import com.powsybl.commons.exceptions.UncheckedXmlStreamException; +import com.powsybl.commons.xml.XmlUtil; + +import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; /** @@ -32,7 +36,14 @@ public String getElementName() { } public BusNodeMetadata read(XMLStreamReader reader) { - return new BusNodeMetadata(readDiagramId(reader), readEquipmentId(reader)); + try { + String diagramId = readDiagramId(reader); + String equipmentId = readEquipmentId(reader); + XmlUtil.readEndElementOrThrow(reader); + return new BusNodeMetadata(diagramId, equipmentId); + } catch (XMLStreamException e) { + throw new UncheckedXmlStreamException(e); + } } } } diff --git a/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/DiagramMetadata.java b/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/DiagramMetadata.java index 5b90fb96a..c2b6a3176 100644 --- a/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/DiagramMetadata.java +++ b/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/DiagramMetadata.java @@ -7,6 +7,7 @@ */ package com.powsybl.nad.svg.metadata; +import com.powsybl.commons.PowsyblException; import com.powsybl.commons.xml.XmlUtil; import javax.xml.stream.XMLInputFactory; @@ -35,39 +36,32 @@ public class DiagramMetadata { private final List nodesMetadata = new ArrayList<>(); private final List edgesMetadata = new ArrayList<>(); - public static DiagramMetadata readXml(InputStream inputStream) throws XMLStreamException { - return readXml(XMLInputFactory.newDefaultFactory().createXMLStreamReader(inputStream)); + public static DiagramMetadata readFromSvg(InputStream inputStream) throws XMLStreamException { + return readFromSvg(XMLInputFactory.newDefaultFactory().createXMLStreamReader(inputStream)); } - public static DiagramMetadata readXml(XMLStreamReader reader) throws XMLStreamException { + public static DiagramMetadata readFromSvg(XMLStreamReader reader) throws XMLStreamException { DiagramMetadata metadata = new DiagramMetadata(); - XmlUtil.readUntilEndElement(METADATA_DIAGRAM_ELEMENT_NAME, reader, () -> { - String token = reader.getLocalName(); - switch (token) { - case METADATA_BUS_NODES_ELEMENT_NAME: - readCollection(metadata.busNodesMetadata, METADATA_BUS_NODES_ELEMENT_NAME, new BusNodeMetadata.Reader(), reader); - break; - case METADATA_NODES_ELEMENT_NAME: - readCollection(metadata.nodesMetadata, METADATA_NODES_ELEMENT_NAME, new NodeMetadata.Reader(), reader); - break; - case METADATA_EDGES_ELEMENT_NAME: - readCollection(metadata.edgesMetadata, METADATA_EDGES_ELEMENT_NAME, new EdgeMetadata.Reader(), reader); - break; - default: - // Not managed - } - }); + XmlUtil.readUntilStartElement("/svg/metadata/nad", reader, metadataToken -> + XmlUtil.readSubElements(reader, token -> { + switch (token) { + case METADATA_BUS_NODES_ELEMENT_NAME -> readCollection(metadata.busNodesMetadata, new BusNodeMetadata.Reader(), reader); + case METADATA_NODES_ELEMENT_NAME -> readCollection(metadata.nodesMetadata, new NodeMetadata.Reader(), reader); + case METADATA_EDGES_ELEMENT_NAME -> readCollection(metadata.edgesMetadata, new EdgeMetadata.Reader(), reader); + default -> throw new PowsyblException("Unexpected element '" + token + "' in metadata"); + } + }) + ); return metadata; } private static > void readCollection( Collection items, - String collectionElementName, R itemReader, - XMLStreamReader reader) throws XMLStreamException { - XmlUtil.readUntilEndElement(collectionElementName, reader, () -> { - if (reader.getLocalName().equals(itemReader.getElementName())) { + XMLStreamReader reader) { + XmlUtil.readSubElements(reader, token -> { + if (token.equals(itemReader.getElementName())) { items.add(itemReader.read(reader)); } }); diff --git a/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/EdgeMetadata.java b/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/EdgeMetadata.java index ee3a15990..eff75f7b3 100644 --- a/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/EdgeMetadata.java +++ b/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/EdgeMetadata.java @@ -7,6 +7,9 @@ */ package com.powsybl.nad.svg.metadata; +import com.powsybl.commons.exceptions.UncheckedXmlStreamException; +import com.powsybl.commons.xml.XmlUtil; + import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; import javax.xml.stream.XMLStreamWriter; @@ -48,9 +51,16 @@ public String getElementName() { } public EdgeMetadata read(XMLStreamReader reader) { - return new EdgeMetadata(readDiagramId(reader), readEquipmentId(reader), - reader.getAttributeValue(null, NODE1_ATTRIBUTE), - reader.getAttributeValue(null, NODE2_ATTRIBUTE)); + try { + String svgId = readDiagramId(reader); + String equipmentId = readEquipmentId(reader); + String node1 = reader.getAttributeValue(null, NODE1_ATTRIBUTE); + String node2 = reader.getAttributeValue(null, NODE2_ATTRIBUTE); + XmlUtil.readEndElementOrThrow(reader); + return new EdgeMetadata(svgId, equipmentId, node1, node2); + } catch (XMLStreamException e) { + throw new UncheckedXmlStreamException(e); + } } } } diff --git a/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/NodeMetadata.java b/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/NodeMetadata.java index 9a510ef5b..167de08b8 100644 --- a/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/NodeMetadata.java +++ b/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/NodeMetadata.java @@ -7,6 +7,9 @@ */ package com.powsybl.nad.svg.metadata; +import com.powsybl.commons.exceptions.UncheckedXmlStreamException; +import com.powsybl.commons.xml.XmlUtil; + import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; import javax.xml.stream.XMLStreamWriter; @@ -54,9 +57,16 @@ public String getElementName() { } public NodeMetadata read(XMLStreamReader reader) { - return new NodeMetadata(readDiagramId(reader), readEquipmentId(reader), - reader.getAttributeValue(null, POSITION_X_ATTRIBUTE), - reader.getAttributeValue(null, POSITION_Y_ATTRIBUTE)); + try { + String diagramId = readDiagramId(reader); + String equipmentId = readEquipmentId(reader); + String positionX = reader.getAttributeValue(null, POSITION_X_ATTRIBUTE); + String positionY = reader.getAttributeValue(null, POSITION_Y_ATTRIBUTE); + XmlUtil.readEndElementOrThrow(reader); + return new NodeMetadata(diagramId, equipmentId, positionX, positionY); + } catch (XMLStreamException e) { + throw new UncheckedXmlStreamException(e); + } } } } diff --git a/network-area-diagram/src/main/java/com/powsybl/nad/utils/iidm/IidmUtils.java b/network-area-diagram/src/main/java/com/powsybl/nad/utils/iidm/IidmUtils.java index e3900dc62..a2da59a3d 100644 --- a/network-area-diagram/src/main/java/com/powsybl/nad/utils/iidm/IidmUtils.java +++ b/network-area-diagram/src/main/java/com/powsybl/nad/utils/iidm/IidmUtils.java @@ -47,41 +47,41 @@ public static Terminal getTerminalFromEdge(Network network, BranchEdge edge, Bra } } - public static ThreeWindingsTransformer.Leg get3wtLeg(ThreeWindingsTransformer twt, ThreeWindingsTransformer.Side side) { - if (side == ThreeWindingsTransformer.Side.ONE) { + public static ThreeWindingsTransformer.Leg get3wtLeg(ThreeWindingsTransformer twt, ThreeSides side) { + if (side == ThreeSides.ONE) { return twt.getLeg1(); - } else if (side == ThreeWindingsTransformer.Side.TWO) { + } else if (side == ThreeSides.TWO) { return twt.getLeg2(); } else { return twt.getLeg3(); } } - public static Branch.Side getOpposite(Branch.Side side) { - return side == Branch.Side.ONE ? Branch.Side.TWO : Branch.Side.ONE; + public static TwoSides getOpposite(TwoSides side) { + return side == TwoSides.ONE ? TwoSides.TWO : TwoSides.ONE; } - public static Branch.Side getIidmSideFromBranchEdgeSide(BranchEdge.Side side) { - return Objects.requireNonNull(side) == BranchEdge.Side.ONE ? Branch.Side.ONE : Branch.Side.TWO; + public static TwoSides getIidmSideFromBranchEdgeSide(BranchEdge.Side side) { + return Objects.requireNonNull(side) == BranchEdge.Side.ONE ? TwoSides.ONE : TwoSides.TWO; } - public static HvdcLine.Side getIidmHvdcSideFromBranchEdgeSide(BranchEdge.Side side) { - return Objects.requireNonNull(side) == BranchEdge.Side.ONE ? HvdcLine.Side.ONE : HvdcLine.Side.TWO; + public static TwoSides getIidmHvdcSideFromBranchEdgeSide(BranchEdge.Side side) { + return Objects.requireNonNull(side) == BranchEdge.Side.ONE ? TwoSides.ONE : TwoSides.TWO; } - public static ThreeWindingsTransformer.Side getIidmSideFromThreeWtEdgeSide(ThreeWtEdge.Side side) { + public static ThreeSides getIidmSideFromThreeWtEdgeSide(ThreeWtEdge.Side side) { switch (Objects.requireNonNull(side)) { case ONE: - return ThreeWindingsTransformer.Side.ONE; + return ThreeSides.ONE; case TWO: - return ThreeWindingsTransformer.Side.TWO; + return ThreeSides.TWO; case THREE: - return ThreeWindingsTransformer.Side.THREE; + return ThreeSides.THREE; } return null; } - public static ThreeWtEdge.Side getThreeWtEdgeSideFromIidmSide(ThreeWindingsTransformer.Side side) { + public static ThreeWtEdge.Side getThreeWtEdgeSideFromIidmSide(ThreeSides side) { switch (Objects.requireNonNull(side)) { case ONE: return ThreeWtEdge.Side.ONE; diff --git a/network-area-diagram/src/test/java/com/powsybl/nad/svg/DiagramMetadataTest.java b/network-area-diagram/src/test/java/com/powsybl/nad/svg/DiagramMetadataTest.java index 655664fc9..799f4f1c1 100644 --- a/network-area-diagram/src/test/java/com/powsybl/nad/svg/DiagramMetadataTest.java +++ b/network-area-diagram/src/test/java/com/powsybl/nad/svg/DiagramMetadataTest.java @@ -75,7 +75,7 @@ void test() throws XMLStreamException { String reference = "/hvdc.svg"; InputStream in = Objects.requireNonNull(getClass().getResourceAsStream(reference)); // Create Metadata from svg file - DiagramMetadata metadata = DiagramMetadata.readXml(in); + DiagramMetadata metadata = DiagramMetadata.readFromSvg(in); // Write Metadata as temporary xml file Path outPath = tmpDir.resolve("metadata.xml"); writeMetadata(metadata, outPath); @@ -93,19 +93,22 @@ void test() throws XMLStreamException { @Test void testInvalid() throws XMLStreamException { // Referenced svg file - String reference = "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " "; + String reference = """ + + + + + + + + + + + + """; InputStream in = new ByteArrayInputStream(reference.getBytes(StandardCharsets.UTF_8)); // Create Metadata from svg file - DiagramMetadata metadata = DiagramMetadata.readXml(in); + DiagramMetadata metadata = DiagramMetadata.readFromSvg(in); // Write Metadata as temporary xml file Path outPath = tmpDir.resolve("metadataInvalid.xml"); writeMetadata(metadata, outPath); @@ -114,13 +117,14 @@ void testInvalid() throws XMLStreamException { // remove xml header (first line) actual = actual.substring(actual.indexOf(METADATA_START_TOKEN)); // Keep only metadata from svg file - String expected = "\n" + - " " + - " \n" + - " \n" + - " \n" + - " " + - " "; + String expected = """ + + + + + + + """; // Checking assertEquals(removeWhiteSpaces(expected), removeWhiteSpaces(actual)); } diff --git a/network-area-diagram/src/test/java/com/powsybl/nad/svg/NominalVoltageStyleTest.java b/network-area-diagram/src/test/java/com/powsybl/nad/svg/NominalVoltageStyleTest.java index da782e5d5..88fafb632 100644 --- a/network-area-diagram/src/test/java/com/powsybl/nad/svg/NominalVoltageStyleTest.java +++ b/network-area-diagram/src/test/java/com/powsybl/nad/svg/NominalVoltageStyleTest.java @@ -11,7 +11,7 @@ import com.powsybl.iidm.network.Network; import com.powsybl.iidm.network.Terminal; import com.powsybl.iidm.network.test.FourSubstationsNodeBreakerFactory; -import com.powsybl.iidm.xml.NetworkXml; +import com.powsybl.iidm.serde.NetworkSerDe; import com.powsybl.nad.AbstractTest; import com.powsybl.nad.layout.LayoutParameters; import com.powsybl.nad.svg.iidm.DefaultLabelProvider; @@ -92,7 +92,7 @@ void testFictitiousVoltageLevel() { @Test void testIEEE24() { - Network network = NetworkXml.read(getClass().getResourceAsStream("/IEEE_24_bus.xiidm")); + Network network = NetworkSerDe.read(getClass().getResourceAsStream("/IEEE_24_bus.xiidm")); assertEquals(toString("/IEEE_24_bus.svg"), generateSvgString(network, "/IEEE_24_bus.svg")); } diff --git a/network-area-diagram/src/test/java/com/powsybl/nad/svg/ThreeWindingTransformerTest.java b/network-area-diagram/src/test/java/com/powsybl/nad/svg/ThreeWindingTransformerTest.java index 606ec9533..c164550c9 100644 --- a/network-area-diagram/src/test/java/com/powsybl/nad/svg/ThreeWindingTransformerTest.java +++ b/network-area-diagram/src/test/java/com/powsybl/nad/svg/ThreeWindingTransformerTest.java @@ -7,7 +7,7 @@ package com.powsybl.nad.svg; import com.powsybl.iidm.network.Network; -import com.powsybl.iidm.network.ThreeWindingsTransformer; +import com.powsybl.iidm.network.ThreeSides; import com.powsybl.iidm.network.test.ThreeWindingsTransformerNetworkFactory; import com.powsybl.nad.AbstractTest; import com.powsybl.nad.build.iidm.VoltageLevelFilter; @@ -56,7 +56,7 @@ void test3wt() { @Test void testDisconnected3wt() { Network network = ThreeWindingsTransformerNetworkFactory.create(); - network.getThreeWindingsTransformer("3WT").getTerminal(ThreeWindingsTransformer.Side.TWO).disconnect(); + network.getThreeWindingsTransformer("3WT").getTerminal(ThreeSides.TWO).disconnect(); network.getLoad("LOAD_33").remove(); assertEquals(toString("/3wt_disconnected.svg"), generateSvgString(network, "/3wt_disconnected.svg")); } @@ -64,7 +64,7 @@ void testDisconnected3wt() { @Test void testDisconnected3wtTopologicalStyle() { Network network = ThreeWindingsTransformerNetworkFactory.create(); - network.getThreeWindingsTransformer("3WT").getTerminal(ThreeWindingsTransformer.Side.TWO).disconnect(); + network.getThreeWindingsTransformer("3WT").getTerminal(ThreeSides.TWO).disconnect(); network.getLoad("LOAD_33").remove(); styleProvider = new TopologicalStyleProvider(network); assertEquals(toString("/3wt_disconnected_topological.svg"), generateSvgString(network, "/3wt_disconnected_topological.svg")); diff --git a/pom.xml b/pom.xml index ea14c227a..a41eb1de3 100644 --- a/pom.xml +++ b/pom.xml @@ -73,7 +73,7 @@ **/generated/**/* - 6.0.0 + 6.1.0 diff --git a/single-line-diagram/single-line-diagram-cgmes/single-line-diagram-cgmes-layout/src/test/java/com/powsybl/sld/cgmes/layout/CgmesZoneLayoutTest.java b/single-line-diagram/single-line-diagram-cgmes/single-line-diagram-cgmes-layout/src/test/java/com/powsybl/sld/cgmes/layout/CgmesZoneLayoutTest.java index b228cc78d..a0a6183d3 100644 --- a/single-line-diagram/single-line-diagram-cgmes/single-line-diagram-cgmes-layout/src/test/java/com/powsybl/sld/cgmes/layout/CgmesZoneLayoutTest.java +++ b/single-line-diagram/single-line-diagram-cgmes/single-line-diagram-cgmes-layout/src/test/java/com/powsybl/sld/cgmes/layout/CgmesZoneLayoutTest.java @@ -7,7 +7,6 @@ */ package com.powsybl.sld.cgmes.layout; -import com.powsybl.iidm.network.Branch.Side; import com.powsybl.iidm.network.*; import com.powsybl.sld.builders.NetworkGraphBuilder; import com.powsybl.sld.cgmes.dl.iidm.extensions.*; @@ -19,9 +18,9 @@ import com.powsybl.sld.model.nodes.BranchEdge; import com.powsybl.sld.model.nodes.BusNode; import com.powsybl.sld.model.nodes.Node; -import org.joda.time.DateTime; import org.junit.jupiter.api.Test; +import java.time.ZonedDateTime; import java.util.Arrays; import java.util.List; @@ -51,7 +50,7 @@ class CgmesZoneLayoutTest { private Network createNetwork() { Network network = Network.create("Network", "test"); - network.setCaseDate(DateTime.parse("2018-01-01T00:30:00.000+01:00")); + network.setCaseDate(ZonedDateTime.parse("2018-01-01T00:30:00.000+01:00")); Substation substation1 = network.newSubstation() .setId(SUBSTATION_1_ID) .setCountry(Country.FR) @@ -218,29 +217,29 @@ void test() { VoltageLevelGraph vlGraph11 = graph.getSubstationGraph(SUBSTATION_1_ID).getVoltageLevel(VOLTAGE_LEVEL_11_ID); assertEquals(3, vlGraph11.getNodes().size()); assertEquals(2, vlGraph11.getEdges().size()); - checkNode(vlGraph11.getNodes().get(0), Node.NodeType.BUS, BUS_11_ID, BUSBAR_SECTION, Arrays.asList(LOAD_ID, TRANSFORMER_ID + "_" + Side.ONE), 60, 10, true); + checkNode(vlGraph11.getNodes().get(0), Node.NodeType.BUS, BUS_11_ID, BUSBAR_SECTION, Arrays.asList(LOAD_ID, TRANSFORMER_ID + "_" + TwoSides.ONE), 60, 10, true); checkNode(vlGraph11.getNodes().get(1), Node.NodeType.FEEDER, LOAD_ID, LOAD, Arrays.asList(BUS_11_ID), 20, 30, true); - checkNode(vlGraph11.getNodes().get(2), Node.NodeType.FEEDER, TRANSFORMER_ID + "_" + Side.ONE, TWO_WINDINGS_TRANSFORMER_LEG, Arrays.asList(BUS_11_ID), 100, 30, false); + checkNode(vlGraph11.getNodes().get(2), Node.NodeType.FEEDER, TRANSFORMER_ID + "_" + TwoSides.ONE, TWO_WINDINGS_TRANSFORMER_LEG, Arrays.asList(BUS_11_ID), 100, 30, false); VoltageLevelGraph vlGraph12 = graph.getSubstationGraph(SUBSTATION_1_ID).getVoltageLevel(VOLTAGE_LEVEL_12_ID); assertEquals(3, vlGraph12.getNodes().size()); assertEquals(2, vlGraph12.getEdges().size()); - checkNode(vlGraph12.getNodes().get(0), Node.NodeType.BUS, BUS_12_ID, BUSBAR_SECTION, Arrays.asList(LINE_ID + "_" + Side.ONE, TRANSFORMER_ID + "_" + Side.TWO), 140, 10, true); - checkNode(vlGraph12.getNodes().get(1), Node.NodeType.FEEDER, TRANSFORMER_ID + "_" + Side.TWO, TWO_WINDINGS_TRANSFORMER_LEG, Arrays.asList(BUS_12_ID), 100, 30, false); - checkNode(vlGraph12.getNodes().get(2), Node.NodeType.FEEDER, LINE_ID + "_" + Side.ONE, LINE, Arrays.asList(BUS_12_ID), 180, 30, true); + checkNode(vlGraph12.getNodes().get(0), Node.NodeType.BUS, BUS_12_ID, BUSBAR_SECTION, Arrays.asList(LINE_ID + "_" + TwoSides.ONE, TRANSFORMER_ID + "_" + TwoSides.TWO), 140, 10, true); + checkNode(vlGraph12.getNodes().get(1), Node.NodeType.FEEDER, TRANSFORMER_ID + "_" + TwoSides.TWO, TWO_WINDINGS_TRANSFORMER_LEG, Arrays.asList(BUS_12_ID), 100, 30, false); + checkNode(vlGraph12.getNodes().get(2), Node.NodeType.FEEDER, LINE_ID + "_" + TwoSides.ONE, LINE, Arrays.asList(BUS_12_ID), 180, 30, true); VoltageLevelGraph vlGraph21 = graph.getSubstationGraph(SUBSTATION_2_ID).getVoltageLevel(VOLTAGE_LEVEL_21_ID); assertEquals(3, vlGraph21.getNodes().size()); assertEquals(2, vlGraph21.getEdges().size()); - checkNode(vlGraph21.getNodes().get(0), Node.NodeType.BUS, BUS_21_ID, BUSBAR_SECTION, Arrays.asList(LINE_ID + "_" + Side.TWO, GENERATOR_ID), 260, 90, true); + checkNode(vlGraph21.getNodes().get(0), Node.NodeType.BUS, BUS_21_ID, BUSBAR_SECTION, Arrays.asList(LINE_ID + "_" + TwoSides.TWO, GENERATOR_ID), 260, 90, true); checkNode(vlGraph21.getNodes().get(1), Node.NodeType.FEEDER, GENERATOR_ID, GENERATOR, Arrays.asList(BUS_21_ID), 300, 110, false); - checkNode(vlGraph21.getNodes().get(2), Node.NodeType.FEEDER, LINE_ID + "_" + Side.TWO, LINE, Arrays.asList(BUS_21_ID), 220, 110, true); + checkNode(vlGraph21.getNodes().get(2), Node.NodeType.FEEDER, LINE_ID + "_" + TwoSides.TWO, LINE, Arrays.asList(BUS_21_ID), 220, 110, true); assertEquals(1, graph.getLineEdges().size()); BranchEdge linEdge = graph.getLineEdges().get(0); assertEquals(LINE_ID, linEdge.getId()); - assertEquals(LINE_ID + "_" + Side.ONE, linEdge.getNode1().getId()); - assertEquals(LINE_ID + "_" + Side.TWO, linEdge.getNode2().getId()); + assertEquals(LINE_ID + "_" + TwoSides.ONE, linEdge.getNode1().getId()); + assertEquals(LINE_ID + "_" + TwoSides.TWO, linEdge.getNode2().getId()); List points = linEdge.getSnakeLine(); assertEquals(4, points.size()); checkLinePointCoordinates(points.get(0), 180, 30); diff --git a/single-line-diagram/single-line-diagram-cgmes/single-line-diagram-cgmes-layout/src/test/java/com/powsybl/sld/cgmes/layout/LayoutToCgmesDlExporterToolTest.java b/single-line-diagram/single-line-diagram-cgmes/single-line-diagram-cgmes-layout/src/test/java/com/powsybl/sld/cgmes/layout/LayoutToCgmesDlExporterToolTest.java index 8d9158cf6..ddf3f0bc6 100644 --- a/single-line-diagram/single-line-diagram-cgmes/single-line-diagram-cgmes-layout/src/test/java/com/powsybl/sld/cgmes/layout/LayoutToCgmesDlExporterToolTest.java +++ b/single-line-diagram/single-line-diagram-cgmes/single-line-diagram-cgmes-layout/src/test/java/com/powsybl/sld/cgmes/layout/LayoutToCgmesDlExporterToolTest.java @@ -9,7 +9,7 @@ import com.powsybl.commons.PowsyblException; import com.powsybl.iidm.network.Network; import com.powsybl.iidm.network.test.NetworkTest1Factory; -import com.powsybl.iidm.xml.XMLExporter; +import com.powsybl.iidm.serde.XMLExporter; import com.powsybl.tools.Tool; import com.powsybl.tools.ToolRunningContext; import com.powsybl.tools.test.AbstractToolTest; diff --git a/single-line-diagram/single-line-diagram-cgmes/single-line-diagram-cgmes-layout/src/test/java/com/powsybl/sld/cgmes/layout/LayoutToCgmesExtensionsTest.java b/single-line-diagram/single-line-diagram-cgmes/single-line-diagram-cgmes-layout/src/test/java/com/powsybl/sld/cgmes/layout/LayoutToCgmesExtensionsTest.java index 2bc060d31..bfe92f3c1 100644 --- a/single-line-diagram/single-line-diagram-cgmes/single-line-diagram-cgmes-layout/src/test/java/com/powsybl/sld/cgmes/layout/LayoutToCgmesExtensionsTest.java +++ b/single-line-diagram/single-line-diagram-cgmes/single-line-diagram-cgmes-layout/src/test/java/com/powsybl/sld/cgmes/layout/LayoutToCgmesExtensionsTest.java @@ -6,10 +6,9 @@ */ package com.powsybl.sld.cgmes.layout; +import com.powsybl.diagram.test.Networks; import com.powsybl.iidm.network.*; import com.powsybl.sld.cgmes.dl.iidm.extensions.*; - -import com.powsybl.diagram.test.Networks; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.Mockito; @@ -79,7 +78,7 @@ public void visitStaticVarCompensator(StaticVarCompensator staticVarCompensator) } @Override - public void visitLine(Line line, Branch.Side side) { + public void visitLine(Line line, TwoSides side) { assertNotNull(line.getExtension(LineDiagramData.class)); } @@ -89,12 +88,12 @@ public void visitBusbarSection(BusbarSection busBarSection) { } @Override - public void visitTwoWindingsTransformer(TwoWindingsTransformer transformer, Branch.Side side) { + public void visitTwoWindingsTransformer(TwoWindingsTransformer transformer, TwoSides side) { assertNotNull(transformer.getExtension(CouplingDeviceDiagramData.class)); } @Override - public void visitThreeWindingsTransformer(ThreeWindingsTransformer transformer, ThreeWindingsTransformer.Side side) { + public void visitThreeWindingsTransformer(ThreeWindingsTransformer transformer, ThreeSides side) { assertNotNull(transformer.getExtension(ThreeWindingsTransformerDiagramData.class)); } @@ -135,7 +134,7 @@ public void visitStaticVarCompensator(StaticVarCompensator staticVarCompensator) } @Override - public void visitLine(Line line, Branch.Side side) { + public void visitLine(Line line, TwoSides side) { assertNull(line.getExtension(LineDiagramData.class)); } @@ -145,12 +144,12 @@ public void visitBusbarSection(BusbarSection busBarSection) { } @Override - public void visitTwoWindingsTransformer(TwoWindingsTransformer transformer, Branch.Side side) { + public void visitTwoWindingsTransformer(TwoWindingsTransformer transformer, TwoSides side) { assertNull(transformer.getExtension(CouplingDeviceDiagramData.class)); } @Override - public void visitThreeWindingsTransformer(ThreeWindingsTransformer transformer, ThreeWindingsTransformer.Side side) { + public void visitThreeWindingsTransformer(ThreeWindingsTransformer transformer, ThreeSides side) { assertNull(transformer.getExtension(ThreeWindingsTransformerDiagramData.class)); } diff --git a/single-line-diagram/single-line-diagram-core/pom.xml b/single-line-diagram/single-line-diagram-core/pom.xml index ae09007de..f00945767 100644 --- a/single-line-diagram/single-line-diagram-core/pom.xml +++ b/single-line-diagram/single-line-diagram-core/pom.xml @@ -89,7 +89,7 @@ com.powsybl - powsybl-iidm-xml-converter + powsybl-iidm-serde test diff --git a/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/builders/NetworkGraphBuilder.java b/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/builders/NetworkGraphBuilder.java index 1b7647b93..d961c2b5d 100644 --- a/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/builders/NetworkGraphBuilder.java +++ b/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/builders/NetworkGraphBuilder.java @@ -222,21 +222,21 @@ protected AbstractGraphBuilder(VoltageLevelGraph graph) { protected abstract void add3wtFeeder(Middle3WTNode middleNode, FeederNode firstOtherLegNode, FeederNode secondOtherLegNode, Terminal terminal); - private FeederNode createFeederLineNode(VoltageLevelGraph graph, Line line, Branch.Side side) { + private FeederNode createFeederLineNode(VoltageLevelGraph graph, Line line, TwoSides side) { return createFeederBranchNode(graph, line, side, LINE); } - private FeederNode createFeederTieLineNode(VoltageLevelGraph graph, TieLine tieLine, Branch.Side side) { + private FeederNode createFeederTieLineNode(VoltageLevelGraph graph, TieLine tieLine, TwoSides side) { return createFeederBranchNode(graph, tieLine, side, TIE_LINE); } - private FeederNode createFeederBranchNode(VoltageLevelGraph graph, Branch branch, Branch.Side side, String componentTypeName) { + private FeederNode createFeederBranchNode(VoltageLevelGraph graph, Branch branch, TwoSides side, String componentTypeName) { String nodeId = branch.getId() + "_" + side.name(); String equipmentNameOrId = branch.getNameOrId(); String equipmentId; equipmentId = branch.getId(); NodeSide s = NodeSide.valueOf(side.name()); - Branch.Side otherSide = side == Branch.Side.ONE ? Branch.Side.TWO : Branch.Side.ONE; + TwoSides otherSide = side == TwoSides.ONE ? TwoSides.TWO : TwoSides.ONE; VoltageLevel vlOtherSide = branch.getTerminal(otherSide).getVoltageLevel(); return NodeFactory.createFeederBranchNode(graph, nodeId, equipmentNameOrId, equipmentId, componentTypeName, s, new VoltageLevelInfos(vlOtherSide.getId(), vlOtherSide.getNameOrId(), vlOtherSide.getNominalV())); @@ -262,15 +262,15 @@ private FeederNode createFeederLccNode(VoltageLevelGraph graph, HvdcConverterSta .orElseGet(() -> NodeFactory.createLccConverterStationInjection(graph, hvdcStation.getId(), hvdcStation.getNameOrId())); } - private Node createInternal2wtSideNode(VoltageLevelGraph graph, TwoWindingsTransformer branch, Branch.Side side) { + private Node createInternal2wtSideNode(VoltageLevelGraph graph, TwoWindingsTransformer branch, TwoSides side) { return NodeFactory.createConnectivityNode(graph, branch.getId() + "_" + side.name(), NODE); } - private FeederNode createFeeder2wtNode(VoltageLevelGraph graph, TwoWindingsTransformer branch, Branch.Side side) { + private FeederNode createFeeder2wtNode(VoltageLevelGraph graph, TwoWindingsTransformer branch, TwoSides side) { String id = branch.getId() + "_" + side.name(); String name = branch.getNameOrId(); String equipmentId = branch.getId(); - Branch.Side otherSide = side == Branch.Side.ONE ? Branch.Side.TWO : Branch.Side.ONE; + TwoSides otherSide = side == TwoSides.ONE ? TwoSides.TWO : TwoSides.ONE; VoltageLevel vlOtherSide = branch.getTerminal(otherSide).getVoltageLevel(); VoltageLevelInfos otherSideVoltageLevelInfos = new VoltageLevelInfos(vlOtherSide.getId(), vlOtherSide.getNameOrId(), vlOtherSide.getNominalV()); @@ -291,7 +291,7 @@ private FeederNode createFeeder2wtNode(VoltageLevelGraph graph, TwoWindingsTrans private void addFeeder3wtNode(VoltageLevelGraph graph, ThreeWindingsTransformer transformer, - ThreeWindingsTransformer.Side side) { + ThreeSides side) { if (graph.isForVoltageLevelDiagram() && isNotInternalToVoltageLevel(transformer)) { // in a voltageLevel diagram we represent 3 windings transformers by a double feeder cell: // - a transformer middle node at double feeder fork @@ -387,7 +387,7 @@ public void visitDanglingLine(DanglingLine dl) { } private void visitTieLine(TieLine tieLine, DanglingLine dl, Graph graph) { - Branch.Side side = tieLine.getSide(dl.getTerminal()); + TwoSides side = tieLine.getSide(dl.getTerminal()); Terminal terminal = dl.getTerminal(); addTerminalNode(createFeederTieLineNode((VoltageLevelGraph) graph, tieLine, side), terminal); } @@ -409,7 +409,7 @@ public void visitStaticVarCompensator(StaticVarCompensator svc) { } @Override - public void visitTwoWindingsTransformer(TwoWindingsTransformer transformer, Branch.Side side) { + public void visitTwoWindingsTransformer(TwoWindingsTransformer transformer, TwoSides side) { Node transformerNode = isInternalToVoltageLevel(transformer) ? createInternal2wtSideNode(graph, transformer, side) : createFeeder2wtNode(graph, transformer, side); @@ -417,7 +417,7 @@ public void visitTwoWindingsTransformer(TwoWindingsTransformer transformer, Bran } @Override - public void visitLine(Line line, Branch.Side side) { + public void visitLine(Line line, TwoSides side) { addTerminalNode(createFeederLineNode(graph, line, side), line.getTerminal(side)); } @@ -428,7 +428,7 @@ private static VoltageLevelInfos createVoltageLevelInfos(Terminal terminal) { @Override public void visitThreeWindingsTransformer(ThreeWindingsTransformer transformer, - ThreeWindingsTransformer.Side side) { + ThreeSides side) { addFeeder3wtNode(graph, transformer, side); } } @@ -702,8 +702,8 @@ private boolean addLineEdge(Graph graph, String lineId, Terminal t1, Terminal t2 private void add2wtEdges(VoltageLevelGraph graph, List twoWindingsTransformers) { for (TwoWindingsTransformer transfo : twoWindingsTransformers) { - Node n1 = graph.getNode(transfo.getId() + "_" + Branch.Side.ONE); - Node n2 = graph.getNode(transfo.getId() + "_" + Branch.Side.TWO); + Node n1 = graph.getNode(transfo.getId() + "_" + TwoSides.ONE); + Node n2 = graph.getNode(transfo.getId() + "_" + TwoSides.TWO); NodeFactory.createInternal2WTNode(graph, transfo.getId(), transfo.getNameOrId(), n1, n2, transfo.hasPhaseTapChanger()); } diff --git a/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/DefaultLabelProvider.java b/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/DefaultLabelProvider.java index dbfb55817..043c3e19f 100644 --- a/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/DefaultLabelProvider.java +++ b/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/DefaultLabelProvider.java @@ -8,7 +8,7 @@ package com.powsybl.sld.svg; import com.powsybl.iidm.network.*; -import com.powsybl.iidm.network.extensions.BranchStatus; +import com.powsybl.iidm.network.extensions.OperatingStatus; import com.powsybl.sld.layout.LayoutParameters; import com.powsybl.sld.library.ComponentLibrary; import com.powsybl.sld.model.coordinate.Direction; @@ -87,7 +87,7 @@ private List getBranchFeederInfos(FeederNode node, FeederWithSides f List measures = new ArrayList<>(); Branch branch = network.getBranch(node.getEquipmentId()); if (branch != null) { - Branch.Side side = Branch.Side.valueOf(feeder.getSide().name()); + TwoSides side = TwoSides.valueOf(feeder.getSide().name()); measures = buildFeederInfos(branch, side); } return measures; @@ -97,7 +97,7 @@ private List get3WTFeederInfos(FeederNode node, FeederTwLeg feeder) List feederInfos = new ArrayList<>(); ThreeWindingsTransformer transformer = network.getThreeWindingsTransformer(node.getEquipmentId()); if (transformer != null) { - ThreeWindingsTransformer.Side side = ThreeWindingsTransformer.Side.valueOf(feeder.getSide().name()); + ThreeSides side = ThreeSides.valueOf(feeder.getSide().name()); boolean insideVoltageLevel = feeder.getOwnVoltageLevelInfos().getId().equals(feeder.getVoltageLevelInfos().getId()); feederInfos = buildFeederInfos(transformer, side, insideVoltageLevel); } @@ -108,7 +108,7 @@ private List get2WTFeederInfos(FeederNode node, FeederTwLeg feeder) List measures = new ArrayList<>(); TwoWindingsTransformer transformer = network.getTwoWindingsTransformer(node.getEquipmentId()); if (transformer != null) { - Branch.Side side = Branch.Side.valueOf(feeder.getSide().name()); + TwoSides side = TwoSides.valueOf(feeder.getSide().name()); measures = buildFeederInfos(transformer, side); } return measures; @@ -130,7 +130,7 @@ public List getNodeDecorators(Node node, Direction direction) { List nodeDecorators = new ArrayList<>(); - // BranchStatus extension is on connectables, so we're looking for them + // OperatingStatus extension is on identifiables, so we're looking for them if (node instanceof EquipmentNode && !(node instanceof SwitchNode)) { if (node instanceof FeederNode) { FeederNode feederNode = (FeederNode) node; @@ -180,7 +180,7 @@ public List getElectricalNodesInfos(VoltageLevelGraph graph) } private void addBranchStatusDecorator(List nodeDecorators, Node node, Direction direction, Connectable c) { - BranchStatus branchStatus = (BranchStatus) c.getExtension(BranchStatus.class); + OperatingStatus branchStatus = (OperatingStatus) c.getExtension(OperatingStatus.class); if (branchStatus != null) { switch (branchStatus.getStatus()) { case PLANNED_OUTAGE: @@ -201,7 +201,7 @@ private NodeDecorator getBranchStatusDecorator(Node node, Direction direction, S new NodeDecorator(decoratorType, getFeederDecoratorPosition(direction, decoratorType)); } - private List buildFeederInfos(ThreeWindingsTransformer transformer, ThreeWindingsTransformer.Side side, boolean insideVoltageLevel) { + private List buildFeederInfos(ThreeWindingsTransformer transformer, ThreeSides side, boolean insideVoltageLevel) { return this.buildFeederInfos(transformer.getTerminal(side), insideVoltageLevel); } @@ -209,7 +209,7 @@ private List buildFeederInfos(Injection injection) { return this.buildFeederInfos(injection.getTerminal()); } - private List buildFeederInfos(Branch branch, Branch.Side side) { + private List buildFeederInfos(Branch branch, TwoSides side) { return this.buildFeederInfos(branch.getTerminal(side)); } diff --git a/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/styles/iidm/HighlightLineStateStyleProvider.java b/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/styles/iidm/HighlightLineStateStyleProvider.java index 3a542d6d2..ff8082512 100644 --- a/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/styles/iidm/HighlightLineStateStyleProvider.java +++ b/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/styles/iidm/HighlightLineStateStyleProvider.java @@ -101,15 +101,15 @@ protected Map connectionStatus(FeederNode node) { if (node.getFeeder().getFeederType() == FeederType.BRANCH || node.getFeeder().getFeederType() == FeederType.TWO_WINDINGS_TRANSFORMER_LEG) { Branch branch = network.getBranch(node.getEquipmentId()); if (branch != null) { - res.put(NodeSide.ONE, branch.getTerminal(Branch.Side.ONE).isConnected()); - res.put(NodeSide.TWO, branch.getTerminal(Branch.Side.TWO).isConnected()); + res.put(NodeSide.ONE, branch.getTerminal(TwoSides.ONE).isConnected()); + res.put(NodeSide.TWO, branch.getTerminal(TwoSides.TWO).isConnected()); } } else if (node.getFeeder().getFeederType() == FeederType.THREE_WINDINGS_TRANSFORMER_LEG) { ThreeWindingsTransformer transformer = network.getThreeWindingsTransformer(node.getEquipmentId()); if (transformer != null) { - res.put(NodeSide.ONE, transformer.getTerminal(ThreeWindingsTransformer.Side.ONE).isConnected()); - res.put(NodeSide.TWO, transformer.getTerminal(ThreeWindingsTransformer.Side.TWO).isConnected()); - res.put(NodeSide.THREE, transformer.getTerminal(ThreeWindingsTransformer.Side.THREE).isConnected()); + res.put(NodeSide.ONE, transformer.getTerminal(ThreeSides.ONE).isConnected()); + res.put(NodeSide.TWO, transformer.getTerminal(ThreeSides.TWO).isConnected()); + res.put(NodeSide.THREE, transformer.getTerminal(ThreeSides.THREE).isConnected()); } } return res; @@ -120,9 +120,9 @@ private static NodeSide getOtherSide(NodeSide side) { } private static NodeSide getTransformerSide(String idVl, ThreeWindingsTransformer transformer) { - if (transformer.getTerminal(ThreeWindingsTransformer.Side.ONE).getVoltageLevel().getId().equals(idVl)) { + if (transformer.getTerminal(ThreeSides.ONE).getVoltageLevel().getId().equals(idVl)) { return NodeSide.ONE; - } else if (transformer.getTerminal(ThreeWindingsTransformer.Side.TWO).getVoltageLevel().getId().equals(idVl)) { + } else if (transformer.getTerminal(ThreeSides.TWO).getVoltageLevel().getId().equals(idVl)) { return NodeSide.TWO; } else { return NodeSide.THREE; diff --git a/single-line-diagram/single-line-diagram-core/src/test/java/com/powsybl/sld/SingleLineDiagramToolTest.java b/single-line-diagram/single-line-diagram-core/src/test/java/com/powsybl/sld/SingleLineDiagramToolTest.java index f6f742cf8..3abdb81ca 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/java/com/powsybl/sld/SingleLineDiagramToolTest.java +++ b/single-line-diagram/single-line-diagram-core/src/test/java/com/powsybl/sld/SingleLineDiagramToolTest.java @@ -9,7 +9,7 @@ import com.powsybl.commons.PowsyblException; import com.powsybl.iidm.network.Network; import com.powsybl.iidm.network.test.NetworkTest1Factory; -import com.powsybl.iidm.xml.XMLExporter; +import com.powsybl.iidm.serde.XMLExporter; import com.powsybl.tools.Tool; import com.powsybl.tools.ToolRunningContext; import com.powsybl.tools.test.AbstractToolTest; diff --git a/single-line-diagram/single-line-diagram-core/src/test/java/com/powsybl/sld/iidm/TestDisconnectedComponentsBusBreaker.java b/single-line-diagram/single-line-diagram-core/src/test/java/com/powsybl/sld/iidm/TestDisconnectedComponentsBusBreaker.java index 9303e334f..185373489 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/java/com/powsybl/sld/iidm/TestDisconnectedComponentsBusBreaker.java +++ b/single-line-diagram/single-line-diagram-core/src/test/java/com/powsybl/sld/iidm/TestDisconnectedComponentsBusBreaker.java @@ -8,8 +8,8 @@ package com.powsybl.sld.iidm; import com.powsybl.diagram.test.Networks; -import com.powsybl.iidm.network.Branch; -import com.powsybl.iidm.network.ThreeWindingsTransformer; +import com.powsybl.iidm.network.ThreeSides; +import com.powsybl.iidm.network.TwoSides; import com.powsybl.sld.builders.NetworkGraphBuilder; import com.powsybl.sld.model.graphs.VoltageLevelGraph; import org.junit.jupiter.api.BeforeEach; @@ -33,9 +33,9 @@ public void setUp() { void testDisconnectedComponents() { network.getLoad("LD1").getTerminal().disconnect(); network.getGenerator("G").getTerminal().disconnect(); - network.getLine("L12").getTerminal(Branch.Side.TWO).disconnect(); - network.getTwoWindingsTransformer("T11").getTerminal(Branch.Side.TWO).disconnect(); - network.getThreeWindingsTransformer("T3_12").getTerminal(ThreeWindingsTransformer.Side.THREE).disconnect(); + network.getLine("L12").getTerminal(TwoSides.TWO).disconnect(); + network.getTwoWindingsTransformer("T11").getTerminal(TwoSides.TWO).disconnect(); + network.getThreeWindingsTransformer("T3_12").getTerminal(ThreeSides.THREE).disconnect(); // build graph graphBuilder = new NetworkGraphBuilder(network); diff --git a/single-line-diagram/single-line-diagram-core/src/test/java/com/powsybl/sld/iidm/TestSVGWriter.java b/single-line-diagram/single-line-diagram-core/src/test/java/com/powsybl/sld/iidm/TestSVGWriter.java index 4a0c9cae2..543e7cfe9 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/java/com/powsybl/sld/iidm/TestSVGWriter.java +++ b/single-line-diagram/single-line-diagram-core/src/test/java/com/powsybl/sld/iidm/TestSVGWriter.java @@ -7,8 +7,8 @@ */ package com.powsybl.sld.iidm; -import com.powsybl.iidm.network.Branch.Side; import com.powsybl.iidm.network.Network; +import com.powsybl.iidm.network.TwoSides; import com.powsybl.sld.library.ComponentTypeName; import com.powsybl.sld.model.coordinate.Direction; import com.powsybl.sld.model.coordinate.Orientation; @@ -529,7 +529,7 @@ private void createZoneGraph() { bus11Node.setPxWidth(40); FeederNode loadNode = NodeFactory.createLoad(vl11Graph, LOAD_ID, LOAD_ID); loadNode.setCoordinates(50, 10); - FeederNode twtSide1Node = NodeFactory.createFeeder2WTLegNode(vl11Graph, TRANSFORMER_ID + "_" + Side.ONE, TRANSFORMER_ID, TRANSFORMER_ID, ONE); + FeederNode twtSide1Node = NodeFactory.createFeeder2WTLegNode(vl11Graph, TRANSFORMER_ID + "_" + TwoSides.ONE, TRANSFORMER_ID, TRANSFORMER_ID, ONE); twtSide1Node.setCoordinates(50, 260); vl11Graph.addEdge(bus11Node, loadNode); vl11Graph.addEdge(bus11Node, twtSide1Node); @@ -540,9 +540,9 @@ private void createZoneGraph() { BusNode bus12Node = NodeFactory.createBusNode(vl12Graph, BUS_12_ID, BUS_12_ID); bus12Node.setCoordinates(30, 110); bus12Node.setPxWidth(40); - FeederNode twtSide2Node = NodeFactory.createFeeder2WTLegNode(vl12Graph, TRANSFORMER_ID + "_" + Side.TWO, TRANSFORMER_ID, TRANSFORMER_ID, TWO); + FeederNode twtSide2Node = NodeFactory.createFeeder2WTLegNode(vl12Graph, TRANSFORMER_ID + "_" + TwoSides.TWO, TRANSFORMER_ID, TRANSFORMER_ID, TWO); twtSide2Node.setCoordinates(50, 10); - FeederNode lineSide1Node = NodeFactory.createFeederLineNode(vl12Graph, LINE_ID + "_" + Side.ONE, LINE_ID, LINE_ID, ONE, vl21Infos); + FeederNode lineSide1Node = NodeFactory.createFeederLineNode(vl12Graph, LINE_ID + "_" + TwoSides.ONE, LINE_ID, LINE_ID, ONE, vl21Infos); lineSide1Node.setCoordinates(50, 260); vl12Graph.addEdge(bus12Node, twtSide2Node); vl12Graph.addEdge(bus12Node, lineSide1Node); @@ -555,7 +555,7 @@ private void createZoneGraph() { bus21Node.setPxWidth(40); FeederNode genNode = NodeFactory.createGenerator(vl21Graph, GENERATOR_ID, GENERATOR_ID); genNode.setCoordinates(50, 310); - FeederNode lineSide2Node = NodeFactory.createFeederLineNode(vl21Graph, LINE_ID + "_" + Side.TWO, LINE_ID, LINE_ID, TWO, vl12Infos); + FeederNode lineSide2Node = NodeFactory.createFeederLineNode(vl21Graph, LINE_ID + "_" + TwoSides.TWO, LINE_ID, LINE_ID, TWO, vl12Infos); lineSide2Node.setCoordinates(50, 10); vl21Graph.addEdge(bus21Node, genNode); vl21Graph.addEdge(bus21Node, lineSide2Node); diff --git a/single-line-diagram/single-line-diagram-core/src/test/java/com/powsybl/sld/model/ZoneGraphTest.java b/single-line-diagram/single-line-diagram-core/src/test/java/com/powsybl/sld/model/ZoneGraphTest.java index c24373a00..59ff4738d 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/java/com/powsybl/sld/model/ZoneGraphTest.java +++ b/single-line-diagram/single-line-diagram-core/src/test/java/com/powsybl/sld/model/ZoneGraphTest.java @@ -7,7 +7,7 @@ package com.powsybl.sld.model; import com.powsybl.diagram.test.Networks; -import com.powsybl.iidm.network.*; +import com.powsybl.iidm.network.TwoSides; import com.powsybl.sld.builders.NetworkGraphBuilder; import com.powsybl.sld.model.graphs.SubstationGraph; import com.powsybl.sld.model.graphs.VoltageLevelGraph; @@ -44,13 +44,13 @@ void test() { assertEquals(1, graph.getLineEdges().size()); BranchEdge edge = graph.getLineEdges().get(0); assertEquals(LINE_ID, edge.getId()); - String lineNodeId1 = getLineNodeId(graph, SUBSTATION_ID_1, VOLTAGELEVEL_ID_1, Branch.Side.ONE); - String lineNodeId2 = getLineNodeId(graph, SUBSTATION_ID_2, VOLTAGELEVEL_ID_2, Branch.Side.TWO); + String lineNodeId1 = getLineNodeId(graph, SUBSTATION_ID_1, VOLTAGELEVEL_ID_1, TwoSides.ONE); + String lineNodeId2 = getLineNodeId(graph, SUBSTATION_ID_2, VOLTAGELEVEL_ID_2, TwoSides.TWO); assertEquals(lineNodeId1, edge.getNode1().getId()); assertEquals(lineNodeId2, edge.getNode2().getId()); } - private String getLineNodeId(ZoneGraph graph, String substationId, String voltageLevelId, Branch.Side side) { + private String getLineNodeId(ZoneGraph graph, String substationId, String voltageLevelId, TwoSides side) { SubstationGraph substationGraph1 = graph.getSubstationGraph(substationId); assertNotNull(substationGraph1); VoltageLevelGraph voltageLevelGraph1 = substationGraph1.getVoltageLevel(voltageLevelId);