Skip to content

Commit

Permalink
using crac to get to and from country nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
SCHWITZGUEBEL Marc Ext committed Dec 15, 2023
1 parent 0eaae1f commit a9da0db
Showing 1 changed file with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,12 @@ public Map<String, MergedCnec> getMergedCnecs(String contingencyId) {
}

private CnecCommon makeCnecCommon(FlowCnec cnec, NativeBranch nativeBranch, boolean selected) {
NetworkElement networkElement = cnec.getNetworkElement();
CnecCommon cnecCommon = new CnecCommon();
cnecCommon.setName(cnec.getName());
cnecCommon.setCode(makeCode(nativeBranch));
cnecCommon.setAreaFrom(getAreaFrom(cnec.getNetworkElement()));
cnecCommon.setAreaTo(getAreaTo(cnec.getNetworkElement()));
cnecCommon.setAreaFrom(getAreaFrom(networkElement, nativeBranch));
cnecCommon.setAreaTo(getAreaTo(networkElement, nativeBranch));
cnecCommon.setNodeFrom(nativeBranch.getFrom());
cnecCommon.setNodeTo(nativeBranch.getTo());
cnecCommon.setOrderCode(nativeBranch.getSuffix());
Expand Down Expand Up @@ -251,13 +252,25 @@ public String getAreaTo(NetworkElement networkElement) {
return getCountryOfNode(networkElement, countryTo, countryFrom);
}

private String getCountryOfNode(NetworkElement networkElement, String countryFrom, String countryTo) {
if (!countryFrom.equals(UcteCountryCode.XX.toString())) {
return countryFrom;
public String getAreaFrom(NetworkElement networkElement, NativeBranch nativeBranch) {
String countryFrom = UcteCountryCode.fromUcteCode(nativeBranch.getFrom().charAt(0)).toString();
String countryTo = UcteCountryCode.fromUcteCode(nativeBranch.getTo().charAt(0)).toString();
return getCountryOfNode(networkElement, countryFrom, countryTo);
}

public String getAreaTo(NetworkElement networkElement, NativeBranch nativeBranch) {
String countryFrom = UcteCountryCode.fromUcteCode(nativeBranch.getFrom().charAt(0)).toString();
String countryTo = UcteCountryCode.fromUcteCode(nativeBranch.getTo().charAt(0)).toString();
return getCountryOfNode(networkElement, countryTo, countryFrom);
}

private String getCountryOfNode(NetworkElement networkElement, String nodeCountry, String destinationNodeCountry) {
if (!nodeCountry.equals(UcteCountryCode.XX.toString())) {
return nodeCountry;
} else {
String area1 = getCountrySide1(networkElement);
String area2 = getCountrySide2(networkElement);
if (StringUtils.equals(area1, countryTo)) {
if (StringUtils.equals(area1, destinationNodeCountry)) {
return area2;
} else {
return area1;
Expand Down

0 comments on commit a9da0db

Please sign in to comment.