From a6634b6c9ff640030ac0d2e17b86638576a8298a Mon Sep 17 00:00:00 2001 From: Mathieu DEHARBE Date: Tue, 10 Dec 2024 15:20:49 +0100 Subject: [PATCH 01/17] stores and apply several limit sets in the branch creation Signed-off-by: Mathieu DEHARBE --- .../modification/dto/BranchCreationInfos.java | 16 +++++-- .../modification/dto/CurrentLimitsInfos.java | 9 ++-- .../modifications/LineCreation.java | 18 +++++--- .../TwoWindingsTransformerCreation.java | 17 +++++--- .../modification/utils/ModificationUtils.java | 43 +++++++++++-------- .../LineCreationInBusBreakerTest.java | 12 ++++-- ...ingsTransformerCreationBusBreakerTest.java | 8 +++- ...ngsTransformerCreationNodeBreakerTest.java | 10 +++-- 8 files changed, 89 insertions(+), 44 deletions(-) diff --git a/src/main/java/org/gridsuite/modification/dto/BranchCreationInfos.java b/src/main/java/org/gridsuite/modification/dto/BranchCreationInfos.java index bb59e42..a2bc4c4 100644 --- a/src/main/java/org/gridsuite/modification/dto/BranchCreationInfos.java +++ b/src/main/java/org/gridsuite/modification/dto/BranchCreationInfos.java @@ -14,6 +14,8 @@ import lombok.ToString; import lombok.experimental.SuperBuilder; +import java.util.List; + /** * @author Sylvain Bouzols */ @@ -43,11 +45,17 @@ public class BranchCreationInfos extends EquipmentCreationInfos { @Schema(description = "Bus or Busbar section id Side 2") private String busOrBusbarSectionId2; - @Schema(description = "Current limits Side 1") - private CurrentLimitsInfos currentLimits1; + @Schema(description = "Current limits on side 1") + private List currentLimits1; + + @Schema(description = "Current limits on side 2") + private List currentLimits2; + + @Schema(description = "Selected operational limits group id on Side 1") + private String selectedOperationalLimitsGroupId1; - @Schema(description = "Current limits Side 2") - private CurrentLimitsInfos currentLimits2; + @Schema(description = "Selected operational limits group id on Side 2") + private String selectedOperationalLimitsGroupId2; @Schema(description = "Connection Name 1") private String connectionName1; diff --git a/src/main/java/org/gridsuite/modification/dto/CurrentLimitsInfos.java b/src/main/java/org/gridsuite/modification/dto/CurrentLimitsInfos.java index 58e94ea..2cc5a5d 100644 --- a/src/main/java/org/gridsuite/modification/dto/CurrentLimitsInfos.java +++ b/src/main/java/org/gridsuite/modification/dto/CurrentLimitsInfos.java @@ -7,16 +7,14 @@ package org.gridsuite.modification.dto; import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.ToString; +import lombok.*; import lombok.experimental.SuperBuilder; import java.util.List; /** * @author Sylvain Bouzols + * ~= environ operational limit group, ~= limit set */ @SuperBuilder @@ -27,6 +25,9 @@ @Schema(description = "Current Limits") public class CurrentLimitsInfos { + @Schema(description = "Operational limit group name") + private String operationalLimitGroupId; + @Schema(description = "Permanent current limit") private Double permanentLimit; diff --git a/src/main/java/org/gridsuite/modification/modifications/LineCreation.java b/src/main/java/org/gridsuite/modification/modifications/LineCreation.java index b574746..84cfef8 100644 --- a/src/main/java/org/gridsuite/modification/modifications/LineCreation.java +++ b/src/main/java/org/gridsuite/modification/modifications/LineCreation.java @@ -17,6 +17,8 @@ import org.gridsuite.modification.utils.ModificationUtils; import org.gridsuite.modification.utils.PropertiesUtils; +import java.util.List; + import static org.gridsuite.modification.NetworkModificationException.Type.*; /** @@ -67,16 +69,22 @@ public void apply(Network network, ReportNode subReportNode) { } // Set permanent and temporary current limits - CurrentLimitsInfos currentLimitsInfos1 = modificationInfos.getCurrentLimits1(); - CurrentLimitsInfos currentLimitsInfos2 = modificationInfos.getCurrentLimits2(); - if (currentLimitsInfos1 != null || currentLimitsInfos2 != null) { + List operationalLimitGroups1 = modificationInfos.getCurrentLimits1(); + List operationalLimitGroups2 = modificationInfos.getCurrentLimits2(); + if (operationalLimitGroups1 != null && !operationalLimitGroups1.isEmpty() || operationalLimitGroups2 != null && !operationalLimitGroups2.isEmpty()) { var line = ModificationUtils.getInstance().getLine(network, modificationInfos.getEquipmentId()); - ModificationUtils.getInstance().setCurrentLimits(currentLimitsInfos1, line.newCurrentLimits1()); - ModificationUtils.getInstance().setCurrentLimits(currentLimitsInfos2, line.newCurrentLimits2()); + ModificationUtils.getInstance().setAllCurrentLimits(operationalLimitGroups1, line); + ModificationUtils.getInstance().setAllCurrentLimits(operationalLimitGroups2, line); } ModificationUtils.getInstance().disconnectBranch(modificationInfos, network.getLine(modificationInfos.getEquipmentId()), subReportNode); // properties Line line = network.getLine(modificationInfos.getEquipmentId()); + if (modificationInfos.getSelectedOperationalLimitsGroupId1() != null) { + line.setSelectedOperationalLimitsGroup1(modificationInfos.getSelectedOperationalLimitsGroupId1()); + } + if (modificationInfos.getSelectedOperationalLimitsGroupId2() != null) { + line.setSelectedOperationalLimitsGroup2(modificationInfos.getSelectedOperationalLimitsGroupId2()); + } PropertiesUtils.applyProperties(line, subReportNode, modificationInfos.getProperties(), "LineProperties"); } diff --git a/src/main/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreation.java b/src/main/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreation.java index 5e7adc1..fef3c76 100644 --- a/src/main/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreation.java +++ b/src/main/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreation.java @@ -16,6 +16,7 @@ import org.gridsuite.modification.utils.ModificationUtils; import org.gridsuite.modification.utils.PropertiesUtils; +import java.util.List; import java.util.Optional; import static org.gridsuite.modification.NetworkModificationException.Type.*; @@ -53,11 +54,17 @@ public void apply(Network network, ReportNode subReportNode) { } // Set permanent and temporary current limits - CurrentLimitsInfos currentLimitsInfos1 = modificationInfos.getCurrentLimits1(); - CurrentLimitsInfos currentLimitsInfos2 = modificationInfos.getCurrentLimits2(); - if (currentLimitsInfos1 != null || currentLimitsInfos2 != null) { - ModificationUtils.getInstance().setCurrentLimits(currentLimitsInfos1, twoWindingsTransformer.newCurrentLimits1()); - ModificationUtils.getInstance().setCurrentLimits(currentLimitsInfos2, twoWindingsTransformer.newCurrentLimits2()); + List operationalLimitGroups1 = modificationInfos.getCurrentLimits1(); + List operationalLimitGroups2 = modificationInfos.getCurrentLimits2(); + if (operationalLimitGroups1 != null && !operationalLimitGroups1.isEmpty() || operationalLimitGroups2 != null && !operationalLimitGroups2.isEmpty()) { + ModificationUtils.getInstance().setAllCurrentLimits(operationalLimitGroups1, twoWindingsTransformer); + ModificationUtils.getInstance().setAllCurrentLimits(operationalLimitGroups2, twoWindingsTransformer); + } + if (modificationInfos.getSelectedOperationalLimitsGroupId1() != null) { + twoWindingsTransformer.setSelectedOperationalLimitsGroup1(modificationInfos.getSelectedOperationalLimitsGroupId1()); + } + if (modificationInfos.getSelectedOperationalLimitsGroupId2() != null) { + twoWindingsTransformer.setSelectedOperationalLimitsGroup2(modificationInfos.getSelectedOperationalLimitsGroupId2()); } ModificationUtils.getInstance().disconnectBranch(modificationInfos, network.getTwoWindingsTransformer(modificationInfos.getEquipmentId()), subReportNode); diff --git a/src/main/java/org/gridsuite/modification/utils/ModificationUtils.java b/src/main/java/org/gridsuite/modification/utils/ModificationUtils.java index 7614c0e..c62a20d 100644 --- a/src/main/java/org/gridsuite/modification/utils/ModificationUtils.java +++ b/src/main/java/org/gridsuite/modification/utils/ModificationUtils.java @@ -1010,25 +1010,32 @@ public Identifiable getEquipmentByIdentifiableType(Network network, Identifia }; } - public void setCurrentLimits(CurrentLimitsInfos currentLimitsInfos, CurrentLimitsAdder limitsAdder) { - if (currentLimitsInfos != null) { - boolean hasPermanent = currentLimitsInfos.getPermanentLimit() != null; - boolean hasTemporary = currentLimitsInfos.getTemporaryLimits() != null && !currentLimitsInfos.getTemporaryLimits().isEmpty(); - if (hasPermanent) { - limitsAdder.setPermanentLimit(currentLimitsInfos.getPermanentLimit()); - } - if (hasTemporary) { - for (CurrentTemporaryLimitCreationInfos limit : currentLimitsInfos.getTemporaryLimits()) { - limitsAdder - .beginTemporaryLimit() - .setName(limit.getName()) - .setValue(limit.getValue() == null ? Double.MAX_VALUE : limit.getValue()) - .setAcceptableDuration(limit.getAcceptableDuration() == null ? Integer.MAX_VALUE : limit.getAcceptableDuration()) - .endTemporaryLimit(); + /** + * adds the complete operational limit group into the line, and the selectedOperationalLimitsGroupIds + */ + public void setAllCurrentLimits(List allCurrentLimitsInfos, Branch branch) { + if (allCurrentLimitsInfos != null) { + for (CurrentLimitsInfos currentLimitsInfos : allCurrentLimitsInfos) { + OperationalLimitsGroup opGroup = branch.newOperationalLimitsGroup1(currentLimitsInfos.getOperationalLimitGroupId()); + CurrentLimitsAdder limitsAdder = opGroup.newCurrentLimits(); + boolean hasPermanent = currentLimitsInfos.getPermanentLimit() != null; + boolean hasTemporary = currentLimitsInfos.getTemporaryLimits() != null && !currentLimitsInfos.getTemporaryLimits().isEmpty(); + if (hasPermanent) { + limitsAdder.setPermanentLimit(currentLimitsInfos.getPermanentLimit()); + } + if (hasTemporary) { + for (CurrentTemporaryLimitCreationInfos limit : currentLimitsInfos.getTemporaryLimits()) { + limitsAdder + .beginTemporaryLimit() + .setName(limit.getName()) + .setValue(limit.getValue() == null ? Double.MAX_VALUE : limit.getValue()) + .setAcceptableDuration(limit.getAcceptableDuration() == null ? Integer.MAX_VALUE : limit.getAcceptableDuration()) + .endTemporaryLimit(); + } + } + if (hasPermanent || hasTemporary) { + limitsAdder.add(); } - } - if (hasPermanent || hasTemporary) { - limitsAdder.add(); } } } diff --git a/src/test/java/org/gridsuite/modification/modifications/LineCreationInBusBreakerTest.java b/src/test/java/org/gridsuite/modification/modifications/LineCreationInBusBreakerTest.java index fbab449..4567636 100644 --- a/src/test/java/org/gridsuite/modification/modifications/LineCreationInBusBreakerTest.java +++ b/src/test/java/org/gridsuite/modification/modifications/LineCreationInBusBreakerTest.java @@ -54,7 +54,9 @@ void testCreateLineOptionalParameters5() throws Exception { .busOrBusbarSectionId1("bus1") .voltageLevelId2("v2") .busOrBusbarSectionId2("bus2") - .currentLimits1(CurrentLimitsInfos.builder().permanentLimit(-1.0).build()) + .currentLimits1( + List.of(CurrentLimitsInfos.builder().permanentLimit(-1.0).build()) + ) .build(); ValidationException exception = assertThrows(ValidationException.class, () -> lineCreationInfosPermanentLimitNOK.toModification().apply(getNetwork())); assertEquals("AC Line 'idLine2': permanent limit must be >= 0", exception.getMessage()); @@ -82,8 +84,12 @@ protected ModificationInfos buildModification() { .b2(20.0) .voltageLevelId1("v1") .busOrBusbarSectionId1("bus1") - .currentLimits1(CurrentLimitsInfos.builder().permanentLimit(5.).temporaryLimits(Collections.emptyList()).build()) - .currentLimits2(CurrentLimitsInfos.builder().permanentLimit(5.).temporaryLimits(Collections.emptyList()).build()) + .currentLimits1( + List.of(CurrentLimitsInfos.builder().permanentLimit(5.).temporaryLimits(Collections.emptyList()).build()) + ) + .currentLimits2( + List.of(CurrentLimitsInfos.builder().permanentLimit(5.).temporaryLimits(Collections.emptyList()).build()) + ) .voltageLevelId2("v2") .busOrBusbarSectionId2("bus2") .properties(List.of(FreePropertyInfos.builder().name(PROPERTY_NAME).value(PROPERTY_VALUE).build())) diff --git a/src/test/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreationBusBreakerTest.java b/src/test/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreationBusBreakerTest.java index eae082c..989f4d1 100644 --- a/src/test/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreationBusBreakerTest.java +++ b/src/test/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreationBusBreakerTest.java @@ -52,8 +52,12 @@ protected ModificationInfos buildModification() { .voltageLevelId2("v12") .busOrBusbarSectionId2("bus12") .connected2(true) - .currentLimits1(CurrentLimitsInfos.builder().permanentLimit(3.).temporaryLimits(List.of(CurrentTemporaryLimitCreationInfos.builder().name("IT5").acceptableDuration(98647).value(45.).build())).build()) - .currentLimits2(CurrentLimitsInfos.builder().permanentLimit(2.).temporaryLimits(List.of(CurrentTemporaryLimitCreationInfos.builder().name("IT10").acceptableDuration(683647).value(791.).build())).build()) + .currentLimits1( + List.of(CurrentLimitsInfos.builder().permanentLimit(3.).temporaryLimits(List.of(CurrentTemporaryLimitCreationInfos.builder().name("IT5").acceptableDuration(98647).value(45.).build())).build()) + ) + .currentLimits2( + List.of(CurrentLimitsInfos.builder().permanentLimit(2.).temporaryLimits(List.of(CurrentTemporaryLimitCreationInfos.builder().name("IT10").acceptableDuration(683647).value(791.).build())).build()) + ) .connectionName1("cn201") .connectionDirection1(ConnectablePosition.Direction.TOP) .connectionName2("cn202") diff --git a/src/test/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreationNodeBreakerTest.java b/src/test/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreationNodeBreakerTest.java index d648a94..7e968de 100644 --- a/src/test/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreationNodeBreakerTest.java +++ b/src/test/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreationNodeBreakerTest.java @@ -52,8 +52,12 @@ protected ModificationInfos buildModification() { .voltageLevelId2("v2") .busOrBusbarSectionId2("1A") .connected2(true) - .currentLimits1(CurrentLimitsInfos.builder().permanentLimit(3.).temporaryLimits(List.of(CurrentTemporaryLimitCreationInfos.builder().name("IT5").acceptableDuration(2147483647).value(671.).build())).build()) - .currentLimits2(CurrentLimitsInfos.builder().permanentLimit(2.).temporaryLimits(List.of(CurrentTemporaryLimitCreationInfos.builder().name("IT10").acceptableDuration(683647).value(791.).build())).build()) + .currentLimits1( + List.of(CurrentLimitsInfos.builder().permanentLimit(3.).temporaryLimits(List.of(CurrentTemporaryLimitCreationInfos.builder().name("IT5").acceptableDuration(2147483647).value(671.).build())).build()) + ) + .currentLimits2( + List.of(CurrentLimitsInfos.builder().permanentLimit(2.).temporaryLimits(List.of(CurrentTemporaryLimitCreationInfos.builder().name("IT10").acceptableDuration(683647).value(791.).build())).build()) + ) .connectionName1("cn201") .connectionDirection1(ConnectablePosition.Direction.TOP) .connected1(true) @@ -219,7 +223,7 @@ void testCreateTwoWindingsTransformerWithRatioTapChangerInNodeBreaker() throws E testCreateTwoWindingsTransformerInNodeBreaker(twoWindingsTransformerCreationInfos2); assertEquals( - "TwoWindingsTransformerCreationInfos(super=BranchCreationInfos(super=EquipmentCreationInfos(super=EquipmentModificationInfos(super=ModificationInfos(uuid=null, type=TWO_WINDINGS_TRANSFORMER_CREATION, date=null, stashed=false, messageType=null, messageValues=null, activated=true), equipmentId=id2wt1WithRatioTapChanger2, properties=null), equipmentName=2wtName), r=400.0, x=300.0, voltageLevelId1=v1, voltageLevelId2=v4, busOrBusbarSectionId1=1.1, busOrBusbarSectionId2=1.A, currentLimits1=null, currentLimits2=null, connectionName1=null, connectionDirection1=TOP, connectionName2=null, connectionDirection2=TOP, connectionPosition1=null, connectionPosition2=null, connected1=true, connected2=true), g=100.0, b=200.0, ratedU1=1000.0, ratedU2=1010.0, ratedS=null, ratioTapChanger=RatioTapChangerCreationInfos(super=TapChangerCreationInfos(lowTapPosition=0, tapPosition=1, regulating=true, targetDeadband=null, regulatingTerminalId=v1load, regulatingTerminalType=LOAD, regulatingTerminalVlId=v1, steps=[TapChangerStepCreationInfos(index=0, rho=1.0, r=39.78473, x=39.784725, g=0.0, b=0.0, alpha=0.0), TapChangerStepCreationInfos(index=0, rho=1.0, r=39.78474, x=39.784726, g=0.0, b=0.0, alpha=0.0), TapChangerStepCreationInfos(index=0, rho=1.0, r=39.78475, x=39.784727, g=0.0, b=0.0, alpha=0.0)]), loadTapChangingCapabilities=true, targetV=220.0), phaseTapChanger=null)", + "TwoWindingsTransformerCreationInfos(super=BranchCreationInfos(super=EquipmentCreationInfos(super=EquipmentModificationInfos(super=ModificationInfos(uuid=null, type=TWO_WINDINGS_TRANSFORMER_CREATION, date=null, stashed=false, messageType=null, messageValues=null, activated=true), equipmentId=id2wt1WithRatioTapChanger2, properties=null), equipmentName=2wtName), r=400.0, x=300.0, voltageLevelId1=v1, voltageLevelId2=v4, busOrBusbarSectionId1=1.1, busOrBusbarSectionId2=1.A, currentLimits1=null, currentLimits2=null, selectedOperationalLimitsGroupId1=null, selectedOperationalLimitsGroupId2=null, connectionName1=null, connectionDirection1=TOP, connectionName2=null, connectionDirection2=TOP, connectionPosition1=null, connectionPosition2=null, connected1=true, connected2=true), g=100.0, b=200.0, ratedU1=1000.0, ratedU2=1010.0, ratedS=null, ratioTapChanger=RatioTapChangerCreationInfos(super=TapChangerCreationInfos(lowTapPosition=0, tapPosition=1, regulating=true, targetDeadband=null, regulatingTerminalId=v1load, regulatingTerminalType=LOAD, regulatingTerminalVlId=v1, steps=[TapChangerStepCreationInfos(index=0, rho=1.0, r=39.78473, x=39.784725, g=0.0, b=0.0, alpha=0.0), TapChangerStepCreationInfos(index=0, rho=1.0, r=39.78474, x=39.784726, g=0.0, b=0.0, alpha=0.0), TapChangerStepCreationInfos(index=0, rho=1.0, r=39.78475, x=39.784727, g=0.0, b=0.0, alpha=0.0)]), loadTapChangingCapabilities=true, targetV=220.0), phaseTapChanger=null)", twoWindingsTransformerCreationInfos2.toString() ); From 28ad43f6ba36b22a99f52d344d41e09348e9e7c7 Mon Sep 17 00:00:00 2001 From: Mathieu DEHARBE Date: Thu, 12 Dec 2024 11:26:45 +0100 Subject: [PATCH 02/17] back to CurrentLimitsEntity + update application Signed-off-by: Mathieu DEHARBE --- .../modification/modifications/LineCreation.java | 9 ++++++--- .../modifications/TwoWindingsTransformerCreation.java | 8 +++++--- .../modification/utils/ModificationUtils.java | 11 +++++++++-- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/gridsuite/modification/modifications/LineCreation.java b/src/main/java/org/gridsuite/modification/modifications/LineCreation.java index 84cfef8..419cb21 100644 --- a/src/main/java/org/gridsuite/modification/modifications/LineCreation.java +++ b/src/main/java/org/gridsuite/modification/modifications/LineCreation.java @@ -71,10 +71,13 @@ public void apply(Network network, ReportNode subReportNode) { // Set permanent and temporary current limits List operationalLimitGroups1 = modificationInfos.getCurrentLimits1(); List operationalLimitGroups2 = modificationInfos.getCurrentLimits2(); - if (operationalLimitGroups1 != null && !operationalLimitGroups1.isEmpty() || operationalLimitGroups2 != null && !operationalLimitGroups2.isEmpty()) { + if (operationalLimitGroups1 != null && !operationalLimitGroups1.isEmpty()) { var line = ModificationUtils.getInstance().getLine(network, modificationInfos.getEquipmentId()); - ModificationUtils.getInstance().setAllCurrentLimits(operationalLimitGroups1, line); - ModificationUtils.getInstance().setAllCurrentLimits(operationalLimitGroups2, line); + ModificationUtils.getInstance().setAllCurrentLimits(operationalLimitGroups1, line, ModificationUtils.Side.SIDE1); + } + if (operationalLimitGroups2 != null && !operationalLimitGroups2.isEmpty()) { + var line = ModificationUtils.getInstance().getLine(network, modificationInfos.getEquipmentId()); + ModificationUtils.getInstance().setAllCurrentLimits(operationalLimitGroups2, line, ModificationUtils.Side.SIDE2); } ModificationUtils.getInstance().disconnectBranch(modificationInfos, network.getLine(modificationInfos.getEquipmentId()), subReportNode); // properties diff --git a/src/main/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreation.java b/src/main/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreation.java index fef3c76..08f07a3 100644 --- a/src/main/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreation.java +++ b/src/main/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreation.java @@ -56,9 +56,11 @@ public void apply(Network network, ReportNode subReportNode) { // Set permanent and temporary current limits List operationalLimitGroups1 = modificationInfos.getCurrentLimits1(); List operationalLimitGroups2 = modificationInfos.getCurrentLimits2(); - if (operationalLimitGroups1 != null && !operationalLimitGroups1.isEmpty() || operationalLimitGroups2 != null && !operationalLimitGroups2.isEmpty()) { - ModificationUtils.getInstance().setAllCurrentLimits(operationalLimitGroups1, twoWindingsTransformer); - ModificationUtils.getInstance().setAllCurrentLimits(operationalLimitGroups2, twoWindingsTransformer); + if (operationalLimitGroups1 != null && !operationalLimitGroups1.isEmpty()) { + ModificationUtils.getInstance().setAllCurrentLimits(operationalLimitGroups1, twoWindingsTransformer, ModificationUtils.Side.SIDE1); + } + if (operationalLimitGroups2 != null && !operationalLimitGroups2.isEmpty()) { + ModificationUtils.getInstance().setAllCurrentLimits(operationalLimitGroups2, twoWindingsTransformer, ModificationUtils.Side.SIDE2); } if (modificationInfos.getSelectedOperationalLimitsGroupId1() != null) { twoWindingsTransformer.setSelectedOperationalLimitsGroup1(modificationInfos.getSelectedOperationalLimitsGroupId1()); diff --git a/src/main/java/org/gridsuite/modification/utils/ModificationUtils.java b/src/main/java/org/gridsuite/modification/utils/ModificationUtils.java index c62a20d..31ea42e 100644 --- a/src/main/java/org/gridsuite/modification/utils/ModificationUtils.java +++ b/src/main/java/org/gridsuite/modification/utils/ModificationUtils.java @@ -43,6 +43,11 @@ // TODO remove public qualifier for all methods public final class ModificationUtils { + public enum Side { + SIDE1, + SIDE2 + } + public static final String DISCONNECTOR = "disconnector_"; public static final String BREAKER = "breaker_"; public static final String BUS_BAR_SECTION_ID = "busbarSectionId"; @@ -1013,10 +1018,12 @@ public Identifiable getEquipmentByIdentifiableType(Network network, Identifia /** * adds the complete operational limit group into the line, and the selectedOperationalLimitsGroupIds */ - public void setAllCurrentLimits(List allCurrentLimitsInfos, Branch branch) { + public void setAllCurrentLimits(List allCurrentLimitsInfos, Branch branch, Side side) { if (allCurrentLimitsInfos != null) { for (CurrentLimitsInfos currentLimitsInfos : allCurrentLimitsInfos) { - OperationalLimitsGroup opGroup = branch.newOperationalLimitsGroup1(currentLimitsInfos.getOperationalLimitGroupId()); + OperationalLimitsGroup opGroup = side == Side.SIDE1 + ? branch.newOperationalLimitsGroup1(currentLimitsInfos.getOperationalLimitGroupId()) + : branch.newOperationalLimitsGroup2(currentLimitsInfos.getOperationalLimitGroupId()); CurrentLimitsAdder limitsAdder = opGroup.newCurrentLimits(); boolean hasPermanent = currentLimitsInfos.getPermanentLimit() != null; boolean hasTemporary = currentLimitsInfos.getTemporaryLimits() != null && !currentLimitsInfos.getTemporaryLimits().isEmpty(); From 1f00dc0677b90073584ddec813206c070c03b5d9 Mon Sep 17 00:00:00 2001 From: Mathieu DEHARBE Date: Thu, 12 Dec 2024 16:02:34 +0100 Subject: [PATCH 03/17] renaming Signed-off-by: Mathieu DEHARBE --- .../modification/modifications/LineCreation.java | 12 ++++++------ .../TwoWindingsTransformerCreation.java | 12 ++++++------ .../modification/utils/ModificationUtils.java | 4 +++- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/gridsuite/modification/modifications/LineCreation.java b/src/main/java/org/gridsuite/modification/modifications/LineCreation.java index 419cb21..5e3fa50 100644 --- a/src/main/java/org/gridsuite/modification/modifications/LineCreation.java +++ b/src/main/java/org/gridsuite/modification/modifications/LineCreation.java @@ -69,15 +69,15 @@ public void apply(Network network, ReportNode subReportNode) { } // Set permanent and temporary current limits - List operationalLimitGroups1 = modificationInfos.getCurrentLimits1(); - List operationalLimitGroups2 = modificationInfos.getCurrentLimits2(); - if (operationalLimitGroups1 != null && !operationalLimitGroups1.isEmpty()) { + List currentLimitsSide1 = modificationInfos.getCurrentLimits1(); + List currentLimitsSide2 = modificationInfos.getCurrentLimits2(); + if (currentLimitsSide1 != null && !currentLimitsSide1.isEmpty()) { var line = ModificationUtils.getInstance().getLine(network, modificationInfos.getEquipmentId()); - ModificationUtils.getInstance().setAllCurrentLimits(operationalLimitGroups1, line, ModificationUtils.Side.SIDE1); + ModificationUtils.getInstance().setAllCurrentLimits(currentLimitsSide1, line, ModificationUtils.Side.SIDE1); } - if (operationalLimitGroups2 != null && !operationalLimitGroups2.isEmpty()) { + if (currentLimitsSide2 != null && !currentLimitsSide2.isEmpty()) { var line = ModificationUtils.getInstance().getLine(network, modificationInfos.getEquipmentId()); - ModificationUtils.getInstance().setAllCurrentLimits(operationalLimitGroups2, line, ModificationUtils.Side.SIDE2); + ModificationUtils.getInstance().setAllCurrentLimits(currentLimitsSide2, line, ModificationUtils.Side.SIDE2); } ModificationUtils.getInstance().disconnectBranch(modificationInfos, network.getLine(modificationInfos.getEquipmentId()), subReportNode); // properties diff --git a/src/main/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreation.java b/src/main/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreation.java index 08f07a3..3400e95 100644 --- a/src/main/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreation.java +++ b/src/main/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreation.java @@ -54,13 +54,13 @@ public void apply(Network network, ReportNode subReportNode) { } // Set permanent and temporary current limits - List operationalLimitGroups1 = modificationInfos.getCurrentLimits1(); - List operationalLimitGroups2 = modificationInfos.getCurrentLimits2(); - if (operationalLimitGroups1 != null && !operationalLimitGroups1.isEmpty()) { - ModificationUtils.getInstance().setAllCurrentLimits(operationalLimitGroups1, twoWindingsTransformer, ModificationUtils.Side.SIDE1); + List currentLimitsSide1 = modificationInfos.getCurrentLimits1(); + List currentLimitsSide2 = modificationInfos.getCurrentLimits2(); + if (currentLimitsSide1 != null && !currentLimitsSide1.isEmpty()) { + ModificationUtils.getInstance().setAllCurrentLimits(currentLimitsSide1, twoWindingsTransformer, ModificationUtils.Side.SIDE1); } - if (operationalLimitGroups2 != null && !operationalLimitGroups2.isEmpty()) { - ModificationUtils.getInstance().setAllCurrentLimits(operationalLimitGroups2, twoWindingsTransformer, ModificationUtils.Side.SIDE2); + if (currentLimitsSide2 != null && !currentLimitsSide2.isEmpty()) { + ModificationUtils.getInstance().setAllCurrentLimits(currentLimitsSide2, twoWindingsTransformer, ModificationUtils.Side.SIDE2); } if (modificationInfos.getSelectedOperationalLimitsGroupId1() != null) { twoWindingsTransformer.setSelectedOperationalLimitsGroup1(modificationInfos.getSelectedOperationalLimitsGroupId1()); diff --git a/src/main/java/org/gridsuite/modification/utils/ModificationUtils.java b/src/main/java/org/gridsuite/modification/utils/ModificationUtils.java index 31ea42e..c7262a8 100644 --- a/src/main/java/org/gridsuite/modification/utils/ModificationUtils.java +++ b/src/main/java/org/gridsuite/modification/utils/ModificationUtils.java @@ -1016,7 +1016,9 @@ public Identifiable getEquipmentByIdentifiableType(Network network, Identifia } /** - * adds the complete operational limit group into the line, and the selectedOperationalLimitsGroupIds + * @param allCurrentLimitsInfos added current limits + * @param branch branch to which limits are going to be added + * @param side which side of the branch receives the limits */ public void setAllCurrentLimits(List allCurrentLimitsInfos, Branch branch, Side side) { if (allCurrentLimitsInfos != null) { From 58a77efc290f0d1bc30da746a44c7b2dd53ef50b Mon Sep 17 00:00:00 2001 From: Mathieu DEHARBE Date: Mon, 16 Dec 2024 11:20:01 +0100 Subject: [PATCH 04/17] TUs Signed-off-by: Mathieu DEHARBE --- .../modifications/LineCreation.java | 4 ++-- .../TwoWindingsTransformerCreation.java | 4 ++-- .../modification/utils/ModificationUtils.java | 2 +- .../LineCreationInBusBreakerTest.java | 9 ++++++--- ...dingsTransformerCreationBusBreakerTest.java | 18 ++++++++++++++++-- 5 files changed, 27 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/gridsuite/modification/modifications/LineCreation.java b/src/main/java/org/gridsuite/modification/modifications/LineCreation.java index 5e3fa50..4fd25ff 100644 --- a/src/main/java/org/gridsuite/modification/modifications/LineCreation.java +++ b/src/main/java/org/gridsuite/modification/modifications/LineCreation.java @@ -73,11 +73,11 @@ public void apply(Network network, ReportNode subReportNode) { List currentLimitsSide2 = modificationInfos.getCurrentLimits2(); if (currentLimitsSide1 != null && !currentLimitsSide1.isEmpty()) { var line = ModificationUtils.getInstance().getLine(network, modificationInfos.getEquipmentId()); - ModificationUtils.getInstance().setAllCurrentLimits(currentLimitsSide1, line, ModificationUtils.Side.SIDE1); + ModificationUtils.getInstance().setCurrentLimitsOnASide(currentLimitsSide1, line, ModificationUtils.Side.SIDE1); } if (currentLimitsSide2 != null && !currentLimitsSide2.isEmpty()) { var line = ModificationUtils.getInstance().getLine(network, modificationInfos.getEquipmentId()); - ModificationUtils.getInstance().setAllCurrentLimits(currentLimitsSide2, line, ModificationUtils.Side.SIDE2); + ModificationUtils.getInstance().setCurrentLimitsOnASide(currentLimitsSide2, line, ModificationUtils.Side.SIDE2); } ModificationUtils.getInstance().disconnectBranch(modificationInfos, network.getLine(modificationInfos.getEquipmentId()), subReportNode); // properties diff --git a/src/main/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreation.java b/src/main/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreation.java index 3400e95..fe1474a 100644 --- a/src/main/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreation.java +++ b/src/main/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreation.java @@ -57,10 +57,10 @@ public void apply(Network network, ReportNode subReportNode) { List currentLimitsSide1 = modificationInfos.getCurrentLimits1(); List currentLimitsSide2 = modificationInfos.getCurrentLimits2(); if (currentLimitsSide1 != null && !currentLimitsSide1.isEmpty()) { - ModificationUtils.getInstance().setAllCurrentLimits(currentLimitsSide1, twoWindingsTransformer, ModificationUtils.Side.SIDE1); + ModificationUtils.getInstance().setCurrentLimitsOnASide(currentLimitsSide1, twoWindingsTransformer, ModificationUtils.Side.SIDE1); } if (currentLimitsSide2 != null && !currentLimitsSide2.isEmpty()) { - ModificationUtils.getInstance().setAllCurrentLimits(currentLimitsSide2, twoWindingsTransformer, ModificationUtils.Side.SIDE2); + ModificationUtils.getInstance().setCurrentLimitsOnASide(currentLimitsSide2, twoWindingsTransformer, ModificationUtils.Side.SIDE2); } if (modificationInfos.getSelectedOperationalLimitsGroupId1() != null) { twoWindingsTransformer.setSelectedOperationalLimitsGroup1(modificationInfos.getSelectedOperationalLimitsGroupId1()); diff --git a/src/main/java/org/gridsuite/modification/utils/ModificationUtils.java b/src/main/java/org/gridsuite/modification/utils/ModificationUtils.java index c7262a8..5735cf0 100644 --- a/src/main/java/org/gridsuite/modification/utils/ModificationUtils.java +++ b/src/main/java/org/gridsuite/modification/utils/ModificationUtils.java @@ -1020,7 +1020,7 @@ public Identifiable getEquipmentByIdentifiableType(Network network, Identifia * @param branch branch to which limits are going to be added * @param side which side of the branch receives the limits */ - public void setAllCurrentLimits(List allCurrentLimitsInfos, Branch branch, Side side) { + public void setCurrentLimitsOnASide(List allCurrentLimitsInfos, Branch branch, Side side) { if (allCurrentLimitsInfos != null) { for (CurrentLimitsInfos currentLimitsInfos : allCurrentLimitsInfos) { OperationalLimitsGroup opGroup = side == Side.SIDE1 diff --git a/src/test/java/org/gridsuite/modification/modifications/LineCreationInBusBreakerTest.java b/src/test/java/org/gridsuite/modification/modifications/LineCreationInBusBreakerTest.java index 4567636..d63b5a0 100644 --- a/src/test/java/org/gridsuite/modification/modifications/LineCreationInBusBreakerTest.java +++ b/src/test/java/org/gridsuite/modification/modifications/LineCreationInBusBreakerTest.java @@ -55,8 +55,9 @@ void testCreateLineOptionalParameters5() throws Exception { .voltageLevelId2("v2") .busOrBusbarSectionId2("bus2") .currentLimits1( - List.of(CurrentLimitsInfos.builder().permanentLimit(-1.0).build()) + List.of(CurrentLimitsInfos.builder().operationalLimitGroupId("limiSet1").permanentLimit(-1.0).build()) ) + .selectedOperationalLimitsGroupId1("limiSet1") .build(); ValidationException exception = assertThrows(ValidationException.class, () -> lineCreationInfosPermanentLimitNOK.toModification().apply(getNetwork())); assertEquals("AC Line 'idLine2': permanent limit must be >= 0", exception.getMessage()); @@ -85,11 +86,13 @@ protected ModificationInfos buildModification() { .voltageLevelId1("v1") .busOrBusbarSectionId1("bus1") .currentLimits1( - List.of(CurrentLimitsInfos.builder().permanentLimit(5.).temporaryLimits(Collections.emptyList()).build()) + List.of(CurrentLimitsInfos.builder().operationalLimitGroupId("limitSet1").permanentLimit(5.).temporaryLimits(Collections.emptyList()).build()) ) .currentLimits2( - List.of(CurrentLimitsInfos.builder().permanentLimit(5.).temporaryLimits(Collections.emptyList()).build()) + List.of(CurrentLimitsInfos.builder().operationalLimitGroupId("limitSet2").permanentLimit(5.).temporaryLimits(Collections.emptyList()).build()) ) + .selectedOperationalLimitsGroupId1("limitSet1") + .selectedOperationalLimitsGroupId2("limitSet2") .voltageLevelId2("v2") .busOrBusbarSectionId2("bus2") .properties(List.of(FreePropertyInfos.builder().name(PROPERTY_NAME).value(PROPERTY_VALUE).build())) diff --git a/src/test/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreationBusBreakerTest.java b/src/test/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreationBusBreakerTest.java index 989f4d1..0ac501f 100644 --- a/src/test/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreationBusBreakerTest.java +++ b/src/test/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreationBusBreakerTest.java @@ -53,11 +53,25 @@ protected ModificationInfos buildModification() { .busOrBusbarSectionId2("bus12") .connected2(true) .currentLimits1( - List.of(CurrentLimitsInfos.builder().permanentLimit(3.).temporaryLimits(List.of(CurrentTemporaryLimitCreationInfos.builder().name("IT5").acceptableDuration(98647).value(45.).build())).build()) + List.of( + CurrentLimitsInfos.builder() + .operationalLimitGroupId("limitSet1") + .permanentLimit(3.) + .temporaryLimits( + List.of(CurrentTemporaryLimitCreationInfos.builder().name("IT5").acceptableDuration(98647).value(45.).build()) + ).build()) ) .currentLimits2( - List.of(CurrentLimitsInfos.builder().permanentLimit(2.).temporaryLimits(List.of(CurrentTemporaryLimitCreationInfos.builder().name("IT10").acceptableDuration(683647).value(791.).build())).build()) + List.of( + CurrentLimitsInfos.builder() + .operationalLimitGroupId("limitSet2") + .permanentLimit(2.) + .temporaryLimits( + List.of(CurrentTemporaryLimitCreationInfos.builder().name("IT10").acceptableDuration(683647).value(791.).build()) + ).build()) ) + .selectedOperationalLimitsGroupId1("limitSet1") + .selectedOperationalLimitsGroupId2("limitSet2") .connectionName1("cn201") .connectionDirection1(ConnectablePosition.Direction.TOP) .connectionName2("cn202") From 0c576512f3441b1d0ee31758caa782be6352d46c Mon Sep 17 00:00:00 2001 From: Mathieu DEHARBE Date: Mon, 16 Dec 2024 11:27:09 +0100 Subject: [PATCH 05/17] cleans Signed-off-by: Mathieu DEHARBE --- .../modification/utils/ModificationUtils.java | 46 +++++++++---------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/src/main/java/org/gridsuite/modification/utils/ModificationUtils.java b/src/main/java/org/gridsuite/modification/utils/ModificationUtils.java index 5735cf0..68cf31f 100644 --- a/src/main/java/org/gridsuite/modification/utils/ModificationUtils.java +++ b/src/main/java/org/gridsuite/modification/utils/ModificationUtils.java @@ -1020,32 +1020,30 @@ public Identifiable getEquipmentByIdentifiableType(Network network, Identifia * @param branch branch to which limits are going to be added * @param side which side of the branch receives the limits */ - public void setCurrentLimitsOnASide(List allCurrentLimitsInfos, Branch branch, Side side) { - if (allCurrentLimitsInfos != null) { - for (CurrentLimitsInfos currentLimitsInfos : allCurrentLimitsInfos) { - OperationalLimitsGroup opGroup = side == Side.SIDE1 - ? branch.newOperationalLimitsGroup1(currentLimitsInfos.getOperationalLimitGroupId()) - : branch.newOperationalLimitsGroup2(currentLimitsInfos.getOperationalLimitGroupId()); - CurrentLimitsAdder limitsAdder = opGroup.newCurrentLimits(); - boolean hasPermanent = currentLimitsInfos.getPermanentLimit() != null; - boolean hasTemporary = currentLimitsInfos.getTemporaryLimits() != null && !currentLimitsInfos.getTemporaryLimits().isEmpty(); - if (hasPermanent) { - limitsAdder.setPermanentLimit(currentLimitsInfos.getPermanentLimit()); - } - if (hasTemporary) { - for (CurrentTemporaryLimitCreationInfos limit : currentLimitsInfos.getTemporaryLimits()) { - limitsAdder - .beginTemporaryLimit() - .setName(limit.getName()) - .setValue(limit.getValue() == null ? Double.MAX_VALUE : limit.getValue()) - .setAcceptableDuration(limit.getAcceptableDuration() == null ? Integer.MAX_VALUE : limit.getAcceptableDuration()) - .endTemporaryLimit(); - } - } - if (hasPermanent || hasTemporary) { - limitsAdder.add(); + public void setCurrentLimitsOnASide(List allCurrentLimitsInfos, Branch branch, Side side) { + for (CurrentLimitsInfos currentLimitsInfos : allCurrentLimitsInfos) { + OperationalLimitsGroup opGroup = side == Side.SIDE1 + ? branch.newOperationalLimitsGroup1(currentLimitsInfos.getOperationalLimitGroupId()) + : branch.newOperationalLimitsGroup2(currentLimitsInfos.getOperationalLimitGroupId()); + CurrentLimitsAdder limitsAdder = opGroup.newCurrentLimits(); + boolean hasPermanent = currentLimitsInfos.getPermanentLimit() != null; + boolean hasTemporary = currentLimitsInfos.getTemporaryLimits() != null && !currentLimitsInfos.getTemporaryLimits().isEmpty(); + if (hasPermanent) { + limitsAdder.setPermanentLimit(currentLimitsInfos.getPermanentLimit()); + } + if (hasTemporary) { + for (CurrentTemporaryLimitCreationInfos limit : currentLimitsInfos.getTemporaryLimits()) { + limitsAdder + .beginTemporaryLimit() + .setName(limit.getName()) + .setValue(limit.getValue() == null ? Double.MAX_VALUE : limit.getValue()) + .setAcceptableDuration(limit.getAcceptableDuration() == null ? Integer.MAX_VALUE : limit.getAcceptableDuration()) + .endTemporaryLimit(); } } + if (hasPermanent || hasTemporary) { + limitsAdder.add(); + } } } From eccbc5e60d5c6a57e2c4c319fcdb20c72c1c3bee Mon Sep 17 00:00:00 2001 From: Mathieu DEHARBE Date: Mon, 16 Dec 2024 11:36:08 +0100 Subject: [PATCH 06/17] simplify Signed-off-by: Mathieu DEHARBE --- .../modification/utils/ModificationUtils.java | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/main/java/org/gridsuite/modification/utils/ModificationUtils.java b/src/main/java/org/gridsuite/modification/utils/ModificationUtils.java index 68cf31f..7238861 100644 --- a/src/main/java/org/gridsuite/modification/utils/ModificationUtils.java +++ b/src/main/java/org/gridsuite/modification/utils/ModificationUtils.java @@ -1022,26 +1022,27 @@ public Identifiable getEquipmentByIdentifiableType(Network network, Identifia */ public void setCurrentLimitsOnASide(List allCurrentLimitsInfos, Branch branch, Side side) { for (CurrentLimitsInfos currentLimitsInfos : allCurrentLimitsInfos) { - OperationalLimitsGroup opGroup = side == Side.SIDE1 - ? branch.newOperationalLimitsGroup1(currentLimitsInfos.getOperationalLimitGroupId()) - : branch.newOperationalLimitsGroup2(currentLimitsInfos.getOperationalLimitGroupId()); - CurrentLimitsAdder limitsAdder = opGroup.newCurrentLimits(); boolean hasPermanent = currentLimitsInfos.getPermanentLimit() != null; - boolean hasTemporary = currentLimitsInfos.getTemporaryLimits() != null && !currentLimitsInfos.getTemporaryLimits().isEmpty(); - if (hasPermanent) { - limitsAdder.setPermanentLimit(currentLimitsInfos.getPermanentLimit()); - } - if (hasTemporary) { - for (CurrentTemporaryLimitCreationInfos limit : currentLimitsInfos.getTemporaryLimits()) { - limitsAdder - .beginTemporaryLimit() - .setName(limit.getName()) - .setValue(limit.getValue() == null ? Double.MAX_VALUE : limit.getValue()) - .setAcceptableDuration(limit.getAcceptableDuration() == null ? Integer.MAX_VALUE : limit.getAcceptableDuration()) - .endTemporaryLimit(); + boolean hasTemporary = CollectionUtils.isEmpty(currentLimitsInfos.getTemporaryLimits()); + boolean hasLimits = hasPermanent || hasTemporary; + if (hasLimits) { + OperationalLimitsGroup opGroup = side == Side.SIDE1 + ? branch.newOperationalLimitsGroup1(currentLimitsInfos.getOperationalLimitGroupId()) + : branch.newOperationalLimitsGroup2(currentLimitsInfos.getOperationalLimitGroupId()); + CurrentLimitsAdder limitsAdder = opGroup.newCurrentLimits(); + if (hasPermanent) { + limitsAdder.setPermanentLimit(currentLimitsInfos.getPermanentLimit()); + } + if (hasTemporary) { + for (CurrentTemporaryLimitCreationInfos limit : currentLimitsInfos.getTemporaryLimits()) { + limitsAdder + .beginTemporaryLimit() + .setName(limit.getName()) + .setValue(limit.getValue() == null ? Double.MAX_VALUE : limit.getValue()) + .setAcceptableDuration(limit.getAcceptableDuration() == null ? Integer.MAX_VALUE : limit.getAcceptableDuration()) + .endTemporaryLimit(); + } } - } - if (hasPermanent || hasTemporary) { limitsAdder.add(); } } From d05d9bec88839e815b29be325e761090aef7967d Mon Sep 17 00:00:00 2001 From: Mathieu DEHARBE Date: Mon, 16 Dec 2024 11:41:37 +0100 Subject: [PATCH 07/17] correction Signed-off-by: Mathieu DEHARBE --- .../org/gridsuite/modification/utils/ModificationUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/gridsuite/modification/utils/ModificationUtils.java b/src/main/java/org/gridsuite/modification/utils/ModificationUtils.java index 7238861..3f666ca 100644 --- a/src/main/java/org/gridsuite/modification/utils/ModificationUtils.java +++ b/src/main/java/org/gridsuite/modification/utils/ModificationUtils.java @@ -1023,7 +1023,7 @@ public Identifiable getEquipmentByIdentifiableType(Network network, Identifia public void setCurrentLimitsOnASide(List allCurrentLimitsInfos, Branch branch, Side side) { for (CurrentLimitsInfos currentLimitsInfos : allCurrentLimitsInfos) { boolean hasPermanent = currentLimitsInfos.getPermanentLimit() != null; - boolean hasTemporary = CollectionUtils.isEmpty(currentLimitsInfos.getTemporaryLimits()); + boolean hasTemporary = !CollectionUtils.isEmpty(currentLimitsInfos.getTemporaryLimits()); boolean hasLimits = hasPermanent || hasTemporary; if (hasLimits) { OperationalLimitsGroup opGroup = side == Side.SIDE1 From 5eae6c813b860f10e5433ea81daa559efd2cdaf3 Mon Sep 17 00:00:00 2001 From: Mathieu DEHARBE Date: Wed, 18 Dec 2024 15:16:38 +0100 Subject: [PATCH 08/17] adds OperationalLimitsGroupInfos Signed-off-by: Mathieu DEHARBE --- .../modification/dto/BranchCreationInfos.java | 8 ++-- .../modification/dto/CurrentLimitsInfos.java | 4 -- .../dto/OperationalLimitsGroupInfos.java | 22 ++++++++++ .../modifications/LineCreation.java | 16 ++++---- .../TwoWindingsTransformerCreation.java | 12 +++--- .../modification/utils/ModificationUtils.java | 34 +++++++--------- .../LineCreationInBusBreakerTest.java | 35 +++++++++++----- ...ingsTransformerCreationBusBreakerTest.java | 40 +++++++++++-------- ...ngsTransformerCreationNodeBreakerTest.java | 21 +++++++--- 9 files changed, 121 insertions(+), 71 deletions(-) create mode 100644 src/main/java/org/gridsuite/modification/dto/OperationalLimitsGroupInfos.java diff --git a/src/main/java/org/gridsuite/modification/dto/BranchCreationInfos.java b/src/main/java/org/gridsuite/modification/dto/BranchCreationInfos.java index a2bc4c4..11da782 100644 --- a/src/main/java/org/gridsuite/modification/dto/BranchCreationInfos.java +++ b/src/main/java/org/gridsuite/modification/dto/BranchCreationInfos.java @@ -45,11 +45,11 @@ public class BranchCreationInfos extends EquipmentCreationInfos { @Schema(description = "Bus or Busbar section id Side 2") private String busOrBusbarSectionId2; - @Schema(description = "Current limits on side 1") - private List currentLimits1; + @Schema(description = "Operational limit groups on side 1") + private List operationalLimitsGroup1; - @Schema(description = "Current limits on side 2") - private List currentLimits2; + @Schema(description = "Operational limit groups on side 2") + private List operationalLimitsGroup2; @Schema(description = "Selected operational limits group id on Side 1") private String selectedOperationalLimitsGroupId1; diff --git a/src/main/java/org/gridsuite/modification/dto/CurrentLimitsInfos.java b/src/main/java/org/gridsuite/modification/dto/CurrentLimitsInfos.java index 2cc5a5d..edece28 100644 --- a/src/main/java/org/gridsuite/modification/dto/CurrentLimitsInfos.java +++ b/src/main/java/org/gridsuite/modification/dto/CurrentLimitsInfos.java @@ -14,7 +14,6 @@ /** * @author Sylvain Bouzols - * ~= environ operational limit group, ~= limit set */ @SuperBuilder @@ -25,9 +24,6 @@ @Schema(description = "Current Limits") public class CurrentLimitsInfos { - @Schema(description = "Operational limit group name") - private String operationalLimitGroupId; - @Schema(description = "Permanent current limit") private Double permanentLimit; diff --git a/src/main/java/org/gridsuite/modification/dto/OperationalLimitsGroupInfos.java b/src/main/java/org/gridsuite/modification/dto/OperationalLimitsGroupInfos.java new file mode 100644 index 0000000..f35b9a6 --- /dev/null +++ b/src/main/java/org/gridsuite/modification/dto/OperationalLimitsGroupInfos.java @@ -0,0 +1,22 @@ +package org.gridsuite.modification.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.SuperBuilder; + +@SuperBuilder +@NoArgsConstructor +@Getter +@Setter +@ToString +@Schema(description = "Operational limits group") +public class OperationalLimitsGroupInfos { + @Schema(description = "Operational limit group id") + private String id; + + @Schema(description = "Current limits") + private CurrentLimitsInfos currentLimits; +} diff --git a/src/main/java/org/gridsuite/modification/modifications/LineCreation.java b/src/main/java/org/gridsuite/modification/modifications/LineCreation.java index 4fd25ff..e92cf2e 100644 --- a/src/main/java/org/gridsuite/modification/modifications/LineCreation.java +++ b/src/main/java/org/gridsuite/modification/modifications/LineCreation.java @@ -12,13 +12,15 @@ import com.powsybl.iidm.modification.topology.CreateBranchFeederBaysBuilder; import com.powsybl.iidm.network.*; import org.gridsuite.modification.NetworkModificationException; -import org.gridsuite.modification.dto.CurrentLimitsInfos; import org.gridsuite.modification.dto.LineCreationInfos; +import org.gridsuite.modification.dto.OperationalLimitsGroupInfos; import org.gridsuite.modification.utils.ModificationUtils; import org.gridsuite.modification.utils.PropertiesUtils; import java.util.List; +import static com.powsybl.iidm.network.TwoSides.ONE; +import static com.powsybl.iidm.network.TwoSides.TWO; import static org.gridsuite.modification.NetworkModificationException.Type.*; /** @@ -69,15 +71,15 @@ public void apply(Network network, ReportNode subReportNode) { } // Set permanent and temporary current limits - List currentLimitsSide1 = modificationInfos.getCurrentLimits1(); - List currentLimitsSide2 = modificationInfos.getCurrentLimits2(); - if (currentLimitsSide1 != null && !currentLimitsSide1.isEmpty()) { + List opLimitsGroupSide1 = modificationInfos.getOperationalLimitsGroup1(); + List opLimitsGroupSide2 = modificationInfos.getOperationalLimitsGroup2(); + if (opLimitsGroupSide1 != null && !opLimitsGroupSide1.isEmpty()) { var line = ModificationUtils.getInstance().getLine(network, modificationInfos.getEquipmentId()); - ModificationUtils.getInstance().setCurrentLimitsOnASide(currentLimitsSide1, line, ModificationUtils.Side.SIDE1); + ModificationUtils.getInstance().setCurrentLimitsOnASide(opLimitsGroupSide1, line, ONE); } - if (currentLimitsSide2 != null && !currentLimitsSide2.isEmpty()) { + if (opLimitsGroupSide2 != null && !opLimitsGroupSide2.isEmpty()) { var line = ModificationUtils.getInstance().getLine(network, modificationInfos.getEquipmentId()); - ModificationUtils.getInstance().setCurrentLimitsOnASide(currentLimitsSide2, line, ModificationUtils.Side.SIDE2); + ModificationUtils.getInstance().setCurrentLimitsOnASide(opLimitsGroupSide2, line, TWO); } ModificationUtils.getInstance().disconnectBranch(modificationInfos, network.getLine(modificationInfos.getEquipmentId()), subReportNode); // properties diff --git a/src/main/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreation.java b/src/main/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreation.java index fe1474a..88d125a 100644 --- a/src/main/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreation.java +++ b/src/main/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreation.java @@ -54,13 +54,13 @@ public void apply(Network network, ReportNode subReportNode) { } // Set permanent and temporary current limits - List currentLimitsSide1 = modificationInfos.getCurrentLimits1(); - List currentLimitsSide2 = modificationInfos.getCurrentLimits2(); - if (currentLimitsSide1 != null && !currentLimitsSide1.isEmpty()) { - ModificationUtils.getInstance().setCurrentLimitsOnASide(currentLimitsSide1, twoWindingsTransformer, ModificationUtils.Side.SIDE1); + List opLimitsGroupSide1 = modificationInfos.getOperationalLimitsGroup1(); + List opLimitsGroupSide2 = modificationInfos.getOperationalLimitsGroup2(); + if (opLimitsGroupSide1 != null && !opLimitsGroupSide1.isEmpty()) { + ModificationUtils.getInstance().setCurrentLimitsOnASide(opLimitsGroupSide1, twoWindingsTransformer, TwoSides.ONE); } - if (currentLimitsSide2 != null && !currentLimitsSide2.isEmpty()) { - ModificationUtils.getInstance().setCurrentLimitsOnASide(currentLimitsSide2, twoWindingsTransformer, ModificationUtils.Side.SIDE2); + if (opLimitsGroupSide2 != null && !opLimitsGroupSide2.isEmpty()) { + ModificationUtils.getInstance().setCurrentLimitsOnASide(opLimitsGroupSide2, twoWindingsTransformer, TwoSides.TWO); } if (modificationInfos.getSelectedOperationalLimitsGroupId1() != null) { twoWindingsTransformer.setSelectedOperationalLimitsGroup1(modificationInfos.getSelectedOperationalLimitsGroupId1()); diff --git a/src/main/java/org/gridsuite/modification/utils/ModificationUtils.java b/src/main/java/org/gridsuite/modification/utils/ModificationUtils.java index 3f666ca..215c7e8 100644 --- a/src/main/java/org/gridsuite/modification/utils/ModificationUtils.java +++ b/src/main/java/org/gridsuite/modification/utils/ModificationUtils.java @@ -34,6 +34,7 @@ import javax.annotation.Nullable; +import static com.powsybl.iidm.network.TwoSides.ONE; import static org.gridsuite.modification.NetworkModificationException.Type.*; /** @@ -43,11 +44,6 @@ // TODO remove public qualifier for all methods public final class ModificationUtils { - public enum Side { - SIDE1, - SIDE2 - } - public static final String DISCONNECTOR = "disconnector_"; public static final String BREAKER = "breaker_"; public static final String BUS_BAR_SECTION_ID = "busbarSectionId"; @@ -445,7 +441,7 @@ public LineAdder createLineAdder(Network network, VoltageLevel voltageLevel1, Vo .setB2(lineCreationInfos.getB2() != null ? lineCreationInfos.getB2() : 0.0); // lineAdder completion by topology - setBranchAdderNodeOrBus(lineAdder, voltageLevel1, lineCreationInfos, TwoSides.ONE, withSwitch1); + setBranchAdderNodeOrBus(lineAdder, voltageLevel1, lineCreationInfos, ONE, withSwitch1); setBranchAdderNodeOrBus(lineAdder, voltageLevel2, lineCreationInfos, TwoSides.TWO, withSwitch2); return lineAdder; @@ -453,7 +449,7 @@ public LineAdder createLineAdder(Network network, VoltageLevel voltageLevel1, Vo public void setBranchAdderNodeOrBus(BranchAdder branchAdder, VoltageLevel voltageLevel, BranchCreationInfos branchCreationInfos, TwoSides side, boolean withSwitch) { - String busOrBusbarSectionId = (side == TwoSides.ONE) ? branchCreationInfos.getBusOrBusbarSectionId1() : branchCreationInfos.getBusOrBusbarSectionId2(); + String busOrBusbarSectionId = (side == ONE) ? branchCreationInfos.getBusOrBusbarSectionId1() : branchCreationInfos.getBusOrBusbarSectionId2(); if (voltageLevel.getTopologyKind() == TopologyKind.BUS_BREAKER) { setBranchAdderBusBreaker(branchAdder, voltageLevel, side, busOrBusbarSectionId); } else { @@ -467,7 +463,7 @@ private void setBranchAdderBusBreaker(BranchAdder branchAdder, VoltageLeve Bus bus = getBusBreakerBus(voltageLevel, busId); // complete the lineAdder - if (side == TwoSides.ONE) { + if (side == ONE) { branchAdder.setBus1(bus.getId()).setConnectableBus1(bus.getId()); } else { branchAdder.setBus2(bus.getId()).setConnectableBus2(bus.getId()); @@ -486,7 +482,7 @@ private void setBranchAdderNodeBreaker(BranchAdder branchAdder, VoltageLev sideSuffix); // complete the lineAdder - if (side == TwoSides.ONE) { + if (side == ONE) { branchAdder.setNode1(nodeNum); } else { branchAdder.setNode2(nodeNum); @@ -1016,25 +1012,25 @@ public Identifiable getEquipmentByIdentifiableType(Network network, Identifia } /** - * @param allCurrentLimitsInfos added current limits + * @param opLimitGroups added current limits * @param branch branch to which limits are going to be added * @param side which side of the branch receives the limits */ - public void setCurrentLimitsOnASide(List allCurrentLimitsInfos, Branch branch, Side side) { - for (CurrentLimitsInfos currentLimitsInfos : allCurrentLimitsInfos) { - boolean hasPermanent = currentLimitsInfos.getPermanentLimit() != null; - boolean hasTemporary = !CollectionUtils.isEmpty(currentLimitsInfos.getTemporaryLimits()); + public void setCurrentLimitsOnASide(List opLimitGroups, Branch branch, TwoSides side) { + for (OperationalLimitsGroupInfos opLimitsGroup : opLimitGroups) { + boolean hasPermanent = opLimitsGroup.getCurrentLimits().getPermanentLimit() != null; + boolean hasTemporary = !CollectionUtils.isEmpty(opLimitsGroup.getCurrentLimits().getTemporaryLimits()); boolean hasLimits = hasPermanent || hasTemporary; if (hasLimits) { - OperationalLimitsGroup opGroup = side == Side.SIDE1 - ? branch.newOperationalLimitsGroup1(currentLimitsInfos.getOperationalLimitGroupId()) - : branch.newOperationalLimitsGroup2(currentLimitsInfos.getOperationalLimitGroupId()); + OperationalLimitsGroup opGroup = side == ONE + ? branch.newOperationalLimitsGroup1(opLimitsGroup.getId()) + : branch.newOperationalLimitsGroup2(opLimitsGroup.getId()); CurrentLimitsAdder limitsAdder = opGroup.newCurrentLimits(); if (hasPermanent) { - limitsAdder.setPermanentLimit(currentLimitsInfos.getPermanentLimit()); + limitsAdder.setPermanentLimit(opLimitsGroup.getCurrentLimits().getPermanentLimit()); } if (hasTemporary) { - for (CurrentTemporaryLimitCreationInfos limit : currentLimitsInfos.getTemporaryLimits()) { + for (CurrentTemporaryLimitCreationInfos limit : opLimitsGroup.getCurrentLimits().getTemporaryLimits()) { limitsAdder .beginTemporaryLimit() .setName(limit.getName()) diff --git a/src/test/java/org/gridsuite/modification/modifications/LineCreationInBusBreakerTest.java b/src/test/java/org/gridsuite/modification/modifications/LineCreationInBusBreakerTest.java index d63b5a0..ca84492 100644 --- a/src/test/java/org/gridsuite/modification/modifications/LineCreationInBusBreakerTest.java +++ b/src/test/java/org/gridsuite/modification/modifications/LineCreationInBusBreakerTest.java @@ -11,10 +11,7 @@ import com.powsybl.iidm.network.ValidationException; import org.gridsuite.modification.NetworkModificationException; -import org.gridsuite.modification.dto.CurrentLimitsInfos; -import org.gridsuite.modification.dto.FreePropertyInfos; -import org.gridsuite.modification.dto.LineCreationInfos; -import org.gridsuite.modification.dto.ModificationInfos; +import org.gridsuite.modification.dto.*; import org.gridsuite.modification.utils.NetworkCreation; import org.junit.jupiter.api.Test; import java.util.Collections; @@ -54,8 +51,14 @@ void testCreateLineOptionalParameters5() throws Exception { .busOrBusbarSectionId1("bus1") .voltageLevelId2("v2") .busOrBusbarSectionId2("bus2") - .currentLimits1( - List.of(CurrentLimitsInfos.builder().operationalLimitGroupId("limiSet1").permanentLimit(-1.0).build()) + .operationalLimitsGroup1( + List.of( + OperationalLimitsGroupInfos.builder() + .id("limiSet1") + .currentLimits( + CurrentLimitsInfos.builder().permanentLimit(-1.0).build() + ).build() + ) ) .selectedOperationalLimitsGroupId1("limiSet1") .build(); @@ -85,11 +88,23 @@ protected ModificationInfos buildModification() { .b2(20.0) .voltageLevelId1("v1") .busOrBusbarSectionId1("bus1") - .currentLimits1( - List.of(CurrentLimitsInfos.builder().operationalLimitGroupId("limitSet1").permanentLimit(5.).temporaryLimits(Collections.emptyList()).build()) + .operationalLimitsGroup1( + List.of( + OperationalLimitsGroupInfos.builder() + .id("limitSet1") + .currentLimits( + CurrentLimitsInfos.builder().permanentLimit(5.).temporaryLimits(Collections.emptyList()).build() + ).build() + ) ) - .currentLimits2( - List.of(CurrentLimitsInfos.builder().operationalLimitGroupId("limitSet2").permanentLimit(5.).temporaryLimits(Collections.emptyList()).build()) + .operationalLimitsGroup1( + List.of( + OperationalLimitsGroupInfos.builder() + .id("limitSet2") + .currentLimits( + CurrentLimitsInfos.builder().permanentLimit(5.).temporaryLimits(Collections.emptyList()).build() + ).build() + ) ) .selectedOperationalLimitsGroupId1("limitSet1") .selectedOperationalLimitsGroupId2("limitSet2") diff --git a/src/test/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreationBusBreakerTest.java b/src/test/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreationBusBreakerTest.java index 0ac501f..cab8217 100644 --- a/src/test/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreationBusBreakerTest.java +++ b/src/test/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreationBusBreakerTest.java @@ -52,23 +52,31 @@ protected ModificationInfos buildModification() { .voltageLevelId2("v12") .busOrBusbarSectionId2("bus12") .connected2(true) - .currentLimits1( - List.of( - CurrentLimitsInfos.builder() - .operationalLimitGroupId("limitSet1") - .permanentLimit(3.) - .temporaryLimits( - List.of(CurrentTemporaryLimitCreationInfos.builder().name("IT5").acceptableDuration(98647).value(45.).build()) - ).build()) + .operationalLimitsGroup1( + List.of( + OperationalLimitsGroupInfos.builder() + .id("limitSet1") + .currentLimits( + CurrentLimitsInfos.builder() + .permanentLimit(3.) + .temporaryLimits( + List.of(CurrentTemporaryLimitCreationInfos.builder().name("IT5").acceptableDuration(98647).value(45.).build()) + ).build() + ).build() + ) ) - .currentLimits2( - List.of( - CurrentLimitsInfos.builder() - .operationalLimitGroupId("limitSet2") - .permanentLimit(2.) - .temporaryLimits( - List.of(CurrentTemporaryLimitCreationInfos.builder().name("IT10").acceptableDuration(683647).value(791.).build()) - ).build()) + .operationalLimitsGroup2( + List.of( + OperationalLimitsGroupInfos.builder() + .id("limitSet2") + .currentLimits( + CurrentLimitsInfos.builder() + .permanentLimit(2.) + .temporaryLimits( + List.of(CurrentTemporaryLimitCreationInfos.builder().name("IT10").acceptableDuration(683647).value(791.).build()) + ).build()) + .build() + ) ) .selectedOperationalLimitsGroupId1("limitSet1") .selectedOperationalLimitsGroupId2("limitSet2") diff --git a/src/test/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreationNodeBreakerTest.java b/src/test/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreationNodeBreakerTest.java index 7e968de..3ef24b3 100644 --- a/src/test/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreationNodeBreakerTest.java +++ b/src/test/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreationNodeBreakerTest.java @@ -15,6 +15,7 @@ import org.gridsuite.modification.dto.*; import org.gridsuite.modification.utils.NetworkCreation; import org.junit.jupiter.api.Test; + import java.util.List; import java.util.Map; import java.util.UUID; @@ -52,11 +53,21 @@ protected ModificationInfos buildModification() { .voltageLevelId2("v2") .busOrBusbarSectionId2("1A") .connected2(true) - .currentLimits1( - List.of(CurrentLimitsInfos.builder().permanentLimit(3.).temporaryLimits(List.of(CurrentTemporaryLimitCreationInfos.builder().name("IT5").acceptableDuration(2147483647).value(671.).build())).build()) + .operationalLimitsGroup1( + List.of( + OperationalLimitsGroupInfos.builder() + .currentLimits( + CurrentLimitsInfos.builder().permanentLimit(3.).temporaryLimits(List.of(CurrentTemporaryLimitCreationInfos.builder().name("IT5").acceptableDuration(2147483647).value(671.).build())).build() + ).build() + ) ) - .currentLimits2( - List.of(CurrentLimitsInfos.builder().permanentLimit(2.).temporaryLimits(List.of(CurrentTemporaryLimitCreationInfos.builder().name("IT10").acceptableDuration(683647).value(791.).build())).build()) + .operationalLimitsGroup1( + List.of( + OperationalLimitsGroupInfos.builder() + .currentLimits( + CurrentLimitsInfos.builder().permanentLimit(2.).temporaryLimits(List.of(CurrentTemporaryLimitCreationInfos.builder().name("IT10").acceptableDuration(683647).value(791.).build())).build() + ).build() + ) ) .connectionName1("cn201") .connectionDirection1(ConnectablePosition.Direction.TOP) @@ -223,7 +234,7 @@ void testCreateTwoWindingsTransformerWithRatioTapChangerInNodeBreaker() throws E testCreateTwoWindingsTransformerInNodeBreaker(twoWindingsTransformerCreationInfos2); assertEquals( - "TwoWindingsTransformerCreationInfos(super=BranchCreationInfos(super=EquipmentCreationInfos(super=EquipmentModificationInfos(super=ModificationInfos(uuid=null, type=TWO_WINDINGS_TRANSFORMER_CREATION, date=null, stashed=false, messageType=null, messageValues=null, activated=true), equipmentId=id2wt1WithRatioTapChanger2, properties=null), equipmentName=2wtName), r=400.0, x=300.0, voltageLevelId1=v1, voltageLevelId2=v4, busOrBusbarSectionId1=1.1, busOrBusbarSectionId2=1.A, currentLimits1=null, currentLimits2=null, selectedOperationalLimitsGroupId1=null, selectedOperationalLimitsGroupId2=null, connectionName1=null, connectionDirection1=TOP, connectionName2=null, connectionDirection2=TOP, connectionPosition1=null, connectionPosition2=null, connected1=true, connected2=true), g=100.0, b=200.0, ratedU1=1000.0, ratedU2=1010.0, ratedS=null, ratioTapChanger=RatioTapChangerCreationInfos(super=TapChangerCreationInfos(lowTapPosition=0, tapPosition=1, regulating=true, targetDeadband=null, regulatingTerminalId=v1load, regulatingTerminalType=LOAD, regulatingTerminalVlId=v1, steps=[TapChangerStepCreationInfos(index=0, rho=1.0, r=39.78473, x=39.784725, g=0.0, b=0.0, alpha=0.0), TapChangerStepCreationInfos(index=0, rho=1.0, r=39.78474, x=39.784726, g=0.0, b=0.0, alpha=0.0), TapChangerStepCreationInfos(index=0, rho=1.0, r=39.78475, x=39.784727, g=0.0, b=0.0, alpha=0.0)]), loadTapChangingCapabilities=true, targetV=220.0), phaseTapChanger=null)", + "TwoWindingsTransformerCreationInfos(super=BranchCreationInfos(super=EquipmentCreationInfos(super=EquipmentModificationInfos(super=ModificationInfos(uuid=null, type=TWO_WINDINGS_TRANSFORMER_CREATION, date=null, stashed=false, messageType=null, messageValues=null, activated=true), equipmentId=id2wt1WithRatioTapChanger2, properties=null), equipmentName=2wtName), r=400.0, x=300.0, voltageLevelId1=v1, voltageLevelId2=v4, busOrBusbarSectionId1=1.1, busOrBusbarSectionId2=1.A, operationalLimitsGroup1=null, operationalLimitsGroup2=null, selectedOperationalLimitsGroupId1=null, selectedOperationalLimitsGroupId2=null, connectionName1=null, connectionDirection1=TOP, connectionName2=null, connectionDirection2=TOP, connectionPosition1=null, connectionPosition2=null, connected1=true, connected2=true), g=100.0, b=200.0, ratedU1=1000.0, ratedU2=1010.0, ratedS=null, ratioTapChanger=RatioTapChangerCreationInfos(super=TapChangerCreationInfos(lowTapPosition=0, tapPosition=1, regulating=true, targetDeadband=null, regulatingTerminalId=v1load, regulatingTerminalType=LOAD, regulatingTerminalVlId=v1, steps=[TapChangerStepCreationInfos(index=0, rho=1.0, r=39.78473, x=39.784725, g=0.0, b=0.0, alpha=0.0), TapChangerStepCreationInfos(index=0, rho=1.0, r=39.78474, x=39.784726, g=0.0, b=0.0, alpha=0.0), TapChangerStepCreationInfos(index=0, rho=1.0, r=39.78475, x=39.784727, g=0.0, b=0.0, alpha=0.0)]), loadTapChangingCapabilities=true, targetV=220.0), phaseTapChanger=null)", twoWindingsTransformerCreationInfos2.toString() ); From ad86424f2fd2872cf0cc3f76061b89896409436b Mon Sep 17 00:00:00 2001 From: Mathieu DEHARBE Date: Wed, 18 Dec 2024 15:22:53 +0100 Subject: [PATCH 09/17] !CollectionUtils.isEmpty( Signed-off-by: Mathieu DEHARBE --- .../gridsuite/modification/modifications/LineCreation.java | 5 +++-- .../modifications/TwoWindingsTransformerCreation.java | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/gridsuite/modification/modifications/LineCreation.java b/src/main/java/org/gridsuite/modification/modifications/LineCreation.java index e92cf2e..3312220 100644 --- a/src/main/java/org/gridsuite/modification/modifications/LineCreation.java +++ b/src/main/java/org/gridsuite/modification/modifications/LineCreation.java @@ -11,6 +11,7 @@ import com.powsybl.iidm.modification.topology.CreateBranchFeederBays; import com.powsybl.iidm.modification.topology.CreateBranchFeederBaysBuilder; import com.powsybl.iidm.network.*; +import org.apache.commons.collections4.CollectionUtils; import org.gridsuite.modification.NetworkModificationException; import org.gridsuite.modification.dto.LineCreationInfos; import org.gridsuite.modification.dto.OperationalLimitsGroupInfos; @@ -73,11 +74,11 @@ public void apply(Network network, ReportNode subReportNode) { // Set permanent and temporary current limits List opLimitsGroupSide1 = modificationInfos.getOperationalLimitsGroup1(); List opLimitsGroupSide2 = modificationInfos.getOperationalLimitsGroup2(); - if (opLimitsGroupSide1 != null && !opLimitsGroupSide1.isEmpty()) { + if (!CollectionUtils.isEmpty(opLimitsGroupSide1)) { var line = ModificationUtils.getInstance().getLine(network, modificationInfos.getEquipmentId()); ModificationUtils.getInstance().setCurrentLimitsOnASide(opLimitsGroupSide1, line, ONE); } - if (opLimitsGroupSide2 != null && !opLimitsGroupSide2.isEmpty()) { + if (!CollectionUtils.isEmpty(opLimitsGroupSide2)) { var line = ModificationUtils.getInstance().getLine(network, modificationInfos.getEquipmentId()); ModificationUtils.getInstance().setCurrentLimitsOnASide(opLimitsGroupSide2, line, TWO); } diff --git a/src/main/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreation.java b/src/main/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreation.java index 88d125a..26da92c 100644 --- a/src/main/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreation.java +++ b/src/main/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreation.java @@ -11,6 +11,7 @@ import com.powsybl.iidm.modification.topology.CreateBranchFeederBays; import com.powsybl.iidm.modification.topology.CreateBranchFeederBaysBuilder; import com.powsybl.iidm.network.*; +import org.apache.commons.collections4.CollectionUtils; import org.gridsuite.modification.NetworkModificationException; import org.gridsuite.modification.dto.*; import org.gridsuite.modification.utils.ModificationUtils; @@ -56,10 +57,10 @@ public void apply(Network network, ReportNode subReportNode) { // Set permanent and temporary current limits List opLimitsGroupSide1 = modificationInfos.getOperationalLimitsGroup1(); List opLimitsGroupSide2 = modificationInfos.getOperationalLimitsGroup2(); - if (opLimitsGroupSide1 != null && !opLimitsGroupSide1.isEmpty()) { + if (!CollectionUtils.isEmpty(opLimitsGroupSide1)) { ModificationUtils.getInstance().setCurrentLimitsOnASide(opLimitsGroupSide1, twoWindingsTransformer, TwoSides.ONE); } - if (opLimitsGroupSide2 != null && !opLimitsGroupSide2.isEmpty()) { + if (!CollectionUtils.isEmpty(opLimitsGroupSide2)) { ModificationUtils.getInstance().setCurrentLimitsOnASide(opLimitsGroupSide2, twoWindingsTransformer, TwoSides.TWO); } if (modificationInfos.getSelectedOperationalLimitsGroupId1() != null) { From 13d096f6d4cc442f381f8f19c75956193be4a242 Mon Sep 17 00:00:00 2001 From: Mathieu DEHARBE Date: Thu, 19 Dec 2024 10:44:51 +0100 Subject: [PATCH 10/17] OperationalLimitsGroupEntity and everything that uses it Signed-off-by: Mathieu DEHARBE --- .../org/gridsuite/modification/dto/BranchCreationInfos.java | 4 ++-- .../modification/dto/OperationalLimitsGroupInfos.java | 6 ++++++ .../gridsuite/modification/modifications/LineCreation.java | 4 ++-- .../modifications/TwoWindingsTransformerCreation.java | 4 ++-- .../modifications/LineCreationInBusBreakerTest.java | 6 +++--- .../TwoWindingsTransformerCreationBusBreakerTest.java | 4 ++-- .../TwoWindingsTransformerCreationNodeBreakerTest.java | 6 +++--- 7 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/main/java/org/gridsuite/modification/dto/BranchCreationInfos.java b/src/main/java/org/gridsuite/modification/dto/BranchCreationInfos.java index 11da782..c0f4ed3 100644 --- a/src/main/java/org/gridsuite/modification/dto/BranchCreationInfos.java +++ b/src/main/java/org/gridsuite/modification/dto/BranchCreationInfos.java @@ -46,10 +46,10 @@ public class BranchCreationInfos extends EquipmentCreationInfos { private String busOrBusbarSectionId2; @Schema(description = "Operational limit groups on side 1") - private List operationalLimitsGroup1; + private List operationalLimitsGroups1; @Schema(description = "Operational limit groups on side 2") - private List operationalLimitsGroup2; + private List operationalLimitsGroups2; @Schema(description = "Selected operational limits group id on Side 1") private String selectedOperationalLimitsGroupId1; diff --git a/src/main/java/org/gridsuite/modification/dto/OperationalLimitsGroupInfos.java b/src/main/java/org/gridsuite/modification/dto/OperationalLimitsGroupInfos.java index f35b9a6..7872c28 100644 --- a/src/main/java/org/gridsuite/modification/dto/OperationalLimitsGroupInfos.java +++ b/src/main/java/org/gridsuite/modification/dto/OperationalLimitsGroupInfos.java @@ -1,3 +1,9 @@ +/* + Copyright (c) 2024, RTE (http://www.rte-france.com) + This Source Code Form is subject to the terms of the Mozilla Public + 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/. + */ package org.gridsuite.modification.dto; import io.swagger.v3.oas.annotations.media.Schema; diff --git a/src/main/java/org/gridsuite/modification/modifications/LineCreation.java b/src/main/java/org/gridsuite/modification/modifications/LineCreation.java index 3312220..9a2bd72 100644 --- a/src/main/java/org/gridsuite/modification/modifications/LineCreation.java +++ b/src/main/java/org/gridsuite/modification/modifications/LineCreation.java @@ -72,8 +72,8 @@ public void apply(Network network, ReportNode subReportNode) { } // Set permanent and temporary current limits - List opLimitsGroupSide1 = modificationInfos.getOperationalLimitsGroup1(); - List opLimitsGroupSide2 = modificationInfos.getOperationalLimitsGroup2(); + List opLimitsGroupSide1 = modificationInfos.getOperationalLimitsGroups1(); + List opLimitsGroupSide2 = modificationInfos.getOperationalLimitsGroups2(); if (!CollectionUtils.isEmpty(opLimitsGroupSide1)) { var line = ModificationUtils.getInstance().getLine(network, modificationInfos.getEquipmentId()); ModificationUtils.getInstance().setCurrentLimitsOnASide(opLimitsGroupSide1, line, ONE); diff --git a/src/main/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreation.java b/src/main/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreation.java index 26da92c..38a8dcd 100644 --- a/src/main/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreation.java +++ b/src/main/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreation.java @@ -55,8 +55,8 @@ public void apply(Network network, ReportNode subReportNode) { } // Set permanent and temporary current limits - List opLimitsGroupSide1 = modificationInfos.getOperationalLimitsGroup1(); - List opLimitsGroupSide2 = modificationInfos.getOperationalLimitsGroup2(); + List opLimitsGroupSide1 = modificationInfos.getOperationalLimitsGroups1(); + List opLimitsGroupSide2 = modificationInfos.getOperationalLimitsGroups2(); if (!CollectionUtils.isEmpty(opLimitsGroupSide1)) { ModificationUtils.getInstance().setCurrentLimitsOnASide(opLimitsGroupSide1, twoWindingsTransformer, TwoSides.ONE); } diff --git a/src/test/java/org/gridsuite/modification/modifications/LineCreationInBusBreakerTest.java b/src/test/java/org/gridsuite/modification/modifications/LineCreationInBusBreakerTest.java index ca84492..5705451 100644 --- a/src/test/java/org/gridsuite/modification/modifications/LineCreationInBusBreakerTest.java +++ b/src/test/java/org/gridsuite/modification/modifications/LineCreationInBusBreakerTest.java @@ -51,7 +51,7 @@ void testCreateLineOptionalParameters5() throws Exception { .busOrBusbarSectionId1("bus1") .voltageLevelId2("v2") .busOrBusbarSectionId2("bus2") - .operationalLimitsGroup1( + .operationalLimitsGroups1( List.of( OperationalLimitsGroupInfos.builder() .id("limiSet1") @@ -88,7 +88,7 @@ protected ModificationInfos buildModification() { .b2(20.0) .voltageLevelId1("v1") .busOrBusbarSectionId1("bus1") - .operationalLimitsGroup1( + .operationalLimitsGroups1( List.of( OperationalLimitsGroupInfos.builder() .id("limitSet1") @@ -97,7 +97,7 @@ protected ModificationInfos buildModification() { ).build() ) ) - .operationalLimitsGroup1( + .operationalLimitsGroups2( List.of( OperationalLimitsGroupInfos.builder() .id("limitSet2") diff --git a/src/test/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreationBusBreakerTest.java b/src/test/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreationBusBreakerTest.java index cab8217..5b25b35 100644 --- a/src/test/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreationBusBreakerTest.java +++ b/src/test/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreationBusBreakerTest.java @@ -52,7 +52,7 @@ protected ModificationInfos buildModification() { .voltageLevelId2("v12") .busOrBusbarSectionId2("bus12") .connected2(true) - .operationalLimitsGroup1( + .operationalLimitsGroups1( List.of( OperationalLimitsGroupInfos.builder() .id("limitSet1") @@ -65,7 +65,7 @@ protected ModificationInfos buildModification() { ).build() ) ) - .operationalLimitsGroup2( + .operationalLimitsGroups2( List.of( OperationalLimitsGroupInfos.builder() .id("limitSet2") diff --git a/src/test/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreationNodeBreakerTest.java b/src/test/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreationNodeBreakerTest.java index 3ef24b3..e86219d 100644 --- a/src/test/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreationNodeBreakerTest.java +++ b/src/test/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreationNodeBreakerTest.java @@ -53,7 +53,7 @@ protected ModificationInfos buildModification() { .voltageLevelId2("v2") .busOrBusbarSectionId2("1A") .connected2(true) - .operationalLimitsGroup1( + .operationalLimitsGroups1( List.of( OperationalLimitsGroupInfos.builder() .currentLimits( @@ -61,7 +61,7 @@ protected ModificationInfos buildModification() { ).build() ) ) - .operationalLimitsGroup1( + .operationalLimitsGroups2( List.of( OperationalLimitsGroupInfos.builder() .currentLimits( @@ -234,7 +234,7 @@ void testCreateTwoWindingsTransformerWithRatioTapChangerInNodeBreaker() throws E testCreateTwoWindingsTransformerInNodeBreaker(twoWindingsTransformerCreationInfos2); assertEquals( - "TwoWindingsTransformerCreationInfos(super=BranchCreationInfos(super=EquipmentCreationInfos(super=EquipmentModificationInfos(super=ModificationInfos(uuid=null, type=TWO_WINDINGS_TRANSFORMER_CREATION, date=null, stashed=false, messageType=null, messageValues=null, activated=true), equipmentId=id2wt1WithRatioTapChanger2, properties=null), equipmentName=2wtName), r=400.0, x=300.0, voltageLevelId1=v1, voltageLevelId2=v4, busOrBusbarSectionId1=1.1, busOrBusbarSectionId2=1.A, operationalLimitsGroup1=null, operationalLimitsGroup2=null, selectedOperationalLimitsGroupId1=null, selectedOperationalLimitsGroupId2=null, connectionName1=null, connectionDirection1=TOP, connectionName2=null, connectionDirection2=TOP, connectionPosition1=null, connectionPosition2=null, connected1=true, connected2=true), g=100.0, b=200.0, ratedU1=1000.0, ratedU2=1010.0, ratedS=null, ratioTapChanger=RatioTapChangerCreationInfos(super=TapChangerCreationInfos(lowTapPosition=0, tapPosition=1, regulating=true, targetDeadband=null, regulatingTerminalId=v1load, regulatingTerminalType=LOAD, regulatingTerminalVlId=v1, steps=[TapChangerStepCreationInfos(index=0, rho=1.0, r=39.78473, x=39.784725, g=0.0, b=0.0, alpha=0.0), TapChangerStepCreationInfos(index=0, rho=1.0, r=39.78474, x=39.784726, g=0.0, b=0.0, alpha=0.0), TapChangerStepCreationInfos(index=0, rho=1.0, r=39.78475, x=39.784727, g=0.0, b=0.0, alpha=0.0)]), loadTapChangingCapabilities=true, targetV=220.0), phaseTapChanger=null)", + "TwoWindingsTransformerCreationInfos(super=BranchCreationInfos(super=EquipmentCreationInfos(super=EquipmentModificationInfos(super=ModificationInfos(uuid=null, type=TWO_WINDINGS_TRANSFORMER_CREATION, date=null, stashed=false, messageType=null, messageValues=null, activated=true), equipmentId=id2wt1WithRatioTapChanger2, properties=null), equipmentName=2wtName), r=400.0, x=300.0, voltageLevelId1=v1, voltageLevelId2=v4, busOrBusbarSectionId1=1.1, busOrBusbarSectionId2=1.A, operationalLimitsGroups1=null, operationalLimitsGroups2=null, selectedOperationalLimitsGroupId1=null, selectedOperationalLimitsGroupId2=null, connectionName1=null, connectionDirection1=TOP, connectionName2=null, connectionDirection2=TOP, connectionPosition1=null, connectionPosition2=null, connected1=true, connected2=true), g=100.0, b=200.0, ratedU1=1000.0, ratedU2=1010.0, ratedS=null, ratioTapChanger=RatioTapChangerCreationInfos(super=TapChangerCreationInfos(lowTapPosition=0, tapPosition=1, regulating=true, targetDeadband=null, regulatingTerminalId=v1load, regulatingTerminalType=LOAD, regulatingTerminalVlId=v1, steps=[TapChangerStepCreationInfos(index=0, rho=1.0, r=39.78473, x=39.784725, g=0.0, b=0.0, alpha=0.0), TapChangerStepCreationInfos(index=0, rho=1.0, r=39.78474, x=39.784726, g=0.0, b=0.0, alpha=0.0), TapChangerStepCreationInfos(index=0, rho=1.0, r=39.78475, x=39.784727, g=0.0, b=0.0, alpha=0.0)]), loadTapChangingCapabilities=true, targetV=220.0), phaseTapChanger=null)", twoWindingsTransformerCreationInfos2.toString() ); From a52072a606984e14bf1160b4d2c8b16ec31fe9fc Mon Sep 17 00:00:00 2001 From: Mathieu DEHARBE Date: Mon, 6 Jan 2025 18:26:22 +0100 Subject: [PATCH 11/17] post review 1 Signed-off-by: Mathieu DEHARBE --- .../modification/dto/BranchCreationInfos.java | 8 ++++---- .../modification/dto/CurrentLimitsInfos.java | 5 ++++- .../modification/modifications/LineCreation.java | 15 +++++++-------- .../TwoWindingsTransformerCreation.java | 8 ++++---- .../LineCreationInBusBreakerTest.java | 6 +++--- ...WindingsTransformerCreationBusBreakerTest.java | 4 ++-- 6 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/main/java/org/gridsuite/modification/dto/BranchCreationInfos.java b/src/main/java/org/gridsuite/modification/dto/BranchCreationInfos.java index c0f4ed3..1d99fb3 100644 --- a/src/main/java/org/gridsuite/modification/dto/BranchCreationInfos.java +++ b/src/main/java/org/gridsuite/modification/dto/BranchCreationInfos.java @@ -51,11 +51,11 @@ public class BranchCreationInfos extends EquipmentCreationInfos { @Schema(description = "Operational limit groups on side 2") private List operationalLimitsGroups2; - @Schema(description = "Selected operational limits group id on Side 1") - private String selectedOperationalLimitsGroupId1; + @Schema(description = "Selected operational limits group on Side 1") + private String selectedOperationalLimitsGroup1; - @Schema(description = "Selected operational limits group id on Side 2") - private String selectedOperationalLimitsGroupId2; + @Schema(description = "Selected operational limits group on Side 2") + private String selectedOperationalLimitsGroup2; @Schema(description = "Connection Name 1") private String connectionName1; diff --git a/src/main/java/org/gridsuite/modification/dto/CurrentLimitsInfos.java b/src/main/java/org/gridsuite/modification/dto/CurrentLimitsInfos.java index edece28..58e94ea 100644 --- a/src/main/java/org/gridsuite/modification/dto/CurrentLimitsInfos.java +++ b/src/main/java/org/gridsuite/modification/dto/CurrentLimitsInfos.java @@ -7,7 +7,10 @@ package org.gridsuite.modification.dto; import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; import lombok.experimental.SuperBuilder; import java.util.List; diff --git a/src/main/java/org/gridsuite/modification/modifications/LineCreation.java b/src/main/java/org/gridsuite/modification/modifications/LineCreation.java index 9a2bd72..855feec 100644 --- a/src/main/java/org/gridsuite/modification/modifications/LineCreation.java +++ b/src/main/java/org/gridsuite/modification/modifications/LineCreation.java @@ -20,8 +20,7 @@ import java.util.List; -import static com.powsybl.iidm.network.TwoSides.ONE; -import static com.powsybl.iidm.network.TwoSides.TWO; +import static com.powsybl.iidm.network.TwoSides.*; import static org.gridsuite.modification.NetworkModificationException.Type.*; /** @@ -75,21 +74,21 @@ public void apply(Network network, ReportNode subReportNode) { List opLimitsGroupSide1 = modificationInfos.getOperationalLimitsGroups1(); List opLimitsGroupSide2 = modificationInfos.getOperationalLimitsGroups2(); if (!CollectionUtils.isEmpty(opLimitsGroupSide1)) { - var line = ModificationUtils.getInstance().getLine(network, modificationInfos.getEquipmentId()); + Line line = ModificationUtils.getInstance().getLine(network, modificationInfos.getEquipmentId()); ModificationUtils.getInstance().setCurrentLimitsOnASide(opLimitsGroupSide1, line, ONE); } if (!CollectionUtils.isEmpty(opLimitsGroupSide2)) { - var line = ModificationUtils.getInstance().getLine(network, modificationInfos.getEquipmentId()); + Line line = ModificationUtils.getInstance().getLine(network, modificationInfos.getEquipmentId()); ModificationUtils.getInstance().setCurrentLimitsOnASide(opLimitsGroupSide2, line, TWO); } ModificationUtils.getInstance().disconnectBranch(modificationInfos, network.getLine(modificationInfos.getEquipmentId()), subReportNode); // properties Line line = network.getLine(modificationInfos.getEquipmentId()); - if (modificationInfos.getSelectedOperationalLimitsGroupId1() != null) { - line.setSelectedOperationalLimitsGroup1(modificationInfos.getSelectedOperationalLimitsGroupId1()); + if (modificationInfos.getSelectedOperationalLimitsGroup1() != null) { + line.setSelectedOperationalLimitsGroup1(modificationInfos.getSelectedOperationalLimitsGroup1()); } - if (modificationInfos.getSelectedOperationalLimitsGroupId2() != null) { - line.setSelectedOperationalLimitsGroup2(modificationInfos.getSelectedOperationalLimitsGroupId2()); + if (modificationInfos.getSelectedOperationalLimitsGroup2() != null) { + line.setSelectedOperationalLimitsGroup2(modificationInfos.getSelectedOperationalLimitsGroup2()); } PropertiesUtils.applyProperties(line, subReportNode, modificationInfos.getProperties(), "LineProperties"); } diff --git a/src/main/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreation.java b/src/main/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreation.java index 38a8dcd..fadee9f 100644 --- a/src/main/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreation.java +++ b/src/main/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreation.java @@ -63,11 +63,11 @@ public void apply(Network network, ReportNode subReportNode) { if (!CollectionUtils.isEmpty(opLimitsGroupSide2)) { ModificationUtils.getInstance().setCurrentLimitsOnASide(opLimitsGroupSide2, twoWindingsTransformer, TwoSides.TWO); } - if (modificationInfos.getSelectedOperationalLimitsGroupId1() != null) { - twoWindingsTransformer.setSelectedOperationalLimitsGroup1(modificationInfos.getSelectedOperationalLimitsGroupId1()); + if (modificationInfos.getSelectedOperationalLimitsGroup1() != null) { + twoWindingsTransformer.setSelectedOperationalLimitsGroup1(modificationInfos.getSelectedOperationalLimitsGroup1()); } - if (modificationInfos.getSelectedOperationalLimitsGroupId2() != null) { - twoWindingsTransformer.setSelectedOperationalLimitsGroup2(modificationInfos.getSelectedOperationalLimitsGroupId2()); + if (modificationInfos.getSelectedOperationalLimitsGroup2() != null) { + twoWindingsTransformer.setSelectedOperationalLimitsGroup2(modificationInfos.getSelectedOperationalLimitsGroup2()); } ModificationUtils.getInstance().disconnectBranch(modificationInfos, network.getTwoWindingsTransformer(modificationInfos.getEquipmentId()), subReportNode); diff --git a/src/test/java/org/gridsuite/modification/modifications/LineCreationInBusBreakerTest.java b/src/test/java/org/gridsuite/modification/modifications/LineCreationInBusBreakerTest.java index 5705451..e2f4413 100644 --- a/src/test/java/org/gridsuite/modification/modifications/LineCreationInBusBreakerTest.java +++ b/src/test/java/org/gridsuite/modification/modifications/LineCreationInBusBreakerTest.java @@ -60,7 +60,7 @@ void testCreateLineOptionalParameters5() throws Exception { ).build() ) ) - .selectedOperationalLimitsGroupId1("limiSet1") + .selectedOperationalLimitsGroup1("limiSet1") .build(); ValidationException exception = assertThrows(ValidationException.class, () -> lineCreationInfosPermanentLimitNOK.toModification().apply(getNetwork())); assertEquals("AC Line 'idLine2': permanent limit must be >= 0", exception.getMessage()); @@ -106,8 +106,8 @@ protected ModificationInfos buildModification() { ).build() ) ) - .selectedOperationalLimitsGroupId1("limitSet1") - .selectedOperationalLimitsGroupId2("limitSet2") + .selectedOperationalLimitsGroup1("limitSet1") + .selectedOperationalLimitsGroup2("limitSet2") .voltageLevelId2("v2") .busOrBusbarSectionId2("bus2") .properties(List.of(FreePropertyInfos.builder().name(PROPERTY_NAME).value(PROPERTY_VALUE).build())) diff --git a/src/test/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreationBusBreakerTest.java b/src/test/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreationBusBreakerTest.java index 5b25b35..227bf4d 100644 --- a/src/test/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreationBusBreakerTest.java +++ b/src/test/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreationBusBreakerTest.java @@ -78,8 +78,8 @@ protected ModificationInfos buildModification() { .build() ) ) - .selectedOperationalLimitsGroupId1("limitSet1") - .selectedOperationalLimitsGroupId2("limitSet2") + .selectedOperationalLimitsGroup1("limitSet1") + .selectedOperationalLimitsGroup2("limitSet2") .connectionName1("cn201") .connectionDirection1(ConnectablePosition.Direction.TOP) .connectionName2("cn202") From 1c71d77bd75f2fac9aba54b990999f35612a355c Mon Sep 17 00:00:00 2001 From: Mathieu DEHARBE Date: Mon, 6 Jan 2025 18:35:20 +0100 Subject: [PATCH 12/17] TU Signed-off-by: Mathieu DEHARBE --- .../TwoWindingsTransformerCreationNodeBreakerTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreationNodeBreakerTest.java b/src/test/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreationNodeBreakerTest.java index e86219d..9999d6a 100644 --- a/src/test/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreationNodeBreakerTest.java +++ b/src/test/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreationNodeBreakerTest.java @@ -234,7 +234,7 @@ void testCreateTwoWindingsTransformerWithRatioTapChangerInNodeBreaker() throws E testCreateTwoWindingsTransformerInNodeBreaker(twoWindingsTransformerCreationInfos2); assertEquals( - "TwoWindingsTransformerCreationInfos(super=BranchCreationInfos(super=EquipmentCreationInfos(super=EquipmentModificationInfos(super=ModificationInfos(uuid=null, type=TWO_WINDINGS_TRANSFORMER_CREATION, date=null, stashed=false, messageType=null, messageValues=null, activated=true), equipmentId=id2wt1WithRatioTapChanger2, properties=null), equipmentName=2wtName), r=400.0, x=300.0, voltageLevelId1=v1, voltageLevelId2=v4, busOrBusbarSectionId1=1.1, busOrBusbarSectionId2=1.A, operationalLimitsGroups1=null, operationalLimitsGroups2=null, selectedOperationalLimitsGroupId1=null, selectedOperationalLimitsGroupId2=null, connectionName1=null, connectionDirection1=TOP, connectionName2=null, connectionDirection2=TOP, connectionPosition1=null, connectionPosition2=null, connected1=true, connected2=true), g=100.0, b=200.0, ratedU1=1000.0, ratedU2=1010.0, ratedS=null, ratioTapChanger=RatioTapChangerCreationInfos(super=TapChangerCreationInfos(lowTapPosition=0, tapPosition=1, regulating=true, targetDeadband=null, regulatingTerminalId=v1load, regulatingTerminalType=LOAD, regulatingTerminalVlId=v1, steps=[TapChangerStepCreationInfos(index=0, rho=1.0, r=39.78473, x=39.784725, g=0.0, b=0.0, alpha=0.0), TapChangerStepCreationInfos(index=0, rho=1.0, r=39.78474, x=39.784726, g=0.0, b=0.0, alpha=0.0), TapChangerStepCreationInfos(index=0, rho=1.0, r=39.78475, x=39.784727, g=0.0, b=0.0, alpha=0.0)]), loadTapChangingCapabilities=true, targetV=220.0), phaseTapChanger=null)", + "TwoWindingsTransformerCreationInfos(super=BranchCreationInfos(super=EquipmentCreationInfos(super=EquipmentModificationInfos(super=ModificationInfos(uuid=null, type=TWO_WINDINGS_TRANSFORMER_CREATION, date=null, stashed=false, messageType=null, messageValues=null, activated=true), equipmentId=id2wt1WithRatioTapChanger2, properties=null), equipmentName=2wtName), r=400.0, x=300.0, voltageLevelId1=v1, voltageLevelId2=v4, busOrBusbarSectionId1=1.1, busOrBusbarSectionId2=1.A, operationalLimitsGroups1=null, operationalLimitsGroups2=null, selectedOperationalLimitsGroup1=null, selectedOperationalLimitsGroup2=null, connectionName1=null, connectionDirection1=TOP, connectionName2=null, connectionDirection2=TOP, connectionPosition1=null, connectionPosition2=null, connected1=true, connected2=true), g=100.0, b=200.0, ratedU1=1000.0, ratedU2=1010.0, ratedS=null, ratioTapChanger=RatioTapChangerCreationInfos(super=TapChangerCreationInfos(lowTapPosition=0, tapPosition=1, regulating=true, targetDeadband=null, regulatingTerminalId=v1load, regulatingTerminalType=LOAD, regulatingTerminalVlId=v1, steps=[TapChangerStepCreationInfos(index=0, rho=1.0, r=39.78473, x=39.784725, g=0.0, b=0.0, alpha=0.0), TapChangerStepCreationInfos(index=0, rho=1.0, r=39.78474, x=39.784726, g=0.0, b=0.0, alpha=0.0), TapChangerStepCreationInfos(index=0, rho=1.0, r=39.78475, x=39.784727, g=0.0, b=0.0, alpha=0.0)]), loadTapChangingCapabilities=true, targetV=220.0), phaseTapChanger=null)", twoWindingsTransformerCreationInfos2.toString() ); From e5e03d9be47689c824322e6f7f350dfafc7c61a6 Mon Sep 17 00:00:00 2001 From: Mathieu DEHARBE Date: Tue, 7 Jan 2025 10:29:40 +0100 Subject: [PATCH 13/17] reduce cognitive complexity Signed-off-by: Mathieu DEHARBE --- .../modification/utils/ModificationUtils.java | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/main/java/org/gridsuite/modification/utils/ModificationUtils.java b/src/main/java/org/gridsuite/modification/utils/ModificationUtils.java index b41227b..8b05686 100644 --- a/src/main/java/org/gridsuite/modification/utils/ModificationUtils.java +++ b/src/main/java/org/gridsuite/modification/utils/ModificationUtils.java @@ -1021,26 +1021,27 @@ public void setCurrentLimitsOnASide(List opLimitGro boolean hasPermanent = opLimitsGroup.getCurrentLimits().getPermanentLimit() != null; boolean hasTemporary = !CollectionUtils.isEmpty(opLimitsGroup.getCurrentLimits().getTemporaryLimits()); boolean hasLimits = hasPermanent || hasTemporary; - if (hasLimits) { - OperationalLimitsGroup opGroup = side == ONE - ? branch.newOperationalLimitsGroup1(opLimitsGroup.getId()) - : branch.newOperationalLimitsGroup2(opLimitsGroup.getId()); - CurrentLimitsAdder limitsAdder = opGroup.newCurrentLimits(); - if (hasPermanent) { - limitsAdder.setPermanentLimit(opLimitsGroup.getCurrentLimits().getPermanentLimit()); - } - if (hasTemporary) { - for (CurrentTemporaryLimitCreationInfos limit : opLimitsGroup.getCurrentLimits().getTemporaryLimits()) { - limitsAdder - .beginTemporaryLimit() - .setName(limit.getName()) - .setValue(limit.getValue() == null ? Double.MAX_VALUE : limit.getValue()) - .setAcceptableDuration(limit.getAcceptableDuration() == null ? Integer.MAX_VALUE : limit.getAcceptableDuration()) - .endTemporaryLimit(); - } + + if (!hasLimits) { continue; } + + OperationalLimitsGroup opGroup = side == ONE + ? branch.newOperationalLimitsGroup1(opLimitsGroup.getId()) + : branch.newOperationalLimitsGroup2(opLimitsGroup.getId()); + CurrentLimitsAdder limitsAdder = opGroup.newCurrentLimits(); + if (hasPermanent) { + limitsAdder.setPermanentLimit(opLimitsGroup.getCurrentLimits().getPermanentLimit()); + } + if (hasTemporary) { + for (CurrentTemporaryLimitCreationInfos limit : opLimitsGroup.getCurrentLimits().getTemporaryLimits()) { + limitsAdder + .beginTemporaryLimit() + .setName(limit.getName()) + .setValue(limit.getValue() == null ? Double.MAX_VALUE : limit.getValue()) + .setAcceptableDuration(limit.getAcceptableDuration() == null ? Integer.MAX_VALUE : limit.getAcceptableDuration()) + .endTemporaryLimit(); } - limitsAdder.add(); } + limitsAdder.add(); } } From 2e16fd5ab0889a211200690733538378f97768ad Mon Sep 17 00:00:00 2001 From: Mathieu DEHARBE Date: Tue, 7 Jan 2025 10:35:12 +0100 Subject: [PATCH 14/17] comply with build requirements Signed-off-by: Mathieu DEHARBE --- .../org/gridsuite/modification/utils/ModificationUtils.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/gridsuite/modification/utils/ModificationUtils.java b/src/main/java/org/gridsuite/modification/utils/ModificationUtils.java index 8b05686..90a5b9a 100644 --- a/src/main/java/org/gridsuite/modification/utils/ModificationUtils.java +++ b/src/main/java/org/gridsuite/modification/utils/ModificationUtils.java @@ -1022,7 +1022,9 @@ public void setCurrentLimitsOnASide(List opLimitGro boolean hasTemporary = !CollectionUtils.isEmpty(opLimitsGroup.getCurrentLimits().getTemporaryLimits()); boolean hasLimits = hasPermanent || hasTemporary; - if (!hasLimits) { continue; } + if (!hasLimits) { + continue; + } OperationalLimitsGroup opGroup = side == ONE ? branch.newOperationalLimitsGroup1(opLimitsGroup.getId()) From 6e93a4a29baa8e1af013528b2a93629aaded232a Mon Sep 17 00:00:00 2001 From: Mathieu DEHARBE Date: Tue, 7 Jan 2025 10:59:44 +0100 Subject: [PATCH 15/17] post review 2 Signed-off-by: Mathieu DEHARBE --- .../modification/modifications/LineCreation.java | 6 ++---- .../modification/utils/ModificationUtils.java | 14 ++++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/gridsuite/modification/modifications/LineCreation.java b/src/main/java/org/gridsuite/modification/modifications/LineCreation.java index 855feec..ec48a82 100644 --- a/src/main/java/org/gridsuite/modification/modifications/LineCreation.java +++ b/src/main/java/org/gridsuite/modification/modifications/LineCreation.java @@ -69,21 +69,19 @@ public void apply(Network network, ReportNode subReportNode) { } else { addLine(network, voltageLevel1, voltageLevel2, modificationInfos, true, true, subReportNode); } + ModificationUtils.getInstance().disconnectBranch(modificationInfos, network.getLine(modificationInfos.getEquipmentId()), subReportNode); + Line line = network.getLine(modificationInfos.getEquipmentId()); // Set permanent and temporary current limits List opLimitsGroupSide1 = modificationInfos.getOperationalLimitsGroups1(); List opLimitsGroupSide2 = modificationInfos.getOperationalLimitsGroups2(); if (!CollectionUtils.isEmpty(opLimitsGroupSide1)) { - Line line = ModificationUtils.getInstance().getLine(network, modificationInfos.getEquipmentId()); ModificationUtils.getInstance().setCurrentLimitsOnASide(opLimitsGroupSide1, line, ONE); } if (!CollectionUtils.isEmpty(opLimitsGroupSide2)) { - Line line = ModificationUtils.getInstance().getLine(network, modificationInfos.getEquipmentId()); ModificationUtils.getInstance().setCurrentLimitsOnASide(opLimitsGroupSide2, line, TWO); } - ModificationUtils.getInstance().disconnectBranch(modificationInfos, network.getLine(modificationInfos.getEquipmentId()), subReportNode); // properties - Line line = network.getLine(modificationInfos.getEquipmentId()); if (modificationInfos.getSelectedOperationalLimitsGroup1() != null) { line.setSelectedOperationalLimitsGroup1(modificationInfos.getSelectedOperationalLimitsGroup1()); } diff --git a/src/main/java/org/gridsuite/modification/utils/ModificationUtils.java b/src/main/java/org/gridsuite/modification/utils/ModificationUtils.java index 90a5b9a..0e8e79b 100644 --- a/src/main/java/org/gridsuite/modification/utils/ModificationUtils.java +++ b/src/main/java/org/gridsuite/modification/utils/ModificationUtils.java @@ -1034,14 +1034,16 @@ public void setCurrentLimitsOnASide(List opLimitGro limitsAdder.setPermanentLimit(opLimitsGroup.getCurrentLimits().getPermanentLimit()); } if (hasTemporary) { - for (CurrentTemporaryLimitCreationInfos limit : opLimitsGroup.getCurrentLimits().getTemporaryLimits()) { - limitsAdder - .beginTemporaryLimit() + opLimitsGroup.getCurrentLimits().getTemporaryLimits().forEach(limit -> { + double value = limit.getValue() != null ? limit.getValue() : Double.MAX_VALUE; + int duration = limit.getAcceptableDuration() != null ? limit.getAcceptableDuration() : Integer.MAX_VALUE; + + limitsAdder.beginTemporaryLimit() .setName(limit.getName()) - .setValue(limit.getValue() == null ? Double.MAX_VALUE : limit.getValue()) - .setAcceptableDuration(limit.getAcceptableDuration() == null ? Integer.MAX_VALUE : limit.getAcceptableDuration()) + .setValue(value) + .setAcceptableDuration(duration) .endTemporaryLimit(); - } + }); } limitsAdder.add(); } From 31cfb438be729b4a5e662ba1edd18583a5bf1824 Mon Sep 17 00:00:00 2001 From: Mathieu DEHARBE Date: Fri, 17 Jan 2025 15:02:37 +0100 Subject: [PATCH 16/17] log selected limit set Signed-off-by: Mathieu DEHARBE --- .../modification/modifications/LineCreation.java | 10 ++++++++++ .../modifications/TwoWindingsTransformerCreation.java | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/main/java/org/gridsuite/modification/modifications/LineCreation.java b/src/main/java/org/gridsuite/modification/modifications/LineCreation.java index ec48a82..167f032 100644 --- a/src/main/java/org/gridsuite/modification/modifications/LineCreation.java +++ b/src/main/java/org/gridsuite/modification/modifications/LineCreation.java @@ -84,9 +84,19 @@ public void apply(Network network, ReportNode subReportNode) { // properties if (modificationInfos.getSelectedOperationalLimitsGroup1() != null) { line.setSelectedOperationalLimitsGroup1(modificationInfos.getSelectedOperationalLimitsGroup1()); + subReportNode.newReportNode() + .withMessageTemplate("limit set selected on side 1", "limit set selected on side 1 : ${selectedOperationalLimitsGroup1}") + .withUntypedValue("selectedOperationalLimitsGroup1", modificationInfos.getSelectedOperationalLimitsGroup1()) + .withSeverity(TypedValue.INFO_SEVERITY) + .add(); } if (modificationInfos.getSelectedOperationalLimitsGroup2() != null) { line.setSelectedOperationalLimitsGroup2(modificationInfos.getSelectedOperationalLimitsGroup2()); + subReportNode.newReportNode() + .withMessageTemplate("limit set selected on side 2", "limit set selected on side 2 : ${selectedOperationalLimitsGroup2}") + .withUntypedValue("selectedOperationalLimitsGroup2", modificationInfos.getSelectedOperationalLimitsGroup2()) + .withSeverity(TypedValue.INFO_SEVERITY) + .add(); } PropertiesUtils.applyProperties(line, subReportNode, modificationInfos.getProperties(), "LineProperties"); } diff --git a/src/main/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreation.java b/src/main/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreation.java index fadee9f..b0ab50c 100644 --- a/src/main/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreation.java +++ b/src/main/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreation.java @@ -65,9 +65,19 @@ public void apply(Network network, ReportNode subReportNode) { } if (modificationInfos.getSelectedOperationalLimitsGroup1() != null) { twoWindingsTransformer.setSelectedOperationalLimitsGroup1(modificationInfos.getSelectedOperationalLimitsGroup1()); + subReportNode.newReportNode() + .withMessageTemplate("limit set selected on side 1", "limit set selected on side 1 : ${selectedOperationalLimitsGroup1}") + .withUntypedValue("selectedOperationalLimitsGroup1", modificationInfos.getSelectedOperationalLimitsGroup1()) + .withSeverity(TypedValue.INFO_SEVERITY) + .add(); } if (modificationInfos.getSelectedOperationalLimitsGroup2() != null) { twoWindingsTransformer.setSelectedOperationalLimitsGroup2(modificationInfos.getSelectedOperationalLimitsGroup2()); + subReportNode.newReportNode() + .withMessageTemplate("limit set selected on side 2", "limit set selected on side 2 : ${selectedOperationalLimitsGroup2}") + .withUntypedValue("selectedOperationalLimitsGroup2", modificationInfos.getSelectedOperationalLimitsGroup2()) + .withSeverity(TypedValue.INFO_SEVERITY) + .add(); } ModificationUtils.getInstance().disconnectBranch(modificationInfos, network.getTwoWindingsTransformer(modificationInfos.getEquipmentId()), subReportNode); From 44c9e25eaa495a1237a8cfaf61a3e6d2000df317 Mon Sep 17 00:00:00 2001 From: Mathieu DEHARBE Date: Fri, 17 Jan 2025 16:03:25 +0100 Subject: [PATCH 17/17] log created limit set Signed-off-by: Mathieu DEHARBE --- .../modification/modifications/LineCreation.java | 4 ++-- .../TwoWindingsTransformerCreation.java | 4 ++-- .../modification/utils/ModificationUtils.java | 14 +++++++++++++- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/gridsuite/modification/modifications/LineCreation.java b/src/main/java/org/gridsuite/modification/modifications/LineCreation.java index 167f032..494de98 100644 --- a/src/main/java/org/gridsuite/modification/modifications/LineCreation.java +++ b/src/main/java/org/gridsuite/modification/modifications/LineCreation.java @@ -76,10 +76,10 @@ public void apply(Network network, ReportNode subReportNode) { List opLimitsGroupSide1 = modificationInfos.getOperationalLimitsGroups1(); List opLimitsGroupSide2 = modificationInfos.getOperationalLimitsGroups2(); if (!CollectionUtils.isEmpty(opLimitsGroupSide1)) { - ModificationUtils.getInstance().setCurrentLimitsOnASide(opLimitsGroupSide1, line, ONE); + ModificationUtils.getInstance().setCurrentLimitsOnASide(opLimitsGroupSide1, line, ONE, subReportNode); } if (!CollectionUtils.isEmpty(opLimitsGroupSide2)) { - ModificationUtils.getInstance().setCurrentLimitsOnASide(opLimitsGroupSide2, line, TWO); + ModificationUtils.getInstance().setCurrentLimitsOnASide(opLimitsGroupSide2, line, TWO, subReportNode); } // properties if (modificationInfos.getSelectedOperationalLimitsGroup1() != null) { diff --git a/src/main/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreation.java b/src/main/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreation.java index b0ab50c..9361863 100644 --- a/src/main/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreation.java +++ b/src/main/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreation.java @@ -58,10 +58,10 @@ public void apply(Network network, ReportNode subReportNode) { List opLimitsGroupSide1 = modificationInfos.getOperationalLimitsGroups1(); List opLimitsGroupSide2 = modificationInfos.getOperationalLimitsGroups2(); if (!CollectionUtils.isEmpty(opLimitsGroupSide1)) { - ModificationUtils.getInstance().setCurrentLimitsOnASide(opLimitsGroupSide1, twoWindingsTransformer, TwoSides.ONE); + ModificationUtils.getInstance().setCurrentLimitsOnASide(opLimitsGroupSide1, twoWindingsTransformer, TwoSides.ONE, subReportNode); } if (!CollectionUtils.isEmpty(opLimitsGroupSide2)) { - ModificationUtils.getInstance().setCurrentLimitsOnASide(opLimitsGroupSide2, twoWindingsTransformer, TwoSides.TWO); + ModificationUtils.getInstance().setCurrentLimitsOnASide(opLimitsGroupSide2, twoWindingsTransformer, TwoSides.TWO, subReportNode); } if (modificationInfos.getSelectedOperationalLimitsGroup1() != null) { twoWindingsTransformer.setSelectedOperationalLimitsGroup1(modificationInfos.getSelectedOperationalLimitsGroup1()); diff --git a/src/main/java/org/gridsuite/modification/utils/ModificationUtils.java b/src/main/java/org/gridsuite/modification/utils/ModificationUtils.java index 467d5e8..04073ee 100644 --- a/src/main/java/org/gridsuite/modification/utils/ModificationUtils.java +++ b/src/main/java/org/gridsuite/modification/utils/ModificationUtils.java @@ -1020,7 +1020,8 @@ public Identifiable getEquipmentByIdentifiableType(Network network, Identifia * @param branch branch to which limits are going to be added * @param side which side of the branch receives the limits */ - public void setCurrentLimitsOnASide(List opLimitGroups, Branch branch, TwoSides side) { + public void setCurrentLimitsOnASide(List opLimitGroups, Branch branch, TwoSides side, ReportNode subReportNode) { + List reportNodes = new ArrayList<>(); for (OperationalLimitsGroupInfos opLimitsGroup : opLimitGroups) { boolean hasPermanent = opLimitsGroup.getCurrentLimits().getPermanentLimit() != null; boolean hasTemporary = !CollectionUtils.isEmpty(opLimitsGroup.getCurrentLimits().getTemporaryLimits()); @@ -1033,6 +1034,12 @@ public void setCurrentLimitsOnASide(List opLimitGro OperationalLimitsGroup opGroup = side == ONE ? branch.newOperationalLimitsGroup1(opLimitsGroup.getId()) : branch.newOperationalLimitsGroup2(opLimitsGroup.getId()); + if (opLimitsGroup.getId() != null) { + reportNodes.add(ReportNode.newRootReportNode().withMessageTemplate("limitSetAdded", " ${name} added") + .withUntypedValue("name", opLimitsGroup.getId()) + .withSeverity(TypedValue.INFO_SEVERITY) + .build()); + } CurrentLimitsAdder limitsAdder = opGroup.newCurrentLimits(); if (hasPermanent) { limitsAdder.setPermanentLimit(opLimitsGroup.getCurrentLimits().getPermanentLimit()); @@ -1051,6 +1058,11 @@ public void setCurrentLimitsOnASide(List opLimitGro } limitsAdder.add(); } + if (!reportNodes.isEmpty()) { + ModificationUtils.getInstance().reportModifications(subReportNode, reportNodes, + "LimitSets", "Limit sets " + (side == ONE ? "side one" : "side two") + ); + } } public ReportNode buildCreationReport(T value, String fieldName) {