Quintiq file version 2.0
#parent: #root
Method ApplyConfigurationQueryAndRefresh (
  KpiQuery kpiQuery
) id:Method_FormKpiQueryCompare_ApplyConfigurationQueryAndRefresh
{
  #keys: '[146874.0.1482342490]'
  Body:
  [*
    // Applies the configuration query from a KpiQuery to radio button groups, List, checkbox and selector.
    kpiLabel := select( KpiTracker, Label, label, label.Name() = kpiQuery.SeriesSelection() );
    DataHolderSeriesSelection.Data( kpiLabel );
    DataHolderTimeType.Data( kpiQuery.Timetype() );
    
    DataHolderCompareLabels.Data().Flush();
    DataHolderLabelFilters.Data().Flush();
    DataHolderMetaDatas.Data().Flush();
    
    traverse( kpiQuery.LabelFilters().Tokenize( "," ), Elements, lv )
    {
      label := select( KpiTracker, Label.Value, labelvalue, labelvalue.Value() = lv );
      if( not isnull( label ) )
      {
        if( label.Label() = kpiLabel )
        {
          DataHolderCompareLabels.Data().Add( label );
        }
        else
        {
          DataHolderLabelFilters.Data().Add( label );
        }
      }
    }
    
    
    traverse( kpiQuery.MetaDatas().Tokenize( "," ), Elements, md )
    {
      metaData := select( KpiTracker, MetaData, metadata, metadata.DisplayName() = md );
      if( not isnull(  metaData ) )
      {
        DataHolderMetaDatas.Data().Add( metaData );
      }
    }
    
    Form.RefreshData();
  *]
}
