@@ -37,6 +37,8 @@ public class OperationalLimitsGroupModification {
3737 List <ReportNode > limitsReportsSide1 ;
3838 List <ReportNode > limitsReportsSide2 ;
3939
40+ private static final String NO_VALUE = "no value" ;
41+
4042 public OperationalLimitsGroupModification (
4143 Branch <?> modifiedBranch ,
4244 OperationalLimitsGroupModificationInfos olgModifInfos ,
@@ -445,10 +447,10 @@ private void applyTemporaryLimitModification(
445447 List <LoadingLimits .TemporaryLimit > unmodifiedTemporaryLimits ,
446448 OperationalLimitsGroupInfos .Applicability applicability ) {
447449 CurrentLimitsModificationInfos currentLimitsInfos = olgModifInfos .getCurrentLimits ();
448- int limitAcceptableDuration = limit .getAcceptableDuration () == null ? Integer .MAX_VALUE : limit .getAcceptableDuration ();
449- double limitValue = limit .getValue () == null ? Double .MAX_VALUE : limit .getValue ();
450+ int limitAcceptableDuration = limit .getAcceptableDuration () == null ? Integer .MAX_VALUE : limit .getAcceptableDuration (). getValue () ;
451+ double limitValue = limit .getValue () == null ? Double .MAX_VALUE : limit .getValue (). getValue () ;
450452 String limitDurationToReport = limitAcceptableDuration == Integer .MAX_VALUE ? " " : String .valueOf (limitAcceptableDuration );
451- String limitValueToReport = limitValue == Double .MAX_VALUE ? "no value" : String .valueOf (limitValue );
453+ String limitValueToReport = limitValue == Double .MAX_VALUE ? NO_VALUE : String .valueOf (limitValue );
452454 LoadingLimits .TemporaryLimit limitToModify = null ;
453455 if (networkCurrentLimits != null ) {
454456 limitToModify = getTemporaryLimitToModify (networkCurrentLimits , limit , currentLimitsInfos , olgModifInfos .getTemporaryLimitsModificationType ());
@@ -464,13 +466,13 @@ private void applyTemporaryLimitModification(
464466 addToLogsOnSide (ReportNode .newRootReportNode ()
465467 .withResourceBundles (NetworkModificationReportResourceBundle .BASE_NAME )
466468 .withMessageTemplate ("network.modification.temporaryLimitDeleted.name" )
467- .withUntypedValue (NAME , limit .getName ())
469+ .withUntypedValue (NAME , limit .getName (). getValue () )
468470 .withUntypedValue (DURATION , limitDurationToReport )
469471 .withSeverity (TypedValue .DETAIL_SEVERITY )
470472 .build (),
471473 applicability );
472474 } else {
473- modifyTemporaryLimit (limitsAdder , limit , limitToModify , limitValue , limitDurationToReport , limitValueToReport , limitAcceptableDuration , applicability );
475+ modifyTemporaryLimit (limitsAdder , limit , limitToModify , limitValue , limitDurationToReport , limitAcceptableDuration , applicability );
474476 }
475477 } else if (limit .getModificationType () == TemporaryLimitModificationType .MODIFY || limit .getModificationType () == TemporaryLimitModificationType .MODIFY_OR_ADD ) {
476478 // invalid modification
@@ -490,7 +492,7 @@ private void applyTemporaryLimitModification(
490492 public boolean isThisLimitDeleted (List <CurrentTemporaryLimitModificationInfos > temporaryLimitsModification , int acceptableDuration ) {
491493 return temporaryLimitsModification .stream ()
492494 .anyMatch (temporaryLimit ->
493- temporaryLimit .getAcceptableDuration () == acceptableDuration && temporaryLimit .getModificationType () == TemporaryLimitModificationType .DELETE
495+ temporaryLimit .getAcceptableDuration (). getValue () == acceptableDuration && temporaryLimit .getModificationType () == TemporaryLimitModificationType .DELETE
494496 );
495497 }
496498
@@ -499,7 +501,7 @@ private LoadingLimits.TemporaryLimit getTemporaryLimitToModify(
499501 CurrentTemporaryLimitModificationInfos limit ,
500502 CurrentLimitsModificationInfos currentLimitsInfos ,
501503 TemporaryLimitModificationType temporaryLimitsModificationType ) {
502- int limitAcceptableDuration = limit .getAcceptableDuration () == null ? Integer .MAX_VALUE : limit .getAcceptableDuration ();
504+ int limitAcceptableDuration = limit .getAcceptableDuration () == null ? Integer .MAX_VALUE : limit .getAcceptableDuration (). getValue () ;
503505 LoadingLimits .TemporaryLimit limitToModify ;
504506 limitToModify = networkCurrentLimits .getTemporaryLimit (limitAcceptableDuration );
505507 if (limitToModify != null && !limitToModify .getName ().equals (limit .getName ())) {
@@ -519,46 +521,59 @@ private LoadingLimits.TemporaryLimit getTemporaryLimitToModify(
519521 return limitToModify ;
520522 }
521523
524+ private boolean hasModification (AttributeModification <?> attribute ) {
525+ return attribute != null && attribute .getValue () != null && attribute .getOp ().equals (OperationType .SET );
526+ }
527+
522528 public void modifyTemporaryLimit (
523529 CurrentLimitsAdder limitsAdder ,
524530 CurrentTemporaryLimitModificationInfos limitModificationInfos ,
525531 LoadingLimits .TemporaryLimit limitToModify ,
526532 double limitValue ,
527533 String limitDurationToReport ,
528- String limitValueToReport ,
529534 int limitAcceptableDuration ,
530535 OperationalLimitsGroupInfos .Applicability applicability ) {
531- if (Double .compare (limitToModify .getValue (), limitValue ) != 0 && limitModificationInfos .getModificationType () != null ) {
532- // value change
536+ // Apply modifications only if specified, otherwise keep existing values
537+ String finalName = hasModification (limitModificationInfos .getName ())
538+ ? limitModificationInfos .getName ().getValue ()
539+ : limitToModify .getName ();
540+
541+ double finalValue = hasModification (limitModificationInfos .getValue ())
542+ ? limitValue
543+ : limitToModify .getValue ();
544+
545+ // Check if there are any actual changes
546+ boolean nameChanged = !limitToModify .getName ().equals (finalName );
547+ boolean valueChanged = Double .compare (limitToModify .getValue (), finalValue ) != 0 ;
548+
549+ if (valueChanged && !nameChanged ) {
550+ // only the value changes
551+ String finalValueToReport = finalValue == Double .MAX_VALUE ? NO_VALUE : String .valueOf (finalValue );
533552 addToLogsOnSide (ReportNode .newRootReportNode ()
534553 .withResourceBundles (NetworkModificationReportResourceBundle .BASE_NAME )
535554 .withMessageTemplate ("network.modification.temporaryLimitValueModified.name" )
536- .withUntypedValue (AbstractBranchModification .NAME , limitModificationInfos . getName () )
555+ .withUntypedValue (AbstractBranchModification .NAME , finalName )
537556 .withUntypedValue (DURATION , limitDurationToReport )
538- .withUntypedValue (AbstractBranchModification .VALUE , limitValueToReport )
557+ .withUntypedValue (AbstractBranchModification .VALUE , finalValueToReport )
539558 .withUntypedValue ("oldValue" ,
540- limitToModify .getValue () == Double .MAX_VALUE ? "no value"
559+ limitToModify .getValue () == Double .MAX_VALUE ? NO_VALUE
541560 : String .valueOf (limitToModify .getValue ()))
542561 .withSeverity (TypedValue .DETAIL_SEVERITY )
543562 .build (),
544563 applicability );
545- addTemporaryLimit (limitsAdder , limitModificationInfos .getName (), limitValue , limitAcceptableDuration );
546- } else {
547- addTemporaryLimit (limitsAdder , limitModificationInfos .getName (), limitToModify .getValue (), limitAcceptableDuration );
564+ } else if (nameChanged || valueChanged ) {
548565 // log only if there is at least one actual modification
549- if (Double .compare (limitToModify .getValue (), limitValue ) != 0 ||
550- !limitToModify .getName ().equals (limitModificationInfos .getName ())) {
551- addToLogsOnSide (ReportNode .newRootReportNode ()
552- .withResourceBundles (NetworkModificationReportResourceBundle .BASE_NAME )
553- .withMessageTemplate ("network.modification.temporaryLimitModified.name" )
554- .withUntypedValue (NAME , limitModificationInfos .getName ())
555- .withUntypedValue (VALUE , limitToModify .getValue ())
556- .withUntypedValue (DURATION , limitAcceptableDuration )
557- .withSeverity (TypedValue .DETAIL_SEVERITY )
558- .build (),
559- applicability );
560- }
566+ addToLogsOnSide (ReportNode .newRootReportNode ()
567+ .withResourceBundles (NetworkModificationReportResourceBundle .BASE_NAME )
568+ .withMessageTemplate ("network.modification.temporaryLimitModified.name" )
569+ .withUntypedValue (NAME , finalName )
570+ .withUntypedValue (VALUE , finalValue )
571+ .withUntypedValue (DURATION , limitAcceptableDuration )
572+ .withSeverity (TypedValue .DETAIL_SEVERITY )
573+ .build (),
574+ applicability );
561575 }
576+ addTemporaryLimit (limitsAdder , finalName , finalValue , limitAcceptableDuration );
562577 }
563578
564579 public void createTemporaryLimit (
@@ -572,12 +587,12 @@ public void createTemporaryLimit(
572587 addToLogsOnSide (ReportNode .newRootReportNode ()
573588 .withResourceBundles (NetworkModificationReportResourceBundle .BASE_NAME )
574589 .withMessageTemplate ("network.modification.temporaryLimitModified.name" )
575- .withUntypedValue (AbstractBranchModification .NAME , limit .getName ())
590+ .withUntypedValue (AbstractBranchModification .NAME , limit .getName (). getValue () )
576591 .withUntypedValue (DURATION , limitDurationToReport )
577592 .withUntypedValue (AbstractBranchModification .VALUE , limitValueToReport )
578593 .withSeverity (TypedValue .DETAIL_SEVERITY )
579594 .build (),
580595 applicability );
581- addTemporaryLimit (limitsAdder , limit .getName (), limitValue , limitAcceptableDuration );
596+ addTemporaryLimit (limitsAdder , limit .getName (). getValue () , limitValue , limitAcceptableDuration );
582597 }
583598}
0 commit comments