ParameterAsSelection: IMsModelParam;
ParameterAsSelection: Prognoz.Platform.Interop.Ms.IMsModelParam;
The ParameterAsSelection property determines parameters for sending selection to filter element.
To set the parameter value, use the IValidationExecuteSettings.ParamValues property
Executing the example requires a form containing the WorkbookDocumentViewerBox component with the WorkbookDocumentViewerBox1 identifier and the UiErAnalayzer component with the UiErAnalyzer1 identifier. UiErAnalyzer1 is a data source for WorkbookDocumentViewerBox1 and contains a time series database workbook with the TSDB_VALIDATION_PARAMETERS identifier. Time series database parameters:
The mandatory series attribute with the CITY identifier referring to the dictionary.
A validation rule with the VALIDATION_TREND identifier of the Compare Trends type.
Add links to the Cubes, Dimensions, Metabase, Ms, Rds system assemblies.
The example is the method to add parameter to the validation filter. The parameter limits the filtered series set. Method input parameters:
IsGroup. It determines whether the parameter value is the group of elements. True - the parameter value is the group of elements; False - the parameter value is the elements selection.
Value. Parameter value.
Sub AddFilterParam(IsGroup: Boolean; Value: Variant);
Var
mb: IMetabase;
FCObj: IMetabaseObject;
FC: IRubricator;
Atts: IMetaAttributes;
LinkedDict: IMetabaseObjectDescriptor;
ValidObj: IMetabaseObject;
ValidFilter: IValidationFilter;
Params: IMsModelParams;
FilterPrarm: IMsModelParam;
Filter: IValidationSelectionFilter;
Sel: IDimSelection;
FilterVal: IValidationSelectionValues;
ExecSett: IValidationExecuteSettings;
Analyzer: IEaxAnalyzer;
ParamVals: IMsModelParamValues;
ExecRun: IValidationExecRun;
DiagRep: IDiagnosticReport;
Begin
mb := MetabaseClass.Active;
// Get time series database
FCObj := mb.ItemById("TSDB_VALIDATION_PARAMETERS").Bind;
FC := FCObj As IRubricator;
// Get dictionary, to which the CITY attribute refers
Atts := FC.Facts.Attributes;
LinkedDict := Atts.FindById("CITY").ValuesObject;
// Get validation rule
ValidObj := Mb.ItemByIdNamespace("VALIDATION_TREND", FCObj.Key).Edit;
ValidFilter := ValidObj As IValidationFilter;
// Get validation rule parameters
Params := ValidFilter.Params;
Params.Clear;
// Add parameter for elements filtering
FilterPrarm := Params.Add;
FilterPrarm.Id := "FILTER_CITY";
FilterPrarm.Name := "City for filter";
FilterPrarm.LinkedObject := LinkedDict;
// Set validation filter based on the parameter
Filter := (ValidFilter.Details As IValidationTrend).SelectionFilter;
Filter.Clear;
Sel := (LinkedDict.Open(Null) As IDimInstance).CreateSelection;
FilterVal := Filter.Add(Sel);
If IsGroup Then
FilterVal.ParameterAsGroup := FilterPrarm;
Else
FilterVal.ParameterAsSelection := FilterPrarm;
End If;
// Save validation rule
ValidObj.Save;
// Set rule execution parameters
ExecSett := ValidFilter.CreateExecuteSettings;
Analyzer := UiErAnalyzer1.ErAnalyzer;
ExecSett.Laner := Analyzer.Laner;
// Set parameter values
ParamVals := ExecSett.ParamValues;
ParamVals.FindById("FILTER_CITY").Value := Value;
// Execute validation rule
ExecRun := ValidFilter.Execute(ExecSett);
DiagRep := New DiagnosticReport.Create;
DiagRep.Run := ExecRun;
DiagRep.EaxAnalyzer := Analyzer;
End Sub AddFilterParam;
After executing the example the filter is set for the VALIDATION_TREND validation rule. The selection forming the filter is set by the COMPAR_CITY parameter. This parameter determines value of the CITY mandatory attribute. The rule is calculated for the workbook displayed in WorkbookDocumentViewerBox1.
The requirements and result of the Fore.NET example execution match with those in the Fore example. Use Fore.NET analogs instead of Fore components.
Imports Prognoz.Platform.Interop.Cubes;
Imports Prognoz.Platform.Interop.Dimensions;
Imports Prognoz.Platform.Interop.Express;
Imports Prognoz.Platform.Interop.Metabase;
Imports Prognoz.Platform.Interop.Ms;
Imports Prognoz.Platform.Interop.Rds;
…
Public Sub AddFilterParam(IsGroup: Boolean; Value: object);
Var
mb: IMetabase;
FCObj: IMetabaseObject;
FC: IRubricator;
Atts: IMetaAttributes;
LinkedDict: IMetabaseObjectDescriptor;
ValidObj: IMetabaseObject;
ValidFilter: IValidationFilter;
Params: IMsModelParams;
FilterPrarm: IMsModelParam;
Filter: IValidationSelectionFilter;
Sel: IDimSelection;
FilterVal: IValidationSelectionValues;
ExecSett: ValidationExecuteSettings;
Analyzer: EaxAnalyzer;
ParamVals: IMsModelParamValues;
ExecRun: IValidationExecRun;
DiagRep: IDiagnosticReport;
Begin
mb := self.Metabase;
// Get time series database
FCObj := mb.ItemById["TSDB_VALIDATION_PARAMETERS"].Bind();
FC := FCObj As IRubricator;
// Get dictionary, to which the CITY attribute refers
Atts := FC.Facts.Attributes;
LinkedDict := Atts.FindById("CITY").ValuesObject;
// Get validation rule
ValidObj := Mb.ItemByIdNamespace["VALIDATION_TREND", FCObj.Key].Edit();
ValidFilter := ValidObj As IValidationFilter;
// Get validation rule parameters
Params := ValidFilter.Params;
Params.Clear();
// Add parameter for elements filtering
FilterPrarm := Params.Add();
FilterPrarm.Id := "FILTER_CITY";
FilterPrarm.Name := "City for filter";
FilterPrarm.LinkedObject := LinkedDict;
// Set validation filter based on the parameter
Filter := (ValidFilter.Details As IValidationTrend).SelectionFilter;
Filter.Clear();
Sel := (LinkedDict.Open(Null) As IDimInstance).CreateSelection();
FilterVal := Filter.Add(Sel);
If IsGroup Then
FilterVal.ParameterAsGroup := FilterPrarm;
Else
FilterVal.ParameterAsSelection := FilterPrarm;
End If;
// Save validation rule
ValidObj.Save();
// Set rule execution parameters
ExecSett := ValidFilter.CreateExecuteSettings();
Analyzer := uiErAnalyzerNet1.ErAnalyzer.ErAnalyzer;
ExecSett.Laner := Analyzer.Laner;
// Set parameter values
ParamVals := ExecSett.ParamValues;
ParamVals.FindById("FILTER_CITY").Value := Value;
// Execute validation rule
ExecRun := ValidFilter.Execute(ExecSett);
DiagRep := New DiagnosticReport.Create();
DiagRep.Run := ExecRun;
DiagRep.EaxAnalyzer := Analyzer;
End Sub AddFilterParam;
See also: