Quintiq file version 2.0
#parent: #root
Method GetConfigurationQuery () as JSON id:Method_Kpi_frmKpiSnapshots_GetConfigurationQuery
{
  #keys: '[146450.3.312493348]'
  Body:
  [*
    // Converts the configuration query into JSON.
    json := JSON::Object();
    
    queryType := KpiQuery::QUERY_TRACK();
    
    json.Add( "QueryType", queryType );
    
    // Query parameters                      
    // Default value for datetimefrom and datetimeto
    datetimefrom := DateTime::MinDateTime();
    datetimeto    := DateTime::MaxDateTime();
    timespan     := rbgTimespan.BoundValue();
    if( timespan = "range" )
    {
      datetimefrom := dtFrom.DateTime();
      datetimeto   := dtTo.DateTime();
    }
    limit        := txtSnapshotLimit.Text();
    
    json.Add( "Timespan", timespan );
    json.Add( "DateTimeFrom", [String] datetimefrom );
    json.Add( "DateTimeTo", [String] datetimeto );
    json.Add( "LimitSnapshot", [Number] limit );
    
    // Other
    isAllSnapshotEnabled := cbSelectAllSnapshots.Checked();
    json.Add( "IsAllSnapsnotEnabled", isAllSnapshotEnabled );
    
    // Label filtering
    isLabelFilteringEnabled := cbLabelFilterEnabled.Checked();
    labelfilters := selectvalues( dhSelectedLabelValues.Data(), Elements, labelvalue, true, labelvalue.Value() );
    
    json.Add( "IsLabelFilteringEnabled", isLabelFilteringEnabled );
    json.Add( "LabelFilters", labelfilters.ToString( "," ) );
    
    // Kpi selection
    metadatas := selectvalues( dhSelectedKpis.Data(), Elements, metadata, true, metadata.DisplayName() );
    json.Add( "MetaDatas", metadatas.ToString( "," ) );
    
    // Series selection
    series := guard( selSeries.Data().Name(), '' );
    isLastSnapshotEnabled := cbOnlyLastSnapshot.Checked() and cbOnlyLastSnapshot.Enabled();
    timetype := rbgTimeType.BoundValue();
    
    json.Add( "Series", series );
    json.Add( "IsLastSnapshotEnabled", isLastSnapshotEnabled );
    json.Add( "Timetype", timetype );
    
    return &json.Build();
  *]
  ReturnsOwning: true
}
