Browse Source

Fixing bugs related to installation testing

Stephen Ficklin 9 years ago
parent
commit
abadb9e1b7

+ 3 - 2
tripal_core/api/tripal_core.chado_query.api.inc

@@ -1153,8 +1153,9 @@ function chado_select_record($table, $columns, $values, $options = NULL) {
         else {
           tripal_report_error('tripal_core', TRIPAL_ERROR,
             'chado_select_record: There is no value for %field thus we cannot ' .
-            ' check if this record for table, %table, is unique.',
-            array('%field' => $field, '%table' => $table), array('print' => $print_errors));
+            'check if this record for table, %table, is unique. %values',
+            array('%field' => $field, '%table' => $table, '%values' => print_r($values, TRUE)),
+            array('print' => $print_errors));
           return FALSE;
         }
       }

+ 0 - 1
tripal_core/api/tripal_core.files.api.inc

@@ -56,7 +56,6 @@ function tripal_create_files_dir($module_name, $path = FALSE) {
 
     // now make sure the sub dir exists
     $sub_dir = tripal_get_files_dir() . '/' . $module_name . '/' . $path;
-    print "$sub_dir\n";
     if (!file_prepare_directory($sub_dir, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) {
       $message = "Can not create directory $sub_dir. ";
       drupal_set_message(check_plain(t($message)), 'error');

+ 6 - 1
tripal_core/api/tripal_core.jobs.api.inc

@@ -65,6 +65,7 @@
  * @ingroup tripal_jobs_api
  */
 function tripal_add_job($job_name, $modulename, $callback, $arguments, $uid, $priority = 10) {
+  global $user;
 
   // convert the arguments into a string for storage in the database
   $args = array();
@@ -86,7 +87,11 @@ function tripal_add_job($job_name, $modulename, $callback, $arguments, $uid, $pr
     drupal_set_message(t("Job '%job_name' submitted.", array('%job_name' => $job_name)));
     if (user_access('administer tripal')) {
       $jobs_url = url("admin/tripal/tripal_jobs");
-      drupal_set_message(t("Check the <a href='!jobs_url'>jobs page</a> for status.", array('!jobs_url' => $jobs_url)));
+      drupal_set_message(t("Check the <a href='!jobs_url'>jobs page</a> for status.",
+        array('!jobs_url' => $jobs_url)));
+      drupal_set_message(t("You can execute the job queue manually on the command line " .
+        "using the following Drush command: <br>drush trp-run-jobs --username=%uname --root=%base_path",
+        array('%base_path' => DRUPAL_ROOT, '%uname' => $user->name)));
     }
   }
   else {

+ 2 - 1
tripal_core/api/tripal_core.mviews.api.inc

@@ -41,7 +41,7 @@
  * @ingroup tripal_mviews_api
  *
 function tripal_add_legacy_mview($name, $modulename, $mv_table, $mv_specs, $indexed,
-  $query, $special_index, $comment = NULL) {
+  $query, $special_index, $comment =OR NULL) {
 
   // Create a new record
   $record = new stdClass();
@@ -314,6 +314,7 @@ function chado_get_mview_table_names() {
   $sql = "SELECT name FROM {tripal_mviews}";
   $resource = db_query($sql);
 
+  $tables = array();
   foreach ($resource as $r) {
     $tables[$r->name] = $r->name;
   }

+ 2 - 12
tripal_core/tripal_core.install

@@ -11,18 +11,8 @@
  */
 function tripal_core_install() {
 
-  // make the data directory for this module
-  $data_dir = tripal_get_files_dir();
-  if (!file_prepare_directory($data_dir, FILE_CREATE_DIRECTORY)) {
-    $message = "Cannot create directory $data_dir. This module may not " .
-               "behave correctly without this directory.  Please  create " .
-               "the directory manually or fix the problem and reinstall.";
-    drupal_set_message(check_plain($message), 'error');
-    tripal_report_error('tripal_core', TRIPAL_ERROR, $message, array());
-  }
-
-  // the foreign key specification doesn't really add one to the
-  // Drupal schema, it is just used internally, but we want one
+  // The foreign key specification doesn't really add one to the
+  // Drupal schema, it is just used internally, but we want one.
   db_query('
       ALTER TABLE {tripal_custom_tables}
       ADD CONSTRAINT tripal_custom_tables_fk1

+ 10 - 10
tripal_cv/api/tripal_cv.api.inc

@@ -226,7 +226,7 @@ function tripal_get_cvterm($identifiers, $options = array()) {
     $property = $identifiers['property'];
     unset($identifiers['property']);
     $cvterm = chado_get_record_with_property(
-      array('table' => 'cvterm', 'base_records' => $identifiers), 
+      array('table' => 'cvterm', 'base_records' => $identifiers),
       array('type_name' => $property),
       $options
     );
@@ -277,7 +277,7 @@ function tripal_get_cvterm($identifiers, $options = array()) {
  *
  * @param $cv_id
  *   The chado cv_id; only cvterms with the supplied cv_id will be returned
- *   
+ *
  * @return
  *   An associative array with the cvterm_id's as keys. The first
  *   element in the array has a key of '0' and a value of 'Select a Type'
@@ -289,7 +289,7 @@ function tripal_get_cvterm_select_options($cv_id) {
   $values = array('cv_id' => $cv_id);
   $s_options = array('order_by' => array('name' => 'ASC'));
 
-  $cvterms = chado_select_record('cvterm', $columns, $values, $s_options); 
+  $cvterms = chado_select_record('cvterm', $columns, $values, $s_options);
 
   $options = array();
   $options[0] = 'Select a Type';
@@ -818,8 +818,8 @@ function tripal_submit_obo_job($obo) {
 
 /**
  * Add the OBO to the tripal_cv_obo table in the Drupal database.
- * 
- * If the OBO name already exists in the table then the path is updated. 
+ *
+ * If the OBO name already exists in the table then the path is updated.
  *
  * @param $name
  *   The human readable name of this ontology
@@ -838,7 +838,7 @@ function tripal_insert_obo($name, $path) {
     ->condition('name', $name)
     ->execute()
     ->fetchField();
-  
+
   if ($obo_id) {
     db_update('tripal_cv_obo')
       ->fields(array(
@@ -896,8 +896,8 @@ function tripal_autocomplete_cvterm($cv_id, $string = '') {
  * @param $record_id
  *   The primary key of the basetable to associate the cvterm with. This should be in integer.
  * @param $cvterm
- *   An associative array describing the cvterm. Valid keys include: 
- *     - name: the name for the cvterm, 
+ *   An associative array describing the cvterm. Valid keys include:
+ *     - name: the name for the cvterm,
  *     - cv_name: the name of the cv the cvterm belongs to.
  *     - cv_id: the primary key of the cv the cvterm belongs to.
  * @param $options
@@ -920,7 +920,7 @@ function tripal_associate_cvterm($basetable, $record_id, $cvterm, $options = arr
     );
     if (isset($cvterm['cv_id'])) {
       $values['cv_id'] = $cvterm['cv_id'];
-    } 
+    }
     elseif (isset($cvterm['cv_name'])) {
       $values['cv_id'] = array(
         'name' => $cvterm['cv_name']
@@ -964,7 +964,7 @@ function tripal_associate_cvterm($basetable, $record_id, $cvterm, $options = arr
       return FALSE;
     }
   }
-  
+
   // Now add the link between the record & cvterm
   if ($cvterm['cvterm_id'] > 0) {
     $values = array(

+ 3 - 7
tripal_cv/includes/tripal_cv.obo_loader.inc

@@ -151,7 +151,7 @@ function tripal_cv_load_obo_v1_2_id($obo_id, $jobid = NULL) {
     $module = $matches[1];
     $path = drupal_realpath(drupal_get_path('module', $module));
     $obo->path = preg_replace("/\{.*?\}/", $path, $obo->path);
-  } 
+  }
 
   // if the reference is for a remote URL then run the URL processing function
   if (preg_match("/^http:\/\//", $obo->path) or preg_match("/^ftp:\/\//", $obo->path)) {
@@ -871,11 +871,10 @@ function tripal_cv_obo_add_synonyms($term, $cvterm) {
           'name' => 'synonym_type',
         ),
       );
-      $options = array('is_duplicate' => 1);
-      $results = chado_select_record('cvterm', array('*'), $values, $options);
+      $syntype = tripal_get_cvterm($values);
 
       // if it doesn't exist then add it
-      if (!$results) {
+      if (!$syntype) {
         // build a 'term' object so we can add the missing term
         $term = array(
            'name' => $scope,
@@ -890,9 +889,6 @@ function tripal_cv_obo_add_synonyms($term, $cvterm) {
           tripal_cv_obo_quiterror("Cannot add synonym type: internal:$scope");
         }
       }
-      else {
-        $syntype = $results[0];
-      }
 
       // make sure the synonym doesn't already exists
       $values = array(

+ 3 - 3
tripal_feature/includes/tripal_feature.admin.inc

@@ -125,7 +125,7 @@ function tripal_feature_admin_feature_view() {
     'organisms' => $organism_names,
     'mviewUrl' => url('admin/tripal/schema/mviews/update/' . $mview->mview_id),
     'mviewUable' => $mview->name,
-    'mviewLastUpdate' => format_date($mview->last_update),
+    'mviewLastUpdate' => $mview->last_update ? format_date($mview->last_update) : '',
   ))), 'setting');
 
   // Finally add all the javascript and css needed to render the chart.
@@ -188,7 +188,7 @@ function tripal_feature_admin() {
      '#collapsed' => TRUE,
   );
   $form['browser']['browser_desc'] = array(
-     '#markup' => t('A feature browser can be added to an organism page to allow users to quickly ' .
+     '#markup' => t('<font color="red">NOTE: the feature browser will be removed in a future Tripal version. It remains to give time for sites to cycle it out.</font> A feature browser can be added to an organism page to allow users to quickly ' .
         'access a feature.  This will most likely not be the ideal mechanism for accessing feature ' .
         'information, especially for large sites, but it will alow users exploring the site (such ' .
         'as students) to better understand the data types available on the site.'),
@@ -199,7 +199,7 @@ function tripal_feature_admin() {
      '#type'        => 'textarea',
      '#description' => t("Enter the Sequence Ontology (SO) terms for the feature types that " .
                          "will be shown in the feature browser."),
-     '#default_value' => variable_get('chado_browser_feature_types', 'gene mRNA'),
+     '#default_value' => variable_get('chado_browser_feature_types'),
   );
 
 

+ 106 - 121
tripal_feature/theme/templates/tripal_organism_feature_browser.tpl.php

@@ -5,141 +5,126 @@ $organism = $variables['node']->organism;
 // get the list of available sequence ontology terms for which
 // we will build drupal pages from features in chado.  If a feature
 // is not one of the specified typse we won't build a node for it.
-$allowed_types = variable_get('chado_browser_feature_types', 'gene mRNA');
+$allowed_types = variable_get('chado_browser_feature_types');
 $allowed_types = preg_replace("/[\s\n\r]+/", " ", $allowed_types);
 $so_terms = explode(' ', $allowed_types);
 
-// get the feature_id's of the feature that belong to this organism.  But we only
-// want 25 and we want a pager to let the user cycle between pages of features.
-// so we, use the chado_select_record API function to get the results and
-// generate the pager.  The function is smart enough to know which page the user is
-// on and retrieves the proper set of features
-$element = 0;        // an index to specify the pager if more than one is on the page
-$num_per_page = 25;  // the number of features to show per page
-$values = array(
-  'organism_id' => $organism->organism_id,
-  'type_id' => array(
-    'name' => $so_terms
-  ),
-);
-$columns = array('feature_id');
-$options = array(
-  'pager' => array(
-    'limit' => $num_per_page,
-    'element' => $element
-   ),
-  'order_by' => array('name' => 'ASC'),
-);
-$results = chado_select_record('feature', $columns, $values, $options);
+// Don't show the browser if there are no terms
+if (count($so_terms) > 0) {
 
-// now that we have all of the feature IDs, we want to expand each one so that we
-// have all of the neccessary values, including the node ID, if one exists, and the
-// cvterm type name.
-$features = array();
-foreach ($results as $result) {
-  $values = array('feature_id' => $result->feature_id);
+  // get the feature_id's of the feature that belong to this organism.  But we only
+  // want 25 and we want a pager to let the user cycle between pages of features.
+  // so we, use the chado_select_record API function to get the results and
+  // generate the pager.  The function is smart enough to know which page the user is
+  // on and retrieves the proper set of features
+  $element = 0;        // an index to specify the pager if more than one is on the page
+  $num_per_page = 25;  // the number of features to show per page
+  $values = array(
+    'organism_id' => $organism->organism_id,
+    'type_id' => array(
+      'name' => $so_terms
+    ),
+  );
+  $columns = array('feature_id');
   $options = array(
-    'include_fk' => array(
-      'type_id' => 1
-    )
+    'pager' => array(
+      'limit' => $num_per_page,
+      'element' => $element
+     ),
+    'order_by' => array('name' => 'ASC'),
   );
-  $features[] = chado_generate_var('feature', $values, $options);
-}
+  $results = chado_select_record('feature', $columns, $values, $options);
 
-if (count($features) > 0) { ?>
-  <div class="tripal_organism-data-block-desc tripal-data-block-desc">The following browser provides a quick view for new visitors.  Use the searching mechanism to find specific features.</div> <?php
+  // now that we have all of the feature IDs, we want to expand each one so that we
+  // have all of the neccessary values, including the node ID, if one exists, and the
+  // cvterm type name.
+  $features = array();
+  foreach ($results as $result) {
+    $values = array('feature_id' => $result->feature_id);
+    $options = array(
+      'include_fk' => array(
+        'type_id' => 1
+      )
+    );
+    $features[] = chado_generate_var('feature', $values, $options);
+  }
 
-  // the $headers array is an array of fields to use as the colum headers.
-  // additional documentation can be found here
-  // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
-  $headers = array('Feature Name' ,'Unique Name', 'Type');
+  if (count($features) > 0) { ?>
+    <div class="tripal_organism-data-block-desc tripal-data-block-desc">The following browser provides a quick view for new visitors.  Use the searching mechanism to find specific features.</div> <?php
 
-  // the $rows array contains an array of rows where each row is an array
-  // of values for each column of the table in that row.  Additional documentation
-  // can be found here:
-  // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
-  $rows = array();
+    // the $headers array is an array of fields to use as the colum headers.
+    // additional documentation can be found here
+    // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
+    $headers = array('Feature Name' ,'Unique Name', 'Type');
 
-  // let admins know they can customize the terms that appear in the list
-  print tripal_set_message("Administrators, you can specify the feature types ".
-    "that should appear in this browser or remove it from the list of resources ".
-    "by navigating to the ".
-    l("Tripal feature settings page", "admin/tripal/chado/tripal_feature/configuration", array('attributes' => array('target' => '_blank'))),
-    TRIPAL_INFO,
-    array('return_html' => 1)
-  );
+    // the $rows array contains an array of rows where each row is an array
+    // of values for each column of the table in that row.  Additional documentation
+    // can be found here:
+    // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
+    $rows = array();
+
+    // let admins know they can customize the terms that appear in the list
+    print tripal_set_message("Administrators, you can specify the feature types ".
+      "that should appear in this browser or remove it from the list of resources ".
+      "by navigating to the ".
+      l("Tripal feature settings page", "admin/tripal/chado/tripal_feature/configuration", array('attributes' => array('target' => '_blank'))),
+      TRIPAL_INFO,
+      array('return_html' => 1)
+    );
 
-  foreach ($features as $feature){
-    $fname =  $feature->name;
-    if (property_exists($feature, 'nid')) {
-      $fname =   l($fname, "node/$feature->nid", array('attributes' => array('target' => '_blank')));
+    foreach ($features as $feature){
+      $fname =  $feature->name;
+      if (property_exists($feature, 'nid')) {
+        $fname =   l($fname, "node/$feature->nid", array('attributes' => array('target' => '_blank')));
+      }
+      $rows[] = array(
+        $fname,
+        $feature->uniquename,
+        $feature->type_id->name
+      );
     }
-    $rows[] = array(
-      $fname,
-      $feature->uniquename,
-      $feature->type_id->name
+    // the $table array contains the headers and rows array as well as other
+    // options for controlling the display of the table.  Additional
+    // documentation can be found here:
+    // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
+    $table = array(
+      'header' => $headers,
+      'rows' => $rows,
+      'attributes' => array(
+        'id' => 'tripal_organism-table-features',
+        'class' => 'tripal-data-table'
+      ),
+      'sticky' => FALSE,
+      'caption' => '',
+      'colgroups' => array(),
+      'empty' => '',
     );
-  }
-  // the $table array contains the headers and rows array as well as other
-  // options for controlling the display of the table.  Additional
-  // documentation can be found here:
-  // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
-  $table = array(
-    'header' => $headers,
-    'rows' => $rows,
-    'attributes' => array(
-      'id' => 'tripal_organism-table-features',
-      'class' => 'tripal-data-table'
-    ),
-    'sticky' => FALSE,
-    'caption' => '',
-    'colgroups' => array(),
-    'empty' => '',
-  );
-  // once we have our table array structure defined, we call Drupal's theme_table()
-  // function to generate the table.
-  print theme_table($table);
+    // once we have our table array structure defined, we call Drupal's theme_table()
+    // function to generate the table.
+    print theme_table($table);
 
-  // the $pager array values that control the behavior of the pager.  For
-  // documentation on the values allows in this array see:
-  // https://api.drupal.org/api/drupal/includes!pager.inc/function/theme_pager/7
-  // here we add the paramter 'block' => 'feature_browser'. This is because
-  // the pager is not on the default block that appears. When the user clicks a
-  // page number we want the browser to re-appear with the page is loaded.
-  $pager = array(
-    'tags' => array(),
-    'element' => $element,
-    'parameters' => array(
-      'block' => 'feature_browser'
-    ),
-    'quantity' => $num_per_page,
-  );
-  print theme_pager($pager);
-}
-else {  ?>
-  <p>There are no results.</p><?php
-  print tripal_set_message("
-    Administrators, perform the following to show features in this browser:
-    <ul>
-      <li>Load features for this organism using the " .
-        l("FASTA loader", 'admin/tripal/loaders/fasta_loader') . ",  ".
-        l("GFF Loader",   'admin/tripal/loaders/gff3_load') . " or ".
-        l("Bulk Loader",  'admin/tripal/loaders/bulk'). "</li>
-      <li>Sync the features that should have pages using the ".
-        l("Sync features page", 'admin/tripal/chado/tripal_feature/sync'). "</li>
-      <li>Return to this page to browse features.</li>
-      <li>Ensure the user " .
-       l("has permission", 'admin/people/permissions') . " to view the feature content</li>
-    </ul>
-    <br>
-    <br>
-    You can specify the feature types
-    that should appear in this browser or remove it from the list of resources by navigating to the " .
-    l("Tripal feature settings page", "admin/tripal/chado/tripal_feature/configuration", array('attributes' => array('target' => '_blank')))  . "
-    The feature browser will not appear to site visitors unless features are present. ",
-    TRIPAL_INFO,
-    array('return_html' => 1));
-}
+    // the $pager array values that control the behavior of the pager.  For
+    // documentation on the values allows in this array see:
+    // https://api.drupal.org/api/drupal/includes!pager.inc/function/theme_pager/7
+    // here we add the paramter 'block' => 'feature_browser'. This is because
+    // the pager is not on the default block that appears. When the user clicks a
+    // page number we want the browser to re-appear with the page is loaded.
+    $pager = array(
+      'tags' => array(),
+      'element' => $element,
+      'parameters' => array(
+        'block' => 'feature_browser'
+      ),
+      'quantity' => $num_per_page,
+    );
+    print theme_pager($pager);
 
+    print tripal_set_message("
+      Administrators, please note that the feature browser will be retired in
+      a future version of Tripal.",
+      TRIPAL_INFO,
+      array('return_html' => 1));
+  }
+}
 
 

+ 2 - 2
tripal_views/includes/tripal_views_integration.inc

@@ -57,7 +57,7 @@ function tripal_views_integrate_all_chado_tables() {
 
       // Assuming that we have a default chado table, genereate an integration
       // array describing it's Tripal Views integration.
-      if (in_array($tablename, $base_tables) OR in_array($tablename, $mview_tables)) {
+      if (in_array($tablename, $base_tables) OR (is_array($mview_tables) and in_array($tablename, $mview_tables))) {
         $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, TRUE, $priority);
       }
       else {
@@ -66,7 +66,7 @@ function tripal_views_integrate_all_chado_tables() {
 
       // Check to see if this table is a Materialized view and if it is,
       // treat it specially :).
-      if (in_array($tablename, $mview_tables)) {
+      if (is_array($mview_tables) and in_array($tablename, $mview_tables)) {
         $table_integration_array['type'] = 'mview';
       }