From 09047fd33a10eaef542e20b23c3394ab9b50fd1f Mon Sep 17 00:00:00 2001 From: Anis Touri Date: Fri, 8 Mar 2024 17:36:46 +0100 Subject: [PATCH] Homogenize substation attributes (#97) Signed-off-by: TOURI ANIS --- .../java/com/powsybl/sld/server/dto/SubstationInfos.java | 7 ++++--- .../java/com/powsybl/sld/server/dto/VoltageLevelInfos.java | 7 ++++--- .../java/com/powsybl/sld/server/SingleLineDiagramTest.java | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/powsybl/sld/server/dto/SubstationInfos.java b/src/main/java/com/powsybl/sld/server/dto/SubstationInfos.java index 4fa365a..22ad626 100644 --- a/src/main/java/com/powsybl/sld/server/dto/SubstationInfos.java +++ b/src/main/java/com/powsybl/sld/server/dto/SubstationInfos.java @@ -7,6 +7,7 @@ package com.powsybl.sld.server.dto; import com.fasterxml.jackson.annotation.JsonInclude; +import com.powsybl.iidm.network.Country; import com.powsybl.iidm.network.Substation; import lombok.Getter; @@ -14,13 +15,13 @@ public class SubstationInfos extends EquipmentInfos { @JsonInclude(JsonInclude.Include.NON_NULL) - private String countryName; + private Country country; public SubstationInfos(Substation substation) { this.id = substation.getId(); this.name = substation.getOptionalName().orElse(null); - substation.getCountry().ifPresent(country -> { - this.countryName = country.getName(); + substation.getCountry().ifPresent(countryValue -> { + this.country = countryValue; }); } } diff --git a/src/main/java/com/powsybl/sld/server/dto/VoltageLevelInfos.java b/src/main/java/com/powsybl/sld/server/dto/VoltageLevelInfos.java index 35de1dc..2f34b79 100644 --- a/src/main/java/com/powsybl/sld/server/dto/VoltageLevelInfos.java +++ b/src/main/java/com/powsybl/sld/server/dto/VoltageLevelInfos.java @@ -7,6 +7,7 @@ package com.powsybl.sld.server.dto; import com.fasterxml.jackson.annotation.JsonInclude; +import com.powsybl.iidm.network.Country; import com.powsybl.iidm.network.VoltageLevel; import lombok.Getter; @@ -17,15 +18,15 @@ public class VoltageLevelInfos extends EquipmentInfos { private String substationId; @JsonInclude(JsonInclude.Include.NON_NULL) - private String countryName; + private Country country; public VoltageLevelInfos(VoltageLevel voltageLevel) { this.id = voltageLevel.getId(); this.name = voltageLevel.getOptionalName().orElse(null); voltageLevel.getSubstation().ifPresent(substation -> { this.substationId = substation.getId(); - substation.getCountry().ifPresent(country -> { - this.countryName = country.getName(); + substation.getCountry().ifPresent(countryValue -> { + this.country = countryValue; }); }); } diff --git a/src/test/java/com/powsybl/sld/server/SingleLineDiagramTest.java b/src/test/java/com/powsybl/sld/server/SingleLineDiagramTest.java index a94a02f..7935325 100644 --- a/src/test/java/com/powsybl/sld/server/SingleLineDiagramTest.java +++ b/src/test/java/com/powsybl/sld/server/SingleLineDiagramTest.java @@ -358,7 +358,7 @@ public void testVoltageLevelSingleLineDiagramAdditionalMetadata() { }); assertEquals("vlFr1A", convertedMetadata.get("id")); assertEquals("vlFr1A", convertedMetadata.get("name")); - assertEquals("FRANCE", convertedMetadata.get("countryName")); + assertEquals("FR", convertedMetadata.get("country")); assertEquals("subFr1", convertedMetadata.get("substationId")); } @@ -386,7 +386,7 @@ public void testSubstationSingleLineDiagramAdditionalMetadata() { }); assertEquals("subFr1", convertedMetadata.get("id")); assertEquals(null, convertedMetadata.get("name")); - assertEquals("FRANCE", convertedMetadata.get("countryName")); + assertEquals("FR", convertedMetadata.get("country")); } public static Network createNetwork() {