IMsBranchCondition.ConditionJoin

Fore Syntax

ConditionJoin: OrmLogicalOperator;

Fore.NET Syntax

ConditionJoin: Prognoz.Platform.Interop.Orm.OrmLogicalOperator;

Description

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

Comments

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

Fore 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 represented by 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, 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 a parameter that is referred 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 to store
    // modeling container data
    TSDB := (MsObj.Bind As IMsModelSpace).Rubricator As IRubricator;
    // Get time series attributes
    Atrs := TSDB.Facts.Attributes;
    // Determine that dictionary, to which the CITY attribute is referred,
    // will determine values of parameter
    param1.LinkedObject := Atrs.FindById("CITY").ValuesObject;
    // Add an integer parameter
    param2 := MetaParams.Add;
    param2.DefaultValue := 7;
    param2.Id := "P_THRESHOLD";
    param2.Name := "Threshold";
    // Create a condition node
    pBranch := Chain.AddBranch("");
    // Specify that name is generated automatically
    pBranch.AutoName := True;
    // Create a branch, which is executed if none of other branches is executed  
    pDefaultContents := pBranch.DefaultContents;
    // Determine 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 branch of condition
    pCaseList := pBranch.CaseList;
    pCase := pCaseList.Add;
    // Determine 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 a condition of branch calculation
    pBranchConditions := pCase.Conditions;
    // Determine a type of condition for branch calculation: included into element selection
    pCondSel := pBranchConditions.Add(MsBranchConditionType.InSelection) As IMsBranchConditionInSelection;
    // Determine that condition is managed by parameter
    pCondSel.Parameter := Param1;
    // Determine elements selection
    pDimInstance := param1.LinkedObject.Open(NullAs IDimInstance;
    pSelection := pDimInstance.CreateSelection;
    pSelection.SelectElement(1False);
    pCondSel.Selection := pSelection;
    // Create the second branch of condition
    pCase := pCaseList.Add;
    // Determine 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";
    // Determine 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 a condition of branch calculation
    pBranchConditions := pCase.Conditions;
    // Determine a type of branch calculation condition: corresponding to the expression
    pCondExpr1 := pBranchConditions.Add(MsBranchConditionType.Expression) As IMsBranchConditionExpression;
    // Determine that condition is managed by parameter
    pCondExpr1.Parameter := Param2;
    // Determine an expression
    expr := pCondExpr1.Expression;
    expr.AsString := "{Threshold}>10";
    // Add another branch calculation condition of the Corresponding to Expression type
    pCondExpr2 := pBranchConditions.Add(MsBranchConditionType.Expression) As IMsBranchConditionExpression;
    // Determine an expression
    expr := pCondExpr2.Expression;
    expr.AsString := "{Threshold}<5";
    // Determine that both conditions are joined 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.

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.ForeSystem;
Imports Prognoz.Platform.Interop.Ms;
Imports Prognoz.Platform.Interop.Orm;
Imports Prognoz.Platform.Interop.Rds;

Public Shared Sub Main(Params: StartParams);
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 := Params.Metabase;
    // 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 a parameter that is referred to dictionary
    param1 := MetaParams.Add();
    param1.DataType := DbDataType.ddtInteger;
    param1.Hidden := True;
    param1.Id := "P_CITY";
    param1.Name := "City";
    // Get time series database that is used to store
    // modeling container data
    TSDB := (MsObj.Bind() As IMsModelSpace).Rubricator As IRubricator;
    // Get time series attributes
    Atrs := TSDB.Facts.Attributes;
    // Determine that dictionary, to which the CITY attribute is referred,
    // will determine values of parameter
    param1.LinkedObject := Atrs.FindById("CITY").ValuesObject;
    // Add an integer parameter
    param2 := MetaParams.Add();
    param2.DefaultValue := 7;
    param2.Id := "P_THRESHOLD";
    param2.Name := "Threshold";
    // Create a condition node
    pBranch := Chain.AddBranch("");
    // Specify that name is generated automatically
    pBranch.AutoName := True;
    // Create a branch that is executed if none of other branches is executed
    pDefaultContents := pBranch.DefaultContents;
    // Determine 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 branch of condition
    pCaseList := pBranch.CaseList;
    pCase := pCaseList.Add();
    // Determine 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 a condition of branch calculation
    pBranchConditions := pCase.Conditions;
    // Determine a type of condition for branch calculation: included into element selection
    pCondSel := pBranchConditions.Add(MsBranchConditionType.mbctInSelection) As IMsBranchConditionInSelection;
    // Determine that condition is managed by parameter
    pCondSel.Parameter := Param1;
    // Determine elements selection
    pDimInstance := param1.LinkedObject.Open(NullAs IDimInstance;
    pSelection := pDimInstance.CreateSelection();
    pSelection.SelectElement(1False);
    pCondSel.Selection := pSelection;
    // Create the second branch of condition
    pCase := pCaseList.Add();
    // Determine 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";
    // Determine 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 a condition of branch calculation
    pBranchConditions := pCase.Conditions;
    // Determine a type of branch calculation condition: corresponding to the expression
    pCondExpr1 := pBranchConditions.Add(MsBranchConditionType.mbctExpression) As IMsBranchConditionExpression;
    // Determine that condition is managed by parameter
    pCondExpr1.Parameter := Param2;
    // Determine an expression
    expr := pCondExpr1.Expression;
    expr.AsString := "{Threshold}>10";
    // Add another branch calculation condition of the Corresponding to Expression type
    pCondExpr2 := pBranchConditions.Add(MsBranchConditionType.mbctExpression) As IMsBranchConditionExpression;
    // Determine an expression
    expr := pCondExpr2.Expression;
    expr.AsString := "{Threshold}<5";
    // Determine that both conditions are joined by logical AND
    pCondExpr2.ConditionJoin := OrmLogicalOperator.oloOr;
    // Save metamodel
    (pMetaModel As IMetabaseObject).Save();
End Sub;

See also:

IMsBranchCondition