Parcourir la source

Fixed chado_views_relationship_to_node views handler -now produces fully qualified joins

Lacey Sanderson il y a 12 ans
Parent
commit
8626dd6023

+ 5 - 2
tripal_views/tripal_views.views.inc

@@ -81,7 +81,7 @@ function tripal_views_views_handlers() {
       'tripal_views_handler_filter_sequence' => array(
         'parent' => 'chado_views_handler_filter_string',
       ),
-      
+
       // Custom Tripal Field Handlers
       'tripal_views_handler_field_aggregate' => array(
         'parent' => 'chado_views_handler_field',
@@ -102,6 +102,9 @@ function tripal_views_views_handlers() {
       'chado_views_handler_relationship' => array(
         'parent' => 'views_handler_relationship'
       ),
+      'chado_views_handler_relationship_to_node' => array(
+        'parent' => 'views_handler_relationship'
+      ),
 
       // Wrappers for Default Views Handlers-----
       // Field Handlers
@@ -554,7 +557,7 @@ function tripal_views_data_export_download_form(&$form_state, $view, $display_id
 
       $urls[$display->id]['path'] = $path;
       $urls[$display->id]['query'] = $query;
-      
+
       // add the new item to the options array
       $options[$display->id] = $display->display_title;
     }

+ 19 - 8
tripal_views/views/handlers/chado_views_handler_relationship_to_node.inc

@@ -25,15 +25,27 @@ class chado_views_handler_relationship_to_node extends views_handler_relationshi
 
     // First add base => chado_base join
     $def = array();
-    $def['left_table'] = 'chado_' . $this->table;
-    $def['left_field'] = $this->field;
-    $def['table'] = $this->table;
+    $def['table'] = 'chado_' . $this->table;
     $def['field'] = $this->field;
+    $def['left_table'] = $this->table;
+    $def['left_field'] = $this->field;
     //$def['handler'] = 'views_handler_join_chado_aggregator';
-    $def['pre-aggregated'] = TRUE;
-    $def['table_aggregated'] = 'CURRENT';
 
-    dpm($def, 'definition in to node relationship handler');
+    $join = new views_join();
+
+    $join->definition = $def;
+    $join->construct();
+    $join->adjusted = TRUE;
+
+    $this->linker_alias = $this->query->add_relationship('stock_chado_stock', $join, $this->table);
+
+    // Now add chado_base => node join
+    $def = array();
+    $def['table'] = 'node';
+    $def['field'] = 'nid';
+    $def['left_table'] = $this->linker_alias;
+    $def['left_field'] = 'nid';
+    //$def['handler'] = 'views_handler_join_chado_aggregator';
 
     $join = new views_join();
 
@@ -41,7 +53,6 @@ class chado_views_handler_relationship_to_node extends views_handler_relationshi
     $join->construct();
     $join->adjusted = TRUE;
 
-    $this->alias = $this->query->add_relationship('stock_chado_stock', $join, $def['left_table']);
-    dpm($this->query, 'query');
+    $this->alias = $this->query->add_relationship('chado_stock_node', $join, 'node');
   }
 }