IMsCalculationChainBranch.ParamAttributes

Syntax

ParamAttributes: IMsModelParamAttributes;

Description

The ParamAttributes property determines a condition parameter.

Example

Executing the example requires that the repository contains a modeling container with the CONT_MODEL identifier. This container must include a metamodel with the METAMODEL identifier and models with the DEFAULT, MODEL_1 and MODEL_2 identifiers. The repository must also have a dictionary with the D_SOURCE identifier that contains a group of elements with the DICT_GROUP identifier.

Add links to the Dal, Dimensions, Metabase, Ms, and Orm system assemblies.

Sub UserProc;
Var
    pMetaModel: IMsMetaModel;
    pBranch: IMsCalculationChainBranch;
    pBranchConditions: IMsBranchConditions;
    pBranchParam: IMsModelParamAttributes;
    pCase: IMsBranchCase;
    pCaseList: IMsBranchCaseList;
    Chain, pDefaultContents: IMsCalculationChainEntries;
    pCondSelect: IMsBranchConditionInSelection;
    pCondGroup: IMsBranchConditionInGroup;
    pCondScalar: IMsBranchConditionScalar;
    Case_1, Case_2, Case_default: IMsModel;
    Mb: IMetabase;
    pModelSpace: IMetabaseObjectDescriptor;
    Param: IMsModelParam;
    pDimInstance: IDimInstance;
    pSelection: IDimSelection;
    ParamCollection: IMsModelParams;
Begin
    Mb := MetabaseClass.Active;
    pModelSpace := Mb.ItemById(
"CONT_MODEL");
    pMetaModel := Mb.ItemByIdNamespace(
"METAMODEL", pModelSpace.Key).Edit As IMsMetaModel;
    Chain := pMetaModel.CalculationChain;
    Chain.Clear;
    
// Set metamodel parameter
    ParamCollection:= pMetaModel.Params;
    ParamCollection.Clear;
    Param := ParamCollection.Add;
    Param.DataType := DbDataType.Integer;
    Param.DefaultValue := 
1;
    Param.Hidden := 
True;
    Param.Id := 
"T_ID";
    Param.Name := 
"ID";
    Param.LinkedObject := Mb.ItemById(
"D_SOURCE");
    
// Create a condition node
    pBranch := Chain.AddBranch("Branch");
    pBranchParam := pBranch.ParamAttributes;
    pBranchParam.Parameter := Param;
    pDefaultContents := pBranch.DefaultContents;
    Case_default := Mb.ItemByIdNamespace(
"DEFAULT", pModelSpace.Key).Bind As IMsModel;
    pDefaultContents.AddModel(Case_default);
    
// Create the first condition branch
    pCaseList := pBranch.CaseList;
    pCase := pCaseList.Add;
    Case_1 := Mb.ItemByIdNamespace(
"MODEL_1", pModelSpace.Key).Bind As IMsModel;
    pCase.Contents.AddModel(Case_1);
    pBranchConditions := pCase.Conditions;
    pCondScalar := pBranchConditions.Add(MsBranchConditionType.Scalar) 
As IMsBranchConditionScalar;
    pCondScalar.ComparisonOperator := MsBranchConditionComparisonOperator.Equal;
    pCondScalar.Value := 
6;
    pCondGroup := pBranchConditions.Add(MsBranchConditionType.InGroup) 
As IMsBranchConditionInGroup;
    pDimInstance := Mb.ItemById(
"D_SOURCE").Open(NullAs IDimInstance;
    pCondGroup.ElementGroup := Mb.ItemByIdNamespace(
"DICT_GROUP", pDimInstance.Key).Bind As IDimElementGroup;
    pCondGroup.Negation := 
False;
    pCondGroup.ConditionJoin := OrmLogicalOperator.Or_;
    
// Create the second condition branch
    pCase := pCaseList.Add;
    Case_2 := Mb.ItemByIdNamespace(
"MODEL_2", pModelSpace.Key).Bind As IMsModel;
    pCase.Contents.AddModel(Case_2);
    pBranchConditions := pCase.Conditions;
    pCondSelect := pBranchConditions.Add(MsBranchConditionType.InSelection) 
As IMsBranchConditionInSelection;
    pSelection := pDimInstance.CreateSelection;
    pSelection.DeselectAll;
    pSelection.SelectElement(
2False);
    pCondSelect.Negation := 
False;
    pCondSelect.Selection := pSelection;
    (pMetaModel 
As IMetabaseObject).Save;
End Sub UserProc;

After executing the example, the parameter that refers to the dictionary, and the condition that is based on value of the given parameter, is set for metamodel. The condition consists in the following: if the parameter value is equal to six or it is the part of the group of the dictionary elements, the MODEL_1 model is calculated; if the parameter value is the part of the dictionary selection, the MODEL_2 model is calculated; if none of the given conditions is fulfilled, the DEFAULT model is calculated.

See also:

IMsCalculationChainBranch