ConditionJoin: OrmLogicalOperator;
ConditionJoin: Prognoz.Platform.Interop.Orm.OrmLogicalOperator;
The ConditionJoin property determines join operator for combining with the previous condition.
Default value. OrmLogicalOperator.And (logical AND).
Executing the example requires that repository contains modeling container with the MS identifier containing metamodel with the METAMODEL_BRANCH_PARAM identifier and model with the MODEL_BRANCH_PARAM_SEL, MODEL_BRANCH_PARAM_INT, 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, 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 which is referred to the dictionary
param1 := MetaParams.Add;
param1.DataType := DbDataType.Integer;
param1.Hidden := True;
param1.Id := "P_CITY";
param1.Name := "City";
// 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;
// Determine that the dictionary to which the CITY attribute is referred
// will determine values of the following parameter
param1.LinkedObject := Atrs.FindById("CITY").ValuesObject;
// Add an integer parameter
param2 := MetaParams.Add;
param2.DefaultValue := 7;
param2.Id := "P_THRESHOLD";
param2.Name := "Thershold";
// Create 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 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 following parameter
pCondSel.Parameter := Param1;
// Determine elements selection
pDimInstance := param1.LinkedObject.Open(Null) As IDimInstance;
pSelection := pDimInstance.CreateSelection;
pSelection.SelectElement(1, False);
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 which 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 condition of branch calculation
pBranchConditions := pCase.Conditions;
// Determine type of branch calculation condition: corresponding to the expression
pCondExpr1 := pBranchConditions.Add(MsBranchConditionType.Expression) As IMsBranchConditionExpression;
// Determine that condition is managed by the following parameter
pCondExpr1.Parameter := Param2;
// Determine expression
expr := pCondExpr1.Expression;
expr.AsString := "{Thershold}>10";
// Add one more branch calculation condition of the Corresponding to the expression type
pCondExpr2 := pBranchConditions.Add(MsBranchConditionType.Expression) As IMsBranchConditionExpression;
// Determine expression
expr := pCondExpr2.Expression;
expr.AsString := "{Threshold}<5";
// Determine that both conditions are united by The AND logical operator
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. Condition consists of three branches. The first branch is parametric and it is calculated, if parameter value is included in the specified selection. The second branch is parametric and it is calculated, if parameter values is less than five or more than ten. The third branch is calculated, if none of two previous branches was not calculated.
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 which is referred to the dictionary
param1 := MetaParams.Add();
param1.DataType := DbDataType.ddtInteger;
param1.Hidden := True;
param1.Id := "P_CITY";
param1.Name := "City";
// 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;
// Determine that the dictionary to which the CITY attribute is referred
// will determine values of the following parameter
param1.LinkedObject := Atrs.FindById("CITY").ValuesObject;
// Add an integer parameter
param2 := MetaParams.Add();
param2.DefaultValue := 7;
param2.Id := "P_THRESHOLD";
param2.Name := "Thershold";
// Create condition node
pBranch := Chain.AddBranch("");
// Specify that name is generated automatically
pBranch.AutoName := True;
// Create 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 following parameter
pCondSel.Parameter := Param1;
// Determine elements selection
pDimInstance := param1.LinkedObject.Open(Null) As IDimInstance;
pSelection := pDimInstance.CreateSelection();
pSelection.SelectElement(1, False);
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 which 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 condition of branch calculation
pBranchConditions := pCase.Conditions;
// Determine type of branch calculation condition: corresponding to the expression
pCondExpr1 := pBranchConditions.Add(MsBranchConditionType.mbctExpression) As IMsBranchConditionExpression;
// Determine that condition is managed by the following parameter
pCondExpr1.Parameter := Param2;
// Determine expression
expr := pCondExpr1.Expression;
expr.AsString := "{Thershold}>10";
// Add one more branch calculation condition of the Corresponding to the expression type
pCondExpr2 := pBranchConditions.Add(MsBranchConditionType.mbctExpression) As IMsBranchConditionExpression;
// Determine expression
expr := pCondExpr2.Expression;
expr.AsString := "{Threshold}<5";
// Determine that both conditions are united by The AND logical operator
pCondExpr2.ConditionJoin := OrmLogicalOperator.oloOr;
// Save metamodel
(pMetaModel As IMetabaseObject).Save();
End Sub;
See also: