IDimHierarchiesInstance.DefaultHierarchy

Syntax

DefaultHierarchy: IDimHierarchiesInstance;

Description

The property is read-only.

The DefaultHierarchy property determines whether there is a default alternative hierarchy to be used on opening a dictionary.

Comments

To set a default hierarchy to be used on opening a dictionary, use the IDimHierarchies.DefaultHierarchy property.

Example

Executing the example requires that the repository contains table dictionaries with the DIC_RF_DH and FACTS2_DH identifiers. The DIC_RF_DH dictionary is considered as a main dictionary that contains alternative hierarchies, and FACTS2_DH is considered as an alternative hierarchy dictionary.

Add links to the Dimensions, Metabase system assemblies.

Sub UserProc;
Var
    Mb: IMetabase;
    OriginalModelObj: IMetabaseObject;
    OriginalModel, AlternateModel: IDimensionModel;
    Hierarchies: IDimHierarchies;
    Hierarchy, Alt_Hierarchy: IDimHierarchy;
    Origin_Attributes, Alt_Attributes: IDimAttributes;
    Origin_Attr, Alt_Attr: IDimAttribute;
    dimInstance: IDimInstance;
    Hs_Instance: IDimHierarchiesInstance;
    H_Inst, Hs_Inst: IDimHierarchyInstance;
    dimSel: IDimSelection;
    i: Integer;
Begin
    // Get repository
    Mb := MetabaseClass.Active;
    // Get table dictionary
    OriginalModelObj := Mb.ItemById("DIC_RF_DH").Edit;
    OriginalModel := OriginalModelObj As IDimensionModel;
    // Get alternative hierarchy source
    AlternateModel := Mb.ItemById("FACTS2_DH").Bind As IDimensionModel;
    Hierarchies := OriginalModel.Hierarchies;
    Hierarchy := Hierarchies.Item(0);
    // Set default hierarchy
    Hierarchies.DefaultHierarchy := Hierarchy;
    // Determine index, containing keys of elements for alternative hierarchy
    Hierarchies.OriginalIndex := OriginalModel.Indexes.PrimaryIndex;
    // Add source alternative hierarchy
    Alt_Hierarchy := Hierarchies.Add(AlternateModel);
    // Determine index containing keys for comparing elements of main and alternative dictionary
    Alt_Hierarchy.SourceIndex := AlternateModel.Indexes.PrimaryIndex;
    Origin_Attributes := OriginalModel.Attributes;
    Alt_Attributes := AlternateModel.Attributes;
    // Link source dimension attributes with attributes from alternative hierarchy source by identifier
    For i := 0 To Origin_Attributes.Count - 1 Do
        Origin_Attr := Origin_Attributes.FindById("NAME");
        Alt_Attr := Alt_Attributes.FindById("NAME");
        Alt_Hierarchy.SourceAttribute(Origin_Attr) := Alt_Attr;
    End For;
    OriginalModelObj.Save;
    dimInstance := OriginalModelObj.Open(NullAs IDimInstance;
    Hs_Instance := dimInstance.Hierarchies;
    // Replace main hierarchy with alternative one
    dimSel := dimInstance.CreateSelection;
    dimSel.InitAdditionalHierarchy(Alt_Hierarchy);
    dimSel.Hierarchy := dimSel.AdditionalHierarchy;
    // Display name of the default hierarchy in the console
    Debug.WriteLine(Hs_Instance.DefaultHierarchy.Name);
    // Save dictionary
    OriginalModelObj.Save;
End Sub UserProc;

After executing the example the alternative hierarchy is added to the main dictionary, the default hierarchy is set, the console window displays the default hierarchy name.

See also:

IDimHierarchiesInstance