Skip to content

Commit 38f9f33

Browse files
fix(report): don't use withAllResourceBundlesFromClasspath which is resource heavy (#122)
Signed-off-by: Joris Mancini <[email protected]>
1 parent 3d0d4ed commit 38f9f33

File tree

45 files changed

+158
-113
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+158
-113
lines changed

src/main/java/org/gridsuite/modification/dto/byfilter/equipmentfield/PropertyField.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import com.powsybl.iidm.network.OperationalLimitsGroup;
1414
import com.powsybl.iidm.network.TwoSides;
1515
import org.gridsuite.modification.NetworkModificationException;
16+
import org.gridsuite.modification.report.NetworkModificationReportResourceBundle;
1617

1718
import java.util.List;
1819

@@ -63,7 +64,7 @@ static boolean isEditableOperationalLimitsGroupPropertyValue(Branch<?> branch, S
6364

6465
if (operationalLimitsGroupList.isEmpty()) {
6566
equipmentsReport.add(ReportNode.newRootReportNode()
66-
.withAllResourceBundlesFromClasspath()
67+
.withResourceBundles(NetworkModificationReportResourceBundle.BASE_NAME)
6768
.withMessageTemplate(REPORT_KEY_OPERATIONAL_LIMITS_GROUP_PROPERTY_VALUE_NOT_FOUND_ERROR)
6869
.withUntypedValue(VALUE_KEY_ID, branch.getId())
6970
.withUntypedValue(VALUE_KEY_SIDE, side.ordinal() + 1)
@@ -74,7 +75,7 @@ static boolean isEditableOperationalLimitsGroupPropertyValue(Branch<?> branch, S
7475
return false;
7576
} else if (operationalLimitsGroupList.size() > 1) {
7677
equipmentsReport.add(ReportNode.newRootReportNode()
77-
.withAllResourceBundlesFromClasspath()
78+
.withResourceBundles(NetworkModificationReportResourceBundle.BASE_NAME)
7879
.withMessageTemplate(REPORT_KEY_OPERATIONAL_LIMITS_GROUP_PROPERTY_VALUE_MULTIPLE_ERROR)
7980
.withUntypedValue(VALUE_KEY_ID, branch.getId())
8081
.withUntypedValue(VALUE_KEY_SIDE, side.ordinal() + 1)

src/main/java/org/gridsuite/modification/dto/byfilter/equipmentfield/TwoWindingsTransformerField.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import jakarta.validation.constraints.NotNull;
1414
import org.gridsuite.modification.dto.AttributeModification;
1515
import org.gridsuite.modification.dto.OperationType;
16+
import org.gridsuite.modification.report.NetworkModificationReportResourceBundle;
1617
import org.gridsuite.modification.utils.ModificationUtils;
1718

1819
import java.util.List;
@@ -60,7 +61,7 @@ public static boolean isEquipmentEditable(TwoWindingsTransformer twoWindingsTran
6061
boolean isEditable = twoWindingsTransformer.getRatioTapChanger() != null;
6162
if (!isEditable) {
6263
equipmentsReport.add(ReportNode.newRootReportNode()
63-
.withAllResourceBundlesFromClasspath()
64+
.withResourceBundles(NetworkModificationReportResourceBundle.BASE_NAME)
6465
.withMessageTemplate(REPORT_KEY_RATIO_TAP_CHANGER_EQUIPMENT_MODIFIED_ERROR)
6566
.withUntypedValue(VALUE_KEY_FIELD_NAME, field.name())
6667
.withUntypedValue(VALUE_KEY_EQUIPMENT_NAME, twoWindingsTransformer.getId())
@@ -73,7 +74,7 @@ public static boolean isEquipmentEditable(TwoWindingsTransformer twoWindingsTran
7374
boolean isEditable = twoWindingsTransformer.getPhaseTapChanger() != null;
7475
if (!isEditable) {
7576
equipmentsReport.add(ReportNode.newRootReportNode()
76-
.withAllResourceBundlesFromClasspath()
77+
.withResourceBundles(NetworkModificationReportResourceBundle.BASE_NAME)
7778
.withMessageTemplate(REPORT_KEY_PHASE_TAP_CHANGER_EQUIPMENT_MODIFIED_ERROR)
7879
.withUntypedValue(VALUE_KEY_FIELD_NAME, field.name())
7980
.withUntypedValue(VALUE_KEY_EQUIPMENT_NAME, twoWindingsTransformer.getId())

src/main/java/org/gridsuite/modification/modifications/AbstractBranchModification.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import jakarta.validation.constraints.NotNull;
1515
import org.gridsuite.modification.NetworkModificationException;
1616
import org.gridsuite.modification.dto.*;
17+
import org.gridsuite.modification.report.NetworkModificationReportResourceBundle;
1718
import org.gridsuite.modification.utils.ModificationUtils;
1819
import org.springframework.util.CollectionUtils;
1920
import org.springframework.util.StringUtils;
@@ -757,7 +758,7 @@ protected void modifyTemporaryLimits(@NotNull OperationalLimitsGroupModification
757758
// this needs to be logged only if there are unmodifiedTemporaryLimits left.
758759
// which means that they are going to be removed by the REPLACE mode
759760
temporaryLimitsReports.addFirst(ReportNode.newRootReportNode()
760-
.withAllResourceBundlesFromClasspath()
761+
.withResourceBundles(NetworkModificationReportResourceBundle.BASE_NAME)
761762
.withMessageTemplate("network.modification.temporaryLimitsReplaced")
762763
.withSeverity(TypedValue.INFO_SEVERITY)
763764
.build());
@@ -770,7 +771,7 @@ protected void modifyTemporaryLimits(@NotNull OperationalLimitsGroupModification
770771
}
771772
if (!temporaryLimitsReports.isEmpty()) {
772773
temporaryLimitsReports.addFirst(ReportNode.newRootReportNode()
773-
.withAllResourceBundlesFromClasspath()
774+
.withResourceBundles(NetworkModificationReportResourceBundle.BASE_NAME)
774775
.withMessageTemplate("network.modification.temporaryLimitsModification")
775776
.withSeverity(TypedValue.INFO_SEVERITY)
776777
.build());
@@ -818,7 +819,7 @@ private void applyTemporaryLimitModification(
818819
if (limit.getModificationType() == TemporaryLimitModificationType.DELETE) {
819820
// the limit has been removed previously
820821
temporaryLimitsReports.add(ReportNode.newRootReportNode()
821-
.withAllResourceBundlesFromClasspath()
822+
.withResourceBundles(NetworkModificationReportResourceBundle.BASE_NAME)
822823
.withMessageTemplate("network.modification.temporaryLimitDeleted.name")
823824
.withUntypedValue(NAME, limit.getName())
824825
.withUntypedValue(DURATION, limitDurationToReport)
@@ -830,7 +831,7 @@ private void applyTemporaryLimitModification(
830831
} else if (limit.getModificationType() == TemporaryLimitModificationType.MODIFY || limit.getModificationType() == TemporaryLimitModificationType.MODIFY_OR_ADD) {
831832
// invalid modification
832833
temporaryLimitsReports.add(ReportNode.newRootReportNode()
833-
.withAllResourceBundlesFromClasspath()
834+
.withResourceBundles(NetworkModificationReportResourceBundle.BASE_NAME)
834835
.withMessageTemplate("network.modification.temporaryLimitsNoMatch")
835836
.withUntypedValue(LIMIT_ACCEPTABLE_DURATION, limitAcceptableDuration)
836837
.withSeverity(TypedValue.WARN_SEVERITY)
@@ -849,7 +850,7 @@ private static void modifyTemporaryLimit(
849850
int limitAcceptableDuration) {
850851
if (Double.compare(limitToModify.getValue(), limitValue) != 0 && limitModificationInfos.getModificationType() != null) {
851852
temporaryLimitsReports.add(ReportNode.newRootReportNode()
852-
.withAllResourceBundlesFromClasspath()
853+
.withResourceBundles(NetworkModificationReportResourceBundle.BASE_NAME)
853854
.withMessageTemplate("network.modification.temporaryLimitModified.name")
854855
.withUntypedValue(NAME, limitModificationInfos.getName())
855856
.withUntypedValue(DURATION, limitDurationToReport)
@@ -875,7 +876,7 @@ private static void createTemporaryLimit(
875876
double limitValue,
876877
int limitAcceptableDuration) {
877878
temporaryLimitsReports.add(ReportNode.newRootReportNode()
878-
.withAllResourceBundlesFromClasspath()
879+
.withResourceBundles(NetworkModificationReportResourceBundle.BASE_NAME)
879880
.withMessageTemplate("network.modification.temporaryLimitAdded.name")
880881
.withUntypedValue(NAME, limit.getName())
881882
.withUntypedValue(DURATION, limitDurationToReport)

src/main/java/org/gridsuite/modification/modifications/BatteryCreation.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import com.powsybl.iidm.network.extensions.BatteryShortCircuitAdder;
1515
import org.gridsuite.modification.NetworkModificationException;
1616
import org.gridsuite.modification.dto.BatteryCreationInfos;
17+
import org.gridsuite.modification.report.NetworkModificationReportResourceBundle;
1718
import org.gridsuite.modification.utils.ModificationUtils;
1819
import org.gridsuite.modification.utils.PropertiesUtils;
1920

@@ -175,7 +176,7 @@ private void createBatteryActivePowerControl(BatteryCreationInfos batteryCreatio
175176
"Droop"));
176177
} catch (PowsyblException e) {
177178
activePowerRegulationReports.add(ReportNode.newRootReportNode()
178-
.withAllResourceBundlesFromClasspath()
179+
.withResourceBundles(NetworkModificationReportResourceBundle.BASE_NAME)
179180
.withMessageTemplate("network.modification.activePowerExtensionAddError.battery")
180181
.withUntypedValue("id", batteryCreationInfos.getEquipmentId())
181182
.withUntypedValue("message", e.getMessage())

src/main/java/org/gridsuite/modification/modifications/GeneratorCreation.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import com.powsybl.network.store.iidm.impl.extensions.GeneratorStartupAdderImpl;
1717
import org.gridsuite.modification.NetworkModificationException;
1818
import org.gridsuite.modification.dto.GeneratorCreationInfos;
19+
import org.gridsuite.modification.report.NetworkModificationReportResourceBundle;
1920
import org.gridsuite.modification.utils.ModificationUtils;
2021
import org.gridsuite.modification.utils.PropertiesUtils;
2122

@@ -209,7 +210,7 @@ private void createGeneratorVoltageRegulation(GeneratorCreationInfos generatorCr
209210
voltageReports.add(ModificationUtils.getInstance().buildCreationReport(generatorCreationInfos.getQPercent(), "Reactive percentage"));
210211
} catch (PowsyblException e) {
211212
voltageReports.add(ReportNode.newRootReportNode()
212-
.withAllResourceBundlesFromClasspath()
213+
.withResourceBundles(NetworkModificationReportResourceBundle.BASE_NAME)
213214
.withMessageTemplate("network.modification.ReactivePercentageError")
214215
.withUntypedValue("id", generatorCreationInfos.getEquipmentId())
215216
.withUntypedValue("message", e.getMessage())
@@ -268,7 +269,7 @@ private void createGeneratorActivePowerControl(GeneratorCreationInfos generatorC
268269
"Droop"));
269270
} catch (PowsyblException e) {
270271
activePowerRegulationReports.add(ReportNode.newRootReportNode()
271-
.withAllResourceBundlesFromClasspath()
272+
.withResourceBundles(NetworkModificationReportResourceBundle.BASE_NAME)
272273
.withMessageTemplate("network.modification.activePowerExtensionAddError.generator")
273274
.withUntypedValue("id", generatorCreationInfos.getEquipmentId())
274275
.withUntypedValue("message", e.getMessage())
@@ -311,7 +312,7 @@ private void createGeneratorStartUp(GeneratorCreationInfos generatorCreationInfo
311312
}
312313
} catch (PowsyblException e) {
313314
startupReports.add(ReportNode.newRootReportNode()
314-
.withAllResourceBundlesFromClasspath()
315+
.withResourceBundles(NetworkModificationReportResourceBundle.BASE_NAME)
315316
.withMessageTemplate("network.modification.StartupExtensionAddError")
316317
.withUntypedValue("id", generatorCreationInfos.getEquipmentId())
317318
.withUntypedValue("message", e.getMessage())

src/main/java/org/gridsuite/modification/modifications/LccModification.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import org.gridsuite.modification.dto.LccConverterStationModificationInfos;
1616
import org.gridsuite.modification.dto.LccModificationInfos;
1717
import org.gridsuite.modification.dto.LccShuntCompensatorModificationInfos;
18+
import org.gridsuite.modification.report.NetworkModificationReportResourceBundle;
1819
import org.gridsuite.modification.utils.ModificationUtils;
1920
import org.gridsuite.modification.utils.PropertiesUtils;
2021

@@ -181,7 +182,7 @@ private static void modifyShuntCompensator(VoltageLevel voltageLevel, List<Repor
181182

182183
if (shuntCompensator == null) {
183184
nodes.add(ReportNode.newRootReportNode()
184-
.withAllResourceBundlesFromClasspath()
185+
.withResourceBundles(NetworkModificationReportResourceBundle.BASE_NAME)
185186
.withMessageTemplate("network.modification.lcc.shuntCompensator.notFound")
186187
.withUntypedValue("id", infos.getId())
187188
.withSeverity(TypedValue.WARN_SEVERITY)
@@ -192,7 +193,7 @@ private static void modifyShuntCompensator(VoltageLevel voltageLevel, List<Repor
192193
if (infos.isDeletionMark()) {
193194
shuntCompensator.remove();
194195
nodes.add(ReportNode.newRootReportNode()
195-
.withAllResourceBundlesFromClasspath()
196+
.withResourceBundles(NetworkModificationReportResourceBundle.BASE_NAME)
196197
.withMessageTemplate("network.modification.lcc.shuntCompensator.removed")
197198
.withUntypedValue("id", infos.getId())
198199
.withSeverity(TypedValue.INFO_SEVERITY)
@@ -209,15 +210,15 @@ private static void modifyShuntCompensator(VoltageLevel voltageLevel, List<Repor
209210
if (Boolean.TRUE.equals(infos.getConnectedToHvdc())) {
210211
shuntCompensator.getTerminal().connect();
211212
nodes.add(ReportNode.newRootReportNode()
212-
.withAllResourceBundlesFromClasspath()
213+
.withResourceBundles(NetworkModificationReportResourceBundle.BASE_NAME)
213214
.withMessageTemplate("network.modification.lcc.shuntCompensator.connected")
214215
.withUntypedValue("id", shuntCompensator.getId())
215216
.withSeverity(TypedValue.INFO_SEVERITY)
216217
.build());
217218
} else {
218219
shuntCompensator.getTerminal().disconnect();
219220
nodes.add(ReportNode.newRootReportNode()
220-
.withAllResourceBundlesFromClasspath()
221+
.withResourceBundles(NetworkModificationReportResourceBundle.BASE_NAME)
221222
.withMessageTemplate("network.modification.lcc.shuntCompensator.disconnected")
222223
.withUntypedValue("id", shuntCompensator.getId())
223224
.withSeverity(TypedValue.INFO_SEVERITY)

src/main/java/org/gridsuite/modification/modifications/StaticVarCompensatorCreation.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import com.powsybl.iidm.network.extensions.StandbyAutomatonAdder;
1414
import org.gridsuite.modification.NetworkModificationException;
1515
import org.gridsuite.modification.dto.StaticVarCompensatorCreationInfos;
16+
import org.gridsuite.modification.report.NetworkModificationReportResourceBundle;
1617
import org.gridsuite.modification.utils.ModificationUtils;
1718
import org.gridsuite.modification.utils.PropertiesUtils;
1819

@@ -180,7 +181,7 @@ private void reportStaticVarCompensatorStandbyAutomaton(StaticVarCompensatorCrea
180181
"Low voltage threshold"));
181182
} catch (PowsyblException e) {
182183
standbyAutomatonReports.add(ReportNode.newRootReportNode()
183-
.withAllResourceBundlesFromClasspath()
184+
.withResourceBundles(NetworkModificationReportResourceBundle.BASE_NAME)
184185
.withMessageTemplate("network.modification.StandbyAutomatonExtensionAddError")
185186
.withUntypedValue("message", e.getMessage())
186187
.withSeverity(TypedValue.ERROR_SEVERITY)

src/main/java/org/gridsuite/modification/modifications/TwoWindingsTransformerModification.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import org.apache.commons.lang3.BooleanUtils;
1515
import org.gridsuite.modification.NetworkModificationException;
1616
import org.gridsuite.modification.dto.*;
17+
import org.gridsuite.modification.report.NetworkModificationReportResourceBundle;
1718
import org.gridsuite.modification.utils.ModificationUtils;
1819
import org.gridsuite.modification.utils.PropertiesUtils;
1920

@@ -625,7 +626,7 @@ private static void processTapchangerSteps(List<ReportNode> tapChangerStepsRepor
625626
List<TapChangerStepCreationInfos> modifSteps) {
626627
if (tapChangerStepsReports != null) {
627628
tapChangerStepsReports.add(ReportNode.newRootReportNode()
628-
.withAllResourceBundlesFromClasspath()
629+
.withResourceBundles(NetworkModificationReportResourceBundle.BASE_NAME)
629630
.withMessageTemplate("network.modification.tapChangerStepsModification")
630631
.withSeverity(TypedValue.INFO_SEVERITY)
631632
.build());
@@ -716,7 +717,7 @@ public static void processTapChangerPositionsAndSteps(TapChanger<?, ?, ?, ?> tap
716717

717718
private static void addStepAttributeReport(List<ReportNode> tapChangerStepsReports, String key, String value) {
718719
tapChangerStepsReports.add(ReportNode.newRootReportNode()
719-
.withAllResourceBundlesFromClasspath()
720+
.withResourceBundles(NetworkModificationReportResourceBundle.BASE_NAME)
720721
.withMessageTemplate(key)
721722
.withUntypedValue("value", value)
722723
.withUntypedValue("delta", "Δ") // Workaround to use non-ISO-8859-1 characters in the internationalization file

0 commit comments

Comments
 (0)