AttributeHierarchy: IDimAttributeHierarchy;
AttributeHierarchy: Prognoz.Platform.Interop.Dimensions.IDimAttributeHierarchy;
The AttributeHierarchy property returns data of attribute alternative hierarchy.
To get collection of dictionary alternative hierarchy data, use IDimInstance.AttributeHierarchies.
Executing the example requires that repository contains table dictionary with the DIM_SEP identifier which alternative hierarchy consists of two levels.
Add links to the Dimensions, Metabase system assemblies.
Sub UserProc;
Var
mb: IMetabase;
diminstance: IDimInstance;
attrhierarchy: IDimAttributeHierarchy;
attrhierarchies: IDimAttributeHierarchiesInstance;
attrhierinstance: IDimAttributeHierarchyInstance;
attrhierinstance1: IDimAttributeHierarchyInstance;
id, name: string;
Begin
// Get repository
mb := MetabaseClass.Active;
// Get dictionary data
diminstance := mb.ItemById("DIM_SEP").Open(Null) As IDimInstance;
// Get data of alternative hierarchy
attrhierinstance := diminstance.AttributeHierarchies.HierarchyItem(0);
// Get alternative hierarchy
attrhierarchy := attrhierinstance.AttributeHierarchy;
// Get identifier of alternative hierarchy and display to the console
id := attrhierarchy.Id;
Debug.WriteLine("Identifier of alternative hierarchy = " + id);
// Get data of alternative hierarchies collection
attrhierarchies := diminstance.AttributeHierarchies;
// Get alternative hierarchy by attribute level
attrhierinstance1 := attrhierarchies.FindByAttributeLevel(2, 2);
If attrhierinstance1 <> Null Then
// Display name of alternative hierarchy to the console
name := attrhierinstance1.Name;
Debug.WriteLine("Name of alternative hierarchy = " + name) Else
Debug.WriteLine("Alternative hierarchy is not found = " + name)
End If;
End Sub UserProc;
After executing the example the console displays identifier and name of obtained alternative hierarchies.
The requirements and result of the Fore.NET example execution match with those in the Fore Example.
Imports Prognoz.Platform.Interop.Dimensions;
…
Public Shared Sub Main(Params: StartParams);
Var
mb: IMetabase;
diminstance: IDimInstance;
attrhierarchy: IDimAttributeHierarchy;
attrhierarchies: IDimAttributeHierarchiesInstance;
attrhierinstance: IDimAttributeHierarchyInstance;
attrhierinstance1: IDimAttributeHierarchyInstance;
id, name: string;
Begin
// Get repository
mb := Params.Metabase;
// Get dictionary data
diminstance := mb.ItemById["DIM_SEP"].Open(Null) As IDimInstance;
// Get data of alternative hierarchy
attrhierinstance := diminstance.AttributeHierarchies.HierarchyItem[0];
// Get alternative hierarchy
attrhierarchy := attrhierinstance.AttributeHierarchy;
// Get identifier of alternative hierarchy and display to the console
id := attrhierarchy.Id;
System.Diagnostics.Debug.WriteLine("Identifier of alternative hierarchy = " + id);
// Get data of alternative hierarchies collection
attrhierarchies := diminstance.AttributeHierarchies;
// Get alternative hierarchy by attribute level
attrhierinstance1 := attrhierarchies.FindByAttributeLevel(2, 2);
If attrhierinstance1 <> Null Then
// Display name of alternative hierarchy to the console
name := attrhierinstance1.Name;
System.Diagnostics.Debug.WriteLine
("Name of alternative hierarchy = " + name) Else
System.Diagnostics.Debug.WriteLine
("Alternative hierarchy is not found = " + name)
End If;
End Sub;
See also: