Browse Source

Applied fix from Tv2 issue

Stephen Ficklin 9 years ago
parent
commit
01861c4474
2 changed files with 46 additions and 58 deletions
  1. 11 20
      tripal/tripal.install
  2. 35 38
      tripal_chado/api/modules/tripal_chado.cv.api.inc

+ 11 - 20
tripal/tripal.install

@@ -10,7 +10,18 @@
  * @ingroup tripal
  */
 function tripal_install() {
+  // Add some variables for the bundles.
   tripal_add_variables();
+
+  // On upgrade from Tv2 to Tv3 we need to add a new field to the tripal_jobs
+  // table it's missing.
+  if (!db_field_exists('tripal_jobs', 'includes')) {
+    db_add_field('tripal_jobs', 'includes', array(
+      'type' => 'text',
+      'description' => 'A serialized array of file paths that should be included prior to executing the job.',
+      'not NULL' => FALSE,
+    ));
+  }
 }
 
 /**
@@ -689,23 +700,3 @@ function tripal_tripal_bundle_variables_schema() {
 
   return $schema;
 }
-
-/**
- * This is the required update for tripal_feature when upgrading from Drupal core API 6.x.
- * This update may take some time to complete.
- */
-function tripal_update_7300() {
-  try {
-    if (!db_field_exists('tripal_jobs', 'includes')) {
-      db_add_field('tripal_jobs', 'includes', array(
-        'type' => 'text',
-        'description' => 'A serialized array of file paths that should be included prior to executing the job.',
-        'not NULL' => FALSE,
-      ));
-    }
-  }
-  catch (\PDOException $e) {
-    $error = $e->getMessage();
-    throw new DrupalUpdateException('Failed to complete update' . $error);
-  }
-}

+ 35 - 38
tripal_chado/api/modules/tripal_chado.cv.api.inc

@@ -579,9 +579,6 @@ function tripal_insert_cvterm($term, $options = array()) {
     ),
   );
   $result = chado_select_record('cvterm', array('*'), $values);
-
-  // If the constraint is met then let's check it to see if
-  // the database name matches the one we have been provided
   if (count($result) == 1) {
     $cvterm = $result[0];
 
@@ -595,41 +592,41 @@ function tripal_insert_cvterm($term, $options = array()) {
     $result = chado_select_record('db', array('*'), $values);
     $db_check = $result[0];
 
-    // The database name for this existing term does not match that of the
-    // one provided to this function.  The CV name matches otherwise we
-    // wouldn't have made it this far. So, let's swap the database for
-    // this term.
-    if ($db_check->name != $db->name) {
-
-      // Look to see if the correct dbxref record already exists for this
-      // database.
-      $values = array(
-        'db_id' => $db->db_id,
-        'accession' => $accession,
-      );
-
-      $result = chado_select_record('dbxref', array('*'), $values);
-
-      // If we already have a good dbxref then we want to update our cvterm
-      // to use this dbxref.
-      if (count($result) > 0) {
-        $dbxref = $result[0];
-        $match = array('cvterm_id' => $cvterm->cvterm_id);
-        $values = array('dbxref_id' => $dbxref->dbxref_id);
-        $success = chado_update_record('cvterm', $match, $values);
-        if (!$success) {
-          tripal_report_error('tripal_chado', TRIPAL_WARNING, "Failed to correct the dbxref id for the cvterm " .
-            "'$name' (id: $accession), for database $dbname", NULL);
-          return 0;
-        }
-      }
-      // If we don't have the dbxref then we want to delete our cvterm and let
-      // the code below recreate it with the correct info.
-      else {
-        $match = array('cvterm_id' => $cvterm->cvterm_id);
-        chado_delete_record('cvterm', $match);
-      }
-    }
+//     // The database name for this existing term does not match that of the
+//     // one provided to this function.  The CV name matches otherwise we
+//     // wouldn't have made it this far. So, let's swap the database for
+//     // this term.
+//     if ($db_check->name != $db->name) {
+
+//       // Look to see if the correct dbxref record already exists for this
+//       // database.
+//       $values = array(
+//         'db_id' => $db->db_id,
+//         'accession' => $accession,
+//       );
+
+//       $result = chado_select_record('dbxref', array('*'), $values);
+
+//       // If we already have a good dbxref then we want to update our cvterm
+//       // to use this dbxref.
+//       if (count($result) > 0) {
+//         $dbxref = $result[0];
+//         $match = array('cvterm_id' => $cvterm->cvterm_id);
+//         $values = array('dbxref_id' => $dbxref->dbxref_id);
+//         $success = chado_update_record('cvterm', $match, $values);
+//         if (!$success) {
+//           tripal_report_error('tripal_chado', TRIPAL_WARNING, "Failed to correct the dbxref id for the cvterm " .
+//             "'$name' (id: $accession), for database $dbname", NULL);
+//           return 0;
+//         }
+//       }
+//       // If we don't have the dbxref then we want to delete our cvterm and let
+//       // the code below recreate it with the correct info.
+//       else {
+//         $match = array('cvterm_id' => $cvterm->cvterm_id);
+//         chado_delete_record('cvterm', $match);
+//       }
+//     }
 
     // check that the accession matches.  Sometimes an OBO can define the same term
     // multiple times but with different accessions.  If this is the case we