Skip to content

Commit

Permalink
Homogenize substation attributes (#97)
Browse files Browse the repository at this point in the history
Signed-off-by: TOURI ANIS <anis-1.touri@rte-france.com>
  • Loading branch information
anistouri authored Mar 8, 2024
1 parent c97084a commit 09047fd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
7 changes: 4 additions & 3 deletions src/main/java/com/powsybl/sld/server/dto/SubstationInfos.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,21 @@
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;

@Getter
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;
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
});
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}

Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit 09047fd

Please sign in to comment.