Pārlūkot izejas kodu

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

Stephen Ficklin 8 gadi atpakaļ
vecāks
revīzija
00f95e05b6

+ 1 - 1
tripal_core/api/tripal_core.chado_nodes.api.inc

@@ -911,7 +911,7 @@ function chado_node_sync_records($base_table, $max_sync = FALSE,
   print "\n$count $base_table records found.\n";
 
   $i = 0;
-  $transaction = db_transaction();
+  //$transaction = db_transaction();
   print "\nNOTE: Syncing is performed using a database transaction. \n" .
       "If the sync fails or is terminated prematurely then the entire set of \n" .
       "synced items is rolled back and will not be found in the database\n\n";

+ 28 - 0
tripal_core/api/tripal_core.jobs.api.inc

@@ -277,6 +277,34 @@ function tripal_cancel_job($job_id, $redirect = TRUE) {
   }
 }
 
+
+/**
+ * Execute a specific Tripal Job.
+ *
+ * @param $job_id
+ *          The job id to be exeuted
+ * @param bool $redirect [optional]
+ *          Whether to redirect to the job page or not
+ */
+function tripal_execute_job($job_id, $redirect = TRUE) {
+  $sql = "SELECT * FROM {tripal_jobs} WHERE job_id = :job_id";
+  $results = db_query($sql, array(':job_id' => $job_id));
+  $job = $results->fetchObject();
+
+  // set the end time for this job
+  if ($job->start_time == 0 and $job->end_time == 0) {
+    tripal_launch_job(1, $job_id);
+    drupal_set_message(t("Job %job_id has finished executing. See below for more information.", array('%job_id' => $job_id)));
+  }
+  else {
+    drupal_set_message(t("Job %job_id cannot be executed. It has already finished.", array('%job_id' => $job_id)));
+  }
+
+  if ($redirect) {
+    drupal_goto("admin/tripal/tripal_jobs/view/$job_id");
+  }
+}
+
 /**
  * A function used to manually launch all queued tripal jobs
  *

+ 5 - 1
tripal_core/includes/tripal_core.jobs.inc

@@ -176,9 +176,12 @@ function tripal_jobs_report() {
     $start = tripal_get_job_start($job);
     $end = tripal_get_job_end($job);
     $cancel_link = '';
+    $execute_link = '';
     if ($job->start_time == 0 and $job->end_time == 0) {
       $cancel_link = "<a href=\"" . url("admin/tripal/tripal_jobs/cancel/" . $job->job_id) . "\">Cancel</a><br />";
+      $execute_link = "<a href=\"" . url("admin/tripal/tripal_jobs/execute/" . $job->job_id) . "\">Execute</a><br />";
     }
+
     $rerun_link = "<a href=\"" . url("admin/tripal/tripal_jobs/rerun/" . $job->job_id) . "\">Re-run</a><br />";
     $view_link ="<a href=\"" . url("admin/tripal/tripal_jobs/view/" . $job->job_id) . "\">View</a>";
     $rows[] = array(
@@ -189,7 +192,7 @@ function tripal_jobs_report() {
       $job->priority,
       $job->progress . '%',
       $job->job_status,
-      "$cancel_link $rerun_link $view_link",
+      "$execute_link $cancel_link $rerun_link $view_link",
     );
   }
 
@@ -287,6 +290,7 @@ function tripal_jobs_view($job_id) {
   $links .= l('Re-run this job', "admin/tripal/tripal_jobs/rerun/" . $job->job_id) . ' | ';
   if ($job->start_time == 0 and $job->end_time == 0) {
     $links .= l('Cancel this job', "admin/tripal/tripal_jobs/cancel/" . $job->job_id) . ' | ';
+    $links .= l('Execute this job', "admin/tripal/tripal_jobs/execute/".$job->job_id);
   }
 
   // make our start and end times more legible

+ 10 - 0
tripal_core/tripal_core.module

@@ -211,6 +211,16 @@ function tripal_core_menu() {
     'access arguments' => array('administer tripal'),
     'type' => MENU_CALLBACK,
   );
+
+  $items['admin/tripal/tripal_jobs/execute/%'] = array(
+    'title' => 'Jobs',
+    'description' => t('Execute an existing job'),
+    'page callback' => 'tripal_execute_job',
+    'page arguments' => array(4),
+    'access arguments' => array('administer tripal'),
+    'type' => MENU_CALLBACK,
+  );
+
   $items['admin/tripal/tripal_jobs/rerun/%'] = array(
     'title' => 'Jobs',
     'description' => t('Re-run an existing job.'),

+ 10 - 2
tripal_core/tripal_core.views_default.inc

@@ -245,12 +245,20 @@ function tripal_core_admin_defaultview_jobs() {
   $handler->display->display_options['fields']['nothing_3']['alter']['make_link'] = TRUE;
   $handler->display->display_options['fields']['nothing_3']['alter']['path'] = 'admin/tripal/tripal_jobs/cancel/[job_id]';
   /* Field: Global: Custom text */
+  $handler->display->display_options['fields']['nothing_4']['id'] = 'nothing_4';
+  $handler->display->display_options['fields']['nothing_4']['table'] = 'views';
+  $handler->display->display_options['fields']['nothing_4']['field'] = 'nothing';
+  $handler->display->display_options['fields']['nothing_4']['label'] = 'Execute link';
+  $handler->display->display_options['fields']['nothing_4']['exclude'] = TRUE;
+  $handler->display->display_options['fields']['nothing_4']['alter']['text'] = 'Execute';
+  $handler->display->display_options['fields']['nothing_4']['alter']['make_link'] = TRUE;
+  $handler->display->display_options['fields']['nothing_4']['alter']['path'] = 'admin/tripal/tripal_jobs/execute/[job_id]';
+  /* Field: Global: Custom text */
   $handler->display->display_options['fields']['nothing_1']['id'] = 'nothing_1';
   $handler->display->display_options['fields']['nothing_1']['table'] = 'views';
   $handler->display->display_options['fields']['nothing_1']['field'] = 'nothing';
   $handler->display->display_options['fields']['nothing_1']['label'] = 'Action';
-  $handler->display->display_options['fields']['nothing_1']['alter']['text'] = '[nothing_2]<br />
-  [nothing_3]';
+  $handler->display->display_options['fields']['nothing_1']['alter']['text'] = '[nothing_4]<br />[nothing_2]<br />[nothing_3]';
   $handler->display->display_options['fields']['nothing_1']['element_class'] = 'short-column';
   $handler->display->display_options['fields']['nothing_1']['element_label_class'] = 'short-column';
   /* Filter criterion: Tripal Jobs: Job Name */

+ 1 - 1
tripal_feature/theme/templates/tripal_feature_publications.tpl.php

@@ -1184,7 +1184,7 @@ function tripal_pub_node_insert($node) {
 function tripal_pub_node_load($nodes, $types) {
   if (count(array_intersect(array('chado_pub'), $types))) {
     foreach ($nodes as $nid => $node) {
-      if ($node->type == 'chado_pub' and !property_exists($node, 'path')) {
+      if ($node->type == 'chado_pub' and !drupal_lookup_path('alias', 'node/'. $nid)) {
         $pub_id = chado_get_id_from_nid('pub', $node->nid);
         $path = tripal_pub_set_pub_url($node, $pub_id);
       }