ICubeMetaUpdateAttributeRemapping.AlternateHierarchyMappings

Syntax

AlternateHierarchyMappings: IAlternateHierarchyMappings;

Description

The IAlternateHierarchyMappings property returns parameters of correspondence between alternative hierarchies in the dictionary of the copied time series database and alternative hierarchies in the dictionaries of the database copy.

Comments

Parameters of correspondence between alternative hierarchies and relevant for time series attributes being a reference to the dictionary.

Example

Executing the example requires that the repository contains time series databases with the TSDB_SRC_HIE and TSDB_DEST_HIE identifiers. Data of the time series database must have the same structure and contain a time series attribute with the INDICATOR identifier. The attribute must be a reference to the dictionary. In the TSDB_SRC_HIE time series database the INDICATOR attribute must refer to the DICT_INDICATOR_SRC dictionary; in the TSDB_DEST_HIE dictionary - to the DICT_INDICATOR_DEST dictionary. The DICT_INDICATOR_SRC and the DICT_INDICATOR_DEST dictionaries must have the same structure and contain two or more alternative hierarchies.

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

Sub UserProc;
Var
    mb: IMetabase;
    CrInfo: IMetabaseObjectCreateInfo;
    Obj: IMetabaseObject;
    ObjDesc: IMetabaseObjectDescriptor;
    RubUpdateEx: ICubeMetaUpdateEx;
    Rub: IRubricator;
    AttrRemapping: ICubeMetaUpdateAttributeRemappings;
    AttrR: ICubeMetaUpdateAttributeRemapping;
    Attr: IMetaAttribute;
    AlterHies: IDimHierarchies;
    AlterHie: IDimHierarchy;
    HieMappings: IAlternateHierarchyMappings;
    HieMap: IAlternateHierarchyMapping;
    Progress: IMetabaseUpdateProgress;
Begin
    // Get repository
    mb := MetabaseClass.Active;
    // Create a copying object
    CrInfo := Mb.CreateCreateInfo;
    CrInfo.ClassId := MetabaseObjectClass.KE_CLASS_CUBEMETAUPDATE;
    CrInfo.Id := Mb.GenerateId("Cube_Meta_Upd");
    CrInfo.Permanent := True;
    CrInfo.Parent := Mb.Root;
    ObjDesc := Mb.CreateObject(CrInfo);
    Obj := ObjDesc.Edit;
    // Set parameters of copying object
    RubUpdateEx := Obj As ICubeMetaUpdateEx;
    // Specify time series database being a data source
    Rub := mb.ItemById("TSDB_SRC_HIE").Bind As IRubricator;
    RubUpdateEx.Rubricator := Rub;
    // Specify repository to copy time series database in
    RubUpdateEx.Metabase := Mb;
    // Specify MDM repository to store time series database
    RubUpdateEx.RdsDatabase := Rub.Database;
    // Specify time series database being a data consumer
    RubUpdateEx.TargetRubricator := mb.ItemById("TSDB_DEST_HIE").Bind As IRubricator;
    // Set attribute correspondence
    AttrRemapping := RubUpdateEx.MetafactsAttributeRemappings;
    // Set correspondence parameters for the INDICATOR attribute both in source and consumer
    AttrR := AttrRemapping.FindById("INDICATOR");
    // Set correspondence parameters for alternative hierarchies both in source and consumer
    HieMappings := AttrR.AlternateHierarchyMappings;
    // Get all alternative hierarchies that exist in dictionary,
    // being a data source for the INDICATOR attribute in source time series database
    Attr := Rub.Facts.Attributes.FindById("INDICATOR");
    AlterHies := (Attr.ValuesObject.Bind As IDimensionModel).Hierarchies;
    // Get the first alternative hierarchy
    AlterHie := AlterHies.Item(0);
    // Create a correspondence between alternative hierarchies in source and consumer
    HieMap := HieMappings.Add(AlterHie.Key, AlterHie.Id);
    // Get all alternative hierarchies that exist in dictionary,
    // being a data source for the INDICATOR attribute. The attribute is contained in database
    // time series being data consumers.
    Rub := RubUpdateEx.TargetRubricator;
    Attr := Rub.Facts.Attributes.FindById("INDICATOR");
    AlterHies := (Attr.ValuesObject.Bind As IDimensionModel).Hierarchies;
    // Get the second alternative hierarchy
    AlterHie := AlterHies.Item(1);
    // Specify that the first alternative hierarchy in source time series database
    // corresponds to the second alternative hierarchy in time series database being a data consumer.
    HieMap.TargetId := AlterHie.Id;
    HieMap.TargetKey := AlterHie.Key;
    // Display parameters of copied alternative hierarchy in the console window
    Debug.WriteLine("Identifier of copied alternative hierarchy: " + HieMap.SourceId);
    Debug.WriteLine("Key of copied alternative hierarchy: " + HieMap.SourceKey.ToString);
    // Copy
    RubUpdateEx.Apply(Progress);
    // Save changes in copying object
    Obj.Save;
End Sub UserProc;

After executing the example the TSDB_SRC_HIE time series database is copied to the TSDB_DEST_HIE time series database. When dictionaries that are data sources for the INDICATOR attributes a copied, the first alternative hierarchy in the source time series database corresponds to the second alternative hierarchy in the time series database being a data consumer.

See also:

ICubeMetaUpdateAttributeRemapping