Browse Source

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

Stephen Ficklin 7 years ago
parent
commit
f2de390323

+ 13 - 2
tripal/includes/TripalJob.inc

@@ -115,8 +115,19 @@ class TripalJob {
     }
 
     $includes = $details['includes'];
-    foreach ($includes as $include) {
-      require_once($include);
+    foreach ($includes as $path) {
+      $full_path = $_SERVER['DOCUMENT_ROOT'] . base_path() . $path;
+      if (!empty($path)) {
+        if (file_exists($path)) {
+          require_once($path);
+        }
+        elseif (file_exists($full_path)) {
+          require_once($path);
+        }
+        elseif (!empty($path)) {
+          throw new Exception("Included files for Tripal Job must exist. This path ($full_path) doesn't exist.");
+        }
+      }
     }
     if (!function_exists($details['callback'])) {
       throw new Exception("Must provide a valid callback function to the tripal_add_job() function.");

+ 14 - 8
tripal_chado/api/modules/tripal_chado.cv.api.inc

@@ -1239,7 +1239,7 @@ function tripal_submit_obo_job($obo) {
   $obo['file']   = (isset($obo['file']))   ? $obo['file']   : NULL;
 
   $includes = array(
-    module_load_include('inc', 'tripal_chado', 'includes/loaders/tripal_chado.obo_loader'),
+    drupal_get_path('module', 'tripal_chado') . '/includes/tripal_chado.cv.inc',
   );
 
   if ($obo['obo_id']) {
@@ -1248,18 +1248,24 @@ function tripal_submit_obo_job($obo) {
 
     $args = array($result->obo_id);
     return tripal_add_job("Load OBO " . $result->name, 'tripal_chado',
-       "tripal_chado_load_obo_v1_2_id", $args, $user->uid, 10, $includes);
+       "tripal_cv_load_obo", $args, $user->uid, 10, $includes);
   }
   else {
     if ($obo['url']) {
-      $args = array($obo['name'], $obo['url']);
-      return tripal_add_job("Load OBO " . $obo['name'], 'tripal_chado',
-        "tripal_chado_load_obo_v1_2_url", $args, $user->uid, 10, $includes);
+      $sql = "SELECT * FROM {tripal_cv_obo} WHERE path = :url";
+      $result = db_query($sql, array(':url' => $obo['url']))->fetchObject();
+
+      $args = array($result->obo_id);
+      return tripal_add_job("Load OBO " . $result->name, 'tripal_chado',
+        "tripal_cv_load_obo", $args, $user->uid, 10, $includes);
     }
     elseif ($obo['file']) {
-      $args = array($obo['name'], $obo['file']);
-      return tripal_add_job("Load OBO " . $obo['name'], 'tripal_chado',
-        "tripal_chado_load_obo_v1_2_file", $args, $user->uid, 10, $includes);
+      $sql = "SELECT * FROM {tripal_cv_obo} WHERE path = :file";
+      $result = db_query($sql, array(':url' => $obo['file']))->fetchObject();
+
+      $args = array($result->obo_id);
+      return tripal_add_job("Load OBO " . $result->name, 'tripal_chado',
+        "tripal_cv_load_obo", $args, $user->uid, 10, $includes);
     }
   }
   return FALSE;

+ 13 - 0
tripal_chado/includes/tripal_chado.cv.inc

@@ -1,4 +1,17 @@
 <?php
+
+/**
+ * Loads an OBO File using the new TripalImporter. Expected to be run by a Tripal Job.
+ */
+function tripal_cv_load_obo($obo_id) {
+
+  module_load_include('inc', 'tripal_chado', 'includes/TripalImporter/OBOImporter');
+  $obo_importer = new OBOImporter();
+  $obo_importer->create(array('obo_id' => $obo_id));
+  $obo_importer->run();
+
+}
+
 /**
  * Provide landing page to the new admin pages
  *