Add: IMetaDataRule;
The Add method adds a new rule to the collection.
Executing the example requires a time series database with the OBJ_FC identifier. This database must have the COUNTRY and INDICATOR attributes.
Add links to the Metabase, Cubes, Orm and Rds system assemblies.
Sub UserProc;
Var
Mb: IMetabase;
Rub: IRubricator;
Dict: IMetaDictionary;
MetaDataRules: IMetaDataRules;
MetaDataRule: IMetaDataRule;
Conditions: IOrmConditions;
Condition: IOrmCondition;
i: Integer;
x: array Of Variant;
Begin
Mb := MetabaseClass.Active;
Rub := Mb.ItemById("OBJ_FC").Bind As IRubricator;
Dict := (Rub.Facts As IMetabaseObject).Edit As IMetaDictionary;
MetaDataRules := Dict.DataRules;
//Delete all existing rules
For i := MetaDataRules.Count - 1 To 0 Step - 1 Do
MetaDataRules.Remove(MetaDataRules.Item(i));
End For;
//Create a new rule
MetaDataRule := MetaDataRules.Add;
//Create conditions for selecting time series , for which the rule conditions need to be checked
//Condition: One of the time series is selected for the specified country
Conditions := MetaDataRule.Condition;
Condition := Conditions.Add;
Condition.AttributeName := "COUNTRY";
Condition.Operator_ := OrmComparisonOperator.In_;
x := New Variant[2];
x[0] := 976;
x[1] := 979;
Condition.Value := x;
Condition := Conditions.Add;
Condition.AttributeName := "INDICATOR";
Condition.Operator_ := OrmComparisonOperator.In_;
x := New Variant[2];
x[0] := 1035;
x[1] := 1036;
Condition.Value := x;
Condition.ConditionJoin := OrmLogicalOperator.And_;
//Rule conditions checked for time series
//Condition: Time series units correspond to one of the specified values
Conditions := MetaDataRule.Rule;
Condition := Conditions.Add;
Condition.AttributeName := "UNIT";
Condition.Operator_ := OrmComparisonOperator.Equal;
Condition.Value := 3430;
Condition := Conditions.Add;
Condition.AttributeName := "UNIT";
Condition.Operator_ := OrmComparisonOperator.Equal;
Condition.Value := 3530;
Condition.ConditionJoin := OrmLogicalOperator.Or_;
(Dict As IMetabaseObject).Save;
End Sub UserProc;
After executing the example, a rule is created for the dictionary of indicators of the time series database with the OBJ_FC identifier. The rule will be checked in the following way:
The rule will be checked for the time series, which have one of the specified country keys or one of the specified time series keys set (for countries with keys 976 or 979, indicators 1035 or 1036 must be specified).
The time series, for which the rule is checked, must have a unit with one of the specified keys (3430 or 3530).
See also: