chenqinghong
2024-05-07 3ec06a830367465068963156dcc1d8e522571c13
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
Quintiq file version 2.0
#parent: #root
MethodOverride CreateIssue (LibOpt_SuboptimizerScopeElement suboptimizerscopeelement, String issuetype, const constcontent LibOpt_StatisticSeverityScaleEntrys severityscaleentries_lowerthresholdviolation, 
  const constcontent LibOpt_StatisticSeverityScaleEntrys severityscaleentries_upperthresholdviolation)
{
  Description: 'Create a `LibOpt_Issue` for the given "suboptimizer scope element" (`LibOpt_SuboptimizerScopeElement`) if its `LibOpt_SuboptimizerScopeElement.InputPercentage` violates the `LowerThreshold` / `UpperThreshold` of this statistic.'
  TextBody:
  [*
    // Variables needed for Issues creation.
    shouldcreateissue := false;
    severity := 0.0;
    
    if( suboptimizerscopeelement.InputPercentage() < this.LowerThreshold() or suboptimizerscopeelement.InputPercentage() = 0 )
    {
      shouldcreateissue := true;
      
      severity := this.GetSeverity( suboptimizerscopeelement.InputPercentage(), false /*is upper threshold violation*/, severityscaleentries_lowerthresholdviolation );
    }
    else if( suboptimizerscopeelement.InputPercentage() > this.UpperThreshold() )
    {
      shouldcreateissue := true;
      
      severity := this.GetSeverity( suboptimizerscopeelement.InputPercentage(), true /*is upper threshold violation*/, severityscaleentries_upperthresholdviolation );
    }
    
    if( shouldcreateissue )
    {
      // Create an Issue and link it with the relevant Suboptimizer Scope Element.
      LibOpt_Issue::Create( this,
                            suboptimizerscopeelement,
                            issuetype,
                            this.Focus() + ', ' + suboptimizerscopeelement.ScopeElement().Identifier(),
                            severity,
                            Translations::LibOpt_Issue_Details_ScopeElementInput( suboptimizerscopeelement.InputPercentage(),
                                                                                  this.LowerThreshold(),
                                                                                  this.UpperThreshold(),
                                                                                  LibOpt_Statistic::GetFormat( suboptimizerscopeelement.InputPercentage(),
                                                                                                               this.LowerThreshold(),
                                                                                                               this.UpperThreshold() ) )
                          );
    }
  *]
}