public function load(AbstractMetaModel $environment_metamodel, array $filters = NULL) { LogHelper::log_notice(t('Loading Environment Meta Model from GovDashboard Content Types ...')); // Note we do not apply filters because we do not have any // if we want to use the filters we would need to prepare list of data source names // but to prepare those name we need to load meta model. // but that is what we are trying to do in this code // Catch 22 if (isset($filters)) { throw new UnsupportedOperationException(t('Filters are not supported during data source loading')); } $datamartNodes = gd_datamart_get_datamarts(LOAD_ENTITY); // preparing data sources foreach ($datamartNodes as $datamartNode) { GD_DataMartMetaModelLoaderHelper::prepareDataSource($environment_metamodel, $datamartNode); } // finalizing the preparation foreach($datamartNodes as $datamartNode) { $datasource = GD_DataMartMetaModelLoaderHelper::getDataSourceByNodeId($environment_metamodel->datasources, $datamartNode->nid); GD_DataMartMetaModelLoaderHelper::finalizeDataSourcePreparation($environment_metamodel, $datasource); } LogHelper::log_info(t('Processed @datamartCount data mart node(s)', array('@datamartCount' => count($datamartNodes)))); }
function gd_sync_admin_datamart_form ( $form, &$form_state ) { // Enable language column if translation module is enabled or if we have any // node with language. $multilanguage = (module_exists('translation') || db_query_range("SELECT 1 FROM {node} WHERE language <> :language", 0, 1, array(':language' => LANGUAGE_NONE))->fetchField()); // Build the sortable table header. $header = array( 'title' => array('data' => t('Title'), 'field' => 'n.title'), 'author' => t('Author'), 'changed' => array('data' => t('Updated'), 'field' => 'n.changed', 'sort' => 'desc'), 'datasets' => t('Datasets'), 'reports' => t('Reports'), 'dashboards' => t('Dashboards') ); if ($multilanguage) { $header['language'] = array('data' => t('Language'), 'field' => 'n.language'); } $header['operations'] = array('data' => t('Operations')); $nodes = gd_datamart_get_datamarts(LOAD_ENTITY); // Prepare the list of nodes. $languages = language_list(); $destination = drupal_get_destination(); $options = array(); foreach ($nodes as $node) { $langcode = entity_language('node', $node); $l_options = $langcode != LANGUAGE_NONE && isset($languages[$langcode]) ? array('language' => $languages[$langcode]) : array(); $options[$node->nid] = array( 'title' => array( 'data' => array( '#type' => 'link', '#title' => $node->title, '#href' => 'admin/structure/govdashboard/sync/datamart/' . $node->nid, '#options' => $l_options, '#suffix' => ' ' . theme('mark', array('type' => node_mark($node->nid, $node->changed))), ), ), 'author' => theme('username', array('account' => $node)), 'changed' => format_date($node->changed, 'short'), 'datasets' => count(gd_dataset_findall_by_datasource(!LOAD_ENTITY,get_node_field_value($node,'field_datamart_sysname'))), 'reports' => count(gd_report_findall_by_datasource(!LOAD_ENTITY,get_node_field_value($node,'field_datamart_sysname'))), 'dashboards' => count(gd_dashboard_findall_by_datasource(!LOAD_ENTITY,get_node_field_value($node,'field_datamart_sysname'))) ); if ($multilanguage) { if ($langcode == LANGUAGE_NONE || isset($languages[$langcode])) { $options[$node->nid]['language'] = $langcode == LANGUAGE_NONE ? t('Language neutral') : t($languages[$langcode]->name); } else { $options[$node->nid]['language'] = t('Undefined language (@langcode)', array('@langcode' => $langcode)); } } // Build a list of all the accessible operations for the current node. $operations = array(); if (node_access('update', $node)) { $operations['edit'] = array( 'title' => t('edit'), 'href' => 'node/' . $node->nid . '/edit', 'query' => $destination, ); } $options[$node->nid]['operations'] = array(); if (count($operations) > 1) { // Render an unordered list of operations links. $options[$node->nid]['operations'] = array( 'data' => array( '#theme' => 'links__node_operations', '#links' => $operations, '#attributes' => array('class' => array('links', 'inline')), ), ); } elseif (!empty($operations)) { // Render the first and only operation as a link. $link = reset($operations); $options[$node->nid]['operations'] = array( 'data' => array( '#type' => 'link', '#title' => $link['title'], '#href' => $link['href'], '#options' => array('query' => $link['query']), ), ); } } $form['nodes'] = array( '#type' => 'tableselect', '#header' => $header, '#options' => $options, '#empty' => t('No content available.'), ); return $form; }