protected function loadFromDirectory(AbstractMetaModel $metamodel, array $filters = NULL, $path, $namespace, $level = 0) { $filecount = 0; $handle = opendir($path); if ($handle !== FALSE) { $indent = str_pad('', $level * 4); while (($filename = readdir($handle)) !== FALSE) { if (is_dir($path . DIRECTORY_SEPARATOR . $filename)) { if ($filename[0] != '.') { $folder = DIRECTORY_SEPARATOR . $filename; $nestedNameSpace = isset($namespace) ? NameSpaceHelper::addNameSpace($namespace, $filename) : $filename; LogHelper::log_debug(t("{$indent}Scanning '@folderName' ...", array('@folderName' => $folder))); $filecount += $this->loadFromDirectory($metamodel, $filters, $path . $folder, $nestedNameSpace, $level + 1); } } elseif ($this->fileNameEndsWithJson($filename)) { LogHelper::log_debug(t("{$indent}Processing '@filename' ...", array('@filename' => $filename))); $this->loadFromFile($metamodel, $filters, $namespace, $path . DIRECTORY_SEPARATOR, $filename); $filecount++; } } closedir($handle); } return $filecount; }
public function load(AbstractMetaModel $environment_metamodel, array $filters = NULL) { LogHelper::log_notice(t('Generating Environment Meta Model for Drupal database connections ...')); global $databases; $datasourceCount = 0; foreach ($databases as $namespace => $connections) { foreach ($connections as $datasourceNameOnly => $connection) { $datasource = new DataSourceMetaData(); $datasource->name = NameSpaceHelper::addNameSpace($namespace, $datasourceNameOnly); $datasource->markAsPrivate(); $datasource->readonly = FALSE; // setting required properties $this->setDataSourceProperty($datasource, $connection, 'type', 'driver'); // setting other provided properties $this->setDataSourceExtensionProperties($datasource, $connection); // registering the data source $environment_metamodel->registerDataSource($datasource); $datasourceCount++; } } // Default database connection is shared because we store common utilities and dimensions there $defaultDataSource = $environment_metamodel->getDataSource(self::$DATASOURCE_NAME__DEFAULT); $defaultDataSource->shared = TRUE; LogHelper::log_info(t('Generated @datasourceCount data sources', array('@datasourceCount' => $datasourceCount))); }
protected function assembleCacheEntryName($name) { $cacheEntryName = $name; if (isset($this->prefix)) { $cacheEntryName = isset($name) ? NameSpaceHelper::addNameSpace($this->prefix, $name) : $this->prefix; } return $cacheEntryName; }
protected function getRequestId() { $requestId = &drupal_static(__CLASS__ . '::requestId'); if (!isset($requestId)) { $sequenceName = NameSpaceHelper::addNameSpace(get_class($this), 'requestId'); $requestId = Sequence::getNextSequenceValue($sequenceName); } return $requestId; }
public function load(AbstractMetaModelFactory $factory, AbstractMetaModel $environment_metamodel, array $filters = NULL, $finalAttempt) { LogHelper::log_notice(t('Generating Environment Meta Model for APC cache ...')); $datasourceCount = 0; $datasource = new DataSourceMetaData(); $datasource->name = NameSpaceHelper::addNameSpace(APCHandler::$CACHE__TYPE, DefaultCacheFactory::$DATASOURCE_NAME__DEFAULT); $datasource->type = APCHandler::$CACHE__TYPE; $environment_metamodel->registerDataSource($datasource); $datasourceCount++; LogHelper::log_info(t('Generated @datasourceCount data sources', array('@datasourceCount' => $datasourceCount))); return self::LOAD_STATE__SUCCESSFUL; }
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 __construct($prefix, DataSourceMetaData $datasource = NULL) { LogHelper::log_notice(t('[@cacheType] Initializing PHP extension ...', array('@cacheType' => $this->getCacheType()))); // taking into account possible datasource's nested name space $adjustedPrefix = isset($datasource->nestedNameSpace) ? (isset($prefix) ? NameSpaceHelper::addNameSpace($datasource->nestedNameSpace, $prefix) : $datasource->nestedNameSpace) : $prefix; parent::__construct($adjustedPrefix); if ($this->initialize($prefix, $datasource) !== FALSE) { $this->checkAccessibility(FALSE); } }
public function __construct($prefix, DataSourceMetaData $datasource) { LogHelper::log_notice(t('[@cacheType] Initializing PHP extension ...', array('@cacheType' => $this->getCacheType()))); // taking into account possible datasource's nested name space $adjustedPrefix = isset($datasource->nestedNameSpace) ? NameSpaceHelper::addNameSpace($prefix, $datasource->nestedNameSpace) : $prefix; parent::__construct($adjustedPrefix); // the optional datasource can have its own expiration schedule if (isset($datasource->entryExpiration)) { $this->entryExpiration = $datasource->entryExpiration; } if ($this->initialize($prefix, $datasource) !== FALSE) { $this->checkAccessibility(FALSE); } }
protected function getMetaDataStorageProperties(DataControllerCallContext $callcontext, $sourceDatasetName) { $metamodel = data_controller_get_metamodel(); $dataset = $metamodel->getDataset($sourceDatasetName); $databaseName = $dataset->source->database; $namespace = NameSpaceHelper::getNameSpace($dataset->name); $metadataDatasetName = NameSpaceHelper::addNameSpace($namespace, self::$DATASET__METADATA); $schemaDocumentId = self::$PROPERTY__DOCUMENT_IDENTIFIER__SCHEMA_TEMPLATE . '@' . $databaseName; return array($metadataDatasetName, $schemaDocumentId); }
public function load(AbstractMetaModel $environment_metamodel, array $filters = NULL) { LogHelper::log_notice(t('Generating Environment Meta Model for APC cache ...')); $datasourceCount = 0; $datasource = new DataSourceMetaData(); $datasource->name = NameSpaceHelper::addNameSpace(APCHandler::CACHE__TYPE, 'default'); $datasource->type = APCHandler::CACHE__TYPE; $datasource->category = CacheFactory::$DATASOURCE__CATEGORY; $datasource->markAsPrivate(); $environment_metamodel->registerDataSource($datasource); $datasourceCount++; LogHelper::log_info(t('Generated @datasourceCount data sources', array('@datasourceCount' => $datasourceCount))); }
public function flush() { if (!isset($this->recordsHolder)) { return; } $datasetName = NameSpaceHelper::addNameSpace(DATASOURCE_NAME__HEALTH_MONITORING, 'hm_trails'); // generating and assigning primary key $identifiers = Sequence::getNextSequenceValues($datasetName, count($this->recordsHolder->records)); foreach ($this->recordsHolder->records as $index => $recordInstance) { $recordInstance->setColumnValue(0, $identifiers[$index]); } // storing data in the database $dataManipulationController = data_controller_dml_get_instance(); $dataManipulationController->insertDatasetRecordBatch($datasetName, $this->recordsHolder); $this->recordsHolder = NULL; }
protected function assembleCacheEntryName($name) { return isset($this->prefix) ? NameSpaceHelper::addNameSpace($this->prefix, $name) : $name; }
public function getLocalCacheHandler($prefix) { $handlerKey = NameSpaceHelper::addNameSpace($prefix, InMemoryCacheHandler::$CACHE__TYPE); if (isset($this->handlerInstances[$handlerKey])) { $handler = $this->handlerInstances[$handlerKey]; } else { $handler = $this->initializeLocalCache($prefix); $this->handlerInstances[$handlerKey] = $handler; } return $handler; }
public static function prepareElementUIMetaDataName($namespace, $name) { return NameSpaceHelper::addNameSpace($namespace, $name); }
public function assembleResourceName($resourceType, $name) { return NameSpaceHelper::addNameSpace($resourceType, $name); }
public function getLocalCacheHandler($prefix) { $handlerKey = isset($prefix) ? $prefix : (get_class($this) . '.local'); $handlerKey = NameSpaceHelper::addNameSpace($handlerKey, InMemoryCacheHandler::CACHE__TYPE); if (isset($this->handlers[$handlerKey])) { $handler = $this->handlers[$handlerKey]; } else { $handler = $this->initializeLocalCache($prefix); $this->handlers[$handlerKey] = $handler; } return $handler; }
protected function populateDatasets() { $metamodel = data_controller_get_metamodel(); $namespaceParts = explode(NameSpaceHelper::NAME_SPACE_SEPARATOR, DATASOURCE_NAME__TEST); $path = realpath(drupal_get_path('module', 'gd_test')) . DIRECTORY_SEPARATOR . '_db' . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, $namespaceParts); $handle = opendir($path); if ($handle !== FALSE) { while (($name = readdir($handle)) !== FALSE) { if ($name[0] == '.') { continue; } $fullname = $path . DIRECTORY_SEPARATOR . $name; if (!is_dir($fullname)) { continue; } $datasetName = NameSpaceHelper::addNameSpace(DATASOURCE_NAME__TEST, $name); $dataset = $metamodel->findDataset($datasetName); if (!isset($dataset)) { continue; } $folderName = $fullname; $this->populateDataset($dataset, $folderName); } closedir($handle); } }
protected function processConfig ( &$config ) { // TODO Services casts everything to array not objects $config = (object) $config; $config->model = (object) $config->model; $metamodel = data_controller_get_metamodel(); if ( !empty($config->model->datasets) ) { foreach ( $config->model->datasets as $key => $datasetIdentifier ) { $dataset = GD_DatasetMetaModelLoaderHelper::findDatasetByUUID($this->datasets,$datasetIdentifier); if (!isset($dataset)) { $datasetName = NameSpaceHelper::addNameSpace(gd_datasource_get_active(), $datasetIdentifier); $dataset = $metamodel->getDataset($datasetName); } $config->model->datasets[$key] = $dataset->name; } } // update columns if ( !empty($config->model->columns) ) { foreach ( $config->model->columns as $key => $value ) { $config->model->columns[$key] = DatasetImportHelper::getNewColumnName($value,$this->datasets); } } // update column configs if ( !empty($config->columnConfigs) ) { foreach ( $config->columnConfigs as $key => $value ) { $config->columnConfigs[$key]->columnId = DatasetImportHelper::getNewColumnName($value->columnId,$this->datasets); } } // update column orders if ( !empty($config->model->columnOrder) ) { foreach ( $config->model->columnOrder as $key => $value ) { $config->model->columnOrder[$key] = DatasetImportHelper::getNewColumnName($value,$this->datasets); } } // update column sorts if ( !empty($config->model->orderBy) ) { foreach ( $config->model->orderBy as $key => $value ) { $config->model->orderBy[$key]->column = DatasetImportHelper::getNewColumnName($value->column,$this->datasets); } } // update filters if ( !empty($config->model->filters) ) { foreach ( $config->model->filters as $key => $value ) { $config->model->filters[$key]->column = DatasetImportHelper::getNewColumnName($value->column,$this->datasets); } } // update visual series if ( !empty($config->visual->series) ) { $newSeries = array(); foreach ( $config->visual->series as $key => $value ) { $newSeries[DatasetImportHelper::getNewColumnName($key,$this->datasets)] = $value; } $config->visual->series = $newSeries; } // update traffic column if ( !empty($config->visual->trafficColumn) ) { $config->visual->trafficColumn = DatasetImportHelper::getNewColumnName($config->visual->trafficColumn,$this->datasets); } // update color column if ( !empty($config->visual->useColumnDataForColor) ) { $config->visual->useColumnDataForColor = DatasetImportHelper::getNewColumnName($config->visual->useColumnDataForColor,$this->datasets); } // update traffic columns if ( !empty($config->visual->traffic) ) { $newTraffic = array(); foreach ( $config->visual->traffic as $key => $value ) { $newName = DatasetImportHelper::getNewColumnName($key,$this->datasets); $value->trafficColumn = $newName; $newTraffic[$newName] = $value; } $config->visual->traffic = $newTraffic; } }
public static function prepareDataset(MetaModel $metamodel, $datasetNode, array $datasetColumnNodes = NULL, DataSourceMetaData $datasource) { $dataset = new DatasetMetaData(); $dataset->name = get_node_field_value($datasetNode, 'field_dataset_sysname', 0, 'value', TRUE); $dataset->publicName = $datasetNode->title; // preparing the dataset alternative names (aliases) $aliasIndex = 0; while (($alias = get_node_field_value($datasetNode, 'field_dataset_alias', $aliasIndex)) != NULL) { $dataset->aliases[] = $alias; $aliasIndex++; } $dataset->description = get_node_field_value($datasetNode, 'field_dataset_desc'); $dataset->datasourceName = $datasource->name; // preparing source configuration properties $dataset->sourceType = get_node_field_value($datasetNode, 'field_dataset_source_type', 0, 'value', TRUE); $dataset->source = get_node_field_value($datasetNode, 'field_dataset_source', 0, 'value', TRUE); // preparing source properties as an associative array $dataset->configuration = get_node_field_object_value($datasetNode, 'field_dataset_source_properties'); // dataset system properties $dataset->uuid = get_node_field_value($datasetNode, 'field_dataset_uuid', 0, 'value', TRUE); $dataset->nid = $datasetNode->nid; // preparing dataset columns if (isset($datasetColumnNodes)) { foreach ($datasetColumnNodes as $columnNode) { $column = $dataset->initiateColumn(); $column->used = $columnNode->status == NODE_PUBLISHED; $column->name = get_node_field_value($columnNode, 'field_column_sysname', 0, 'value', TRUE); $column->publicName = $columnNode->title; $column->description = get_node_field_value($columnNode, 'field_column_desc'); $column->key = get_node_field_boolean_value($columnNode, 'field_column_key'); // column data type $column->type->applicationType = get_node_field_value($columnNode, 'field_column_datatype', 0, 'value', $column->used); if (isset($column->type->applicationType) && ($column->type->getReferencedDatasetName() == NULL)) { $column->type->logicalApplicationType = NameSpaceHelper::addNameSpace(NAME_SPACE__STAR_SCHEMA, $column->type->applicationType); } $format = get_node_field_object_value($columnNode, 'field_column_format'); if (isset($format->scale)) { $column->type->scale = $format->scale; } $column->columnIndex = get_node_field_int_value($columnNode, 'field_column_index', 0, 'value', TRUE); $column->source = get_node_field_value($columnNode, 'field_column_source'); $column->persistence = get_node_field_int_value($columnNode, 'field_column_persistence', 0, 'value', TRUE); // attribute system properties $column->nid = $columnNode->nid; $dataset->registerColumnInstance($column); } } // marking that the dataset object contains complete meta data $dataset->markAsComplete(); $metamodel->registerDataset($dataset); return $dataset; }
protected function generateDatasets(SystemTableMetaModelLoaderCallContext $callcontext, DataSourceMetaData $datasource) { $columnsProperties = $this->loadColumnsProperties($callcontext, $datasource); if (isset($columnsProperties)) { foreach ($columnsProperties as $columnProperties) { $tableOwner = $this->adjustOwnerName($columnProperties[self::CN_TABLE_OWNER]); $originalTableName = $columnProperties[self::CN_TABLE_NAME]; $tableName = $this->adjustTableName($originalTableName); if (!$this->isTableSupported($callcontext, $tableName)) { continue; } $tableAccessKey = ArrayHelper::prepareCompositeKey(array($tableOwner, $tableName)); // checking if we can process the column name $originalColumnName = $columnProperties[self::CN_COLUMN_NAME]; $columnName = $this->adjustColumnName($originalColumnName); $generatedColumnName = $this->nameGenerator->generate($columnName); // this column cannot be supported by the system if ($columnName != $generatedColumnName) { LogHelper::log_warn(t( "Unsupported column name from '@tableName' table: @columnName", array('@tableName' => $originalTableName, '@columnName' => $originalColumnName))); continue; } // preparing new dataset if (!isset($callcontext->datasets[$tableAccessKey])) { $source = TableReferenceHelper::assembleTableReference($tableOwner, $tableName); $dataset = new DatasetMetaData(); $dataset->name = NameSpaceHelper::addNameSpace($datasource->name, $this->nameGenerator->generate($tableName)); $dataset->publicName = $this->generateTablePublicName($originalTableName); $dataset->datasourceName = $datasource->name; $dataset->source = $source; $dataset->markAsPrivate(); $callcontext->datasets[$tableAccessKey] = $dataset; } $dataset = $callcontext->datasets[$tableAccessKey]; // adding new column to the dataset $column = $dataset->initiateColumn(); $column->name = $columnName; $column->publicName = $this->generateColumnPublicName($originalColumnName); $column->persistence = ColumnMetaData::PERSISTENCE__STORAGE_CREATED; $column->columnIndex = $columnProperties[self::CN_COLUMN_INDEX]; $column->type->databaseType = $columnProperties[self::CN_COLUMN_TYPE]; if (isset($columnProperties[self::CN_COLUMN_TYPE_LENGTH])) { $column->type->length = $columnProperties[self::CN_COLUMN_TYPE_LENGTH]; } if (isset($columnProperties[self::CN_COLUMN_TYPE_PRECISION])) { $column->type->precision = $columnProperties[self::CN_COLUMN_TYPE_PRECISION]; } if (isset($columnProperties[self::CN_COLUMN_TYPE_SCALE])) { $column->type->scale = $columnProperties[self::CN_COLUMN_TYPE_SCALE]; } $this->generateColumnApplicationType($callcontext, $datasource, $column); // adjusting column properties if (!isset($column->type->applicationType)) { $column->visible = FALSE; LogHelper::log_warn(t( "Data type is not supported for '@columnName' column from '@tableName' table: @databaseDataType", array( '@tableName' => $originalTableName, '@columnName' => $originalColumnName, '@databaseDataType' => $column->type->databaseType))); } $this->adjustColumnVisibility($callcontext, $column); $dataset->registerColumnInstance($column); } } LogHelper::log_info(t( 'Processed system meta data about @tableCount table(s) and @columnCount column(s)', array('@tableCount' => count($callcontext->datasets), '@columnCount' => count($columnsProperties)))); }
public static function getDatasetName($contentTypeName) { // FIXME cache it somewhere list($namespace) = NameSpaceHelper::splitAlias(AbstractDrupalDataSourceQueryProxy::$DATASOURCE_NAME__DEFAULT); return NameSpaceHelper::addNameSpace($namespace, self::$DATASET__PREFIX . $contentTypeName); }