IMsBranchCondition.Type

Syntax

Type: MsBranchConditionType;

Description

The Type property returns condition type.

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.

Sub Main;

Var

pMetaModel: IMsMetaModel;

pBranch: IMsCalculationChainBranch;

pBranchConditions: IMsBranchConditions;

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;

params: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

params:=pMetaModel.Params;

params.Clear;

param:=params.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");

pBranch.Parameter := Param;

pDefaultContents := pBranch.DefaultContents;

Case_default := mb.ItemByIdNamespace("DEFAULT", pModelSpace.Key).Bind As IMsModel;

pDefaultContents.AddModel(Case_default);

 

// Create the first branch of condition

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(Null) As IDimInstance;

pCondGroup.ElementGroup := mb.ItemByIdNamespace("DICT_GROUP", pDimInstance.Key).Bind As IDimElementGroup;

pCondGroup.Negation := False;

pCondGroup.ConditionJoin := OrmLogicalOperator.Or_;

 

// Create the second branch of condition

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(2, False);

pCondSelect.Negation := False;

pCondSelect.Selection := pSelection;

 

(pMetaModel As IMetabaseObject).Save;

End Sub Main;

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

See also:

IMsBranchCondition