yanweiyuan3
2023-08-09 588bc7829387dfc761cc25f06f77d4c81818bd10
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
Quintiq file version 2.0
#parent: #root
Method ApplyConfigurationQuery (
  KpiQuery kpiQuery
) id:Method_Kpi_frmKpiMatrix_ApplyConfigurationQuery
{
  #keys: '[146874.0.1463046408]'
  Body:
  [*
    // Applies the configuration query from a KpiQuery to radio button groups, List, and selector.
    selKpiCompareLabel.BoundValue( kpiQuery.SeriesSelection() );
    rbgTimeType.BoundValue( kpiQuery.Timetype() );
    
    // Expand all so the selection (in collapsed list) will be recorded in DataHolder
    lstKpiLabelFilter.ExpandAll();
    
    // Clear selection in list
    lstKpiLabelCompare.SelectByKey( Key::ZeroKey() );
    lstKpiLabelFilter.SelectByKey( Key::ZeroKey() );
    
    compareLabels := construct( KpiLabelValues );
    fixedLabels   := construct( KpiLabelValues );
    traverse( kpiQuery.LabelFilters().Tokenize( "," ), Elements, lv )
    {
      label := select( KpiTracker, Label.Value, labelvalue, labelvalue.Value() = lv );
      if ( not isnull( label ) )
      {
        if( label.Label() = selKpiCompareLabel.Data() )
        {
          lstKpiLabelCompare.ExtendSelectByKey( label.Key() );
          compareLabels.Add( label );
        }
        else
        {
          lstKpiLabelFilter.ExtendSelectByKey( label.Key() );
          fixedLabels.Add( label );
        }
      }
    }
    
    lstFilterKpis.SelectByKey( Key::ZeroKey() );
    
    traverse( kpiQuery.MetaDatas().Tokenize( "," ), Elements, md )
    {
      metadata := select( KpiTracker, MetaData, metadata, metadata.DisplayName() = md );
      if ( not isnull( metadata ) )
      {
        lstFilterKpis.ExtendSelectByKey( metadata.Key() );
      }
    }
    
    
    // Refresh data - Queries the KPI Tracker for the KPI compare data
    // Do this because the DataHolder has independency on drop down selector and is not reflect the changes immediately.
    compareLabel := selKpiCompareLabel.Data();
    
    data := KpiTracker.SnapshotRetrieval().GetLastSnapshotsForCompareLabelWithLabelFilterNvt( compareLabels, fixedLabels );
    
    set := Kpi_GlobalState.ConvertNvtToShadowSnapshotSetData( data );
    Kpi_GlobalState.PropagateLabel( set, compareLabel.Name() );
    Kpi_GlobalState.PropagateTimeStamp( set, rbgTimeType.BoundValue() );
                            
    // Set relations
    traverse( set, SnapshotData.Value, v ) 
    {
      v.UI_CompareLabel( relset, select( compareLabels, Elements, s, s.Value() = v.UI_LabelValue() ) );
      v.UI_Kpi( relset, select( KpiTracker, MetaData, k, k.Name() = v.Name() ) );
    }  
     
    dhSnapshotData.Data( &set );
  *]
}