diff --git a/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/NodeContainerMappingTest.java b/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/NodeContainerMappingTest.java index 0cf36afb930..3713462ca58 100644 --- a/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/NodeContainerMappingTest.java +++ b/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/NodeContainerMappingTest.java @@ -146,4 +146,16 @@ void voltageLevelsConnectedByOpenSwitchTest() { assertEquals(1, network.getVoltageLevelCount()); assertNotNull(network.getVoltageLevel("VL_1")); } + + @Test + void voltageLevelWithoutName() { + // CGMES network: + // Voltage level of ID "VoltageLevel1" has no name + // IIDM network: + // The voltage level imported without name, and can be retrieved via its id + Network network = readCgmesResources(DIR, "vl_without_name.xml"); + assertNotNull(network); + assertEquals(2, network.getVoltageLevelCount()); + assertNotNull(network.getVoltageLevel("VoltageLevel")); + } } diff --git a/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/cim14/Cim14SmallCasesConversionTest.java b/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/cim14/Cim14SmallCasesConversionTest.java index c14a6327bbc..7539792ca7c 100644 --- a/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/cim14/Cim14SmallCasesConversionTest.java +++ b/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/cim14/Cim14SmallCasesConversionTest.java @@ -30,8 +30,8 @@ import java.util.Properties; import java.util.stream.Collectors; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertNotNull; /** * @author Luma ZamarreƱo {@literal } @@ -113,5 +113,20 @@ void condenser() { assertTrue(c.isCondenser()); } + @Test + void voltageLevelWithoutName() { + // CGMES network: + // Voltage level of ID "VoltageLevel1" has no name + // IIDM network: + // The voltage level imported without name, and can be retrieved via its id + + ReadOnlyDataSource ds = new ResourceDataSource("vl_without_name", + new ResourceSet("/cim14/", "vl_without_name.xml")); + Network network = new CgmesImport().importData(ds, new NetworkFactoryImpl(), new Properties()); + + assertNotNull(network); + assertNotNull(network.getVoltageLevel("VoltageLevel")); + } + private static ConversionTester tester; } diff --git a/cgmes/cgmes-conversion/src/test/resources/cim14/vl_without_name.xml b/cgmes/cgmes-conversion/src/test/resources/cim14/vl_without_name.xml new file mode 100644 index 00000000000..70bb42b53a2 --- /dev/null +++ b/cgmes/cgmes-conversion/src/test/resources/cim14/vl_without_name.xml @@ -0,0 +1,27 @@ + + + + GeographicalRegion + + + SubGeographicalRegion + + + + Substation + + + + + + + + + 11 kV + 11.0 + + + IEC61970CIM14v02 + 2009-05-10 + + diff --git a/cgmes/cgmes-conversion/src/test/resources/issues/node-containers/vl_without_name.xml b/cgmes/cgmes-conversion/src/test/resources/issues/node-containers/vl_without_name.xml new file mode 100644 index 00000000000..9e6e1b546d2 --- /dev/null +++ b/cgmes/cgmes-conversion/src/test/resources/issues/node-containers/vl_without_name.xml @@ -0,0 +1,72 @@ + + + 2024-03-28T11:00:00Z + 2024-03-28T11:00:00Z + 1 + Line containers and fictitious voltage levels + https://www.powsybl.org/ + http://entsoe.eu/CIM/EquipmentCore/3/1 + http://entsoe.eu/CIM/EquipmentOperation/3/1 + + + GeographicalRegion + + + SubGeographicalRegion + + + + Substation + + + + + + + + + Bay + + + + Node inside bay + + + + Line Container + + + Node inside line container + + + + 0 + 0 + 0 + 0 + Line segment + 0.1 + 0.1 + 75 + 1 + 1 + + + + + Line segment Terminal 1 + + 1 + + + + Line segment Terminal 2 + + 2 + + + + 11 kV + 11.0 + + diff --git a/cgmes/cgmes-model/src/main/resources/CIM14.sparql b/cgmes/cgmes-model/src/main/resources/CIM14.sparql index 2f49406b1c2..44ee184a271 100644 --- a/cgmes/cgmes-model/src/main/resources/CIM14.sparql +++ b/cgmes/cgmes-model/src/main/resources/CIM14.sparql @@ -54,8 +54,8 @@ GRAPH ?graph { ?VoltageLevel a cim:VoltageLevel ; cim:VoltageLevel.MemberOf_Substation ?Substation ; - cim:IdentifiedObject.name ?name ; cim:VoltageLevel.BaseVoltage ?BaseVoltage . + OPTIONAL { ?VoltageLevel cim:IdentifiedObject.name ?name } } # BaseVoltage may be defined in a different EQ graph GRAPH ?graph2 { diff --git a/cgmes/cgmes-model/src/main/resources/CIM16.sparql b/cgmes/cgmes-model/src/main/resources/CIM16.sparql index bae7ca1b6db..c137be21da9 100644 --- a/cgmes/cgmes-model/src/main/resources/CIM16.sparql +++ b/cgmes/cgmes-model/src/main/resources/CIM16.sparql @@ -215,8 +215,8 @@ WHERE { ?VoltageLevel a cim:VoltageLevel ; cim:VoltageLevel.Substation ?Substation ; - cim:IdentifiedObject.name ?name ; cim:VoltageLevel.BaseVoltage ?BaseVoltage . + OPTIONAL { ?VoltageLevel cim:IdentifiedObject.name ?name } OPTIONAL { ?VoltageLevel cim:VoltageLevel.lowVoltageLimit ?lowVoltageLimit } OPTIONAL { ?VoltageLevel cim:VoltageLevel.highVoltageLimit ?highVoltageLimit } }} @@ -342,9 +342,9 @@ WHERE { # A Bay may be in a different instance file of its containing Voltage Level, # and a Voltage Level in a different instance file of its containing Substation. # This is why we do not use a "restrictive" GRAPH clause here. - ?ConnectivityNodeContainer a ?connectivityNodeContainerType ; + ?ConnectivityNodeContainer a ?connectivityNodeContainerType . + OPTIONAL { ?ConnectivityNodeContainer cim:IdentifiedObject.name ?name } VALUES ?connectivityNodeContainerType { cim:VoltageLevel cim:Bay cim:Line cim:Substation} . - ?ConnectivityNodeContainer cim:IdentifiedObject.name ?name . OPTIONAL { ?ConnectivityNodeContainer a cim:VoltageLevel ;