/** * Looks up a hierarchy in a cube with a given name or, failing that, a * given unique name. Throws if not found. * * @param ICube $cube * @param string $hierarchyName Name (or unique name) of hierarchy. * * @return IHierarchy * @throws OLAPException on error */ private function lookupHierarchy(XMLACube $cube, $hierarchyName) { $hierarchy = $cube->getHierarchies()->get($hierarchyName); if ($hierarchy == null) { foreach ($cube->getHierarchies() as $hierarchy1) { if ($hierarchy1->getUniqueName() == $hierarchyName) { $hierarchy = $hierarchy1; break; } } if ($hierarchy == null) { throw new OLAPException("Internal error: hierarchy '" . $hierarchyName . "' not found in cube '" . $cube->getName() . "'"); } } return $hierarchy; }
/** * Shorthand way to create a Context at Cube level or finer. * * @param XMLACube Cube (must not be null) * @param XMLADimension Dimension (may be null) * @param XMLAHierarchy Hierarchy (may be null if Dimension is null) * @param XMLALevel Level (may be null if Hierarchy is null) */ public static function createAtGranule(XMLACube $cube, XMLADimension $dimension = NULL, XMLAHierarchy $hierarchy = NULL, XMLALevel $level = NULL) { return new XMLAConnectionContext($cube->getSchema()->getCatalog()->getMetadata()->getConnection(), $cube->getSchema()->getCatalog()->getMetadata(), $cube->getSchema()->getCatalog(), $cube->getSchema(), $cube, $dimension, $hierarchy, $level); }