Locating a hierarchy member
Posted by Vladimir Lyutetsky on 19 March 2007 10:01 AM
All operations, fulfilled in the RadarCube library, deal with hierarchy members represented by the TMember objects. Thus, locating a hierarchy member is one of the important tasks for a programmer to solve. The speed of this operation and the searching algorithm will depend on the programmer’s choice.
When working with RadarCube, you should remember that any object of TMember related to a certain hierarchy member can be destroyed and re-created even within a single session.
To re-create TMember objects (as well as TLevel), use the following operations:
If a programmer fulfills any of the these operations, or there is a possibility for a user to fulfill one of them, then it is better for a programmer not to count on reference to the TMember instance, which he has obtained earlier, to be still valid.
That is why the task of locating a hierarchy member is of vital importance.
Locating a member by its unique name, stored in the UniqueName property, does not hamper the component's performance. For MS AS, a unique hierarchy member name is the same as its unique MDX name, and for the Desktop version (with the TOLAPCube object as the data source), its unique name is formed as follows:
[TDimension.DisplayName].[THieararchy.DisplayName].[TMember.DisplayName]...[TMember.DisplayName]. A chain of [TMember.DisplayName]...[TMember.DisplayName] is formed according to the positioning of the members within a hierarchy.
For example, if you have a dimension Time, a hierarchy Fiscal Date containing levels Year, Month and Day, and you need to form a unique name for a member, which corresponds to the date May 7, 2006, then it will look as follows:
If you know the unique member's name, then use the following methods to find an appropriate object to TMember:
If you have only a display name of the object, then you can call the last three functions from this list, passing the following chain of arguments as a parameter: [TDimension.DisplayName].[THieararchy.DisplayName].[TMember.DisplayName]...[TMember.DisplayName]. A chain of [TMember.DisplayName]...[TMember.DisplayName] is formed according to the hierarchy structure of the members within the hierarchy (see the example two paragraphs above).
In some cases, you can give the string [TDimension.DisplayName].[THieararchy.DisplayName].[TMember.DisplayName] in any of the functions as an argument, despite the relations of the members within the hierarchy. However, we won't recommend this method, since, first, it's too slow, and, second, it can return wrong results if there are several members with the same display name in the same hierarchy.
There is a workaround, however, that is more preferable in regard to speed: using the TCubeMember.RetrieveGridMember method.
The TCubeMember objects, unlike the TMember objects, are not re-created during the Cube's session. That is why, if once per session you save reference to a TCubeMember object, then you will always be able to use it.