IMsBranchConditionInSelection.ParameterAsSelection

Fore Syntax

ParameterAsSelection: IMsModelParam;

Fore.NET Syntax

ParameterAsSelection: Prognoz.Platform.Interop.Ms.IMsModelParam;

Description

The ParameterAsSelection property determines parameters specifying selection.

Comments

If the ParameterAsSelection and IMsBranchConditionInSelection.Selection properties are set at the same time, the last specified will be taken into account.

Fore Example

Executing the example requires that repository contains modeling container with the MS identifier containing metamodel with the METAMODEL_BRANCH_PARAM identifier and models with the MODEL_BRANCH_PARAM_SEL, MODEL_BRANCH_PARAM_DEFAULT identifiers. Data source for modeling container should be represented by time series database containing time series attribute with the CITY identifier. This attribute should be a link to the dictionary.

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

Sub UserProc;
Var
    mb: IMetabase;
    MsObj, Dict: IMetabaseObjectDescriptor;
    pMetaModel: IMsMetaModel;
    Chain, pDefaultContents: IMsCalculationChainEntries;
    MetaParams: IMsModelParams;
    param1, param2: IMsModelParam;
    TSDB: IRubricator;
    Atrs: IMetaAttributes;
    pBranch: IMsCalculationChainBranch;
    Case_1, Case_default: IMsModel;
    pCase: IMsBranchCase;
    pCaseList: IMsBranchCaseList;
    pBranchConditions: IMsBranchConditions;
    pCondSel: IMsBranchConditionInSelection;
    pDimInstance: IDimInstance;
    pSelection: IDimSelection;
Begin
    // Get current repository
    mb := MetabaseClass.Active;
    // Get modeling container
    MsObj := mb.ItemById("MS");
    // Get metamodel
    pMetaModel := mb.ItemByIdNamespace("METAMODEL_BRANCH_PARAM", MsObj.Key).Edit As IMsMetaModel;
    // Get time series database used to store
    // modeling container data
    TSDB := (MsObj.Bind As IMsModelSpace).Rubricator As IRubricator;
    // Get time series attributes
    Atrs := TSDB.Facts.Attributes;
    // Get dictionary to which the CITY attribute refers
    Dict := Atrs.FindById("CITY").ValuesObject;
    pDimInstance := Dict.Open(NullAs IDimInstance;
    // Get and clear metamodel calculation chain
    Chain := pMetaModel.CalculationChain;
    Chain.Clear;
    // Get and clear metamodel parameters
    MetaParams := pMetaModel.Params;
    MetaParams.Clear;
    // Add the first parameter which refers to the dictionary
    param1 := MetaParams.Add;
    param1.DataType := DbDataType.Integer;
    param1.Hidden := True;
    param1.Id := "P_CITY";
    param1.Name := "City";
    param1.ParamType := TsParamType.Selection;
    // Specify that dictionary which will determine values of the parameter
    param1.LinkedObject := Dict;
    // Set parameter selection 
    pSelection := pDimInstance.CreateSelection;
    pSelection.SelectElement(1False);
    Param1.DefaultValue := pSelection;
    // Add the second parameters which refers to the dictionary
    param2 := MetaParams.Add;
    param2.DataType := DbDataType.Integer;
    param2.Hidden := True;
    param2.Id := "P_CITY_SEL";
    param2.Name := "City (selection)";
    param2.ParamType := TsParamType.Selection;
    // Specify that dictionary which will determine values of the parameter
    param2.LinkedObject := Dict;
    // Set parameter selection 
    pSelection.DeselectAll;
    pSelection.SelectElement(2False);
    param2.DefaultValue := pSelection;
    // Create condition node
    pBranch := Chain.AddBranch("Condition");
    pBranch.Parameter := param1;
    // Create a branch which is executed, if none of other branches is not executed  
    pDefaultContents := pBranch.DefaultContents;
    // Determine the model which will be calculated in this branch
    Case_default := mb.ItemByIdNamespace("MODEL_BRANCH_PARAM_DEFAULT", MsObj.Key).Bind As IMsModel;
    pDefaultContents.AddModel(Case_default);
    // Create the first branch of condition
    pCaseList := pBranch.CaseList;
    pCase := pCaseList.Add;
    // Determine the model which will be calculated in this branch
    Case_1 := mb.ItemByIdNamespace("MODEL_BRANCH_PARAM_SEL", MsObj.Key).Bind As IMsModel;
    pCase.Contents.AddModel(Case_1);
    // Create condition of branch calculation
    pBranchConditions := pCase.Conditions;
    // Determine type of condition for branch calculation: included into element selection
    pCondSel := pBranchConditions.Add(MsBranchConditionType.InSelection) As IMsBranchConditionInSelection;
    // Determine that condition is managed by the parameter which is a selection
    pCondSel.ParameterAsSelection := Param2;
    // Save metamodel
    (pMetaModel As IMetabaseObject).Save;
End Sub UserProc;

After executing the example, the condition and two parameters will be added to the metamodel. Both parameters are referred to the dictionary. Condition consists of two branches. The first branch is parametric and it is calculated, if parameter value is included in the specified selection. The second branch is calculated if the previous branch was not calculated.

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.Dal;
Imports Prognoz.Platform.Interop.Dimensions;
Imports Prognoz.Platform.Interop.Ms;
Imports Prognoz.Platform.Interop.Rds;
Imports Prognoz.Platform.Interop.Transform;

Public Shared Sub Main(Params: StartParams);
Var
    mb: IMetabase;
    MsObj, Dict: IMetabaseObjectDescriptor;
    pMetaModel: IMsMetaModel;
    Chain, pDefaultContents: IMsCalculationChainEntries;
    MetaParams: IMsModelParams;
    param1, param2: IMsModelParam;
    TSDB: IRubricator;
    Atrs: IMetaAttributes;
    pBranch: IMsCalculationChainBranch;
    Case_1, Case_default: IMsModel;
    pCase: IMsBranchCase;
    pCaseList: IMsBranchCaseList;
    pBranchConditions: IMsBranchConditions;
    pCondSel: IMsBranchConditionInSelection;
    pDimInstance: IDimInstance;
    pSelection: IDimSelection;
Begin
    // Get current repository
    mb := Params.Metabase;
    // Get modeling container
    MsObj := mb.ItemById["MS"];
    // Get metamodel
    pMetaModel := mb.ItemByIdNamespace["METAMODEL_BRANCH_PARAM", MsObj.Key].Edit() As IMsMetaModel;
    // Get time series database used to store
    // modeling container data
    TSDB := (MsObj.Bind() As IMsModelSpace).Rubricator As IRubricator;
    // Get time series attributes
    Atrs := TSDB.Facts.Attributes;
    // Get dictionary to which the CITY attribute refers
    Dict := Atrs.FindById("CITY").ValuesObject;
    pDimInstance := Dict.Open(NullAs IDimInstance;
    // Get and clear metamodel calculation chain
    Chain := pMetaModel.CalculationChain;
    Chain.Clear();
    // Get and clear metamodel parameters
    MetaParams := pMetaModel.Params;
    MetaParams.Clear();
    // Add the first parameter which refers to the dictionary
    param1 := MetaParams.Add();
    param1.DataType := DbDataType.ddtInteger;
    param1.Hidden := True;
    param1.Id := "P_CITY";
    param1.Name := "City";
    param1.ParamType := TsParamType.tsptSelection;
    // Specify that dictionary which will determine values of the parameter
    param1.LinkedObject := Dict;
    // Set parameter selection 
    pSelection := pDimInstance.CreateSelection();
    pSelection.SelectElement(1False);
    Param1.DefaultValue := pSelection;
    // Add the second parameters which refers to the dictionary
    param2 := MetaParams.Add();
    param2.DataType := DbDataType.ddtInteger;
    param2.Hidden := True;
    param2.Id := "P_CITY_SEL";
    param2.Name := "City (selection)";
    param2.ParamType := TsParamType.tsptSelection;
    // Specify that dictionary which will determine values of the parameter
    param2.LinkedObject := Dict;
    // Set parameter selection 
    pSelection.DeselectAll();
    pSelection.SelectElement(2False);
    param2.DefaultValue := pSelection;
    // Create condition node
    pBranch := Chain.AddBranch("Condition");
    pBranch.Parameter := param1;
    // Create a branch which is executed, if none of other branches is not executed  
    pDefaultContents := pBranch.DefaultContents;
    // Determine the model which will be calculated in this branch
    Case_default := mb.ItemByIdNamespace["MODEL_BRANCH_PARAM_DEFAULT", MsObj.Key].Bind() As IMsModel;
    pDefaultContents.AddModel(Case_default);
    // Create the first branch of condition
    pCaseList := pBranch.CaseList;
    pCase := pCaseList.Add();
    // Determine the model which will be calculated in this branch
    Case_1 := mb.ItemByIdNamespace["MODEL_BRANCH_PARAM_SEL", MsObj.Key].Bind() As IMsModel;
    pCase.Contents.AddModel(Case_1);
    // Create condition of branch calculation
    pBranchConditions := pCase.Conditions;
    // Determine type of condition for branch calculation: included into element selection
    pCondSel := pBranchConditions.Add(MsBranchConditionType.mbctInSelection) As IMsBranchConditionInSelection;
    // Determine that condition is managed by the parameter which is a selection
    pCondSel.ParameterAsSelection := Param2;
    // Save metamodel
    (pMetaModel As IMetabaseObject).Save();
End Sub;

See also:

IMsBranchConditionInSelection