Quintiq file version 2.0
#parent: #root
Method ApplyConfigurationQuery (
  KpiQuery kpiQuery
) id:Method_Kpi_frmKpiQueryTrack_ApplyConfigurationQuery
{
  #keys: '[146874.0.1477827526]'
  Body:
  [*
    // Applies the configuration query from a KpiQuery to radio button groups, List, checkbox and selector.
    // Query parameters
    dhTimespan.Data( kpiQuery.Timespan() );
    dhDateTimeFrom.Data( kpiQuery.DateTimeFrom() );
    dhDateTimeTo.Data( kpiQuery.DateTimeTo() );
    dhSnapshotLimits.Data( [String] kpiQuery.SnapshotLimit() );
    
    // Label filtering
    dhEnableLabelFiltering.Data( kpiQuery.IsLabelFilteringEnabled() );
    
    // Clear dataholder before add label filters.
    dhLabelFilters.Data().Flush();
    traverse( kpiQuery.LabelFilters().Tokenize( "," ), Elements, labelvalue )
    {
      labelValue := select( KpiTracker, Label.Value, lv, lv.Value() = labelvalue );
      if ( not isnull( labelValue ) )
      {
        dhLabelFilters.Data().Add( labelValue );
      }
    }
    
    // Kpi selection
    dhMetaDatas.Data().Flush();
    traverse( kpiQuery.MetaDatas().Tokenize( "," ), Elements, metadata )
    {
      metaData := select( KpiTracker, MetaData, md, md.DisplayName() = metadata );
      if ( not isnull( metaData ) )
      {
        dhMetaDatas.Data().Add( metaData );
      }
    }
    
    // Series selection
    label := select( KpiTracker, Label, label, label.Name() = kpiQuery.SeriesSelection() );
    dhSeriesSelection.Data( guard( label, null( KpiLabel ) ) );
    dhEnableLastSnapshots.Data( kpiQuery.IsOnlyLastSnapshotEnabled() );
    dhTimestamp.Data( kpiQuery.Timetype() );
  *]
}
