public static function checkReference($reference, $checkResource = TRUE, $checkName = TRUE) {
        if (!isset($reference)) {
            return;
        }

        $parts = self::splitReference($reference);
        for ($i = 0, $count = count($parts); $i < $count; $i += 2) {
            if ($checkResource) {
                $resource = $parts[$i];
                if (isset($resource)) {
                    NameSpaceHelper::checkAlias($resource);
                }
            }

            if ($checkName) {
                $name = $parts[$i + 1];
                StringDataTypeHandler::checkValueAsWord($name);
            }
        }
    }
    public function registerCube(CubeMetaData $cube) {
        $this->checkAssemblingStarted();

        if (!isset($cube->name)) {
            LogHelper::log_debug($cube);
            throw new IllegalArgumentException(t('Cube name has not been defined'));
        }

        $cubeName = $cube->name;
        NameSpaceHelper::checkAlias($cubeName);

        $existingCube = $this->findCube($cubeName, TRUE);
        if (isset($existingCube)) {
            if ($cube->isTemporary()) {
                $this->unregisterCube($cubeName);
            }
            else {
                LogHelper::log_debug($existingCube);
                LogHelper::log_debug($cube);
                throw new IllegalArgumentException(t(
                    'Cube with name %cubeName has already been defined',
                    array('%cubeName' => $cube->publicName)));
            }
        }

        if (!$cube->isTemporary()) {
            // we support only one cube per dataset
            $cube2 = $this->findCubeByDatasetName($cube->factsDatasetName);
            if (isset($cube2)) {
                LogHelper::log_debug($cube2);
                LogHelper::log_debug($cube);
                throw new IllegalArgumentException(t(
                    'Found several cubes for %datasetName dataset: [%cubeName1, %cubeName2]',
                    array('%datasetName' => $cube->factsDatasetName, '%cubeName1' => $cube->publicName, '%cubeName2' => $cube2->publicName)));
            }
        }

        // fixing cube properties
        if (isset($cube->dimensions)) {
            foreach ($cube->dimensions as $dimension) {
                if (!isset($dimension->attributeColumnName)) {
                    $dimension->attributeColumnName = $dimension->name;
                }
            }
        }

        $this->cubes[$cubeName] = $cube;
    }
Exemple #3
0
 public function registerCube(CubeMetaData $cube)
 {
     $this->checkAssemblingStarted();
     if (!isset($cube->name)) {
         LogHelper::log_error($cube);
         throw new IllegalArgumentException(t('Cube name has not been defined'));
     }
     $cubeName = $cube->name;
     NameSpaceHelper::checkAlias($cubeName);
     if (isset($this->cubes[$cubeName])) {
         if ($cube->temporary) {
             unset($this->cubes[$cubeName]);
         } else {
             throw new IllegalArgumentException(t('Cube with name @cubeName has already been defined', array('@cubeName' => $cube->publicName)));
         }
     }
     if (!$cube->temporary) {
         // we support only one cube per dataset
         $cube2 = $this->findCubeByDatasetName($cube->sourceDatasetName);
         if (isset($cube2)) {
             throw new IllegalArgumentException(t("Found several cubes for '@datasetName' dataset: ['@cubeName1', '@cubeName2']", array('@datasetName' => $cube->sourceDatasetName, '@cubeName1' => $cube->publicName, '@cubeName2' => $cube2->publicName)));
         }
     }
     $this->cubes[$cubeName] = $cube;
 }