diff --git a/pom.xml b/pom.xml index 60e08d3..8deed35 100644 --- a/pom.xml +++ b/pom.xml @@ -42,7 +42,7 @@ - 37.0.0 + 38.1.0-SNAPSHOT gridsuite org.gridsuite:network-modification diff --git a/src/main/java/org/gridsuite/modification/dto/BatteryCreationInfos.java b/src/main/java/org/gridsuite/modification/dto/BatteryCreationInfos.java index 46d7737..9a9f48e 100644 --- a/src/main/java/org/gridsuite/modification/dto/BatteryCreationInfos.java +++ b/src/main/java/org/gridsuite/modification/dto/BatteryCreationInfos.java @@ -14,7 +14,6 @@ import lombok.Setter; import lombok.ToString; import lombok.experimental.SuperBuilder; -import org.gridsuite.modification.ModificationType; import org.gridsuite.modification.dto.annotation.ModificationErrorTypeName; import org.gridsuite.modification.modifications.AbstractModification; import org.gridsuite.modification.modifications.BatteryCreation; @@ -72,6 +71,6 @@ public AbstractModification toModification() { @Override public ReportNode createSubReportNode(ReportNode reportNode) { - return reportNode.newReportNode().withMessageTemplate(ModificationType.BATTERY_CREATION.name(), "Battery creation ${batteryId}").withUntypedValue("batteryId", this.getEquipmentId()).add(); + return reportNode.newReportNode().withMessageTemplate("network.modification.batteryCreation").withUntypedValue("batteryId", this.getEquipmentId()).add(); } } diff --git a/src/main/java/org/gridsuite/modification/dto/BatteryModificationInfos.java b/src/main/java/org/gridsuite/modification/dto/BatteryModificationInfos.java index e710e43..0cc0df3 100644 --- a/src/main/java/org/gridsuite/modification/dto/BatteryModificationInfos.java +++ b/src/main/java/org/gridsuite/modification/dto/BatteryModificationInfos.java @@ -70,6 +70,9 @@ public AbstractModification toModification() { @Override public ReportNode createSubReportNode(ReportNode reportNode) { - return reportNode.newReportNode().withMessageTemplate(getType().name(), "Battery modification ${batteryId}").withUntypedValue("batteryId", this.getEquipmentId()).add(); + return reportNode.newReportNode() + .withMessageTemplate("network.modification.battery.modification") + .withUntypedValue("batteryId", this.getEquipmentId()) + .add(); } } diff --git a/src/main/java/org/gridsuite/modification/dto/ByFilterDeletionInfos.java b/src/main/java/org/gridsuite/modification/dto/ByFilterDeletionInfos.java index 53a50b2..3ef524f 100644 --- a/src/main/java/org/gridsuite/modification/dto/ByFilterDeletionInfos.java +++ b/src/main/java/org/gridsuite/modification/dto/ByFilterDeletionInfos.java @@ -50,7 +50,7 @@ public AbstractModification toModification() { @Override public ReportNode createSubReportNode(ReportNode reportNode) { - return reportNode.newReportNode().withMessageTemplate(getType().name(), "By filter deletion").add(); + return reportNode.newReportNode().withMessageTemplate("network.modification.byFilter.deletion").add(); } @Override diff --git a/src/main/java/org/gridsuite/modification/dto/ByFormulaModificationInfos.java b/src/main/java/org/gridsuite/modification/dto/ByFormulaModificationInfos.java index 8db5861..268008b 100644 --- a/src/main/java/org/gridsuite/modification/dto/ByFormulaModificationInfos.java +++ b/src/main/java/org/gridsuite/modification/dto/ByFormulaModificationInfos.java @@ -17,7 +17,6 @@ import lombok.Setter; import lombok.ToString; import lombok.experimental.SuperBuilder; -import org.gridsuite.modification.ModificationType; import org.gridsuite.modification.dto.annotation.ModificationErrorTypeName; import org.gridsuite.modification.dto.byfilter.formula.FormulaInfos; import org.gridsuite.modification.modifications.byfilter.ByFormulaModification; @@ -51,6 +50,6 @@ public ByFormulaModification toModification() { @Override public ReportNode createSubReportNode(ReportNode reportNode) { - return reportNode.newReportNode().withMessageTemplate(ModificationType.BY_FORMULA_MODIFICATION.name(), "Modification by formula").add(); + return reportNode.newReportNode().withMessageTemplate("network.modification.byFormulaModification").add(); } } diff --git a/src/main/java/org/gridsuite/modification/dto/DeleteAttachingLineInfos.java b/src/main/java/org/gridsuite/modification/dto/DeleteAttachingLineInfos.java index b79cc13..f797cdb 100644 --- a/src/main/java/org/gridsuite/modification/dto/DeleteAttachingLineInfos.java +++ b/src/main/java/org/gridsuite/modification/dto/DeleteAttachingLineInfos.java @@ -58,7 +58,7 @@ public AbstractModification toModification() { @Override public ReportNode createSubReportNode(ReportNode reportNode) { - return reportNode.newReportNode().withMessageTemplate(getType().name(), "Delete attaching line").add(); + return reportNode.newReportNode().withMessageTemplate("network.modification.deleteAttachingLine").add(); } @Override diff --git a/src/main/java/org/gridsuite/modification/dto/DeleteVoltageLevelOnLineInfos.java b/src/main/java/org/gridsuite/modification/dto/DeleteVoltageLevelOnLineInfos.java index 24fbeac..bfeb5e5 100644 --- a/src/main/java/org/gridsuite/modification/dto/DeleteVoltageLevelOnLineInfos.java +++ b/src/main/java/org/gridsuite/modification/dto/DeleteVoltageLevelOnLineInfos.java @@ -52,7 +52,7 @@ public AbstractModification toModification() { @Override public ReportNode createSubReportNode(ReportNode reportNode) { - return reportNode.newReportNode().withMessageTemplate(getType().name(), "Delete voltage level on line").add(); + return reportNode.newReportNode().withMessageTemplate("network.modification.deleteVoltageLevelOnLine").add(); } @Override diff --git a/src/main/java/org/gridsuite/modification/dto/EquipmentAttributeModificationInfos.java b/src/main/java/org/gridsuite/modification/dto/EquipmentAttributeModificationInfos.java index f3a3895..9d660d6 100644 --- a/src/main/java/org/gridsuite/modification/dto/EquipmentAttributeModificationInfos.java +++ b/src/main/java/org/gridsuite/modification/dto/EquipmentAttributeModificationInfos.java @@ -59,9 +59,9 @@ public AbstractModification toModification() { @Override public ReportNode createSubReportNode(ReportNode reportNode) { return reportNode.newReportNode() - .withMessageTemplate(getType().name(), "${EquipmentType} '${EquipmentId}' change") - .withTypedValue("EquipmentType", equipmentType.name(), TypedValue.UNTYPED) - .withTypedValue("EquipmentId", getEquipmentId(), TypedValue.UNTYPED) + .withMessageTemplate("network.modification.equipmentAttributeModification") + .withTypedValue("EquipmentType", equipmentType.name(), TypedValue.UNTYPED_TYPE) + .withTypedValue("EquipmentId", getEquipmentId(), TypedValue.UNTYPED_TYPE) .add(); } diff --git a/src/main/java/org/gridsuite/modification/dto/EquipmentDeletionInfos.java b/src/main/java/org/gridsuite/modification/dto/EquipmentDeletionInfos.java index 9492178..1d009a5 100644 --- a/src/main/java/org/gridsuite/modification/dto/EquipmentDeletionInfos.java +++ b/src/main/java/org/gridsuite/modification/dto/EquipmentDeletionInfos.java @@ -48,7 +48,7 @@ public AbstractModification toModification() { @Override public ReportNode createSubReportNode(ReportNode reportNode) { return reportNode.newReportNode() - .withMessageTemplate(getType().name(), "Equipment deletion ${equipmentId}") + .withMessageTemplate("network.modification.equipmentDeletion") .withUntypedValue("equipmentId", this.getEquipmentId()) .add(); } diff --git a/src/main/java/org/gridsuite/modification/dto/GenerationDispatchInfos.java b/src/main/java/org/gridsuite/modification/dto/GenerationDispatchInfos.java index 4fed34b..36e1f3c 100644 --- a/src/main/java/org/gridsuite/modification/dto/GenerationDispatchInfos.java +++ b/src/main/java/org/gridsuite/modification/dto/GenerationDispatchInfos.java @@ -57,7 +57,7 @@ public AbstractModification toModification() { @Override public ReportNode createSubReportNode(ReportNode reportNode) { return reportNode.newReportNode() - .withMessageTemplate(getType().name(), "Generation dispatch") + .withMessageTemplate("network.modification.generationDispatch") .add(); } } diff --git a/src/main/java/org/gridsuite/modification/dto/GeneratorCreationInfos.java b/src/main/java/org/gridsuite/modification/dto/GeneratorCreationInfos.java index 9a49a85..c3e4b94 100644 --- a/src/main/java/org/gridsuite/modification/dto/GeneratorCreationInfos.java +++ b/src/main/java/org/gridsuite/modification/dto/GeneratorCreationInfos.java @@ -119,7 +119,7 @@ public AbstractModification toModification() { @Override public ReportNode createSubReportNode(ReportNode reportNode) { return reportNode.newReportNode() - .withMessageTemplate(getType().name(), "Generator creation ${generatorId}") + .withMessageTemplate("network.modification.generator.creation") .withUntypedValue("generatorId", this.getEquipmentId()) .add(); } diff --git a/src/main/java/org/gridsuite/modification/dto/GeneratorModificationInfos.java b/src/main/java/org/gridsuite/modification/dto/GeneratorModificationInfos.java index bf22ec2..821c445 100644 --- a/src/main/java/org/gridsuite/modification/dto/GeneratorModificationInfos.java +++ b/src/main/java/org/gridsuite/modification/dto/GeneratorModificationInfos.java @@ -121,7 +121,7 @@ public AbstractModification toModification() { @Override public ReportNode createSubReportNode(ReportNode reportNode) { return reportNode.newReportNode() - .withMessageTemplate(getType().name(), "Generator modification ${generatorId}") + .withMessageTemplate("network.modification.generator.modification") .withUntypedValue("generatorId", this.getEquipmentId()) .add(); } diff --git a/src/main/java/org/gridsuite/modification/dto/GeneratorScalingInfos.java b/src/main/java/org/gridsuite/modification/dto/GeneratorScalingInfos.java index 73eb26a..f37e6ac 100644 --- a/src/main/java/org/gridsuite/modification/dto/GeneratorScalingInfos.java +++ b/src/main/java/org/gridsuite/modification/dto/GeneratorScalingInfos.java @@ -39,7 +39,7 @@ public AbstractModification toModification() { @Override public ReportNode createSubReportNode(ReportNode reportNode) { return reportNode.newReportNode() - .withMessageTemplate(getType().name(), "Generator scaling") + .withMessageTemplate("network.modification.generatorScaling") .add(); } } diff --git a/src/main/java/org/gridsuite/modification/dto/GroovyScriptInfos.java b/src/main/java/org/gridsuite/modification/dto/GroovyScriptInfos.java index 9986e21..bd15c87 100644 --- a/src/main/java/org/gridsuite/modification/dto/GroovyScriptInfos.java +++ b/src/main/java/org/gridsuite/modification/dto/GroovyScriptInfos.java @@ -41,7 +41,7 @@ public AbstractModification toModification() { @Override public ReportNode createSubReportNode(ReportNode reportNode) { return reportNode.newReportNode() - .withMessageTemplate(getType().name(), "Apply groovy script") + .withMessageTemplate("network.modification.groovyScript") .add(); } } diff --git a/src/main/java/org/gridsuite/modification/dto/LccCreationInfos.java b/src/main/java/org/gridsuite/modification/dto/LccCreationInfos.java index ce72a9d..8c84108 100644 --- a/src/main/java/org/gridsuite/modification/dto/LccCreationInfos.java +++ b/src/main/java/org/gridsuite/modification/dto/LccCreationInfos.java @@ -62,7 +62,7 @@ public AbstractModification toModification() { @Override public ReportNode createSubReportNode(ReportNode reportNode) { return reportNode.newReportNode() - .withMessageTemplate(getType().name(), "Lcc creation ${lccId}") + .withMessageTemplate("network.modification.lcc.creation") .withUntypedValue("lccId", getEquipmentId()) .add(); } diff --git a/src/main/java/org/gridsuite/modification/dto/LineAttachToVoltageLevelInfos.java b/src/main/java/org/gridsuite/modification/dto/LineAttachToVoltageLevelInfos.java index 8e2ad78..cd3a5f8 100644 --- a/src/main/java/org/gridsuite/modification/dto/LineAttachToVoltageLevelInfos.java +++ b/src/main/java/org/gridsuite/modification/dto/LineAttachToVoltageLevelInfos.java @@ -73,7 +73,7 @@ public AbstractModification toModification() { @Override public ReportNode createSubReportNode(ReportNode reportNode) { - return reportNode.newReportNode().withMessageTemplate(getType().name(), "Line attach to voltage level").add(); + return reportNode.newReportNode().withMessageTemplate("network.modification.lineAttachToVoltageLevel").add(); } @Override diff --git a/src/main/java/org/gridsuite/modification/dto/LineCreationInfos.java b/src/main/java/org/gridsuite/modification/dto/LineCreationInfos.java index e272fa0..ab52f19 100644 --- a/src/main/java/org/gridsuite/modification/dto/LineCreationInfos.java +++ b/src/main/java/org/gridsuite/modification/dto/LineCreationInfos.java @@ -53,7 +53,7 @@ public AbstractModification toModification() { @Override public ReportNode createSubReportNode(ReportNode reportNode) { return reportNode.newReportNode() - .withMessageTemplate(getType().name(), "Creation of line ${lineId}") + .withMessageTemplate("network.modification.lineCreation") .withUntypedValue("lineId", getEquipmentId()) .add(); } diff --git a/src/main/java/org/gridsuite/modification/dto/LineModificationInfos.java b/src/main/java/org/gridsuite/modification/dto/LineModificationInfos.java index 6a1f97c..10f3a9d 100644 --- a/src/main/java/org/gridsuite/modification/dto/LineModificationInfos.java +++ b/src/main/java/org/gridsuite/modification/dto/LineModificationInfos.java @@ -53,7 +53,7 @@ public AbstractModification toModification() { @Override public ReportNode createSubReportNode(ReportNode reportNode) { return reportNode.newReportNode() - .withMessageTemplate(getType().name(), "Line modification ${lineId}") + .withMessageTemplate("network.modification.line.modification") .withUntypedValue("lineId", getEquipmentId()) .add(); } diff --git a/src/main/java/org/gridsuite/modification/dto/LineSplitWithVoltageLevelInfos.java b/src/main/java/org/gridsuite/modification/dto/LineSplitWithVoltageLevelInfos.java index 16d1c2a..1eeadb2 100644 --- a/src/main/java/org/gridsuite/modification/dto/LineSplitWithVoltageLevelInfos.java +++ b/src/main/java/org/gridsuite/modification/dto/LineSplitWithVoltageLevelInfos.java @@ -67,7 +67,7 @@ public AbstractModification toModification() { @Override public ReportNode createSubReportNode(ReportNode reportNode) { return reportNode.newReportNode() - .withMessageTemplate(getType().name(), "Line split with voltage level") + .withMessageTemplate("network.modification.lineSplitWithVoltageLevel") .add(); } diff --git a/src/main/java/org/gridsuite/modification/dto/LinesAttachToSplitLinesInfos.java b/src/main/java/org/gridsuite/modification/dto/LinesAttachToSplitLinesInfos.java index 6b8bfa0..0605cfb 100644 --- a/src/main/java/org/gridsuite/modification/dto/LinesAttachToSplitLinesInfos.java +++ b/src/main/java/org/gridsuite/modification/dto/LinesAttachToSplitLinesInfos.java @@ -66,7 +66,7 @@ public AbstractModification toModification() { @Override public ReportNode createSubReportNode(ReportNode reportNode) { return reportNode.newReportNode() - .withMessageTemplate(getType().name(), "Lines attach to split lines") + .withMessageTemplate("network.modification.linesAttachToSplitLines") .add(); } diff --git a/src/main/java/org/gridsuite/modification/dto/LoadCreationInfos.java b/src/main/java/org/gridsuite/modification/dto/LoadCreationInfos.java index 439c74c..87bc1d6 100644 --- a/src/main/java/org/gridsuite/modification/dto/LoadCreationInfos.java +++ b/src/main/java/org/gridsuite/modification/dto/LoadCreationInfos.java @@ -49,7 +49,7 @@ public AbstractModification toModification() { @Override public ReportNode createSubReportNode(ReportNode reportNode) { return reportNode.newReportNode() - .withMessageTemplate(getType().name(), "Load creation ${loadId}") + .withMessageTemplate("network.modification.load.creation") .withUntypedValue("loadId", getEquipmentId()) .add(); } diff --git a/src/main/java/org/gridsuite/modification/dto/LoadModificationInfos.java b/src/main/java/org/gridsuite/modification/dto/LoadModificationInfos.java index d866f77..59e930d 100644 --- a/src/main/java/org/gridsuite/modification/dto/LoadModificationInfos.java +++ b/src/main/java/org/gridsuite/modification/dto/LoadModificationInfos.java @@ -48,7 +48,7 @@ public AbstractModification toModification() { @Override public ReportNode createSubReportNode(ReportNode reportNode) { return reportNode.newReportNode() - .withMessageTemplate(getType().name(), "Load modification ${loadId}") + .withMessageTemplate("network.modification.load.modification") .withUntypedValue("loadId", getEquipmentId()) .add(); } diff --git a/src/main/java/org/gridsuite/modification/dto/LoadScalingInfos.java b/src/main/java/org/gridsuite/modification/dto/LoadScalingInfos.java index 7360fad..3b178be 100644 --- a/src/main/java/org/gridsuite/modification/dto/LoadScalingInfos.java +++ b/src/main/java/org/gridsuite/modification/dto/LoadScalingInfos.java @@ -39,7 +39,7 @@ public AbstractModification toModification() { @Override public ReportNode createSubReportNode(ReportNode reportNode) { return reportNode.newReportNode() - .withMessageTemplate(getType().name(), "Load Scaling") + .withMessageTemplate("network.modification.loadScaling") .add(); } } diff --git a/src/main/java/org/gridsuite/modification/dto/ModificationByAssignmentInfos.java b/src/main/java/org/gridsuite/modification/dto/ModificationByAssignmentInfos.java index 5e2f7c4..a77d74e 100644 --- a/src/main/java/org/gridsuite/modification/dto/ModificationByAssignmentInfos.java +++ b/src/main/java/org/gridsuite/modification/dto/ModificationByAssignmentInfos.java @@ -16,7 +16,6 @@ import lombok.Setter; import lombok.ToString; import lombok.experimental.SuperBuilder; -import org.gridsuite.modification.ModificationType; import org.gridsuite.modification.dto.annotation.ModificationErrorTypeName; import org.gridsuite.modification.dto.byfilter.assignment.AssignmentInfos; import org.gridsuite.modification.modifications.byfilter.ModificationByAssignment; @@ -48,6 +47,6 @@ public ModificationByAssignment toModification() { @Override public ReportNode createSubReportNode(ReportNode reportNode) { - return reportNode.newReportNode().withMessageTemplate(ModificationType.MODIFICATION_BY_ASSIGNMENT.name(), "Modification by filter").add(); + return reportNode.newReportNode().withMessageTemplate("network.modification.modificationByAssignment").add(); } } diff --git a/src/main/java/org/gridsuite/modification/dto/OperatingStatusModificationInfos.java b/src/main/java/org/gridsuite/modification/dto/OperatingStatusModificationInfos.java index 995ebeb..684c23b 100644 --- a/src/main/java/org/gridsuite/modification/dto/OperatingStatusModificationInfos.java +++ b/src/main/java/org/gridsuite/modification/dto/OperatingStatusModificationInfos.java @@ -56,13 +56,10 @@ public AbstractModification toModification() { @Override public ReportNode createSubReportNode(ReportNode reportNode) { - String defaultName = switch (action) { - case LOCKOUT -> "Lockout ${equipmentId}"; - case TRIP -> "Trip ${equipmentId}"; - case ENERGISE_END_ONE, ENERGISE_END_TWO -> "Energise ${equipmentId}"; - case SWITCH_ON -> "Switch on ${equipmentId}"; - }; - return reportNode.newReportNode().withMessageTemplate(getType().name() + "_" + action, defaultName).withUntypedValue("equipmentId", this.getEquipmentId()).add(); + return reportNode.newReportNode() + .withMessageTemplate("network.modification.OPERATING_STATUS_MODIFICATION" + "_" + action) + .withUntypedValue("equipmentId", this.getEquipmentId()) + .add(); } @Override diff --git a/src/main/java/org/gridsuite/modification/dto/ShuntCompensatorCreationInfos.java b/src/main/java/org/gridsuite/modification/dto/ShuntCompensatorCreationInfos.java index b78e682..568ca0c 100644 --- a/src/main/java/org/gridsuite/modification/dto/ShuntCompensatorCreationInfos.java +++ b/src/main/java/org/gridsuite/modification/dto/ShuntCompensatorCreationInfos.java @@ -55,7 +55,7 @@ public AbstractModification toModification() { @Override public ReportNode createSubReportNode(ReportNode reportNode) { return reportNode.newReportNode() - .withMessageTemplate(getType().name(), "Shunt compensator creation ${shuntCompensatorId}") + .withMessageTemplate("network.modification.shuntCompensatorCreation") .withUntypedValue("shuntCompensatorId", this.getEquipmentId()) .add(); } diff --git a/src/main/java/org/gridsuite/modification/dto/ShuntCompensatorModificationInfos.java b/src/main/java/org/gridsuite/modification/dto/ShuntCompensatorModificationInfos.java index 07355e0..b7e0724 100644 --- a/src/main/java/org/gridsuite/modification/dto/ShuntCompensatorModificationInfos.java +++ b/src/main/java/org/gridsuite/modification/dto/ShuntCompensatorModificationInfos.java @@ -57,7 +57,7 @@ public AbstractModification toModification() { @Override public ReportNode createSubReportNode(ReportNode reportNode) { return reportNode.newReportNode() - .withMessageTemplate(getType().name(), "Shunt compensator modification ${shuntCompensatorId}") + .withMessageTemplate("network.modification.shuntCompensatorModification.modification") .withUntypedValue("shuntCompensatorId", this.getEquipmentId()) .add(); } diff --git a/src/main/java/org/gridsuite/modification/dto/StaticVarCompensatorCreationInfos.java b/src/main/java/org/gridsuite/modification/dto/StaticVarCompensatorCreationInfos.java index 9a182fd..b44083e 100644 --- a/src/main/java/org/gridsuite/modification/dto/StaticVarCompensatorCreationInfos.java +++ b/src/main/java/org/gridsuite/modification/dto/StaticVarCompensatorCreationInfos.java @@ -16,7 +16,6 @@ import lombok.ToString; import lombok.experimental.SuperBuilder; -import org.gridsuite.modification.ModificationType; import org.gridsuite.modification.dto.annotation.ModificationErrorTypeName; import org.gridsuite.modification.modifications.AbstractModification; import org.gridsuite.modification.modifications.StaticVarCompensatorCreation; @@ -98,7 +97,6 @@ public AbstractModification toModification() { @Override public ReportNode createSubReportNode(ReportNode reportNode) { - return reportNode.newReportNode().withMessageTemplate(ModificationType.STATIC_VAR_COMPENSATOR_CREATION.name(), - "Static var compensator creation ${id}").withUntypedValue("id", this.getEquipmentId()).add(); + return reportNode.newReportNode().withMessageTemplate("network.modification.staticVarCompensatorCreation").withUntypedValue("id", this.getEquipmentId()).add(); } } diff --git a/src/main/java/org/gridsuite/modification/dto/SubstationCreationInfos.java b/src/main/java/org/gridsuite/modification/dto/SubstationCreationInfos.java index ea637c7..8b31029 100644 --- a/src/main/java/org/gridsuite/modification/dto/SubstationCreationInfos.java +++ b/src/main/java/org/gridsuite/modification/dto/SubstationCreationInfos.java @@ -45,7 +45,7 @@ public AbstractModification toModification() { @Override public ReportNode createSubReportNode(ReportNode reportNode) { return reportNode.newReportNode() - .withMessageTemplate(getType().name(), "Substation creation ${substationId}") + .withMessageTemplate("network.modification.substation.creation") .withUntypedValue("substationId", this.getEquipmentId()) .add(); } diff --git a/src/main/java/org/gridsuite/modification/dto/SubstationModificationInfos.java b/src/main/java/org/gridsuite/modification/dto/SubstationModificationInfos.java index da49095..5ee5c40 100644 --- a/src/main/java/org/gridsuite/modification/dto/SubstationModificationInfos.java +++ b/src/main/java/org/gridsuite/modification/dto/SubstationModificationInfos.java @@ -45,7 +45,7 @@ public AbstractModification toModification() { @Override public ReportNode createSubReportNode(ReportNode reportNode) { return reportNode.newReportNode() - .withMessageTemplate(getType().name(), "Substation modification ${substationId}") + .withMessageTemplate("network.modification.substation.modification") .withUntypedValue("substationId", this.getEquipmentId()) .add(); } diff --git a/src/main/java/org/gridsuite/modification/dto/TabularCreationInfos.java b/src/main/java/org/gridsuite/modification/dto/TabularCreationInfos.java index 7ff7ce8..ca40c04 100644 --- a/src/main/java/org/gridsuite/modification/dto/TabularCreationInfos.java +++ b/src/main/java/org/gridsuite/modification/dto/TabularCreationInfos.java @@ -52,7 +52,7 @@ public AbstractModification toModification() { @Override public ReportNode createSubReportNode(ReportNode reportNode) { return reportNode.newReportNode() - .withMessageTemplate(ModificationType.TABULAR_CREATION.name(), "Tabular creation") + .withMessageTemplate("network.modification.tabularCreation") .add(); } diff --git a/src/main/java/org/gridsuite/modification/dto/TabularModificationInfos.java b/src/main/java/org/gridsuite/modification/dto/TabularModificationInfos.java index 9e14130..f72d056 100644 --- a/src/main/java/org/gridsuite/modification/dto/TabularModificationInfos.java +++ b/src/main/java/org/gridsuite/modification/dto/TabularModificationInfos.java @@ -50,7 +50,7 @@ public AbstractModification toModification() { @Override public ReportNode createSubReportNode(ReportNode reportNode) { return reportNode.newReportNode() - .withMessageTemplate(ModificationType.TABULAR_CREATION.name(), "Tabular modification") + .withMessageTemplate("network.modification.tabularModification") .add(); } diff --git a/src/main/java/org/gridsuite/modification/dto/TwoWindingsTransformerCreationInfos.java b/src/main/java/org/gridsuite/modification/dto/TwoWindingsTransformerCreationInfos.java index bf6e070..1dadad2 100644 --- a/src/main/java/org/gridsuite/modification/dto/TwoWindingsTransformerCreationInfos.java +++ b/src/main/java/org/gridsuite/modification/dto/TwoWindingsTransformerCreationInfos.java @@ -62,7 +62,7 @@ public AbstractModification toModification() { @Override public ReportNode createSubReportNode(ReportNode reportNode) { return reportNode.newReportNode() - .withMessageTemplate(getType().name(), "Two windings transformer creation ${twoWindingsTransformerId}") + .withMessageTemplate("network.modification.twoWindingsTransformerCreation") .withUntypedValue("twoWindingsTransformerId", getEquipmentId()) .add(); } diff --git a/src/main/java/org/gridsuite/modification/dto/TwoWindingsTransformerModificationInfos.java b/src/main/java/org/gridsuite/modification/dto/TwoWindingsTransformerModificationInfos.java index 3324826..9cfca30 100644 --- a/src/main/java/org/gridsuite/modification/dto/TwoWindingsTransformerModificationInfos.java +++ b/src/main/java/org/gridsuite/modification/dto/TwoWindingsTransformerModificationInfos.java @@ -66,7 +66,7 @@ public AbstractModification toModification() { @Override public ReportNode createSubReportNode(ReportNode reportNode) { return reportNode.newReportNode() - .withMessageTemplate(getType().name(), "Two windings transformer modification ${twoWindingsTransformerId}") + .withMessageTemplate("network.modification.twoWindingsTransformerModification.modification") .withUntypedValue("twoWindingsTransformerId", getEquipmentId()) .add(); } diff --git a/src/main/java/org/gridsuite/modification/dto/VoltageInitModificationInfos.java b/src/main/java/org/gridsuite/modification/dto/VoltageInitModificationInfos.java index 81f4c8e..2844333 100644 --- a/src/main/java/org/gridsuite/modification/dto/VoltageInitModificationInfos.java +++ b/src/main/java/org/gridsuite/modification/dto/VoltageInitModificationInfos.java @@ -13,7 +13,6 @@ import lombok.NoArgsConstructor; import lombok.Setter; import lombok.experimental.SuperBuilder; -import org.gridsuite.modification.ModificationType; import org.gridsuite.modification.dto.annotation.ModificationErrorTypeName; import org.gridsuite.modification.modifications.AbstractModification; import org.gridsuite.modification.modifications.VoltageInitModification; @@ -56,6 +55,6 @@ public AbstractModification toModification() { @Override public ReportNode createSubReportNode(ReportNode reportNode) { - return reportNode.newReportNode().withMessageTemplate(ModificationType.VOLTAGE_INIT_MODIFICATION.name(), "Voltage init modification").add(); + return reportNode.newReportNode().withMessageTemplate("network.modification.voltageInitModification").add(); } } diff --git a/src/main/java/org/gridsuite/modification/dto/VoltageLevelCreationInfos.java b/src/main/java/org/gridsuite/modification/dto/VoltageLevelCreationInfos.java index 62ebc2f..d007d7c 100644 --- a/src/main/java/org/gridsuite/modification/dto/VoltageLevelCreationInfos.java +++ b/src/main/java/org/gridsuite/modification/dto/VoltageLevelCreationInfos.java @@ -88,7 +88,7 @@ public Map getMapMessageValues() { @Override public ReportNode createSubReportNode(ReportNode reportNode) { return reportNode.newReportNode() - .withMessageTemplate(getType().name(), "VoltageLevel creation ${voltageLevelId}") + .withMessageTemplate("network.modification.voltageLevel.creation") .withUntypedValue("voltageLevelId", getEquipmentId()) .add(); } diff --git a/src/main/java/org/gridsuite/modification/dto/VoltageLevelModificationInfos.java b/src/main/java/org/gridsuite/modification/dto/VoltageLevelModificationInfos.java index b6a026b..b077c85 100644 --- a/src/main/java/org/gridsuite/modification/dto/VoltageLevelModificationInfos.java +++ b/src/main/java/org/gridsuite/modification/dto/VoltageLevelModificationInfos.java @@ -54,7 +54,7 @@ public AbstractModification toModification() { @Override public ReportNode createSubReportNode(ReportNode reportNode) { return reportNode.newReportNode() - .withMessageTemplate(getType().name(), "VoltageLevel modification ${voltageLevelId}") + .withMessageTemplate("network.modification.voltageLevel.modification") .withUntypedValue("voltageLevelId", getEquipmentId()) .add(); } diff --git a/src/main/java/org/gridsuite/modification/dto/VoltageLevelTopologyModificationInfos.java b/src/main/java/org/gridsuite/modification/dto/VoltageLevelTopologyModificationInfos.java index b587397..a081c04 100644 --- a/src/main/java/org/gridsuite/modification/dto/VoltageLevelTopologyModificationInfos.java +++ b/src/main/java/org/gridsuite/modification/dto/VoltageLevelTopologyModificationInfos.java @@ -44,7 +44,7 @@ public AbstractModification toModification() { @Override public ReportNode createSubReportNode(ReportNode reportNode) { return reportNode.newReportNode() - .withMessageTemplate(getType().name(), "Voltage Level topology modification ${voltageLevelId}") + .withMessageTemplate("network.modification.VOLTAGE_LEVEL_TOPOLOGY_MODIFICATION") .withUntypedValue("voltageLevelId", getEquipmentId()) .add(); } diff --git a/src/main/java/org/gridsuite/modification/dto/VscCreationInfos.java b/src/main/java/org/gridsuite/modification/dto/VscCreationInfos.java index ffa8272..37e9d2a 100644 --- a/src/main/java/org/gridsuite/modification/dto/VscCreationInfos.java +++ b/src/main/java/org/gridsuite/modification/dto/VscCreationInfos.java @@ -78,7 +78,7 @@ public AbstractModification toModification() { @Override public ReportNode createSubReportNode(ReportNode reportNode) { return reportNode.newReportNode() - .withMessageTemplate(getType().name(), "Vsc creation ${vscId}") + .withMessageTemplate("network.modification.vsc.creation") .withUntypedValue("vscId", getEquipmentId()) .add(); } diff --git a/src/main/java/org/gridsuite/modification/dto/VscModificationInfos.java b/src/main/java/org/gridsuite/modification/dto/VscModificationInfos.java index b19d156..8de25fe 100644 --- a/src/main/java/org/gridsuite/modification/dto/VscModificationInfos.java +++ b/src/main/java/org/gridsuite/modification/dto/VscModificationInfos.java @@ -67,7 +67,7 @@ public AbstractModification toModification() { @Override public ReportNode createSubReportNode(ReportNode reportNode) { return reportNode.newReportNode() - .withMessageTemplate(getType().name(), "Vsc modification ${vscId}") + .withMessageTemplate("network.modification.vsc.modification") .withUntypedValue("vscId", getEquipmentId()) .add(); } diff --git a/src/main/java/org/gridsuite/modification/modifications/AbstractBranchModification.java b/src/main/java/org/gridsuite/modification/modifications/AbstractBranchModification.java index 4ffb506..a8c8530 100644 --- a/src/main/java/org/gridsuite/modification/modifications/AbstractBranchModification.java +++ b/src/main/java/org/gridsuite/modification/modifications/AbstractBranchModification.java @@ -46,14 +46,14 @@ protected AbstractBranchModification(BranchModificationInfos modificationInfos) this.modificationInfos = modificationInfos; } - protected void modifyBranch(Branch branch, BranchModificationInfos branchModificationInfos, ReportNode subReportNode, String reporterKey, String reporterDefaultMessage) { + protected void modifyBranch(Branch branch, BranchModificationInfos branchModificationInfos, ReportNode subReportNode, String reporterKey) { subReportNode.newReportNode() - .withMessageTemplate(reporterKey, reporterDefaultMessage) + .withMessageTemplate(reporterKey) .withUntypedValue("id", branchModificationInfos.getEquipmentId()) .withSeverity(TypedValue.INFO_SEVERITY) .add(); if (branchModificationInfos.getEquipmentName() != null) { - insertReportNode(subReportNode, ModificationUtils.getInstance().buildModificationReport(Optional.of(branch.getOptionalName()).orElse(null), branchModificationInfos.getEquipmentName().getValue(), "Name", 0)); + insertReportNode(subReportNode, ModificationUtils.getInstance().buildModificationReport(Optional.of(branch.getOptionalName()).orElse(null), branchModificationInfos.getEquipmentName().getValue(), "Name")); branch.setName(branchModificationInfos.getEquipmentName().getValue()); } @@ -76,11 +76,9 @@ protected void modifyBranch(Branch branch, BranchModificationInfos branchModi modifyCurrentLimits(currentLimitsInfos2, branch.newCurrentLimits2(), currentLimits2, side2LimitsReports); } if (!side1LimitsReports.isEmpty() || !side2LimitsReports.isEmpty()) { - ReportNode limitsReportNode = subReportNode.newReportNode().withMessageTemplate("limits", "Limits").add(); - ModificationUtils.getInstance().reportModifications(limitsReportNode, side1LimitsReports, "side1LimitsModification", - " Side 1"); - ModificationUtils.getInstance().reportModifications(limitsReportNode, side2LimitsReports, "side2LimitsModification", - " Side 2"); + ReportNode limitsReportNode = subReportNode.newReportNode().withMessageTemplate("network.modification.limits").add(); + ModificationUtils.getInstance().reportModifications(limitsReportNode, side1LimitsReports, "network.modification.side1LimitsModification"); + ModificationUtils.getInstance().reportModifications(limitsReportNode, side2LimitsReports, "network.modification.side2LimitsModification"); } updateConnections(branch, branchModificationInfos); @@ -115,13 +113,13 @@ public ReportNode updateMeasurements(Branch branch, BranchModificationInfos b // report changes ReportNode estimSubReportNode = null; if (!side1Reports.isEmpty() || !side2Reports.isEmpty()) { - estimSubReportNode = subReportNode.newReportNode().withMessageTemplate("StateEstimationData", "State estimation").add(); + estimSubReportNode = subReportNode.newReportNode().withMessageTemplate("network.modification.stateEstimationData").add(); } if (!side1Reports.isEmpty()) { - ModificationUtils.getInstance().reportModifications(estimSubReportNode, side1Reports, "measurementsSide1", " Side 1"); + ModificationUtils.getInstance().reportModifications(estimSubReportNode, side1Reports, "network.modification.measurementsSide1"); } if (!side2Reports.isEmpty()) { - ModificationUtils.getInstance().reportModifications(estimSubReportNode, side2Reports, "measurementsSide2", " Side 2"); + ModificationUtils.getInstance().reportModifications(estimSubReportNode, side2Reports, "network.modification.measurementsSide2"); } return estimSubReportNode; } @@ -136,22 +134,22 @@ private void upsertMeasurement(Measurements measurements, Measurement.Type ty if (value != null) { double oldValue = m.getValue(); m.setValue(value); - reports.add(ModificationUtils.buildModificationReport(oldValue, value, measurementType + VALUE, 1, TypedValue.INFO_SEVERITY)); + reports.add(ModificationUtils.buildModificationReport(oldValue, value, measurementType + VALUE, TypedValue.INFO_SEVERITY)); } if (validity != null) { boolean oldValidity = m.isValid(); m.setValid(validity); - reports.add(ModificationUtils.buildModificationReport(oldValidity, validity, measurementType + VALIDITY, 1, TypedValue.INFO_SEVERITY)); + reports.add(ModificationUtils.buildModificationReport(oldValidity, validity, measurementType + VALIDITY, TypedValue.INFO_SEVERITY)); } } else { // add new measurement var mAdder = measurements.newMeasurement().setId(UUID.randomUUID().toString()).setType(type).setSide(side); if (value != null) { mAdder.setValue(value); - reports.add(ModificationUtils.buildModificationReport(null, value, measurementType + VALUE, 1, TypedValue.INFO_SEVERITY)); + reports.add(ModificationUtils.buildModificationReport(null, value, measurementType + VALUE, TypedValue.INFO_SEVERITY)); } if (validity != null) { mAdder.setValid(validity); - reports.add(ModificationUtils.buildModificationReport(null, validity, measurementType + VALIDITY, 1, TypedValue.INFO_SEVERITY)); + reports.add(ModificationUtils.buildModificationReport(null, validity, measurementType + VALIDITY, TypedValue.INFO_SEVERITY)); } mAdder.add(); } @@ -201,7 +199,7 @@ protected void modifyCurrentLimits(CurrentLimitsModificationInfos currentLimitsI boolean hasPermanent = currentLimitsInfos.getPermanentLimit() != null; if (hasPermanent) { limitsReports.add(ModificationUtils.getInstance().buildModificationReport(currentLimits != null ? currentLimits.getPermanentLimit() : Double.NaN, - currentLimitsInfos.getPermanentLimit(), "IST", 2)); + currentLimitsInfos.getPermanentLimit(), "IST")); limitsAdder.setPermanentLimit(currentLimitsInfos.getPermanentLimit()); } else { if (currentLimits != null) { @@ -236,7 +234,8 @@ protected void modifyTemporaryLimits(CurrentLimitsModificationInfos currentLimit } if (limitToModify == null && limit.getModificationType() == TemporaryLimitModificationType.ADDED) { temporaryLimitsReports.add(ReportNode.newRootReportNode() - .withMessageTemplate("temporaryLimitAdded" + limit.getName(), " ${name} (${duration}) added with ${value}") + .withAllResourceBundlesFromClasspath() + .withMessageTemplate("network.modification.temporaryLimitAdded.name") .withUntypedValue(NAME, limit.getName()) .withUntypedValue(DURATION, limitDurationToReport) .withUntypedValue(VALUE, limitValueToReport) @@ -246,7 +245,8 @@ protected void modifyTemporaryLimits(CurrentLimitsModificationInfos currentLimit } else if (limitToModify != null) { if (limit.getModificationType() == TemporaryLimitModificationType.DELETED) { temporaryLimitsReports.add(ReportNode.newRootReportNode() - .withMessageTemplate("temporaryLimitDeleted" + limit.getName(), " ${name} (${duration}) deleted") + .withAllResourceBundlesFromClasspath() + .withMessageTemplate("network.modification.temporaryLimitDeleted.name") .withUntypedValue(NAME, limit.getName()) .withUntypedValue(DURATION, limitDurationToReport) .withSeverity(TypedValue.INFO_SEVERITY) @@ -254,7 +254,8 @@ protected void modifyTemporaryLimits(CurrentLimitsModificationInfos currentLimit continue; } else if (Double.compare(limitToModify.getValue(), limitValue) != 0 && limit.getModificationType() != null) { temporaryLimitsReports.add(ReportNode.newRootReportNode() - .withMessageTemplate("temporaryLimitModified" + limit.getName(), " ${name} (${duration}) : ${oldValue} -> ${value}") + .withAllResourceBundlesFromClasspath() + .withMessageTemplate("network.modification.temporaryLimitModified.name") .withUntypedValue(NAME, limit.getName()) .withUntypedValue(DURATION, limitDurationToReport) .withUntypedValue(VALUE, limitValueToReport) @@ -289,7 +290,8 @@ protected void modifyTemporaryLimits(CurrentLimitsModificationInfos currentLimit } if (!temporaryLimitsReports.isEmpty()) { temporaryLimitsReports.add(0, ReportNode.newRootReportNode() - .withMessageTemplate("temporaryLimitsModification", " Temporary current limits :") + .withAllResourceBundlesFromClasspath() + .withMessageTemplate("network.modification.temporaryLimitsModification") .withSeverity(TypedValue.INFO_SEVERITY) .build()); limitsReports.addAll(temporaryLimitsReports); diff --git a/src/main/java/org/gridsuite/modification/modifications/AbstractInjectionModification.java b/src/main/java/org/gridsuite/modification/modifications/AbstractInjectionModification.java index 4645f96..d3a4040 100644 --- a/src/main/java/org/gridsuite/modification/modifications/AbstractInjectionModification.java +++ b/src/main/java/org/gridsuite/modification/modifications/AbstractInjectionModification.java @@ -54,8 +54,8 @@ protected ReportNode updateMeasurements(Injection injection, InjectionModific // report changes ReportNode estimSubReportNode = null; if (!reports.isEmpty()) { - estimSubReportNode = subReportNode.newReportNode().withMessageTemplate("StateEstimationData", "State estimation").add(); - ModificationUtils.getInstance().reportModifications(estimSubReportNode, reports, "measurements", " Measurements"); + estimSubReportNode = subReportNode.newReportNode().withMessageTemplate("network.modification.stateEstimationData").add(); + ModificationUtils.getInstance().reportModifications(estimSubReportNode, reports, "network.modification.measurements"); } return estimSubReportNode; } @@ -70,22 +70,22 @@ private void upsertMeasurement(Measurements measurements, Measurement.Type ty if (value != null) { double oldValue = measurement.getValue(); measurement.setValue(value); - reports.add(ModificationUtils.buildModificationReport(oldValue, value, measurementType + VALUE, 1, TypedValue.INFO_SEVERITY)); + reports.add(ModificationUtils.buildModificationReport(oldValue, value, measurementType + VALUE, TypedValue.INFO_SEVERITY)); } if (validity != null) { boolean oldValidity = measurement.isValid(); measurement.setValid(validity); - reports.add(ModificationUtils.buildModificationReport(oldValidity, validity, measurementType + VALIDITY, 1, TypedValue.INFO_SEVERITY)); + reports.add(ModificationUtils.buildModificationReport(oldValidity, validity, measurementType + VALIDITY, TypedValue.INFO_SEVERITY)); } } else { var measurementAdder = measurements.newMeasurement().setId(UUID.randomUUID().toString()).setType(type); if (value != null) { measurementAdder.setValue(value); - reports.add(ModificationUtils.buildModificationReport(null, value, measurementType + VALUE, 1, TypedValue.INFO_SEVERITY)); + reports.add(ModificationUtils.buildModificationReport(null, value, measurementType + VALUE, TypedValue.INFO_SEVERITY)); } if (validity != null) { measurementAdder.setValid(validity); - reports.add(ModificationUtils.buildModificationReport(null, validity, measurementType + VALIDITY, 1, TypedValue.INFO_SEVERITY)); + reports.add(ModificationUtils.buildModificationReport(null, validity, measurementType + VALIDITY, TypedValue.INFO_SEVERITY)); } measurementAdder.add(); } diff --git a/src/main/java/org/gridsuite/modification/modifications/AbstractModification.java b/src/main/java/org/gridsuite/modification/modifications/AbstractModification.java index 88a1d3c..219777a 100644 --- a/src/main/java/org/gridsuite/modification/modifications/AbstractModification.java +++ b/src/main/java/org/gridsuite/modification/modifications/AbstractModification.java @@ -20,9 +20,6 @@ */ public abstract class AbstractModification extends AbstractNetworkModification { - public static final String CHARACTERISTICS = "Characteristics"; - public static final String SETPOINTS = "Setpoints"; - @Override public void apply(Network network, NamingStrategy namingStrategy, boolean throwException, ComputationManager computationManager, ReportNode reportNode) { apply(network, reportNode); diff --git a/src/main/java/org/gridsuite/modification/modifications/AbstractScaling.java b/src/main/java/org/gridsuite/modification/modifications/AbstractScaling.java index 6b502a7..c1725a4 100644 --- a/src/main/java/org/gridsuite/modification/modifications/AbstractScaling.java +++ b/src/main/java/org/gridsuite/modification/modifications/AbstractScaling.java @@ -61,15 +61,12 @@ public void apply(Network network, ReportNode subReportNode) { if (CollectionUtils.isEmpty(identifiableAttributes)) { String filterNames = variation.getFilters().stream().map(FilterInfos::getName).collect(Collectors.joining(", ")); - createReport(subReportNode, - "allFiltersWrong", - "All of the following variation's filters have equipments with wrong id : ${filterNames}", - Map.of("filterNames", filterNames), TypedValue.WARN_SEVERITY); + createReport(subReportNode, "network.modification.allFiltersWrong.variation", Map.of("filterNames", filterNames), TypedValue.WARN_SEVERITY); } else { applyVariation(network, subReportNode, identifiableAttributes, variation); } }); - createReport(subReportNode, "scalingCreated", "new scaling created", Map.of(), TypedValue.INFO_SEVERITY); + createReport(subReportNode, "network.modification.scalingCreated", Map.of(), TypedValue.INFO_SEVERITY); } } @@ -104,7 +101,7 @@ private Double getDistributionKeys(Set identifiableAttri .mapToDouble(IdentifiableAttributes::getDistributionKey) .sum(); if (distributionKeys == 0) { - createReport(subReportNode, "distributionKeysNotFound", "This mode is available only for equipment with distribution key", Map.of(), TypedValue.WARN_SEVERITY); + createReport(subReportNode, "network.modification.distributionKeysNotFound", Map.of(), TypedValue.WARN_SEVERITY); return null; } return distributionKeys; diff --git a/src/main/java/org/gridsuite/modification/modifications/BatteryCreation.java b/src/main/java/org/gridsuite/modification/modifications/BatteryCreation.java index a4be616..ece4920 100644 --- a/src/main/java/org/gridsuite/modification/modifications/BatteryCreation.java +++ b/src/main/java/org/gridsuite/modification/modifications/BatteryCreation.java @@ -30,8 +30,6 @@ public class BatteryCreation extends AbstractModification { private final BatteryCreationInfos modificationInfos; - private static final String LIMITS = "Limits"; - private static final String ACTIVE_LIMITS = "Active limits"; public BatteryCreation(BatteryCreationInfos modificationInfos) { this.modificationInfos = modificationInfos; @@ -74,7 +72,7 @@ public void apply(Network network, ReportNode subReportNode) { } // properties Battery battery = network.getBattery(modificationInfos.getEquipmentId()); - PropertiesUtils.applyProperties(battery, subReportNode, modificationInfos.getProperties(), "BatteryProperties"); + PropertiesUtils.applyProperties(battery, subReportNode, modificationInfos.getProperties(), "network.modification.BatteryProperties"); } @Override @@ -118,7 +116,7 @@ private void createBatteryInBusBreaker(VoltageLevel voltageLevel, BatteryCreatio addExtensionsToBattery(batteryCreationInfos, battery, subReportNode); subReportNode.newReportNode() - .withMessageTemplate("batteryCreated", "New battery with id=${id} created") + .withMessageTemplate("network.modification.batteryCreated") .withUntypedValue("id", modificationInfos.getEquipmentId()) .withSeverity(TypedValue.INFO_SEVERITY) .add(); @@ -143,17 +141,17 @@ private ReportNode reportBatterySetPoints(BatteryCreationInfos batteryCreationIn setPointReports.add(ModificationUtils.getInstance() .buildCreationReport(batteryCreationInfos.getTargetQ(), "Reactive power")); } - return ModificationUtils.getInstance().reportModifications(subReportNode, setPointReports, "SetPointCreated", "Setpoints"); + return ModificationUtils.getInstance().reportModifications(subReportNode, setPointReports, "network.modification.SetPointCreated"); } private ReportNode reportBatteryActiveLimits(BatteryCreationInfos batteryCreationInfos, ReportNode subReportNode) { - ReportNode subReportNodeLimits = subReportNode.newReportNode().withMessageTemplate(LIMITS, LIMITS).add(); + ReportNode subReportNodeLimits = subReportNode.newReportNode().withMessageTemplate("network.modification.limits").add(); List limitsReports = new ArrayList<>(); limitsReports.add(ModificationUtils.getInstance().buildCreationReport( batteryCreationInfos.getMinP(), "Min active power")); limitsReports.add(ModificationUtils.getInstance().buildCreationReport( batteryCreationInfos.getMaxP(), "Max active power")); - ModificationUtils.getInstance().reportModifications(subReportNodeLimits, limitsReports, "ActiveLimitsCreated", ACTIVE_LIMITS); + ModificationUtils.getInstance().reportModifications(subReportNodeLimits, limitsReports, "network.modification.ActiveLimitsCreated"); return subReportNodeLimits; } @@ -173,13 +171,14 @@ private void createBatteryActivePowerControl(BatteryCreationInfos batteryCreatio "Droop")); } catch (PowsyblException e) { activePowerRegulationReports.add(ReportNode.newRootReportNode() - .withMessageTemplate("ActivePowerExtensionAddError", "cannot add active power extension on battery with id=${id} : ${message}") + .withAllResourceBundlesFromClasspath() + .withMessageTemplate("network.modification.activePowerExtensionAddError.battery") .withUntypedValue("id", batteryCreationInfos.getEquipmentId()) .withUntypedValue("message", e.getMessage()) .withSeverity(TypedValue.ERROR_SEVERITY) .build()); } - ModificationUtils.getInstance().reportModifications(subReporter, activePowerRegulationReports, "ActivePowerRegulationCreated", "Active power regulation"); + ModificationUtils.getInstance().reportModifications(subReporter, activePowerRegulationReports, "network.modification.ActivePowerRegulationCreated"); } } } diff --git a/src/main/java/org/gridsuite/modification/modifications/BatteryModification.java b/src/main/java/org/gridsuite/modification/modifications/BatteryModification.java index 10bb39d..3425566 100644 --- a/src/main/java/org/gridsuite/modification/modifications/BatteryModification.java +++ b/src/main/java/org/gridsuite/modification/modifications/BatteryModification.java @@ -34,9 +34,6 @@ public class BatteryModification extends AbstractModification { private final BatteryModificationInfos modificationInfos; - private static final String LIMITS = "Limits"; - private static final String ACTIVE_LIMITS = "Active limits"; - private static final String SETPOINTS = "Setpoints"; public static final String ERROR_MESSAGE = "Battery '%s' : "; public BatteryModification(BatteryModificationInfos modificationInfos) { @@ -85,7 +82,7 @@ public String getName() { private void modifyBattery(Battery battery, BatteryModificationInfos modificationInfos, ReportNode subReportNode) { subReportNode.newReportNode() - .withMessageTemplate("batteryModification", "Battery with id=${id} modified :") + .withMessageTemplate("network.modification.batteryModification") .withUntypedValue("id", modificationInfos.getEquipmentId()) .withSeverity(TypedValue.INFO_SEVERITY) .add(); @@ -100,7 +97,7 @@ private void modifyBattery(Battery battery, BatteryModificationInfos modificatio modificationInfos.getParticipate(), modificationInfos.getDroop(), battery, subReportNode); modifyBatteryConnectivityAttributes(modificationInfos, battery, subReportNode); - PropertiesUtils.applyProperties(battery, subReportNode, modificationInfos.getProperties(), "BatteryProperties"); + PropertiesUtils.applyProperties(battery, subReportNode, modificationInfos.getProperties(), "network.modification.BatteryProperties"); } public static void modifyBatterySetpointsAttributes(AttributeModification targetP, @@ -113,7 +110,7 @@ public static void modifyBatterySetpointsAttributes(AttributeModification converterStation1 = hvdcLine.getConverterStation1(); HvdcConverterStation converterStation2 = hvdcLine.getConverterStation2(); if (converterStation1.getHvdcType() == HvdcConverterStation.HvdcType.LCC || converterStation2.getHvdcType() == HvdcConverterStation.HvdcType.LCC) { - String hdvcLineId = identifiableAttribute.getId(); subReportNode.newReportNode() - .withMessageTemplate("SCNotRemoved" + hdvcLineId, "Shunt compensators were not removed for HVDC line id=${id}") + .withMessageTemplate("network.modification.SCNotRemoved") .withUntypedValue("id", identifiableAttribute.getId()) .withSeverity(TypedValue.WARN_SEVERITY) .add(); diff --git a/src/main/java/org/gridsuite/modification/modifications/EquipmentAttributeModification.java b/src/main/java/org/gridsuite/modification/modifications/EquipmentAttributeModification.java index b2daa08..df14618 100644 --- a/src/main/java/org/gridsuite/modification/modifications/EquipmentAttributeModification.java +++ b/src/main/java/org/gridsuite/modification/modifications/EquipmentAttributeModification.java @@ -71,7 +71,7 @@ private void changeSwitchAttribute(Switch aSwitch, String attributeName, Object if (Boolean.TRUE.equals(aSwitch.isOpen() != (Boolean) attributeValue)) { aSwitch.setOpen((Boolean) attributeValue); reportNode.newReportNode() - .withMessageTemplate("switchChanged", "${operation} switch '${id}' in voltage level ${voltageLevelId}") + .withMessageTemplate("network.modification.switchChanged") .withUntypedValue("id", aSwitch.getId()) .withUntypedValue("operation", Boolean.TRUE.equals(attributeValue) ? "Opening" : "Closing") .withUntypedValue("voltageLevelId", aSwitch.getVoltageLevel().getId()) @@ -88,7 +88,7 @@ private void changeGeneratorAttribute(Generator generator, String attributeName, if (attributeName.equals("targetP")) { generator.setTargetP((Double) attributeValue); reportNode.newReportNode() - .withMessageTemplate("generatorChanged", "Generator with id=${id} targetP changed") + .withMessageTemplate("network.modification.generatorChanged") .withUntypedValue("id", generator.getId()) .withSeverity(TypedValue.INFO_SEVERITY) .add(); @@ -102,7 +102,7 @@ private void changeLineAttribute(Line line, String attributeName, Object attribu if (attributeName.equals("operatingStatus")) { line.newExtension(OperatingStatusAdder.class).withStatus(OperatingStatus.Status.valueOf((String) attributeValue)).add(); reportNode.newReportNode() - .withMessageTemplate("lineStatusChanged", "Branch with id=${id} status changed") + .withMessageTemplate("network.modification.lineStatusChanged") .withUntypedValue("id", line.getId()) .withSeverity(TypedValue.INFO_SEVERITY) .add(); @@ -114,24 +114,21 @@ private void changeLineAttribute(Line line, String attributeName, Object attribu // TODO remove only for switch private void changeTwoWindingsTransformerAttribute(TwoWindingsTransformer transformer, String attributeName, Object attributeValue, ReportNode reportNode) { String reportKey; - String reportDefaultMessage; switch (attributeName) { case "ratioTapChanger.tapPosition": transformer.getOptionalRatioTapChanger().ifPresent(r -> r.setTapPosition((Integer) attributeValue)); - reportKey = "ratioTapPositionChanged"; - reportDefaultMessage = "2WT with id=${id} ratio tap changer position changed"; + reportKey = "network.modification.ratioTapPositionChanged"; break; case "phaseTapChanger.tapPosition": - reportKey = "phaseTapPositionChanged"; - reportDefaultMessage = "2WT with id=${id} phase tap changer position changed"; + reportKey = "network.modification.phaseTapPositionChanged"; break; default: throw NetworkModificationException.createEquipementAttributeNotEditable(transformer.getType(), attributeName); } reportNode.newReportNode() - .withMessageTemplate(reportKey, reportDefaultMessage) + .withMessageTemplate(reportKey) .withUntypedValue("id", transformer.getId()) .withSeverity(TypedValue.INFO_SEVERITY) .add(); @@ -140,45 +137,38 @@ private void changeTwoWindingsTransformerAttribute(TwoWindingsTransformer transf // TODO remove only for switch private void changeThreeWindingsTransformerAttribute(ThreeWindingsTransformer transformer, String attributeName, Object attributeValue, ReportNode reportNode) { String reportKey; - String reportDefaultMessage; switch (attributeName) { case "ratioTapChanger1.tapPosition": transformer.getLeg1().getOptionalRatioTapChanger().ifPresent(r -> r.setTapPosition((Integer) attributeValue)); - reportKey = "ratioTapChanger1.tapPosition"; - reportDefaultMessage = "3WT with id=${id} ratio tap changer 1 position changed"; + reportKey = "network.modification.ratioTapChanger1.tapPosition"; break; case "ratioTapChanger2.tapPosition": transformer.getLeg2().getOptionalRatioTapChanger().ifPresent(r -> r.setTapPosition((Integer) attributeValue)); - reportKey = "ratioTapChanger2.tapPosition"; - reportDefaultMessage = "3WT with id=${id} ratio tap changer 2 position changed"; + reportKey = "network.modification.ratioTapChanger2.tapPosition"; break; case "ratioTapChanger3.tapPosition": transformer.getLeg3().getOptionalRatioTapChanger().ifPresent(r -> r.setTapPosition((Integer) attributeValue)); - reportKey = "ratioTapChanger3.tapPosition"; - reportDefaultMessage = "3WT with id=${id} ratio tap changer 3 position changed"; + reportKey = "network.modification.ratioTapChanger3.tapPosition"; break; case "phaseTapChanger1.tapPosition": transformer.getLeg1().getOptionalPhaseTapChanger().ifPresent(p -> p.setTapPosition((Integer) attributeValue)); - reportKey = "phaseTapChanger1.tapPosition"; - reportDefaultMessage = "3WT with id=${id} phase tap changer 1 position changed"; + reportKey = "network.modification.phaseTapChanger1.tapPosition"; break; case "phaseTapChanger2.tapPosition": transformer.getLeg2().getOptionalPhaseTapChanger().ifPresent(p -> p.setTapPosition((Integer) attributeValue)); - reportKey = "phaseTapChanger2.tapPosition"; - reportDefaultMessage = "3WT with id=${id} phase tap changer 2 position changed"; + reportKey = "network.modification.phaseTapChanger2.tapPosition"; break; case "phaseTapChanger3.tapPosition": transformer.getLeg3().getOptionalPhaseTapChanger().ifPresent(p -> p.setTapPosition((Integer) attributeValue)); - reportKey = "phaseTapChanger3.tapPosition"; - reportDefaultMessage = "3WT with id=${id} phase tap changer 3 position changed"; + reportKey = "network.modification.phaseTapChanger3.tapPosition"; break; default: throw NetworkModificationException.createEquipementAttributeNotEditable(transformer.getType(), attributeName); } reportNode.newReportNode() - .withMessageTemplate(reportKey, reportDefaultMessage) + .withMessageTemplate(reportKey) .withUntypedValue("id", transformer.getId()) .withSeverity(TypedValue.INFO_SEVERITY) .add(); diff --git a/src/main/java/org/gridsuite/modification/modifications/EquipmentDeletion.java b/src/main/java/org/gridsuite/modification/modifications/EquipmentDeletion.java index 97fb9f2..61873f1 100644 --- a/src/main/java/org/gridsuite/modification/modifications/EquipmentDeletion.java +++ b/src/main/java/org/gridsuite/modification/modifications/EquipmentDeletion.java @@ -57,7 +57,7 @@ public void apply(Network network, ReportNode subReportNode) { rs.apply(network, true, subReportNode); } subReportNode.newReportNode() - .withMessageTemplate("equipmentDeleted", "equipment of type=${type} and id=${id} deleted") + .withMessageTemplate("network.modification.equipmentDeleted") .withUntypedValue("type", modificationInfos.getEquipmentType().name()) .withUntypedValue("id", modificationInfos.getEquipmentId()) .withSeverity(TypedValue.INFO_SEVERITY) @@ -80,7 +80,7 @@ private void removeHvdcLine(Network network, ReportNode subReportNode) { // isConnectedToHvdc means: selected to be removed (can be changed by the Front) if (mcsInfo.isConnectedToHvdc() && network.getShuntCompensator(mcsInfo.getId()) == null) { subReportNode.newReportNode() - .withMessageTemplate("shuntCompensatorNotDeleted", "Shunt compensator with id=${id} not found in the network") + .withMessageTemplate("network.modification.shuntCompensatorNotDeleted") .withUntypedValue("id", mcsInfo.getId()) .withSeverity(TypedValue.WARN_SEVERITY) .add(); diff --git a/src/main/java/org/gridsuite/modification/modifications/GenerationDispatch.java b/src/main/java/org/gridsuite/modification/modifications/GenerationDispatch.java index 41aaa07..f431e35 100644 --- a/src/main/java/org/gridsuite/modification/modifications/GenerationDispatch.java +++ b/src/main/java/org/gridsuite/modification/modifications/GenerationDispatch.java @@ -8,7 +8,6 @@ import com.google.common.util.concurrent.AtomicDouble; import com.powsybl.commons.report.ReportNode; -import com.powsybl.commons.report.ReportNodeAdder; import com.powsybl.commons.report.TypedValue; import com.powsybl.iidm.modification.scalable.Scalable; import com.powsybl.iidm.modification.scalable.ScalingParameters; @@ -20,6 +19,7 @@ import org.gridsuite.modification.IFilterService; import org.gridsuite.modification.NetworkModificationException; import org.gridsuite.modification.dto.*; +import org.gridsuite.modification.utils.ModificationUtils; import org.springframework.util.CollectionUtils; import java.util.*; @@ -40,9 +40,9 @@ */ public class GenerationDispatch extends AbstractModification { private static final String SYNCHRONOUS_COMPONENT = "SC"; - private static final String POWER_TO_DISPATCH = "PowerToDispatch"; - private static final String STACKING = "Stacking"; - private static final String RESULT = "Result"; + private static final String POWER_TO_DISPATCH = "network.modification.PowerToDispatch"; + private static final String STACKING = "network.modification.Stacking"; + private static final String RESULT = "network.modification.Result"; private static final String GENERATOR = "generator"; private static final String SUBSTATION = "substation"; private static final String REGION_CVG = "regionCvg"; @@ -60,14 +60,8 @@ public GenerationDispatch(GenerationDispatchInfos generationDispatchInfos) { this.generationDispatchInfos = generationDispatchInfos; } - private static void report(ReportNode reportNode, String suffixKey, String key, String defaultMessage, Map values, TypedValue severity) { - ReportNodeAdder adder = reportNode.newReportNode() - .withMessageTemplate(key + suffixKey, defaultMessage) - .withSeverity(severity); - for (Map.Entry valueEntry : values.entrySet()) { - adder.withUntypedValue(valueEntry.getKey(), valueEntry.getValue().toString()); - } - adder.add(); + private static void report(ReportNode reportNode, String key, Map values, TypedValue severity) { + ModificationUtils.createReport(reportNode, key, values, severity); } private static double computeTotalActiveLoad(Component component) { @@ -109,16 +103,14 @@ private static double computeTotalAmountFixedSupply(Network network, Component c }) .mapToDouble(Generator::getTargetP).sum(); if (!generatorsWithoutSetpointList.isEmpty()) { - report(reportNode, Integer.toString(component.getNum()), "GeneratorsWithoutPredefinedActivePowerSetpoint", - "${numGeneratorsWithoutSetpoint} generator${isPlural} not have a predefined active power set point", + report(reportNode, "network.modification.GeneratorsWithoutPredefinedActivePowerSetpoint", Map.of("numGeneratorsWithoutSetpoint", generatorsWithoutSetpointList.size(), IS_PLURAL, generatorsWithoutSetpointList.size() > 1 ? "s do" : " does"), TypedValue.WARN_SEVERITY); } // Report details for each generator without a predefined setpoint generatorsWithoutSetpointList.forEach(generator -> - report(reportNode, Integer.toString(component.getNum()), "MissingPredefinedActivePowerSetpointForGenerator", - "The generator ${generatorId} does not have a predefined active power set point", + report(reportNode, "network.modification.MissingPredefinedActivePowerSetpointForGenerator", Map.of("generatorId", generator.getId()), TypedValue.TRACE_SEVERITY)); return totalAmountFixedSupply; } @@ -171,7 +163,7 @@ private static Double getGeneratorMarginalCost(Generator generator) { return null; } - private static Map> getGeneratorsByMarginalCost(List generators, ReportNode reportNode, String reporterSuffixKey) { + private static Map> getGeneratorsByMarginalCost(List generators, ReportNode reportNode) { Map> generatorsByMarginalCost = new TreeMap<>(); // set targetP to 0 @@ -183,14 +175,14 @@ private static Map> getGeneratorsByMarginalCost(List 0) { - report(reportNode, reporterSuffixKey, "NbGeneratorsWithNoCost", "${nbNoCost} generator${isPlural} been discarded from generation dispatch because of missing marginal cost. Their active power set point has been set to 0", + report(reportNode, "network.modification.NbGeneratorsWithNoCost", Map.of("nbNoCost", nbNoCost, IS_PLURAL, nbNoCost > 1 ? "s have" : " has"), TypedValue.INFO_SEVERITY); } generators.stream() .filter(generator -> getGeneratorMarginalCost(generator) == null) - .forEach(g -> report(reportNode, reporterSuffixKey, "MissingMarginalCostForGenerator", "The generator ${generator} does not have a marginal cost", + .forEach(g -> report(reportNode, "network.modification.MissingMarginalCostForGenerator", Map.of(GENERATOR, g.getId()), TypedValue.TRACE_SEVERITY) ); @@ -205,13 +197,13 @@ private static Map> getGeneratorsByMarginalCost(List substationsGeneratorsOrderingInfos, ReportNode reportNode, String reporterSuffixKey) { + private static void reportUnknownSubstations(Network network, List substationsGeneratorsOrderingInfos, ReportNode reportNode) { if (!CollectionUtils.isEmpty(substationsGeneratorsOrderingInfos)) { substationsGeneratorsOrderingInfos.forEach(sInfo -> sInfo.getSubstationIds().forEach(sId -> { Substation substation = network.getSubstation(sId); if (substation == null) { - report(reportNode, reporterSuffixKey, "SubstationNotFound", "Substation ${substation} not found", + report(reportNode, "network.modification.SubstationNotFound", Map.of(SUBSTATION, sId), TypedValue.WARN_SEVERITY); } })); @@ -222,10 +214,9 @@ private static List computeAdjustableGenerators(Network network, Comp List substationsGeneratorsOrderingInfos, ReportNode reportNode) { List generatorsToReturn = new ArrayList<>(); - String reporterSuffixKey = Integer.toString(component.getNum()); // log substations not found - reportUnknownSubstations(network, substationsGeneratorsOrderingInfos, reportNode, reporterSuffixKey); + reportUnknownSubstations(network, substationsGeneratorsOrderingInfos, reportNode); // get all connected generators in the component List generators = component.getBusStream().flatMap(Bus::getGeneratorStream).collect(Collectors.toList()); @@ -233,7 +224,7 @@ private static List computeAdjustableGenerators(Network network, Comp // remove generators with fixed supply generators.removeIf(generator -> generatorsWithFixedSupply.contains(generator.getId())); - Map> generatorsByMarginalCost = getGeneratorsByMarginalCost(generators, reportNode, reporterSuffixKey); + Map> generatorsByMarginalCost = getGeneratorsByMarginalCost(generators, reportNode); generatorsByMarginalCost.forEach((mCost, gList) -> { // loop on generators of same cost if (!CollectionUtils.isEmpty(substationsGeneratorsOrderingInfos)) { // substations hierarchy provided // build mapGeneratorsBySubstationsList, that will contain all the generators with the same marginal cost as mCost contained in each list of substations @@ -286,7 +277,7 @@ private static List computeAdjustableGenerators(Network network, Comp }); if (generatorsToReturn.isEmpty()) { - report(reportNode, reporterSuffixKey, "NoAvailableAdjustableGenerator", "There is no adjustable generator", + report(reportNode, "network.modification.NoAvailableAdjustableGenerator", Map.of(), TypedValue.WARN_SEVERITY); } @@ -295,12 +286,10 @@ private static List computeAdjustableGenerators(Network network, Comp private static class GeneratorTargetPListener extends DefaultNetworkListener { private final ReportNode reportNode; - private final String suffixKey; private final List updatedGenerators = new ArrayList<>(); - GeneratorTargetPListener(ReportNode reportNode, String suffixKey) { + GeneratorTargetPListener(ReportNode reportNode) { this.reportNode = reportNode; - this.suffixKey = suffixKey; } @Override @@ -312,21 +301,21 @@ public void onUpdate(Identifiable identifiable, String attribute, String variant public void endReport(List adjustableGenerators) { // report updated generators - report(reportNode, suffixKey, "TotalGeneratorSetTargetP", "The active power set points of ${nbUpdatedGenerator} generator${isPlural} have been updated as a result of generation dispatch", + report(reportNode, "network.modification.TotalGeneratorSetTargetP", Map.of("nbUpdatedGenerator", updatedGenerators.size(), IS_PLURAL, updatedGenerators.size() > 1 ? "s" : ""), TypedValue.INFO_SEVERITY); - updatedGenerators.forEach(g -> report(reportNode, suffixKey, "GeneratorSetTargetP", "The active power set point of generator ${generator} has been set to ${newValue} MW", + updatedGenerators.forEach(g -> report(reportNode, "network.modification.GeneratorSetTargetP", Map.of(GENERATOR, g.getId(), "newValue", round(g.getTargetP())), TypedValue.TRACE_SEVERITY)); // report unchanged generators int nbUnchangedGenerators = adjustableGenerators.size() - updatedGenerators.size(); if (nbUnchangedGenerators > 0) { List updatedGeneratorsIds = updatedGenerators.stream().map(Identifiable::getId).toList(); - report(reportNode, suffixKey, "TotalGeneratorUnchangedTargetP", "${nbUnchangedGenerator} eligible generator${isPlural} not been selected by the merit order algorithm. Their active power set point has been set to 0", + report(reportNode, "network.modification.TotalGeneratorUnchangedTargetP", Map.of("nbUnchangedGenerator", nbUnchangedGenerators, IS_PLURAL, nbUnchangedGenerators > 1 ? "s have" : " has"), TypedValue.INFO_SEVERITY); adjustableGenerators.stream() .filter(g -> !updatedGeneratorsIds.contains(g.getId())) - .forEach(g -> report(reportNode, suffixKey, "GeneratorUnchangedTargetP", "Generator ${generator} has not been selected by the merit order algorithm. Its active power set point has been set to 0", + .forEach(g -> report(reportNode, "network.modification.GeneratorUnchangedTargetP", Map.of(GENERATOR, g.getId()), TypedValue.TRACE_SEVERITY)); } // report the max marginal cost used @@ -335,7 +324,7 @@ public void endReport(List adjustableGenerators) { .filter(Objects::nonNull) .mapToDouble(Double::doubleValue).max().orElseThrow(); - report(reportNode, suffixKey, "MaxUsedMarginalCost", "Marginal cost: ${maxUsedMarginalCost}", + report(reportNode, "network.modification.MaxUsedMarginalCost", Map.of("maxUsedMarginalCost", maxUsedMarginalCost), TypedValue.INFO_SEVERITY); } } @@ -385,10 +374,10 @@ private List exportFilters(List generatorsFilters filtersWithGeneratorsNotFound.values().forEach(f -> { var filterName = filters.get(f.getFilterId()); var notFoundGenerators = f.getNotFoundEquipments(); - report(subReportNode, generatorsType, "filterGeneratorsNotFound", getGeneratorsReportMessagePrefix(generatorsType) + ": Cannot find ${nbNotFoundGen} generators in filter ${filterName}", + report(subReportNode, "network.modification.filterGeneratorsNotFound." + generatorsType, Map.of("nbNotFoundGen", notFoundGenerators.size(), "filterName", filterName), TypedValue.WARN_SEVERITY); - f.getNotFoundEquipments().forEach(e -> report(subReportNode, generatorsType, "generatorNotFound" + e, getGeneratorsReportMessagePrefix(generatorsType) + ": Cannot find generator ${notFoundGeneratorId} in filter ${filterName}", + f.getNotFoundEquipments().forEach(e -> report(subReportNode, "network.modification.generatorNotFound." + generatorsType, Map.of("notFoundGeneratorId", e, "filterName", filterName), TypedValue.TRACE_SEVERITY)); }); @@ -450,12 +439,12 @@ private void reportDisconnectedGenerators(List globalDisconnectedGene g.getTerminal().getBusView().getConnectableBus().getSynchronousComponent().getNum() == componentNum) .toList(); if (!componentDisconnectedGenerators.isEmpty()) { - report(reportNode, Integer.toString(componentNum), "TotalDisconnectedGenerator", "${nbDisconnectedGenerator} generator${isPlural} been discarded from generation dispatch because their are disconnected. Their active power set point remains unchanged", + report(reportNode, "network.modification.TotalDisconnectedGenerator", Map.of("nbDisconnectedGenerator", componentDisconnectedGenerators.size(), IS_PLURAL, componentDisconnectedGenerators.size() > 1 ? "s have" : " has"), TypedValue.INFO_SEVERITY); componentDisconnectedGenerators.forEach(g -> - report(reportNode, Integer.toString(componentNum), "DisconnectedGenerator", "Generator ${generator} has been discarded from generation dispatch because it is disconnected. Its active power set point remains unchanged", + report(reportNode, "network.modification.DisconnectedGenerator", Map.of(GENERATOR, g.getId()), TypedValue.TRACE_SEVERITY) ); } @@ -468,7 +457,7 @@ public void apply(Network network, ReportNode subReportNode) { .map(Bus::getSynchronousComponent) .collect(collectingAndThen(toCollection(() -> new TreeSet<>(comparingInt(Component::getNum))), ArrayList::new)); - report(subReportNode, "", "NbSynchronousComponents", "Network has ${scNumber} synchronous component${isPlural}: ${scList}", + report(subReportNode, "network.modification.NbSynchronousComponents", Map.of("scNumber", synchronousComponents.size(), IS_PLURAL, synchronousComponents.size() > 1 ? "s" : "", "scList", synchronousComponents.stream().map(sc -> "SC" + sc.getNum()).collect(Collectors.joining(", "))), @@ -492,11 +481,12 @@ public void apply(Network network, ReportNode subReportNode) { int componentNum = component.getNum(); ReportNode componentReportNode = subReportNode.newReportNode() - .withMessageTemplate("Network CC0 " + SYNCHRONOUS_COMPONENT + componentNum, "Network CC0 " + SYNCHRONOUS_COMPONENT + componentNum) + .withMessageTemplate("network.modification.NetworkCC0.SYNCHRONOUS_COMPONENT") + .withUntypedValue("componentNum", componentNum) .add(); ReportNode powerToDispatchReportNode = componentReportNode.newReportNode() - .withMessageTemplate(POWER_TO_DISPATCH, POWER_TO_DISPATCH) + .withMessageTemplate(POWER_TO_DISPATCH) .add(); // log disconnected generators attached to this synchronous component @@ -504,30 +494,30 @@ public void apply(Network network, ReportNode subReportNode) { // get total value of connected loads in the connected component double totalDemand = computeTotalDemand(component, generationDispatchInfos.getLossCoefficient()); - report(powerToDispatchReportNode, Integer.toString(componentNum), "TotalDemand", "The total demand is : ${totalDemand} MW", + report(powerToDispatchReportNode, "network.modification.TotalDemand", Map.of("totalDemand", round(totalDemand)), TypedValue.INFO_SEVERITY); // get total supply value for generators with fixed supply double totalAmountFixedSupply = computeTotalAmountFixedSupply(network, component, generatorsWithFixedSupply, powerToDispatchReportNode); - report(powerToDispatchReportNode, Integer.toString(componentNum), "TotalAmountFixedSupply", "The total amount of fixed supply is : ${totalAmountFixedSupply} MW", + report(powerToDispatchReportNode, "network.modification.TotalAmountFixedSupply", Map.of("totalAmountFixedSupply", round(totalAmountFixedSupply)), TypedValue.INFO_SEVERITY); // compute hvdc balance to other synchronous components double hvdcBalance = computeHvdcBalance(component); - report(powerToDispatchReportNode, Integer.toString(componentNum), "TotalOutwardHvdcFlow", "The HVDC balance is : ${hvdcBalance} MW", + report(powerToDispatchReportNode, "network.modification.TotalOutwardHvdcFlow", Map.of("hvdcBalance", round(hvdcBalance)), TypedValue.INFO_SEVERITY); double activeBatteryTotalTargetP = computeTotalActiveBatteryTargetP(component); - report(powerToDispatchReportNode, Integer.toString(componentNum), "TotalActiveBatteryTargetP", "The battery balance is : ${batteryBalance} MW", + report(powerToDispatchReportNode, "network.modification.TotalActiveBatteryTargetP", Map.of("batteryBalance", round(activeBatteryTotalTargetP)), TypedValue.INFO_SEVERITY); double totalAmountSupplyToBeDispatched = totalDemand - totalAmountFixedSupply - hvdcBalance - activeBatteryTotalTargetP; if (totalAmountSupplyToBeDispatched < 0.) { - report(powerToDispatchReportNode, Integer.toString(componentNum), "TotalAmountFixedSupplyExceedsTotalDemand", "The total amount of fixed supply exceeds the total demand", + report(powerToDispatchReportNode, "network.modification.TotalAmountFixedSupplyExceedsTotalDemand", Map.of(), TypedValue.WARN_SEVERITY); continue; } else { - report(powerToDispatchReportNode, Integer.toString(componentNum), "TotalAmountSupplyToBeDispatched", "The total amount of supply to be dispatched is : ${totalAmountSupplyToBeDispatched} MW", + report(powerToDispatchReportNode, "network.modification.TotalAmountSupplyToBeDispatched", Map.of("totalAmountSupplyToBeDispatched", round(totalAmountSupplyToBeDispatched)), TypedValue.INFO_SEVERITY); } @@ -546,10 +536,10 @@ public void apply(Network network, ReportNode subReportNode) { }).toList(); ReportNode stackingReportNode = componentReportNode.newReportNode() - .withMessageTemplate(STACKING, STACKING) + .withMessageTemplate(STACKING) .add(); - GeneratorTargetPListener listener = new GeneratorTargetPListener(stackingReportNode, Integer.toString(componentNum)); + GeneratorTargetPListener listener = new GeneratorTargetPListener(stackingReportNode); network.addListener(listener); Scalable scalable = Scalable.stack(generatorsScalable.toArray(Scalable[]::new)); @@ -560,17 +550,17 @@ public void apply(Network network, ReportNode subReportNode) { } ReportNode resultReporter = componentReportNode.newReportNode() - .withMessageTemplate(RESULT, RESULT) + .withMessageTemplate(RESULT) .add(); if (Math.abs(totalAmountSupplyToBeDispatched - realized) < EPSILON) { Map> generatorsByRegion = getGeneratorsByRegion(network, component); - report(resultReporter, Integer.toString(componentNum), "SupplyDemandBalanceCouldBeMet", "The supply-demand balance could be met", + report(resultReporter, "network.modification.SupplyDemandBalanceCouldBeMet", Map.of(), TypedValue.INFO_SEVERITY); generatorsByRegion.forEach((region, generators) -> { Map activePowerSumByEnergySource = getActivePowerSumByEnergySource(generators); - report(resultReporter, Integer.toString(componentNum), "SumGeneratorActivePower" + region, "Sum of generator active power setpoints in ${region} region: ${sum} MW (NUCLEAR: ${nuclearSum} MW, THERMAL: ${thermalSum} MW, HYDRO: ${hydroSum} MW, WIND AND SOLAR: ${windAndSolarSum} MW, OTHER: ${otherSum} MW).", + report(resultReporter, "network.modification.SumGeneratorActivePower", Map.of("region", region, "sum", round(activePowerSumByEnergySource.values().stream().reduce(0d, Double::sum)), "nuclearSum", round(activePowerSumByEnergySource.getOrDefault(EnergySource.NUCLEAR, 0d)), @@ -582,7 +572,7 @@ public void apply(Network network, ReportNode subReportNode) { }); } else { double remainingPowerImbalance = totalAmountSupplyToBeDispatched - realized; - report(resultReporter, Integer.toString(componentNum), "SupplyDemandBalanceCouldNotBeMet", "The supply-demand balance could not be met : the remaining power imbalance is ${remainingPower} MW", + report(resultReporter, "network.modification.SupplyDemandBalanceCouldNotBeMet", Map.of("remainingPower", round(remainingPowerImbalance)), TypedValue.WARN_SEVERITY); } } @@ -644,13 +634,4 @@ private Map getActivePowerSumByEnergySource(List "Generators with fixed active power"; - case GENERATORS_WITHOUT_OUTAGE -> "Generators without outage simulation"; - case GENERATORS_FREQUENCY_RESERVE -> "Frequency reserve"; - default -> ""; - }; - } } diff --git a/src/main/java/org/gridsuite/modification/modifications/GeneratorCreation.java b/src/main/java/org/gridsuite/modification/modifications/GeneratorCreation.java index 6d185d0..27ab491 100644 --- a/src/main/java/org/gridsuite/modification/modifications/GeneratorCreation.java +++ b/src/main/java/org/gridsuite/modification/modifications/GeneratorCreation.java @@ -32,8 +32,6 @@ public class GeneratorCreation extends AbstractModification { private final GeneratorCreationInfos modificationInfos; - private static final String LIMITS = "Limits"; - private static final String ACTIVE_LIMITS = "Active limits"; public GeneratorCreation(GeneratorCreationInfos modificationInfos) { this.modificationInfos = modificationInfos; @@ -85,7 +83,7 @@ public void apply(Network network, ReportNode subReportNode) { } // apply the properties Generator generator = network.getGenerator(modificationInfos.getEquipmentId()); - PropertiesUtils.applyProperties(generator, subReportNode, modificationInfos.getProperties(), "GeneratorProperties"); + PropertiesUtils.applyProperties(generator, subReportNode, modificationInfos.getProperties(), "network.modification.GeneratorProperties"); } @Override @@ -169,7 +167,7 @@ private void createGeneratorInBusBreaker(VoltageLevel voltageLevel, GeneratorCre addExtensionsToGenerator(generatorCreationInfos, generator, voltageLevel, subReportNode); subReportNode.newReportNode() - .withMessageTemplate("generatorCreated", "New generator with id=${id} created") + .withMessageTemplate("network.modification.generatorCreated") .withUntypedValue("id", modificationInfos.getEquipmentId()) .withSeverity(TypedValue.INFO_SEVERITY) .add(); @@ -183,13 +181,13 @@ private ReportNode reportGeneratorSetPoints(GeneratorCreationInfos generatorCrea setPointReports.add(ModificationUtils.getInstance() .buildCreationReport(generatorCreationInfos.getTargetQ(), "Reactive power")); } - return ModificationUtils.getInstance().reportModifications(subReportNode, setPointReports, "SetPointCreated", "Setpoints"); + return ModificationUtils.getInstance().reportModifications(subReportNode, setPointReports, "network.modification.SetPointCreated"); } private void createGeneratorVoltageRegulation(GeneratorCreationInfos generatorCreationInfos, Generator generator, VoltageLevel voltageLevel, ReportNode subReportNode) { List voltageReports = new ArrayList<>(); voltageReports.add(ModificationUtils.getInstance() - .createEnabledDisabledReport("VoltageRegulationOn", modificationInfos.isVoltageRegulationOn())); + .createEnabledDisabledReport("network.modification.VoltageRegulationOn", modificationInfos.isVoltageRegulationOn())); voltageReports.add(ModificationUtils.getInstance().buildCreationReport(generatorCreationInfos.getTargetV(), "Voltage")); if (generatorCreationInfos.getRegulatingTerminalVlId() != null && generatorCreationInfos.getRegulatingTerminalId() != null && generatorCreationInfos.getRegulatingTerminalType() != null) { @@ -208,14 +206,15 @@ private void createGeneratorVoltageRegulation(GeneratorCreationInfos generatorCr voltageReports.add(ModificationUtils.getInstance().buildCreationReport(generatorCreationInfos.getQPercent(), "Reactive percentage")); } catch (PowsyblException e) { voltageReports.add(ReportNode.newRootReportNode() - .withMessageTemplate("ReactivePercentageError", "cannot add Coordinated reactive extension on generator with id=${id} : ${message}") + .withAllResourceBundlesFromClasspath() + .withMessageTemplate("network.modification.ReactivePercentageError") .withUntypedValue("id", generatorCreationInfos.getEquipmentId()) .withUntypedValue("message", e.getMessage()) .withSeverity(TypedValue.ERROR_SEVERITY) .build()); } } - ModificationUtils.getInstance().reportModifications(subReportNode, voltageReports, "VoltageRegulationCreated", "Voltage regulation"); + ModificationUtils.getInstance().reportModifications(subReportNode, voltageReports, "network.modification.VoltageRegulationCreated"); } @@ -236,7 +235,7 @@ private void updateGeneratorRegulatingTerminal(GeneratorCreationInfos generatorC } private ReportNode reportGeneratorActiveLimits(GeneratorCreationInfos generatorCreationInfos, ReportNode subReportNode) { - ReportNode subReportNodeLimits = subReportNode.newReportNode().withMessageTemplate(LIMITS, LIMITS).add(); + ReportNode subReportNodeLimits = subReportNode.newReportNode().withMessageTemplate("network.modification.Limits").add(); List limitsReports = new ArrayList<>(); limitsReports.add(ModificationUtils.getInstance().buildCreationReport( generatorCreationInfos.getMinP(), "Min active power")); @@ -246,7 +245,7 @@ private ReportNode reportGeneratorActiveLimits(GeneratorCreationInfos generatorC limitsReports.add(ModificationUtils.getInstance().buildCreationReport( generatorCreationInfos.getRatedS(), "Rated nominal power")); } - ModificationUtils.getInstance().reportModifications(subReportNodeLimits, limitsReports, "ActiveLimitsCreated", ACTIVE_LIMITS); + ModificationUtils.getInstance().reportModifications(subReportNodeLimits, limitsReports, "network.modification.ActiveLimitsCreated"); return subReportNodeLimits; } @@ -266,14 +265,15 @@ private void createGeneratorActivePowerControl(GeneratorCreationInfos generatorC "Droop")); } catch (PowsyblException e) { activePowerRegulationReports.add(ReportNode.newRootReportNode() - .withMessageTemplate("ActivePowerExtensionAddError", "cannot add active power extension on generator with id=${id} : ${message}") + .withAllResourceBundlesFromClasspath() + .withMessageTemplate("network.modification.activePowerExtensionAddError.generator") .withUntypedValue("id", generatorCreationInfos.getEquipmentId()) .withUntypedValue("message", e.getMessage()) .withSeverity(TypedValue.ERROR_SEVERITY) .build()); } - ModificationUtils.getInstance().reportModifications(subReportNode, activePowerRegulationReports, "ActivePowerRegulationCreated", "Active power regulation"); + ModificationUtils.getInstance().reportModifications(subReportNode, activePowerRegulationReports, "network.modification.ActivePowerRegulationCreated"); } } @@ -293,13 +293,14 @@ private void createGeneratorShortCircuit(GeneratorCreationInfos generatorCreatio } } catch (PowsyblException e) { shortCircuitReports.add(ReportNode.newRootReportNode() - .withMessageTemplate("ShortCircuitExtensionAddError", "cannot add short-circuit extension on generator with id=${id} : ${message}") + .withAllResourceBundlesFromClasspath() + .withMessageTemplate("network.modification.ShortCircuitExtensionAddError") .withUntypedValue("id", generatorCreationInfos.getEquipmentId()) .withUntypedValue("message", e.getMessage()) .withSeverity(TypedValue.ERROR_SEVERITY) .build()); } - ModificationUtils.getInstance().reportModifications(subReportNode, shortCircuitReports, "shortCircuitCreated", "Short-circuit"); + ModificationUtils.getInstance().reportModifications(subReportNode, shortCircuitReports, "network.modification.shortCircuitCreated"); } } @@ -334,13 +335,14 @@ private void createGeneratorStartUp(GeneratorCreationInfos generatorCreationInfo } } catch (PowsyblException e) { startupReports.add(ReportNode.newRootReportNode() - .withMessageTemplate("StartupExtensionAddError", "cannot add startup extension on generator with id=${id} : ${message}") + .withAllResourceBundlesFromClasspath() + .withMessageTemplate("network.modification.StartupExtensionAddError") .withUntypedValue("id", generatorCreationInfos.getEquipmentId()) - .withMessageTemplate("message", e.getMessage()) + .withUntypedValue("message", e.getMessage()) .withSeverity(TypedValue.ERROR_SEVERITY) .build()); } - ModificationUtils.getInstance().reportModifications(subReportNode, startupReports, "startUpAttributesCreated", "Start up"); + ModificationUtils.getInstance().reportModifications(subReportNode, startupReports, "network.modification.startUpAttributesCreated"); } } } diff --git a/src/main/java/org/gridsuite/modification/modifications/GeneratorModification.java b/src/main/java/org/gridsuite/modification/modifications/GeneratorModification.java index 73c2bdd..893e1b2 100644 --- a/src/main/java/org/gridsuite/modification/modifications/GeneratorModification.java +++ b/src/main/java/org/gridsuite/modification/modifications/GeneratorModification.java @@ -28,9 +28,9 @@ */ public class GeneratorModification extends AbstractModification { - private static final String LIMITS = "Limits"; - private static final String ACTIVE_LIMITS = "Active limits"; - private static final String SETPOINTS = "Setpoints"; + private static final String LIMITS = "network.modification.Limits"; + private static final String ACTIVE_LIMITS = "network.modification.ActiveLimits"; + private static final String SETPOINTS = "network.modification.Setpoints"; public static final String ERROR_MESSAGE = "Generator '%s' : "; private final GeneratorModificationInfos modificationInfos; @@ -99,7 +99,7 @@ public String getName() { private void modifyGenerator(Generator generator, GeneratorModificationInfos modificationInfos, ReportNode subReportNode) { subReportNode.newReportNode() - .withMessageTemplate("generatorModification", "Generator with id=${id} modified :") + .withMessageTemplate("network.modification.generatorModification") .withUntypedValue("id", modificationInfos.getEquipmentId()) .withSeverity(TypedValue.INFO_SEVERITY) .add(); @@ -114,7 +114,7 @@ private void modifyGenerator(Generator generator, GeneratorModificationInfos mod modifyGeneratorShortCircuitAttributes(modificationInfos.getDirectTransX(), modificationInfos.getStepUpTransformerX(), generator, subReportNode); modifyGeneratorStartUpAttributes(modificationInfos, generator, subReportNode); modifyGeneratorConnectivityAttributes(modificationInfos, generator, subReportNode); - PropertiesUtils.applyProperties(generator, subReportNode, modificationInfos.getProperties(), "GeneratorProperties"); + PropertiesUtils.applyProperties(generator, subReportNode, modificationInfos.getProperties(), "network.modification.GeneratorProperties"); } public static void modifyGeneratorShortCircuitAttributes(AttributeModification directTransX, @@ -161,7 +161,7 @@ public static void modifyGeneratorShortCircuitAttributes(AttributeModification setPointsReports = new ArrayList<>(); setPointsReports.add(ModificationUtils.getInstance().buildCreationReport(modificationInfos.getConvertersMode(), "Converters mode")); setPointsReports.add(ModificationUtils.getInstance().buildCreationReport(modificationInfos.getActivePowerSetpoint(), "Active power")); - ModificationUtils.getInstance().reportModifications(subReportNode, setPointsReports, LCC_SETPOINTS, SETPOINTS); - PropertiesUtils.applyProperties(hvdcLine, subReportNode, modificationInfos.getProperties(), "LCC_Properties"); + ModificationUtils.getInstance().reportModifications(subReportNode, setPointsReports, "network.modification.LccSetPoints"); + PropertiesUtils.applyProperties(hvdcLine, subReportNode, modificationInfos.getProperties(), "network.modification.LCC_Properties"); } private void addReportConverterStationLcc(LccConverterStationCreationInfos lccConverterStationCreationInfos, String logFieldName, ReportNode subReporter) { ReportNode reportConverterStationNode = subReporter.newReportNode() - .withMessageTemplate("converterStationCreated", "${fieldName} with id=${id} created") + .withMessageTemplate("network.modification.converterStationCreated") .withUntypedValue("fieldName", logFieldName) .withUntypedValue("id", lccConverterStationCreationInfos.getEquipmentId()).add(); @@ -265,9 +260,9 @@ private void addReportConverterStationLcc(LccConverterStationCreationInfos lccCo )) .toList(); - ModificationUtils.getInstance().reportModifications(reportConverterStationNode, characteristicsReport, "converterStationCharacteristics", CHARACTERISTICS); + ModificationUtils.getInstance().reportModifications(reportConverterStationNode, characteristicsReport, "network.modification.converterStationCharacteristics"); reportInjectionCreationConnectivity(lccConverterStationCreationInfos, reportConverterStationNode); - ModificationUtils.getInstance().reportModifications(reportConverterStationNode, shuntCompensatorsOnSide, "converterStationFilters", FILTERS); + ModificationUtils.getInstance().reportModifications(reportConverterStationNode, shuntCompensatorsOnSide, "network.modification.converterStationFilters"); } } diff --git a/src/main/java/org/gridsuite/modification/modifications/LineCreation.java b/src/main/java/org/gridsuite/modification/modifications/LineCreation.java index 519d491..13b866d 100644 --- a/src/main/java/org/gridsuite/modification/modifications/LineCreation.java +++ b/src/main/java/org/gridsuite/modification/modifications/LineCreation.java @@ -78,7 +78,7 @@ public void apply(Network network, ReportNode subReportNode) { if (modificationInfos.getSelectedOperationalLimitsGroup1() != null) { line.setSelectedOperationalLimitsGroup1(modificationInfos.getSelectedOperationalLimitsGroup1()); subReportNode.newReportNode() - .withMessageTemplate("limit set selected on side 1", "limit set selected on side 1 : ${selectedOperationalLimitsGroup1}") + .withMessageTemplate("network.modification.limitSetSelectedOnSide1") .withUntypedValue("selectedOperationalLimitsGroup1", modificationInfos.getSelectedOperationalLimitsGroup1()) .withSeverity(TypedValue.INFO_SEVERITY) .add(); @@ -86,12 +86,12 @@ public void apply(Network network, ReportNode subReportNode) { if (modificationInfos.getSelectedOperationalLimitsGroup2() != null) { line.setSelectedOperationalLimitsGroup2(modificationInfos.getSelectedOperationalLimitsGroup2()); subReportNode.newReportNode() - .withMessageTemplate("limit set selected on side 2", "limit set selected on side 2 : ${selectedOperationalLimitsGroup2}") + .withMessageTemplate("network.modification.limitSetSelectedOnSide2") .withUntypedValue("selectedOperationalLimitsGroup2", modificationInfos.getSelectedOperationalLimitsGroup2()) .withSeverity(TypedValue.INFO_SEVERITY) .add(); } - PropertiesUtils.applyProperties(line, subReportNode, modificationInfos.getProperties(), "LineProperties"); + PropertiesUtils.applyProperties(line, subReportNode, modificationInfos.getProperties(), "network.modification.LineProperties"); } @Override @@ -103,7 +103,7 @@ private void addLine(Network network, VoltageLevel voltageLevel1, VoltageLevel v ModificationUtils.getInstance().createLineAdder(network, voltageLevel1, voltageLevel2, lineCreationInfos, withSwitch1, withSwitch2).add(); subReportNode.newReportNode() - .withMessageTemplate("lineCreated", "New line with id=${id} created") + .withMessageTemplate("network.modification.lineCreated") .withUntypedValue("id", lineCreationInfos.getEquipmentId()) .withSeverity(TypedValue.INFO_SEVERITY) .add(); diff --git a/src/main/java/org/gridsuite/modification/modifications/LineModification.java b/src/main/java/org/gridsuite/modification/modifications/LineModification.java index 2d968b4..e00bdfe 100644 --- a/src/main/java/org/gridsuite/modification/modifications/LineModification.java +++ b/src/main/java/org/gridsuite/modification/modifications/LineModification.java @@ -67,15 +67,15 @@ public String getName() { } private void modifyLine(Line line, BranchModificationInfos lineModificationInfos, ReportNode subReportNode) { - modifyBranch(line, lineModificationInfos, subReportNode, "lineModification", "Line with id=${id} modified :"); + modifyBranch(line, lineModificationInfos, subReportNode, "network.modification.lineModification"); updateMeasurements(line, lineModificationInfos, subReportNode); - PropertiesUtils.applyProperties(line, subReportNode, modificationInfos.getProperties(), "LineProperties"); + PropertiesUtils.applyProperties(line, subReportNode, modificationInfos.getProperties(), "network.modification.LineProperties"); } @Override protected void modifyCharacteristics(Branch branch, BranchModificationInfos branchModificationInfos, ReportNode subReportNode) { Line line = (Line) branch; - ReportNode characteristicsReporter = subReportNode.newReportNode().withMessageTemplate("characteristics", "Characteristics").add(); + ReportNode characteristicsReporter = subReportNode.newReportNode().withMessageTemplate("network.modification.characteristics").add(); modifyR(line, branchModificationInfos.getR(), characteristicsReporter); modifyX(line, branchModificationInfos.getX(), characteristicsReporter); @@ -89,7 +89,7 @@ private void modifySide1Characteristics(Line line, LineModificationInfos lineMod ReportNode characteristicsReportNode) { if (lineModificationInfos.getG1() != null && lineModificationInfos.getG1().getValue() != null || lineModificationInfos.getB1() != null && lineModificationInfos.getB1().getValue() != null) { - ReportNode side1ReportNode = characteristicsReportNode.newReportNode().withMessageTemplate("side1Characteristics", "Side 1").add(); + ReportNode side1ReportNode = characteristicsReportNode.newReportNode().withMessageTemplate("network.modification.side1Characteristics").add(); modifyG1(line, lineModificationInfos.getG1(), side1ReportNode); modifyB1(line, lineModificationInfos.getB1(), side1ReportNode); } @@ -99,7 +99,7 @@ private void modifySide2Characteristics(Line line, LineModificationInfos lineMod ReportNode characteristicsReportNode) { if (lineModificationInfos.getG2() != null && lineModificationInfos.getG2().getValue() != null || lineModificationInfos.getB2() != null && lineModificationInfos.getB2().getValue() != null) { - ReportNode side2Reporter = characteristicsReportNode.newReportNode().withMessageTemplate("side2Characteristics", "Side 2").add(); + ReportNode side2Reporter = characteristicsReportNode.newReportNode().withMessageTemplate("network.modification.side2Characteristics").add(); modifyG2(line, lineModificationInfos.getG2(), side2Reporter); modifyB2(line, lineModificationInfos.getB2(), side2Reporter); } @@ -123,7 +123,7 @@ public static void modifyX(Line line, AttributeModification modifX, Repo if (modifX != null && modifX.getValue() != null) { if (reportNode != null) { insertReportNode(reportNode, ModificationUtils.getInstance().buildModificationReport(line.getX(), - modifX.getValue(), "Series reactance", 1)); + modifX.getValue(), "Series reactance")); } line.setX(modifX.getValue()); } @@ -133,7 +133,7 @@ public static void modifyR(Line line, AttributeModification modifR, Repo if (modifR != null && modifR.getValue() != null) { if (reportNode != null) { insertReportNode(reportNode, ModificationUtils.getInstance().buildModificationReport(line.getR(), - modifR.getValue(), "Series resistance", 1)); + modifR.getValue(), "Series resistance")); } line.setR(modifR.getValue()); } @@ -144,8 +144,7 @@ public static void modifyG1(Line line, AttributeModification modifG1, Re if (reportNode != null) { ReportNode gReportNode = ModificationUtils.getInstance().buildModificationReport(line.getG1(), modifG1.getValue(), - MAGNETIZING_CONDUCTANCE_MESSAGE, - 2); + MAGNETIZING_CONDUCTANCE_MESSAGE); insertReportNode(reportNode, gReportNode); } line.setG1(modifG1.getValue()); @@ -157,8 +156,7 @@ public static void modifyG2(Line line, AttributeModification modifG2, Re if (reportNode != null) { ReportNode gReportNode = ModificationUtils.getInstance().buildModificationReport(line.getG2(), modifG2.getValue(), - MAGNETIZING_CONDUCTANCE_MESSAGE, - 2); + MAGNETIZING_CONDUCTANCE_MESSAGE); insertReportNode(reportNode, gReportNode); } line.setG2(modifG2.getValue()); @@ -169,7 +167,7 @@ public static void modifyB1(Line line, AttributeModification modifB1, Re if (modifB1 != null && modifB1.getValue() != null) { if (reportNode != null) { insertReportNode(reportNode, ModificationUtils.getInstance().buildModificationReport(line.getB1(), - modifB1.getValue(), MAGNETIZING_SUSCEPTANCE_MESSAGE, 2)); + modifB1.getValue(), MAGNETIZING_SUSCEPTANCE_MESSAGE)); } line.setB1(modifB1.getValue()); } @@ -179,7 +177,7 @@ public static void modifyB2(Line line, AttributeModification modifB2, Re if (modifB2 != null && modifB2.getValue() != null) { if (reportNode != null) { insertReportNode(reportNode, ModificationUtils.getInstance().buildModificationReport(line.getB2(), - modifB2.getValue(), MAGNETIZING_SUSCEPTANCE_MESSAGE, 2)); + modifB2.getValue(), MAGNETIZING_SUSCEPTANCE_MESSAGE)); } line.setB2(modifB2.getValue()); } diff --git a/src/main/java/org/gridsuite/modification/modifications/LoadCreation.java b/src/main/java/org/gridsuite/modification/modifications/LoadCreation.java index dd7f336..435d5dd 100644 --- a/src/main/java/org/gridsuite/modification/modifications/LoadCreation.java +++ b/src/main/java/org/gridsuite/modification/modifications/LoadCreation.java @@ -47,7 +47,7 @@ public void apply(Network network, ReportNode subReporter) { } else { createLoadInBusBreaker(voltageLevel, modificationInfos); subReporter.newReportNode() - .withMessageTemplate("loadCreated", "New load with id=${id} created") + .withMessageTemplate("network.modification.loadCreated") .withUntypedValue("id", modificationInfos.getEquipmentId()) .withSeverity(TypedValue.INFO_SEVERITY) .add(); @@ -57,7 +57,7 @@ public void apply(Network network, ReportNode subReporter) { // properties Load load = network.getLoad(modificationInfos.getEquipmentId()); - PropertiesUtils.applyProperties(load, subReporter, modificationInfos.getProperties(), "LoadProperties"); + PropertiesUtils.applyProperties(load, subReporter, modificationInfos.getProperties(), "network.modification.LoadProperties"); } @Override diff --git a/src/main/java/org/gridsuite/modification/modifications/LoadModification.java b/src/main/java/org/gridsuite/modification/modifications/LoadModification.java index 8842d95..4fb6104 100644 --- a/src/main/java/org/gridsuite/modification/modifications/LoadModification.java +++ b/src/main/java/org/gridsuite/modification/modifications/LoadModification.java @@ -54,7 +54,7 @@ public String getName() { private void modifyLoad(Load load, ReportNode subReportNode) { LoadModificationInfos loadModificationInfos = (LoadModificationInfos) modificationInfos; subReportNode.newReportNode() - .withMessageTemplate("loadModification", "Load with id=${id} modified :") + .withMessageTemplate("network.modification.loadModification") .withUntypedValue("id", loadModificationInfos.getEquipmentId()) .withSeverity(TypedValue.INFO_SEVERITY) .add(); @@ -67,7 +67,7 @@ private void modifyLoad(Load load, ReportNode subReportNode) { // measurements updateMeasurements(load, loadModificationInfos, subReportNode); // properties - PropertiesUtils.applyProperties(load, subReportNode, loadModificationInfos.getProperties(), "LoadProperties"); + PropertiesUtils.applyProperties(load, subReportNode, loadModificationInfos.getProperties(), "network.modification.LoadProperties"); } public static void modifyQ0(Load load, AttributeModification q0, ReportNode subReportNode) { diff --git a/src/main/java/org/gridsuite/modification/modifications/LoadScaling.java b/src/main/java/org/gridsuite/modification/modifications/LoadScaling.java index ac67d7d..170e732 100644 --- a/src/main/java/org/gridsuite/modification/modifications/LoadScaling.java +++ b/src/main/java/org/gridsuite/modification/modifications/LoadScaling.java @@ -143,7 +143,7 @@ public String getName() { private void reportScaling(ReportNode subReportNode, VariationMode variationMode, double askedValue, double actualValue) { subReportNode.newReportNode() - .withMessageTemplate("scalingApplied", "Successfully scaling variation in ${variationMode} mode with variation value asked is ${askedValue} and variation done is ${actualValue}") + .withMessageTemplate("network.modification.scalingApplied") .withUntypedValue("variationMode", variationMode.name()) .withUntypedValue("askedValue", askedValue) .withUntypedValue("actualValue", actualValue) diff --git a/src/main/java/org/gridsuite/modification/modifications/OperatingStatusModification.java b/src/main/java/org/gridsuite/modification/modifications/OperatingStatusModification.java index 625c106..b06533b 100644 --- a/src/main/java/org/gridsuite/modification/modifications/OperatingStatusModification.java +++ b/src/main/java/org/gridsuite/modification/modifications/OperatingStatusModification.java @@ -39,7 +39,7 @@ public class OperatingStatusModification extends AbstractModification { private final OperatingStatusModificationInfos modificationInfos; private static final Logger LOGGER = LoggerFactory.getLogger(OperatingStatusModification.class); - private static final String APPLIED = "Applied"; + private static final String EQUIPMENT_TYPE = "equipmentType"; public OperatingStatusModification(OperatingStatusModificationInfos modificationInfos) { this.modificationInfos = modificationInfos; @@ -88,8 +88,8 @@ private void applyLockoutEquipment(ReportNode subReportNode, Identifiable equ throw new NetworkModificationException(OPERATING_STATUS_MODIFICATION_ERROR, "Unable to disconnect all equipment ends"); } subReportNode.newReportNode() - .withMessageTemplate("lockout" + equipmentType + APPLIED, "${equipmentType} ${id} (id) : lockout applied") - .withUntypedValue("equipmentType", equipmentType) + .withMessageTemplate("network.modification.lockout.equipment.Applied") + .withUntypedValue(EQUIPMENT_TYPE, equipmentType) .withUntypedValue("id", equipment.getId()) .withSeverity(TypedValue.INFO_SEVERITY) .add(); @@ -111,8 +111,8 @@ private void applyTripEquipment(ReportNode subReportNode, Identifiable equipm terminalsToDisconnect.forEach(Terminal::disconnect); subReportNode.newReportNode() - .withMessageTemplate("trip" + equipmentType + APPLIED, "${equipmentType} ${id} (id) : trip applied") - .withUntypedValue("equipmentType", equipmentType) + .withMessageTemplate("network.modification.trip.equipment.Applied") + .withUntypedValue(EQUIPMENT_TYPE, equipmentType) .withUntypedValue("id", equipment.getId()) .withSeverity(TypedValue.INFO_SEVERITY) .add(); @@ -138,8 +138,8 @@ private void applySwitchOnEquipment(ReportNode subReportNode, Identifiable eq } subReportNode.newReportNode() - .withMessageTemplate("switchOn" + equipmentType + APPLIED, "${equipmentType} ${id} (id) : switch on applied") - .withUntypedValue("equipmentType", equipmentType) + .withMessageTemplate("network.modification.switchOn.equipment.Applied") + .withUntypedValue(EQUIPMENT_TYPE, equipmentType) .withUntypedValue("id", equipment.getId()) .withSeverity(TypedValue.INFO_SEVERITY) .add(); @@ -158,8 +158,8 @@ private void applyEnergiseEquipmentEnd(ReportNode subReportNode, Identifiable } subReportNode.newReportNode() - .withMessageTemplate("energise" + equipmentType + "EndApplied", "${equipmentType} ${id} (id) : energise the side ${side} applied") - .withUntypedValue("equipmentType", equipmentType) + .withMessageTemplate("network.modification.energise.equipment.EndApplied") + .withUntypedValue(EQUIPMENT_TYPE, equipmentType) .withUntypedValue("id", equipment.getId()) .withUntypedValue("side", side.name()) .withSeverity(TypedValue.INFO_SEVERITY) diff --git a/src/main/java/org/gridsuite/modification/modifications/ShuntCompensatorCreation.java b/src/main/java/org/gridsuite/modification/modifications/ShuntCompensatorCreation.java index a79a610..5d99eb4 100644 --- a/src/main/java/org/gridsuite/modification/modifications/ShuntCompensatorCreation.java +++ b/src/main/java/org/gridsuite/modification/modifications/ShuntCompensatorCreation.java @@ -66,7 +66,7 @@ public void apply(Network network, ReportNode subReportNode) { } else { createShuntInBusBreaker(voltageLevel, modificationInfos); subReportNode.newReportNode() - .withMessageTemplate("shuntCompensatorCreated", "New shunt compensator with id=${id} created") + .withMessageTemplate("network.modification.shuntCompensatorCreated") .withUntypedValue("id", modificationInfos.getEquipmentId()) .withSeverity(TypedValue.INFO_SEVERITY) .add(); @@ -74,7 +74,7 @@ public void apply(Network network, ReportNode subReportNode) { ModificationUtils.getInstance().disconnectCreatedInjection(modificationInfos, network.getShuntCompensator(modificationInfos.getEquipmentId()), subReportNode); // properties ShuntCompensator shuntCompensator = network.getShuntCompensator(modificationInfos.getEquipmentId()); - PropertiesUtils.applyProperties(shuntCompensator, subReportNode, modificationInfos.getProperties(), "ShuntCompensatorProperties"); + PropertiesUtils.applyProperties(shuntCompensator, subReportNode, modificationInfos.getProperties(), "network.modification.ShuntCompensatorProperties"); } @Override diff --git a/src/main/java/org/gridsuite/modification/modifications/ShuntCompensatorModification.java b/src/main/java/org/gridsuite/modification/modifications/ShuntCompensatorModification.java index b34f8cc..3e17f2e 100644 --- a/src/main/java/org/gridsuite/modification/modifications/ShuntCompensatorModification.java +++ b/src/main/java/org/gridsuite/modification/modifications/ShuntCompensatorModification.java @@ -70,7 +70,7 @@ public void apply(Network network, ReportNode subReportNode) { VoltageLevel voltageLevel = shuntCompensator.getTerminal().getVoltageLevel(); subReportNode.newReportNode() - .withMessageTemplate("shuntCompensatorModification", "Shunt Compensator with id=${id} modified :") + .withMessageTemplate("network.modification.shuntCompensatorModification.withId") .withUntypedValue("id", modificationInfos.getEquipmentId()) .withSeverity(TypedValue.INFO_SEVERITY) .add(); @@ -81,7 +81,7 @@ public void apply(Network network, ReportNode subReportNode) { applyModificationOnLinearModel(subReportNode, shuntCompensator, voltageLevel); } modifyShuntCompensatorConnectivityAttributes(modificationInfos, shuntCompensator, subReportNode); - PropertiesUtils.applyProperties(shuntCompensator, subReportNode, modificationInfos.getProperties(), "ShuntCompensatorProperties"); + PropertiesUtils.applyProperties(shuntCompensator, subReportNode, modificationInfos.getProperties(), "network.modification.ShuntCompensatorProperties"); } @Override diff --git a/src/main/java/org/gridsuite/modification/modifications/StaticVarCompensatorCreation.java b/src/main/java/org/gridsuite/modification/modifications/StaticVarCompensatorCreation.java index 9698d06..e647f6c 100644 --- a/src/main/java/org/gridsuite/modification/modifications/StaticVarCompensatorCreation.java +++ b/src/main/java/org/gridsuite/modification/modifications/StaticVarCompensatorCreation.java @@ -76,9 +76,9 @@ public void apply(Network network, ReportNode subReportNode) { ModificationUtils.getInstance().disconnectCreatedInjection(modificationInfos, network.getStaticVarCompensator(modificationInfos.getEquipmentId()), subReportNode); // properties StaticVarCompensator staticVarCompensator = network.getStaticVarCompensator(modificationInfos.getEquipmentId()); - PropertiesUtils.applyProperties(staticVarCompensator, subReportNode, modificationInfos.getProperties(), "StaticVarCompensatorProperties"); + PropertiesUtils.applyProperties(staticVarCompensator, subReportNode, modificationInfos.getProperties(), "network.modification.StaticVarCompensatorProperties"); subReportNode.newReportNode() - .withMessageTemplate("staticVarCompensatorCreated", "New static var compensator with id=${id} created") + .withMessageTemplate("network.modification.staticVarCompensatorCreated") .withUntypedValue("id", modificationInfos.getEquipmentId()) .withSeverity(TypedValue.INFO_SEVERITY) .add(); @@ -177,14 +177,14 @@ private void reportStaticVarCompensatorStandbyAutomaton(StaticVarCompensatorCrea "Low voltage threshold")); } catch (PowsyblException e) { standbyAutomatonReports.add(ReportNode.newRootReportNode() - .withMessageTemplate("StandbyAutomatonExtensionAddError", - "Cannot add standby automaton extension on ${message}") + .withAllResourceBundlesFromClasspath() + .withMessageTemplate("network.modification.StandbyAutomatonExtensionAddError") .withUntypedValue("message", e.getMessage()) .withSeverity(TypedValue.ERROR_SEVERITY) .build()); } ModificationUtils.getInstance().reportModifications(subReportNode, standbyAutomatonReports, - "StandbyAutomatonCreated", "Standby automaton"); + "network.modification.StandbyAutomatonCreated"); } } @@ -249,7 +249,7 @@ private void reportStaticVarCompensatorLimitsAndSetpoints(StaticVarCompensatorCr updateCompensatorRegulatingTerminal(staticVarCompensatorCreationInfos, staticVarCompensator, terminal, voltageReports); } } - ModificationUtils.getInstance().reportModifications(subReportNode, voltageReports, "LimitsAndSetpointsCreated", "Limits and Setpoints"); + ModificationUtils.getInstance().reportModifications(subReportNode, voltageReports, "network.modification.LimitsAndSetpointsCreated"); } private void updateCompensatorRegulatingTerminal(StaticVarCompensatorCreationInfos staticVarCompensatorCreationInfos, StaticVarCompensator staticVarCompensator, diff --git a/src/main/java/org/gridsuite/modification/modifications/SubstationCreation.java b/src/main/java/org/gridsuite/modification/modifications/SubstationCreation.java index 3beda55..1ed6358 100644 --- a/src/main/java/org/gridsuite/modification/modifications/SubstationCreation.java +++ b/src/main/java/org/gridsuite/modification/modifications/SubstationCreation.java @@ -20,7 +20,7 @@ public void apply(Network network, ReportNode subReportNode) { ModificationUtils.getInstance().createSubstation(modificationInfos, subReportNode, network); Substation substation = network.getSubstation(modificationInfos.getEquipmentId()); // properties - PropertiesUtils.applyProperties(substation, subReportNode, modificationInfos.getProperties(), "SubstationProperties"); + PropertiesUtils.applyProperties(substation, subReportNode, modificationInfos.getProperties(), "network.modification.SubstationProperties"); } @Override diff --git a/src/main/java/org/gridsuite/modification/modifications/SubstationModification.java b/src/main/java/org/gridsuite/modification/modifications/SubstationModification.java index a67032a..223ec88 100644 --- a/src/main/java/org/gridsuite/modification/modifications/SubstationModification.java +++ b/src/main/java/org/gridsuite/modification/modifications/SubstationModification.java @@ -43,7 +43,7 @@ public void apply(Network network, ReportNode subReportNode) { // modify the substation in the network subReportNode.newReportNode() - .withMessageTemplate("substationModification", "Substation with id=${id} modified :") + .withMessageTemplate("network.modification.substationModification") .withUntypedValue("id", modificationInfos.getEquipmentId()) .withSeverity(TypedValue.INFO_SEVERITY) .add(); @@ -51,7 +51,7 @@ public void apply(Network network, ReportNode subReportNode) { ModificationUtils.getInstance().applyElementaryModifications(station::setName, () -> station.getOptionalName().orElse("No value"), modificationInfos.getEquipmentName(), subReportNode, "Name"); ModificationUtils.getInstance().applyElementaryModifications(station::setCountry, station::getNullableCountry, modificationInfos.getCountry(), subReportNode, "Country"); // properties - PropertiesUtils.applyProperties(station, subReportNode, modificationInfos.getProperties(), "SubstationProperties"); + PropertiesUtils.applyProperties(station, subReportNode, modificationInfos.getProperties(), "network.modification.SubstationProperties"); } @Override diff --git a/src/main/java/org/gridsuite/modification/modifications/TabularCreation.java b/src/main/java/org/gridsuite/modification/modifications/TabularCreation.java index 678fba7..50830ed 100644 --- a/src/main/java/org/gridsuite/modification/modifications/TabularCreation.java +++ b/src/main/java/org/gridsuite/modification/modifications/TabularCreation.java @@ -50,7 +50,7 @@ public void apply(Network network, ReportNode subReportNode) { } catch (PowsyblException e) { applicationFailuresCount++; subReportNode.newReportNode() - .withMessageTemplate(creatInfos.getType().name() + applicationFailuresCount, "${message}") + .withMessageTemplate("network.modification.tabular.creation.exception") .withUntypedValue("message", e.getMessage()) .withSeverity(TypedValue.WARN_SEVERITY) .add(); @@ -64,13 +64,13 @@ public void apply(Network network, ReportNode subReportNode) { if (creationInfos.getCreations().size() == applicationFailuresCount) { subReportNode.newReportNode() - .withMessageTemplate(TABULAR_CREATION_REPORT_KEY_PREFIX + creationInfos.getCreationType().name() + "Error", "Tabular creation: No ${defaultMessage}") + .withMessageTemplate("network.modification.tabular.creation.error") .withUntypedValue("defaultMessage", defaultMessage) .withSeverity(TypedValue.ERROR_SEVERITY) .add(); } else if (applicationFailuresCount > 0) { subReportNode.newReportNode() - .withMessageTemplate(TABULAR_CREATION_REPORT_KEY_PREFIX + creationInfos.getCreationType().name() + "Warning", "Tabular creation: ${creationsCount} ${defaultMessage} and ${failuresCount} have not been created") + .withMessageTemplate("network.modification.tabular.creation.warning") .withUntypedValue("creationsCount", creationInfos.getCreations().size() - applicationFailuresCount) .withUntypedValue("failuresCount", applicationFailuresCount) .withUntypedValue("defaultMessage", defaultMessage) @@ -78,7 +78,7 @@ public void apply(Network network, ReportNode subReportNode) { .add(); } else { subReportNode.newReportNode() - .withMessageTemplate(TABULAR_CREATION_REPORT_KEY_PREFIX + creationInfos.getCreationType().name(), "Tabular creation: ${creationsCount} ${defaultMessage}") + .withMessageTemplate("network.modification.tabular.creation") .withUntypedValue("creationsCount", creationInfos.getCreations().size()) .withUntypedValue("defaultMessage", defaultMessage) .withSeverity(TypedValue.INFO_SEVERITY) diff --git a/src/main/java/org/gridsuite/modification/modifications/TabularModification.java b/src/main/java/org/gridsuite/modification/modifications/TabularModification.java index 82d1faf..280eb74 100644 --- a/src/main/java/org/gridsuite/modification/modifications/TabularModification.java +++ b/src/main/java/org/gridsuite/modification/modifications/TabularModification.java @@ -26,8 +26,6 @@ public class TabularModification extends AbstractModification { private static final Logger LOGGER = LoggerFactory.getLogger(TabularModification.class); - private static final String TABULAR_MODIFICATION_REPORT_KEY_PREFIX = "tabular"; - private final TabularModificationInfos modificationInfos; public TabularModification(TabularModificationInfos modificationInfos) { @@ -55,7 +53,7 @@ public void apply(Network network, ReportNode subReportNode) { } catch (PowsyblException e) { applicationFailuresCount++; subReportNode.newReportNode() - .withMessageTemplate(modifInfos.getType().name() + applicationFailuresCount, "${message}") + .withMessageTemplate("network.modification.tabular.modification.exception") .withUntypedValue("message", e.getMessage()) .withSeverity(TypedValue.WARN_SEVERITY) .add(); @@ -76,13 +74,13 @@ public void apply(Network network, ReportNode subReportNode) { if (modificationInfos.getModifications().size() == applicationFailuresCount) { subReportNode.newReportNode() - .withMessageTemplate(TABULAR_MODIFICATION_REPORT_KEY_PREFIX + modificationInfos.getModificationType().name() + "Error", "Tabular modification: No ${defaultMessage}") + .withMessageTemplate("network.modification.tabular.modification.error") .withUntypedValue("defaultMessage", defaultMessage) .withSeverity(TypedValue.ERROR_SEVERITY) .add(); } else if (applicationFailuresCount > 0) { subReportNode.newReportNode() - .withMessageTemplate(TABULAR_MODIFICATION_REPORT_KEY_PREFIX + modificationInfos.getModificationType().name() + "Warning", "Tabular modification: ${modificationsCount} ${defaultMessage} and ${failuresCount} have not been modified") + .withMessageTemplate("network.modification.tabular.modification.warning") .withUntypedValue("modificationsCount", modificationInfos.getModifications().size() - applicationFailuresCount) .withUntypedValue("failuresCount", applicationFailuresCount) .withUntypedValue("defaultMessage", defaultMessage) @@ -90,7 +88,7 @@ public void apply(Network network, ReportNode subReportNode) { .add(); } else { subReportNode.newReportNode() - .withMessageTemplate(TABULAR_MODIFICATION_REPORT_KEY_PREFIX + modificationInfos.getModificationType().name(), "Tabular modification: ${modificationsCount} ${defaultMessage}") + .withMessageTemplate("network.modification.tabular.modification") .withUntypedValue("modificationsCount", modificationInfos.getModifications().size()) .withUntypedValue("defaultMessage", defaultMessage) .withSeverity(TypedValue.INFO_SEVERITY) @@ -111,26 +109,26 @@ public void checkShuntCompensatorModification( var shuntCompensator = network.getShuntCompensator(shuntCompensatorModificationInfos.getEquipmentId()); if (shuntCompensator.getModelType() == ShuntCompensatorModelType.NON_LINEAR) { subReportNode.newReportNode() - .withMessageTemplate(shuntCompensator.getId(), "Tabular modification: It is currently not possible to modify non-linear shunt compensator with id ${id}") + .withMessageTemplate("network.modification.tabular.shuntCompensator.modifyImpossible") .withUntypedValue("id", shuntCompensator.getId()) .withSeverity(TypedValue.ERROR_SEVERITY) .add(); } else if (shuntCompensatorModificationInfos.getMaxSusceptance() != null) { if (shuntCompensatorModificationInfos.getShuntCompensatorType() != null && shuntCompensatorModificationInfos.getMaxQAtNominalV() != null) { subReportNode.newReportNode() - .withMessageTemplate(shuntCompensator.getId(), "Tabular modification: Input for maximum susceptance has been ignored since it is not possible to simultaneously update type, maximum reactive power and maximum susceptance for shunt compensator with id ${id}") + .withMessageTemplate("network.modification.tabular.shuntCompensator.maxSusceptanceIgnored.1") .withUntypedValue("id", shuntCompensator.getId()) .withSeverity(TypedValue.WARN_SEVERITY) .add(); } else if (shuntCompensatorModificationInfos.getShuntCompensatorType() != null) { subReportNode.newReportNode() - .withMessageTemplate(shuntCompensator.getId(), "Tabular modification: Input for maximum susceptance has been ignored since it is not possible to simultaneously update type and maximum susceptance for shunt compensator with id ${id}") + .withMessageTemplate("network.modification.tabular.shuntCompensator.maxSusceptanceIgnored.2") .withUntypedValue("id", shuntCompensator.getId()) .withSeverity(TypedValue.WARN_SEVERITY) .add(); } else if (shuntCompensatorModificationInfos.getMaxQAtNominalV() != null) { subReportNode.newReportNode() - .withMessageTemplate(shuntCompensator.getId(), "Tabular modification: Input for maximum susceptance has been ignored since it is not possible to simultaneously update maximum reactive power and maximum susceptance for shunt compensator with id ${id}") + .withMessageTemplate("network.modification.tabular.shuntCompensator.maxSusceptanceIgnored.3") .withUntypedValue("id", shuntCompensator.getId()) .withSeverity(TypedValue.WARN_SEVERITY) .add(); diff --git a/src/main/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreation.java b/src/main/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreation.java index 9e8618c..e1327d6 100644 --- a/src/main/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreation.java +++ b/src/main/java/org/gridsuite/modification/modifications/TwoWindingsTransformerCreation.java @@ -23,8 +23,6 @@ import static org.gridsuite.modification.utils.ModificationUtils.*; public class TwoWindingsTransformerCreation extends AbstractModification { - private static final String PHASE_TAP_CHANGER = "Phase Tap Changer"; - private static final String RATIO_TAP_CHANGER = "Ratio Tap Changer"; private final TwoWindingsTransformerCreationInfos modificationInfos; public TwoWindingsTransformerCreation(TwoWindingsTransformerCreationInfos modificationInfos) { @@ -63,10 +61,9 @@ public void apply(Network network, ReportNode subReportNode) { // Create 2wt in bus/mixed breaker create2WTInOtherBreaker(network, voltageLevel1, voltageLevel2, modificationInfos, true, true, subReportNode); } - getInstance().disconnectBranch(modificationInfos, network.getTwoWindingsTransformer(modificationInfos.getEquipmentId()), subReportNode); subReportNode.newReportNode() - .withMessageTemplate("twoWindingsTransformerCreated", "New two windings transformer with id=${id} created") + .withMessageTemplate("network.modification.twoWindingsTransformerCreated") .withUntypedValue("id", modificationInfos.getEquipmentId()) .withSeverity(TypedValue.INFO_SEVERITY) .add(); @@ -169,15 +166,15 @@ private void addPhaseTapChangersToTwoWindingsTransformer(Network network, TwoWin } phaseTapChangerAdder.add(); - ReportNode ratioTapChangerReporter = subReportNode.newReportNode().withMessageTemplate("PhaseTapChangerCreated", PHASE_TAP_CHANGER).add(); + ReportNode ratioTapChangerReporter = subReportNode.newReportNode().withMessageTemplate("network.modification.PhaseTapChangerCreated").add(); if (!regulationReports.isEmpty()) { - getInstance().reportModifications(ratioTapChangerReporter, regulationReports, "RegulatingCreated", "Regulation"); + getInstance().reportModifications(ratioTapChangerReporter, regulationReports, "network.modification.RegulatingCreated"); } if (!regulatedTerminalReports.isEmpty()) { - getInstance().reportModifications(ratioTapChangerReporter, regulatedTerminalReports, "RegulatedTerminalCreated", "Regulated terminal"); + getInstance().reportModifications(ratioTapChangerReporter, regulatedTerminalReports, "network.modification.RegulatedTerminalCreated"); } if (!tapsReports.isEmpty()) { - getInstance().reportModifications(ratioTapChangerReporter, tapsReports, "TapsCreated", "Taps"); + getInstance().reportModifications(ratioTapChangerReporter, tapsReports, "network.modification.TapsCreated"); } } } @@ -221,15 +218,15 @@ private void addRatioTapChangersToTwoWindingsTransformer(Network network, TwoWin ratioTapChangerAdder.beginStep().setR(step.getR()).setX(step.getX()).setG(step.getG()).setB(step.getB()).setRho(step.getRho()).endStep(); } ratioTapChangerAdder.add(); - ReportNode ratioTapChangerReporter = subReportNode.newReportNode().withMessageTemplate("RatioTapChangerCreated", RATIO_TAP_CHANGER).add(); + ReportNode ratioTapChangerReporter = subReportNode.newReportNode().withMessageTemplate("network.modification.RatioTapChangerCreated").add(); if (!regulationReports.isEmpty()) { - getInstance().reportModifications(ratioTapChangerReporter, regulationReports, "RegulationCreated", "Regulation"); + getInstance().reportModifications(ratioTapChangerReporter, regulationReports, "network.modification.RegulationCreated"); } if (!regulatedTerminalReports.isEmpty()) { - getInstance().reportModifications(ratioTapChangerReporter, regulatedTerminalReports, "RegulatedTerminalCreated", "Regulated terminal"); + getInstance().reportModifications(ratioTapChangerReporter, regulatedTerminalReports, "network.modification.RegulatedTerminalCreated"); } if (!tapsReports.isEmpty()) { - getInstance().reportModifications(ratioTapChangerReporter, tapsReports, "TapsCreated", "Taps"); + getInstance().reportModifications(ratioTapChangerReporter, tapsReports, "network.modification.TapsCreated"); } } } @@ -246,18 +243,14 @@ private void setCurrentLimitsForSide(List operation if (selectedGroup != null) { if (side == TwoSides.ONE) { transformer.setSelectedOperationalLimitsGroup1(selectedGroup); - limitsReporter.newReportNode().withMessageTemplate( - "limit set selected on side 1", - "limit set selected on side 1 : ${selectedOperationalLimitsGroup1}") + limitsReporter.newReportNode().withMessageTemplate("network.modification.limitSetSelectedOnSide1") .withUntypedValue("selectedOperationalLimitsGroup1", modificationInfos.getSelectedOperationalLimitsGroup1()) .withSeverity(TypedValue.INFO_SEVERITY) .add(); } if (side == TwoSides.TWO) { transformer.setSelectedOperationalLimitsGroup2(selectedGroup); - limitsReporter.newReportNode().withMessageTemplate( - "limit set selected on side 2", - "limit set selected on side 2 : ${selectedOperationalLimitsGroup2}") + limitsReporter.newReportNode().withMessageTemplate("network.modification.limitSetSelectedOnSide2") .withUntypedValue("selectedOperationalLimitsGroup2", modificationInfos.getSelectedOperationalLimitsGroup2()) .withSeverity(TypedValue.INFO_SEVERITY) .add(); @@ -273,10 +266,10 @@ private void completeTwoWindingsTransformerCreation(Network network, reportBranchCreationConnectivity(modificationInfos, subReportNode); // properties - PropertiesUtils.applyProperties(twoWindingsTransformer, subReportNode, modificationInfos.getProperties(), "TwoWindingsTransformerProperties"); + PropertiesUtils.applyProperties(twoWindingsTransformer, subReportNode, modificationInfos.getProperties(), "network.modification.TwoWindingsTransformerProperties"); // Set permanent and temporary current limits - ReportNode limitsReporter = subReportNode.newReportNode().withMessageTemplate("LimitsCreated", LIMITS).add(); + ReportNode limitsReporter = subReportNode.newReportNode().withMessageTemplate("network.modification.limitsCreated").add(); setCurrentLimitsForSide(modificationInfos.getOperationalLimitsGroups1(), modificationInfos.getSelectedOperationalLimitsGroup1(), twoWindingsTransformer, TwoSides.ONE, limitsReporter); setCurrentLimitsForSide(modificationInfos.getOperationalLimitsGroups2(), modificationInfos.getSelectedOperationalLimitsGroup2(), twoWindingsTransformer, TwoSides.TWO, limitsReporter); diff --git a/src/main/java/org/gridsuite/modification/modifications/TwoWindingsTransformerModification.java b/src/main/java/org/gridsuite/modification/modifications/TwoWindingsTransformerModification.java index e723b3e..1e4cc32 100644 --- a/src/main/java/org/gridsuite/modification/modifications/TwoWindingsTransformerModification.java +++ b/src/main/java/org/gridsuite/modification/modifications/TwoWindingsTransformerModification.java @@ -12,7 +12,6 @@ import com.powsybl.iidm.network.extensions.TwoWindingsTransformerToBeEstimated; import com.powsybl.iidm.network.extensions.TwoWindingsTransformerToBeEstimatedAdder; import org.gridsuite.modification.NetworkModificationException; -import org.gridsuite.modification.TapChangerType; import org.gridsuite.modification.dto.*; import org.gridsuite.modification.utils.ModificationUtils; import org.gridsuite.modification.utils.PropertiesUtils; @@ -29,8 +28,6 @@ */ public class TwoWindingsTransformerModification extends AbstractBranchModification { - private static final String RATIO_TAP_CHANGER_SUBREPORTER_DEFAULT_MESSAGE = "Ratio tap changer"; - private static final String PHASE_TAP_CHANGER_SUBREPORTER_DEFAULT_MESSAGE = "Phase tap changer"; public static final String MAGNETIZING_CONDUCTANCE_FIELD_NAME = "Magnetizing conductance"; private static final String TARGET_DEADBAND = "Target deadband"; @@ -99,16 +96,16 @@ public String getName() { } private void modifyTwoWindingsTransformer(TwoWindingsTransformer twoWindingsTransformer, BranchModificationInfos twoWindingsTransformerModificationInfos, ReportNode subReportNode, Network network) { - modifyBranch(twoWindingsTransformer, twoWindingsTransformerModificationInfos, subReportNode, "twoWindingsTransformerModification", "TwoWindingsTransformer with id=${id} modified :"); + modifyBranch(twoWindingsTransformer, twoWindingsTransformerModificationInfos, subReportNode, "network.modification.twoWindingsTransformerModification.modified"); updateStateEstimationData((TwoWindingsTransformerModificationInfos) twoWindingsTransformerModificationInfos, twoWindingsTransformer, subReportNode); addTapChangersToTwoWindingsTransformer(network, (TwoWindingsTransformerModificationInfos) twoWindingsTransformerModificationInfos, twoWindingsTransformer, subReportNode); - PropertiesUtils.applyProperties(twoWindingsTransformer, subReportNode, twoWindingsTransformerModificationInfos.getProperties(), "TwoWindingsTransformerProperties"); + PropertiesUtils.applyProperties(twoWindingsTransformer, subReportNode, twoWindingsTransformerModificationInfos.getProperties(), "network.modification.TwoWindingsTransformerProperties"); } @Override protected void modifyCharacteristics(Branch branch, BranchModificationInfos branchModificationInfos, ReportNode subReportNode) { TwoWindingsTransformer twoWindingsTransformer = (TwoWindingsTransformer) branch; - ReportNode characteristicsReporter = subReportNode.newReportNode().withMessageTemplate("characteristics", "Characteristics").add(); + ReportNode characteristicsReporter = subReportNode.newReportNode().withMessageTemplate("network.modification.characteristics").add(); // Branch specific fields modifyR(twoWindingsTransformer, branchModificationInfos.getR(), characteristicsReporter); @@ -143,7 +140,7 @@ public static void modifyRatedU2(TwoWindingsTransformer transformer, AttributeMo if (modifRatedU2 != null && modifRatedU2.getValue() != null) { if (reportNode != null) { insertReportNode(reportNode, ModificationUtils.getInstance().buildModificationReport(transformer.getRatedU2(), - modifRatedU2.getValue(), "Rated Voltage (Side 2)", 1)); + modifRatedU2.getValue(), "Rated Voltage (Side 2)")); } transformer.setRatedU2(modifRatedU2.getValue()); } @@ -153,7 +150,7 @@ public static void modifyRatedU1(TwoWindingsTransformer transformer, AttributeMo if (modifRatedU1 != null && modifRatedU1.getValue() != null) { if (reportNode != null) { insertReportNode(reportNode, ModificationUtils.getInstance().buildModificationReport(transformer.getRatedU1(), - modifRatedU1.getValue(), "Rated Voltage (Side 1)", 1)); + modifRatedU1.getValue(), "Rated Voltage (Side 1)")); } transformer.setRatedU1(modifRatedU1.getValue()); } @@ -163,7 +160,7 @@ public static void modifyRatedS(TwoWindingsTransformer transformer, AttributeMod if (modifRatedS != null && modifRatedS.getValue() != null) { if (reportNode != null) { insertReportNode(reportNode, ModificationUtils.getInstance().buildModificationReport(transformer.getRatedS(), - modifRatedS.getValue(), "Rated nominal power", 1)); + modifRatedS.getValue(), "Rated nominal power")); } transformer.setRatedS(modifRatedS.getValue()); } @@ -176,7 +173,7 @@ public static void modifyB(TwoWindingsTransformer transformer, AttributeModifica double oldMagnetizingSusceptanceToReport = transformer.getB() * Math.pow(10, 6); double newMagnetizingSusceptanceToReport = modifB.getValue() * Math.pow(10, 6); insertReportNode(reportNode, ModificationUtils.getInstance().buildModificationReport(oldMagnetizingSusceptanceToReport, - newMagnetizingSusceptanceToReport, "Magnetizing susceptance", 1)); + newMagnetizingSusceptanceToReport, "Magnetizing susceptance")); } transformer.setB(modifB.getValue()); } @@ -191,8 +188,7 @@ public static void modifyG(TwoWindingsTransformer transformer, AttributeModifica ReportNode gReportNode = ModificationUtils.getInstance().buildModificationReport( oldMagnetizingConductanceToReport, newMagnetizingConductanceToReport, - MAGNETIZING_CONDUCTANCE_FIELD_NAME, - 1); + MAGNETIZING_CONDUCTANCE_FIELD_NAME); insertReportNode(reportNode, gReportNode); } transformer.setG(modifG.getValue()); @@ -203,7 +199,7 @@ public static void modifyX(TwoWindingsTransformer twt, AttributeModification null, - regulationValueModification, fieldName, 1); + regulationValueModification, fieldName); if (regulationReports != null && regulationValueReportNode != null) { regulationReports.add(regulationValueReportNode); } @@ -415,7 +410,7 @@ private static void setPhaseTapChangerRegulationAttributes(PhaseTapChanger phase ReportNode targetDeadbandReportNode = ModificationUtils.getInstance().applyElementaryModificationsAndReturnReport( isModification ? phaseTapChanger::setTargetDeadband : phaseTapChangerAdder::setTargetDeadband, isModification ? phaseTapChanger::getTargetDeadband : () -> null, - targetDeadbandModification, TARGET_DEADBAND, 1); + targetDeadbandModification, TARGET_DEADBAND); if (regulationReports != null && targetDeadbandReportNode != null) { regulationReports.add(targetDeadbandReportNode); } @@ -424,7 +419,7 @@ private static void setPhaseTapChangerRegulationAttributes(PhaseTapChanger phase ReportNode regulationReportNode = ModificationUtils.getInstance().applyElementaryModificationsAndReturnReport( isModification ? phaseTapChanger::setRegulationMode : phaseTapChangerAdder::setRegulationMode, isModification ? phaseTapChanger::getRegulationMode : () -> null, - regulationModeModification, "Regulation mode", 1); + regulationModeModification, "Regulation mode"); if (regulationReports != null && regulationReportNode != null) { regulationReports.add(regulationReportNode); } @@ -433,7 +428,7 @@ private static void setPhaseTapChangerRegulationAttributes(PhaseTapChanger phase ReportNode regulatingReportNode = ModificationUtils.getInstance().applyElementaryModificationsAndReturnReport( isModification ? phaseTapChanger::setRegulating : phaseTapChangerAdder::setRegulating, isModification ? phaseTapChanger::isRegulating : () -> null, - regulatingModification, "Regulation", 1); + regulatingModification, "Phase tap regulating"); if (regulationReports != null && regulatingReportNode != null) { regulationReports.add(regulatingReportNode); } @@ -453,7 +448,7 @@ private void processRatioTapChanger(Network network, isModification ? ratioTapChanger::setLoadTapChangingCapabilities : ratioTapChangerAdder::setLoadTapChangingCapabilities, isModification ? ratioTapChanger::hasLoadTapChangingCapabilities : () -> null, - ratioTapChangerInfos.getLoadTapChangingCapabilities(), "Load tap changing capabilities", 1); + ratioTapChangerInfos.getLoadTapChangingCapabilities(), "Load tap changing capabilities"); if (tapChangingReport != null) { ratioTapChangerReports.add(tapChangingReport); } @@ -476,18 +471,18 @@ private void processRatioTapChanger(Network network, if (!ratioTapChangerReports.isEmpty() || !regulationReports.isEmpty() || !regulatedTerminalReports.isEmpty() || !positionsAndStepsReports.isEmpty()) { ReportNode ratioTapChangerReporter = ModificationUtils.getInstance().reportModifications(subReporter, - ratioTapChangerReports, TapChangerType.RATIO.name(), RATIO_TAP_CHANGER_SUBREPORTER_DEFAULT_MESSAGE); + ratioTapChangerReports, "network.modification.RATIO"); if (ratioTapChangerReporter == null) { ratioTapChangerReporter = subReporter.newReportNode() - .withMessageTemplate(TapChangerType.RATIO.name(), RATIO_TAP_CHANGER_SUBREPORTER_DEFAULT_MESSAGE) + .withMessageTemplate("network.modification.RATIO") .add(); } ModificationUtils.getInstance().reportModifications(ratioTapChangerReporter, regulationReports, - "ratioTapChangerRegulationModification", " Regulation"); + "network.modification.ratioTapChangerRegulationModification"); ModificationUtils.getInstance().reportModifications(ratioTapChangerReporter, regulatedTerminalReports, - "ratioTapChangerTerminalRegulatedModification", " Regulated Terminal"); + "network.modification.ratioTapChangerTerminalRegulatedModification"); ModificationUtils.getInstance().reportModifications(ratioTapChangerReporter, positionsAndStepsReports, - "ratioTapChangerPositionsAndStepsModification", " Taps"); + "network.modification.ratioTapChangerPositionsAndStepsModification"); } } @@ -504,7 +499,7 @@ private void processRegulating(RatioTapChangerModificationInfos ratioTapChangerI isModification ? ratioTapChanger::setTargetDeadband : ratioTapChangerAdder::setTargetDeadband, isModification ? ratioTapChanger::getTargetDeadband : () -> null, - AttributeModification.toAttributeModification(0d, OperationType.SET), TARGET_DEADBAND, 2); + AttributeModification.toAttributeModification(0d, OperationType.SET), TARGET_DEADBAND); regulationReports.add(targetDeadbandReportNode); } Boolean isRegulating = ratioTapChangerInfos.getRegulating() != null ? ratioTapChangerInfos.getRegulating().getValue() : null; @@ -515,7 +510,7 @@ private void processRegulating(RatioTapChangerModificationInfos ratioTapChangerI AttributeModification regulationModeModification = AttributeModification.toAttributeModification(regulationMode, OperationType.SET); ReportNode regulationModeReport = ModificationUtils.getInstance().applyElementaryModificationsAndReturnReport( isModification ? ratioTapChanger::setRegulationMode : ratioTapChangerAdder::setRegulationMode, - isModification ? ratioTapChanger::getRegulationMode : () -> null, regulationModeModification, "Regulation mode : " + regulationMode, 2); + isModification ? ratioTapChanger::getRegulationMode : () -> null, regulationModeModification, "Regulation mode : " + regulationMode); if (regulationModeReport != null) { regulationReports.add(regulationModeReport); } @@ -523,7 +518,7 @@ private void processRegulating(RatioTapChangerModificationInfos ratioTapChangerI isModification ? ratioTapChanger::setRegulating : ratioTapChangerAdder::setRegulating, isModification ? ratioTapChanger::isRegulating : () -> null, - ratioTapChangerInfos.getRegulating(), Boolean.TRUE.equals(isRegulating) ? "Regulation" : "Fixed ratio", 2); + ratioTapChangerInfos.getRegulating(), isRegulating ? "Regulation" : "Fixed ratio"); if (voltageRegulationReport != null) { regulationReports.add(voltageRegulationReport); } @@ -550,13 +545,13 @@ public static void modifyTargets(RatioTapChanger ratioTapChanger, RatioTapChange isModification ? ratioTapChanger::setTargetV : ratioTapChangerAdder::setTargetV, isModification ? ratioTapChanger::getTargetV : () -> null, - targetV, "Target voltage", 2); + targetV, "Target voltage"); ReportNode targetDeadbandReportNode = ModificationUtils.getInstance().applyElementaryModificationsAndReturnReport( isModification ? ratioTapChanger::setTargetDeadband : ratioTapChangerAdder::setTargetDeadband, isModification ? ratioTapChanger::getTargetDeadband : () -> null, - targetDeadband, TARGET_DEADBAND, 2); + targetDeadband, TARGET_DEADBAND); if (regulationReports != null) { if (targetVoltageReportNode != null) { @@ -608,11 +603,11 @@ private void processRegulatingTerminal(TapChangerModificationInfos tapChangerMod regulatedTerminalReports .add(ModificationUtils.getInstance().buildModificationReport(oldVoltageLevel, tapChangerModificationInfos.getRegulatingTerminalVlId().getValue(), - "Voltage level", 2)); + "Voltage level")); regulatedTerminalReports.add(ModificationUtils.getInstance().buildModificationReport(oldEquipment, tapChangerModificationInfos.getRegulatingTerminalType().getValue() + " : " + tapChangerModificationInfos.getRegulatingTerminalId().getValue(), - "Equipment", 2)); + "Equipment")); } } @@ -629,7 +624,8 @@ private static void processTapchangerSteps(List tapChangerStepsRepor List modifSteps) { if (tapChangerStepsReports != null) { tapChangerStepsReports.add(ReportNode.newRootReportNode() - .withMessageTemplate("tapChangerStepsModification", " Taps were replaced by new ones below") + .withAllResourceBundlesFromClasspath() + .withMessageTemplate("network.modification.tapChangerStepsModification") .withSeverity(TypedValue.INFO_SEVERITY) .build()); } @@ -650,8 +646,7 @@ private static void processTapchangerSteps(List tapChangerStepsRepor private static void processPhaseTapChangerStep(List tapChangerStepsReports, PhaseTapChangerAdder tapChangerAdder, PhaseTapChangerStepsReplacer tapChangerStepReplacer, boolean isModification, TapChangerStepCreationInfos step) { if (tapChangerStepsReports != null) { - addStepAttributeReport(tapChangerStepsReports, "newStepAlpha" + step.getAlpha(), - " Shift angle : ${alpha}", "alpha", String.valueOf(step.getAlpha())); + addStepAttributeReport(tapChangerStepsReports, "network.modification.newStepAlpha", String.valueOf(step.getAlpha())); } if (isModification) { tapChangerStepReplacer.beginStep().setR(step.getR()).setX(step.getX()).setG(step.getG()) @@ -673,18 +668,12 @@ private static void processRatioTapChangerStep(TapChangerAdder } private static void addStepAttributeReports(List tapChangerStepsReports, TapChangerStepCreationInfos step) { - addStepAttributeReport(tapChangerStepsReports, "newStepIndex" + step.getIndex(), - " Tap (${index})", "index", String.valueOf(step.getIndex())); - addStepAttributeReport(tapChangerStepsReports, "newStepResistance" + step.getR(), - " Δ resistance : ${r}", "r", String.valueOf(step.getR())); - addStepAttributeReport(tapChangerStepsReports, "newStepReactance" + step.getX(), - " Δ reactance : ${x}", "x", String.valueOf(step.getX())); - addStepAttributeReport(tapChangerStepsReports, "newStepConductance" + step.getG(), - " Δ conductance : ${g}", "g", String.valueOf(step.getG())); - addStepAttributeReport(tapChangerStepsReports, "newStepSusceptance" + step.getB(), - " Δ susceptance : ${b}", "b", String.valueOf(step.getB())); - addStepAttributeReport(tapChangerStepsReports, "newStepRatio" + step.getRho(), - " Ratio : ${rho}", "rho", String.valueOf(step.getRho())); + addStepAttributeReport(tapChangerStepsReports, "network.modification.newStepIndex", String.valueOf(step.getIndex())); + addStepAttributeReport(tapChangerStepsReports, "network.modification.newStepResistance", String.valueOf(step.getR())); + addStepAttributeReport(tapChangerStepsReports, "network.modification.newStepReactance", String.valueOf(step.getX())); + addStepAttributeReport(tapChangerStepsReports, "network.modification.newStepConductance", String.valueOf(step.getG())); + addStepAttributeReport(tapChangerStepsReports, "network.modification.newStepSusceptance", String.valueOf(step.getB())); + addStepAttributeReport(tapChangerStepsReports, "network.modification.newStepRatio", String.valueOf(step.getRho())); } public static void processTapChangerPositionsAndSteps(TapChanger tapChanger, @@ -698,13 +687,13 @@ public static void processTapChangerPositionsAndSteps(TapChanger tap isModification ? tapChanger::setLowTapPosition : tapChangerAdder::setLowTapPosition, isModification ? tapChanger::getLowTapPosition : () -> null, - modifyLowTapPosition, "Low tap position", 2); + modifyLowTapPosition, "Low tap position"); ReportNode tapPositionReportNode = ModificationUtils.getInstance().applyElementaryModificationsAndReturnReport( isModification ? tapChanger::setTapPosition : tapChangerAdder::setTapPosition, isModification ? tapChanger::getTapPosition : () -> null, - modifyTapPosition, "Tap position", 2); + modifyTapPosition, "Tap position"); if (tapChangerReports != null) { if (lowTapPositionReportNode != null) { @@ -722,11 +711,12 @@ public static void processTapChangerPositionsAndSteps(TapChanger tap } } - private static void addStepAttributeReport(List tapChangerStepsReports, String key, String defaultMessage, - String valueKey, String value) { + private static void addStepAttributeReport(List tapChangerStepsReports, String key, String value) { tapChangerStepsReports.add(ReportNode.newRootReportNode() - .withMessageTemplate(key, defaultMessage) - .withUntypedValue(valueKey, value) + .withAllResourceBundlesFromClasspath() + .withMessageTemplate(key) + .withUntypedValue("value", value) + .withUntypedValue("delta", "Δ") // Workaround to use non-ISO-8859-1 characters in the internationalization file .withSeverity(TypedValue.INFO_SEVERITY) .build()); } diff --git a/src/main/java/org/gridsuite/modification/modifications/VoltageInitModification.java b/src/main/java/org/gridsuite/modification/modifications/VoltageInitModification.java index 793a494..e890b99 100644 --- a/src/main/java/org/gridsuite/modification/modifications/VoltageInitModification.java +++ b/src/main/java/org/gridsuite/modification/modifications/VoltageInitModification.java @@ -28,18 +28,12 @@ public class VoltageInitModification extends AbstractModification { private final VoltageInitModificationInfos voltageInitModificationInfos; - private static final String GENERATORS_KEY = "GeneratorsModifications"; - private static final String GENERATORS_NAME = "Generators"; - private static final String TWO_WINDINGS_TRANSFORMERS_KEY = "2WindingsTransformersModifications"; - private static final String TWO_WINDINGS_TRANSFORMERS_NAME = "2 windings transformers"; - private static final String THREE_WINDINGS_TRANSFORMERS_KEY = "3WindingsTransformersModifications"; - private static final String THREE_WINDINGS_TRANSFORMERS_NAME = "3 windings transformers"; - private static final String STATIC_VAR_COMPENSATORS_KEY = "StaticVarCompensatorsModifications"; - private static final String STATIC_VAR_COMPENSATORS_NAME = "Static var compensators"; - private static final String VSC_CONVERTER_STATIONS_KEY = "VscConverterStationsModifications"; - private static final String VSC_CONVERTER_STATIONS_NAME = "Vsc converter stations"; - private static final String SHUNT_COMPENSATORS_KEY = "ShuntCompensatorsModifications"; - private static final String SHUNT_COMPENSATORS_NAME = "Shunt compensators"; + private static final String GENERATORS_KEY = "network.modification.GeneratorsModifications"; + private static final String TWO_WINDINGS_TRANSFORMERS_KEY = "network.modification.2WindingsTransformersModifications"; + private static final String THREE_WINDINGS_TRANSFORMERS_KEY = "network.modification.3WindingsTransformersModifications"; + private static final String STATIC_VAR_COMPENSATORS_KEY = "network.modification.StaticVarCompensatorsModifications"; + private static final String VSC_CONVERTER_STATIONS_KEY = "network.modification.VscConverterStationsModifications"; + private static final String SHUNT_COMPENSATORS_KEY = "network.modification.ShuntCompensatorsModifications"; private static final String VOLTAGE_SET_POINT = "Voltage set point"; private static final String VOLTAGE_MAGNITUDE = "Voltage magnitude"; @@ -95,38 +89,40 @@ private void applyBusModification(Network network, ReportNode subReportNode) { } if (bus == null) { reports.add(ReportNode.newRootReportNode() - .withMessageTemplate("busNotFound", "Bus with id=${id} not found") + .withAllResourceBundlesFromClasspath() + .withMessageTemplate("network.modification.busNotFound") .withUntypedValue("id", m.getBusId()) .withSeverity(TypedValue.WARN_SEVERITY) .build()); } else if (m.getV() != null || m.getAngle() != null) { modificationsCount++; reports.add(ReportNode.newRootReportNode() - .withMessageTemplate("busModification", "Bus with id=${id} modified :") + .withAllResourceBundlesFromClasspath() + .withMessageTemplate("network.modification.busModification") .withUntypedValue("id", m.getBusId()) .withSeverity(TypedValue.TRACE_SEVERITY) .build()); if (m.getV() != null) { final double oldV = bus.getV(); bus.setV(m.getV()); - reports.add(ModificationUtils.buildModificationReport(oldV, m.getV(), VOLTAGE_MAGNITUDE, 1, + reports.add(ModificationUtils.buildModificationReport(oldV, m.getV(), VOLTAGE_MAGNITUDE, TypedValue.TRACE_SEVERITY)); } if (m.getAngle() != null) { final double oldAngle = bus.getAngle(); bus.setAngle(m.getAngle()); - reports.add(ModificationUtils.buildModificationReport(oldAngle, m.getAngle(), VOLTAGE_ANGLE, 1, + reports.add(ModificationUtils.buildModificationReport(oldAngle, m.getAngle(), VOLTAGE_ANGLE, TypedValue.TRACE_SEVERITY)); } } } if (!reports.isEmpty()) { - ReportNode busesReporter = subReportNode.newReportNode().withMessageTemplate("BusesModifications", "Buses").add(); + ReportNode busesReporter = subReportNode.newReportNode().withMessageTemplate("network.modification.BusesModifications").add(); reports.forEach(report -> insertReportNode(busesReporter, report)); } if (modificationsCount > 0) { subReportNode.newReportNode() - .withMessageTemplate("busModificationsResume", "${count} bus(es) have been modified.") + .withMessageTemplate("network.modification.busModificationsResume") .withUntypedValue(COUNT, modificationsCount) .withTypedValue(ReportConstants.SEVERITY_KEY, TypedValue.INFO_SEVERITY.toString(), TypedValue.SEVERITY) .add(); @@ -140,36 +136,38 @@ private void applyGeneratorModification(Network network, ReportNode subReportNod final Generator generator = network.getGenerator(m.getGeneratorId()); if (generator == null) { reports.add(ReportNode.newRootReportNode() - .withMessageTemplate("generatorNotFound", "Generator with id=${id} not found") + .withAllResourceBundlesFromClasspath() + .withMessageTemplate("network.modification.generatorNotFound") .withUntypedValue("id", m.getGeneratorId()) .withSeverity(TypedValue.WARN_SEVERITY) .build()); } else if (m.getTargetV() != null || m.getTargetQ() != null) { modificationsCount++; reports.add(ReportNode.newRootReportNode() - .withMessageTemplate("generatorModification", "Generator with id=${id} modified :") + .withAllResourceBundlesFromClasspath() + .withMessageTemplate("network.modification.generatorModification") .withUntypedValue("id", m.getGeneratorId()) .withSeverity(TypedValue.TRACE_SEVERITY) .build()); if (m.getTargetV() != null) { final double oldTargetV = generator.getTargetV(); generator.setTargetV(m.getTargetV()); - reports.add(ModificationUtils.buildModificationReport(oldTargetV, m.getTargetV(), VOLTAGE_SET_POINT, 1, TypedValue.TRACE_SEVERITY)); + reports.add(ModificationUtils.buildModificationReport(oldTargetV, m.getTargetV(), VOLTAGE_SET_POINT, TypedValue.TRACE_SEVERITY)); } if (m.getTargetQ() != null) { final double oldTargetQ = generator.getTargetQ(); generator.setTargetQ(m.getTargetQ()); - reports.add(ModificationUtils.buildModificationReport(oldTargetQ, m.getTargetQ(), REACTIVE_POWER_SET_POINT, 1, TypedValue.TRACE_SEVERITY)); + reports.add(ModificationUtils.buildModificationReport(oldTargetQ, m.getTargetQ(), REACTIVE_POWER_SET_POINT, TypedValue.TRACE_SEVERITY)); } } } if (!reports.isEmpty()) { - ReportNode generatorsReportNode = subReportNode.newReportNode().withMessageTemplate(GENERATORS_KEY, GENERATORS_NAME).add(); + ReportNode generatorsReportNode = subReportNode.newReportNode().withMessageTemplate(GENERATORS_KEY).add(); reports.forEach(report -> insertReportNode(generatorsReportNode, report)); } if (modificationsCount > 0) { subReportNode.newReportNode() - .withMessageTemplate("generatorModificationsResume", "${count} generator(s) have been modified.") + .withMessageTemplate("network.modification.generatorModificationsResume") .withUntypedValue(COUNT, modificationsCount) .withTypedValue(ReportConstants.SEVERITY_KEY, TypedValue.INFO_SEVERITY.toString(), TypedValue.SEVERITY) .add(); @@ -185,13 +183,15 @@ private void applyTransformerModification(Network network, ReportNode subReportN final ThreeWindingsTransformer threeWindingsTransformer = network.getThreeWindingsTransformer(t.getTransformerId()); if (threeWindingsTransformer == null) { reports3WT.add(ReportNode.newRootReportNode() - .withMessageTemplate("3WindingsTransformerNotFound", "3 windings transformer with id=${id} not found") + .withAllResourceBundlesFromClasspath() + .withMessageTemplate("network.modification.3WindingsTransformerNotFound") .withUntypedValue("id", t.getTransformerId()) .withSeverity(TypedValue.WARN_SEVERITY) .build()); } else if (threeWindingsTransformer.getLeg(t.getLegSide()).getRatioTapChanger() == null) { reports3WT.add(ReportNode.newRootReportNode() - .withMessageTemplate("3WindingsTransformerRatioTapChangerNotFound", "3 windings transformer with id=${id} : Ratio tap changer for leg ${leg} not found") + .withAllResourceBundlesFromClasspath() + .withMessageTemplate("network.modification.3WindingsTransformerRatioTapChangerNotFound") .withUntypedValue("id", t.getTransformerId()) .withUntypedValue("leg", t.getLegSide().name()) .withSeverity(TypedValue.WARN_SEVERITY) @@ -199,66 +199,70 @@ private void applyTransformerModification(Network network, ReportNode subReportN } else if (t.getRatioTapChangerPosition() != null || t.getRatioTapChangerTargetV() != null) { modificationsCount++; reports3WT.add(ReportNode.newRootReportNode() - .withMessageTemplate("3WindingsTransformerModification", "3 windings transformer with id=${id} modified :") + .withAllResourceBundlesFromClasspath() + .withMessageTemplate("network.modification.3WindingsTransformerModification") .withUntypedValue("id", t.getTransformerId()) .withSeverity(TypedValue.TRACE_SEVERITY) .build()); if (t.getRatioTapChangerPosition() != null) { final int oldTapPosition = threeWindingsTransformer.getLeg(t.getLegSide()).getRatioTapChanger().getTapPosition(); threeWindingsTransformer.getLeg(t.getLegSide()).getRatioTapChanger().setTapPosition(t.getRatioTapChangerPosition()); - reports3WT.add(ModificationUtils.buildModificationReport(oldTapPosition, t.getRatioTapChangerPosition(), "Leg " + t.getLegSide().name() + " ratio tap changer position", 1, TypedValue.TRACE_SEVERITY)); + reports3WT.add(ModificationUtils.buildModificationReport(oldTapPosition, t.getRatioTapChangerPosition(), "Leg " + t.getLegSide().name() + " ratio tap changer position", TypedValue.TRACE_SEVERITY)); } if (t.getRatioTapChangerTargetV() != null) { final double oldTapTargetV = threeWindingsTransformer.getLeg(t.getLegSide()).getRatioTapChanger().getTargetV(); threeWindingsTransformer.getLeg(t.getLegSide()).getRatioTapChanger().setTargetV(t.getRatioTapChangerTargetV()); - reports3WT.add(ModificationUtils.buildModificationReport(oldTapTargetV, t.getRatioTapChangerTargetV(), "Leg " + t.getLegSide().name() + " ratio tap changer target voltage", 1, TypedValue.TRACE_SEVERITY)); + reports3WT.add(ModificationUtils.buildModificationReport(oldTapTargetV, t.getRatioTapChangerTargetV(), "Leg " + t.getLegSide().name() + " ratio tap changer target voltage", TypedValue.TRACE_SEVERITY)); } } } else { final TwoWindingsTransformer twoWindingsTransformer = network.getTwoWindingsTransformer(t.getTransformerId()); if (twoWindingsTransformer == null) { reports2WT.add(ReportNode.newRootReportNode() - .withMessageTemplate("2WindingsTransformerNotFound", "2 windings transformer with id=${id} not found") + .withAllResourceBundlesFromClasspath() + .withMessageTemplate("network.modification.2WindingsTransformerNotFound") .withUntypedValue("id", t.getTransformerId()) .withSeverity(TypedValue.WARN_SEVERITY) .build()); } else if (twoWindingsTransformer.getRatioTapChanger() == null) { reports2WT.add(ReportNode.newRootReportNode() - .withMessageTemplate("2WindingsTransformerRatioTapChangerNotFound", "2 windings transformer with id=${id} : Ratio tap changer not found") + .withAllResourceBundlesFromClasspath() + .withMessageTemplate("network.modification.2WindingsTransformerRatioTapChangerNotFound") .withUntypedValue("id", t.getTransformerId()) .withSeverity(TypedValue.WARN_SEVERITY) .build()); } else if (t.getRatioTapChangerPosition() != null || t.getRatioTapChangerTargetV() != null) { modificationsCount++; reports2WT.add(ReportNode.newRootReportNode() - .withMessageTemplate("2WindingsTransformerModification", "2 windings transformer with id=${id} modified :") + .withAllResourceBundlesFromClasspath() + .withMessageTemplate("network.modification.2WindingsTransformerModification") .withUntypedValue("id", t.getTransformerId()) .withSeverity(TypedValue.TRACE_SEVERITY) .build()); if (t.getRatioTapChangerPosition() != null) { final int oldTapPosition = twoWindingsTransformer.getRatioTapChanger().getTapPosition(); twoWindingsTransformer.getRatioTapChanger().setTapPosition(t.getRatioTapChangerPosition()); - reports2WT.add(ModificationUtils.buildModificationReport(oldTapPosition, t.getRatioTapChangerPosition(), "Ratio tap changer position", 1, TypedValue.TRACE_SEVERITY)); + reports2WT.add(ModificationUtils.buildModificationReport(oldTapPosition, t.getRatioTapChangerPosition(), "Ratio tap changer position", TypedValue.TRACE_SEVERITY)); } if (t.getRatioTapChangerTargetV() != null) { final double oldTapTargetV = twoWindingsTransformer.getRatioTapChanger().getTargetV(); twoWindingsTransformer.getRatioTapChanger().setTargetV(t.getRatioTapChangerTargetV()); - reports2WT.add(ModificationUtils.buildModificationReport(oldTapTargetV, t.getRatioTapChangerTargetV(), "Ratio tap changer target voltage", 1, TypedValue.TRACE_SEVERITY)); + reports2WT.add(ModificationUtils.buildModificationReport(oldTapTargetV, t.getRatioTapChangerTargetV(), "Ratio tap changer target voltage", TypedValue.TRACE_SEVERITY)); } } } } if (!reports2WT.isEmpty()) { - ReportNode twoWindingsTransformerReportNode = subReportNode.newReportNode().withMessageTemplate(TWO_WINDINGS_TRANSFORMERS_KEY, TWO_WINDINGS_TRANSFORMERS_NAME).add(); + ReportNode twoWindingsTransformerReportNode = subReportNode.newReportNode().withMessageTemplate(TWO_WINDINGS_TRANSFORMERS_KEY).add(); reports2WT.forEach(report -> insertReportNode(twoWindingsTransformerReportNode, report)); } if (!reports3WT.isEmpty()) { - ReportNode threeWindingsTransformerReporter = subReportNode.newReportNode().withMessageTemplate(THREE_WINDINGS_TRANSFORMERS_KEY, THREE_WINDINGS_TRANSFORMERS_NAME).add(); + ReportNode threeWindingsTransformerReporter = subReportNode.newReportNode().withMessageTemplate(THREE_WINDINGS_TRANSFORMERS_KEY).add(); reports3WT.forEach(report -> insertReportNode(threeWindingsTransformerReporter, report)); } if (modificationsCount > 0) { subReportNode.newReportNode() - .withMessageTemplate("windingsTransformerModificationsResume", "${count} transformer(s) have been modified.") + .withMessageTemplate("network.modification.windingsTransformerModificationsResume") .withUntypedValue(COUNT, modificationsCount) .withTypedValue(ReportConstants.SEVERITY_KEY, TypedValue.INFO_SEVERITY.toString(), TypedValue.SEVERITY) .add(); @@ -272,36 +276,38 @@ private void applyStaticVarCompensatorModification(Network network, ReportNode s final StaticVarCompensator staticVarCompensator = network.getStaticVarCompensator(s.getStaticVarCompensatorId()); if (staticVarCompensator == null) { reports.add(ReportNode.newRootReportNode() - .withMessageTemplate("staticVarCompensatorNotFound", "Static var compensator with id=${id} not found") + .withAllResourceBundlesFromClasspath() + .withMessageTemplate("network.modification.staticVarCompensatorNotFound") .withUntypedValue("id", s.getStaticVarCompensatorId()) .withSeverity(TypedValue.WARN_SEVERITY) .build()); } else if (s.getVoltageSetpoint() != null || s.getReactivePowerSetpoint() != null) { modificationsCount++; reports.add(ReportNode.newRootReportNode() - .withMessageTemplate("staticVarCompensatorModification", "Static var compensator with id=${id} modified :") + .withAllResourceBundlesFromClasspath() + .withMessageTemplate("network.modification.staticVarCompensatorModification") .withUntypedValue("id", s.getStaticVarCompensatorId()) .withSeverity(TypedValue.TRACE_SEVERITY) .build()); if (s.getVoltageSetpoint() != null) { final double oldTargetV = staticVarCompensator.getVoltageSetpoint(); staticVarCompensator.setVoltageSetpoint(s.getVoltageSetpoint()); - reports.add(ModificationUtils.buildModificationReport(oldTargetV, s.getVoltageSetpoint(), VOLTAGE_SET_POINT, 1, TypedValue.TRACE_SEVERITY)); + reports.add(ModificationUtils.buildModificationReport(oldTargetV, s.getVoltageSetpoint(), VOLTAGE_SET_POINT, TypedValue.TRACE_SEVERITY)); } if (s.getReactivePowerSetpoint() != null) { final double oldTargetQ = staticVarCompensator.getReactivePowerSetpoint(); staticVarCompensator.setReactivePowerSetpoint(s.getReactivePowerSetpoint()); - reports.add(ModificationUtils.buildModificationReport(oldTargetQ, s.getReactivePowerSetpoint(), REACTIVE_POWER_SET_POINT, 1, TypedValue.TRACE_SEVERITY)); + reports.add(ModificationUtils.buildModificationReport(oldTargetQ, s.getReactivePowerSetpoint(), REACTIVE_POWER_SET_POINT, TypedValue.TRACE_SEVERITY)); } } } if (!reports.isEmpty()) { - ReportNode staticVarsReportNode = subReportNode.newReportNode().withMessageTemplate(STATIC_VAR_COMPENSATORS_KEY, STATIC_VAR_COMPENSATORS_NAME).add(); + ReportNode staticVarsReportNode = subReportNode.newReportNode().withMessageTemplate(STATIC_VAR_COMPENSATORS_KEY).add(); reports.forEach(report -> insertReportNode(staticVarsReportNode, report)); } if (modificationsCount > 0) { subReportNode.newReportNode() - .withMessageTemplate("svcModificationsResume", "${count} static var compensator(s) have been modified.") + .withMessageTemplate("network.modification.svcModificationsResume") .withUntypedValue(COUNT, modificationsCount) .withTypedValue(ReportConstants.SEVERITY_KEY, TypedValue.INFO_SEVERITY.toString(), TypedValue.SEVERITY) .add(); @@ -315,36 +321,38 @@ private void applyVscConverterStationModification(Network network, ReportNode su final VscConverterStation vscConverterStation = network.getVscConverterStation(v.getVscConverterStationId()); if (vscConverterStation == null) { reports.add(ReportNode.newRootReportNode() - .withMessageTemplate("vscConverterStationNotFound", "Vsc converter station with id=${id} not found") + .withAllResourceBundlesFromClasspath() + .withMessageTemplate("network.modification.vscConverterStationNotFound") .withUntypedValue("id", v.getVscConverterStationId()) .withSeverity(TypedValue.WARN_SEVERITY) .build()); } else if (v.getVoltageSetpoint() != null || v.getReactivePowerSetpoint() != null) { modificationsCount++; reports.add(ReportNode.newRootReportNode() - .withMessageTemplate("vscConverterStationModification", "Vsc converter station with id=${id} modified :") + .withAllResourceBundlesFromClasspath() + .withMessageTemplate("network.modification.vscConverterStationModification") .withUntypedValue("id", v.getVscConverterStationId()) .withSeverity(TypedValue.TRACE_SEVERITY) .build()); if (v.getVoltageSetpoint() != null) { final double oldTargetV = vscConverterStation.getVoltageSetpoint(); vscConverterStation.setVoltageSetpoint(v.getVoltageSetpoint()); - reports.add(ModificationUtils.buildModificationReport(oldTargetV, v.getVoltageSetpoint(), VOLTAGE_SET_POINT, 1, TypedValue.TRACE_SEVERITY)); + reports.add(ModificationUtils.buildModificationReport(oldTargetV, v.getVoltageSetpoint(), VOLTAGE_SET_POINT, TypedValue.TRACE_SEVERITY)); } if (v.getReactivePowerSetpoint() != null) { final double oldTargetQ = vscConverterStation.getReactivePowerSetpoint(); vscConverterStation.setReactivePowerSetpoint(v.getReactivePowerSetpoint()); - reports.add(ModificationUtils.buildModificationReport(oldTargetQ, v.getReactivePowerSetpoint(), REACTIVE_POWER_SET_POINT, 1, TypedValue.TRACE_SEVERITY)); + reports.add(ModificationUtils.buildModificationReport(oldTargetQ, v.getReactivePowerSetpoint(), REACTIVE_POWER_SET_POINT, TypedValue.TRACE_SEVERITY)); } } } if (!reports.isEmpty()) { - ReportNode vscConverterStationsReporter = subReportNode.newReportNode().withMessageTemplate(VSC_CONVERTER_STATIONS_KEY, VSC_CONVERTER_STATIONS_NAME).add(); + ReportNode vscConverterStationsReporter = subReportNode.newReportNode().withMessageTemplate(VSC_CONVERTER_STATIONS_KEY).add(); reports.forEach(report -> insertReportNode(vscConverterStationsReporter, report)); } if (modificationsCount > 0) { subReportNode.newReportNode() - .withMessageTemplate("vscModificationsResume", "${count} vsc converter station(s) have been modified.") + .withMessageTemplate("network.modification.vscModificationsResume") .withUntypedValue(COUNT, modificationsCount) .withTypedValue(ReportConstants.SEVERITY_KEY, TypedValue.INFO_SEVERITY.toString(), TypedValue.SEVERITY) .add(); @@ -358,7 +366,8 @@ private void applyShuntCompensatorModification(Network network, ReportNode subRe final ShuntCompensator shuntCompensator = network.getShuntCompensator(m.getShuntCompensatorId()); if (shuntCompensator == null) { reports.add(ReportNode.newRootReportNode() - .withMessageTemplate("shuntCompensatorNotFound", "Shunt compensator with id=${id} not found") + .withAllResourceBundlesFromClasspath() + .withMessageTemplate("network.modification.shuntCompensatorNotFound") .withUntypedValue("id", m.getShuntCompensatorId()) .withSeverity(TypedValue.WARN_SEVERITY) .build()); @@ -369,51 +378,56 @@ private void applyShuntCompensatorModification(Network network, ReportNode subRe if (shuntCompensatorTerminal.isConnected()) { // shunt compensator is connected if (m.getSectionCount() == null) { reportsShunt.add(ReportNode.newRootReportNode() - .withMessageTemplate("shuntCompensatorSectionCountUndefined", "\tSection count value is undefined") + .withAllResourceBundlesFromClasspath() + .withMessageTemplate("network.modification.shuntCompensatorSectionCountUndefined") .withSeverity(TypedValue.WARN_SEVERITY) .build()); } else { if (m.getSectionCount() == 0) { shuntCompensatorTerminal.disconnect(); reportsShunt.add(ReportNode.newRootReportNode() - .withMessageTemplate("shuntCompensatorDisconnected", "\tShunt compensator disconnected") + .withAllResourceBundlesFromClasspath() + .withMessageTemplate("network.modification.shuntCompensatorDisconnected") .withSeverity(TypedValue.TRACE_SEVERITY) .build()); } if (m.getSectionCount() != currentSectionCount) { shuntCompensator.setSectionCount(m.getSectionCount()); - reportsShunt.add(ModificationUtils.buildModificationReport(currentSectionCount, m.getSectionCount(), SECTION_COUNT, 1, TypedValue.TRACE_SEVERITY)); + reportsShunt.add(ModificationUtils.buildModificationReport(currentSectionCount, m.getSectionCount(), SECTION_COUNT, TypedValue.TRACE_SEVERITY)); } } } else { // shunt compensator is disconnected if (m.getConnect() == null) { reportsShunt.add(ReportNode.newRootReportNode() - .withMessageTemplate("shuntCompensatorConnectUndefined", "\tConnect value is undefined") + .withAllResourceBundlesFromClasspath() + .withMessageTemplate("network.modification.shuntCompensatorConnectUndefined") .withSeverity(TypedValue.WARN_SEVERITY) .build()); } else { if (Boolean.TRUE.equals(m.getConnect())) { shuntCompensatorTerminal.connect(); reportsShunt.add(ReportNode.newRootReportNode() - .withMessageTemplate("shuntCompensatorReconnected", "\tShunt compensator reconnected") + .withAllResourceBundlesFromClasspath() + .withMessageTemplate("network.modification.shuntCompensatorReconnected") .withSeverity(TypedValue.TRACE_SEVERITY) .build()); } if (m.getSectionCount() != currentSectionCount) { shuntCompensator.setSectionCount(m.getSectionCount()); - reportsShunt.add(ModificationUtils.buildModificationReport(currentSectionCount, m.getSectionCount(), SECTION_COUNT, 1, TypedValue.TRACE_SEVERITY)); + reportsShunt.add(ModificationUtils.buildModificationReport(currentSectionCount, m.getSectionCount(), SECTION_COUNT, TypedValue.TRACE_SEVERITY)); } } } if (m.getTargetV() != null) { final double oldTargetV = shuntCompensator.getTargetV(); shuntCompensator.setTargetV(m.getTargetV()); - reportsShunt.add(ModificationUtils.buildModificationReport(oldTargetV, m.getTargetV(), VOLTAGE_SET_POINT, 1, TypedValue.TRACE_SEVERITY)); + reportsShunt.add(ModificationUtils.buildModificationReport(oldTargetV, m.getTargetV(), VOLTAGE_SET_POINT, TypedValue.TRACE_SEVERITY)); } if (!reportsShunt.isEmpty()) { modificationsCount++; reports.add(ReportNode.newRootReportNode() - .withMessageTemplate("shuntCompensatorModification", "Shunt compensator with id=${id} modified :") + .withAllResourceBundlesFromClasspath() + .withMessageTemplate("network.modification.shuntCompensatorModification") .withUntypedValue("id", m.getShuntCompensatorId()) .withSeverity(TypedValue.TRACE_SEVERITY) .build()); @@ -422,12 +436,12 @@ private void applyShuntCompensatorModification(Network network, ReportNode subRe } } if (!reports.isEmpty()) { - ReportNode shuntCompensatorsReporter = subReportNode.newReportNode().withMessageTemplate(SHUNT_COMPENSATORS_KEY, SHUNT_COMPENSATORS_NAME).add(); + ReportNode shuntCompensatorsReporter = subReportNode.newReportNode().withMessageTemplate(SHUNT_COMPENSATORS_KEY).add(); reports.forEach(report -> insertReportNode(shuntCompensatorsReporter, report)); } if (modificationsCount > 0) { subReportNode.newReportNode() - .withMessageTemplate("shuntCompensatorModificationsResume", "${count} shunt compensator(s) have been modified.") + .withMessageTemplate("network.modification.shuntCompensatorModificationsResume") .withUntypedValue(COUNT, modificationsCount) .withTypedValue(ReportConstants.SEVERITY_KEY, TypedValue.INFO_SEVERITY.toString(), TypedValue.SEVERITY) .add(); diff --git a/src/main/java/org/gridsuite/modification/modifications/VoltageLevelCreation.java b/src/main/java/org/gridsuite/modification/modifications/VoltageLevelCreation.java index 366884b..c74b96b 100644 --- a/src/main/java/org/gridsuite/modification/modifications/VoltageLevelCreation.java +++ b/src/main/java/org/gridsuite/modification/modifications/VoltageLevelCreation.java @@ -42,7 +42,7 @@ public void apply(Network network, ReportNode subReportNode) { ModificationUtils.getInstance().createVoltageLevel(modificationInfos, subReportNode, network); // properties VoltageLevel voltageLevel = network.getVoltageLevel(modificationInfos.getEquipmentId()); - PropertiesUtils.applyProperties(voltageLevel, subReportNode, modificationInfos.getProperties(), "VlProperties"); + PropertiesUtils.applyProperties(voltageLevel, subReportNode, modificationInfos.getProperties(), "network.modification.VlProperties"); } @Override diff --git a/src/main/java/org/gridsuite/modification/modifications/VoltageLevelModification.java b/src/main/java/org/gridsuite/modification/modifications/VoltageLevelModification.java index 59e48b3..d9c38db 100644 --- a/src/main/java/org/gridsuite/modification/modifications/VoltageLevelModification.java +++ b/src/main/java/org/gridsuite/modification/modifications/VoltageLevelModification.java @@ -94,7 +94,7 @@ public void apply(Network network, ReportNode subReportNode) { VoltageLevel voltageLevel = ModificationUtils.getInstance().getVoltageLevel(network, modificationInfos.getEquipmentId()); subReportNode.newReportNode() - .withMessageTemplate("voltageLevelModification", "Voltage level with id=${id} modified :") + .withMessageTemplate("network.modification.voltageLevelModification") .withUntypedValue("id", modificationInfos.getEquipmentId()) .withSeverity(TypedValue.INFO_SEVERITY) .add(); @@ -105,7 +105,7 @@ public void apply(Network network, ReportNode subReportNode) { modifyHighVoltageLimit(voltageLevel, modificationInfos.getHighVoltageLimit(), subReportNode); modifyVoltageLevelShortCircuit(modificationInfos.getIpMin(), modificationInfos.getIpMax(), subReportNode, voltageLevel); - PropertiesUtils.applyProperties(voltageLevel, subReportNode, modificationInfos.getProperties(), "VlProperties"); + PropertiesUtils.applyProperties(voltageLevel, subReportNode, modificationInfos.getProperties(), "network.modification.VlProperties"); } @Override diff --git a/src/main/java/org/gridsuite/modification/modifications/VoltageLevelTopologyModification.java b/src/main/java/org/gridsuite/modification/modifications/VoltageLevelTopologyModification.java index 1d6b6df..8553fc1 100644 --- a/src/main/java/org/gridsuite/modification/modifications/VoltageLevelTopologyModification.java +++ b/src/main/java/org/gridsuite/modification/modifications/VoltageLevelTopologyModification.java @@ -53,7 +53,7 @@ public void apply(Network network, ReportNode subReportNode) { equipmentAttributeModification.apply(network, subReportNode); } subReportNode.newReportNode() - .withMessageTemplate("voltageLevelTopologyModified", "Voltage level '${id}' topology has been modified") + .withMessageTemplate("network.modification.voltageLevelTopologyModified") .withUntypedValue("id", modificationInfos.getEquipmentId()) .withSeverity(TypedValue.DEBUG_SEVERITY) .add(); diff --git a/src/main/java/org/gridsuite/modification/modifications/VscCreation.java b/src/main/java/org/gridsuite/modification/modifications/VscCreation.java index 9ebb552..eccebc3 100644 --- a/src/main/java/org/gridsuite/modification/modifications/VscCreation.java +++ b/src/main/java/org/gridsuite/modification/modifications/VscCreation.java @@ -30,8 +30,8 @@ public class VscCreation extends AbstractModification { - public static final String VSC_SETPOINTS = "vscSetPoints"; - public static final String VSC_CHARACTERISTICS = "vscCharacteristics"; + public static final String VSC_SETPOINTS = "network.modification.vscSetPoints"; + public static final String VSC_CHARACTERISTICS = "network.modification.vscCharacteristics"; private final VscCreationInfos modificationInfos; @@ -131,7 +131,7 @@ public void apply(Network network, ReportNode subReportNode) { reportHvdcLineInfos(subReportNode); subReportNode.newReportNode() - .withMessageTemplate("vscCreated", "New vsc with id=${id} created") + .withMessageTemplate("network.modification.vscCreated") .withUntypedValue("id", modificationInfos.getEquipmentId()) .withSeverity(TypedValue.INFO_SEVERITY) .add(); @@ -141,7 +141,7 @@ public void apply(Network network, ReportNode subReportNode) { .reportElementaryCreation(subReportNode, modificationInfos.getEquipmentName(), "Name"); } - PropertiesUtils.applyProperties(hvdcLine, subReportNode, modificationInfos.getProperties(), "VscProperties"); + PropertiesUtils.applyProperties(hvdcLine, subReportNode, modificationInfos.getProperties(), "network.modification.VscProperties"); } @Override @@ -159,28 +159,28 @@ private void reportHvdcLineInfos(ReportNode subReportNode) { characteristicsReports.add(ModificationUtils.getInstance().buildCreationReport(modificationInfos.getNominalV(), "DC nominal voltage")); characteristicsReports.add(ModificationUtils.getInstance().buildCreationReport(modificationInfos.getR(), "DC resistance")); characteristicsReports.add(ModificationUtils.getInstance().buildCreationReport(modificationInfos.getMaxP(), "Pmax")); - ModificationUtils.getInstance().reportModifications(subReportNode, characteristicsReports, VSC_CHARACTERISTICS, CHARACTERISTICS); + ModificationUtils.getInstance().reportModifications(subReportNode, characteristicsReports, VSC_CHARACTERISTICS); List limitsReports = new ArrayList<>(); limitsReports.add(ModificationUtils.getInstance().buildCreationReport(modificationInfos.getOperatorActivePowerLimitFromSide1ToSide2(), "Operator active power limit (Side1 -> Side 2)")); limitsReports.add(ModificationUtils.getInstance().buildCreationReport(modificationInfos.getOperatorActivePowerLimitFromSide2ToSide1(), "Operator active power limit (Side2 -> Side 1)")); - ModificationUtils.getInstance().reportModifications(subReportNode, limitsReports, "vscLimits", "Limits"); + ModificationUtils.getInstance().reportModifications(subReportNode, limitsReports, "network.modification.vscLimits"); List setPointsReports = new ArrayList<>(); setPointsReports.add(ModificationUtils.getInstance().buildCreationReport(modificationInfos.getConvertersMode(), "Converters mode")); setPointsReports.add(ModificationUtils.getInstance().buildCreationReport(modificationInfos.getActivePowerSetpoint(), "Active power")); - ReportNode setPointsReporter = ModificationUtils.getInstance().reportModifications(subReportNode, setPointsReports, VSC_SETPOINTS, SETPOINTS); + ReportNode setPointsReporter = ModificationUtils.getInstance().reportModifications(subReportNode, setPointsReports, VSC_SETPOINTS); List angleDroopActivePowerControlReports = new ArrayList<>(); angleDroopActivePowerControlReports.add(ModificationUtils.getInstance() - .createEnabledDisabledReport("angleDroopActivePowerControl", modificationInfos.getAngleDroopActivePowerControl())); + .createEnabledDisabledReport("network.modification.angleDroopActivePowerControl", modificationInfos.getAngleDroopActivePowerControl())); if (modificationInfos.getP0() != null) { angleDroopActivePowerControlReports.add(ModificationUtils.getInstance().buildCreationReport(modificationInfos.getP0(), "P0")); } if (modificationInfos.getDroop() != null) { angleDroopActivePowerControlReports.add(ModificationUtils.getInstance().buildCreationReport(modificationInfos.getDroop(), "Droop")); } - ModificationUtils.getInstance().reportModifications(setPointsReporter, angleDroopActivePowerControlReports, "vscAngleDroop", "Angle droop active power control"); + ModificationUtils.getInstance().reportModifications(setPointsReporter, angleDroopActivePowerControlReports, "network.modification.vscAngleDroop"); } private VscConverterStation createConverterStation(Network network, @@ -188,7 +188,7 @@ private VscConverterStation createConverterStation(Network network, ReportNode subReportNode, String logFieldName) { ReportNode converterStationReporter = subReportNode.newReportNode() - .withMessageTemplate("converterStationCreated", "${fieldName} with id=${id} created") + .withMessageTemplate("network.modification.converterStationCreated") .withUntypedValue("fieldName", logFieldName) .withUntypedValue("id", converterStationCreationInfos.getEquipmentId()) .add(); @@ -262,8 +262,7 @@ private void addExtensionsAndReports(VscConverterStation vscConverterStation, ModificationUtils.getInstance().reportModifications(subReporter, List.of(ModificationUtils.getInstance().buildCreationReport(converterStationCreationInfos.getLossFactor(), "Loss Factor")), - "converterStationCharacteristics", - CHARACTERISTICS); + "network.modification.converterStationCharacteristics"); ModificationUtils.getInstance().createReactiveLimits(converterStationCreationInfos, vscConverterStation, subReporter); @@ -271,7 +270,7 @@ private void addExtensionsAndReports(VscConverterStation vscConverterStation, } private void reportConverterStationSetPoints(ConverterStationCreationInfos converterStationCreationInfos, ReportNode subReportNode) { - ReportNode setPointReporter = subReportNode.newReportNode().withMessageTemplate("converterStationSetPoint", SETPOINTS).add(); + ReportNode setPointReporter = subReportNode.newReportNode().withMessageTemplate("network.modification.converterStationSetPoint").add(); if (converterStationCreationInfos.getReactivePowerSetpoint() != null) { ModificationUtils.getInstance().reportElementaryCreation(setPointReporter, @@ -280,7 +279,7 @@ private void reportConverterStationSetPoints(ConverterStationCreationInfos conve } List setPointsVoltageReports = new ArrayList<>(); - setPointsVoltageReports.add(ModificationUtils.getInstance().createEnabledDisabledReport("voltageRegulationOn", + setPointsVoltageReports.add(ModificationUtils.getInstance().createEnabledDisabledReport("network.modification.voltageRegulationOn", converterStationCreationInfos.getVoltageRegulationOn())); if (converterStationCreationInfos.getVoltageSetpoint() != null) { setPointsVoltageReports.add(ModificationUtils.getInstance().buildCreationReport(converterStationCreationInfos.getReactivePowerSetpoint(), "Voltage")); @@ -288,7 +287,6 @@ private void reportConverterStationSetPoints(ConverterStationCreationInfos conve ModificationUtils.getInstance().reportModifications(setPointReporter, setPointsVoltageReports, - "converterStationSetPointsVoltageRegulation", - "Voltage regulation"); + "network.modification.converterStationSetPointsVoltageRegulation"); } } diff --git a/src/main/java/org/gridsuite/modification/modifications/VscModification.java b/src/main/java/org/gridsuite/modification/modifications/VscModification.java index a64f51e..fc442fe 100644 --- a/src/main/java/org/gridsuite/modification/modifications/VscModification.java +++ b/src/main/java/org/gridsuite/modification/modifications/VscModification.java @@ -134,7 +134,7 @@ public String getName() { private void modifyVsc(@Nonnull Network network, @Nonnull HvdcLine hvdcLine, VscModificationInfos modificationInfos, ReportNode subReportNode) { subReportNode.newReportNode() - .withMessageTemplate("VscModification", "Vsc with id=${id} modified :") + .withMessageTemplate("network.modification.VscModification") .withUntypedValue("id", modificationInfos.getEquipmentId()) .withSeverity(TypedValue.INFO_SEVERITY) .add(); @@ -149,14 +149,14 @@ private void modifyVsc(@Nonnull Network network, @Nonnull HvdcLine hvdcLine, Vsc if (!setPointsReports.isEmpty() || !droopReports.isEmpty()) { ReportNode setPointsReport = null; if (!setPointsReports.isEmpty()) { - setPointsReport = ModificationUtils.getInstance().reportModifications(subReportNode, setPointsReports, VSC_SETPOINTS, SETPOINTS); + setPointsReport = ModificationUtils.getInstance().reportModifications(subReportNode, setPointsReports, VSC_SETPOINTS); } if (!droopReports.isEmpty()) { if (setPointsReport == null) { - setPointsReport = subReportNode.newReportNode().withMessageTemplate(VSC_SETPOINTS, SETPOINTS).add(); + setPointsReport = subReportNode.newReportNode().withMessageTemplate(VSC_SETPOINTS).add(); } // Hvdc droop logs are in a subReport of Set Points - ModificationUtils.getInstance().reportModifications(setPointsReport, droopReports, "vscAngleDroop", "Angle droop active power control"); + ModificationUtils.getInstance().reportModifications(setPointsReport, droopReports, "network.modification.vscAngleDroop"); } } @@ -167,7 +167,7 @@ private void modifyVsc(@Nonnull Network network, @Nonnull HvdcLine hvdcLine, Vsc modifyConverterStation(ModificationUtils.getInstance().getVscConverterStation(network, hvdcLine.getConverterStation1().getId()), modificationInfos.getConverterStation1(), subReportNode); modifyConverterStation(ModificationUtils.getInstance().getVscConverterStation(network, hvdcLine.getConverterStation2().getId()), modificationInfos.getConverterStation2(), subReportNode); - PropertiesUtils.applyProperties(hvdcLine, subReportNode, modificationInfos.getProperties(), "VscProperties"); + PropertiesUtils.applyProperties(hvdcLine, subReportNode, modificationInfos.getProperties(), "network.modification.VscProperties"); } private static void characteristics(HvdcLine hvdcLine, VscModificationInfos modificationInfos, ReportNode subReportNode) { @@ -187,7 +187,7 @@ private static void characteristics(HvdcLine hvdcLine, VscModificationInfos modi characteristicsReportsContainer.add(ModificationUtils.getInstance().applyAndBuildModificationReport(hvdcLine::setMaxP, hvdcLine::getMaxP, modificationInfos.getMaxP(), "Power max")); } if (!characteristicsReportsContainer.isEmpty()) { - ModificationUtils.getInstance().reportModifications(subReportNode, characteristicsReportsContainer, VSC_CHARACTERISTICS, CHARACTERISTICS); + ModificationUtils.getInstance().reportModifications(subReportNode, characteristicsReportsContainer, VSC_CHARACTERISTICS); } } @@ -217,7 +217,7 @@ private static void operatorActivePowerLimit(HvdcLine hvdcLine, VscModificationI } } if (!reports.isEmpty()) { - ModificationUtils.getInstance().reportModifications(subReportNode, reports, "vscLimits", "Limits"); + ModificationUtils.getInstance().reportModifications(subReportNode, reports, "network.modification.vscLimits"); } } @@ -315,7 +315,7 @@ private void modifyConverterStation(VscConverterStation converterStation, Conver } ReportNode converterStationReportNode = subReportNode.newReportNode() - .withMessageTemplate("Converter Station", "Converter station ${id} modified") + .withMessageTemplate("network.modification.ConverterStation") .withUntypedValue("id", converterStation.getId()) .withSeverity(TypedValue.INFO_SEVERITY) .add(); @@ -334,7 +334,7 @@ private void modifyConverterStation(VscConverterStation converterStation, Conver if (!characteristicReports.isEmpty()) { ModificationUtils.getInstance().reportModifications(converterStationReportNode, - characteristicReports, "Characteristics", "Characteristics"); + characteristicReports, "network.modification.Characteristics"); } // set points @@ -355,7 +355,7 @@ private void modifyConverterStation(VscConverterStation converterStation, Conver } if (!setPointsReports.isEmpty()) { ModificationUtils.getInstance().reportModifications(converterStationReportNode, - setPointsReports, SETPOINTS, SETPOINTS); + setPointsReports, "network.modification.Setpoints"); } // limits diff --git a/src/main/java/org/gridsuite/modification/modifications/byfilter/AbstractModificationByAssignment.java b/src/main/java/org/gridsuite/modification/modifications/byfilter/AbstractModificationByAssignment.java index f9992c4..b4cbf8d 100644 --- a/src/main/java/org/gridsuite/modification/modifications/byfilter/AbstractModificationByAssignment.java +++ b/src/main/java/org/gridsuite/modification/modifications/byfilter/AbstractModificationByAssignment.java @@ -52,23 +52,24 @@ public abstract class AbstractModificationByAssignment extends AbstractModificat public static final String VALUE_KEY_MODIFICATION_TYPE_LABEL = "modificationTypeLabel"; public static final String VALUE_KEY_FILTERS_EACH_ASSIGNMENT = "filtersEachAssignment"; public static final String VALUE_KEY_ERROR_MESSAGE = "errorMessage"; - public static final String REPORT_KEY_RATIO_TAP_CHANGER_EQUIPMENT_MODIFIED_ERROR = "ratioTapChangerEquipmentModifiedError"; - public static final String REPORT_KEY_PHASE_TAP_CHANGER_EQUIPMENT_MODIFIED_ERROR = "phaseTapChangerEquipmentModifiedError"; - public static final String REPORT_KEY_EQUIPMENT_MODIFIED_ERROR = "equipmentModifiedError"; - public static final String REPORT_KEY_BY_FILTER_MODIFICATION_SOME = "byFilterModificationSome"; - public static final String REPORT_KEY_BY_FILTER_MODIFICATION_FAILED = "byFilterModificationFailed"; - public static final String REPORT_KEY_BY_FILTER_MODIFICATION_SUCCESS = "byFilterModificationSuccess"; - public static final String REPORT_KEY_NUMBER_OF_VALID_EQUIPMENT = "numberOfValidEquipment"; - public static final String REPORT_KEY_NOT_EDITED_EQUIPMENTS_FILTER = "notEditedEquipmentsFilter"; - public static final String REPORT_KEY_EDITED_FIELD_FILTER = "editedFieldFilter"; - public static final String REPORT_KEY_FILTER_EQUIPMENTS_NOT_FOUND = "filterEquipmentsNotFound"; - public static final String REPORT_KEY_EQUIPMENT_MODIFIED_REPORT = "equipmentModifiedReport"; - public static final String REPORT_KEY_EQUIPMENT_MODIFIED_REPORT_EXCEPTION = "equipmentModifiedReportException"; - public static final String REPORT_KEY_APPLIED_BY_FILTER_MODIFICATIONS = "appliedByFilterModifications"; - public static final String REPORT_KEY_APPLIED_ASSIGNMENT = "appliedAssignment"; - public static final String REPORT_KEY_BY_FILTER_MODIFICATION_ALL = "byFilterModificationAll"; - public static final String REPORT_KEY_BY_FILTER_MODIFICATION_NONE = "byFilterModificationNone"; - public static final String REPORT_KEY_BY_FILTER_MODIFICATION_NOT_FOUND = "byFilterModificationNotFound"; + public static final String REPORT_KEY_RATIO_TAP_CHANGER_EQUIPMENT_MODIFIED_ERROR = "network.modification.ratioTapChangerEquipmentModifiedError"; + public static final String REPORT_KEY_PHASE_TAP_CHANGER_EQUIPMENT_MODIFIED_ERROR = "network.modification.phaseTapChangerEquipmentModifiedError"; + public static final String REPORT_KEY_EQUIPMENT_MODIFIED_ERROR_ZERO = "network.modification.equipmentModifiedError.zero"; + public static final String REPORT_KEY_EQUIPMENT_MODIFIED_ERROR_NULL = "network.modification.equipmentModifiedError.null"; + public static final String REPORT_KEY_BY_FILTER_MODIFICATION_SOME = "network.modification.byFilterModificationSome"; + public static final String REPORT_KEY_BY_FILTER_MODIFICATION_FAILED = "network.modification.byFilterModificationFailed"; + public static final String REPORT_KEY_BY_FILTER_MODIFICATION_SUCCESS = "network.modification.byFilterModificationSuccess"; + public static final String REPORT_KEY_NUMBER_OF_VALID_EQUIPMENT = "network.modification.numberOfValidEquipment"; + public static final String REPORT_KEY_NOT_EDITED_EQUIPMENTS_FILTER = "network.modification.notEditedEquipmentsFilter"; + public static final String REPORT_KEY_EDITED_FIELD_FILTER = "network.modification.editedFieldFilter"; + public static final String REPORT_KEY_FILTER_EQUIPMENTS_NOT_FOUND = "network.modification.filterEquipmentsNotFound"; + public static final String REPORT_KEY_EQUIPMENT_MODIFIED_REPORT = "network.modification.equipmentModifiedReport"; + public static final String REPORT_KEY_EQUIPMENT_MODIFIED_REPORT_EXCEPTION = "network.modification.equipmentModifiedReportException"; + public static final String REPORT_KEY_APPLIED_BY_FILTER_MODIFICATIONS = "network.modification.appliedByFilterModifications"; + public static final String REPORT_KEY_APPLIED_ASSIGNMENT = "network.modification.appliedAssignment"; + public static final String REPORT_KEY_BY_FILTER_MODIFICATION_ALL = "network.modification.byFilterModificationAll"; + public static final String REPORT_KEY_BY_FILTER_MODIFICATION_NONE = "network.modification.byFilterModificationNone"; + public static final String REPORT_KEY_BY_FILTER_MODIFICATION_NOT_FOUND = "network.modification.byFilterModificationNotFound"; protected IFilterService filterService; protected int equipmentNotModifiedCount; @@ -143,44 +144,40 @@ public void apply(Network network, ReportNode subReportNode) { if (filterUuidEquipmentsMap != null) { ReportNode subReporter = subReportNode.newReportNode() - .withMessageTemplate(REPORT_KEY_APPLIED_BY_FILTER_MODIFICATIONS, "${" + VALUE_KEY_MODIFICATION_TYPE_LABEL + "}s on ${" + VALUE_KEY_EQUIPMENT_TYPE + "} type") - .withUntypedValue(VALUE_KEY_MODIFICATION_TYPE_LABEL, StringUtils.capitalize(getModificationTypeLabel())) - .withUntypedValue(VALUE_KEY_EQUIPMENT_TYPE, getEquipmentType().name()) - .add(); + .withMessageTemplate(REPORT_KEY_APPLIED_BY_FILTER_MODIFICATIONS) + .withUntypedValue(VALUE_KEY_MODIFICATION_TYPE_LABEL, StringUtils.capitalize(getModificationTypeLabel())) + .withUntypedValue(VALUE_KEY_EQUIPMENT_TYPE, getEquipmentType().name()) + .add(); // perform modifications getAssignmentInfosList().forEach(abstractAssignmentInfos -> { List reports = new ArrayList<>(); ReportNode eachAssignmentReporter = subReporter.newReportNode() - .withMessageTemplate(REPORT_KEY_APPLIED_ASSIGNMENT, "${" + VALUE_KEY_MODIFICATION_TYPE_LABEL + "} on filters : ${" + VALUE_KEY_FILTERS_EACH_ASSIGNMENT + "}") - .withUntypedValue(VALUE_KEY_MODIFICATION_TYPE_LABEL, StringUtils.capitalize(getModificationTypeLabel())) - .withUntypedValue(VALUE_KEY_FILTERS_EACH_ASSIGNMENT, abstractAssignmentInfos.getFilters().stream().map(FilterInfos::getName) - .collect(Collectors.joining(", "))) - .add(); + .withMessageTemplate(REPORT_KEY_APPLIED_ASSIGNMENT) + .withUntypedValue(VALUE_KEY_MODIFICATION_TYPE_LABEL, StringUtils.capitalize(getModificationTypeLabel())) + .withUntypedValue(VALUE_KEY_FILTERS_EACH_ASSIGNMENT, abstractAssignmentInfos.getFilters().stream().map(FilterInfos::getName) + .collect(Collectors.joining(", "))) + .add(); abstractAssignmentInfos.getFilters().forEach(filterInfos -> applyOnFilterEquipments(network, filterUuidEquipmentsMap, reports, abstractAssignmentInfos, filterInfos)); reports.forEach(report -> insertReportNode(eachAssignmentReporter, report)); }); // reporting if (equipmentNotModifiedCount == 0 && equipmentNotFoundCount == 0) { subReportNode.newReportNode() - .withMessageTemplate(REPORT_KEY_BY_FILTER_MODIFICATION_ALL, - "All equipments have been modified : ${" + VALUE_KEY_EQUIPMENT_COUNT + "} equipment(s)") - .withUntypedValue(VALUE_KEY_EQUIPMENT_COUNT, equipmentCount) - .withSeverity(TypedValue.INFO_SEVERITY) - .add(); + .withMessageTemplate(REPORT_KEY_BY_FILTER_MODIFICATION_ALL) + .withUntypedValue(VALUE_KEY_EQUIPMENT_COUNT, equipmentCount) + .withSeverity(TypedValue.INFO_SEVERITY) + .add(); } else { if (equipmentNotModifiedCount == equipmentCount) { - createReport(subReportNode, REPORT_KEY_BY_FILTER_MODIFICATION_NONE, - "No equipment have been modified", - Map.of(), TypedValue.ERROR_SEVERITY); + createReport(subReportNode, REPORT_KEY_BY_FILTER_MODIFICATION_NONE, Map.of(), TypedValue.ERROR_SEVERITY); } else { subReportNode.newReportNode() - .withMessageTemplate(REPORT_KEY_BY_FILTER_MODIFICATION_SOME, - "Some of the equipment have been modified : ${" + VALUE_KEY_NB_CHANGED + "} equipment(s) modified and ${" + VALUE_KEY_NB_UNCHANGED + "} equipment(s) not modified") - .withUntypedValue(VALUE_KEY_NB_CHANGED, equipmentCount - equipmentNotModifiedCount) - .withUntypedValue(VALUE_KEY_NB_UNCHANGED, equipmentNotModifiedCount + equipmentNotFoundCount) - .withSeverity(TypedValue.WARN_SEVERITY) - .add(); + .withMessageTemplate(REPORT_KEY_BY_FILTER_MODIFICATION_SOME) + .withUntypedValue(VALUE_KEY_NB_CHANGED, equipmentCount - equipmentNotModifiedCount) + .withUntypedValue(VALUE_KEY_NB_UNCHANGED, equipmentNotModifiedCount + equipmentNotFoundCount) + .withSeverity(TypedValue.WARN_SEVERITY) + .add(); } } } @@ -201,12 +198,12 @@ protected boolean isEquipmentEditable(Identifiable equipment, boolean isEditable = twoWindingsTransformer.getRatioTapChanger() != null; if (!isEditable) { equipmentsReport.add(ReportNode.newRootReportNode() - .withMessageTemplate(REPORT_KEY_RATIO_TAP_CHANGER_EQUIPMENT_MODIFIED_ERROR + equipmentsReport.size(), - " Cannot modify field ${" + VALUE_KEY_FIELD_NAME + "} of equipment ${" + VALUE_KEY_EQUIPMENT_NAME + "} : Ratio tab changer is null") - .withUntypedValue(VALUE_KEY_FIELD_NAME, editedField.name()) - .withUntypedValue(VALUE_KEY_EQUIPMENT_NAME, equipment.getId()) - .withSeverity(TypedValue.TRACE_SEVERITY) - .build()); + .withAllResourceBundlesFromClasspath() + .withMessageTemplate(REPORT_KEY_RATIO_TAP_CHANGER_EQUIPMENT_MODIFIED_ERROR) + .withUntypedValue(VALUE_KEY_FIELD_NAME, editedField.name()) + .withUntypedValue(VALUE_KEY_EQUIPMENT_NAME, equipment.getId()) + .withSeverity(TypedValue.TRACE_SEVERITY) + .build()); } yield isEditable; } @@ -214,12 +211,12 @@ protected boolean isEquipmentEditable(Identifiable equipment, boolean isEditable = twoWindingsTransformer.getPhaseTapChanger() != null; if (!isEditable) { equipmentsReport.add(ReportNode.newRootReportNode() - .withMessageTemplate(REPORT_KEY_PHASE_TAP_CHANGER_EQUIPMENT_MODIFIED_ERROR + equipmentsReport.size(), - " Cannot modify field ${" + VALUE_KEY_FIELD_NAME + "} of equipment ${" + VALUE_KEY_EQUIPMENT_NAME + "} : Phase tab changer is null") - .withUntypedValue(VALUE_KEY_FIELD_NAME, editedField.name()) - .withUntypedValue(VALUE_KEY_EQUIPMENT_NAME, equipment.getId()) - .withSeverity(TypedValue.TRACE_SEVERITY) - .build()); + .withAllResourceBundlesFromClasspath() + .withMessageTemplate(REPORT_KEY_PHASE_TAP_CHANGER_EQUIPMENT_MODIFIED_ERROR) + .withUntypedValue(VALUE_KEY_FIELD_NAME, editedField.name()) + .withUntypedValue(VALUE_KEY_EQUIPMENT_NAME, equipment.getId()) + .withSeverity(TypedValue.TRACE_SEVERITY) + .build()); } yield isEditable; } @@ -233,56 +230,59 @@ private void createAssignmentReports(List reports, AbstractAssignmen FilterInfos filterInfos, FilterEquipments filterEquipments, List notEditableEquipments) { if (notEditableEquipments.size() == filterEquipments.getIdentifiableAttributes().size()) { reports.add(ReportNode.newRootReportNode() - .withMessageTemplate(REPORT_KEY_BY_FILTER_MODIFICATION_FAILED, - "No equipment(s) have been modified on filter ${" + VALUE_KEY_FILTER_NAME + "}") - .withUntypedValue(VALUE_KEY_FILTER_NAME, filterInfos.getName()) - .withSeverity(TypedValue.WARN_SEVERITY) - .build()); + .withAllResourceBundlesFromClasspath() + .withMessageTemplate(REPORT_KEY_BY_FILTER_MODIFICATION_FAILED) + .withUntypedValue(VALUE_KEY_FILTER_NAME, filterInfos.getName()) + .withSeverity(TypedValue.WARN_SEVERITY) + .build()); } else { reports.add(ReportNode.newRootReportNode() - .withMessageTemplate(REPORT_KEY_BY_FILTER_MODIFICATION_SUCCESS, - "Successful application of ${" + VALUE_KEY_MODIFICATION_TYPE_LABEL + "} on filter ${" + VALUE_KEY_FILTER_NAME + "}") - .withUntypedValue(VALUE_KEY_MODIFICATION_TYPE_LABEL, getModificationTypeLabel()) - .withUntypedValue(VALUE_KEY_FILTER_NAME, filterInfos.getName()) - .withSeverity(TypedValue.INFO_SEVERITY) - .build()); + .withAllResourceBundlesFromClasspath() + .withMessageTemplate(REPORT_KEY_BY_FILTER_MODIFICATION_SUCCESS) + .withUntypedValue(VALUE_KEY_MODIFICATION_TYPE_LABEL, getModificationTypeLabel()) + .withUntypedValue(VALUE_KEY_FILTER_NAME, filterInfos.getName()) + .withSeverity(TypedValue.INFO_SEVERITY) + .build()); reports.add(ReportNode.newRootReportNode() - .withMessageTemplate(REPORT_KEY_NUMBER_OF_VALID_EQUIPMENT, " Number of equipment modified : ${" + VALUE_KEY_NB_CHANGED + "}") - .withUntypedValue(VALUE_KEY_NB_CHANGED, filterEquipments.getIdentifiableAttributes().size() - notEditableEquipments.size()) - .withSeverity(TypedValue.INFO_SEVERITY) - .build()); + .withAllResourceBundlesFromClasspath() + .withMessageTemplate(REPORT_KEY_NUMBER_OF_VALID_EQUIPMENT) + .withUntypedValue(VALUE_KEY_NB_CHANGED, filterEquipments.getIdentifiableAttributes().size() - notEditableEquipments.size()) + .withSeverity(TypedValue.INFO_SEVERITY) + .build()); if (!CollectionUtils.isEmpty(notEditableEquipments)) { reports.add(ReportNode.newRootReportNode() - .withMessageTemplate(REPORT_KEY_NOT_EDITED_EQUIPMENTS_FILTER, - " ${" + VALUE_KEY_NB_UNCHANGED + "} equipment(s) were not modified") - .withUntypedValue(VALUE_KEY_NB_UNCHANGED, notEditableEquipments.size()) - .withSeverity(TypedValue.WARN_SEVERITY) - .build()); + .withAllResourceBundlesFromClasspath() + .withMessageTemplate(REPORT_KEY_NOT_EDITED_EQUIPMENTS_FILTER) + .withUntypedValue(VALUE_KEY_NB_UNCHANGED, notEditableEquipments.size()) + .withSeverity(TypedValue.WARN_SEVERITY) + .build()); } } reports.add(ReportNode.newRootReportNode() - .withMessageTemplate(REPORT_KEY_EDITED_FIELD_FILTER, " Edited field : ${" + VALUE_KEY_FIELD_NAME + "}") - .withUntypedValue(VALUE_KEY_FIELD_NAME, getEditedFieldLabel(abstractAssignmentInfos)) - .withSeverity(TypedValue.INFO_SEVERITY) - .build()); + .withAllResourceBundlesFromClasspath() + .withMessageTemplate(REPORT_KEY_EDITED_FIELD_FILTER) + .withUntypedValue(VALUE_KEY_FIELD_NAME, getEditedFieldLabel(abstractAssignmentInfos)) + .withSeverity(TypedValue.INFO_SEVERITY) + .build()); if (!CollectionUtils.isEmpty(filterEquipments.getNotFoundEquipments())) { String equipmentIds = String.join(", ", filterEquipments.getNotFoundEquipments()); reports.add(ReportNode.newRootReportNode() - .withMessageTemplate(REPORT_KEY_FILTER_EQUIPMENTS_NOT_FOUND, " Equipment not found : ${" + VALUE_KEY_EQUIPMENT_IDS + "}") - .withUntypedValue(VALUE_KEY_EQUIPMENT_IDS, equipmentIds) - .withSeverity(TypedValue.WARN_SEVERITY) - .build()); + .withAllResourceBundlesFromClasspath() + .withMessageTemplate(REPORT_KEY_FILTER_EQUIPMENTS_NOT_FOUND) + .withUntypedValue(VALUE_KEY_EQUIPMENT_IDS, equipmentIds) + .withSeverity(TypedValue.WARN_SEVERITY) + .build()); } } private void applyModification(Identifiable equipment, - AbstractAssignmentInfos abstractAssignmentInfos, - List reports, - List notEditableEquipments) { + AbstractAssignmentInfos abstractAssignmentInfos, + List reports, + List notEditableEquipments) { // check pre-conditions if (!preCheckValue(equipment, abstractAssignmentInfos, reports, notEditableEquipments)) { @@ -294,49 +294,49 @@ private void applyModification(Identifiable equipment, final String oldValue = getOldValue(equipment, abstractAssignmentInfos); final String newValue = applyValue(equipment, abstractAssignmentInfos); reports.add(ReportNode.newRootReportNode() - .withMessageTemplate(REPORT_KEY_EQUIPMENT_MODIFIED_REPORT, - " ${" + VALUE_KEY_EQUIPMENT_TYPE + "} id : ${" + VALUE_KEY_EQUIPMENT_NAME + - "}, ${" + VALUE_KEY_FIELD_NAME + "} : ${" + VALUE_KEY_OLD_VALUE + "} → ${" + VALUE_KEY_NEW_VALUE + "}") - .withUntypedValue(VALUE_KEY_EQUIPMENT_TYPE, equipment.getType().name()) - .withUntypedValue(VALUE_KEY_EQUIPMENT_NAME, equipment.getId()) - .withUntypedValue(VALUE_KEY_FIELD_NAME, getEditedFieldLabel(abstractAssignmentInfos)) - .withUntypedValue(VALUE_KEY_OLD_VALUE, oldValue == null ? NO_VALUE : oldValue) - .withUntypedValue(VALUE_KEY_NEW_VALUE, newValue) - .withSeverity(TypedValue.TRACE_SEVERITY) - .build()); + .withAllResourceBundlesFromClasspath() + .withMessageTemplate(REPORT_KEY_EQUIPMENT_MODIFIED_REPORT) + .withUntypedValue(VALUE_KEY_EQUIPMENT_TYPE, equipment.getType().name()) + .withUntypedValue(VALUE_KEY_EQUIPMENT_NAME, equipment.getId()) + .withUntypedValue(VALUE_KEY_FIELD_NAME, getEditedFieldLabel(abstractAssignmentInfos)) + .withUntypedValue(VALUE_KEY_OLD_VALUE, oldValue == null ? NO_VALUE : oldValue) + .withUntypedValue(VALUE_KEY_NEW_VALUE, newValue) + .withSeverity(TypedValue.TRACE_SEVERITY) + .build()); } catch (Exception e) { notEditableEquipments.add(equipment.getId()); equipmentNotModifiedCount += 1; reports.add(ReportNode.newRootReportNode() - .withMessageTemplate(REPORT_KEY_EQUIPMENT_MODIFIED_REPORT_EXCEPTION, - " Cannot modify equipment ${" + VALUE_KEY_EQUIPMENT_NAME + "} : ${" + VALUE_KEY_ERROR_MESSAGE + "}") - .withUntypedValue(VALUE_KEY_EQUIPMENT_NAME, equipment.getId()) - .withUntypedValue(VALUE_KEY_ERROR_MESSAGE, e.getMessage()) - .withSeverity(TypedValue.WARN_SEVERITY) - .build()); + .withAllResourceBundlesFromClasspath() + .withMessageTemplate(REPORT_KEY_EQUIPMENT_MODIFIED_REPORT_EXCEPTION) + .withUntypedValue(VALUE_KEY_EQUIPMENT_NAME, equipment.getId()) + .withUntypedValue(VALUE_KEY_ERROR_MESSAGE, e.getMessage()) + .withSeverity(TypedValue.WARN_SEVERITY) + .build()); } } private Map getFilters() { return getAssignmentInfosList().stream() - .flatMap(v -> v.getFilters().stream()) - .filter(distinctByKey(FilterInfos::getId)) - .collect(Collectors.toMap(FilterInfos::getId, FilterInfos::getName)); + .flatMap(v -> v.getFilters().stream()) + .filter(distinctByKey(FilterInfos::getId)) + .collect(Collectors.toMap(FilterInfos::getId, FilterInfos::getName)); } private void applyOnFilterEquipments(Network network, - Map filterUuidEquipmentsMap, - List reports, - AbstractAssignmentInfos abstractAssignmentInfos, - FilterInfos filterInfos) { + Map filterUuidEquipmentsMap, + List reports, + AbstractAssignmentInfos abstractAssignmentInfos, + FilterInfos filterInfos) { FilterEquipments filterEquipments = filterUuidEquipmentsMap.get(filterInfos.getId()); if (CollectionUtils.isEmpty(filterEquipments.getIdentifiableAttributes())) { reports.add(ReportNode.newRootReportNode() - .withMessageTemplate(REPORT_KEY_BY_FILTER_MODIFICATION_NOT_FOUND, "No equipments were found for filter ${" + VALUE_KEY_FILTER_NAME + "}") - .withUntypedValue(VALUE_KEY_FILTER_NAME, filterInfos.getName()) - .withSeverity(TypedValue.WARN_SEVERITY) - .build()); + .withAllResourceBundlesFromClasspath() + .withMessageTemplate(REPORT_KEY_BY_FILTER_MODIFICATION_NOT_FOUND) + .withUntypedValue(VALUE_KEY_FILTER_NAME, filterInfos.getName()) + .withSeverity(TypedValue.WARN_SEVERITY) + .build()); } else { equipmentCount += filterEquipments.getIdentifiableAttributes().size(); if (!CollectionUtils.isEmpty(filterEquipments.getNotFoundEquipments())) { @@ -345,17 +345,17 @@ private void applyOnFilterEquipments(Network network, List notEditableEquipments = new ArrayList<>(); List equipmentsReport = new ArrayList<>(); filterEquipments.getIdentifiableAttributes() - .stream() - .map(attributes -> network.getIdentifiable(attributes.getId())) - .filter(equipment -> { - boolean isEditableEquipment = isEquipmentEditable(equipment, abstractAssignmentInfos, equipmentsReport); - if (!isEditableEquipment) { - notEditableEquipments.add(equipment.getId()); - equipmentNotModifiedCount += 1; - } - return isEditableEquipment; - }) - .forEach(equipment -> applyModification(equipment, abstractAssignmentInfos, equipmentsReport, notEditableEquipments)); + .stream() + .map(attributes -> network.getIdentifiable(attributes.getId())) + .filter(equipment -> { + boolean isEditableEquipment = isEquipmentEditable(equipment, abstractAssignmentInfos, equipmentsReport); + if (!isEditableEquipment) { + notEditableEquipments.add(equipment.getId()); + equipmentNotModifiedCount += 1; + } + return isEditableEquipment; + }) + .forEach(equipment -> applyModification(equipment, abstractAssignmentInfos, equipmentsReport, notEditableEquipments)); createAssignmentReports(reports, abstractAssignmentInfos, filterInfos, filterEquipments, notEditableEquipments); diff --git a/src/main/java/org/gridsuite/modification/modifications/byfilter/ByFormulaModification.java b/src/main/java/org/gridsuite/modification/modifications/byfilter/ByFormulaModification.java index 192a6e8..cebc9b8 100644 --- a/src/main/java/org/gridsuite/modification/modifications/byfilter/ByFormulaModification.java +++ b/src/main/java/org/gridsuite/modification/modifications/byfilter/ByFormulaModification.java @@ -71,8 +71,8 @@ protected boolean preCheckValue(Identifiable equipment, AbstractAssignmentInf equipmentNotModifiedCount += 1; notEditableEquipments.add(equipment.getId()); reports.add(ReportNode.newRootReportNode() - .withMessageTemplate(REPORT_KEY_EQUIPMENT_MODIFIED_ERROR, " Cannot modify equipment ${" + - VALUE_KEY_EQUIPMENT_NAME + "} : At least one of the value or referenced field is null") + .withAllResourceBundlesFromClasspath() + .withMessageTemplate(REPORT_KEY_EQUIPMENT_MODIFIED_ERROR_NULL) .withUntypedValue(VALUE_KEY_EQUIPMENT_NAME, equipment.getId()) .withSeverity(TypedValue.TRACE_SEVERITY) .build()); @@ -83,8 +83,8 @@ protected boolean preCheckValue(Identifiable equipment, AbstractAssignmentInf equipmentNotModifiedCount += 1; notEditableEquipments.add(equipment.getId()); reports.add(ReportNode.newRootReportNode() - .withMessageTemplate(REPORT_KEY_EQUIPMENT_MODIFIED_ERROR, " Cannot modify equipment ${" + - VALUE_KEY_EQUIPMENT_NAME + "} : The value or referenced field of the second operand in the division operator is zero") + .withAllResourceBundlesFromClasspath() + .withMessageTemplate(REPORT_KEY_EQUIPMENT_MODIFIED_ERROR_ZERO) .withUntypedValue(VALUE_KEY_EQUIPMENT_NAME, equipment.getId()) .withSeverity(TypedValue.TRACE_SEVERITY) .build()); diff --git a/src/main/java/org/gridsuite/modification/report/NetworkModificationReportResourceBundle.java b/src/main/java/org/gridsuite/modification/report/NetworkModificationReportResourceBundle.java new file mode 100644 index 0000000..6cf0bbd --- /dev/null +++ b/src/main/java/org/gridsuite/modification/report/NetworkModificationReportResourceBundle.java @@ -0,0 +1,24 @@ +/** + * Copyright (c) 2025, 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/. + * SPDX-License-Identifier: MPL-2.0 + */ +package org.gridsuite.modification.report; + +import com.google.auto.service.AutoService; +import com.powsybl.commons.report.ReportResourceBundle; + +/** + * @author Charly Boutier {@literal } + */ +@AutoService(ReportResourceBundle.class) +public final class NetworkModificationReportResourceBundle implements ReportResourceBundle { + + public static final String BASE_NAME = "org.gridsuite.modification.reports"; + + public String getBaseName() { + return BASE_NAME; + } +} diff --git a/src/main/java/org/gridsuite/modification/utils/ModificationUtils.java b/src/main/java/org/gridsuite/modification/utils/ModificationUtils.java index 3e853b2..690b2bc 100644 --- a/src/main/java/org/gridsuite/modification/utils/ModificationUtils.java +++ b/src/main/java/org/gridsuite/modification/utils/ModificationUtils.java @@ -6,10 +6,7 @@ */ package org.gridsuite.modification.utils; -import com.powsybl.commons.report.ReportConstants; -import com.powsybl.commons.report.ReportNode; -import com.powsybl.commons.report.ReportNodeAdder; -import com.powsybl.commons.report.TypedValue; +import com.powsybl.commons.report.*; import com.powsybl.iidm.modification.topology.*; import com.powsybl.iidm.network.*; import com.powsybl.iidm.network.extensions.*; @@ -47,14 +44,13 @@ public final class ModificationUtils { public static final String BUS_BAR_SECTION_ID = "busbarSectionId"; public static final String DOES_NOT_EXIST_IN_NETWORK = " does not exist in network"; - public static final String EQUIPMENT_DISCONNECTED = "equipmentDisconnected"; + public static final String EQUIPMENT_DISCONNECTED = "network.modification.equipmentDisconnected"; public static final String NO_VALUE = "No value"; - public static final String LIMITS = "Limits"; - public static final String REACTIVE_LIMITS = "Reactive limits"; - private static final String SETPOINTS = "Setpoints"; + public static final String LIMITS = "network.modification.Limits"; + public static final String REACTIVE_LIMITS = "network.modification.ReactiveLimits"; + private static final String SETPOINTS = "network.modification.Setpoints"; private static final String MIN_REACTIVE_POWER_FIELDNAME = "Minimum reactive power"; private static final String MAX_REACTIVE_POWER_FIELDNAME = "Maximum reactive power"; - private static final String CONNECTIVITY = "Connectivity"; public static final String CONNECTION_NAME_FIELD_NAME = "Connection name"; public static final String CONNECTION_DIRECTION_FIELD_NAME = "Connection direction"; public static final String CONNECTION_POSITION_FIELD_NAME = "Connection position"; @@ -325,7 +321,7 @@ private boolean checkBbs(Network network, String busbarSectionId1, String busbar Identifiable busOrBbs2 = network.getIdentifiable(busbarSectionId2); if (busOrBbs1 == null) { subReportNode.newReportNode() - .withMessageTemplate("notFoundBurOrBusbarSection", "Bus or busbar section ID ${busbarSectionId} not found. Coupler was not created.") + .withMessageTemplate("network.modification.notFoundBurOrBusbarSection") .withUntypedValue(BUS_BAR_SECTION_ID, busbarSectionId1) .withSeverity(TypedValue.ERROR_SEVERITY) .add(); @@ -333,7 +329,7 @@ private boolean checkBbs(Network network, String busbarSectionId1, String busbar } if (busOrBbs2 == null) { subReportNode.newReportNode() - .withMessageTemplate("notFoundBurOrBusbarSection", "Bus or busbar section ID ${busbarSectionId} not found. Coupler was not created.") + .withMessageTemplate("network.modification.notFoundBurOrBusbarSection") .withUntypedValue(BUS_BAR_SECTION_ID, busbarSectionId2) .withSeverity(TypedValue.ERROR_SEVERITY) .add(); @@ -351,7 +347,7 @@ public void createSubstation(SubstationCreationInfos substationCreationInfos, .add(); subReportNode.newReportNode() - .withMessageTemplate("substationCreated", "New substation with id=${id} created") + .withMessageTemplate("network.modification.substationCreated") .withUntypedValue("id", substationCreationInfos.getEquipmentId()) .withSeverity(TypedValue.INFO_SEVERITY) .add(); @@ -376,7 +372,7 @@ public void createVoltageLevel(VoltageLevelCreationInfos voltageLevelCreationInf substationId = substationCreation.getEquipmentId(); createSubstation(substationCreation, subReportNode, network); substation = network.getSubstation(substationId); - PropertiesUtils.applyProperties(substation, subReportNode, substationCreation.getProperties(), "SubstationProperties"); + PropertiesUtils.applyProperties(substation, subReportNode, substationCreation.getProperties(), "network.modification.SubstationProperties"); } else { substation = network.getSubstation(substationId); } @@ -431,7 +427,7 @@ public void createVoltageLevel(VoltageLevelCreationInfos voltageLevelCreationInf }); subReportNode.newReportNode() - .withMessageTemplate("voltageLevelCreated", "New voltage level with id=${id} created") + .withMessageTemplate("network.modification.voltageLevelCreated") .withUntypedValue("id", voltageLevelCreationInfos.getEquipmentId()) .withSeverity(TypedValue.INFO_SEVERITY) .add(); @@ -501,9 +497,9 @@ private void setBranchAdderNodeBreaker(BranchAdder branchAdder, VoltageLev } } - public static void createReport(ReportNode reportNode, String reporterKey, String defaultMessage, Map values, TypedValue errorSeverity) { + public static void createReport(ReportNode reportNode, String reporterKey, Map values, TypedValue errorSeverity) { ReportNodeAdder adder = reportNode.newReportNode() - .withMessageTemplate(reporterKey, defaultMessage) + .withMessageTemplate(reporterKey) .withSeverity(errorSeverity); for (Map.Entry valueEntry : values.entrySet()) { @@ -531,34 +527,23 @@ public ReportNode applyElementaryModificationsAndReturnReport(Consumer se return null; } - public ReportNode applyElementaryModificationsAndReturnReport(Consumer setter, Supplier getter, - AttributeModification modification, String fieldName, int indentationLevel) { - if (modification != null) { - T oldValue = getter.get(); - T newValue = modification.applyModification(oldValue); - setter.accept(newValue); - - return buildModificationReport(oldValue, newValue, fieldName, indentationLevel); - } - return null; - } - public ReportNode createEnabledDisabledReport(String key, boolean enabled) { return ReportNode.newRootReportNode() - .withMessageTemplate(key, " ${status}") + .withAllResourceBundlesFromClasspath() + .withMessageTemplate(key) .withUntypedValue("status", enabled ? "Enabled" : "Disabled") .withSeverity(TypedValue.INFO_SEVERITY) .build(); } - public ReportNode reportModifications(ReportNode reportNode, List reports, String subReportNodeKey, String subReportNodeMessage) { + public ReportNode reportModifications(ReportNode reportNode, List reports, String subReportNodeKey) { List validReports = reports.stream().filter(Objects::nonNull).toList(); ReportNode subReportNode = null; if (!validReports.isEmpty() && reportNode != null) { // new child report node - subReportNode = reportNode.newReportNode().withMessageTemplate(subReportNodeKey, subReportNodeMessage).add(); + subReportNode = reportNode.newReportNode().withMessageTemplate(subReportNodeKey).add(); for (ReportNode report : validReports) { - ReportNodeAdder reportNodeAdder = subReportNode.newReportNode().withMessageTemplate(report.getMessageKey(), report.getMessageTemplate()).withSeverity(TypedValue.INFO_SEVERITY); + ReportNodeAdder reportNodeAdder = subReportNode.newReportNode().withMessageTemplate(report.getMessageKey()).withSeverity(TypedValue.INFO_SEVERITY); for (Map.Entry valueEntry : report.getValues().entrySet()) { reportNodeAdder.withUntypedValue(valueEntry.getKey(), valueEntry.getValue().toString()); } @@ -587,25 +572,22 @@ public ReportNode applyAndBuildModificationReport(Consumer setter, Suppli T oldValue = getter.get(); T newValue = modification.applyModification(oldValue); setter.accept(newValue); - return buildModificationReport(oldValue, newValue, fieldName, 1, TypedValue.INFO_SEVERITY); + return buildModificationReport(oldValue, newValue, fieldName, TypedValue.INFO_SEVERITY); } public ReportNode buildModificationReport(T oldValue, T newValue, String fieldName) { - return buildModificationReport(oldValue, newValue, fieldName, 1, TypedValue.INFO_SEVERITY); - } - - public ReportNode buildModificationReport(T oldValue, T newValue, String fieldName, int indentationLevel) { - return buildModificationReport(oldValue, newValue, fieldName, indentationLevel, TypedValue.INFO_SEVERITY); + return buildModificationReport(oldValue, newValue, fieldName, TypedValue.INFO_SEVERITY); } - public static ReportNode buildModificationReport(T oldValue, T newValue, String fieldName, int indentationLevel, TypedValue severity) { + public static ReportNode buildModificationReport(T oldValue, T newValue, String fieldName, TypedValue severity) { final String oldValueString = (oldValue == null || oldValue instanceof Double oldDouble && Double.isNaN(oldDouble)) ? NO_VALUE : oldValue.toString(); final String newValueString = (newValue == null || newValue instanceof Double newDouble && Double.isNaN(newDouble)) ? NO_VALUE : newValue.toString(); - final String indentation = "\t".repeat(indentationLevel); return ReportNode.newRootReportNode() - .withMessageTemplate("modification-indent" + indentationLevel, indentation + "${fieldName} : ${oldValue} → ${newValue}") + .withAllResourceBundlesFromClasspath() + .withMessageTemplate("network.modification.fieldModification") + .withUntypedValue("arrow", "→") // Workaround to use non-ISO-8859-1 characters in the internationalization file .withUntypedValue("fieldName", fieldName) .withUntypedValue("oldValue", oldValueString) .withUntypedValue("newValue", newValueString) @@ -666,7 +648,7 @@ public void disconnectCreatedInjection(InjectionCreationInfos modificationInfos, if (!modificationInfos.isTerminalConnected()) { injection.getTerminal().disconnect(); subReportNode.newReportNode() - .withMessageTemplate(EQUIPMENT_DISCONNECTED, "Equipment with id=${id} disconnected") + .withMessageTemplate(EQUIPMENT_DISCONNECTED) .withUntypedValue("id", modificationInfos.getEquipmentId()) .withSeverity(TypedValue.INFO_SEVERITY) .add(); @@ -682,7 +664,7 @@ public ReportNode modifyInjectionConnectivityAttributes(ConnectablePosition c processConnectivityPosition(connectablePosition, connectablePositionAdder, modificationInfos, injection.getNetwork(), reports); modifyConnection(modificationInfos.getTerminalConnected(), injection, injection.getTerminal(), reports); - return reportModifications(connectivityReports, reports, "ConnectivityModified", CONNECTIVITY); + return reportModifications(connectivityReports, reports, "network.modification.ConnectivityModified"); } public ReportNode modifyBranchConnectivityAttributes(ConnectablePosition connectablePosition, @@ -695,7 +677,7 @@ public ReportNode modifyBranchConnectivityAttributes(ConnectablePosition conn modifyConnection(modificationInfos.getTerminal1Connected(), branch, branch.getTerminal1(), reports, ThreeSides.ONE); modifyConnection(modificationInfos.getTerminal2Connected(), branch, branch.getTerminal2(), reports, ThreeSides.TWO); - return reportModifications(connectivityReports, reports, "ConnectivityModified", CONNECTIVITY); + return reportModifications(connectivityReports, reports, "network.modification.ConnectivityModified"); } private void processConnectivityPosition(ConnectablePosition connectablePosition, @@ -977,17 +959,19 @@ private void validateConnectionChange(boolean success, Identifiable equipment throw new NetworkModificationException(equipment instanceof Branch ? BRANCH_MODIFICATION_ERROR : INJECTION_MODIFICATION_ERROR, String.format("Could not %s equipment '%s'", action, equipment.getId())); } - String equipmentMessage = "Equipment with id=${id} %sed"; - String reportKey = "equipment" + capitalize(action); + + String reportKey = "network.modification.equipment" + capitalize(action) + (side != null ? ".side" : ""); + ReportNodeBuilder builder = ReportNode.newRootReportNode() + .withAllResourceBundlesFromClasspath() + .withMessageTemplate(reportKey) + .withUntypedValue("id", equipment.getId()) + .withSeverity(TypedValue.INFO_SEVERITY); + if (side != null) { - equipmentMessage += String.format(" on side %d", side.getNum()); - reportKey += String.format("side%d", side.getNum()); + builder.withUntypedValue("side", side.getNum()); } - reports.add(ReportNode.newRootReportNode() - .withMessageTemplate(reportKey, String.format(equipmentMessage, action)) - .withUntypedValue("id", equipment.getId()) - .withSeverity(TypedValue.INFO_SEVERITY) - .build()); + + reports.add(builder.build()); } private String capitalize(String input) { @@ -999,7 +983,7 @@ public void disconnectBranch(BranchCreationInfos modificationInfos, Branch br if (!modificationInfos.isConnected1()) { branch.getTerminal1().disconnect(); subReportNode.newReportNode() - .withMessageTemplate("terminal1Disconnected", "Equipment with id=${id} disconnected on side 1") + .withMessageTemplate("network.modification.terminal1Disconnected") .withUntypedValue("id", modificationInfos.getEquipmentId()) .withSeverity(TypedValue.INFO_SEVERITY) .add(); @@ -1007,7 +991,7 @@ public void disconnectBranch(BranchCreationInfos modificationInfos, Branch br if (!modificationInfos.isConnected2()) { branch.getTerminal2().disconnect(); subReportNode.newReportNode() - .withMessageTemplate("terminal2Disconnected", "Equipment with id=${id} disconnected on side 2") + .withMessageTemplate("network.modification.terminal2Disconnected") .withUntypedValue("id", modificationInfos.getEquipmentId()) .withSeverity(TypedValue.INFO_SEVERITY) .add(); @@ -1059,7 +1043,9 @@ public void setCurrentLimitsOnASide(List opLimitGro ? branch.newOperationalLimitsGroup1(opLimitsGroup.getId()) : branch.newOperationalLimitsGroup2(opLimitsGroup.getId()); if (opLimitsGroup.getId() != null) { - limitSetsOnSideReportNodes.add(ReportNode.newRootReportNode().withMessageTemplate("limitSetAdded", " ${name} added") + limitSetsOnSideReportNodes.add(ReportNode.newRootReportNode() + .withAllResourceBundlesFromClasspath() + .withMessageTemplate("network.modification.limitSetAdded") .withUntypedValue("name", opLimitsGroup.getId()) .withSeverity(TypedValue.INFO_SEVERITY) .build()); @@ -1084,15 +1070,15 @@ public void setCurrentLimitsOnASide(List opLimitGro } if (!limitSetsOnSideReportNodes.isEmpty()) { ModificationUtils.getInstance().reportModifications(limitsReporter, limitSetsOnSideReportNodes, - "LimitsSetsOnSide" + side.getNum(), "Limit Sets Side " + side.getNum() - ); + "network.modification.LimitsSetsOnSide" + side.getNum()); } } public ReportNode buildCreationReport(T value, String fieldName) { String newValueString = value == null ? NO_VALUE : value.toString(); return ReportNode.newRootReportNode() - .withMessageTemplate("Creation" + fieldName, " ${fieldName} : ${value}") + .withAllResourceBundlesFromClasspath() + .withMessageTemplate("network.modification.creation.fieldName") .withUntypedValue("fieldName", fieldName) .withUntypedValue("value", newValueString) .withSeverity(TypedValue.INFO_SEVERITY) @@ -1139,13 +1125,13 @@ public void modifyReactiveCapabilityCurvePoints(Collection activePowerControl, @@ -1315,9 +1301,9 @@ public ReportNode modifyActivePowerControlAttributes(ActivePowerControl activ if (subReportNode != null) { ReportNode subReportNodeSetpoints2 = subReporterSetpoints; if (subReporterSetpoints == null && !reports.isEmpty()) { - subReportNodeSetpoints2 = subReportNode.newReportNode().withMessageTemplate(SETPOINTS, SETPOINTS).add(); + subReportNodeSetpoints2 = subReportNode.newReportNode().withMessageTemplate(SETPOINTS).add(); } - reportModifications(subReportNodeSetpoints2, reports, "activePowerControlModified", "Active power control"); + reportModifications(subReportNodeSetpoints2, reports, "network.modification.activePowerControlModified"); return subReportNodeSetpoints2; } return null; @@ -1548,9 +1534,9 @@ public void createMinMaxReactiveLimits(ReactiveLimitsHolderInfos batteryCreation batteryCreationInfos.getMaxQ(), MAX_REACTIVE_POWER_FIELDNAME)); - ReportNode subReporterReactiveLimits = subReportNode.newReportNode().withMessageTemplate(REACTIVE_LIMITS, REACTIVE_LIMITS).add(); + ReportNode subReporterReactiveLimits = subReportNode.newReportNode().withMessageTemplate(REACTIVE_LIMITS).add(); - ModificationUtils.getInstance().reportModifications(subReporterReactiveLimits, minMaxReactiveLimitsReports, "minMaxReactiveLimitsCreated", "By range"); + ModificationUtils.getInstance().reportModifications(subReporterReactiveLimits, minMaxReactiveLimitsReports, "network.modification.minMaxReactiveLimitsCreated"); } } @@ -1574,8 +1560,8 @@ public void createReactiveCapabilityCurve(ReactiveLimitsHolderInfos creationInfo createReactiveCapabilityCurvePoint(adder, newPoint, pointsReports, fieldSuffix); }); adder.add(); - ReportNode subReporterReactiveLimits = subReportNode.newReportNode().withMessageTemplate(REACTIVE_LIMITS, REACTIVE_LIMITS).add(); - ModificationUtils.getInstance().reportModifications(subReporterReactiveLimits, pointsReports, "curveReactiveLimitsCreated", "By diagram"); + ReportNode subReporterReactiveLimits = subReportNode.newReportNode().withMessageTemplate(REACTIVE_LIMITS).add(); + ModificationUtils.getInstance().reportModifications(subReporterReactiveLimits, pointsReports, "network.modification.curveReactiveLimitsCreated"); } private void createReactiveCapabilityCurvePoint(ReactiveCapabilityCurveAdder adder, @@ -1599,8 +1585,7 @@ public boolean isValidFilter(ReportNode subReportNode, .allMatch(filterEquipments -> CollectionUtils.isEmpty(filterEquipments.getIdentifiableAttributes())); if (noValidEquipmentId) { - String errorMsg = "${errorType}: There is no valid equipment ID among the provided filter(s)"; - createReport(subReportNode, "invalidFilters", errorMsg, Map.of("errorType", errorType), TypedValue.ERROR_SEVERITY); + createReport(subReportNode, "network.modification.invalidFilters", Map.of("errorType", errorType), TypedValue.ERROR_SEVERITY); return false; } @@ -1610,10 +1595,7 @@ public boolean isValidFilter(ReportNode subReportNode, public static Set getIdentifiableAttributes(Map exportFilters, List filterInfos, ReportNode subReportNode) { filterInfos.stream() .filter(f -> !exportFilters.containsKey(f.getId())) - .forEach(f -> createReport(subReportNode, - "filterNotFound", - "Cannot find the following filter: ${name}", - Map.of("name", f.getName()), TypedValue.WARN_SEVERITY)); + .forEach(f -> createReport(subReportNode, "network.modification.filterNotFound", Map.of("name", f.getName()), TypedValue.WARN_SEVERITY)); return filterInfos .stream() @@ -1640,14 +1622,13 @@ public static void logWrongEquipmentsIdsFilters(ReportNode subReportNode, Map valueEntry : child.getValues().entrySet()) { adder.withUntypedValue(valueEntry.getKey(), valueEntry.getValue().toString()); } @@ -1707,7 +1688,7 @@ public static void reportInjectionCreationConnectivity(InjectionCreationInfos in ); if (!connectivityReports.isEmpty()) { - ModificationUtils.getInstance().reportModifications(subReporter, connectivityReports, "ConnectivityCreated", CONNECTIVITY); + ModificationUtils.getInstance().reportModifications(subReporter, connectivityReports, "network.modification.ConnectivityCreated"); } } @@ -1741,7 +1722,7 @@ public static void reportBranchCreationConnectivity(BranchCreationInfos branchCr } if (!connectivityReports.isEmpty()) { - ModificationUtils.getInstance().reportModifications(subReporter, connectivityReports, "ConnectivityCreated", CONNECTIVITY); + ModificationUtils.getInstance().reportModifications(subReporter, connectivityReports, "network.modification.ConnectivityCreated"); } } @@ -1773,7 +1754,8 @@ private static List buildConnectivityReports( if (!isConnected) { reports.add(ReportNode.newRootReportNode() - .withMessageTemplate(EQUIPMENT_DISCONNECTED, "Equipment with id=${id} disconnected") + .withAllResourceBundlesFromClasspath() + .withMessageTemplate(EQUIPMENT_DISCONNECTED) .withUntypedValue("id", equipmentId) .withSeverity(TypedValue.INFO_SEVERITY) .build()); diff --git a/src/main/java/org/gridsuite/modification/utils/PropertiesUtils.java b/src/main/java/org/gridsuite/modification/utils/PropertiesUtils.java index ca06238..197dad4 100644 --- a/src/main/java/org/gridsuite/modification/utils/PropertiesUtils.java +++ b/src/main/java/org/gridsuite/modification/utils/PropertiesUtils.java @@ -15,7 +15,6 @@ import javax.annotation.Nullable; public final class PropertiesUtils { - public static final String PROPERTIES = "Properties"; private PropertiesUtils() { // Should not be instantiated @@ -30,13 +29,12 @@ public static void applyProperties(Identifiable identifiable, ReportNode subR ) ); if (!reportNodes.isEmpty()) { - ModificationUtils.getInstance().reportModifications(subReportNode, reportNodes, - propertiesLabelKey, PROPERTIES); + ModificationUtils.getInstance().reportModifications(subReportNode, reportNodes, propertiesLabelKey); } } private static ReportNode applyProperty(Identifiable identifiable, FreePropertyInfos prop) { - ReportNodeBuilder builder = ReportNode.newRootReportNode(); + ReportNodeBuilder builder = ReportNode.newRootReportNode().withAllResourceBundlesFromClasspath(); if (prop.isDeletionMark()) { if (identifiable.removeProperty(prop.getName())) { reportPropertyDeletion(builder, prop); @@ -56,14 +54,14 @@ private static ReportNode applyProperty(Identifiable identifiable, FreeProper } private static void reportPropertyCreation(ReportNodeAdderOrBuilder adderOrBuilder, FreePropertyInfos prop) { - adderOrBuilder.withMessageTemplate("propertyAdded", " Property ${name} added with value ${value}") + adderOrBuilder.withMessageTemplate("network.modification.propertyAdded") .withUntypedValue("name", prop.getName()) .withUntypedValue("value", prop.getValue()) .withSeverity(TypedValue.INFO_SEVERITY); } private static void reportPropertyModification(ReportNodeAdderOrBuilder adderOrBuilder, FreePropertyInfos prop) { - adderOrBuilder.withMessageTemplate("propertyChanged", " Property ${name} changed : ${from} -> ${to}") + adderOrBuilder.withMessageTemplate("network.modification.propertyChanged") .withUntypedValue("name", prop.getName()) .withUntypedValue("to", prop.getValue()) .withUntypedValue("from", prop.getPreviousValue() == null ? "null" : prop.getPreviousValue()) @@ -71,7 +69,7 @@ private static void reportPropertyModification(ReportNodeAdderOrBuilder adder } private static void reportPropertyDeletion(ReportNodeAdderOrBuilder adderOrBuilder, FreePropertyInfos prop) { - adderOrBuilder.withMessageTemplate("propertyDeleted", " Property ${name} deleted") + adderOrBuilder.withMessageTemplate("network.modification.propertyDeleted") .withUntypedValue("name", prop.getName()) .withSeverity(TypedValue.INFO_SEVERITY); } diff --git a/src/main/resources/org/gridsuite/modification/reports.properties b/src/main/resources/org/gridsuite/modification/reports.properties new file mode 100644 index 0000000..11193f8 --- /dev/null +++ b/src/main/resources/org/gridsuite/modification/reports.properties @@ -0,0 +1,302 @@ +network.modification.2WindingsTransformerModification = 2 windings transformer with id=${id} modified : +network.modification.2WindingsTransformerNotFound = 2 windings transformer with id=${id} not found +network.modification.2WindingsTransformerRatioTapChangerNotFound = 2 windings transformer with id=${id} : Ratio tap changer not found +network.modification.2WindingsTransformersModifications = 2 windings transformers +network.modification.3WindingsTransformerModification = 3 windings transformer with id=${id} modified : +network.modification.3WindingsTransformerNotFound = 3 windings transformer with id=${id} not found +network.modification.3WindingsTransformerRatioTapChangerNotFound = 3 windings transformer with id=${id} : Ratio tap changer for leg ${leg} not found +network.modification.3WindingsTransformersModifications = 3 windings transformers +network.modification.ActiveLimits = Active limits +network.modification.ActiveLimitsCreated = Active limits +network.modification.ActivePowerRegulationCreated = Active power regulation +network.modification.BatteryProperties = Properties +network.modification.BusesModifications = Buses +network.modification.Characteristics = Characteristics +network.modification.ConnectivityCreated = Connectivity +network.modification.ConnectivityModified = Connectivity +network.modification.ConverterStation = Converter station ${id} modified +network.modification.DisconnectedGenerator = Generator ${generator} has been discarded from generation dispatch because it is disconnected. Its active power set point remains unchanged +network.modification.GeneratorProperties = Properties +network.modification.GeneratorSetTargetP = The active power set point of generator ${generator} has been set to ${newValue} MW +network.modification.GeneratorUnchangedTargetP = Generator ${generator} has not been selected by the merit order algorithm. Its active power set point has been set to 0 +network.modification.GeneratorsModifications = Generators +network.modification.GeneratorsWithoutPredefinedActivePowerSetpoint = ${numGeneratorsWithoutSetpoint} generator${isPlural} not have a predefined active power set point +network.modification.LCC_Properties = Properties +network.modification.LccSetPoints = Setpoints +network.modification.Limits = Limits +network.modification.LimitsAndSetpointsCreated = Limits and Setpoints +network.modification.LimitsSetsOnSide1 = Limit Sets Side 1 +network.modification.LimitsSetsOnSide2 = Limit Sets Side 2 +network.modification.LineProperties = Properties +network.modification.LoadProperties = Properties +network.modification.MaxUsedMarginalCost = Marginal cost: ${maxUsedMarginalCost} +network.modification.MissingMarginalCostForGenerator = The generator ${generator} does not have a marginal cost +network.modification.MissingPredefinedActivePowerSetpointForGenerator = The generator ${generatorId} does not have a predefined active power set point +network.modification.NbGeneratorsWithNoCost = ${nbNoCost} generator${isPlural} been discarded from generation dispatch because of missing marginal cost. Their active power set point has been set to 0 +network.modification.NbSynchronousComponents = Network has ${scNumber} synchronous component${isPlural}: ${scList} +network.modification.NetworkCC0.SYNCHRONOUS_COMPONENT = Network CC0 SC${componentNum} +network.modification.NoAvailableAdjustableGenerator = There is no adjustable generator +network.modification.OPERATING_STATUS_MODIFICATION_ENERGISE_END_ONE = Energise ${equipmentId} +network.modification.OPERATING_STATUS_MODIFICATION_ENERGISE_END_TWO = Energise ${equipmentId} +network.modification.OPERATING_STATUS_MODIFICATION_LOCKOUT = Lockout ${equipmentId} +network.modification.OPERATING_STATUS_MODIFICATION_SWITCH_ON = Switch on ${equipmentId} +network.modification.OPERATING_STATUS_MODIFICATION_TRIP = Trip ${equipmentId} +network.modification.PHASE = Phase tap changer +network.modification.PhaseTapChangerCreated = Phase Tap Changer +network.modification.PhaseTapChangerRemoved = The phase tap changer has been removed +network.modification.PowerToDispatch = PowerToDispatch +network.modification.RATIO = Ratio tap changer +network.modification.RatioTapChangerCreated = Ratio Tap Changer +network.modification.RatioTapChangerRemoved = The ratio tap changer has been removed +network.modification.ReactiveLimits = Reactive limits +network.modification.ReactivePercentageError = cannot add Coordinated reactive extension on generator with id=${id} : ${message} +network.modification.RegulatedTerminalCreated = Regulated terminal +network.modification.RegulatingCreated = Regulation +network.modification.RegulationCreated = Regulation +network.modification.Result = Result +network.modification.SCNotRemoved = Shunt compensators were not removed for HVDC line id=${id} +network.modification.SetPointCreated = Setpoints +network.modification.Setpoints = Setpoints +network.modification.ShortCircuitExtensionAddError = cannot add short-circuit extension on generator with id=${id} : ${message} +network.modification.ShuntCompensatorProperties = Properties +network.modification.ShuntCompensatorsModifications = Shunt compensators +network.modification.Stacking = Stacking +network.modification.StandbyAutomatonCreated = Standby automaton +network.modification.StandbyAutomatonExtensionAddError = Cannot add standby automaton extension on ${message} +network.modification.StartupExtensionAddError = cannot add startup extension on generator with id=${id} : ${message} +network.modification.StateEstimationData = State estimation +network.modification.StaticVarCompensatorProperties = Properties +network.modification.StaticVarCompensatorsModifications = Static var compensators +network.modification.SubstationNotFound = Substation ${substation} not found +network.modification.SubstationProperties = Properties +network.modification.SumGeneratorActivePower = Sum of generator active power setpoints in ${region} region: ${sum} MW (NUCLEAR: ${nuclearSum} MW, THERMAL: ${thermalSum} MW, HYDRO: ${hydroSum} MW, WIND AND SOLAR: ${windAndSolarSum} MW, OTHER: ${otherSum} MW). +network.modification.SupplyDemandBalanceCouldBeMet = The supply-demand balance could be met +network.modification.SupplyDemandBalanceCouldNotBeMet = The supply-demand balance could not be met : the remaining power imbalance is ${remainingPower} MW +network.modification.TapsCreated = Taps +network.modification.TotalActiveBatteryTargetP = The battery balance is : ${batteryBalance} MW +network.modification.TotalAmountFixedSupply = The total amount of fixed supply is : ${totalAmountFixedSupply} MW +network.modification.TotalAmountFixedSupplyExceedsTotalDemand = The total amount of fixed supply exceeds the total demand +network.modification.TotalAmountSupplyToBeDispatched = The total amount of supply to be dispatched is : ${totalAmountSupplyToBeDispatched} MW +network.modification.TotalDemand = The total demand is : ${totalDemand} MW +network.modification.TotalDisconnectedGenerator = ${nbDisconnectedGenerator} generator${isPlural} been discarded from generation dispatch because their are disconnected. Their active power set point remains unchanged +network.modification.TotalGeneratorSetTargetP = The active power set points of ${nbUpdatedGenerator} generator${isPlural} have been updated as a result of generation dispatch +network.modification.TotalGeneratorUnchangedTargetP = ${nbUnchangedGenerator} eligible generator${isPlural} not been selected by the merit order algorithm. Their active power set point has been set to 0 +network.modification.TotalOutwardHvdcFlow = The HVDC balance is : ${hvdcBalance} MW +network.modification.TwoWindingsTransformerProperties = Properties +network.modification.VOLTAGE_LEVEL_TOPOLOGY_MODIFICATION = Voltage Level topology modification ${voltageLevelId} +network.modification.VlProperties = Properties +network.modification.VoltageRegulationCreated = Voltage regulation +network.modification.VoltageRegulationOn = ${status} +network.modification.VscConverterStationsModifications = Vsc converter stations +network.modification.VscModification = Vsc with id=${id} modified : +network.modification.VscProperties = Properties +network.modification.activePowerControlModified = Active power control +network.modification.activePowerExtensionAddError.battery = cannot add active power extension on battery with id=${id} : ${message} +network.modification.activePowerExtensionAddError.generator = cannot add active power extension on generator with id=${id} : ${message} +network.modification.activelimits = Active limits +network.modification.allFiltersWrong = All of the following filters have equipments with wrong id : ${filterNames} +network.modification.allFiltersWrong.variation = All of the following variation's filters have equipments with wrong id : ${filterNames} +network.modification.angleDroopActivePowerControl = ${status} +network.modification.appliedAssignment = ${modificationTypeLabel} on filters : ${filtersEachAssignment} +network.modification.appliedByFilterModifications = ${modificationTypeLabel}s on ${equipmentType} type +network.modification.battery.modification = Battery modification ${batteryId} +network.modification.batteryCreated = New battery with id=${id} created +network.modification.batteryCreation = Battery creation ${batteryId} +network.modification.batteryModification = Battery with id=${id} modified : +network.modification.busModification = Bus with id=${id} modified : +network.modification.busModificationsResume = ${count} bus(es) have been modified. +network.modification.busNotFound = Bus with id=${id} not found +network.modification.byFilter.deletion = By filter deletion +network.modification.byFilterModificationAll = All equipments have been modified : ${equipmentCount} equipment(s) +network.modification.byFilterModificationFailed = No equipment(s) have been modified on filter ${filterName} +network.modification.byFilterModificationNone = No equipment have been modified +network.modification.byFilterModificationNotFound = No equipments were found for filter ${filterName} +network.modification.byFilterModificationSome = Some of the equipment have been modified : ${nbChanged} equipment(s) modified and ${nbUnchanged} equipment(s) not modified +network.modification.byFilterModificationSuccess = Successful application of ${modificationTypeLabel} on filter ${filterName} +network.modification.byFormulaModification = Modification by formula +network.modification.characteristics = Characteristics +network.modification.converterStationCharacteristics = Characteristics +network.modification.converterStationCreated = ${fieldName} with id=${id} created +network.modification.converterStationFilters = Filters +network.modification.converterStationSetPoint = Setpoints +network.modification.converterStationSetPointsVoltageRegulation = Voltage regulation +network.modification.creation.fieldName = ${fieldName} : ${value} +network.modification.curveReactiveLimitsCreated = By diagram +network.modification.curveReactiveLimitsModified = By diagram +network.modification.deleteAttachingLine = Delete attaching line +network.modification.deleteVoltageLevelOnLine = Delete voltage level on line +network.modification.distributionKeysNotFound = This mode is available only for equipment with distribution key +network.modification.editedFieldFilter = Edited field : ${fieldName} +network.modification.energise.equipment.EndApplied = ${equipmentType} ${id} (id) : energise the side ${side} applied +network.modification.equipmentAttributeModification = ${EquipmentType} '${EquipmentId}' change +network.modification.equipmentByFilterDeleted = ${nbEquipments} equipments of type=${type} will be removed +network.modification.equipmentConnect = Equipment with id=${id} connected +network.modification.equipmentConnect.side = Equipment with id=${id} connected on side ${side} +network.modification.equipmentConnectedToHvdc = Equipment with id=${id} is connected to Hvdc +network.modification.equipmentDeleted = equipment of type=${type} and id=${id} deleted +network.modification.equipmentDeletion = Equipment deletion ${equipmentId} +network.modification.equipmentDisconnect = Equipment with id=${id} disconnected +network.modification.equipmentDisconnect.side = Equipment with id=${id} disconnected on side ${side} +network.modification.equipmentDisconnected = Equipment with id=${id} disconnected +network.modification.equipmentModifiedError.null = Cannot modify equipment ${equipmentName} : At least one of the value or referenced field is null +network.modification.equipmentModifiedError.zero = Cannot modify equipment ${equipmentName} : The value or referenced field of the second operand in the division operator is zero +network.modification.equipmentModifiedReport = ${equipmentType} id : ${equipmentName}, ${fieldName} : ${oldValue} ? ${newValue} +network.modification.equipmentModifiedReportException = Cannot modify equipment ${equipmentName} : ${errorMessage} +network.modification.equipmentNotConnectedToHvdc = Equipment with id=${id} is not connected to Hvdc +network.modification.fieldModification = ${fieldName} : ${oldValue} ${arrow} ${newValue} +network.modification.filterEquipmentsNotFound = Equipment not found : ${equipmentIds} +network.modification.filterEquipmentsNotFound.inFilter = Cannot find the following equipments ${equipmentIds} in filter ${filters} +network.modification.filterGeneratorsNotFound.generatorsFrequencyReserve = Frequency reserve: Cannot find ${nbNotFoundGen} generators in filter ${filterName} +network.modification.filterGeneratorsNotFound.generatorsWithFixedSupply = Generators with fixed active power: Cannot find ${nbNotFoundGen} generators in filter ${filterName} +network.modification.filterGeneratorsNotFound.generatorsWithoutOutage = Generators without outage simulation: Cannot find ${nbNotFoundGen} generators in filter ${filterName} +network.modification.filterNotFound = Cannot find the following filter: ${name} +network.modification.generationDispatch = Generation dispatch +network.modification.generator.creation = Generator creation ${generatorId} +network.modification.generator.modification = Generator modification ${generatorId} +network.modification.generatorChanged = Generator with id=${id} targetP changed +network.modification.generatorCreated = New generator with id=${id} created +network.modification.generatorModification = Generator with id=${id} modified : +network.modification.generatorModificationsResume = ${count} generator(s) have been modified. +network.modification.generatorNotFound = Generator with id=${id} not found +network.modification.generatorNotFound.generatorsFrequencyReserve = Frequency reserve: Cannot find generator ${notFoundGeneratorId} in filter ${filterName} +network.modification.generatorNotFound.generatorsWithFixedSupply = Generators with fixed active power: Cannot find generator ${notFoundGeneratorId} in filter ${filterName} +network.modification.generatorNotFound.generatorsWithoutOutage = Generators without outage simulation: Cannot find generator ${notFoundGeneratorId} in filter ${filterName} +network.modification.generatorScaling = Generator scaling +network.modification.groovyScript = Apply groovy script +network.modification.groovyScriptApplied = Groovy script applied +network.modification.invalidFilters = ${errorType}: There is no valid equipment ID among the provided filter(s) +network.modification.lcc.creation = Lcc creation ${lccId} +network.modification.lccCharacteristics = Characteristics +network.modification.lccCreated = New lcc with id=${id} created +network.modification.limitSetAdded = ${name} added +network.modification.limitSetSelectedOnSide1 = limit set selected on side 1 : ${selectedOperationalLimitsGroup1} +network.modification.limitSetSelectedOnSide2 = limit set selected on side 2 : ${selectedOperationalLimitsGroup2} +network.modification.limits = Limits +network.modification.limitsCreated = Limits +network.modification.line.modification = Line modification ${lineId} +network.modification.lineAttachToVoltageLevel = Line attach to voltage level +network.modification.lineCreated = New line with id=${id} created +network.modification.lineCreation = Creation of line ${lineId} +network.modification.lineModification = Line with id=${id} modified : +network.modification.lineSplitWithVoltageLevel = Line split with voltage level +network.modification.lineStatusChanged = Branch with id=${id} status changed +network.modification.linesAttachToSplitLines = Lines attach to split lines +network.modification.load.creation = Load creation ${loadId} +network.modification.load.modification = Load modification ${loadId} +network.modification.loadCreated = New load with id=${id} created +network.modification.loadModification = Load with id=${id} modified : +network.modification.loadScaling = Load Scaling +network.modification.lockout.equipment.Applied = ${equipmentType} ${id} (id) : lockout applied +network.modification.measurements = Measurements +network.modification.measurementsSide1 = Side 1 +network.modification.measurementsSide2 = Side 2 +network.modification.minMaxReactiveLimitsCreated = By range +network.modification.minMaxReactiveLimitsModified = By range +network.modification.modificationByAssignment = Modification by filter +network.modification.newStepAlpha = Shift angle : ${value} +network.modification.newStepConductance = ${delta} conductance : ${value} +network.modification.newStepIndex = Tap (${value}) +network.modification.newStepRatio = Ratio : ${value} +network.modification.newStepReactance = ${delta} reactance : ${value} +network.modification.newStepResistance = ${delta} resistance : ${value} +network.modification.newStepSusceptance = ${delta} susceptance : ${value} +network.modification.notEditedEquipmentsFilter = ${nbUnchanged} equipment(s) were not modified +network.modification.notFoundBurOrBusbarSection = Bus or busbar section ID ${busbarSectionId} not found. Coupler was not created. +network.modification.numberOfValidEquipment = Number of equipment modified : ${nbChanged} +network.modification.phaseTapChanger1.tapPosition = 3WT with id=${id} phase tap changer 1 position changed +network.modification.phaseTapChanger2.tapPosition = 3WT with id=${id} phase tap changer 2 position changed +network.modification.phaseTapChanger3.tapPosition = 3WT with id=${id} phase tap changer 3 position changed +network.modification.phaseTapChangerEquipmentModifiedError = Cannot modify field ${fieldName} of equipment ${equipmentName} : Phase tab changer is null +network.modification.phaseTapChangerPositionsAndStepsModification = Tap Changer +network.modification.phaseTapPositionChanged = 2WT with id=${id} phase tap changer position changed +network.modification.propertyAdded = Property ${name} added with value ${value} +network.modification.propertyChanged = Property ${name} changed : ${from} -> ${to} +network.modification.propertyDeleted = Property ${name} deleted +network.modification.ratioTapChanger1.tapPosition = 3WT with id=${id} ratio tap changer 1 position changed +network.modification.ratioTapChanger2.tapPosition = 3WT with id=${id} ratio tap changer 2 position changed +network.modification.ratioTapChanger3.tapPosition = 3WT with id=${id} ratio tap changer 3 position changed +network.modification.ratioTapChangerEquipmentModifiedError = Cannot modify field ${fieldName} of equipment ${equipmentName} : Ratio tab changer is null +network.modification.ratioTapChangerPositionsAndStepsModification = Taps +network.modification.ratioTapChangerRegulationModification = Regulation +network.modification.ratioTapChangerTerminalRegulatedModification = Regulated Terminal +network.modification.ratioTapPositionChanged = 2WT with id=${id} ratio tap changer position changed +network.modification.scalingApplied = Successfully scaling variation in ${variationMode} mode with variation value asked is ${askedValue} and variation done is ${actualValue} +network.modification.scalingCreated = new scaling created +network.modification.shortCircuitAttributesModified = Short-circuit +network.modification.shortCircuitCreated = Short-circuit +network.modification.shuntCompensatorConnectUndefined = Connect value is undefined +network.modification.shuntCompensatorCreated = New shunt compensator with id=${id} created +network.modification.shuntCompensatorCreation = Shunt compensator creation ${shuntCompensatorId} +network.modification.shuntCompensatorDisconnected = Shunt compensator disconnected +network.modification.shuntCompensatorModification = Shunt compensator with id=${id} modified : +network.modification.shuntCompensatorModification.modification = Shunt compensator modification ${shuntCompensatorId} +network.modification.shuntCompensatorModification.withId = Shunt Compensator with id=${id} modified : +network.modification.shuntCompensatorModificationsResume = ${count} shunt compensator(s) have been modified. +network.modification.shuntCompensatorNotDeleted = Shunt compensator with id=${id} not found in the network +network.modification.shuntCompensatorNotFound = Shunt compensator with id=${id} not found +network.modification.shuntCompensatorReconnected = Shunt compensator reconnected +network.modification.shuntCompensatorSectionCountUndefined = Section count value is undefined +network.modification.side1Characteristics = Side 1 +network.modification.side1LimitsModification = Side 1 +network.modification.side2Characteristics = Side 2 +network.modification.side2LimitsModification = Side 2 +network.modification.startUpAttributesCreated = Start up +network.modification.startUpAttributesModified = Start up +network.modification.stateEstimationData = State estimation +network.modification.staticVarCompensatorCreated = New static var compensator with id=${id} created +network.modification.staticVarCompensatorCreation = Static var compensator creation ${id} +network.modification.staticVarCompensatorModification = Static var compensator with id=${id} modified : +network.modification.staticVarCompensatorNotFound = Static var compensator with id=${id} not found +network.modification.substation.creation = Substation creation ${substationId} +network.modification.substation.modification = Substation modification ${substationId} +network.modification.substationCreated = New substation with id=${id} created +network.modification.substationModification = Substation with id=${id} modified :" +network.modification.svcModificationsResume = ${count} static var compensator(s) have been modified. +network.modification.switchChanged = ${operation} switch '${id}' in voltage level ${voltageLevelId} +network.modification.switchOn.equipment.Applied = ${equipmentType} ${id} (id) : switch on applied +network.modification.tabular.creation = Tabular creation: ${creationsCount} ${defaultMessage} +network.modification.tabular.creation.error = Tabular creation: No ${defaultMessage} +network.modification.tabular.creation.exception = ${message} +network.modification.tabular.creation.warning = Tabular creation: ${creationsCount} ${defaultMessage} and ${failuresCount} have not been created +network.modification.tabular.modification = Tabular modification: ${modificationsCount} ${defaultMessage} +network.modification.tabular.modification.error = Tabular modification: No ${defaultMessage} +network.modification.tabular.modification.exception = ${message} +network.modification.tabular.modification.warning = Tabular modification: ${modificationsCount} ${defaultMessage} and ${failuresCount} have not been modified +network.modification.tabular.shuntCompensator.maxSusceptanceIgnored.1 = Tabular modification: Input for maximum susceptance has been ignored since it is not possible to simultaneously update type, maximum reactive power and maximum susceptance for shunt compensator with id ${id} +network.modification.tabular.shuntCompensator.maxSusceptanceIgnored.2 = Tabular modification: Input for maximum susceptance has been ignored since it is not possible to simultaneously update type and maximum susceptance for shunt compensator with id ${id} +network.modification.tabular.shuntCompensator.maxSusceptanceIgnored.3 = Tabular modification: Input for maximum susceptance has been ignored since it is not possible to simultaneously update maximum reactive power and maximum susceptance for shunt compensator with id ${id} +network.modification.tabular.shuntCompensator.modifyImpossible = Tabular modification: It is currently not possible to modify non-linear shunt compensator with id ${id} +network.modification.tabularCreation = Tabular creation +network.modification.tabularModification = Tabular modification +network.modification.tapChangerStepsModification = Taps were replaced by new ones below +network.modification.tapsModification = Taps +network.modification.temporaryLimitAdded.name = ${name} (${duration}) added with ${value} +network.modification.temporaryLimitDeleted.name = ${name} (${duration}) deleted +network.modification.temporaryLimitModified.name = ${name} (${duration}) : ${oldValue} -> ${value} +network.modification.temporaryLimitsModification = Temporary current limits : +network.modification.terminal1Disconnected = Equipment with id=${id} disconnected on side 1 +network.modification.terminal2Disconnected = Equipment with id=${id} disconnected on side 2 +network.modification.trip.equipment.Applied = ${equipmentType} ${id} (id) : trip applied +network.modification.twoWindingsTransformerCreated = New two windings transformer with id=${id} created +network.modification.twoWindingsTransformerCreation = Two windings transformer creation ${twoWindingsTransformerId} +network.modification.twoWindingsTransformerModification.modification = Two windings transformer modification ${twoWindingsTransformerId} +network.modification.twoWindingsTransformerModification.modified = TwoWindingsTransformer with id=${id} modified : +network.modification.twtToBeEstimated = Estimate tap position +network.modification.voltageInitModification = Voltage init modification +network.modification.voltageLevel.creation = VoltageLevel creation ${voltageLevelId} +network.modification.voltageLevel.modification = VoltageLevel modification ${voltageLevelId} +network.modification.voltageLevelCreated = New voltage level with id=${id} created +network.modification.voltageLevelModification = Voltage level with id=${id} modified : +network.modification.voltageLevelTopologyModified = Voltage level '${id}' topology has been modified +network.modification.voltageRegulationModified = Voltage regulation +network.modification.vsc.creation = Vsc creation ${vscId} +network.modification.vsc.modification = Vsc modification ${vscId} +network.modification.vscAngleDroop = Angle droop active power control +network.modification.vscCharacteristics = Characteristics +network.modification.vscConverterStationModification = Vsc converter station with id=${id} modified : +network.modification.vscConverterStationNotFound = Vsc converter station with id=${id} not found +network.modification.vscCreated = New vsc with id=${id} created +network.modification.vscLimits = Limits +network.modification.vscModificationsResume = ${count} vsc converter station(s) have been modified. +network.modification.vscSetPoints = Setpoints +network.modification.windingsTransformerModificationsResume = ${count} transformer(s) have been modified. diff --git a/src/main/resources/org/gridsuite/modification/reports_en_US.properties b/src/main/resources/org/gridsuite/modification/reports_en_US.properties new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/src/main/resources/org/gridsuite/modification/reports_en_US.properties @@ -0,0 +1 @@ + diff --git a/src/test/java/org/gridsuite/modification/modifications/GenerationDispatchTest.java b/src/test/java/org/gridsuite/modification/modifications/GenerationDispatchTest.java index 4f31e5e..4e5700e 100644 --- a/src/test/java/org/gridsuite/modification/modifications/GenerationDispatchTest.java +++ b/src/test/java/org/gridsuite/modification/modifications/GenerationDispatchTest.java @@ -21,8 +21,8 @@ import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; import java.util.*; -import static org.gridsuite.modification.utils.TestUtils.assertLogMessage; -import static org.gridsuite.modification.utils.TestUtils.assertLogNthMessage; + +import static org.gridsuite.modification.utils.TestUtils.*; import static org.junit.jupiter.api.Assertions.*; import static org.mockito.Mockito.when; @@ -68,26 +68,26 @@ private static IdentifiableAttributes getIdentifiableAttributes(String id) { } private void assertLogReportsForDefaultNetwork(double batteryBalanceOnSc2, ReportNode report) { - int firstSynchronousComponentNum = getNetwork().getGenerator(GTH1_ID).getTerminal().getBusView().getBus().getSynchronousComponent().getNum(); // GTH1 is in first synchronous component - assertLogMessage("The total demand is : 528.0 MW", "TotalDemand" + firstSynchronousComponentNum, report); - assertLogMessage("The total amount of fixed supply is : 0.0 MW", "TotalAmountFixedSupply" + firstSynchronousComponentNum, report); - assertLogMessage("The HVDC balance is : 90.0 MW", "TotalOutwardHvdcFlow" + firstSynchronousComponentNum, report); - assertLogMessage("The battery balance is : 0.0 MW", "TotalActiveBatteryTargetP" + firstSynchronousComponentNum, report); - assertLogMessage("The total amount of supply to be dispatched is : 438.0 MW", "TotalAmountSupplyToBeDispatched" + firstSynchronousComponentNum, report); - assertLogMessage("The supply-demand balance could not be met : the remaining power imbalance is 138.0 MW", "SupplyDemandBalanceCouldNotBeMet" + firstSynchronousComponentNum, report); + // GTH1 is in first synchronous component + assertLogMessage("The total demand is : 528.0 MW", "network.modification.TotalDemand", report); + assertLogMessage("The total amount of fixed supply is : 0.0 MW", "network.modification.TotalAmountFixedSupply", report); + assertLogMessage("The HVDC balance is : 90.0 MW", "network.modification.TotalOutwardHvdcFlow", report); + assertLogMessage("The battery balance is : 0.0 MW", "network.modification.TotalActiveBatteryTargetP", report); + assertLogMessage("The total amount of supply to be dispatched is : 438.0 MW", "network.modification.TotalAmountSupplyToBeDispatched", report); + assertLogMessage("The supply-demand balance could not be met : the remaining power imbalance is 138.0 MW", "network.modification.SupplyDemandBalanceCouldNotBeMet", report); // on SC 2, we have to substract the battery balance final double defaultTotalAmount = 330.0; DecimalFormat df = new DecimalFormat("#0.0", new DecimalFormatSymbols(Locale.US)); final String totalAmount = df.format(defaultTotalAmount - batteryBalanceOnSc2); - int secondSynchronousComponentNum = getNetwork().getGenerator(GH1_ID).getTerminal().getBusView().getBus().getSynchronousComponent().getNum(); // GH1 is in second synchronous component - assertLogMessage("The total demand is : 240.0 MW", "TotalDemand" + secondSynchronousComponentNum, report); - assertLogMessage("The total amount of fixed supply is : 0.0 MW", "TotalAmountFixedSupply" + secondSynchronousComponentNum, report); - assertLogMessage("The HVDC balance is : -90.0 MW", "TotalOutwardHvdcFlow" + secondSynchronousComponentNum, report); - assertLogMessage("The battery balance is : " + df.format(batteryBalanceOnSc2) + " MW", "TotalActiveBatteryTargetP" + secondSynchronousComponentNum, report); - assertLogMessage("The total amount of supply to be dispatched is : " + totalAmount + " MW", "TotalAmountSupplyToBeDispatched" + secondSynchronousComponentNum, report); - assertLogMessage("Marginal cost: 150.0", "MaxUsedMarginalCost" + secondSynchronousComponentNum, report); - assertLogMessage("The supply-demand balance could be met", "SupplyDemandBalanceCouldBeMet" + secondSynchronousComponentNum, report); - assertLogMessage("Sum of generator active power setpoints in SOUTH region: " + totalAmount + " MW (NUCLEAR: 0.0 MW, THERMAL: 0.0 MW, HYDRO: " + totalAmount + " MW, WIND AND SOLAR: 0.0 MW, OTHER: 0.0 MW).", "SumGeneratorActivePowerSOUTH" + secondSynchronousComponentNum, report); + // GH1 is in second synchronous component + assertLogMessageWithoutRank("The total demand is : 240.0 MW", "network.modification.TotalDemand", report); + assertLogMessageWithoutRank("The total amount of fixed supply is : 0.0 MW", "network.modification.TotalAmountFixedSupply", report); + assertLogMessageWithoutRank("The HVDC balance is : -90.0 MW", "network.modification.TotalOutwardHvdcFlow", report); + assertLogMessageWithoutRank("The battery balance is : " + df.format(batteryBalanceOnSc2) + " MW", "network.modification.TotalActiveBatteryTargetP", report); + assertLogMessageWithoutRank("The total amount of supply to be dispatched is : " + totalAmount + " MW", "network.modification.TotalAmountSupplyToBeDispatched", report); + assertLogMessageWithoutRank("Marginal cost: 150.0", "network.modification.MaxUsedMarginalCost", report); + assertLogMessageWithoutRank("The supply-demand balance could be met", "network.modification.SupplyDemandBalanceCouldBeMet", report); + assertLogMessageWithoutRank("Sum of generator active power setpoints in SOUTH region: " + totalAmount + " MW (NUCLEAR: 0.0 MW, THERMAL: 0.0 MW, HYDRO: " + totalAmount + " MW, WIND AND SOLAR: 0.0 MW, OTHER: 0.0 MW).", "network.modification.SumGeneratorActivePower", report); } @Test @@ -97,7 +97,9 @@ void testGenerationDispatch() throws Exception { // network with 2 synchronous components, no battery, 2 hvdc lines between them and no forcedOutageRate and plannedOutageRate for the generators setNetwork(Network.read("testGenerationDispatch.xiidm", getClass().getResourceAsStream("/testGenerationDispatch.xiidm"))); - ReportNode report = modification.createSubReportNode(ReportNode.newRootReportNode().withMessageTemplate("", "").build()); + ReportNode report = modification.createSubReportNode(ReportNode.newRootReportNode() + .withResourceBundles("i18n.reports") + .withMessageTemplate("test").build()); modification.toModification().apply(getNetwork(), report); assertNetworkAfterCreationWithStandardLossCoefficient(); @@ -117,7 +119,9 @@ void testGenerationDispatchWithBattery() throws Exception { assertFalse(getNetwork().getBattery(BATTERY3_ID).getTerminal().isConnected()); final double batteryTotalTargetP = getNetwork().getBattery(BATTERY1_ID).getTargetP() + getNetwork().getBattery(BATTERY2_ID).getTargetP(); - ReportNode report = modification.createSubReportNode(ReportNode.newRootReportNode().withMessageTemplate("", "").build()); + ReportNode report = modification.createSubReportNode(ReportNode.newRootReportNode() + .withResourceBundles("i18n.reports") + .withMessageTemplate("test").build()); modification.toModification().apply(getNetwork(), report); assertLogReportsForDefaultNetwork(batteryTotalTargetP, report); } @@ -136,7 +140,9 @@ void testGenerationDispatchWithBatteryConnection() throws Exception { getNetwork().getBattery(BATTERY3_ID).getTerminal().connect(); final double batteryTotalTargetP = getNetwork().getBattery(BATTERY1_ID).getTargetP() + getNetwork().getBattery(BATTERY2_ID).getTargetP() + getNetwork().getBattery(BATTERY3_ID).getTargetP(); - ReportNode report = modification.createSubReportNode(ReportNode.newRootReportNode().withMessageTemplate("", "").build()); + ReportNode report = modification.createSubReportNode(ReportNode.newRootReportNode() + .withResourceBundles("i18n.reports") + .withMessageTemplate("test").build()); modification.toModification().apply(getNetwork(), report); assertLogReportsForDefaultNetwork(batteryTotalTargetP, report); } @@ -147,17 +153,18 @@ void testGenerationDispatchWithMultipleEnergySource() throws Exception { setNetwork(Network.read("testGenerationDispatchWithMultipleEnergySource.xiidm", getClass().getResourceAsStream("/testGenerationDispatchWithMultipleEnergySource.xiidm"))); - ReportNode report = modification.createSubReportNode(ReportNode.newRootReportNode().withMessageTemplate("", "").build()); + ReportNode report = modification.createSubReportNode(ReportNode.newRootReportNode() + .withResourceBundles("i18n.reports") + .withMessageTemplate("test").build()); modification.toModification().apply(getNetwork(), report); - int synchronousComponentNum = getNetwork().getGenerator(GH1_ID).getTerminal().getBusView().getBus().getSynchronousComponent().getNum(); - assertLogMessage("The total demand is : 768.0 MW", "TotalDemand" + synchronousComponentNum, report); - assertLogMessage("The total amount of fixed supply is : 0.0 MW", "TotalAmountFixedSupply" + synchronousComponentNum, report); - assertLogMessage("The HVDC balance is : -90.0 MW", "TotalOutwardHvdcFlow" + synchronousComponentNum, report); - assertLogMessage("The total amount of supply to be dispatched is : 858.0 MW", "TotalAmountSupplyToBeDispatched" + synchronousComponentNum, report); - assertLogMessage("Marginal cost: 28.0", "MaxUsedMarginalCost" + synchronousComponentNum, report); - assertLogMessage("The supply-demand balance could be met", "SupplyDemandBalanceCouldBeMet" + synchronousComponentNum, report); - assertLogMessage("Sum of generator active power setpoints in SOUTH region: 858.0 MW (NUCLEAR: 150.0 MW, THERMAL: 200.0 MW, HYDRO: 108.0 MW, WIND AND SOLAR: 150.0 MW, OTHER: 250.0 MW).", "SumGeneratorActivePowerSOUTH" + synchronousComponentNum, report); + assertLogMessageWithoutRank("The total demand is : 768.0 MW", "network.modification.TotalDemand", report); + assertLogMessageWithoutRank("The total amount of fixed supply is : 0.0 MW", "network.modification.TotalAmountFixedSupply", report); + assertLogMessageWithoutRank("The HVDC balance is : -90.0 MW", "network.modification.TotalOutwardHvdcFlow", report); + assertLogMessageWithoutRank("The total amount of supply to be dispatched is : 858.0 MW", "network.modification.TotalAmountSupplyToBeDispatched", report); + assertLogMessageWithoutRank("Marginal cost: 28.0", "network.modification.MaxUsedMarginalCost", report); + assertLogMessageWithoutRank("The supply-demand balance could be met", "network.modification.SupplyDemandBalanceCouldBeMet", report); + assertLogMessageWithoutRank("Sum of generator active power setpoints in SOUTH region: 858.0 MW (NUCLEAR: 150.0 MW, THERMAL: 200.0 MW, HYDRO: 108.0 MW, WIND AND SOLAR: 150.0 MW, OTHER: 250.0 MW).", "network.modification.SumGeneratorActivePower", report); } @Test @@ -168,7 +175,9 @@ void testGenerationDispatchWithHigherLossCoefficient() throws Exception { // network with 2 synchronous components, 2 hvdc lines between them and no forcedOutageRate and plannedOutageRate for the generators setNetwork(Network.read("testGenerationDispatch.xiidm", getClass().getResourceAsStream("/testGenerationDispatch.xiidm"))); - ReportNode report = modification.createSubReportNode(ReportNode.newRootReportNode().withMessageTemplate("", "").build()); + ReportNode report = modification.createSubReportNode(ReportNode.newRootReportNode() + .withResourceBundles("i18n.reports") + .withMessageTemplate("test").build()); modification.toModification().apply(getNetwork(), report); assertEquals(100., getNetwork().getGenerator(GH1_ID).getTargetP(), 0.001); @@ -185,19 +194,19 @@ void testGenerationDispatchWithHigherLossCoefficient() throws Exception { assertEquals(7., getNetwork().getGenerator(NEW_GROUP2_ID).getTargetP(), 0.001); // not modified : not in main connected component // test total demand and remaining power imbalance on synchronous components - int firstSynchronousComponentNum = getNetwork().getGenerator(GTH1_ID).getTerminal().getBusView().getBus().getSynchronousComponent().getNum(); // GTH1 is in first synchronous component - assertLogMessage("The total demand is : 836.0 MW", "TotalDemand" + firstSynchronousComponentNum, report); - assertLogMessage("The total amount of fixed supply is : 0.0 MW", "TotalAmountFixedSupply" + firstSynchronousComponentNum, report); - assertLogMessage("The HVDC balance is : 90.0 MW", "TotalOutwardHvdcFlow" + firstSynchronousComponentNum, report); - assertLogMessage("The total amount of supply to be dispatched is : 746.0 MW", "TotalAmountSupplyToBeDispatched" + firstSynchronousComponentNum, report); - assertLogMessage("The supply-demand balance could not be met : the remaining power imbalance is 446.0 MW", "SupplyDemandBalanceCouldNotBeMet" + firstSynchronousComponentNum, report); - - int secondSynchronousComponentNum = getNetwork().getGenerator(GH1_ID).getTerminal().getBusView().getBus().getSynchronousComponent().getNum(); // GH1 is in second synchronous component - assertLogMessage("The total demand is : 380.0 MW", "TotalDemand" + secondSynchronousComponentNum, report); - assertLogMessage("The total amount of fixed supply is : 0.0 MW", "TotalAmountFixedSupply" + secondSynchronousComponentNum, report); - assertLogMessage("The HVDC balance is : -90.0 MW", "TotalOutwardHvdcFlow" + secondSynchronousComponentNum, report); - assertLogMessage("The total amount of supply to be dispatched is : 470.0 MW", "TotalAmountSupplyToBeDispatched" + secondSynchronousComponentNum, report); - assertLogMessage("The supply-demand balance could not be met : the remaining power imbalance is 70.0 MW", "SupplyDemandBalanceCouldNotBeMet" + secondSynchronousComponentNum, report); + // GTH1 is in first synchronous component + assertLogMessage("The total demand is : 836.0 MW", "network.modification.TotalDemand", report); + assertLogMessage("The total amount of fixed supply is : 0.0 MW", "network.modification.TotalAmountFixedSupply", report); + assertLogMessage("The HVDC balance is : 90.0 MW", "network.modification.TotalOutwardHvdcFlow", report); + assertLogMessage("The total amount of supply to be dispatched is : 746.0 MW", "network.modification.TotalAmountSupplyToBeDispatched", report); + assertLogMessage("The supply-demand balance could not be met : the remaining power imbalance is 446.0 MW", "network.modification.SupplyDemandBalanceCouldNotBeMet", report); + + // GH1 is in second synchronous component + assertLogMessageWithoutRank("The total demand is : 380.0 MW", "network.modification.TotalDemand", report); + assertLogMessageWithoutRank("The total amount of fixed supply is : 0.0 MW", "network.modification.TotalAmountFixedSupply", report); + assertLogMessageWithoutRank("The HVDC balance is : -90.0 MW", "network.modification.TotalOutwardHvdcFlow", report); + assertLogMessageWithoutRank("The total amount of supply to be dispatched is : 470.0 MW", "network.modification.TotalAmountSupplyToBeDispatched", report); + assertLogMessageWithoutRank("The supply-demand balance could not be met : the remaining power imbalance is 70.0 MW", "network.modification.SupplyDemandBalanceCouldNotBeMet", report); } @Test @@ -207,7 +216,9 @@ void testGenerationDispatchWithInternalHvdc() throws Exception { // network with unique synchronous component, 2 internal hvdc lines and no forcedOutageRate and plannedOutageRate for the generators setNetwork(Network.read("testGenerationDispatchInternalHvdc.xiidm", getClass().getResourceAsStream("/testGenerationDispatchInternalHvdc.xiidm"))); - ReportNode report = modification.createSubReportNode(ReportNode.newRootReportNode().withMessageTemplate("", "").build()); + ReportNode report = modification.createSubReportNode(ReportNode.newRootReportNode() + .withResourceBundles("i18n.reports") + .withMessageTemplate("test").build()); modification.toModification().apply(getNetwork(), report); assertEquals(100., getNetwork().getGenerator(GH1_ID).getTargetP(), 0.001); @@ -224,12 +235,12 @@ void testGenerationDispatchWithInternalHvdc() throws Exception { assertEquals(7., getNetwork().getGenerator(NEW_GROUP2_ID).getTargetP(), 0.001); // not modified : not in main connected component // test total demand and remaining power imbalance on unique synchronous component - int firstSynchronousComponentNum = getNetwork().getGenerator(GTH1_ID).getTerminal().getBusView().getBus().getSynchronousComponent().getNum(); // GTH1 is in the unique synchronous component - assertLogMessage("The total demand is : 768.0 MW", "TotalDemand" + firstSynchronousComponentNum, report); - assertLogMessage("The total amount of fixed supply is : 0.0 MW", "TotalAmountFixedSupply" + firstSynchronousComponentNum, report); - assertLogMessage("The HVDC balance is : 0.0 MW", "TotalOutwardHvdcFlow" + firstSynchronousComponentNum, report); - assertLogMessage("The total amount of supply to be dispatched is : 768.0 MW", "TotalAmountSupplyToBeDispatched" + firstSynchronousComponentNum, report); - assertLogMessage("The supply-demand balance could not be met : the remaining power imbalance is 68.0 MW", "SupplyDemandBalanceCouldNotBeMet" + firstSynchronousComponentNum, report); + // GTH1 is in the unique synchronous component + assertLogMessage("The total demand is : 768.0 MW", "network.modification.TotalDemand", report); + assertLogMessage("The total amount of fixed supply is : 0.0 MW", "network.modification.TotalAmountFixedSupply", report); + assertLogMessage("The HVDC balance is : 0.0 MW", "network.modification.TotalOutwardHvdcFlow", report); + assertLogMessage("The total amount of supply to be dispatched is : 768.0 MW", "network.modification.TotalAmountSupplyToBeDispatched", report); + assertLogMessage("The supply-demand balance could not be met : the remaining power imbalance is 68.0 MW", "network.modification.SupplyDemandBalanceCouldNotBeMet", report); } @Test @@ -251,7 +262,9 @@ void testGenerationDispatchWithMaxPReduction() throws Exception { when(filterService.exportFilters(List.of(FILTER_ID_1, FILTER_ID_2, FILTER_ID_3), getNetwork())).thenReturn(filters.stream()); GenerationDispatch modif = (GenerationDispatch) modification.toModification(); modif.initApplicationContext(filterService); - ReportNode report = modification.createSubReportNode(ReportNode.newRootReportNode().withMessageTemplate("", "").build()); + ReportNode report = modification.createSubReportNode(ReportNode.newRootReportNode() + .withResourceBundles("i18n.reports") + .withMessageTemplate("test").build()); modif.apply(getNetwork(), report); assertEquals(74.82, getNetwork().getGenerator(GH1_ID).getTargetP(), 0.001); @@ -268,21 +281,21 @@ void testGenerationDispatchWithMaxPReduction() throws Exception { assertEquals(7., getNetwork().getGenerator(NEW_GROUP2_ID).getTargetP(), 0.001); // not modified : not in main connected component // test total demand and remaining power imbalance on synchronous components - int firstSynchronousComponentNum = getNetwork().getGenerator(GTH1_ID).getTerminal().getBusView().getBus().getSynchronousComponent().getNum(); // GTH1 is in first synchronous component - assertLogMessage("The total demand is : 528.0 MW", "TotalDemand" + firstSynchronousComponentNum, report); - assertLogMessage("The total amount of fixed supply is : 0.0 MW", "TotalAmountFixedSupply" + firstSynchronousComponentNum, report); - assertLogMessage("The HVDC balance is : 90.0 MW", "TotalOutwardHvdcFlow" + firstSynchronousComponentNum, report); - assertLogMessage("The total amount of supply to be dispatched is : 438.0 MW", "TotalAmountSupplyToBeDispatched" + firstSynchronousComponentNum, report); - assertLogMessage("The supply-demand balance could not be met : the remaining power imbalance is 169.0 MW", "SupplyDemandBalanceCouldNotBeMet" + firstSynchronousComponentNum, report); - - int secondSynchronousComponentNum = getNetwork().getGenerator(GH1_ID).getTerminal().getBusView().getBus().getSynchronousComponent().getNum(); // GH1 is in second synchronous component - assertLogMessage("The total demand is : 240.0 MW", "TotalDemand" + secondSynchronousComponentNum, report); - assertLogMessage("The total amount of fixed supply is : 0.0 MW", "TotalAmountFixedSupply" + secondSynchronousComponentNum, report); - assertLogMessage("The HVDC balance is : -90.0 MW", "TotalOutwardHvdcFlow" + secondSynchronousComponentNum, report); - assertLogMessage("The total amount of supply to be dispatched is : 330.0 MW", "TotalAmountSupplyToBeDispatched" + secondSynchronousComponentNum, report); - assertLogMessage("Marginal cost: 150.0", "MaxUsedMarginalCost" + secondSynchronousComponentNum, report); - assertLogMessage("The supply-demand balance could be met", "SupplyDemandBalanceCouldBeMet" + secondSynchronousComponentNum, report); - assertLogMessage("Sum of generator active power setpoints in WEST region: 330.0 MW (NUCLEAR: 0.0 MW, THERMAL: 0.0 MW, HYDRO: 330.0 MW, WIND AND SOLAR: 0.0 MW, OTHER: 0.0 MW).", "SumGeneratorActivePowerWEST" + secondSynchronousComponentNum, report); + // GTH1 is in first synchronous component + assertLogMessage("The total demand is : 528.0 MW", "network.modification.TotalDemand", report); + assertLogMessage("The total amount of fixed supply is : 0.0 MW", "network.modification.TotalAmountFixedSupply", report); + assertLogMessage("The HVDC balance is : 90.0 MW", "network.modification.TotalOutwardHvdcFlow", report); + assertLogMessage("The total amount of supply to be dispatched is : 438.0 MW", "network.modification.TotalAmountSupplyToBeDispatched", report); + assertLogMessage("The supply-demand balance could not be met : the remaining power imbalance is 169.0 MW", "network.modification.SupplyDemandBalanceCouldNotBeMet", report); + + // GH1 is in second synchronous component + assertLogMessageWithoutRank("The total demand is : 240.0 MW", "network.modification.TotalDemand", report); + assertLogMessageWithoutRank("The total amount of fixed supply is : 0.0 MW", "network.modification.TotalAmountFixedSupply", report); + assertLogMessageWithoutRank("The HVDC balance is : -90.0 MW", "network.modification.TotalOutwardHvdcFlow", report); + assertLogMessageWithoutRank("The total amount of supply to be dispatched is : 330.0 MW", "network.modification.TotalAmountSupplyToBeDispatched", report); + assertLogMessageWithoutRank("Marginal cost: 150.0", "network.modification.MaxUsedMarginalCost", report); + assertLogMessageWithoutRank("The supply-demand balance could be met", "network.modification.SupplyDemandBalanceCouldBeMet", report); + assertLogMessageWithoutRank("Sum of generator active power setpoints in WEST region: 330.0 MW (NUCLEAR: 0.0 MW, THERMAL: 0.0 MW, HYDRO: 330.0 MW, WIND AND SOLAR: 0.0 MW, OTHER: 0.0 MW).", "network.modification.SumGeneratorActivePower", report); } @Test @@ -311,7 +324,9 @@ void testGenerationDispatchGeneratorsWithFixedSupply() throws Exception { GenerationDispatch modif = (GenerationDispatch) modification.toModification(); modif.initApplicationContext(filterService); - ReportNode report = modification.createSubReportNode(ReportNode.newRootReportNode().withMessageTemplate("", "").build()); + ReportNode report = modification.createSubReportNode(ReportNode.newRootReportNode() + .withResourceBundles("i18n.reports") + .withMessageTemplate("test").build()); modif.apply(getNetwork(), report); assertEquals(74.82, getNetwork().getGenerator(GH1_ID).getTargetP(), 0.001); @@ -327,27 +342,27 @@ void testGenerationDispatchGeneratorsWithFixedSupply() throws Exception { assertEquals(5., getNetwork().getGenerator(NEW_GROUP1_ID).getTargetP(), 0.001); // not modified : not in main connected component assertEquals(7., getNetwork().getGenerator(NEW_GROUP2_ID).getTargetP(), 0.001); // not modified : not in main connected component - assertLogMessage("Generators without outage simulation: Cannot find 2 generators in filter filter3", "filterGeneratorsNotFoundgeneratorsWithoutOutage", report); - assertLogMessage("Generators without outage simulation: Cannot find generator notFoundGen1 in filter filter3", "generatorNotFoundnotFoundGen1generatorsWithoutOutage", report); - assertLogMessage("Generators without outage simulation: Cannot find generator notFoundGen2 in filter filter3", "generatorNotFoundnotFoundGen2generatorsWithoutOutage", report); - assertLogMessage("Generators with fixed active power: Cannot find 1 generators in filter filter1", "filterGeneratorsNotFoundgeneratorsWithFixedSupply", report); - assertLogMessage("Generators with fixed active power: Cannot find generator notFoundGen1 in filter filter1", "generatorNotFoundnotFoundGen1generatorsWithFixedSupply", report); + assertLogMessage("Generators without outage simulation: Cannot find 2 generators in filter filter3", "network.modification.filterGeneratorsNotFound.generatorsWithoutOutage", report); + assertLogMessage("Generators without outage simulation: Cannot find generator notFoundGen1 in filter filter3", "network.modification.generatorNotFound.generatorsWithoutOutage", report); + assertLogMessageWithoutRank("Generators without outage simulation: Cannot find generator notFoundGen2 in filter filter3", "network.modification.generatorNotFound.generatorsWithoutOutage", report); + assertLogMessage("Generators with fixed active power: Cannot find 1 generators in filter filter1", "network.modification.filterGeneratorsNotFound.generatorsWithFixedSupply", report); + assertLogMessage("Generators with fixed active power: Cannot find generator notFoundGen1 in filter filter1", "network.modification.generatorNotFound.generatorsWithFixedSupply", report); // test total demand and remaining power imbalance on synchronous components - int firstSynchronousComponentNum = getNetwork().getGenerator(GTH1_ID).getTerminal().getBusView().getBus().getSynchronousComponent().getNum(); // GTH1 is in first synchronous component - assertLogMessage("The total demand is : 60.0 MW", "TotalDemand" + firstSynchronousComponentNum, report); - assertLogMessage("The total amount of fixed supply is : 90.0 MW", "TotalAmountFixedSupply" + firstSynchronousComponentNum, report); - assertLogMessage("The HVDC balance is : 90.0 MW", "TotalOutwardHvdcFlow" + firstSynchronousComponentNum, report); - assertLogMessage("The total amount of fixed supply exceeds the total demand", "TotalAmountFixedSupplyExceedsTotalDemand" + firstSynchronousComponentNum, report); - - int secondSynchronousComponentNum = getNetwork().getGenerator(GH1_ID).getTerminal().getBusView().getBus().getSynchronousComponent().getNum(); // GH1 is in second synchronous component - assertLogMessage("The total demand is : 240.0 MW", "TotalDemand" + secondSynchronousComponentNum, report); - assertLogMessage("The total amount of fixed supply is : 0.0 MW", "TotalAmountFixedSupply" + secondSynchronousComponentNum, report); - assertLogMessage("The HVDC balance is : -90.0 MW", "TotalOutwardHvdcFlow" + secondSynchronousComponentNum, report); - assertLogMessage("The total amount of supply to be dispatched is : 330.0 MW", "TotalAmountSupplyToBeDispatched" + secondSynchronousComponentNum, report); - assertLogMessage("Marginal cost: 150.0", "MaxUsedMarginalCost" + secondSynchronousComponentNum, report); - assertLogMessage("The supply-demand balance could be met", "SupplyDemandBalanceCouldBeMet" + secondSynchronousComponentNum, report); - assertLogMessage("Sum of generator active power setpoints in EAST region: 330.0 MW (NUCLEAR: 0.0 MW, THERMAL: 0.0 MW, HYDRO: 330.0 MW, WIND AND SOLAR: 0.0 MW, OTHER: 0.0 MW).", "SumGeneratorActivePowerEAST" + secondSynchronousComponentNum, report); + // GTH1 is in first synchronous component + assertLogMessage("The total demand is : 60.0 MW", "network.modification.TotalDemand", report); + assertLogMessage("The total amount of fixed supply is : 90.0 MW", "network.modification.TotalAmountFixedSupply", report); + assertLogMessage("The HVDC balance is : 90.0 MW", "network.modification.TotalOutwardHvdcFlow", report); + assertLogMessage("The total amount of fixed supply exceeds the total demand", "network.modification.TotalAmountFixedSupplyExceedsTotalDemand", report); + + // GH1 is in second synchronous component + assertLogMessageWithoutRank("The total demand is : 240.0 MW", "network.modification.TotalDemand", report); + assertLogMessageWithoutRank("The total amount of fixed supply is : 0.0 MW", "network.modification.TotalAmountFixedSupply", report); + assertLogMessageWithoutRank("The HVDC balance is : -90.0 MW", "network.modification.TotalOutwardHvdcFlow", report); + assertLogMessageWithoutRank("The total amount of supply to be dispatched is : 330.0 MW", "network.modification.TotalAmountSupplyToBeDispatched", report); + assertLogMessageWithoutRank("Marginal cost: 150.0", "network.modification.MaxUsedMarginalCost", report); + assertLogMessageWithoutRank("The supply-demand balance could be met", "network.modification.SupplyDemandBalanceCouldBeMet", report); + assertLogMessageWithoutRank("Sum of generator active power setpoints in EAST region: 330.0 MW (NUCLEAR: 0.0 MW, THERMAL: 0.0 MW, HYDRO: 330.0 MW, WIND AND SOLAR: 0.0 MW, OTHER: 0.0 MW).", "network.modification.SumGeneratorActivePower", report); } private static List getGeneratorsFiltersInfosWithFilters123() { @@ -399,7 +414,9 @@ void testGenerationDispatchWithFrequencyReserve() throws Exception { GenerationDispatch modif = (GenerationDispatch) modification.toModification(); modif.initApplicationContext(filterService); - ReportNode report = modification.createSubReportNode(ReportNode.newRootReportNode().withMessageTemplate("", "").build()); + ReportNode report = modification.createSubReportNode(ReportNode.newRootReportNode() + .withResourceBundles("i18n.reports") + .withMessageTemplate("test").build()); modif.apply(getNetwork(), report); assertEquals(74.82, getNetwork().getGenerator(GH1_ID).getTargetP(), 0.001); @@ -416,21 +433,21 @@ void testGenerationDispatchWithFrequencyReserve() throws Exception { assertEquals(7., getNetwork().getGenerator(NEW_GROUP2_ID).getTargetP(), 0.001); // not modified : not in main connected component // test total demand and remaining power imbalance on synchronous components - int firstSynchronousComponentNum = getNetwork().getGenerator(GTH1_ID).getTerminal().getBusView().getBus().getSynchronousComponent().getNum(); // GTH1 is in first synchronous component - assertLogMessage("The total demand is : 528.0 MW", "TotalDemand" + firstSynchronousComponentNum, report); - assertLogMessage("The total amount of fixed supply is : 0.0 MW", "TotalAmountFixedSupply" + firstSynchronousComponentNum, report); - assertLogMessage("The HVDC balance is : 90.0 MW", "TotalOutwardHvdcFlow" + firstSynchronousComponentNum, report); - assertLogMessage("The total amount of supply to be dispatched is : 438.0 MW", "TotalAmountSupplyToBeDispatched" + firstSynchronousComponentNum, report); - assertLogMessage("The supply-demand balance could not be met : the remaining power imbalance is 177.9 MW", "SupplyDemandBalanceCouldNotBeMet" + firstSynchronousComponentNum, report); - - int secondSynchronousComponentNum = getNetwork().getGenerator(GH1_ID).getTerminal().getBusView().getBus().getSynchronousComponent().getNum(); // GH1 is in second synchronous component - assertLogMessage("The total demand is : 240.0 MW", "TotalDemand" + secondSynchronousComponentNum, report); - assertLogMessage("The total amount of fixed supply is : 0.0 MW", "TotalAmountFixedSupply" + secondSynchronousComponentNum, report); - assertLogMessage("The HVDC balance is : -90.0 MW", "TotalOutwardHvdcFlow" + secondSynchronousComponentNum, report); - assertLogMessage("The total amount of supply to be dispatched is : 330.0 MW", "TotalAmountSupplyToBeDispatched" + secondSynchronousComponentNum, report); - assertLogMessage("Marginal cost: 150.0", "MaxUsedMarginalCost" + secondSynchronousComponentNum, report); - assertLogMessage("The supply-demand balance could be met", "SupplyDemandBalanceCouldBeMet" + secondSynchronousComponentNum, report); - assertLogMessage("Sum of generator active power setpoints in WEST region: 330.0 MW (NUCLEAR: 0.0 MW, THERMAL: 0.0 MW, HYDRO: 330.0 MW, WIND AND SOLAR: 0.0 MW, OTHER: 0.0 MW).", "SumGeneratorActivePowerWEST" + secondSynchronousComponentNum, report); + // GTH1 is in first synchronous component + assertLogMessage("The total demand is : 528.0 MW", "network.modification.TotalDemand", report); + assertLogMessage("The total amount of fixed supply is : 0.0 MW", "network.modification.TotalAmountFixedSupply", report); + assertLogMessage("The HVDC balance is : 90.0 MW", "network.modification.TotalOutwardHvdcFlow", report); + assertLogMessage("The total amount of supply to be dispatched is : 438.0 MW", "network.modification.TotalAmountSupplyToBeDispatched", report); + assertLogMessage("The supply-demand balance could not be met : the remaining power imbalance is 177.9 MW", "network.modification.SupplyDemandBalanceCouldNotBeMet", report); + + // GH1 is in second synchronous component + assertLogMessageWithoutRank("The total demand is : 240.0 MW", "network.modification.TotalDemand", report); + assertLogMessageWithoutRank("The total amount of fixed supply is : 0.0 MW", "network.modification.TotalAmountFixedSupply", report); + assertLogMessageWithoutRank("The HVDC balance is : -90.0 MW", "network.modification.TotalOutwardHvdcFlow", report); + assertLogMessageWithoutRank("The total amount of supply to be dispatched is : 330.0 MW", "network.modification.TotalAmountSupplyToBeDispatched", report); + assertLogMessageWithoutRank("Marginal cost: 150.0", "network.modification.MaxUsedMarginalCost", report); + assertLogMessageWithoutRank("The supply-demand balance could be met", "network.modification.SupplyDemandBalanceCouldBeMet", report); + assertLogMessageWithoutRank("Sum of generator active power setpoints in WEST region: 330.0 MW (NUCLEAR: 0.0 MW, THERMAL: 0.0 MW, HYDRO: 330.0 MW, WIND AND SOLAR: 0.0 MW, OTHER: 0.0 MW).", "network.modification.SumGeneratorActivePower", report); } @Test @@ -545,31 +562,33 @@ void testGenerationDispatchWithMaxValueLessThanMinP() throws Exception { GenerationDispatch modif = (GenerationDispatch) modification.toModification(); modif.initApplicationContext(filterService); - ReportNode report = modification.createSubReportNode(ReportNode.newRootReportNode().withMessageTemplate("", "").build()); + ReportNode report = modification.createSubReportNode(ReportNode.newRootReportNode() + .withResourceBundles("i18n.reports") + .withMessageTemplate("test").build()); modif.apply(getNetwork(), report); // check logs - int firstSynchronousComponentNum = getNetwork().getGenerator(GTH1_ID).getTerminal().getBusView().getBus().getSynchronousComponent().getNum(); // GTH1 is in first synchronous component - assertLogMessage("The total demand is : 528.0 MW", "TotalDemand" + firstSynchronousComponentNum, report); - assertLogMessage("The total amount of fixed supply is : 0.0 MW", "TotalAmountFixedSupply" + firstSynchronousComponentNum, report); - assertLogMessage("The HVDC balance is : 90.0 MW", "TotalOutwardHvdcFlow" + firstSynchronousComponentNum, report); - assertLogMessage("The total amount of supply to be dispatched is : 438.0 MW", "TotalAmountSupplyToBeDispatched" + firstSynchronousComponentNum, report); - assertLogNthMessage("The active power set point of generator TEST1 has been set to 40.4 MW", "GeneratorSetTargetP" + firstSynchronousComponentNum, report, 1); - assertLogNthMessage("The active power set point of generator GTH1 has been set to 80.0 MW", "GeneratorSetTargetP" + firstSynchronousComponentNum, report, 2); - assertLogNthMessage("The active power set point of generator GTH2 has been set to 146.0 MW", "GeneratorSetTargetP" + firstSynchronousComponentNum, report, 3); - assertLogMessage("The supply-demand balance could not be met : the remaining power imbalance is 171.6 MW", "SupplyDemandBalanceCouldNotBeMet" + firstSynchronousComponentNum, report); - int secondSynchronousComponentNum = getNetwork().getGenerator(GH1_ID).getTerminal().getBusView().getBus().getSynchronousComponent().getNum(); // GH1 is in second synchronous component - assertLogMessage("The total demand is : 240.0 MW", "TotalDemand" + secondSynchronousComponentNum, report); - assertLogMessage("The total amount of fixed supply is : 0.0 MW", "TotalAmountFixedSupply" + secondSynchronousComponentNum, report); - assertLogMessage("The HVDC balance is : -90.0 MW", "TotalOutwardHvdcFlow" + secondSynchronousComponentNum, report); - assertLogMessage("The total amount of supply to be dispatched is : 330.0 MW", "TotalAmountSupplyToBeDispatched" + secondSynchronousComponentNum, report); - assertLogNthMessage("The active power set point of generator GH1 has been set to 80.0 MW", "GeneratorSetTargetP" + secondSynchronousComponentNum, report, 1); - assertLogNthMessage("The active power set point of generator GH2 has been set to 60.0 MW", "GeneratorSetTargetP" + secondSynchronousComponentNum, report, 2); - assertLogNthMessage("The active power set point of generator GH3 has been set to 126.1 MW", "GeneratorSetTargetP" + secondSynchronousComponentNum, report, 3); - assertLogNthMessage("The active power set point of generator ABC has been set to 63.9 MW", "GeneratorSetTargetP" + secondSynchronousComponentNum, report, 4); - assertLogMessage("Marginal cost: 150.0", "MaxUsedMarginalCost" + secondSynchronousComponentNum, report); - assertLogMessage("The supply-demand balance could be met", "SupplyDemandBalanceCouldBeMet" + secondSynchronousComponentNum, report); - assertLogMessage("Sum of generator active power setpoints in NORTH region: 330.0 MW (NUCLEAR: 0.0 MW, THERMAL: 0.0 MW, HYDRO: 330.0 MW, WIND AND SOLAR: 0.0 MW, OTHER: 0.0 MW).", "SumGeneratorActivePowerNORTH" + secondSynchronousComponentNum, report); + // GTH1 is in first synchronous component + assertLogMessage("The total demand is : 528.0 MW", "network.modification.TotalDemand", report); + assertLogMessage("The total amount of fixed supply is : 0.0 MW", "network.modification.TotalAmountFixedSupply", report); + assertLogMessage("The HVDC balance is : 90.0 MW", "network.modification.TotalOutwardHvdcFlow", report); + assertLogMessage("The total amount of supply to be dispatched is : 438.0 MW", "network.modification.TotalAmountSupplyToBeDispatched", report); + assertLogNthMessage("The active power set point of generator TEST1 has been set to 40.4 MW", "network.modification.GeneratorSetTargetP", report, 1); + assertLogNthMessage("The active power set point of generator GTH1 has been set to 80.0 MW", "network.modification.GeneratorSetTargetP", report, 2); + assertLogNthMessage("The active power set point of generator GTH2 has been set to 146.0 MW", "network.modification.GeneratorSetTargetP", report, 3); + assertLogMessage("The supply-demand balance could not be met : the remaining power imbalance is 171.6 MW", "network.modification.SupplyDemandBalanceCouldNotBeMet", report); + // GH1 is in second synchronous component + assertLogMessageWithoutRank("The total demand is : 240.0 MW", "network.modification.TotalDemand", report); + assertLogMessageWithoutRank("The total amount of fixed supply is : 0.0 MW", "network.modification.TotalAmountFixedSupply", report); + assertLogMessageWithoutRank("The HVDC balance is : -90.0 MW", "network.modification.TotalOutwardHvdcFlow", report); + assertLogMessageWithoutRank("The total amount of supply to be dispatched is : 330.0 MW", "network.modification.TotalAmountSupplyToBeDispatched", report); + assertLogMessageWithoutRank("The active power set point of generator GH1 has been set to 80.0 MW", "network.modification.GeneratorSetTargetP", report); + assertLogMessageWithoutRank("The active power set point of generator GH2 has been set to 60.0 MW", "network.modification.GeneratorSetTargetP", report); + assertLogMessageWithoutRank("The active power set point of generator GH3 has been set to 126.1 MW", "network.modification.GeneratorSetTargetP", report); + assertLogMessageWithoutRank("The active power set point of generator ABC has been set to 63.9 MW", "network.modification.GeneratorSetTargetP", report); + assertLogMessageWithoutRank("Marginal cost: 150.0", "network.modification.MaxUsedMarginalCost", report); + assertLogMessageWithoutRank("The supply-demand balance could be met", "network.modification.SupplyDemandBalanceCouldBeMet", report); + assertLogMessageWithoutRank("Sum of generator active power setpoints in NORTH region: 330.0 MW (NUCLEAR: 0.0 MW, THERMAL: 0.0 MW, HYDRO: 330.0 MW, WIND AND SOLAR: 0.0 MW, OTHER: 0.0 MW).", "network.modification.SumGeneratorActivePower", report); } @Override diff --git a/src/test/java/org/gridsuite/modification/modifications/GeneratorCreationInNodeBreakerTest.java b/src/test/java/org/gridsuite/modification/modifications/GeneratorCreationInNodeBreakerTest.java index 73b6e80..a98c7e4 100644 --- a/src/test/java/org/gridsuite/modification/modifications/GeneratorCreationInNodeBreakerTest.java +++ b/src/test/java/org/gridsuite/modification/modifications/GeneratorCreationInNodeBreakerTest.java @@ -213,9 +213,11 @@ void testCreateWithShortCircuitErrors() { GeneratorCreationInfos generatorCreationInfos = (GeneratorCreationInfos) buildModification(); generatorCreationInfos.setDirectTransX(Double.NaN); - ReportNode report = generatorCreationInfos.createSubReportNode(ReportNode.newRootReportNode().withMessageTemplate("", "").build()); + ReportNode report = generatorCreationInfos.createSubReportNode(ReportNode.newRootReportNode() + .withResourceBundles("i18n.reports") + .withMessageTemplate("test").build()); generatorCreationInfos.toModification().apply(getNetwork(), report); - assertLogMessage("cannot add short-circuit extension on generator with id=idGenerator1 : Undefined directTransX", "ShortCircuitExtensionAddError", report); + assertLogMessage("cannot add short-circuit extension on generator with id=idGenerator1 : Undefined directTransX", "network.modification.ShortCircuitExtensionAddError", report); } @Override diff --git a/src/test/java/org/gridsuite/modification/modifications/GeneratorScalingTest.java b/src/test/java/org/gridsuite/modification/modifications/GeneratorScalingTest.java index 90e2bca..234bd48 100644 --- a/src/test/java/org/gridsuite/modification/modifications/GeneratorScalingTest.java +++ b/src/test/java/org/gridsuite/modification/modifications/GeneratorScalingTest.java @@ -168,10 +168,12 @@ void testFilterWithWrongIds() throws Exception { GeneratorScaling generatorScaling = (GeneratorScaling) generatorScalingInfo.toModification(); generatorScaling.initApplicationContext(filterService); - ReportNode report = generatorScalingInfo.createSubReportNode(ReportNode.newRootReportNode().withMessageTemplate("", "").build()); + ReportNode report = generatorScalingInfo.createSubReportNode(ReportNode.newRootReportNode() + .withResourceBundles("i18n.reports") + .withMessageTemplate("test").build()); generatorScaling.apply(getNetwork(), report); assertLogMessage(generatorScalingInfo.getErrorType().name() + ": There is no valid equipment ID among the provided filter(s)", - "invalidFilters", report); + "network.modification.invalidFilters", report); } @Test diff --git a/src/test/java/org/gridsuite/modification/modifications/LoadScalingTest.java b/src/test/java/org/gridsuite/modification/modifications/LoadScalingTest.java index 4785d1c..93065e0 100644 --- a/src/test/java/org/gridsuite/modification/modifications/LoadScalingTest.java +++ b/src/test/java/org/gridsuite/modification/modifications/LoadScalingTest.java @@ -170,10 +170,12 @@ void testFilterWithWrongIds() throws Exception { .build(); LoadScaling loadScaling = (LoadScaling) loadScalingInfo.toModification(); loadScaling.initApplicationContext(filterService); - ReportNode report = loadScalingInfo.createSubReportNode(ReportNode.newRootReportNode().withMessageTemplate("", "").build()); + ReportNode report = loadScalingInfo.createSubReportNode(ReportNode.newRootReportNode() + .withResourceBundles("i18n.reports") + .withMessageTemplate("test").build()); loadScaling.apply(getNetwork(), report); assertLogMessage(loadScalingInfo.getErrorType().name() + ": There is no valid equipment ID among the provided filter(s)", - "invalidFilters", report); + "network.modification.invalidFilters", report); } @Test diff --git a/src/test/java/org/gridsuite/modification/modifications/StaticVarCompensatorCreationInNodeBreakerTest.java b/src/test/java/org/gridsuite/modification/modifications/StaticVarCompensatorCreationInNodeBreakerTest.java index e935f90..58074e1 100644 --- a/src/test/java/org/gridsuite/modification/modifications/StaticVarCompensatorCreationInNodeBreakerTest.java +++ b/src/test/java/org/gridsuite/modification/modifications/StaticVarCompensatorCreationInNodeBreakerTest.java @@ -166,10 +166,12 @@ protected void checkModification() { compensatorCreationInfos1.setLowVoltageThreshold(250.0); compensatorCreationInfos1.setHighVoltageThreshold(300.0); compensatorCreationInfos1.setQ0(Double.NaN); - ReportNode report = compensatorCreationInfos1.createSubReportNode(ReportNode.newRootReportNode().withMessageTemplate("", "").build()); + ReportNode report = compensatorCreationInfos1.createSubReportNode(ReportNode.newRootReportNode() + .withResourceBundles("i18n.reports") + .withMessageTemplate("test").build()); compensatorCreationInfos1.toModification().apply(getNetwork(), report); assertLogMessage("Cannot add standby automaton extension on Static var compensator 'idStaticVarCompensator1': b0 is invalid", - "StandbyAutomatonExtensionAddError", report); + "network.modification.StandbyAutomatonExtensionAddError", report); StaticVarCompensatorCreationInfos compensatorCreationInfos2 = (StaticVarCompensatorCreationInfos) buildModification(); compensatorCreationInfos2.setEquipmentId("idStaticVarCompensator2"); compensatorCreationInfos2.setStandbyAutomatonOn(true); diff --git a/src/test/java/org/gridsuite/modification/modifications/VoltageInitModificationTest.java b/src/test/java/org/gridsuite/modification/modifications/VoltageInitModificationTest.java index 3092695..ee2d23a 100644 --- a/src/test/java/org/gridsuite/modification/modifications/VoltageInitModificationTest.java +++ b/src/test/java/org/gridsuite/modification/modifications/VoltageInitModificationTest.java @@ -219,7 +219,9 @@ private ReportNode testVoltageInitShunt(String shuntCompensatorId, int currentSe .connect(connect) .build())) .build(); - ReportNode report = modification.createSubReportNode(ReportNode.newRootReportNode().withMessageTemplate("", "").build()); + ReportNode report = modification.createSubReportNode(ReportNode.newRootReportNode() + .withResourceBundles("i18n.reports") + .withMessageTemplate("test").build()); modification.toModification().apply(getNetwork(), report); return report; } @@ -227,33 +229,33 @@ private ReportNode testVoltageInitShunt(String shuntCompensatorId, int currentSe @Test void testVoltageInitConnectedSectionCountNull() throws Exception { ReportNode report = testVoltageInitShunt("v2shunt", 0, null, false); - assertLogMessage("Section count value is undefined", "shuntCompensatorSectionCountUndefined", report); + assertLogMessage("Section count value is undefined", "network.modification.shuntCompensatorSectionCountUndefined", report); } @Test void testVoltageInitConnectedCurrentSection0Section0() throws Exception { ReportNode report = testVoltageInitShunt("v2shunt", 0, 0, false); - assertLogMessage("Shunt compensator disconnected", "shuntCompensatorDisconnected", report); + assertLogMessage("Shunt compensator disconnected", "network.modification.shuntCompensatorDisconnected", report); } @Test void testVoltageInitDisconnectedConnectNull() throws Exception { ReportNode report = testVoltageInitShunt("v5shunt", 0, 0, null); - assertLogMessage("Connect value is undefined", "shuntCompensatorConnectUndefined", report); + assertLogMessage("Connect value is undefined", "network.modification.shuntCompensatorConnectUndefined", report); } @Test void testVoltageInitDisconnectedCurrentSection0Section2() throws Exception { ReportNode report = testVoltageInitShunt("v5shunt", 0, 2, true); - assertLogMessage("Shunt compensator reconnected", "shuntCompensatorReconnected", report); - assertLogMessage("Section count : 0 → 2", "modification-indent1", report); + assertLogMessage("Shunt compensator reconnected", "network.modification.shuntCompensatorReconnected", report); + assertLogMessage("Section count : 0 → 2", "network.modification.fieldModification", report); assertEquals(2, getNetwork().getShuntCompensator("v5shunt").getSectionCount()); } @Test void testVoltageInitDisconnectedCurrentSection1Section1() throws Exception { ReportNode report = testVoltageInitShunt("v5shunt", 1, 1, true); - assertLogMessage("Shunt compensator reconnected", "shuntCompensatorReconnected", report); + assertLogMessage("Shunt compensator reconnected", "network.modification.shuntCompensatorReconnected", report); assertEquals(1, getNetwork().getShuntCompensator("v5shunt").getSectionCount()); } diff --git a/src/test/java/org/gridsuite/modification/modifications/VoltageLevelTopologyModificationTest.java b/src/test/java/org/gridsuite/modification/modifications/VoltageLevelTopologyModificationTest.java index 4de76a5..43cbecc 100644 --- a/src/test/java/org/gridsuite/modification/modifications/VoltageLevelTopologyModificationTest.java +++ b/src/test/java/org/gridsuite/modification/modifications/VoltageLevelTopologyModificationTest.java @@ -174,10 +174,12 @@ private void testCheckLogMessages() { .equipmentAttributeModificationList(equipmentAttributeModifications) .build(); - ReportNode report = modificationInfos.createSubReportNode(ReportNode.newRootReportNode().withMessageTemplate("", "").build()); + ReportNode report = modificationInfos.createSubReportNode(ReportNode.newRootReportNode() + .withResourceBundles("i18n.reports") + .withMessageTemplate("test").build()); assertEquals("Voltage Level topology modification v1", report.getMessage()); modificationInfos.toModification().apply(getNetwork(), report); - assertLogMessage("Voltage level 'v1' topology has been modified", "voltageLevelTopologyModified", report); + assertLogMessage("Voltage level 'v1' topology has been modified", "network.modification.voltageLevelTopologyModified", report); } @Override diff --git a/src/test/java/org/gridsuite/modification/modifications/byfilterdeletion/AbstractByFilterDeletionTest.java b/src/test/java/org/gridsuite/modification/modifications/byfilterdeletion/AbstractByFilterDeletionTest.java index 94d0d2a..bb3e569 100644 --- a/src/test/java/org/gridsuite/modification/modifications/byfilterdeletion/AbstractByFilterDeletionTest.java +++ b/src/test/java/org/gridsuite/modification/modifications/byfilterdeletion/AbstractByFilterDeletionTest.java @@ -90,11 +90,13 @@ protected void checkModification() { ByFilterDeletion byFilterDeletion = (ByFilterDeletion) byFilterDeletionInfos.toModification(); byFilterDeletion.initApplicationContext(filterService); - ReportNode report = byFilterDeletionInfos.createSubReportNode(ReportNode.newRootReportNode().withMessageTemplate("", "").build()); + ReportNode report = byFilterDeletionInfos.createSubReportNode(ReportNode.newRootReportNode() + .withResourceBundles("i18n.reports") + .withMessageTemplate("test").build()); byFilterDeletion.apply(getNetwork(), report); assertLogMessage("Cannot find the following equipments " + EQUIPMENT_WRONG_ID_1 + " in filter filter1", - "filterEquipmentsNotFound_filter1", report); + "network.modification.filterEquipmentsNotFound.inFilter", report); } @Test @@ -117,10 +119,12 @@ void testCreateAllFiltersWrong() throws Exception { ByFilterDeletion byFilterDeletion = (ByFilterDeletion) byFilterDeletionInfos.toModification(); byFilterDeletion.initApplicationContext(filterService); - ReportNode report = byFilterDeletionInfos.createSubReportNode(ReportNode.newRootReportNode().withMessageTemplate("", "").build()); + ReportNode report = byFilterDeletionInfos.createSubReportNode(ReportNode.newRootReportNode() + .withResourceBundles("i18n.reports") + .withMessageTemplate("test").build()); byFilterDeletion.apply(getNetwork(), report); assertLogMessage(byFilterDeletionInfos.getErrorType().name() + ": There is no valid equipment ID among the provided filter(s)", - "invalidFilters", report); + "network.modification.invalidFilters", report); } @Override diff --git a/src/test/java/org/gridsuite/modification/modifications/tabularcreations/TabularGeneratorCreationsTest.java b/src/test/java/org/gridsuite/modification/modifications/tabularcreations/TabularGeneratorCreationsTest.java index 51c8539..fe70167 100644 --- a/src/test/java/org/gridsuite/modification/modifications/tabularcreations/TabularGeneratorCreationsTest.java +++ b/src/test/java/org/gridsuite/modification/modifications/tabularcreations/TabularGeneratorCreationsTest.java @@ -138,9 +138,11 @@ void testAllModificationsHaveSucceeded() throws Exception { .creationType(ModificationType.GENERATOR_CREATION) .creations(creations) .build(); - ReportNode reportNode = creationInfos.createSubReportNode(ReportNode.newRootReportNode().withMessageTemplate("", "").build()); + ReportNode reportNode = creationInfos.createSubReportNode(ReportNode.newRootReportNode() + .withResourceBundles("i18n.reports") + .withMessageTemplate("test").build()); creationInfos.toModification().apply(getNetwork(), reportNode); - assertLogMessage("Tabular creation: 2 generators have been created", "tabularGENERATOR_CREATION", reportNode); + assertLogMessage("Tabular creation: 2 generators have been created", "network.modification.tabular.creation", reportNode); } @Test @@ -184,9 +186,11 @@ void testAllModificationsHaveFailed() throws Exception { .creationType(ModificationType.GENERATOR_CREATION) .creations(creations) .build(); - ReportNode reportNode = creationInfos.createSubReportNode(ReportNode.newRootReportNode().withMessageTemplate("", "").build()); + ReportNode reportNode = creationInfos.createSubReportNode(ReportNode.newRootReportNode() + .withResourceBundles("i18n.reports") + .withMessageTemplate("test").build()); creationInfos.toModification().apply(getNetwork(), reportNode); - assertLogMessage("Tabular creation: No generators have been created", "tabularGENERATOR_CREATIONError", reportNode); + assertLogMessage("Tabular creation: No generators have been created", "network.modification.tabular.creation.error", reportNode); } @Override diff --git a/src/test/java/org/gridsuite/modification/modifications/tabularmodifications/TabularShuntCompensatorModificationsTest.java b/src/test/java/org/gridsuite/modification/modifications/tabularmodifications/TabularShuntCompensatorModificationsTest.java index d16cf9c..1af4941 100644 --- a/src/test/java/org/gridsuite/modification/modifications/tabularmodifications/TabularShuntCompensatorModificationsTest.java +++ b/src/test/java/org/gridsuite/modification/modifications/tabularmodifications/TabularShuntCompensatorModificationsTest.java @@ -102,7 +102,8 @@ void testCheckModificationConflict() { when(shuntCompensator.getModelType()).thenReturn(ShuntCompensatorModelType.LINEAR); when(shuntCompensator.getId()).thenReturn("id"); ReportNode reportNode = ReportNode.newRootReportNode() - .withMessageTemplate("test", "test") + .withResourceBundles("i18n.reports") + .withMessageTemplate("test") .build(); tabularModification.checkShuntCompensatorModification(network, shuntModification, reportNode); @@ -137,7 +138,8 @@ void testCheckModificationNonLinear() { when(shuntCompensator.getId()).thenReturn("id"); ReportNode reportNode = ReportNode.newRootReportNode() - .withMessageTemplate("test", "test") + .withResourceBundles("i18n.reports") + .withMessageTemplate("test") .build(); tabularModification.checkShuntCompensatorModification(network, shuntModification, reportNode); @@ -165,7 +167,8 @@ void testCheckModificationOK() { when(shuntCompensator.getModelType()).thenReturn(ShuntCompensatorModelType.LINEAR); when(shuntCompensator.getId()).thenReturn("id"); ReportNode reportNode = ReportNode.newRootReportNode() - .withMessageTemplate("test", "test") + .withResourceBundles("i18n.reports") + .withMessageTemplate("test") .build(); tabularModification.checkShuntCompensatorModification(network, shuntModification, reportNode); diff --git a/src/test/resources/i18n/reports.properties b/src/test/resources/i18n/reports.properties new file mode 100644 index 0000000..4c7feaf --- /dev/null +++ b/src/test/resources/i18n/reports.properties @@ -0,0 +1,32 @@ +network.modification.GeneratorSetTargetP = The active power set point of generator ${generator} has been set to ${newValue} MW +network.modification.MaxUsedMarginalCost = Marginal cost: ${maxUsedMarginalCost} +network.modification.PowerToDispatch = PowerToDispatch +network.modification.Result = Result +network.modification.ShortCircuitExtensionAddError = cannot add short-circuit extension on generator with id=${id} : ${message} +network.modification.Stacking = Stacking +network.modification.StandbyAutomatonExtensionAddError = Cannot add standby automaton extension on ${message} +network.modification.SumGeneratorActivePower = Sum of generator active power setpoints in ${region} region: ${sum} MW (NUCLEAR: ${nuclearSum} MW, THERMAL: ${thermalSum} MW, HYDRO: ${hydroSum} MW, WIND AND SOLAR: ${windAndSolarSum} MW, OTHER: ${otherSum} MW). +network.modification.SupplyDemandBalanceCouldBeMet = The supply-demand balance could be met +network.modification.SupplyDemandBalanceCouldNotBeMet = The supply-demand balance could not be met : the remaining power imbalance is ${remainingPower} MW +network.modification.TotalActiveBatteryTargetP = The battery balance is : ${batteryBalance} MW +network.modification.TotalAmountFixedSupply = The total amount of fixed supply is : ${totalAmountFixedSupply} MW +network.modification.TotalAmountFixedSupplyExceedsTotalDemand = The total amount of fixed supply exceeds the total demand +network.modification.TotalAmountSupplyToBeDispatched = The total amount of supply to be dispatched is : ${totalAmountSupplyToBeDispatched} MW +network.modification.TotalDemand = The total demand is : ${totalDemand} MW +network.modification.TotalOutwardHvdcFlow = The HVDC balance is : ${hvdcBalance} MW +network.modification.VOLTAGE_LEVEL_TOPOLOGY_MODIFICATION = Voltage Level topology modification ${voltageLevelId} +network.modification.fieldModification = ${fieldName} : ${oldValue} ${arrow} ${newValue} +network.modification.filterEquipmentsNotFound.inFilter = Cannot find the following equipments ${equipmentIds} in filter ${filters} +network.modification.filterGeneratorsNotFound.generatorsWithFixedSupply = Generators with fixed active power: Cannot find ${nbNotFoundGen} generators in filter ${filterName} +network.modification.filterGeneratorsNotFound.generatorsWithoutOutage = Generators without outage simulation: Cannot find ${nbNotFoundGen} generators in filter ${filterName} +network.modification.generatorNotFound.generatorsWithFixedSupply = Generators with fixed active power: Cannot find generator ${notFoundGeneratorId} in filter ${filterName} +network.modification.generatorNotFound.generatorsWithoutOutage = Generators without outage simulation: Cannot find generator ${notFoundGeneratorId} in filter ${filterName} +network.modification.invalidFilters = ${errorType}: There is no valid equipment ID among the provided filter(s) +network.modification.shuntCompensatorConnectUndefined = Connect value is undefined +network.modification.shuntCompensatorDisconnected = Shunt compensator disconnected +network.modification.shuntCompensatorReconnected = Shunt compensator reconnected +network.modification.shuntCompensatorSectionCountUndefined = Section count value is undefined +network.modification.tabular.creation = Tabular creation: ${creationsCount} ${defaultMessage} +network.modification.tabular.creation.error = Tabular creation: No ${defaultMessage} +network.modification.voltageLevelTopologyModified = Voltage level '${id}' topology has been modified +test = test