Browse Source

Merge branch '7.x-3.x' of https://github.com/tripal/tripal into 7.x-3.x

laceysanderson 7 years ago
parent
commit
61b01348aa

+ 19 - 0
tripal_chado/includes/tripal_chado.fields.inc

@@ -187,6 +187,16 @@ function tripal_chado_bundle_fields_info_base(&$info, $details, $entity_type, $b
     if ($column_name == 'uniquename') {
       $base_info['settings']['text_processing'] = 0;
     }
+
+    // Sometimes the boolean fields are listed as integer.  We need to
+    // correct for that.
+    if ($column_name == 'is_obsolete' or $column_name == 'is_analysis' or
+        $column_name == 'is_relationshiptype' or $column_name == 'is_for_definition' or
+        $column_name == 'is_view' or $column_name == 'is_updateable') {
+      $base_info['type'] = 'list_boolean';
+      $base_info['settings']['allowed_values'] = array(0 => "No", 1 => "Yes");
+    }
+
     //
     // PUB TABLE
     //
@@ -935,6 +945,15 @@ function tripal_chado_bundle_instances_info_base(&$info, $entity_type, $bundle,
       $base_info['label'] = 'Time Last Modified';
       $base_info['description'] = 'Please enter the time that this record was last modified. The default is the current time.';
     }
+
+    // Sometimes the boolean fields are listed as integer.  We need to
+    // correct for that.
+    if ($column_name == 'is_obsolete' or $column_name == 'is_analysis' or
+        $column_name == 'is_relationshiptype' or $column_name == 'is_for_definition' or
+        $column_name == 'is_view' or $column_name == 'is_updateable') {
+      $base_info['widget']['type'] = 'options_onoff';
+      $base_info['required'] = FALSE;
+    }
     //
     // ORGANISM TABLE
     //

+ 22 - 6
tripal_chado/includes/tripal_chado.vocab_storage.inc

@@ -28,14 +28,30 @@ function tripal_chado_vocab_get_vocabulary($vocabulary) {
   if (!chado_table_exists('cv')) {
     return FALSE;
   }
-  $sql = "
-     SELECT DB.name as short_name, DB.description, DB.url, DB.urlprefix,
-       array_to_string(array_agg(DBCVM.cvname), ', ') as name
+
+  if (chado_table_exists('db2cv_mview')) {
+    $sql = "
+       SELECT DB.name as short_name, DB.description, DB.url, DB.urlprefix,
+         array_to_string(array_agg(DBCVM.cvname), ', ') as name
+       FROM {db} DB
+        INNER JOIN {db2cv_mview} DBCVM ON DBCVM.db_id = DB.db_id
+       WHERE DB.name = :name
+       GROUP BY DB.name, DB.description, DB.url, DB.urlprefix
+    ";
+  }
+  // For backwards compatibility.  Tripal sites above 3.0-beta2 don't need this.
+  else {
+    $sql = "
+     SELECT DB.name as short_name, CV.name as name, DB.description, DB.url, DB.urlprefix
      FROM {db} DB
-      INNER JOIN {db2cv_mview} DBCVM ON DBCVM.db_id = DB.db_id
-     WHERE DB.name = :name
-     GROUP BY DB.name, DB.description, DB.url, DB.urlprefix
+      LEFT JOIN {dbxref} DBX on DBX.db_id = DB.db_id
+      LEFT JOIN {cvterm} CVT on CVT.dbxref_id = DBX.dbxref_id
+      LEFT JOIN {cv} CV on CV.cv_id = CVT.cv_id
+     WHERE
+      DB.name = :name
+     LIMIT 1 OFFSET 0
   ";
+  }
   $result = chado_query($sql, array(':name' => $vocabulary));
   $result = $result->fetchAssoc();