Browse Source

Added support to indicate if base_table or not and made this distinction for analysis, contact, cv ,db, feature and organism integration

Lacey Sanderson 12 năm trước cách đây
mục cha
commit
c4b710a2b1

+ 18 - 6
tripal_analysis/tripal_analysis.views.inc

@@ -35,23 +35,35 @@ require('views/misc_tables.views.inc');
 function tripal_analysis_views_data()  {
   $data = array();
 
-  //$data = array_merge($data, retrieve_analysis_views_data());
-  //$data = array_merge($data, retrieve_chado_analysis_views_data());
-  //$data = array_merge($data, retrieve_analysis_misc_tables_views_data());
-
   if (module_exists('tripal_views')) {
+		// Base Table: Analysis
+		$tablename = 'analysis';
+		if (!tripal_views_is_integrated($tablename, 10)) {
+			$table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, TRUE);
+			tripal_views_integration_add_entry($table_integration_array);
+		}
+      
+
     $tables = array(
-      'analysis',
       'analysisfeature',
       'analysisprop'
     );
     foreach ($tables as $tablename) {
       if (!tripal_views_is_integrated($tablename, 10)) {
-        $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename);
+        $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, FALSE);
         tripal_views_integration_add_entry($table_integration_array);
       }
     }
+  
+  // Old Style Views Integration
+  } else {
+
+  	$data = array_merge($data, retrieve_analysis_views_data());
+  	$data = array_merge($data, retrieve_chado_analysis_views_data());
+  	$data = array_merge($data, retrieve_analysis_misc_tables_views_data());
+    
   }
+  
   return $data;
 }
 

+ 10 - 2
tripal_contact/tripal_contact.views.inc

@@ -26,13 +26,21 @@ function tripal_contact_views_data()  {
   $data = array();
 
   if (module_exists('tripal_views')) {
+    
+    // Base Table: contact
+    $table_name = 'contact';
+    if (!tripal_views_is_integrated($tablename, 10)) {
+      $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, TRUE);
+      tripal_views_integration_add_entry($table_integration_array);
+    }
+      
+    // Additional tables
     $tables = array(
-      'contact',
       'contact_relationship',
     );
     foreach ($tables as $tablename) {
       if (!tripal_views_is_integrated($tablename, 10)) {
-        $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename);
+        $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, FALSE);
         tripal_views_integration_add_entry($table_integration_array);
       }
     }

+ 14 - 3
tripal_cv/tripal_cv.views.inc

@@ -43,10 +43,21 @@ function tripal_cv_views_data() {
   //Returns the data array for the chado cv table
   //$data = array_merge($data, retrieve_cv_views_data());
   
-    if (module_exists('tripal_views')) {
+  if (module_exists('tripal_views')) {
+    // Base Tables
     $tables = array(
       'cv',
-      'cvterm',
+      'cvterm'
+    );
+    foreach ($tables as $tablename) {
+      if (!tripal_views_is_integrated($tablename, 10)) {
+        $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename,TRUE);
+        tripal_views_integration_add_entry($table_integration_array);
+      }
+    }
+    
+    // Additional Tables
+    $tables = array(
       'cvterm_dbxref',
       'cvterm_relationship',
       'cvtermpath',
@@ -55,7 +66,7 @@ function tripal_cv_views_data() {
     );
     foreach ($tables as $tablename) {
       if (!tripal_views_is_integrated($tablename, 10)) {
-        $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename);
+        $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename,FALSE);
         tripal_views_integration_add_entry($table_integration_array);
       }
     }

+ 13 - 2
tripal_db/tripal_db.views.inc

@@ -36,14 +36,25 @@ function tripal_db_views_data()  {
    //$data = array_merge($data, retrieve_db_views_data());
    
   if (module_exists('tripal_views')) {
+    // Base Tables
     $tables = array(
       'db',
-      'dbxref',
+      'dbxref'
+    );
+    foreach ($tables as $tablename) {
+      if (!tripal_views_is_integrated($tablename, 10)) {
+        $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename,TRUE);
+        tripal_views_integration_add_entry($table_integration_array);
+      }
+    }
+        
+    // Additional Tables
+    $tables = array(
       'dbxrefprop'
     );
     foreach ($tables as $tablename) {
       if (!tripal_views_is_integrated($tablename, 10)) {
-        $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename);
+        $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename,FALSE);
         tripal_views_integration_add_entry($table_integration_array);
       }
     }

+ 10 - 1
tripal_feature/tripal_feature.views.inc

@@ -42,6 +42,15 @@ function tripal_feature_views_data()  {
   if (module_exists('tripal_views')) {
     $tables = array(
       'feature',
+    );
+    foreach ($tables as $tablename) {
+      if (!tripal_views_is_integrated($tablename, 10)) {
+        $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename,TRUE);
+        tripal_views_integration_add_entry($table_integration_array);
+      }
+    }
+        
+    $tables = array(
       //'feature_cvterm',
       'feature_cvterm_dbxref',
       'feature_cvterm_pub',
@@ -65,7 +74,7 @@ function tripal_feature_views_data()  {
     );
     foreach ($tables as $tablename) {
       if (!tripal_views_is_integrated($tablename, 10)) {
-        $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename);
+        $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename,FALSE);
         tripal_views_integration_add_entry($table_integration_array);
       }
     }

+ 13 - 2
tripal_organism/tripal_organism.views.inc

@@ -36,14 +36,25 @@ function tripal_organism_views_data()  {
   //$data = array_merge($data, retrieve_chado_organism_views_data());
   
   if (module_exists('tripal_views')) {
+    // Base Table
+    $tables = array(
+      'organism'
+    );
+    foreach ($tables as $tablename) {
+      if (!tripal_views_is_integrated($tablename, 10)) {
+        $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename,TRUE);
+        tripal_views_integration_add_entry($table_integration_array);
+      }
+    }
+    
+    // Additional Tables
     $tables = array(
-      'organism',
       'organismprop',
       'organism_dbxref'
     );
     foreach ($tables as $tablename) {
       if (!tripal_views_is_integrated($tablename, 10)) {
-        $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename);
+        $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename,FALSE);
         tripal_views_integration_add_entry($table_integration_array);
       }
     }

+ 4 - 1
tripal_views/tripal_views.api.inc

@@ -89,6 +89,7 @@ function tripal_views_is_lightest_priority_setup ($setup_id, $table_name) {
     'type' => 'chado', //either chado or mview depending on tablename
     'description' => 'Create a listing of features.', //description seen when creating a view of this type
     'priority' => 10, //For Base tripal modules: 10; custom modules: 9 to 0;
+    'base_table' => TRUE //either TRUE or FALSE depending on whether the current table should show up in the add view list
     'fields' => array(
       'feature_id' => array(
         'name' => 'feature_id', //field name in database
@@ -122,6 +123,7 @@ function tripal_views_integration_add_entry($defn_array) {
     'name' => $defn_array['name'],
     'comment' => $defn_array['description'],
     'priority' => $defn_array['priority'],
+    'base_table' => ($defn_array['base_table']) ? 1 : 0,
   );
   if ($defn_array['type'] == 'mview') {
       $mview = db_fetch_object(db_query("SELECT mview_id FROM tripal_mviews WHERE mv_table='%s'",$defn_array['table']));
@@ -266,7 +268,7 @@ function tripal_views_integration_remove_entry_by_setup_id ($setup_id) {
  *   The tripal views integration array which is the parameter for 
  *   tripal_views_integration_add_entry($defn_array)
  */
-function tripal_views_get_integration_array_for_chado_table ($table_name) {
+function tripal_views_get_integration_array_for_chado_table ($table_name, $base_table = TRUE) {
 
   // Get the schema for this table (via the chado schema api)
   $schema = module_invoke_all('chado_'.$table_name.'_schema');
@@ -278,6 +280,7 @@ function tripal_views_get_integration_array_for_chado_table ($table_name) {
     'name' => ucwords(str_replace('_',' ',$table_name)),
     'description' => ($schema['description']) ? $schema['description'] : ' ',
     'priority' => 10,
+    'base_table' => $base_table,
     'fields' => array(),
   );
   

+ 10 - 0
tripal_views/tripal_views.install

@@ -70,6 +70,10 @@ function tripal_views_update_6040 () {
 	$schema = tripal_views_views_schema();
 	db_create_table(&$ret, 'tripal_views_field', $schema['tripal_views_field']);
 	
+	// Add base_table TRUE/FALSE to tripal_views
+	db_add_field($ret, 'tripal_views', 'base_table', array('type' => 'int', 'not null ' => TRUE,
+			'default' => 1));
+	
   return $ret;
 }
 
@@ -112,6 +116,12 @@ function tripal_views_views_schema(){
 				'not null' => TRUE,
 				'default' => '',
 			),
+			'base_table' => array(
+				'description' => 'Indicated whether the table should be a base table of a view',
+				'type' => 'int',
+				'not null ' => TRUE,
+				'default' => 1
+			),
 			'comment' => array(
 				'description' => 'add notes about this views setup',
 				'type' => 'text',

+ 23 - 9
tripal_views/tripal_views.views.inc

@@ -421,7 +421,8 @@ function tripal_views_views_data(){
       ),
    );
   
- 
+    // Add Tripal views Integration
+    // Basically, use tripal_views record to generate the views $data array
     $tvi_query = db_query('SELECT * FROM {tripal_views}');
 
     while($tvi_row = db_fetch_object($tvi_query)){
@@ -441,7 +442,10 @@ function tripal_views_views_data(){
       $base_table = '';
       $base_fields = array();
       $type_prefix = '';
-
+      
+      // indicated whether the current table is a base table or not
+      $is_base_table = $tvi_row->base_table;
+      
       // populate the base table name and fields.  If an $mview_id is given
       // then get the materialized view info, otherwise get the Chado table info
       if($mview_id){
@@ -474,7 +478,7 @@ function tripal_views_views_data(){
          }
       }
       else {
-         $type_prefix = 'Chado Table';
+         $type_prefix = 'Chado';
          $base_table = $tvi_row->table_name;
          // The chado table could be a regular Chado table or a custom table
          // in the chado database.  Therefore we'll check both
@@ -499,12 +503,22 @@ function tripal_views_views_data(){
       }
 
       // Setup the base table info in the data array
-      $data[$base_table]['table']['group'] = t("$type_prefix: $tvi_row->name");
-      $data[$base_table]['table']['base'] = array(
-        'group' => "$type_prefix: $tvi_row->name",
-        'title' => "$type_prefix: $tvi_row->name",
-        'help'  => $tvi_row->comment,
-      );
+      $data[$base_table]['table']['group'] = t("$type_prefix $tvi_row->name");
+      
+      if ($is_base_table) {
+        $data[$base_table]['table']['base'] = array(
+          'group' => "$type_prefix $tvi_row->name",
+          'title' => "$type_prefix $tvi_row->name",
+          'help'  => $tvi_row->comment,
+        );
+      } else {
+        $data[$base_table]['table'] = array(
+          'group' => "$type_prefix $tvi_row->name",
+          'title' => "$type_prefix $tvi_row->name",
+          'help'  => $tvi_row->comment,
+        );
+      }
+      
       // first add the fields
       foreach ($base_fields as $column_name => $base_field){
         $data[$base_table][$column_name] = array(