Skip to content

Commit

Permalink
Merge branch 'main' into ayolab/remove-hack-and-update-report-management
Browse files Browse the repository at this point in the history
  • Loading branch information
ayolab authored Sep 7, 2024
2 parents e61961c + e4342a1 commit e443292
Show file tree
Hide file tree
Showing 12 changed files with 143 additions and 234 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;

import static org.gridsuite.modification.server.NetworkModificationException.Type.BRANCH_MODIFICATION_ERROR;
Expand All @@ -44,7 +44,7 @@ protected void modifyBranch(Branch<?> branch, BranchModificationInfos branchModi
.withSeverity(TypedValue.INFO_SEVERITY)
.add();
if (branchModificationInfos.getEquipmentName() != null) {
insertReportNode(subReportNode, ModificationUtils.getInstance().buildModificationReportWithIndentation(branch.getOptionalName().isEmpty() ? null : branch.getOptionalName().get(), branchModificationInfos.getEquipmentName().getValue(), "Name", 0));
insertReportNode(subReportNode, ModificationUtils.getInstance().buildModificationReport(Optional.of(branch.getOptionalName()).orElse(null), branchModificationInfos.getEquipmentName().getValue(), "Name", 0));
branch.setName(branchModificationInfos.getEquipmentName().getValue());
}

Expand All @@ -66,14 +66,10 @@ protected void modifyBranch(Branch<?> branch, BranchModificationInfos branchModi
}
if (!side1LimitsReports.isEmpty() || !side2LimitsReports.isEmpty()) {
ReportNode limitsReportNode = subReportNode.newReportNode().withMessageTemplate("limits", "Limits").add();
limitsReportNode.newReportNode()
.withMessageTemplate("limitsModification", "Limits")
.withSeverity(TypedValue.INFO_SEVERITY)
.add();
ModificationUtils.getInstance().reportModifications(limitsReportNode, side1LimitsReports, "side1LimitsModification",
" Side 1", Map.of());
" Side 1");
ModificationUtils.getInstance().reportModifications(limitsReportNode, side2LimitsReports, "side2LimitsModification",
" Side 2", Map.of());
" Side 2");
}

updateConnections(branch, branchModificationInfos);
Expand Down Expand Up @@ -118,7 +114,7 @@ private boolean updateConnection(Branch<?> branch, TwoSides side, Boolean connec
protected void modifyCurrentLimits(CurrentLimitsModificationInfos currentLimitsInfos, CurrentLimitsAdder limitsAdder, CurrentLimits currentLimits, List<ReportNode> limitsReports) {
boolean hasPermanent = currentLimitsInfos.getPermanentLimit() != null;
if (hasPermanent) {
limitsReports.add(ModificationUtils.getInstance().buildModificationReportWithIndentation(currentLimits != null ? currentLimits.getPermanentLimit() : Double.NaN,
limitsReports.add(ModificationUtils.getInstance().buildModificationReport(currentLimits != null ? currentLimits.getPermanentLimit() : Double.NaN,
currentLimitsInfos.getPermanentLimit(), "IST", 2));
limitsAdder.setPermanentLimit(currentLimitsInfos.getPermanentLimit());
} else {
Expand Down Expand Up @@ -206,7 +202,7 @@ protected void modifyTemporaryLimits(CurrentLimitsModificationInfos currentLimit
}
}
if (!temporaryLimitsReports.isEmpty()) {
temporaryLimitsReports.add(ReportNode.newRootReportNode()
temporaryLimitsReports.add(0, ReportNode.newRootReportNode()
.withMessageTemplate("temporaryLimitsModification", " Temporary current limits :")
.withSeverity(TypedValue.INFO_SEVERITY)
.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import static org.gridsuite.modification.server.NetworkModificationException.Type.BATTERY_ALREADY_EXISTS;
import static org.gridsuite.modification.server.modifications.ModificationUtils.nanIfNull;
Expand Down Expand Up @@ -147,7 +146,7 @@ private ReportNode reportBatterySetPoints(BatteryCreationInfos batteryCreationIn
setPointReports.add(ModificationUtils.getInstance()
.buildCreationReport(batteryCreationInfos.getTargetQ(), "Reactive power"));
}
return ModificationUtils.getInstance().reportModifications(subReportNode, setPointReports, "SetPointCreated", "Setpoints", Map.of());
return ModificationUtils.getInstance().reportModifications(subReportNode, setPointReports, "SetPointCreated", "Setpoints");
}

private void reportBatteryConnectivity(BatteryCreationInfos batteryCreationInfos, ReportNode subReportNode) {
Expand Down Expand Up @@ -178,24 +177,18 @@ private void reportBatteryConnectivity(BatteryCreationInfos batteryCreationInfos
.withSeverity(TypedValue.INFO_SEVERITY)
.build());
}
ModificationUtils.getInstance().reportModifications(subReportNode, connectivityReports, "ConnectivityCreated", CONNECTIVITY, Map.of());
ModificationUtils.getInstance().reportModifications(subReportNode, connectivityReports, "ConnectivityCreated", CONNECTIVITY);
}
}

private ReportNode reportBatteryActiveLimits(BatteryCreationInfos batteryCreationInfos, ReportNode subReportNode) {
List<ReportNode> limitsReports = new ArrayList<>();
ReportNode subReportNodeLimits = subReportNode.newReportNode().withMessageTemplate(LIMITS, LIMITS).add();
subReportNodeLimits.newReportNode()
.withMessageTemplate(LIMITS, LIMITS)
.withSeverity(TypedValue.INFO_SEVERITY)
.add();
List<ReportNode> 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, Map.of());
ModificationUtils.getInstance().reportModifications(subReportNodeLimits, limitsReports, "ActiveLimitsCreated", ACTIVE_LIMITS);
return subReportNodeLimits;
}

Expand All @@ -221,7 +214,7 @@ private void createBatteryActivePowerControl(BatteryCreationInfos batteryCreatio
.withSeverity(TypedValue.ERROR_SEVERITY)
.build());
}
ModificationUtils.getInstance().reportModifications(subReporter, activePowerRegulationReports, "ActivePowerRegulationCreated", "Active power regulation", Map.of());
ModificationUtils.getInstance().reportModifications(subReporter, activePowerRegulationReports, "ActivePowerRegulationCreated", "Active power regulation");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,6 @@ private void modifyBatterySetpointsAttributes(BatteryModificationInfos modificat
ReportNode subReporterSetpoints = null;
if (reportActivePower != null || reportReactivePower != null) {
subReporterSetpoints = subReportNode.newReportNode().withMessageTemplate(SETPOINTS, SETPOINTS).add();
subReporterSetpoints.newReportNode()
.withMessageTemplate(SETPOINTS, SETPOINTS)
.withSeverity(TypedValue.INFO_SEVERITY)
.add();
if (reportActivePower != null) {
insertReportNode(subReporterSetpoints, reportActivePower);
}
Expand Down Expand Up @@ -134,16 +130,7 @@ private ReportNode modifyBatteryActiveLimitsAttributes(BatteryModificationInfos
ReportNode reportMinActivePower = ModificationUtils.getInstance().applyElementaryModificationsAndReturnReport(battery::setMinP, battery::getMinP, modificationInfos.getMinP(), "Min active power");
if (reportMaxActivePower != null || reportMinActivePower != null) {
subReportNodeLimits = subReportNode.newReportNode().withMessageTemplate(LIMITS, LIMITS).add();
subReportNodeLimits.newReportNode()
.withMessageTemplate(LIMITS, LIMITS)
.withSeverity(TypedValue.INFO_SEVERITY)
.add();

ReportNode subReporterActiveLimits = subReportNodeLimits.newReportNode().withMessageTemplate(ACTIVE_LIMITS, ACTIVE_LIMITS).add();
subReporterActiveLimits.newReportNode()
.withMessageTemplate(ACTIVE_LIMITS, ACTIVE_LIMITS)
.withSeverity(TypedValue.INFO_SEVERITY)
.add();
if (reportMaxActivePower != null) {
insertReportNode(subReporterActiveLimits, reportMaxActivePower);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,6 @@ public void apply(Network network, ReportNode subReportNode) {
}

private void report(ReportNode formulaSubReportNode, List<ReportNode> formulaReports) {
formulaSubReportNode.newReportNode()
.withMessageTemplate("appliedFormulasModifications", " Formulas")
.withSeverity(TypedValue.INFO_SEVERITY)
.add();
formulaReports.forEach(report -> insertReportNode(formulaSubReportNode, report));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import static org.gridsuite.modification.server.NetworkModificationException.Type.GENERATOR_ALREADY_EXISTS;
import static org.gridsuite.modification.server.modifications.ModificationUtils.nanIfNull;
Expand Down Expand Up @@ -190,7 +189,7 @@ private ReportNode reportGeneratorSetPoints(GeneratorCreationInfos generatorCrea
setPointReports.add(ModificationUtils.getInstance()
.buildCreationReport(generatorCreationInfos.getTargetQ(), "Reactive power"));
}
return ModificationUtils.getInstance().reportModifications(subReportNode, setPointReports, "SetPointCreated", "Setpoints", Map.of());
return ModificationUtils.getInstance().reportModifications(subReportNode, setPointReports, "SetPointCreated", "Setpoints");
}

private void createGeneratorVoltageRegulation(GeneratorCreationInfos generatorCreationInfos, Generator generator, VoltageLevel voltageLevel, ReportNode subReportNode) {
Expand Down Expand Up @@ -222,7 +221,7 @@ private void createGeneratorVoltageRegulation(GeneratorCreationInfos generatorCr
.build());
}
}
ModificationUtils.getInstance().reportModifications(subReportNode, voltageReports, "VoltageRegulationCreated", "Voltage regulation", Map.of());
ModificationUtils.getInstance().reportModifications(subReportNode, voltageReports, "VoltageRegulationCreated", "Voltage regulation");

}

Expand Down Expand Up @@ -270,29 +269,22 @@ private void reportGeneratorConnectivity(GeneratorCreationInfos generatorCreatio
.withSeverity(TypedValue.INFO_SEVERITY)
.build());
}
ModificationUtils.getInstance().reportModifications(subReporter, connectivityReports, "ConnectivityCreated", CONNECTIVITY, Map.of());
ModificationUtils.getInstance().reportModifications(subReporter, connectivityReports, "ConnectivityCreated", CONNECTIVITY);
}
}

private ReportNode reportGeneratorActiveLimits(GeneratorCreationInfos generatorCreationInfos, ReportNode subReportNode) {
List<ReportNode> limitsReports = new ArrayList<>();
ReportNode subReportNodeLimits = subReportNode.newReportNode().withMessageTemplate(LIMITS, LIMITS).add();
subReportNodeLimits.newReportNode()
.withMessageTemplate(LIMITS, LIMITS)
.withSeverity(TypedValue.INFO_SEVERITY)
.add();

List<ReportNode> limitsReports = new ArrayList<>();
limitsReports.add(ModificationUtils.getInstance().buildCreationReport(
generatorCreationInfos.getMinP(), "Min active power"));

limitsReports.add(ModificationUtils.getInstance().buildCreationReport(
generatorCreationInfos.getMaxP(), "Max active power"));

if (generatorCreationInfos.getRatedS() != null) {
limitsReports.add(ModificationUtils.getInstance().buildCreationReport(
generatorCreationInfos.getRatedS(), "Rated nominal power"));
}
ModificationUtils.getInstance().reportModifications(subReportNodeLimits, limitsReports, "ActiveLimitsCreated", ACTIVE_LIMITS, Map.of());
ModificationUtils.getInstance().reportModifications(subReportNodeLimits, limitsReports, "ActiveLimitsCreated", ACTIVE_LIMITS);
return subReportNodeLimits;
}

Expand All @@ -319,7 +311,7 @@ private void createGeneratorActivePowerControl(GeneratorCreationInfos generatorC
.build());

}
ModificationUtils.getInstance().reportModifications(subReportNode, activePowerRegulationReports, "ActivePowerRegulationCreated", "Active power regulation", Map.of());
ModificationUtils.getInstance().reportModifications(subReportNode, activePowerRegulationReports, "ActivePowerRegulationCreated", "Active power regulation");
}
}

Expand All @@ -345,7 +337,7 @@ private void createGeneratorShortCircuit(GeneratorCreationInfos generatorCreatio
.withSeverity(TypedValue.ERROR_SEVERITY)
.build());
}
ModificationUtils.getInstance().reportModifications(subReportNode, shortCircuitReports, "shortCircuitCreated", "Short-circuit", Map.of());
ModificationUtils.getInstance().reportModifications(subReportNode, shortCircuitReports, "shortCircuitCreated", "Short-circuit");
}
}

Expand Down Expand Up @@ -386,7 +378,7 @@ private void createGeneratorStartUp(GeneratorCreationInfos generatorCreationInfo
.withSeverity(TypedValue.ERROR_SEVERITY)
.build());
}
ModificationUtils.getInstance().reportModifications(subReportNode, startupReports, "startUpAttributesCreated", "Start up", Map.of());
ModificationUtils.getInstance().reportModifications(subReportNode, startupReports, "startUpAttributesCreated", "Start up");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;

import static org.gridsuite.modification.server.NetworkModificationException.Type.MODIFY_GENERATOR_ERROR;
import static org.gridsuite.modification.server.modifications.ModificationUtils.insertReportNode;
Expand Down Expand Up @@ -139,7 +138,7 @@ private void modifyGeneratorShortCircuitAttributes(GeneratorModificationInfos mo
modificationInfos.getStepUpTransformerX().getValue(),
"Transformer reactance"));
}
ModificationUtils.getInstance().reportModifications(subReportNode, reports, "shortCircuitAttributesModified", "Short-circuit", Map.of());
ModificationUtils.getInstance().reportModifications(subReportNode, reports, "shortCircuitAttributesModified", "Short-circuit");
}

private void modifyGeneratorReactiveCapabilityCurvePoints(GeneratorModificationInfos modificationInfos,
Expand Down Expand Up @@ -167,16 +166,7 @@ private ReportNode modifyGeneratorActiveLimitsAttributes(GeneratorModificationIn
ReportNode reportRatedNominalPower = ModificationUtils.getInstance().applyElementaryModificationsAndReturnReport(generator::setRatedS, generator::getRatedS, modificationInfos.getRatedS(), "Rated nominal power");
if (reportMaxActivePower != null || reportMinActivePower != null || reportRatedNominalPower != null) {
subReporterLimits = subReportNode.newReportNode().withMessageTemplate(LIMITS, LIMITS).add();
subReporterLimits.newReportNode()
.withMessageTemplate(LIMITS, LIMITS)
.withSeverity(TypedValue.INFO_SEVERITY)
.add();

ReportNode subReporterActiveLimits = subReporterLimits.newReportNode().withMessageTemplate(ACTIVE_LIMITS, ACTIVE_LIMITS).add();
subReporterActiveLimits.newReportNode()
.withMessageTemplate(ACTIVE_LIMITS, ACTIVE_LIMITS)
.withSeverity(TypedValue.INFO_SEVERITY)
.add();
if (reportMaxActivePower != null) {
insertReportNode(subReporterActiveLimits, reportMaxActivePower);
}
Expand Down Expand Up @@ -230,7 +220,7 @@ private void modifyGeneratorStartUpAttributes(GeneratorModificationInfos modific
plannedOutageRateUpdated ||
forcedOutageRateUpdated) {
generatorStartupAdder.add();
ModificationUtils.getInstance().reportModifications(subReportNode, reports, "startUpAttributesModified", "Start up", Map.of());
ModificationUtils.getInstance().reportModifications(subReportNode, reports, "startUpAttributesModified", "Start up");
}
}

Expand Down Expand Up @@ -358,9 +348,11 @@ private ReportNode modifyGeneratorVoltageRegulatorAttributes(GeneratorModificati
reportVoltageSetpoint = ModificationUtils.getInstance().buildModificationReport(generator.getTargetV(), Double.NaN, "Voltage");
}
}

voltageRegulationReports.add(ModificationUtils.getInstance().applyElementaryModificationsAndReturnReport(generator::setVoltageRegulatorOn, generator::isVoltageRegulatorOn,
modificationInfos.getVoltageRegulationOn(), "VoltageRegulationOn"));
ReportNode voltageRegulationOn = ModificationUtils.getInstance().applyElementaryModificationsAndReturnReport(generator::setVoltageRegulatorOn, generator::isVoltageRegulatorOn,
modificationInfos.getVoltageRegulationOn(), "VoltageRegulationOn");
if (voltageRegulationOn != null) {
voltageRegulationReports.add(voltageRegulationOn);
}
if (reportVoltageSetpoint != null) {
voltageRegulationReports.add(reportVoltageSetpoint);
}
Expand Down Expand Up @@ -395,12 +387,8 @@ private ReportNode modifyGeneratorVoltageRegulatorAttributes(GeneratorModificati
subReportNodeSetpoints2 = subReportNode.newReportNode()
.withMessageTemplate(SETPOINTS, SETPOINTS)
.add();
subReportNodeSetpoints2.newReportNode()
.withMessageTemplate(SETPOINTS, SETPOINTS)
.withSeverity(TypedValue.INFO_SEVERITY)
.add();
}
ModificationUtils.getInstance().reportModifications(subReportNodeSetpoints2, voltageRegulationReports, "voltageRegulationModified", "Voltage regulation", Map.of());
ModificationUtils.getInstance().reportModifications(subReportNodeSetpoints2, voltageRegulationReports, "voltageRegulationModified", "Voltage regulation");
return subReportNodeSetpoints2;
}

Expand All @@ -419,10 +407,6 @@ private void modifyGeneratorSetpointsAttributes(GeneratorModificationInfos modif
ReportNode subReporterSetpoints = null;
if (reportActivePower != null || reportReactivePower != null) {
subReporterSetpoints = subReportNode.newReportNode().withMessageTemplate(SETPOINTS, SETPOINTS).add();
subReporterSetpoints.newReportNode()
.withMessageTemplate(SETPOINTS, SETPOINTS)
.withSeverity(TypedValue.INFO_SEVERITY)
.add();
if (reportActivePower != null) {
insertReportNode(subReporterSetpoints, reportActivePower);
}
Expand Down
Loading

0 comments on commit e443292

Please sign in to comment.