Ver Fonte

Fixed bug in tripal_get_Cvterm() API function

Stephen Ficklin há 11 anos atrás
pai
commit
b2e9596aa5

+ 12 - 23
tripal_cv/api/tripal_cv.api.inc

@@ -202,36 +202,30 @@ function tripal_get_cvterm($identifiers, $options = array()) {
   }
 
   // If synonym was passed in, then process this first before calling chado_generate_var()
-  if (isset($identifier['synonym'])) {
-    $synonym = $identifier['synonym']['name'];
+  if (isset($identifiers['synonym'])) {
+    $synonym = $identifiers['synonym']['name'];
 
-    $values = array(
-       'synonym' => $synonym,
-    );
-    $statement = "sel_cvtermsynonym_sy";
-    if (isset($identifier['synonym']['cv_id'])) {
-      $values['cvterm_id'] = array('cv_id' => $identifier['synonym']['cv_id']);
-      $statement = "sel_cvtermsynonym_sycv";
+    $values = array('synonym' => $synonym);
+    if (isset($identifiers['synonym']['cv_id'])) {
+      $values['cvterm_id'] = array('cv_id' => $identifiers['synonym']['cv_id']);
     }
-    if (isset($identifier['synonym']['cv_name'])) {
-      $values['cvterm_id'] = array('cv_id' => array('name' => $identifier['synonym']['cv_name']));
-      $statement = "sel_cvtermsynonym_sycv";
+    if (isset($identifiers['synonym']['cv_name'])) {
+      $values['cvterm_id'] = array('cv_id' => array('name' => $identifiers['synonym']['cv_name']));
     }
     $options = array(
-      'statement_name' => $statement,
       'case_insensitive_columns' => array('name')
     );
-    $synonym = chado_select_record('cvtermsynonym', array('cvterm_id'), $values, $options);
+    $result = chado_select_record('cvtermsynonym', array('cvterm_id'), $values, $options);
 
     // if the synonym doens't exist or more than one record is returned then return false
-    if (count($synonym) == 0) {
+    if (count($result) == 0) {
       return FALSE;
     }
-    if (count($synonym) > 1) {
+    if (count($result) > 1) {
       return FALSE;
     }
 
-    $identifiers = array('cvterm_id' => $synonym[0]->cvterm_id);
+    $identifiers = array('cvterm_id' => $result[0]->cvterm_id);
   }
 
   // If one of the identifiers is property then use chado_get_record_with_property()
@@ -243,13 +237,8 @@ function tripal_get_cvterm($identifiers, $options = array()) {
 
   // Else we have a simple case and we can just use chado_generate_var to get the cvterm
   else {
-
     // Try to get the cvterm
-    $cvterm = chado_generate_var(
-      'cvterm',
-      $identifiers,
-      $options
-    );
+    $cvterm = chado_generate_var('cvterm', $identifiers, $options);
   }
 
   // Ensure the cvterm is singular. If it's an array then it is not singular

+ 3 - 3
tripal_pub/includes/tripal_pub.pub_importers.inc

@@ -969,7 +969,7 @@ function tripal_pub_add_publication($pub_details, &$action, $do_contact = FALSE,
         'name' => 'tripal_pub'
       ),
     );
-    $pub_type = cvterm_retrieve($identifiers);
+    $pub_type = tripal_get_cvterm($identifiers);
   }
   else {
     tripal_report_error('tripal_pub', TRIPAL_ERROR,
@@ -1063,7 +1063,7 @@ function tripal_pub_add_publication($pub_details, &$action, $do_contact = FALSE,
         'name' => 'tripal_pub'
       ),
     );
-    $cvterm = cvterm_retrieve($identifiers);
+    $cvterm = tripal_get_cvterm($identifiers);
 
     // if we could not find the cvterm by name then try by synonym
     //$cvterm = tripal_cv_get_cvterm_by_name($key, NULL, 'tripal_pub');
@@ -1074,7 +1074,7 @@ function tripal_pub_add_publication($pub_details, &$action, $do_contact = FALSE,
           'cv_name' => 'tripal_pub'
         )
       );
-      $cvterm = cvterm_retrieve($identifiers);
+      $cvterm = tripal_get_cvterm($identifiers);
     }
     if (!$cvterm) {
       tripal_report_error('tripal_pub', TRIPAL_ERROR, "Cannot find term: '%prop'. Skipping.", array('%prop' => $key));