Преглед на файлове

Added a function that lists all tables in a Chado schema (per version) and altered the core to use that function. Previously it used a Postgres SQL statement to pull out all tables in the schema but this caused problems when non Chado tables were also present in the schema.

spficklin преди 12 години
родител
ревизия
b7c7cd26de

+ 16 - 16
tripal_core/api/tripal_core.api.inc

@@ -2816,24 +2816,24 @@ function tripal_core_chado_schema_exists() {
  */
 function tripal_core_get_chado_tables($include_custom = NULL) {
 
-  if (is_array($db_url) AND array_key_exists('chado', $db_url)) {
-    $previous_db = tripal_db_set_active('chado');
-    // @coder-ignore: acting on pg_catalog schema rather then drupal schema therefore, table prefixing does not apply
-    $sql = 'SELECT tablename FROM pg_tables';
-    $resource = db_query($sql);
-    tripal_db_set_active($previous_db);
-  }
-  else {
-    // @coder-ignore: acting on pg_catalog schema rather then drupal schema therefore, table prefixing does not apply
-    $sql = "SELECT tablename FROM pg_tables WHERE schemaname='chado'";
-    $resource = db_query($sql);
-  }
-
+	
+	// first get the chado version that is installed
+  $v = tripal_core_get_chado_version();
+  
   $tables = array();
-  while ($r = db_fetch_object($resource)) {
-    $tables[$r->tablename] = $r->tablename;
+  if ($v == '1.2') {
+    $tables_v1_2 = tripal_core_chado_get_v1_2_tables();
+    foreach ($tables_v1_2 as $table) {
+      $tables[$table] = $table;
+    }
   }
-
+  if ($v == '1.11' or $v == '1.11 or older') {
+    $tables_v1_11 = tripal_core_chado_get_v1_11_tables();
+    foreach ($tables_v1_11 as $table) {
+      $tables[$table] = $table;
+    }
+  }
+  
   // now add in the custom tables too
   if ($include_custom) {
     $sql = "SELECT table_name FROM {tripal_custom_tables}";

+ 158 - 0
tripal_core/api/tripal_core.schema_v1.11.api.inc

@@ -10751,3 +10751,161 @@ function tripal_core_chado_schema_v1_11_treatment() {
   );
   return $description;
 }
+
+/**
+ * Lists the table names in the v1.11 chado schema
+ *
+ * @return
+ *    An array containing all of the table names
+ *
+ * @ingroup tripal_chado_v1.2_schema_api
+ *
+ */
+function tripal_core_chado_get_v1_11_tables() {
+  $tables = array(
+		'acquisition',
+		'acquisition_relationship',
+		'acquisitionprop',
+		'analysis',
+		'analysisfeature',
+		'analysisfeatureprop',
+		'analysisprop',
+		'arraydesign',
+		'arraydesignprop',
+		'assay',
+		'assay_biomaterial',
+		'assay_project',
+		'assayprop',
+		'biomaterial',
+		'biomaterial_dbxref',
+		'biomaterial_relationship',
+		'biomaterial_treatment',
+		'biomaterialprop',
+		'cell_line',
+		'cell_line_cvterm',
+		'cell_line_cvtermprop',
+		'cell_line_dbxref',
+		'cell_line_feature',
+		'cell_line_library',
+		'cell_line_pub',
+		'cell_line_relationship',
+		'cell_line_synonym',
+		'cell_lineprop',
+		'cell_lineprop_pub',
+		'channel',
+		'contact',
+		'contact_relationship',
+		'control',
+		'cv',
+		'cvterm',
+		'cvterm_dbxref',
+		'cvterm_relationship',
+		'cvtermpath',
+		'cvtermprop',
+		'cvtermsynonym',
+		'db',
+		'dbxref',
+		'dbxrefprop',
+		'eimage',
+		'element',
+		'element_relationship',
+		'elementresult',
+		'elementresult_relationship',
+		'environment',
+		'environment_cvterm',
+		'expression',
+		'expression_cvterm',
+		'expression_cvtermprop',
+		'expression_image',
+		'expression_pub',
+		'expressionprop',
+		'feature',
+		'feature_cvterm',
+		'feature_cvterm_dbxref',
+		'feature_cvterm_pub',
+		'feature_cvtermprop',
+		'feature_dbxref',
+		'feature_expression',
+		'feature_expressionprop',
+		'feature_genotype',
+		'feature_phenotype',
+		'feature_pub',
+		'feature_pubprop',
+		'feature_relationship',
+		'feature_relationship_pub',
+		'feature_relationshipprop',
+		'feature_relationshipprop_pub',
+		'feature_synonym',
+		'featureloc',
+		'featureloc_pub',
+		'featuremap',
+		'featuremap_pub',
+		'featurepos',
+		'featureprop',
+		'featureprop_pub',
+		'featurerange',
+		'genotype',
+		'library',
+		'library_cvterm',
+		'library_dbxref',
+		'library_feature',
+		'library_pub',
+		'library_synonym',
+		'libraryprop',
+		'libraryprop_pub',
+		'magedocumentation',
+		'mageml',
+		'materialized_view',
+		'organism',
+		'organism_dbxref',
+		'organismprop',
+		'phendesc',
+		'phenotype',
+		'phenotype_comparison',
+		'phenotype_comparison_cvterm',
+		'phenotype_cvterm',
+		'phenstatement',
+		'phylonode',
+		'phylonode_dbxref',
+		'phylonode_organism',
+		'phylonode_pub',
+		'phylonode_relationship',
+		'phylonodeprop',
+		'phylotree',
+		'phylotree_pub',
+		'project',
+		'protocol',
+		'protocolparam',
+		'pub',
+		'pub_dbxref',
+		'pub_relationship',
+		'pubauthor',
+		'pubprop',
+		'quantification',
+		'quantification_relationship',
+		'quantificationprop',
+		'stock',
+		'stock_cvterm',
+		'stock_dbxref',
+		'stock_genotype',
+		'stock_pub',
+		'stock_relationship',
+		'stock_relationship_pub',
+		'stockcollection',
+		'stockcollection_stock',
+		'stockcollectionprop',
+		'stockprop',
+		'stockprop_pub',
+		'study',
+		'study_assay',
+		'studydesign',
+		'studydesignprop',
+		'studyfactor',
+		'studyfactorvalue',
+		'studyprop',
+		'studyprop_feature',
+		'synonym',
+		'tableinfo',
+		'treatment'
+  );
+}

+ 188 - 0
tripal_core/api/tripal_core.schema_v1.2.api.inc

@@ -13993,3 +13993,191 @@ function tripal_core_chado_schema_v1_2_treatment() {
   );
   return $description;
 }
+
+/**
+ * Lists the table names in the v1.2 chado schema
+ *
+ * @return
+ *    An array containing all of the table names
+ *
+ * @ingroup tripal_chado_v1.2_schema_api
+ *
+ */
+function tripal_core_chado_get_v1_2_tables() {
+  $tables = array(
+    'acquisition',
+		'acquisition_relationship',
+		'acquisitionprop',
+		'analysis',
+		'analysisfeature',
+		'analysisfeatureprop',
+		'analysisprop',
+		'arraydesign',
+		'arraydesignprop',
+		'assay',
+		'assay_biomaterial',
+		'assay_project',
+		'assayprop',
+		'biomaterial',
+		'biomaterial_dbxref',
+		'biomaterial_relationship',
+		'biomaterial_treatment',
+		'biomaterialprop',
+		'cell_line',
+		'cell_line_cvterm',
+		'cell_line_cvtermprop',
+		'cell_line_dbxref',
+		'cell_line_feature',
+		'cell_line_library',
+		'cell_line_pub',
+		'cell_line_relationship',
+		'cell_line_synonym',
+		'cell_lineprop',
+		'cell_lineprop_pub',
+		'chadoprop',
+		'channel',
+		'contact',
+		'contact_relationship',
+		'control',
+		'cv',
+		'cvprop',
+		'cvterm',
+		'cvterm_dbxref',
+		'cvterm_relationship',
+		'cvtermpath',
+		'cvtermprop',
+		'cvtermsynonym',
+		'db',
+		'dbxref',
+		'dbxrefprop',
+		'eimage',
+		'element',
+		'element_relationship',
+		'elementresult',
+		'elementresult_relationship',
+		'environment',
+		'environment_cvterm',
+		'expression',
+		'expression_cvterm',
+		'expression_cvtermprop',
+		'expression_image',
+		'expression_pub',
+		'expressionprop',
+		'feature',
+		'feature_cvterm',
+		'feature_cvterm_dbxref',
+		'feature_cvterm_pub',
+		'feature_cvtermprop',
+		'feature_dbxref',
+		'feature_expression',
+		'feature_expressionprop',
+		'feature_genotype',
+		'feature_phenotype',
+		'feature_pub',
+		'feature_pubprop',
+		'feature_relationship',
+		'feature_relationship_pub',
+		'feature_relationshipprop',
+		'feature_relationshipprop_pub',
+		'feature_synonym',
+		'featureloc',
+		'featureloc_pub',
+		'featuremap',
+		'featuremap_pub',
+		'featurepos',
+		'featureprop',
+		'featureprop_pub',
+		'featurerange',
+		'genotype',
+		'genotypeprop',
+		'library',
+		'library_cvterm',
+		'library_dbxref',
+		'library_feature',
+		'library_pub',
+		'library_synonym',
+		'libraryprop',
+		'libraryprop_pub',
+		'magedocumentation',
+		'mageml',
+		'nd_experiment',
+		'nd_experiment_contact',
+		'nd_experiment_dbxref',
+		'nd_experiment_genotype',
+		'nd_experiment_phenotype',
+		'nd_experiment_project',
+		'nd_experiment_protocol',
+		'nd_experiment_pub',
+		'nd_experiment_stock',
+		'nd_experiment_stock_dbxref',
+		'nd_experiment_stockprop',
+		'nd_experimentprop',
+		'nd_geolocation',
+		'nd_geolocationprop',
+		'nd_protocol',
+		'nd_protocol_reagent',
+		'nd_protocolprop',
+		'nd_reagent',
+		'nd_reagent_relationship',
+		'nd_reagentprop',
+		'organism',
+		'organism_dbxref',
+		'organismprop',
+		'phendesc',
+		'phenotype',
+		'phenotype_comparison',
+		'phenotype_comparison_cvterm',
+		'phenotype_cvterm',
+		'phenstatement',
+		'phylonode',
+		'phylonode_dbxref',
+		'phylonode_organism',
+		'phylonode_pub',
+		'phylonode_relationship',
+		'phylonodeprop',
+		'phylotree',
+		'phylotree_pub',
+		'project',
+		'project_contact',
+		'project_pub',
+		'project_relationship',
+		'projectprop',
+		'protocol',
+		'protocolparam',
+		'pub',
+		'pub_dbxref',
+		'pub_relationship',
+		'pubauthor',
+		'pubprop',
+		'quantification',
+		'quantification_relationship',
+		'quantificationprop',
+		'stock',
+		'stock_cvterm',
+		'stock_cvtermprop',
+		'stock_dbxref',
+		'stock_dbxrefprop',
+		'stock_genotype',
+		'stock_pub',
+		'stock_relationship',
+		'stock_relationship_cvterm',
+		'stock_relationship_pub',
+		'stockcollection',
+		'stockcollection_stock',
+		'stockcollectionprop',
+		'stockprop',
+		'stockprop_pub',
+		'study',
+		'study_assay',
+		'studydesign',
+		'studydesignprop',
+		'studyfactor',
+		'studyfactorvalue',
+		'studyprop',
+		'studyprop_feature',
+		'synonym',
+		'tableinfo',
+		'treatment'
+   );	
+   return $tables;
+}

+ 1 - 1
tripal_views/api/tripal_views.api.inc

@@ -187,7 +187,7 @@ function tripal_views_integration_add_entry($defn_array) {
   }
   else {
     $status = FALSE;
-    drupal_set_message(t('Unable to integrate %table table due to a missing name or comment field.', array('%table' => $defn_array['table'])), 'error');
+    drupal_set_message(t('Unable to integrate "%table" table due to a missing name or comment field.', array('%table' => $defn_array['table'])), 'error');
   }
 
   if ($status) {

+ 1 - 1
tripal_views/tripal_views.views.inc

@@ -231,7 +231,6 @@ function tripal_views_views_data() {
     ),
   );
 
-
   $tvi_query = db_query('SELECT * FROM {tripal_views}');
 
   while ($tvi_row = db_fetch_object($tvi_query)) {
@@ -285,6 +284,7 @@ function tripal_views_views_data() {
         $base_fields[$field->column_name]['help'] = $field->description;
       }
     }
+    // if this is not a legacy materialized view
     else {
       $base_table = $tvi_row->table_name;