Quintiq file version 2.0
#parent: #root
Method ApplyConfigurationQueryAndRefresh (
  KpiQuery kpiQuery
) id:Method_FormKpiMatrix_ApplyConfigurationQueryAndRefresh
{
  #keys: '[146874.0.1463091719]'
  Body:
  [*
    // Applies the configuration query from a KpiQuery to radio button groups, List, checkbox and selector.
    RadioButtonGroupSelectionList.BoundValue( kpiQuery.Timetype() );
    
    ListCompareLabel.ClearSelection();
    ListLabelFilter.ClearSelection();
    ListFilterKpi.ClearSelection();
    
    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() = DataHolderKpiLabel.Data() )
        {
          ListCompareLabel.ExtendSelectByKey( label.Key() );
          compareLabels.Add( label );
        }
        else
        {
          ListLabelFilter.ExtendSelectByKey( label.Key() );
          fixedLabels.Add( label );
        }  
      }
    }
      
    DataHolderSelectedCompareLabelValues.Data( compareLabels.Copy() );
    DataHolderSelectedFilterLabelValues.Data( fixedLabels.Copy() );
    
    traverse( kpiQuery.MetaDatas().Tokenize( "," ), Elements, md )
    {
      metadata := select( KpiTracker, MetaData, metadata, metadata.DisplayName() = md );
      if( not isnull( metadata ) )
      {
        ListFilterKpi.ExtendSelectByKey( metadata.Key() );
      }
    }
    
    Form.RefreshData();
  *]
}
