Sfoglia il codice sorgente

Fixed priority problem on views integration

spficklin 12 anni fa
parent
commit
0d7db47de7

+ 2 - 2
tripal_analysis/tripal_analysis.views.inc

@@ -37,7 +37,7 @@ function tripal_analysis_views_data()  {
     $tablename = 'analysis';
     // get the setup with the lightest priority. That's the table 
     // that currently integrated with views.
-    $priority = tripal_views_get_lightest_priority_setup($tablename);
+    $priority = tripal_views_get_table_lightest_priority($tablename);
       
     // check to see if the table is integrated. If it is then integrate it's
     // corresponding 'chado_[table]' table.
@@ -66,7 +66,7 @@ function tripal_analysis_views_data()  {
       'analysisprop'
     );
     foreach ($tables as $tablename) {
-    	$priority = tripal_views_get_lightest_priority_setup($tablename);     
+    	$priority = tripal_views_get_table_lightest_priority($tablename);     
       if (!tripal_views_is_integrated($tablename, $priority)) {
         $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, FALSE, $priority);
         tripal_views_integration_add_entry($table_integration_array);

+ 2 - 2
tripal_contact/tripal_contact.views.inc

@@ -32,7 +32,7 @@ function tripal_contact_views_data()  {
     
     // get the setup with the lightest priority. That's the table 
     // that currently integrated with views.
-    $priority = tripal_views_get_lightest_priority_setup($tablename);
+    $priority = tripal_views_get_table_lightest_priority($tablename);
       
     // check to see if the table is integrated. If it is then integrate it's
     // corresponding 'chado_[table]' table.
@@ -49,7 +49,7 @@ function tripal_contact_views_data()  {
       'contact_relationship',
     );
     foreach ($tables as $tablename) {
-    	$priority = tripal_views_get_lightest_priority_setup($tablename);     
+    	$priority = tripal_views_get_table_lightest_priority($tablename);     
       if (!tripal_views_is_integrated($tablename, $priority)) {
         $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, FALSE, $priority);
         $status = tripal_views_integration_add_entry($table_integration_array);

+ 2 - 2
tripal_cv/tripal_cv.views.inc

@@ -42,7 +42,7 @@ function tripal_cv_views_data() {
     foreach ($tables as $tablename) {
     	// get the setup with the lightest priority. That's the table 
       // that currently integrated with views.
-      $priority = tripal_views_get_lightest_priority_setup($tablename);
+      $priority = tripal_views_get_table_lightest_priority($tablename);
       
       // check to see if the table is integrated. If it is then integrate it's
       // corresponding 'chado_[table]' table.
@@ -72,7 +72,7 @@ function tripal_cv_views_data() {
       'cvtermsynonym'
     );
     foreach ($tables as $tablename) {
-    	$priority = tripal_views_get_lightest_priority_setup($tablename);     
+    	$priority = tripal_views_get_table_lightest_priority($tablename);     
       if (!tripal_views_is_integrated($tablename, $priority)) {
         $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, FALSE, $priority);
         tripal_views_integration_add_entry($table_integration_array);

+ 2 - 2
tripal_db/tripal_db.views.inc

@@ -39,7 +39,7 @@ function tripal_db_views_data()  {
     foreach ($tables as $tablename) {
     	// get the setup with the lightest priority. That's the table 
       // that currently integrated with views.
-      $priority = tripal_views_get_lightest_priority_setup($tablename);
+      $priority = tripal_views_get_table_lightest_priority($tablename);
       
       // check to see if the table is integrated. If it is then integrate it's
       // corresponding 'chado_[table]' table.
@@ -60,7 +60,7 @@ function tripal_db_views_data()  {
       'dbxrefprop'
     );
     foreach ($tables as $tablename) {
-    	$priority = tripal_views_get_lightest_priority_setup($tablename);     
+    	$priority = tripal_views_get_table_lightest_priority($tablename);     
       if (!tripal_views_is_integrated($tablename, $priority)) {
         $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, FALSE, $priority);
         tripal_views_integration_add_entry($table_integration_array);

+ 2 - 2
tripal_feature/tripal_feature.views.inc

@@ -40,7 +40,7 @@ function tripal_feature_views_data()  {
     foreach ($tables as $tablename) {
     	// get the setup with the lightest priority. That's the table 
     	// that currently integrated with views.
-    	$priority = tripal_views_get_lightest_priority_setup($tablename);
+    	$priority = tripal_views_get_table_lightest_priority($tablename);
     	
     	// check to see if the table is integrated. If it is then integrate it's
     	// corresponding 'chado_[table]' table.
@@ -84,7 +84,7 @@ function tripal_feature_views_data()  {
       'featurerange'
     );
     foreach ($tables as $tablename) {
-    	$priority = tripal_views_get_lightest_priority_setup($tablename);     
+    	$priority = tripal_views_get_table_lightest_priority($tablename);     
       if (!tripal_views_is_integrated($tablename, $priority)) {
         $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, FALSE, $priority);
         tripal_views_integration_add_entry($table_integration_array);

+ 2 - 2
tripal_genetic/tripal_genetic.views.inc

@@ -32,7 +32,7 @@ function tripal_genetic_views_data()  {
     foreach ($tables as $tablename) {
     	// get the setup with the lightest priority. That's the table 
       // that currently integrated with views.
-      $priority = tripal_views_get_lightest_priority_setup($tablename);
+      $priority = tripal_views_get_table_lightest_priority($tablename);
       
       // check to see if the table is integrated. If it is then integrate it's
       // corresponding 'chado_[table]' table.
@@ -52,7 +52,7 @@ function tripal_genetic_views_data()  {
       'phenotype_comparison'
     );
     foreach ($tables as $tablename) {
-    	$priority = tripal_views_get_lightest_priority_setup($tablename);     
+    	$priority = tripal_views_get_table_lightest_priority($tablename);     
       if (!tripal_views_is_integrated($tablename, $priority)) {
         $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, FALSE, $priority);
         $status = tripal_views_integration_add_entry($table_integration_array);

+ 2 - 2
tripal_library/tripal_library.views.inc

@@ -37,7 +37,7 @@ function tripal_library_views_data()  {
     foreach ($tables as $tablename) {
     	// get the setup with the lightest priority. That's the table 
       // that currently integrated with views.
-      $priority = tripal_views_get_lightest_priority_setup($tablename);
+      $priority = tripal_views_get_table_lightest_priority($tablename);
       
       // check to see if the table is integrated. If it is then integrate it's
       // corresponding 'chado_[table]' table.
@@ -66,7 +66,7 @@ function tripal_library_views_data()  {
       'libraryprop'
     );
     foreach ($tables as $tablename) {
-    	$priority = tripal_views_get_lightest_priority_setup($tablename);     
+    	$priority = tripal_views_get_table_lightest_priority($tablename);     
       if (!tripal_views_is_integrated($tablename, $priority)) {
         $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, FALSE, $priority);
         tripal_views_integration_add_entry($table_integration_array);

+ 2 - 2
tripal_natural_diversity/tripal_natural_diversity.views.inc

@@ -32,7 +32,7 @@ function tripal_natural_diversity_views_data()  {
     foreach ($tables as $tablename) {
     	// get the setup with the lightest priority. That's the table 
       // that currently integrated with views.
-      $priority = tripal_views_get_lightest_priority_setup($tablename);
+      $priority = tripal_views_get_table_lightest_priority($tablename);
       
       // check to see if the table is integrated. If it is then integrate it's
       // corresponding 'chado_[table]' table.
@@ -73,7 +73,7 @@ function tripal_natural_diversity_views_data()  {
       'nd_reagentprop'
     );
     foreach ($tables as $tablename) {
-    	$priority = tripal_views_get_lightest_priority_setup($tablename);     
+    	$priority = tripal_views_get_table_lightest_priority($tablename);     
       if (!tripal_views_is_integrated($tablename, $priority)) {
         $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, FALSE, $priority);
         tripal_views_integration_add_entry($table_integration_array);

+ 2 - 2
tripal_organism/tripal_organism.views.inc

@@ -38,7 +38,7 @@ function tripal_organism_views_data()  {
     foreach ($tables as $tablename) {
     	// get the setup with the lightest priority. That's the table 
       // that currently integrated with views.
-      $priority = tripal_views_get_lightest_priority_setup($tablename);
+      $priority = tripal_views_get_table_lightest_priority($tablename);
       
       // check to see if the table is integrated. If it is then integrate it's
       // corresponding 'chado_[table]' table.
@@ -70,7 +70,7 @@ function tripal_organism_views_data()  {
       'organism_dbxref'
     );
     foreach ($tables as $tablename) {
-    	$priority = tripal_views_get_lightest_priority_setup($tablename);    	
+    	$priority = tripal_views_get_table_lightest_priority($tablename);    	
       if (!tripal_views_is_integrated($tablename, $priority)) {
         $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, FALSE, $priority);
         tripal_views_integration_add_entry($table_integration_array);

+ 2 - 2
tripal_phenotype/tripal_phenotype.views.inc

@@ -30,7 +30,7 @@ function tripal_phenotype_views_data()  {
     foreach ($tables as $tablename) {
     	// get the setup with the lightest priority. That's the table 
 	    // that currently integrated with views.
-	    $priority = tripal_views_get_lightest_priority_setup($tablename);
+	    $priority = tripal_views_get_table_lightest_priority($tablename);
 	      
 	    // check to see if the table is integrated. If it is then integrate it's
 	    // corresponding 'chado_[table]' table.
@@ -56,7 +56,7 @@ function tripal_phenotype_views_data()  {
       'phenotype_cvterm'
     );
     foreach ($tables as $tablename) {
-    	$priority = tripal_views_get_lightest_priority_setup($tablename);     
+    	$priority = tripal_views_get_table_lightest_priority($tablename);     
       if (!tripal_views_is_integrated($tablename, $priority)) {
         $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, FALSE, $priority);
         tripal_views_integration_add_entry($table_integration_array);

+ 2 - 2
tripal_project/tripal_project.views.inc

@@ -30,7 +30,7 @@ function tripal_project_views_data()  {
     foreach ($tables as $tablename) {
     	// get the setup with the lightest priority. That's the table 
       // that currently integrated with views.
-      $priority = tripal_views_get_lightest_priority_setup($tablename);
+      $priority = tripal_views_get_table_lightest_priority($tablename);
       
       // check to see if the table is integrated. If it is then integrate it's
       // corresponding 'chado_[table]' table.
@@ -53,7 +53,7 @@ function tripal_project_views_data()  {
     $tables = array(
     );
     foreach ($tables as $tablename) {
-    	$priority = tripal_views_get_lightest_priority_setup($tablename);     
+    	$priority = tripal_views_get_table_lightest_priority($tablename);     
       if (!tripal_views_is_integrated($tablename, $priority)) {
         $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, FALSE, $priority);
         tripal_views_integration_add_entry($table_integration_array);

+ 3 - 3
tripal_stock/tripal_stock.views.inc

@@ -35,7 +35,7 @@ function tripal_stock_views_data()  {
     $tablename = 'stock';
     // get the setup with the lightest priority. That's the table 
     // that currently integrated with views.
-    $priority = tripal_views_get_lightest_priority_setup($tablename);
+    $priority = tripal_views_get_table_lightest_priority($tablename);
       
     // check to see if the table is integrated. If it is then integrate it's
     // corresponding 'chado_[table]' table.
@@ -55,7 +55,7 @@ function tripal_stock_views_data()  {
     }
 
     $tablename = 'stockcollection';
-    $priority = tripal_views_get_lightest_priority_setup($tablename);     
+    $priority = tripal_views_get_table_lightest_priority($tablename);     
       if (!tripal_views_is_integrated($tablename, $priority)) {
       $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, TRUE, $priority);
       tripal_views_integration_add_entry($table_integration_array);
@@ -74,7 +74,7 @@ function tripal_stock_views_data()  {
       'stockprop_pub'
     );
     foreach ($tables as $tablename) {
-    	$priority = tripal_views_get_lightest_priority_setup($tablename);     
+    	$priority = tripal_views_get_table_lightest_priority($tablename);     
       if (!tripal_views_is_integrated($tablename, $priority)) {
         $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, FALSE, $priority);
         tripal_views_integration_add_entry($table_integration_array);

+ 25 - 0
tripal_views/api/tripal_views.api.inc

@@ -5,6 +5,31 @@
  * API functions for Tripal Views Integration
  */
 
+/**
+ * Retrieve the priority of the lightest priority for a given table
+ *
+ * NOTE: Uses lightest priority (drupal-style) where the range is from -10 to 10
+ * and -10 is of highest priority.
+ *
+ * @param $table_name
+ *   The name of the table to retrieve the setup ID for. This can be either a materialized
+ *   view or a chado table
+ *
+ * @return
+ *   On success, the setup_id to use for integration of this table; otherwise FALSE
+ */
+function tripal_views_get_table_lightest_priority($table_name) {
+
+  $sql = "SELECT setup_id FROM {tripal_views} WHERE table_name='%s' ORDER BY priority ASC";
+  $setup = db_fetch_object(db_query($sql, $table_name));
+  if ($setup) {
+    return $setup->priority;
+  }
+  else {
+    return FALSE;
+  }
+}
+
 /**
  * Retrieve the views integration setup with the lightest priority for a given table
  *