The QueryBuilder automatically finds the levels of a hierarchy in the Java-client user interface.
To find the levels in a hierarchy programmatically, call the getLevels
method of the MDHierarchy
that represents the hierarchy.
The following code finds the levels for the default hierarchy of the Product dimension (mdDefaultProductHierarchy
). Descriptions of the levels are stored in a String
array.
MDLevel[] mdProductLevels = null; String[] strLevelDescriptions = null; try{ mdProductLevels = mdDefaultProductHierarchy.getLevels(); strLevelDescriptions = new String[mdProductLevels.length]; for (int i = 0; ((mdProductLevels != null) && (i < mdProductLevels.length)) ; i ++ ) { strLevelDescriptions[i] = mdProductLevels[i].getShortLabel()); } } catch (MetadataManagerException e){ e.printStackTrace(); }