public function enableDataset(DataControllerCallContext $callcontext, DatasetMetaData $dataset) {
        parent::enableDataset($callcontext, $dataset);

        $metamodel = data_controller_get_metamodel();

        $this->originalLogicalDataset->used = TRUE;

        StarSchemaCubeMetaData::registerFromDataset($metamodel, $this->originalLogicalDataset);
        StarSchemaCubeMetaData::initializeFromDataset($metamodel, $this->originalLogicalDataset);
    }
Exemplo n.º 2
0
function testDatasetUploader_registerDatasetStorage($dataset)
{
    $dataController = data_controller_get_instance();
    echo "<h2>Registering dataset</h2>\n";
    $nameSuffix = uniqid();
    $dataset->name = NameSpaceHelper::addNameSpace(DrupalDataSourceHandler::$NAME_SPACE__DEFAULT, $nameSuffix);
    $dataset->source = TABLE_PREFIX . $nameSuffix;
    $dataset->datasourceName = DrupalDataSourceHandler::$DATASOURCE__DEFAULT;
    $dataController->registerDatasetStorage(DrupalDataSourceHandler::$NAME_SPACE__DEFAULT, $dataset);
    $cube = StarSchemaCubeMetaData::initializeFromDataset(DrupalDataSourceHandler::$DATASOURCE__DEFAULT, $dataset);
    $dataController->registerCubeStorage(DrupalDataSourceHandler::$NAME_SPACE__DEFAULT, $cube);
    echo "{$dataset->name}\n";
}
    public function finalize(AbstractMetaModel $metamodel) {
        parent::finalize($metamodel);

        $loaderName = $this->getName();

        // initializing all cubes. We separated registration from initialization to support inter-cube references
        $loadedDatasets = NULL;
        foreach ($metamodel->datasets as $dataset) {
            // working only with datasets which are created by this loader
            if ($dataset->loaderName != $loaderName) {
                continue;
            }

            StarSchemaCubeMetaData::registerFromDataset($metamodel, $dataset);

            $loadedDatasets[$dataset->nid] = $dataset;
        }

        if (isset($loadedDatasets)) {
            $dataset_nids = array_keys($loadedDatasets);

            // loading measures
            $measureNodes = gd_measure_get_measures_4_dataset($dataset_nids, LOAD_ENTITY);
            // grouping measures in context of dataset
            $datasetsMeasureNodes = $this->groupNodesByDataset($measureNodes, 'field_measure_dataset');

            // creating cubes for all datasets
            foreach ($loadedDatasets as $dataset) {
                // preparing corresponding cube
                $cube = StarSchemaCubeMetaData::initializeFromDataset($metamodel, $dataset);
                // assigning a loader which created the cube
                $cube->factsDataset->loaderName = $loaderName;
                $cube->loaderName = $loaderName;
                // preparing additional measures
                $datasetMeasureNodes = isset($datasetsMeasureNodes[$dataset->nid]) ? $datasetsMeasureNodes[$dataset->nid] : NULL;
                if (isset($datasetMeasureNodes)) {
                    foreach ($datasetMeasureNodes as $measureNode) {
                        $measure = $cube->registerMeasure(get_node_field_value($measureNode, 'field_measure_sysname', 0, 'value', TRUE));
                        $measure->publicName = $measureNode->title;
                        $measure->description = get_node_field_value($measureNode, 'field_measure_desc');
                        $measure->function = get_node_field_value($measureNode, 'field_measure_function', 0, 'value', TRUE);
                    }
                }
            }
        }

        // processing references
        $referenceNodes = gd_reference_get_references(LOAD_ENTITY);
        $referencePointNodes = isset($referenceNodes) ? gd_reference_get_reference_points(LOAD_ENTITY) : NULL;
        if (isset($referencePointNodes)) {
            foreach ($referenceNodes as $referenceNode) {
                GD_DatasetMetaModelLoaderHelper::prepareReference($metamodel, $referenceNode, $referencePointNodes);
            }
        }
    }