IMetaDataRules.Add

Syntax

Add: IMetaDataRule;

Description

The Add method adds a new rule to the collection.

Example

Executing the example requires a time series database with the OBJ_FC identifier. This database must have the COUNTRY and INDICATOR attributes.

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 specified factors is determined 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: Correspondence of measurement units by factor of 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 the OBJ_FC database time series. The rule will be checked in the following way:

See also:

IMetaDataRules