|
From: <gem...@li...> - 2012-03-01 13:22:46
|
Revision: 526
http://gemstracker.svn.sourceforge.net/gemstracker/?rev=526&view=rev
Author: mennodekker
Date: 2012-03-01 13:22:33 +0000 (Thu, 01 Mar 2012)
Log Message:
-----------
Moving to a better directory structure + some cleanup. TODO: replace the two remaining Tracker\Batch classess with tasks
Modified Paths:
--------------
trunk/library/classes/Gems/Task/Db/CreateNewTable.php
trunk/library/classes/Gems/Task/Db/CreateNewTables.php
trunk/library/classes/Gems/Tracker/TrackerInterface.php
trunk/library/classes/Gems/Tracker.php
trunk/library/classes/Gems/Upgrades.php
Added Paths:
-----------
trunk/library/classes/Gems/Task/Db/ExecutePatch.php
trunk/library/classes/Gems/Task/Tracker/
trunk/library/classes/Gems/Task/Tracker/CheckTokenCompletion.php
trunk/library/classes/Gems/Task/Tracker/CheckTrackTokens.php
trunk/library/classes/Gems/Task/Tracker/ProcessTokenCompletion.php
trunk/library/classes/Gems/Task/Tracker/SourceSyncSurveys.php
Removed Paths:
-------------
trunk/library/classes/Gems/Task/CheckTokenCompletion.php
trunk/library/classes/Gems/Task/CheckTrackTokens.php
trunk/library/classes/Gems/Task/ExecutePatch.php
trunk/library/classes/Gems/Task/ProcessTokenCompletion.php
trunk/library/classes/Gems/Task/SourceSyncSurveys.php
trunk/library/classes/Gems/Tracker/Batch/ProcessTokensBatch.php
Deleted: trunk/library/classes/Gems/Task/CheckTokenCompletion.php
===================================================================
--- trunk/library/classes/Gems/Task/CheckTokenCompletion.php 2012-03-01 12:08:30 UTC (rev 525)
+++ trunk/library/classes/Gems/Task/CheckTokenCompletion.php 2012-03-01 13:22:33 UTC (rev 526)
@@ -1,83 +0,0 @@
-<?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.
- *
- * @package Gems
- * @subpackage Task
- * @copyright Copyright (c) 2011 Erasmus MC
- * @license New BSD License
- * @version $Id$
- */
-
-/**
- * Check token completion in a batch job
- *
- * This task handles the token completion check, adding tasks to the queue
- * when needed.
- *
- * @package Gems
- * @subpackage Task
- * @copyright Copyright (c) 2011 Erasmus MC
- * @license New BSD License
- * @since Class available since version 1.6
- */
-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
Deleted: trunk/library/classes/Gems/Task/CheckTrackTokens.php
===================================================================
--- trunk/library/classes/Gems/Task/CheckTrackTokens.php 2012-03-01 12:08:30 UTC (rev 525)
+++ trunk/library/classes/Gems/Task/CheckTrackTokens.php 2012-03-01 13:22:33 UTC (rev 526)
@@ -1,69 +0,0 @@
-<?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.
- *
- * @package Gems
- * @subpackage Task
- * @copyright Copyright (c) 2011 Erasmus MC
- * @license New BSD License
- * @version $Id$
- */
-
-/**
- * Checks a respondentTrack for changes, mostly started by Gems_Task_ProcessTokenCompletion
- *
- * @package Gems
- * @subpackage Task
- * @copyright Copyright (c) 2011 Erasmus MC
- * @license New BSD License
- * @since Class available since version 1.6
- */
-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
Modified: trunk/library/classes/Gems/Task/Db/CreateNewTable.php
===================================================================
--- trunk/library/classes/Gems/Task/Db/CreateNewTable.php 2012-03-01 12:08:30 UTC (rev 525)
+++ trunk/library/classes/Gems/Task/Db/CreateNewTable.php 2012-03-01 13:22:33 UTC (rev 526)
@@ -26,7 +26,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @package Gems
- * @subpackage Task
+ * @subpackage Task_Db
* @copyright Copyright (c) 2011 Erasmus MC
* @license New BSD License
* @version $Id: CheckTokenCompletion.php 502 2012-02-20 14:13:20Z mennodekker $
@@ -38,7 +38,7 @@
* Cleans the cache when a new tables was created
*
* @package Gems
- * @subpackage Task
+ * @subpackage Task_Db
* @copyright Copyright (c) 2011 Erasmus MC
* @license New BSD License
* @since Class available since version 1.6
Modified: trunk/library/classes/Gems/Task/Db/CreateNewTables.php
===================================================================
--- trunk/library/classes/Gems/Task/Db/CreateNewTables.php 2012-03-01 12:08:30 UTC (rev 525)
+++ trunk/library/classes/Gems/Task/Db/CreateNewTables.php 2012-03-01 13:22:33 UTC (rev 526)
@@ -26,7 +26,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @package Gems
- * @subpackage Task
+ * @subpackage Task_Db
* @copyright Copyright (c) 2011 Erasmus MC
* @license New BSD License
* @version $Id: CheckTokenCompletion.php 502 2012-02-20 14:13:20Z mennodekker $
@@ -36,7 +36,7 @@
* Schedules creation of new tables
*
* @package Gems
- * @subpackage Task
+ * @subpackage Task_Db
* @copyright Copyright (c) 2011 Erasmus MC
* @license New BSD License
* @since Class available since version 1.6
Added: trunk/library/classes/Gems/Task/Db/ExecutePatch.php
===================================================================
--- trunk/library/classes/Gems/Task/Db/ExecutePatch.php (rev 0)
+++ trunk/library/classes/Gems/Task/Db/ExecutePatch.php 2012-03-01 13:22:33 UTC (rev 526)
@@ -0,0 +1,92 @@
+<?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.
+ *
+ * @package Gems
+ * @subpackage Task_Db
+ * @copyright Copyright (c) 2011 Erasmus MC
+ * @license New BSD License
+ * @version $Id: CheckTokenCompletion.php 502 2012-02-20 14:13:20Z mennodekker $
+ */
+
+/**
+ * Execute a certain patchlevel
+ *
+ * Cleans the cache when patches where executed
+ *
+ * @package Gems
+ * @subpackage Task_Db
+ * @copyright Copyright (c) 2011 Erasmus MC
+ * @license New BSD License
+ * @since Class available since version 1.6
+ */
+class Gems_Task_Db_ExecutePatch extends Gems_Task_TaskAbstract
+{
+ /**
+ * @var Zend_Db_Adapter_Abstract
+ */
+ public $db;
+
+ /**
+ * @var GemsEscort
+ */
+ public $escort;
+
+ /**
+ *
+ * @var Gems_Util_DatabasePatcher
+ */
+ public $patcher;
+
+ public function execute($patchLevel = null, $ignoreCompleted = true, $ignoreExecuted = false)
+ {
+ $this->_batch->addMessage(sprintf($this->translate->_('Executing patchlevel %d'), $patchLevel));
+ $result = $this->patcher->executePatch($patchLevel, $ignoreCompleted, $ignoreExecuted);
+ $this->_batch->addMessage(sprintf($this->translate->_('%d patch(es) executed.'), $result));
+
+ if ($result>0) {
+ //Perform a clean cache only when needed
+ $this->_batch->setTask('CleanCache', 'cleancache'); //If already scheduled, don't reschedule
+ }
+ }
+
+ /**
+ * Now we have the requests answered, add the DatabasePatcher as it needs the db object
+ *
+ * @return boolean
+ */
+ public function checkRegistryRequestsAnswers() {
+ $this->escort = GemsEscort::getInstance();
+
+ //As an upgrade almost always includes executing db patches, make a DatabasePatcher object available
+ $this->patcher = new Gems_Util_DatabasePatcher($this->db, 'patches.sql', $this->escort->getDatabasePaths());
+
+ //Now load all patches, and save the resulting changed patches for later (not used yet)
+ $changed = $this->patcher->uploadPatches($this->loader->getVersions()->getBuild());
+
+ return true;
+ }
+}
\ No newline at end of file
Deleted: trunk/library/classes/Gems/Task/ExecutePatch.php
===================================================================
--- trunk/library/classes/Gems/Task/ExecutePatch.php 2012-03-01 12:08:30 UTC (rev 525)
+++ trunk/library/classes/Gems/Task/ExecutePatch.php 2012-03-01 13:22:33 UTC (rev 526)
@@ -1,92 +0,0 @@
-<?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.
- *
- * @package Gems
- * @subpackage Task
- * @copyright Copyright (c) 2011 Erasmus MC
- * @license New BSD License
- * @version $Id: CheckTokenCompletion.php 502 2012-02-20 14:13:20Z mennodekker $
- */
-
-/**
- * Execute a certain patchlevel
- *
- * Cleans the cache when patches where executed
- *
- * @package Gems
- * @subpackage Task
- * @copyright Copyright (c) 2011 Erasmus MC
- * @license New BSD License
- * @since Class available since version 1.6
- */
-class Gems_Task_ExecutePatch extends Gems_Task_TaskAbstract
-{
- /**
- * @var Zend_Db_Adapter_Abstract
- */
- public $db;
-
- /**
- * @var GemsEscort
- */
- public $escort;
-
- /**
- *
- * @var Gems_Util_DatabasePatcher
- */
- public $patcher;
-
- public function execute($patchLevel = null, $ignoreCompleted = true, $ignoreExecuted = false)
- {
- $this->_batch->addMessage(sprintf($this->translate->_('Executing patchlevel %d'), $patchLevel));
- $result = $this->patcher->executePatch($patchLevel, $ignoreCompleted, $ignoreExecuted);
- $this->_batch->addMessage($this->translate->_(sprintf('%d patch(es) executed.', $result)));
-
- if ($result>0) {
- //Perform a clean cache only when needed
- $this->_batch->setTask('CleanCache', 'cleancache'); //If already scheduled, don't reschedule
- }
- }
-
- /**
- * Now we have the requests answered, add the DatabasePatcher as it needs the db object
- *
- * @return boolean
- */
- public function checkRegistryRequestsAnswers() {
- $this->escort = GemsEscort::getInstance();
-
- //As an upgrade almost always includes executing db patches, make a DatabasePatcher object available
- $this->patcher = new Gems_Util_DatabasePatcher($this->db, 'patches.sql', $this->escort->getDatabasePaths());
-
- //Now load all patches, and save the resulting changed patches for later (not used yet)
- $changed = $this->patcher->uploadPatches($this->loader->getVersions()->getBuild());
-
- return true;
- }
-}
\ No newline at end of file
Deleted: trunk/library/classes/Gems/Task/ProcessTokenCompletion.php
===================================================================
--- trunk/library/classes/Gems/Task/ProcessTokenCompletion.php 2012-03-01 12:08:30 UTC (rev 525)
+++ trunk/library/classes/Gems/Task/ProcessTokenCompletion.php 2012-03-01 13:22:33 UTC (rev 526)
@@ -1,73 +0,0 @@
-<?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.
- *
- * @package Gems
- * @subpackage Task
- * @copyright Copyright (c) 2011 Erasmus MC
- * @license New BSD License
- * @version $Id$
- */
-
-/**
- * Handles completion of a token, mostly started by Gems_Task_CheckTokenCompletion
- *
- * @package Gems
- * @subpackage Task
- * @copyright Copyright (c) 2011 Erasmus MC
- * @license New BSD License
- * @since Class available since version 1.6
- */
-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
Deleted: trunk/library/classes/Gems/Task/SourceSyncSurveys.php
===================================================================
--- trunk/library/classes/Gems/Task/SourceSyncSurveys.php 2012-03-01 12:08:30 UTC (rev 525)
+++ trunk/library/classes/Gems/Task/SourceSyncSurveys.php 2012-03-01 13:22:33 UTC (rev 526)
@@ -1,56 +0,0 @@
-<?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.
- *
- * @package Gems
- * @subpackage Task
- * @copyright Copyright (c) 2011 Erasmus MC
- * @license New BSD License
- * @version $Id: Sample.php 215 2011-07-12 08:52:54Z michiel $
- */
-
-/**
- * Executes the syncSurveys method for a given sourceId
- *
- * @package Gems
- * @subpackage Task
- * @copyright Copyright (c) 2011 Erasmus MC
- * @license New BSD License
- * @since Class available since version 1.6
- */
-class Gems_Task_SourceSyncSurveys extends Gems_Task_TaskAbstract
-{
- public function execute($id = null)
- {
- $source = $this->loader->getTracker()->getSource($id);
-
- if ($messages = $source->synchronizeSurveys($this->loader->getCurrentUser()->getUserId())) {
- foreach ($messages as $message) {
- $this->_batch->addMessage($message);
- }
- }
- }
-}
\ No newline at end of file
Added: trunk/library/classes/Gems/Task/Tracker/CheckTokenCompletion.php
===================================================================
--- trunk/library/classes/Gems/Task/Tracker/CheckTokenCompletion.php (rev 0)
+++ trunk/library/classes/Gems/Task/Tracker/CheckTokenCompletion.php 2012-03-01 13:22:33 UTC (rev 526)
@@ -0,0 +1,83 @@
+<?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.
+ *
+ * @package Gems
+ * @subpackage TaskTracker
+ * @copyright Copyright (c) 2011 Erasmus MC
+ * @license New BSD License
+ * @version $Id: CheckTokenCompletion.php 502 2012-02-20 14:13:20Z mennodekker $
+ */
+
+/**
+ * Check token completion in a batch job
+ *
+ * This task handles the token completion check, adding tasks to the queue
+ * when needed.
+ *
+ * @package Gems
+ * @subpackage Task_Tracker
+ * @copyright Copyright (c) 2011 Erasmus MC
+ * @license New BSD License
+ * @since Class available since version 1.6
+ */
+class Gems_Task_Tracker_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('Tracker_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/Tracker/CheckTrackTokens.php
===================================================================
--- trunk/library/classes/Gems/Task/Tracker/CheckTrackTokens.php (rev 0)
+++ trunk/library/classes/Gems/Task/Tracker/CheckTrackTokens.php 2012-03-01 13:22:33 UTC (rev 526)
@@ -0,0 +1,69 @@
+<?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.
+ *
+ * @package Gems
+ * @subpackage Task_Tracker
+ * @copyright Copyright (c) 2011 Erasmus MC
+ * @license New BSD License
+ * @version $Id: CheckTrackTokens.php 502 2012-02-20 14:13:20Z mennodekker $
+ */
+
+/**
+ * Checks a respondentTrack for changes, mostly started by Gems_Task_ProcessTokenCompletion
+ *
+ * @package Gems
+ * @subpackage Task_Tracker
+ * @copyright Copyright (c) 2011 Erasmus MC
+ * @license New BSD License
+ * @since Class available since version 1.6
+ */
+class Gems_Task_Tracker_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/Tracker/ProcessTokenCompletion.php
===================================================================
--- trunk/library/classes/Gems/Task/Tracker/ProcessTokenCompletion.php (rev 0)
+++ trunk/library/classes/Gems/Task/Tracker/ProcessTokenCompletion.php 2012-03-01 13:22:33 UTC (rev 526)
@@ -0,0 +1,73 @@
+<?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.
+ *
+ * @package Gems
+ * @subpackage Task_Tracker
+ * @copyright Copyright (c) 2011 Erasmus MC
+ * @license New BSD License
+ * @version $Id: ProcessTokenCompletion.php 502 2012-02-20 14:13:20Z mennodekker $
+ */
+
+/**
+ * Handles completion of a token, mostly started by Gems_Task_CheckTokenCompletion
+ *
+ * @package Gems
+ * @subpackage Task_Tracker
+ * @copyright Copyright (c) 2011 Erasmus MC
+ * @license New BSD License
+ * @since Class available since version 1.6
+ */
+class Gems_Task_Tracker_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('Tracker_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/Tracker/SourceSyncSurveys.php
===================================================================
--- trunk/library/classes/Gems/Task/Tracker/SourceSyncSurveys.php (rev 0)
+++ trunk/library/classes/Gems/Task/Tracker/SourceSyncSurveys.php 2012-03-01 13:22:33 UTC (rev 526)
@@ -0,0 +1,60 @@
+<?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.
+ *
+ * @package Gems
+ * @subpackage Task_Tracker
+ * @copyright Copyright (c) 2011 Erasmus MC
+ * @license New BSD License
+ * @version $Id: Sample.php 215 2011-07-12 08:52:54Z michiel $
+ */
+
+/**
+ * Executes the syncSurveys method for a given sourceId
+ *
+ * @package Gems
+ * @subpackage Task_Tracker
+ * @copyright Copyright (c) 2011 Erasmus MC
+ * @license New BSD License
+ * @since Class available since version 1.6
+ */
+class Gems_Task_Tracker_SourceSyncSurveys extends Gems_Task_TaskAbstract
+{
+ public function execute($id = null, $userId = null)
+ {
+ $source = $this->loader->getTracker()->getSource($id);
+
+ if (is_null($userId)) {
+ $userId = $this->loader->getCurrentUser()->getUserId();
+ }
+
+ if ($messages = $source->synchronizeSurveys($userId)) {
+ foreach ($messages as $message) {
+ $this->_batch->addMessage($message);
+ }
+ }
+ }
+}
\ No newline at end of file
Deleted: trunk/library/classes/Gems/Tracker/Batch/ProcessTokensBatch.php
===================================================================
--- trunk/library/classes/Gems/Tracker/Batch/ProcessTokensBatch.php 2012-03-01 12:08:30 UTC (rev 525)
+++ trunk/library/classes/Gems/Tracker/Batch/ProcessTokensBatch.php 2012-03-01 13:22:33 UTC (rev 526)
@@ -1,248 +0,0 @@
-<?php
-
-/**
- * Copyright (c) 2012, 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 <COPYRIGHT HOLDER> 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.
- *
- *
- * @package Gems
- * @subpackage Tracker
- * @author Matijs de Jong <mj...@ma...>
- * @copyright Copyright (c) 2012 Erasmus MC
- * @license New BSD License
- * @version $Id$
- */
-
-/**
- *
- *
- * @package Gems
- * @subpackage Tracker
- * @copyright Copyright (c) 2012 Erasmus MC
- * @license New BSD License
- * @since Class available since version 1.5
- */
-class Gems_Tracker_Batch_ProcessTokensBatch extends MUtil_Batch_BatchAbstract
-{
- /**
- *
- * @var Gems_Tracker
- */
- protected $tracker;
-
- /**
- *
- * @var Zend_Translate
- */
- protected $translate;
-
- /**
- * Set a little higher, to reduce the effect of the server response time and application startup
- */
- public $minimalStepDurationMs = 3000;
-
- /**
- * Add the check of a single token to the batch.
- *
- * @param mixed $tokenData Array or token id
- * @param int $userId Gems user id
- * @return Gems_Tracker_Batch_ProcessTokensBatch (Continuation pattern)
- */
- public function addToken($tokenData, $userId)
- {
- if (is_array($tokenData)) {
- if (!isset($tokenData['gto_id_token'])) {
- throw new Gems_Exception_Coding('$tokenData array should atleast have a key "gto_id_token" containing the requested token');
- }
- $tokenId = $tokenData['gto_id_token'];
- } else {
- $tokenId = $tokenData;
- }
-
- // MUtil_Echo::track($tokenData);
- $this->setStep('checkTokenCompletion', 'tokchk-' . $tokenId, $tokenId, $userId);
- $this->addToCounter('tokens');
-
- return $this;
- }
-
- /**
- * Check a single track for the effects of token completion.
- *
- * @param mixed $respTrackData Data array or a respondent track id
- * @param int $userId Gems user id
- */
- protected function checkTrackTokens($respTrackData, $userId)
- {
- $respTrack = $this->tracker->getRespondentTrack($respTrackData);
-
- if ($result = $respTrack->checkTrackTokens($userId)) {
- $this->addToCounter('tokenDateCauses');
- $this->addToCounter('tokenDateChanges', $result);
- }
- }
-
- /**
- * Check for token completion and adds the processTokenCompletion
- * command when the token is indeed completed.
- *
- * NOTE: The reasons to add the extra commands in this process are
- * (1) that we are not sure in advance for which tokens we should
- * process and (2) the processing commands should be executed
- * AFTER all tokens have been checked for completion.
- *
- * @param mixed $tokenData Array or token id
- * @param int $userId Gems user id
- */
- protected function checkTokenCompletion($tokenData, $userId)
- {
- $this->addToCounter('checkedTokens');
- $token = $this->tracker->getToken($tokenData);
-
- if ($result = $token->checkTokenCompletion($userId)) {
- if ($result & Gems_Tracker_Token::COMPLETION_DATACHANGE) {
- $this->addToCounter('resultDataChanges');
- }
- if ($result & Gems_Tracker_Token::COMPLETION_EVENTCHANGE) {
- $this->addToCounter('surveyCompletionChanges');
- }
- }
-
- if ($token->isCompleted()) {
- $this->setStep('processTokenCompletion', 'tokproc-' . $token->getTokenId(), $tokenData, $userId);
- }
- }
-
- /**
- * Returns a description of what was changed during this batch.
- *
- * @return array Of message strings
- */
- public function getCounterMessages()
- {
- if ($this->getCounter('checkedRespondentTracks')) {
- $messages[] = sprintf($this->translate->_('Checked %d tracks.'), $this->getCounter('checkedRespondentTracks'));
- }
- if ($this->getCounter('checkedTokens') || (! $this->getCounter('checkedRespondentTracks'))) {
- $messages[] = sprintf($this->translate->_('Checked %d tokens.'), $this->getCounter('checkedTokens'));
- }
-
- if ($this->hasChanged()) {
- if ($this->getCounter('surveyCompletionChanges')) {
- $messages[] = sprintf($this->translate->_('Answers changed by survey completion event for %d tokens.'), $this->getCounter('surveyCompletionChanges'));
- }
- if ($this->getCounter('resultDataChanges')) {
- $messages[] = sprintf($this->translate->_('Results and timing changed for %d tokens.'), $this->getCounter('resultDataChanges'));
- }
- if ($this->getCounter('roundCompletionChanges')) {
- $messages[] = sprintf($this->translate->_('%d token round completion events caused changed to %d tokens.'), $this->getCounter('roundCompletionCauses'), $this->getCounter('roundCompletionChanges'));
- }
- if ($this->getCounter('tokenDateChanges')) {
- $messages[] = sprintf($this->translate->_('%2$d token date changes in %1$d tracks.'), $this->getCounter('tokenDateCauses'), $this->getCounter('tokenDateChanges'));
- }
- if ($this->getCounter('roundChangeUpdates')) {
- $messages[] = sprintf($this->translate->_('Round changes propagated to %d tokens.'), $this->getCounter('roundChangeUpdates'));
- }
- if ($this->getCounter('deletedTokens')) {
- $messages[] = sprintf($this->translate->_('%d tokens deleted by round changes.'), $this->getCounter('deletedTokens'));
- }
- if ($this->getCounter('createdTokens')) {
- $messages[] = sprintf($this->translate->_('%d tokens created to by round changes.'), $this->getCounter('createdTokens'));
- }
- } else {
- $messages[] = $this->translate->_('No tokens were changed.');
- }
-
- return $messages;
- }
-
- /**
- * String of messages from the batch
- *
- * Do not forget to reset() the batch if you're done with it after
- * displaying the report.
- *
- * @param boolean $reset When true the batch is reset afterwards
- * @return array
- */
- public function getMessages($reset = false)
- {
- return array_merge($this->getCounterMessages(), parent::getMessages($reset));
- }
-
- /**
- * The number of tokens to check
- *
- * @return int
- */
- public function getTokenCount()
- {
- return $this->getCounter('tokens');
- }
-
- /**
- * True when the batch changed anything.
- *
- * @return boolean
- */
- public function hasChanged()
- {
- return $this->getCounter('resultDataChanges') ||
- $this->getCounter('surveyCompletionChanges') ||
- $this->getCounter('roundCompletionChanges') ||
- $this->getCounter('tokenDateCauses') ||
- $this->getCounter('roundChangeUpdates') ||
- $this->getCounter('createdTokens');
- }
-
- /**
- * Processes token completion and adds the checkTrackTokens
- * command when the token is indeed completed.
- *
- * NOTE: The reasons we add the checkTrackTokens command are
- * that (1) we do not know in advance which tracks to check
- * and (2) the tracks should be checked AFTER all tokens have
- * been processed.
- *
- * @param mixed $tokenData Array or token id
- * @param int $userId Gems user id
- */
- protected function processTokenCompletion($tokenData, $userId)
- {
- $token = $this->tracker->getToken($tokenData);
-
- if ($token->isCompleted()) {
- $respTrack = $token->getRespondentTrack();
-
- if ($result = $respTrack->handleRoundCompletion($token, $userId)) {
- $this->addToCounter('roundCompletionCauses');
- $this->addToCounter('roundCompletionChanges', $result);
- }
-
- $trackId = $respTrack->getRespondentTrackId();
- $this->setStep('checkTrackTokens', 'chktrck-' . $trackId, $trackId, $userId);
- }
- }
-}
Modified: trunk/library/classes/Gems/Tracker/TrackerInterface.php
===================================================================
--- trunk/library/classes/Gems/Tracker/TrackerInterface.php 2012-03-01 12:08:30 UTC (rev 525)
+++ trunk/library/classes/Gems/Tracker/TrackerInterface.php 2012-03-01 13:22:33 UTC (rev 526)
@@ -298,7 +298,7 @@
* @param string $batch_id A unique identifier for the current batch
* @param int $userId Id of the user who takes the action (for logging)
* @param string $cond
- * @return Gems_Tracker_Batch_ProcessTokensBatch A batch to process the changes
+ * @return Gems_Task_TaskRunnerBatch A batch to process the changes
*/
public function recalculateTokensBatch($batch_id, $userId = null, $cond = null);
@@ -307,7 +307,7 @@
*
* @param string $batch_id A unique identifier for the current batch
* @param string $cond An optional where statement
- * @return Gems_Tracker_Batch_ProcessTokensBatch A batch to process the changes
+ * @return Gems_Task_TaskRunnerBatch A batch to process the changes
*/
public function refreshTokenAttributesBatch($batch_id, $cond = null);
}
Modified: trunk/library/classes/Gems/Tracker.php
===================================================================
--- trunk/library/classes/Gems/Tracker.php 2012-03-01 12:08:30 UTC (rev 525)
+++ trunk/library/classes/Gems/Tracker.php 2012-03-01 13:22:33 UTC (rev 526)
@@ -856,7 +856,7 @@
//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->setTask('Tracker_CheckTokenCompletion', 'tokchk-' . $tokenId, $tokenId, $userId);
$batch->addToCounter('tokens');
}
}
@@ -933,7 +933,7 @@
*
* @param string $batch_id A unique identifier for the current batch
* @param string $cond An optional where statement
- * @return Gems_Tracker_Batch_ProcessTokensBatch A batch to process the changes
+ * @return Gems_Tracker_Batch_RefreshTokenAttributesBatch A batch to process the changes
*/
public function refreshTokenAttributesBatch($batch_id, $cond = null)
{
Modified: trunk/library/classes/Gems/Upgrades.php
===================================================================
--- trunk/library/classes/Gems/Upgrades.php 2012-03-01 12:08:30 UTC (rev 525)
+++ trunk/library/classes/Gems/Upgrades.php 2012-03-01 13:22:33 UTC (rev 526)
@@ -67,20 +67,19 @@
*/
public function Upgrade143to15()
{
- $this->_batch->addTask('ExecutePatch', 42);
- $this->_batch->addTask('ExecutePatch', 43);
+ $this->_batch->addTask('Db_ExecutePatch', 42);
+ $this->_batch->addTask('Db_ExecutePatch', 43);
$this->_batch->addTask('Db_CreateNewTables');
$this->_batch->addTask('Echo', $this->_('Syncing surveys for all sources'));
-
//Now sync the db sources to allow limesurvey source to add a field to the tokentable
$model = new MUtil_Model_TableModel('gems__sources');
$data = $model->load(false);
foreach ($data as $row) {
- $this->_batch->addTask('SourceSyncSurveys', $row['gso_id_source']);
+ $this->_batch->addTask('Tracker_SourceSyncSurveys', $row['gso_id_source']);
}
return true;
@@ -91,7 +90,7 @@
*/
public function Upgrade15to151()
{
- $this->_batch->addTask('ExecutePatch', 44);
+ $this->_batch->addTask('Db_ExecutePatch', 44);
return true;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|