@@ -103,63 +103,78 @@ private void modifyOperationalLimitsGroups(Branch<?> branch, List<OperationalLim
103
103
104
104
private void applySelectedOLGs (Branch <?> branch , List <ReportNode > side1LimitsReports , List <ReportNode > side2LimitsReports ) {
105
105
if (modificationInfos .getSelectedOperationalLimitsGroup1 () != null ) {
106
- applySelectedOLGOnSide1 (branch , side1LimitsReports );
106
+ modifySelectedOperationalLimitsGroup (
107
+ branch ,
108
+ modificationInfos .getSelectedOperationalLimitsGroup1 (),
109
+ TwoSides .ONE ,
110
+ side1LimitsReports
111
+ );
107
112
}
108
113
if (modificationInfos .getSelectedOperationalLimitsGroup2 () != null ) {
109
- applySelectedOLGOnSide2 (branch , side2LimitsReports );
114
+ modifySelectedOperationalLimitsGroup (
115
+ branch ,
116
+ modificationInfos .getSelectedOperationalLimitsGroup2 (),
117
+ TwoSides .TWO ,
118
+ side2LimitsReports );
110
119
}
111
120
}
112
121
113
- private void applySelectedOLGOnSide1 (Branch <?> branch , List <ReportNode > reportNode ) {
114
- if (Objects . requireNonNull ( modificationInfos . getSelectedOperationalLimitsGroup1 () .getOp () ) == OperationType .UNSET ) {
122
+ private static void applySelectedOLGOnSide1 (Branch <?> branch , AttributeModification < String > modifOperationalLimitsGroup , List <ReportNode > reportNode , String newSelectedOLG ) {
123
+ if (! StringUtils . hasText ( newSelectedOLG ) || modifOperationalLimitsGroup .getOp () == OperationType .UNSET ) {
115
124
branch .cancelSelectedOperationalLimitsGroup1 ();
116
- reportNode .add (ReportNode .newRootReportNode ()
117
- .withMessageTemplate ("network.modification.noLimitSetSelectedOnSide1" )
118
- .withSeverity (TypedValue .INFO_SEVERITY )
119
- .build ());
120
- } else if (modificationInfos .getSelectedOperationalLimitsGroup1 ().getOp () == OperationType .SET ) {
121
- String newSelectedOpLG1 = modificationInfos .getSelectedOperationalLimitsGroup1 ().getValue ();
122
- if (StringUtils .hasText (newSelectedOpLG1 ) && branch .getOperationalLimitsGroup1 (newSelectedOpLG1 ).isEmpty ()) {
125
+ if (reportNode != null ) {
126
+ reportNode .add (ReportNode .newRootReportNode ()
127
+ .withMessageTemplate ("network.modification.noLimitSetSelectedOnSide1" )
128
+ .withSeverity (TypedValue .INFO_SEVERITY )
129
+ .build ());
130
+ }
131
+ } else {
132
+ if (StringUtils .hasText (newSelectedOLG ) && branch .getOperationalLimitsGroup1 (newSelectedOLG ).isEmpty () && reportNode != null ) {
123
133
reportNode .add (ReportNode .newRootReportNode ()
124
134
.withMessageTemplate ("network.modification.limitSetAbsentOnSide1" )
125
- .withUntypedValue ("selectedOperationalLimitsGroup" , newSelectedOpLG1 )
135
+ .withUntypedValue ("selectedOperationalLimitsGroup" , newSelectedOLG )
126
136
.withSeverity (TypedValue .WARN_SEVERITY )
127
137
.build ());
128
138
129
139
} else {
130
- branch .setSelectedOperationalLimitsGroup1 (newSelectedOpLG1 );
131
- reportNode .add (ReportNode .newRootReportNode ()
132
- .withMessageTemplate ("network.modification.limitSetSelectedOnSide1" )
133
- .withUntypedValue ("selectedOperationalLimitsGroup1" , newSelectedOpLG1 )
134
- .withSeverity (TypedValue .INFO_SEVERITY )
135
- .build ());
140
+ branch .setSelectedOperationalLimitsGroup1 (newSelectedOLG );
141
+ if (reportNode != null ) {
142
+ reportNode .add (ReportNode .newRootReportNode ()
143
+ .withMessageTemplate ("network.modification.limitSetSelectedOnSide1" )
144
+ .withUntypedValue ("selectedOperationalLimitsGroup1" , newSelectedOLG )
145
+ .withSeverity (TypedValue .INFO_SEVERITY )
146
+ .build ());
147
+ }
136
148
}
137
149
}
138
150
}
139
151
140
- private void applySelectedOLGOnSide2 (Branch <?> branch , List <ReportNode > reportNode ) {
141
- if (Objects .requireNonNull (modificationInfos .getSelectedOperationalLimitsGroup2 ().getOp ()) == OperationType .UNSET ) {
142
- branch .setSelectedOperationalLimitsGroup2 ("" );
143
- reportNode .add (ReportNode .newRootReportNode ()
144
- .withMessageTemplate ("network.modification.noLimitSetSelectedOnSide2" )
145
- .withSeverity (TypedValue .INFO_SEVERITY )
146
- .build ());
147
- } else if (modificationInfos .getSelectedOperationalLimitsGroup2 ().getOp () == OperationType .SET ) {
148
- String newSelectedOpLG = modificationInfos .getSelectedOperationalLimitsGroup2 ().getValue ();
149
- if (StringUtils .hasText (newSelectedOpLG ) && branch .getOperationalLimitsGroup2 (newSelectedOpLG ).isEmpty ()) {
152
+ private static void applySelectedOLGOnSide2 (Branch <?> branch , AttributeModification <String > modifOperationalLimitsGroup , List <ReportNode > reportNode , String newSelectedOLG ) {
153
+ if (!StringUtils .hasText (newSelectedOLG ) || modifOperationalLimitsGroup .getOp () == OperationType .UNSET ) {
154
+ branch .cancelSelectedOperationalLimitsGroup2 ();
155
+ if (reportNode != null ) {
156
+ reportNode .add (ReportNode .newRootReportNode ()
157
+ .withMessageTemplate ("network.modification.noLimitSetSelectedOnSide2" )
158
+ .withSeverity (TypedValue .INFO_SEVERITY )
159
+ .build ());
160
+ }
161
+ } else {
162
+ if (StringUtils .hasText (newSelectedOLG ) && branch .getOperationalLimitsGroup2 (newSelectedOLG ).isEmpty () && reportNode != null ) {
150
163
reportNode .add (ReportNode .newRootReportNode ()
151
164
.withMessageTemplate ("network.modification.limitSetAbsentOnSide2" )
152
- .withUntypedValue ("selectedOperationalLimitsGroup2 " , newSelectedOpLG )
165
+ .withUntypedValue ("selectedOperationalLimitsGroup " , newSelectedOLG )
153
166
.withSeverity (TypedValue .WARN_SEVERITY )
154
167
.build ());
155
168
156
169
} else {
157
- branch .setSelectedOperationalLimitsGroup2 (newSelectedOpLG );
158
- reportNode .add (ReportNode .newRootReportNode ()
159
- .withMessageTemplate ("network.modification.limitSetSelectedOnSide2" )
160
- .withUntypedValue ("selectedOperationalLimitsGroup2" , newSelectedOpLG )
161
- .withSeverity (TypedValue .INFO_SEVERITY )
162
- .build ());
170
+ branch .setSelectedOperationalLimitsGroup2 (newSelectedOLG );
171
+ if (reportNode != null ) {
172
+ reportNode .add (ReportNode .newRootReportNode ()
173
+ .withMessageTemplate ("network.modification.limitSetSelectedOnSide2" )
174
+ .withUntypedValue ("selectedOperationalLimitsGroup2" , newSelectedOLG )
175
+ .withSeverity (TypedValue .INFO_SEVERITY )
176
+ .build ());
177
+ }
163
178
}
164
179
}
165
180
}
@@ -613,30 +628,18 @@ private void modifyBranchVoltageLevelBusOrBusBarSectionAttributesSide2(BranchMod
613
628
);
614
629
}
615
630
616
- public static void modifySelectedOperationalLimitsGroup (Branch <?> branch , AttributeModification <String > modifOperationalLimitsGroup ,
617
- TwoSides side , ReportNode reportNode ) {
631
+ public static void modifySelectedOperationalLimitsGroup (
632
+ Branch <?> branch ,
633
+ AttributeModification <String > modifOperationalLimitsGroup ,
634
+ TwoSides side ,
635
+ List <ReportNode > reportNode ) {
618
636
Objects .requireNonNull (side );
619
637
if (modifOperationalLimitsGroup != null ) {
620
- String value = modifOperationalLimitsGroup .getValue ();
621
- String previousSelectedLimitsGroup = null ;
638
+ String newSelectedOLG = modifOperationalLimitsGroup .getValue ();
622
639
if (side == TwoSides .ONE ) {
623
- previousSelectedLimitsGroup = branch .getSelectedOperationalLimitsGroupId1 ().orElse (null );
624
- if (!StringUtils .hasText (value )) {
625
- branch .cancelSelectedOperationalLimitsGroup1 ();
626
- } else {
627
- branch .setSelectedOperationalLimitsGroup1 (value );
628
- }
640
+ applySelectedOLGOnSide1 (branch , modifOperationalLimitsGroup , reportNode , newSelectedOLG );
629
641
} else if (side == TwoSides .TWO ) {
630
- previousSelectedLimitsGroup = branch .getSelectedOperationalLimitsGroupId2 ().orElse (null );
631
- if (!StringUtils .hasText (value )) {
632
- branch .cancelSelectedOperationalLimitsGroup2 ();
633
- } else {
634
- branch .setSelectedOperationalLimitsGroup2 (value );
635
- }
636
- }
637
- if (reportNode != null ) {
638
- insertReportNode (reportNode , ModificationUtils .getInstance ().buildModificationReport (previousSelectedLimitsGroup ,
639
- modifOperationalLimitsGroup .getValue (), "selected operational limits group side " + side .getNum ()));
642
+ applySelectedOLGOnSide2 (branch , modifOperationalLimitsGroup , reportNode , newSelectedOLG );
640
643
}
641
644
}
642
645
}
0 commit comments