From: <gem...@li...> - 2012-02-29 15:44:14
|
Revision: 519 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=519&view=rev Author: mennodekker Date: 2012-02-29 15:44:03 +0000 (Wed, 29 Feb 2012) Log Message: ----------- CreateNewTables split into smaller tasks and a little cleanup on messages Modified Paths: -------------- trunk/library/classes/Gems/Default/UpgradeAction.php trunk/library/classes/Gems/Task/CreateNewTables.php trunk/library/classes/Gems/Task/ExecutePatch.php Added Paths: ----------- trunk/library/classes/Gems/Task/CreateNewTable.php Modified: trunk/library/classes/Gems/Default/UpgradeAction.php =================================================================== --- trunk/library/classes/Gems/Default/UpgradeAction.php 2012-02-29 15:17:37 UTC (rev 518) +++ trunk/library/classes/Gems/Default/UpgradeAction.php 2012-02-29 15:44:03 UTC (rev 519) @@ -82,17 +82,15 @@ $from = $this->getRequest()->getParam('from'); $to = $this->getRequest()->getParam('to'); - $this->html->h3(sprintf($this->_('Upgrading %s'), $context)); - $batch = $this->loader->getTaskRunnerBatch('upgrade' . $context); - $batch->minimalStepDurationMs = 0; + $batch->minimalStepDurationMs = 0; //One step at a time, can be higher to improve speed if (!$batch->isLoaded()) { $this->_upgrades->setBatch($batch); $this->_upgrades->execute($context, $to, $from); } - $title = $this->_('Performing upgrade'); + $title = sprintf($this->_('Upgrading %s'), $context); $this->_helper->BatchRunner($batch, $title); } Added: trunk/library/classes/Gems/Task/CreateNewTable.php =================================================================== --- trunk/library/classes/Gems/Task/CreateNewTable.php (rev 0) +++ trunk/library/classes/Gems/Task/CreateNewTable.php 2012-02-29 15:44:03 UTC (rev 519) @@ -0,0 +1,104 @@ +<?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 $ + */ + +/** + * Create a single new table + * + * Cleans the cache when a new tables was created + * + * @package Gems + * @subpackage Task + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.6 + */ +class Gems_Task_CreateNewTable extends Gems_Task_TaskAbstract +{ + /** + * @var Zend_Db_Adapter_Abstract + */ + public $db; + + /** + * @var Gems_Model_DbaModel + */ + public $dbaModel; + + /** + * @var GemsEscort + */ + public $escort; + + /** + * @var Gems_Project_ProjectSettings + */ + public $project; + + public function execute($tableData = array()) + { + $this->_batch->addToCounter('createTableStep'); + + $result = $this->dbaModel->runScript($tableData); + $result[] = sprintf($this->translate->_('Finished %s creation script for object %d of %d'), $this->translate->_(strtolower($tableData['type'])), $this->_batch->getCounter('createTableStep'), $this->_batch->getCounter('NewTableCount')) . '<br/>'; + + if (count($result)>0) { + foreach ($result as $result) + { + $this->_batch->addMessage($result); + } + //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(); + + //Load the dbaModel + $paths = $this->escort->getDatabasePaths(); + $model = new Gems_Model_DbaModel($this->db, array_values($paths)); + $model->setLocations(array_keys($paths)); + if ($this->project->databaseFileEncoding) { + $model->setFileEncoding($this->project->databaseFileEncoding); + } + $this->dbaModel = $model; + + return true; + } +} \ No newline at end of file Modified: trunk/library/classes/Gems/Task/CreateNewTables.php =================================================================== --- trunk/library/classes/Gems/Task/CreateNewTables.php 2012-02-29 15:17:37 UTC (rev 518) +++ trunk/library/classes/Gems/Task/CreateNewTables.php 2012-02-29 15:44:03 UTC (rev 519) @@ -33,10 +33,8 @@ */ /** - * Execute a certain patchlevel + * Schedules creation of new tables * - * Cleans the cache when patches where executed - * * @package Gems * @subpackage Task * @copyright Copyright (c) 2011 Erasmus MC @@ -69,25 +67,11 @@ { //Now create all new tables $todo = $this->dbaModel->load(array('state'=> Gems_Model_DbaModel::STATE_DEFINED)); - $i = 1; - $oCount = count($todo); - $results = array(); + foreach($todo as $tableData) { - $result = $this->dbaModel->runScript($tableData); - $results = array_merge($results, $result); - $results[] = sprintf($this->translate->_('Finished %s creation script for object %d of %d'), $this->translate->_(strtolower($tableData['type'])), $i, $oCount) . '<br/>'; - $i++; + $this->_batch->addToCounter('NewTableCount'); + $this->_batch->setTask('CreateNewTable', 'create-tbl-' . $tableData['name'], $tableData); } - - foreach ($results as $result) - { - $this->_batch->addMessage($result); - } - - if (count($results)>0) { - //Perform a clean cache only when needed - $this->_batch->setTask('CleanCache', 'cleancache'); //If already scheduled, don't reschedule - } } /** Modified: trunk/library/classes/Gems/Task/ExecutePatch.php =================================================================== --- trunk/library/classes/Gems/Task/ExecutePatch.php 2012-02-29 15:17:37 UTC (rev 518) +++ trunk/library/classes/Gems/Task/ExecutePatch.php 2012-02-29 15:44:03 UTC (rev 519) @@ -65,7 +65,7 @@ { $this->_batch->addMessage(sprintf($this->translate->_('Executing patchlevel %d'), $patchLevel)); $result = $this->patcher->executePatch($patchLevel, $ignoreCompleted, $ignoreExecuted); - $this->_batch->addMessage($this->translate->_(sprintf('Executed %s patches', $result))); + $this->_batch->addMessage($this->translate->_(sprintf('%d patch(es) executed.', $result))); if ($result>0) { //Perform a clean cache only when needed This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |