IMetaHierarchyInstance.Build

Syntax

Build;

Description

The Build method builds elements hierarchy.

Example

Executing the example requires that the repository contains a time series database with the OBJ_FC identifier.

Sub Main;

Var

Mb: IMetabase;

RubrObj: IMetabaseObject;

CatInst: IRubricatorInstance;

DictInst: IMetaDictionaryInstance;

HierarchyInst: IMetaHierarchyInstance;

Mems: IMetaMembersSet;

Mem: IMetaMember;

sAttr: String;

HLevels: IMetaHierarchyLevels;

HLev: IMetaHierarchyLevel;

AttsSet: IMetaAttributesSet;

Attr: IMetaAttribute;

HierarchyAttr: IMetaHierarchyAttributes;

HierarchySetup: IMetaAttributeHierarchySetup;

DimInst: IDimInstance;

Selection: IDimSelection;

i: Integer;

z: Integer;

Begin

Mb := MetabaseClass.Active;

RubrObj := Mb.ItemById("OBJ_FC").Bind;

CatInst := RubrObj.Open(Null) As IRubricatorInstance;

DictInst := CatInst.GetDictionary(RubricatorDictionary.Facts);

HierarchyInst := DictInst.DefaultHierarchy;

Debug.WriteLine(Before selection is changed);

Mems := HierarchyInst.GetRootMembers;

If Not Mems.Eof Then

Mem := Mems.Current;

Repeat

Debug.WriteLine(" " + Mem.Name);

Mems.Next;

Until Mems.Eof;

End If;

HLevels := HierarchyInst.Levels;

HLev := HLevels.Item(0);

AttsSet := HLev.Attributes;

For i := 0 To AttsSet.Count - 1 Do

sAttr := AttsSet.Item(i).Id;

HierarchyAttr := HierarchyInst.Attributes;

Attr := HierarchyAttr.FindById(sAttr);

HierarchySetup := (Attr As IMetaAttributeHierarchySetup);

Selection := HierarchySetup.Selection;

Selection.SelectAll;

DimInst := HierarchySetup.Dimension;

For z := 0 To DimInst.Elements.Count - 1 Do

If (z Mod 2) = 0 Then

Selection.DeselectElement(z, False);

End If;

End For;

HierarchySetup.IncludeSelectedOnly := True;

End For;

HierarchyInst.Build;

Debug.WriteLine("");

Debug.WriteLine(After selection is changed);

Mems := HierarchyInst.GetRootMembers;

If Not Mems.Eof Then

Mem := Mems.Current;

Repeat

Debug.WriteLine(" " + Mem.Name);

Mems.Next;

Until Mems.Eof;

End If;

End Sub Main;

After executing the example names of root elements of attributes hierarchy are displayed in the console window before and after selection is changed.

See also:

IMetaHierarchyInstance