From: <gem...@li...> - 2012-02-20 12:06:37
|
Revision: 500 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=500&view=rev Author: mennodekker Date: 2012-02-20 12:06:25 +0000 (Mon, 20 Feb 2012) Log Message: ----------- Introducing the independent TaskRunnerBatch that can execute all kinds of tasks in a single batch and converted Gems_Tracker_Batch_ProcessTokensBatch to the TaskRunner Modified Paths: -------------- trunk/library/classes/Gems/Loader.php trunk/library/classes/Gems/Tracker.php trunk/library/classes/MUtil/Batch/BatchAbstract.php Added Paths: ----------- trunk/library/classes/Gems/Task/ trunk/library/classes/Gems/Task/CheckTokenCompletion.php trunk/library/classes/Gems/Task/CheckTrackTokens.php trunk/library/classes/Gems/Task/ProcessTokenCompletion.php trunk/library/classes/Gems/Task/TaskAbstract.php trunk/library/classes/Gems/Task/TaskInterface.php trunk/library/classes/Gems/Task/TaskRunnerBatch.php Modified: trunk/library/classes/Gems/Loader.php =================================================================== --- trunk/library/classes/Gems/Loader.php 2012-02-16 17:19:44 UTC (rev 499) +++ trunk/library/classes/Gems/Loader.php 2012-02-20 12:06:25 UTC (rev 500) @@ -203,6 +203,24 @@ /** * + * @return Gems_Task_TaskAbstract + */ + public function getTask($name) { + return $this->_getClass('task', 'Task_' . ucfirst($name)); + } + + /** + * + * @param type $id + * @return Gems_Task_TaskRunnerBatch + */ + public function getTaskRunnerBatch($id) + { + return $this->_loadClass('Task_TaskRunnerBatch', true, array($id)); + } + + /** + * * @return Gems_Tracker_TrackerInterface */ public function getTracker() Added: trunk/library/classes/Gems/Task/CheckTokenCompletion.php =================================================================== --- trunk/library/classes/Gems/Task/CheckTokenCompletion.php (rev 0) +++ trunk/library/classes/Gems/Task/CheckTokenCompletion.php 2012-02-20 12:06:25 UTC (rev 500) @@ -0,0 +1,85 @@ +<?php +/** + * Copyright (c) 2011, Erasmus MC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Erasmus MC nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Short description of file + * + * @package Gems + * @subpackage + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: Sample.php 215 2011-07-12 08:52:54Z michiel $ + */ + +/** + * Short description for ProcessTokens + * + * Long description for class ProcessTokens (if any)... + * + * @package Gems + * @subpackage Sample + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.0 + * @deprecated Class deprecated since version 2.0 + */ +class Gems_Task_CheckTokenCompletion extends Gems_Task_TaskAbstract +{ + /** + * @var Gems_Tracker + */ + public $tracker; + + public function execute($tokenData = null, $userId = null) + { + $this->tracker = $this->loader->getTracker(); + $this->_batch->addToCounter('checkedTokens'); + $token = $this->tracker->getToken($tokenData); + + if ($result = $token->checkTokenCompletion($userId)) { + if ($result & Gems_Tracker_Token::COMPLETION_DATACHANGE) { + $this->_batch->addToCounter('resultDataChanges'); + } + if ($result & Gems_Tracker_Token::COMPLETION_EVENTCHANGE) { + $this->_batch->addToCounter('surveyCompletionChanges'); + } + } + + if ($token->isCompleted()) { + $this->_batch->setTask('processTokenCompletion', 'tokproc-' . $token->getTokenId(), $tokenData, $userId); + } + + if ($this->_batch->getCounter('surveyCompletionChanges')) { + $this->_batch->setMessage('surveyCompletionChanges', sprintf($this->translate->_('Answers changed by survey completion event for %d tokens.'), $this->_batch->getCounter('surveyCompletionChanges'))); + } + + if ($this->_batch->getCounter('resultDataChanges')) { + $this->_batch->setMessage('resultDataChanges', sprintf($this->translate->_('Results and timing changed for %d tokens.'), $this->_batch->getCounter('resultDataChanges'))); + } + + $this->_batch->setMessage('checkedTokens', sprintf($this->translate->_('Checked %d tokens.'), $this->_batch->getCounter('checkedTokens'))); + } +} \ No newline at end of file Added: trunk/library/classes/Gems/Task/CheckTrackTokens.php =================================================================== --- trunk/library/classes/Gems/Task/CheckTrackTokens.php (rev 0) +++ trunk/library/classes/Gems/Task/CheckTrackTokens.php 2012-02-20 12:06:25 UTC (rev 500) @@ -0,0 +1,74 @@ +<?php + +/** + * Copyright (c) 2011, Erasmus MC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Erasmus MC nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Short description of file + * + * @package Gems + * @subpackage + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: Sample.php 215 2011-07-12 08:52:54Z michiel $ + */ + +/** + * Short description for CheckTrackTokens + * + * Long description for class CheckTrackTokens (if any)... + * + * @package Gems + * @subpackage Sample + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.0 + * @deprecated Class deprecated since version 2.0 + */ +class Gems_Task_CheckTrackTokens extends Gems_Task_TaskAbstract +{ + /** + * @var Gems_Tracker + */ + public $tracker; + + public function execute($respTrackData = null, $userId = null) + { + $this->tracker = $this->loader->getTracker(); + $respTrack = $this->tracker->getRespondentTrack($respTrackData); + $this->_batch->addToCounter('checkedRespondentTracks'); + + if ($result = $respTrack->checkTrackTokens($userId)) { + $this->_batch->addToCounter('tokenDateCauses'); + $this->_batch->addToCounter('tokenDateChanges', $result); + } + + if ($this->_batch->getCounter('tokenDateChanges')) { + $this->_batch->setMessage('tokenDateChanges', sprintf($this->translate->_('%2$d token date changes in %1$d tracks.'), $this->_batch->getCounter('tokenDateCauses'), $this->_batch->getCounter('tokenDateChanges'))); + } + + $this->_batch->setMessage('checkedRespondentTracks', sprintf($this->translate->_('Checked %d tracks.'), $this->_batch->getCounter('checkedRespondentTracks'))); + } +} \ No newline at end of file Added: trunk/library/classes/Gems/Task/ProcessTokenCompletion.php =================================================================== --- trunk/library/classes/Gems/Task/ProcessTokenCompletion.php (rev 0) +++ trunk/library/classes/Gems/Task/ProcessTokenCompletion.php 2012-02-20 12:06:25 UTC (rev 500) @@ -0,0 +1,79 @@ +<?php + +/** + * Copyright (c) 2011, Erasmus MC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Erasmus MC nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Short description of file + * + * @package Gems + * @subpackage + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: Sample.php 215 2011-07-12 08:52:54Z michiel $ + */ + +/** + * Short description for ProcessTokenCompletion + * + * Long description for class ProcessTokenCompletion (if any)... + * + * @package Gems + * @subpackage Sample + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.0 + * @deprecated Class deprecated since version 2.0 + */ +class Gems_Task_ProcessTokenCompletion extends Gems_Task_TaskAbstract +{ + /** + * @var Gems_Tracker + */ + public $tracker; + + + public function execute($tokenData = null, $userId = null) + { + $this->tracker = $this->loader->getTracker(); + $token = $this->tracker->getToken($tokenData); + + if ($token->isCompleted()) { + $respTrack = $token->getRespondentTrack(); + + if ($result = $respTrack->handleRoundCompletion($token, $userId)) { + $this->_batch->addToCounter('roundCompletionCauses'); + $this->_batch->addToCounter('roundCompletionChanges', $result); + } + + $trackId = $respTrack->getRespondentTrackId(); + $this->_batch->setTask('checkTrackTokens', 'chktrck-' . $trackId, $trackId, $userId); + } + + if ($this->_batch->getCounter('roundCompletionChanges')) { + $this->_batch->setMessage('roundCompletionChanges', sprintf($this->translate->_('%d token round completion events caused changed to %d tokens.'), $this->_batch->getCounter('roundCompletionCauses'), $this->_batch->getCounter('roundCompletionChanges'))); + } + } +} \ No newline at end of file Added: trunk/library/classes/Gems/Task/TaskAbstract.php =================================================================== --- trunk/library/classes/Gems/Task/TaskAbstract.php (rev 0) +++ trunk/library/classes/Gems/Task/TaskAbstract.php 2012-02-20 12:06:25 UTC (rev 500) @@ -0,0 +1,76 @@ +<?php + +/** + * Copyright (c) 2011, Erasmus MC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Erasmus MC nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Short description of file + * + * @package Gems + * @subpackage + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: Sample.php 215 2011-07-12 08:52:54Z michiel $ + */ + +/** + * Short description for TaskAbstract + * + * Long description for class TaskAbstract (if any)... + * + * @package Gems + * @subpackage Sample + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.0 + * @deprecated Class deprecated since version 2.0 + */ +abstract class Gems_Task_TaskAbstract extends MUtil_Registry_TargetAbstract implements Gems_Task_TaskInterface +{ + /** + * @var Gems_Task_TaskRunnerBatch + */ + protected $_batch; + + /** + * @var array + */ + protected $_params; + + /** + * @var Gems_Loader + */ + public $loader; + + /** + * @var Zend_Translate_Adapter + */ + public $translate; + + public function setBatch(Gems_Task_TaskRunnerBatch $batch) + { + $this->_batch = $batch; + } +} \ No newline at end of file Added: trunk/library/classes/Gems/Task/TaskInterface.php =================================================================== --- trunk/library/classes/Gems/Task/TaskInterface.php (rev 0) +++ trunk/library/classes/Gems/Task/TaskInterface.php 2012-02-20 12:06:25 UTC (rev 500) @@ -0,0 +1,55 @@ +<?php + +/** + * Copyright (c) 2011, Erasmus MC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Erasmus MC nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Short description of file + * + * @package Gems + * @subpackage + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: Sample.php 215 2011-07-12 08:52:54Z michiel $ + */ + +/** + * Short description for TaskAbstract + * + * Long description for class TaskAbstract (if any)... + * + * @package Gems + * @subpackage Sample + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.0 + * @deprecated Class deprecated since version 2.0 + */ +interface Gems_Task_TaskInterface +{ + public function execute(); + + public function setBatch(Gems_Task_TaskRunnerBatch $batch); +} \ No newline at end of file Added: trunk/library/classes/Gems/Task/TaskRunnerBatch.php =================================================================== --- trunk/library/classes/Gems/Task/TaskRunnerBatch.php (rev 0) +++ trunk/library/classes/Gems/Task/TaskRunnerBatch.php 2012-02-20 12:06:25 UTC (rev 500) @@ -0,0 +1,137 @@ +<?php + +/** + * Copyright (c) 2011, Erasmus MC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Erasmus MC nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Short description of file + * + * @package Gems + * @subpackage + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: Sample.php 215 2011-07-12 08:52:54Z michiel $ + */ + +/** + * Short description for TaskRunnerBatch + * + * Long description for class TaskRunnerBatch (if any)... + * + * @package Gems + * @subpackage Sample + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.0 + * @deprecated Class deprecated since version 2.0 + */ +class Gems_Task_TaskRunnerBatch extends MUtil_Batch_BatchAbstract +{ + /** + * @var Gems_Loader + */ + public $loader; + + public $minimalStepDurationMs = 1000; + + public function __construct($id = null) + { + parent::__construct($id); + $this->loader = GemsEscort::getInstance()->loader; + } + + /** + * Add a message to the message stack. + * + * @param string $text A message to the user + * @return Gems_Task_TaskRunnerBatch + */ + public function addMessage($text) + { + parent::addMessage($text); + } + + /** + * Increment a named counter + * + * @param string $name + * @param integer $add + * @return integer + */ + public function addToCounter($name, $add = 1) + { + return parent::addToCounter($name, $add); + } + + /** + * Add a task to the stack, optionally adding as much parameters as needed + * + * @param string $task + * @return Gems_Task_TaskRunnerBatch + */ + public function addTask($task, $param1 = null) + { + $params = array_slice(func_get_args(), 1); + $this->addStep('runTask', $task, $params); + + return $this; + } + + public function runTask($task, $params) + { + $params = array_slice(func_get_args(), 1); + $taskClass = $this->loader->getTask($task); + $taskClass->setBatch($this); + call_user_func_array(array($taskClass, 'execute'), $params[0]); + } + + /** + * Add/set a message on the message stack with a specific id. + * + * @param scalar $id + * @param string $text A message to the user + * @return Gems_Task_TaskRunnerBatch + */ + public function setMessage($id, $text) + { + return parent::setMessage($id, $text); + } + + /** + * Add an execution step to the command stack. + * + * @param string $task + * @param mixed $id A unique id to prevent double adding of something to do + * @param mixed $param1 Scalar or array with scalars, as many parameters as needed allowed + * @return Gems_Task_TaskRunnerBatch + */ + public function setTask($task, $id, $param1 = null) + { + $params = array_slice(func_get_args(), 2); + $this->setStep('runTask', $id, $task, $params); + + return $this; + } +} \ No newline at end of file Modified: trunk/library/classes/Gems/Tracker.php =================================================================== --- trunk/library/classes/Gems/Tracker.php 2012-02-16 17:19:44 UTC (rev 499) +++ trunk/library/classes/Gems/Tracker.php 2012-02-20 12:06:25 UTC (rev 500) @@ -128,6 +128,12 @@ /** * + * @var Gems_Loader + */ + protected $loader; + + /** + * * @var Zend_Translate */ protected $translate; @@ -841,6 +847,19 @@ { $where = implode(' ', $tokenSelect->getSelect()->getPart(Zend_Db_Select::WHERE)); + $batch = $this->loader->getTaskRunnerBatch($batch_id); + + if (! $batch->isLoaded()) { + $statement = $tokenSelect->getSelect()->query(); + //Process one row at a time to prevent out of memory errors for really big resultsets + while ($tokenData = $statement->fetch()) { + $tokenId = $tokenData['gto_id_token']; + $batch->setTask('checkTokenCompletion', 'tokchk-' . $tokenId, $tokenId, $userId); + $batch->addToCounter('tokens'); + } + } + + /* $batch = $this->_loadClass('Batch_ProcessTokensBatch', true, array($batch_id)); if (! $batch->isLoaded()) { @@ -850,6 +869,7 @@ $batch->addToken($tokenData['gto_id_token'], $userId); } } + */ return $batch; } Modified: trunk/library/classes/MUtil/Batch/BatchAbstract.php =================================================================== --- trunk/library/classes/MUtil/Batch/BatchAbstract.php 2012-02-16 17:19:44 UTC (rev 499) +++ trunk/library/classes/MUtil/Batch/BatchAbstract.php 2012-02-20 12:06:25 UTC (rev 500) @@ -81,6 +81,13 @@ private $_id; /** + * Holds the last message set by the batch job + * + * @var string + */ + private $_lastMessage = null; + + /** * Stack to keep existing id's. * * @var array @@ -246,6 +253,7 @@ protected function addMessage($text) { $this->_session->messages[] = $text; + $this->_lastMessage = $text; return $this; } @@ -313,6 +321,11 @@ return (string) $this->_functionPrefix; } + protected function getLastMessage() + { + return $this->_lastMessage; + } + /** * String of messages from the batch * @@ -560,7 +573,7 @@ // error_log('Cur: ' . microtime(true) . ' report is '. (microtime(true) > $reportRun ? 'true' : 'false')); if (microtime(true) > $reportRun) { // Communicate progress - $bar->update($this->getProgressPercentage(), end($this->_session->messages)); + $bar->update($this->getProgressPercentage(), $this->getLastMessage()); // INFO: When using PULL $bar->update() should exit the program, // but just let us make sure. @@ -619,6 +632,7 @@ protected function setMessage($id, $text) { $this->_session->messages[$id] = $text; + $this->_lastMessage = $text; return $this; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |