From 1f21d0f9303ff2fd07eda8f00b3f634dbb126cdd Mon Sep 17 00:00:00 2001 From: Eike Foken Date: Wed, 14 Sep 2011 05:51:23 +0200 Subject: [PATCH] Add function for starting jobs --- application/controllers/jobs.php | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/application/controllers/jobs.php b/application/controllers/jobs.php index aca4f77..9c6e2c8 100644 --- a/application/controllers/jobs.php +++ b/application/controllers/jobs.php @@ -1,7 +1,6 @@ - + * Copyright (c) 2011 Karsten Heiken, Eike Foken * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -23,7 +22,9 @@ */ /** + * * @author Karsten Heiken + * @author Eike Foken */ class Jobs extends CI_Controller { @@ -33,8 +34,29 @@ class Jobs extends CI_Controller { public function __construct() { parent::__construct(); $this->load->model('job'); + $this->load->model('experiment'); + $this->load->model('program'); } + /** + * Starts a job for the specified experiment. + * + * @param string $experimentId + */ + public function start($experimentId = '') { + $experiment = $this->experiment->getByID($experimentId); + if (isset($experiment['id'])) { + // execute program runner + $program = $this->program->getById($experiment['program_id']); + $this->load->library('program_runner', array('program_driver' => $program['driver'])); + $this->program_runner->createJob($experiment['id']); + + redirect('experiments/detail/' . $experiment['id']); + } else { + show_404(); + } + } + /** * Get jobs belonging to projects owned by the user. */ @@ -91,4 +113,4 @@ class Jobs extends CI_Controller { ) )); } -} \ No newline at end of file +}