IMsBranchCondition.ConditionJoin

Syntax

ConditionJoin: OrmLogicalOperator;

Description

The ConditionJoin property determines join operator for combining with the previous condition.

Comments

The default value. OrmLogicalOperator.And (logical AND).

Example

Executing the example requires that the repository contains a modeling container with the MS identifier containing a metamodel with the METAMODEL_BRANCH_PARAM identifier and a model with the MODEL_BRANCH_PARAM_SEL, MODEL_BRANCH_PARAM_INT, MODEL_BRANCH_PARAM_DEFAULT identifiers . A data source for the modeling container must be a time series database containing a time series attribute with the CITY identifier. This attribute must be a link to the dictionary.

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

Sub UserProc;
Var
    mb: IMetabase;
    MsObj: IMetabaseObjectDescriptor;
    pMetaModel: IMsMetaModel;
    Chain, pDefaultContents: IMsCalculationChainEntries;
    MetaParams: IMsModelParams;
    param1, param2: IMsModelParam;
    TSDB: IRubricator;
    Atrs: IMetaAttributes;
    pBranch: IMsCalculationChainBranch;
    Case_1, Case_2, Case_default: IMsModel;
    pCase: IMsBranchCase;
    pCaseList: IMsBranchCaseList;
    pBranchConditions: IMsBranchConditions;
    pCondSel: IMsBranchConditionInSelection;
    pDimInstance: IDimInstance;
    pSelection: IDimSelection;
    pCondExpr1, pCondExpr2: IMsBranchConditionExpression;
    expr: IExpression;
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 and clear metamodel calculation chain
    Chain := pMetaModel.CalculationChain;
    Chain.Clear;
    
// Get and clear metamodel parameters
    MetaParams := pMetaModel.Params;
    MetaParams.Clear;
    
// Add parameter that refers to dictionary
    param1 := MetaParams.Add;
    param1.DataType := DbDataType.Integer;
    param1.Hidden := 
True;
    param1.Id := 
"P_CITY";
    param1.Name := 
"City";
    
// Get time series database that is used for storing
    // modeling container data
    TSDB := (MsObj.Bind As IMsModelSpace).DefaultObject As IRubricator;
    
// Get time series attributes
    Atrs := TSDB.Facts.Attributes;
    
// Specify that the dictionary, to which the CITY attribute refers,
    // will determine parameter values
    param1.LinkedObject := Atrs.FindById("CITY").ValuesObject;
    
// Add integer parameter
    param2 := MetaParams.Add;
    param2.DefaultValue := 
7;
    param2.Id := 
"P_THRESHOLD";
    param2.Name := 
"Threshold";
    
// Create condition node
    pBranch := Chain.AddBranch("");
    
// Specify that name is generated automatically
    pBranch.AutoName := True;
    
// Create the branch that is executed if no other branch is executed  
    pDefaultContents := pBranch.DefaultContents;
    
// Specify the model that 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 condition branch
    pCaseList := pBranch.CaseList;
    pCase := pCaseList.Add;
    
// Specify the model that 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 branch calculation condition
    pBranchConditions := pCase.Conditions;
    
// Set type of branch calculation condition: include in element selection
    pCondSel := pBranchConditions.Add(MsBranchConditionType.InSelection) As IMsBranchConditionInSelection;
    
// Specify that condition is controlled by parameter
    pCondSel.ParamAttributes.Parameter := Param1;
    
// Specify element selection
    pDimInstance := param1.LinkedObject.Open(NullAs IDimInstance;
    pSelection := pDimInstance.CreateSelection;
    pSelection.SelectElement(
1False);
    pCondSel.Selection := pSelection;
    
// Create the second condition branch
    pCase := pCaseList.Add;
    
// Specify that branch name is generated manually
    pCase.AutoName := False;
    pCase.Name := 
"It is calculated if parameter value is greater than ten or less than five";
    
// Specify the model that will be calculated in this branch
    Case_2 := mb.ItemByIdNamespace("MODEL_BRANCH_PARAM_INT", MsObj.Key).Bind As IMsModel;
    pCase.Contents.AddModel(Case_2);
    
// Create branch calculation condition
    pBranchConditions := pCase.Conditions;
    
// Set type of branch calculation condition: correspond to expression
    pCondExpr1 := pBranchConditions.Add(MsBranchConditionType.Expression) As IMsBranchConditionExpression;
    
// Specify that condition is controlled by parameter
    pCondExpr1.ParamAttributes.Parameter := Param2;
    
// Set expression
    expr := pCondExpr1.Expression;
    expr.AsString := 
"{Threshold}>10";
    
// Add another branch calculation condition of the  "correspond to expression" type
    pCondExpr2 := pBranchConditions.Add(MsBranchConditionType.Expression) As IMsBranchConditionExpression;
    
// Set expression
    expr := pCondExpr2.Expression;
    expr.AsString := 
"{Threshold}<5";
    
// Specify that both conditions are united by logical AND
    pCondExpr2.ConditionJoin := OrmLogicalOperator.Or_;
    
// Save metamodel
    (pMetaModel As IMetabaseObject).Save;
End Sub UserProc;

After executing the example the condition and two parameters will be added to the metamodel. One parameter is referred to the dictionary, another parameter is integer. The condition consists of three branches. The first branch is parametric and is calculated if parameter value is included into the specified selection. The second branch is parametric and is calculated if parameter value is less than five or greater than ten. The third branch is calculated if none of two previous branches were calculated.

See also:

IMsBranchCondition