IMsProblemCalculation.MetaAttributeFilter

Fore Syntax

MetaAttributeFilter: IMsMetaAttributeFilter;

Fore.NET Syntax

MetaAttributeFilter: Prognoz.Platform.Interop.Ms.IMsMetaAttributeFilter;

Description

The MetaAttributeFilter property returns an object that contains the filter applied on modeling problem calculation.

Comments

By default empty filter is applied.

Fore Example

Executing the example requires that the repository contains a modeling container with the MS identifier containing a modeling problem with the PROBLEM_METAFILTER identifier. The time series database which is a data source for modeling container should contain attribute of the CITY series referring to dictionary.

Add links to the Cubes, Dimensions, Metabase, Ms, Rds system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    Descr: IMetabaseObjectDescriptor;
    Problem: IMsProblem;
    CalcSettings: IMsProblemCalculationSettings;
    Calculation: IMsProblemCalculation;
    Ruby: IRubricator;
    MetaAttr: IMetaAttribute;
    MetaVals: IMsMetaAttributeValues;
    Dict: IMetabaseObject;
    DI: IDimInstance;
    Sel: IDimSelection;
Begin
    // Get current repository
    MB := MetabaseClass.Active;
    // Get modeling container
    Descr := MB.ItemById("MS");
    // Get modeling problem
    Problem := MB.ItemByIdNamespace("PROBLEM_METAFILTER", Descr.Key).Edit As IMsProblem;
    // Create problem calculation settings
    CalcSettings := Problem.CreateCalculationSettings;
    // Determine that calculation will be made by the Fact scenario
    CalcSettings.FactIncluded := True;
    // Create an object for problem calculation
    Calculation := Problem.Calculate(CalcSettings);
    // Get time series database which is data source for modeling container
    Ruby := (Descr.Bind As IMsModelSpace).DefaultObject.Bind As IRubricator;
    // Get attribute of the CITY series
    MetaAttr := Ruby.Facts.Attributes.FindById("CITY");
    // Add filtering by this attribute
    MetaVals := Calculation.MetaAttributeFilter.Add(MetaAttr);
    // Create selection of the CITY attribute
    Dict := MetaAttr.ValuesObject.Bind;
    DI := Dict.Open(NullAs IDimInstance;
    Sel := DI.CreateSelection;
    Sel.SelectElement(0False);
    // Determine selection to the filter
    MetaVals.Selection := Sel;
    // Perform calculation
    Calculation.Run;
    // Save changes in modeling task
    (Problem As IMetabaseObject).Save;
End Sub UserProc;

After executing the example filtering is set and calculation is performed for modeling problem.

Fore.NET Example

The requirements and result of the Fore.NET example execution match with those in the Fore example.

Imports Prognoz.Platform.Interop.Cubes;
Imports Prognoz.Platform.Interop.Dimensions;
Imports Prognoz.Platform.Interop.Ms;
Imports Prognoz.Platform.Interop.Rds;

Public Shared Sub Main(Params: StartParams);
Var
    MB: IMetabase;
    Descr: IMetabaseObjectDescriptor;
    Problem: IMsProblem;
    CalcSettings: IMsProblemCalculationSettings;
    Calculation: IMsProblemCalculation;
    Ruby: IRubricator;
    MetaAttr: IMetaAttribute;
    MetaVals: IMsMetaAttributeValues;
    Dict: IMetabaseObject;
    DI: IDimInstance;
    Sel: IDimSelection;
Begin
    // Get current repository
    MB := Params.Metabase;
    // Get modeling container
    Descr := MB.ItemById["MS"];
    // Get modeling problem
    Problem := MB.ItemByIdNamespace["PROBLEM_METAFILTER", Descr.Key].Edit() As IMsProblem;
    // Create problem calculation settings
    CalcSettings := Problem.CreateCalculationSettings();
    // Determine that calculation will be made by the Fact scenario
    CalcSettings.FactIncluded := True;
    // Create an object for problem calculation
    Calculation := Problem.Calculate(CalcSettings);
    // Get time series database which is data source for modeling container
    Ruby := (Descr.Bind() As IMsModelSpace).DefaultObject.Bind() As IRubricator;
    // Get attribute of the CITY series
    MetaAttr := Ruby.Facts.Attributes.FindById("CITY");
    // Add filtering by this attribute
    MetaVals := Calculation.MetaAttributeFilter.Add(MetaAttr);
    // Create selection of the CITY attribute
    Dict := MetaAttr.ValuesObject.Bind();
    DI := Dict.Open(NullAs IDimInstance;
    Sel := DI.CreateSelection();
    Sel.SelectElement(0False);
    // Determine selection to the filter
    MetaVals.Selection := Sel;
    // Perform calculation
    Calculation.Run();
    // Save changes in modeling task
    (Problem As IMetabaseObject).Save();
End Sub;

See also:

IMsProblemCalculation