IValidationCrossDatabase.Mappings

Syntax

Mappings: IValidationCrossDatabaseMappings;

Description

The Mappings property returns collection of dimension bindings of mapped data sources.

Comments

On setting up the Comparison Between Databases validation by default it is considered that all changes are bound by the same identifiers. The Mappings property is used to create its own bindings and to fix values of free dimensions.

Example

Executing the example requires that repository contains time series database with the TSDB_TARGET identifier containing dimension with the CITY identifier. The time series database should also contain a validation rule with the VALIDATION_CROSSDATABASE identifier. The repository should contain time series database with the TSDB_COMPARATOR identifier including a dimension with the CENTRAL_CITY identifier. The CITY and CENTRAL_CITY dimension should refer to the same dictionary. Identifiers of the rest custom dimensions in time series databases should be identic.

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

Sub UserProc;
Var
    Mb: IMetabase;
    Descr: IMetabaseObjectDescriptor;
    RubTagret, RubComparator: IRubricator;
    ValidObj: IMetabaseObject;
    ValidFilter: IValidationFilter;
    CrossDb: IValidationCrossDatabase;
    ComparisonValue: IValidationComparisonValue;
    ValidExecSett: IValidationExecuteSettings;
    ValidExecRun: IValidationExecRun;
    SelValList: IValidationSelectionValueList;
    SelVal: IValidationSelectionValue;
    AttrMappings: IValidationCrossDatabaseMappings;
    DimTagret, DimComparator: IDimensionModel;
    InstTagret, InstComparator: IDimInstance;
    SelTagret, SelComparator: IDimSelection;
    AtMapping: IValidationCrossDatabaseMapping;
    i: Integer;
Begin
    Mb := MetabaseClass.Active;
    // Get compared time series database and the
    // time series database used for comparison
    Descr := Mb.ItemById("TSDB_TARGET");
    RubTagret := Descr.Bind As IRubricator;
    RubComparator := Mb.ItemById("TSDB_COMPARATOR").Bind As IRubricator;
    // Get validation rule
    ValidObj := Mb.ItemByIdNamespace("VALIDATION_CROSSDATABASE", Descr.Key).Edit;
    ValidFilter := ValidObj As IValidationFilter;
    ValidFilter.Level := DimCalendarLevel.None;
    ValidFilter.Kind := ValidationDetailsKind.CrossDatabase;
    CrossDb := ValidFilter.Details As IValidationCrossDatabase;
    // Set up data comparison parameters
    ComparisonValue := CrossDb.ComparisonValue;
    ComparisonValue.ComparisonOperator := ValidationComparisonOperator.Less;
    ComparisonValue.Percentage := False;
    ComparisonValue.Value1 := 0.5;
    // Set type of metadata change for compared values
    CrossDb.ComparisonType := ValidationRevisionMetadataComparisonType.Change;
    // Specify time series database with which comparison is executed
    CrossDb.Comparator := RubComparator As IVariableStub;
    // Remove existing dimension bindings
    AttrMappings := CrossDb.Mappings;
    If AttrMappings.Count > 0 Then
        AttrMappings.Clear;
    End If;
    // Get dictionaries used to build the CITY and CENTRAL_CITY dimensions
    Descr := RubTagret.Facts.Attributes.FindById("CITY").ValuesObject;
    DimTagret := Descr.Bind As IDimensionModel;
    InstTagret := Descr.Open(NullAs IDimInstance;
    Descr := RubComparator.Facts.Attributes.FindById("CENTRAL_CITY").ValuesObject;
    DimComparator := Descr.Bind As IDimensionModel;
    InstComparator := Descr.Open(NullAs IDimInstance;
    // Get selection of these dictionaries
    SelTagret := InstTagret.CreateSelection;
    SelComparator := InstComparator.CreateSelection;
    // Determine binding of the CITY  dimension and the CENTRAL_CITY dimension
    AtMapping := AttrMappings.Add;
    AtMapping.TargetDim := DimTagret;
    AtMapping.TargetSelectionMapping := SelTagret;
    AtMapping.ComparatorDim := DimComparator;
    AtMapping.ComparatorSelectionMapping := SelComparator;
    AtMapping.Type := ValidationCrossDatabaseMappingType.Attributes;
    // Set compared data
    SelValList := CrossDb.SelectionTargetData;
    SelValList.Clear;
    SelVal := SelValList.Add(SelTagret);
    SelTagret.DeselectAll;
    SelTagret.SelectElement(1False);
    SelVal.Value := SelTagret.ToVariant;
    // Set data from time series database,
    // with which comparison is executed
    SelValList := CrossDb.SelectionComparatorData;
    SelValList.Clear;
    SelVal := SelValList.Add(SelComparator);
    SelComparator.DeselectAll;
    SelComparator.SelectElement(0False);
    SelVal.Value := SelComparator.ToVariant;
    // Remove validation filter
    CrossDb.SelectionFilter.Clear;
    // Save changes and calculate validation rule
    ValidObj.Save;
    ValidExecSett := New ValidationExecuteSettings.Create;
    ValidExecRun := ValidFilter.Execute(ValidExecSett);
End Sub UserProc;

After executing the example, the Compare with Time Series Database validation rule is set up:

The rule is started, execution results are saved to the time series database.

See also:

IValidationCrossDatabase