Quintiq file version 2.0
#parent: #root
Method ApplyConfigurationQuery (
  KpiQuery kpiQuery
) id:Method_Kpi_frmKpiSnapshots_ApplyConfigurationQuery
{
  #keys: '[146450.3.312495465]'
  Body:
  [*
    // Applies the configuration query from a KpiQuery to radio button groups, List, checkbox and selector.
    // Query parameters
    rbgTimespan.BoundValue( kpiQuery.Timespan() );
    dtFrom.DateTime( kpiQuery.DateTimeFrom() );
    dtTo.DateTime( kpiQuery.DateTimeTo() );
    txtSnapshotLimit.Text( [String] kpiQuery.SnapshotLimit() );
    
    // Other
    cbSelectAllSnapshots.Checked( kpiQuery.IsAllSnapshotSelected() );
    
    // Label filtering
    cbLabelFilterEnabled.Checked( kpiQuery.IsLabelFilteringEnabled() );
    
    // Reset the selection before extend select
    lstLabelFilter.SelectByKey( Key::ZeroKey() );
    traverse( kpiQuery.LabelFilters().Tokenize( "," ), Elements, labelvalue )
    {
      labelValue := select( KpiTracker, Label.Value, lv, lv.Value() = labelvalue );
      if ( not isnull( labelValue ) )
      {
        lstLabelFilter.ExtendSelectByKey( labelValue.Key() );
      }
    } 
    
    // Kpi selection
    lstKpiMetaData.SelectByKey( Key::ZeroKey() );
    traverse( kpiQuery.MetaDatas().Tokenize( "," ), Elements, metadata )
    {
      metaData := select( KpiTracker, MetaData, md, md.DisplayName() = metadata );
      if ( not isnull( metaData ) )
      {
        lstKpiMetaData.ExtendSelectByKey( metaData.Key() );
      }
    }
    
    // Series selection
    selSeries.BoundValue( kpiQuery.SeriesSelection() )
    cbOnlyLastSnapshot.Checked( kpiQuery.IsOnlyLastSnapshotEnabled() );
    rbgTimeType.BoundValue( kpiQuery.Timetype() );
  *]
}
