소스 검색

Various updates to the core: Views Integration, MViews Table, removed warnings for OBO loading, set form and form action redirects to more intuitive pages

stephen 13 년 전
부모
커밋
d82d8891fe

+ 1 - 1
base/tripal_core/mviews.php

@@ -133,7 +133,7 @@ function tripal_mviews_action ($op,$mview_id){
       }
       tripal_db_set_active($previous_db);  // now use drupal database
    }
-   return '';
+   drupal_goto("admin/tripal/views/mviews");
 }
 /**
 * Update a Materialized View

+ 20 - 15
base/tripal_core/tripal_core.views.inc

@@ -290,25 +290,29 @@ function tripal_core_views_data(){
 
     $tvi_query = db_query('SELECT * FROM {tripal_views}');
 
-    //tvi = tripal_views_integration
     while($tvi_row = db_fetch_object($tvi_query)){
 
-      //ids we'll use for queries
+      // ids we'll use for queries
       $setup_id = $tvi_row->setup_id;
       $mview_id = $tvi_row->mview_id;
 
-      //let's get the name of the materialized view
+      // holds the base table name and fields
       $base_table = '';
       $base_fields = array();
+      $type_prefix = '';
+
+      // populate the base table name and fields.  If an $mview_id is given
+      // the get the materialized view info, otherwise get the Chado table info
       if($mview_id){
-         $mview_table = db_fetch_object(db_query("SELECT name, mv_specs FROM {tripal_mviews} WHERE mview_id = '$mview_id';"));
+         $type_prefix = 'MView';
+         // get the base table name from the materialized view
+         $sql = "SELECT name, mv_specs FROM {tripal_mviews} WHERE mview_id = %d";
+         $mview_table = db_fetch_object(db_query($sql,$mview_id));
          $base_table = $mview_table->name;
 
          // get the columns in this materialized view.  They are separated by commas
          // where the first word is the column name and the rest is the type
-         $sql = "SELECT mv_specs FROM {tripal_mviews} WHERE mview_id = $mview_id";
-         $mview = db_fetch_object(db_query($sql));
-         $columns = explode(",",$mview->mv_specs);
+         $columns = explode(",",$mview_table->mv_specs);
          foreach ($columns as $column){
             $column = trim($column);  // trim trailing and leading spaces
             preg_match("/^(.*?)\ (.*?)$/",$column,$matches);
@@ -318,31 +322,32 @@ function tripal_core_views_data(){
          }
       }
       else {
-         // TODO: get the non materialized view info and populate these variables
+         $type_prefix = 'Chado Table';
+         // TODO: get the chado table info and populate these variables
          //  1) $base_table
          //  2) $base_fields (an array of just the table field names)
       }
 
-      //use name from above and description from $tvi_row
+      // Setup the base table info in the data array
       $data[$base_table]['table']['group'] = t($tvi_row->name);
       $data[$base_table]['table']['base'] = array(
-        'group' => t($tvi_row->name),
-        'title' => t($tvi_row->name),
-        'help'  => t($tvi_row->comment),
+        'group' => "$type_prefix: $tvi_row->name",
+        'title' => "$type_prefix: $tvi_row->name",
+        'help'  => $tvi_row->comment,
       );
 
       // first add the fields
       foreach ($base_fields as $base_field){
         $data[$base_table][$base_field] = array(
-           'title' => t($base_field),
-           'help' => t("**"),
+           'title' => $base_field,
+           'help' => t("The $base_field from the $base_table table (added by Tripal Views Integration)"),
            'field' => array(
               'click sortable' => TRUE,
            ),
         );
 
         // now add the handlers
-        $sql = "SELECT * FROM {tripal_views_handlers} WHERE setup_id = '$setup_id' AND base_field = '$base_field'";
+        $sql = "SELECT * FROM {tripal_views_handlers} WHERE setup_id = '$setup_id' AND column_name = '$base_field'";
         $handlers = db_query($sql);
         while($handler = db_fetch_object($handlers)){
            $data[$base_table][$base_field][$handler->hander_type]['handler'] = $handler->handler_name;

+ 7 - 4
base/tripal_core/tripal_views_integration.inc

@@ -232,7 +232,8 @@ function tripal_core_views_integration_form(&$form_state, $setup_id = NULL){
   $form['views_type']['row_description'] = array(
     '#title' => t('Comment'),
     '#type' => 'textarea',
-    '#description' => '(Optional). Provide any details regarding this setup you would like.',
+    '#description' => '(Optional). Provide any details regarding this setup you would like. This '.
+                      'description will appear when selecting a type for a new Drupal View',
     '#required' => FALSE,
   );
 
@@ -542,9 +543,9 @@ function tripal_core_views_integration_form_validate($form, &$form_state){
   $mview_id = $form_state['values']['mview_id'];
   $table_name = $form_state['values']['table_name'];
 
-  if(count($name_array) > 1){
-    form_set_error($form_state['values']['row_name'], 'The View type name must be a single word only.');
-  }
+//  if(count($name_array) > 1){
+//    form_set_error($form_state['values']['row_name'], 'The View type name must be a single word only.');
+//  }
   if($mview_id and $table_name){
     form_set_error($form_state['values']['mview_id'], 'Please select either a materialized view or a Chado table but not both');
   }
@@ -651,6 +652,8 @@ function tripal_core_views_integration_form_submit($form, &$form_state){
    } else {
       drupal_set_message('Record Added');
    }
+   // now clear all the caches so that Drupal views picks up our chages
+   views_invalidate_cache();
 }
 
 /**

+ 9 - 9
base/tripal_cv/obo_loader.php

@@ -216,7 +216,7 @@ function tripal_cv_obo_process_term($term,$defaultcv,$obo,$is_relationship=0,&$n
 
    // now handle other properites
    if(isset($term['is_anonymous'])){
-     print "WARNING: unhandled tag: is_anonymous\n";
+     //print "WARNING: unhandled tag: is_anonymous\n";
    }
    if(isset($term['alt_id'])){
       foreach($term['alt_id'] as $alt_id){
@@ -226,7 +226,7 @@ function tripal_cv_obo_process_term($term,$defaultcv,$obo,$is_relationship=0,&$n
       }
    }
    if(isset($term['subset'])){
-     print "WARNING: unhandled tag: subset\n";
+     //print "WARNING: unhandled tag: subset\n";
    }
    // add synonyms for this cvterm
    if(isset($term['synonym'])){
@@ -304,13 +304,13 @@ function tripal_cv_obo_process_term($term,$defaultcv,$obo,$is_relationship=0,&$n
       }
    } 
    if(isset($term['intersection_of'])){
-     print "WARNING: unhandled tag: intersection_of\n";
+     //print "WARNING: unhandled tag: intersection_of\n";
    }
    if(isset($term['union_of'])){
-     print "WARNING: unhandled tag: union_on\n";
+     //print "WARNING: unhandled tag: union_on\n";
    }
    if(isset($term['disjoint_from'])){
-     print "WARNING: unhandled tag: disjoint_from\n";
+     //print "WARNING: unhandled tag: disjoint_from\n";
    }
    if(isset($term['relationship'])){
       foreach($term['relationship'] as $value){
@@ -322,16 +322,16 @@ function tripal_cv_obo_process_term($term,$defaultcv,$obo,$is_relationship=0,&$n
       }
    }
    if(isset($term['replaced_by'])){
-     print "WARNING: unhandled tag: replaced_by\n";
+     //print "WARNING: unhandled tag: replaced_by\n";
    }
    if(isset($term['consider'])){
-     print "WARNING: unhandled tag: consider\n";
+     //print "WARNING: unhandled tag: consider\n";
    }
    if(isset($term['use_term'])){
-     print "WARNING: unhandled tag: user_term\n";
+     //print "WARNING: unhandled tag: user_term\n";
    }
    if(isset($term['builtin'])){
-     print "WARNING: unhandled tag: builtin\n";
+     //print "WARNING: unhandled tag: builtin\n";
    }
    return 1;
 }

+ 1 - 1
base/tripal_cv/tripal_cv.module

@@ -923,7 +923,7 @@ function tripal_cv_obo_form(&$form_state = NULL){
      '#executes_submit_callback' => TRUE,
    );
 
-   $form['#redirect'] = 'admin/tripal/tripal_cv/obo';
+   $form['#redirect'] = 'admin/tripal/tripal_cv/obo_loader';
 
 
    return $form;