Sfoglia il codice sorgente

destroying the transaction to try and help speed

Shawna Spoor 7 anni fa
parent
commit
4ed248e606

+ 25 - 13
tripal/api/tripal.importer.api.inc

@@ -113,19 +113,6 @@ function tripal_run_importer($import_id, TripalJob $job = NULL) {
       $loader->logMessage('Removing downloaded file...');
       unlink($temp);
     }
-
-    print "\nDone\n";
-
-
-    // Check for tables with new cvterms
-    tripal_chado_map_cvterms();
-
-    // Check for new fields and notify the user.
-    tripal_tripal_cron_notification();
-
-    // Clear the Drpual chace
-    cache_clear_all();
-
   }
   catch (Exception $e) {
     $transaction->rollback();
@@ -136,5 +123,30 @@ function tripal_run_importer($import_id, TripalJob $job = NULL) {
       $loader->cleanFile();
     }
   }
+  unset($transaction);
+  try {
+    // the transaction
+    $transaction = db_transaction();
+    $loader->postRun();
+  } 
+  catch (Exception $e) {
+    $transaction->rollback();
+    if ($job) {
+      $job->logMessage($e->getMessage(), array(), TRIPAL_ERROR);
+    }
+    if ($loader) {
+      $loader->cleanFile();
+    }
+  }
+  // Check for tables with new cvterms
+  tripal_chado_map_cvterms();
+  
+  // Check for new fields and notify the user.
+  tripal_tripal_cron_notification();
+  
+  // Clear the Drpual chace
+  cache_clear_all();
+
+  print "\nDone\n";
 }
 

+ 6 - 1
tripal/includes/TripalImporter.inc

@@ -672,5 +672,10 @@ class TripalImporter {
   public function run() {
   }
 
+  /**
+   * Performs the import.
+   */
+  public function postRun() {
+  }
 
-}
+}

+ 15 - 9
tripal_chado/includes/TripalImporter/OBOImporter.inc

@@ -83,6 +83,13 @@ class OBOImporter extends TripalImporter {
 
   public static $file_required = FALSE;
 
+  /**
+   * Keep track of vocabularies that have been added.
+   *
+   * @var array
+   */
+  private $newcvs = array();
+
 
   /**
    * @see TripalImporter::form()
@@ -384,7 +391,13 @@ class OBOImporter extends TripalImporter {
 
     $this->loadOBO_v1_2_id($obo);
   }
-
+  /**
+   * @see TripalImporter::postRun()
+   *
+   */
+  public function postRun() {
+    $this->load_cvtermpath($this->newcvs);
+  }
   /**
    * A wrapper function for importing the user specified OBO file into Chado by
    * specifying the obo_id of the OBO. It requires that the file be in OBO v1.2
@@ -447,18 +460,11 @@ class OBOImporter extends TripalImporter {
    * @ingroup tripal_obo_loader
    */
   private function loadOBO_v1_2_file($obo_name, $file, $is_new = TRUE) {
-    $newcvs = array();
-
     if ($is_new) {
       tripal_insert_obo($obo_name, $file);
     }
 
-    $success = $this->loadOBO_v1_2($file, $newcvs);
-    if ($success) {
-      // update the cvtermpath table
-      $this->load_cvtermpath($newcvs);
-      print "\nDone\n";
-    }
+    $success = $this->loadOBO_v1_2($file, $this->newcvs);
   }
 
   /**