+ add the converter of bugfree2.
This commit is contained in:
@@ -83,6 +83,7 @@ $lang->bug->severityList[2] = 2;
|
||||
$lang->bug->severityList[4] = 4;
|
||||
|
||||
/* Define the OS list. */
|
||||
$lang->bug->osList[''] = '';
|
||||
$lang->bug->osList['all'] = '全部';
|
||||
$lang->bug->osList['winxp'] = 'Windows XP';
|
||||
$lang->bug->osList['win7'] = 'Windows 7';
|
||||
@@ -95,6 +96,7 @@ $lang->bug->osList['unix'] = 'Unix';
|
||||
$lang->bug->osList['others'] = '其他';
|
||||
|
||||
/* Define the OS list. */
|
||||
$lang->bug->browserList[''] = '';
|
||||
$lang->bug->browserList['all'] = '全部';
|
||||
$lang->bug->browserList['ie6'] = 'IE6';
|
||||
$lang->bug->browserList['ie7'] = 'IE7';
|
||||
@@ -112,6 +114,15 @@ $lang->bug->typeList[''] = '';
|
||||
$lang->bug->typeList['codeerror'] = '代码错误';
|
||||
$lang->bug->typeList['interface'] = '界面优化';
|
||||
$lang->bug->typeList['designchange'] = '设计变更';
|
||||
$lang->bug->typeList['newfeature'] = '新增需求';
|
||||
$lang->bug->typeList['designdefect'] = '设计缺陷';
|
||||
$lang->bug->typeList['config'] = '配置相关';
|
||||
$lang->bug->typeList['install'] = '安装部署';
|
||||
$lang->bug->typeList['security'] = '安全相关';
|
||||
$lang->bug->typeList['performance'] = '性能问题';
|
||||
$lang->bug->typeList['standard'] = '标准规范';
|
||||
$lang->bug->typeList['automation'] = '测试脚本';
|
||||
$lang->bug->typeList['trackthings'] = '事务跟踪';
|
||||
$lang->bug->typeList['Others'] = '其他';
|
||||
|
||||
$lang->bug->statusList[''] = '';
|
||||
|
||||
@@ -60,8 +60,8 @@ class convert extends control
|
||||
{
|
||||
$this->view->source = 'BugFree';
|
||||
$this->view->version = $version;
|
||||
$this->view->tablePrefix = $version > 1 ? 'bf' : '';
|
||||
$this->view->dbName = 'BugFree';
|
||||
$this->view->tablePrefix = $version > 1 ? 'bf_' : '';
|
||||
$this->view->dbName = $version > 1 ? 'bugfree2' : 'BugFree';
|
||||
$this->display();
|
||||
}
|
||||
|
||||
@@ -104,6 +104,7 @@ class convert extends control
|
||||
$convertFunc = 'convert' . $this->post->source;
|
||||
$this->view->header->title = $this->lang->convert->execute;
|
||||
$this->view->source = $this->post->source;
|
||||
$this->view->version = $this->post->version;
|
||||
$this->view->executeResult = $this->fetch('convert', $convertFunc, "version={$this->post->version}");
|
||||
$this->display();
|
||||
}
|
||||
@@ -112,9 +113,12 @@ class convert extends control
|
||||
public function convertBugFree($version)
|
||||
{
|
||||
helper::import('./converter/bugfree.php');
|
||||
$converter = new bugfreeConvertModel();
|
||||
$this->view->result = $converter->execute();
|
||||
$this->view->info = bugfreeConvertModel::$info;
|
||||
helper::import("./converter/bugfree$version.php");
|
||||
$className = "bugfree{$version}ConvertModel";
|
||||
$converter = new $className();
|
||||
$this->view->version = $version;
|
||||
$this->view->result = $converter->execute($version);
|
||||
$this->view->info = bugfreeConvertModel::$info;
|
||||
$this->display();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* The model file of bugfree convert of ZenTaoMS.
|
||||
* The baisc model file of bugfree convert of ZenTaoMS.
|
||||
*
|
||||
* ZenTaoMS is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
@@ -26,6 +26,8 @@ class bugfreeConvertModel extends convertModel
|
||||
public $map = array();
|
||||
public $filePath = '';
|
||||
static public $info = array();
|
||||
|
||||
/* <20><><EFBFBD>캯<EFBFBD><ECBAAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD>ݿ⡣*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
@@ -52,238 +54,8 @@ class bugfreeConvertModel extends convertModel
|
||||
}
|
||||
|
||||
/* ִ<><D6B4>ת<EFBFBD><D7AA><EFBFBD><EFBFBD>*/
|
||||
public function execute()
|
||||
public function execute($version)
|
||||
{
|
||||
$this->clear();
|
||||
$result['users'] = $this->convertUser();
|
||||
$result['projects'] = $this->convertProject();
|
||||
$result['modules'] = $this->convertModule();
|
||||
$result['bugs'] = $this->convertBug();
|
||||
$result['actions'] = $this->convertAction();
|
||||
$result['files'] = $this->convertFile();
|
||||
$this->loadModel('tree')->fixModulePath();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/* ת<><D7AA><EFBFBD>û<EFBFBD><C3BB><EFBFBD>*/
|
||||
public function convertUser()
|
||||
{
|
||||
/* <20><>ѯ<EFBFBD><D1AF>ǰϵͳ<CFB5>д<EFBFBD><D0B4>ڵ<EFBFBD><DAB5>û<EFBFBD><C3BB><EFBFBD>*/
|
||||
$activeUsers = $this->dao
|
||||
->dbh($this->sourceDBH)
|
||||
->select("{$this->app->company->id} AS company, username AS account, userpassword AS password, realname, email")
|
||||
->from('BugUser')
|
||||
->orderBy('userID ASC')
|
||||
->fetchAll('account');
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>*/
|
||||
$allUsers = $this->dao->select("distinct(username) AS account")->from('BugHistory')->fetchPairs();
|
||||
|
||||
/* <20>ϲ<EFBFBD><CFB2><EFBFBD><EFBFBD>ߡ<EFBFBD>*/
|
||||
foreach($allUsers as $key => $account)
|
||||
{
|
||||
if(isset($activeUsers[$account]))
|
||||
{
|
||||
$allUsers[$key] = $activeUsers[$account];
|
||||
}
|
||||
else
|
||||
{
|
||||
$allUsers[$key] = array('company' => $this->app->company->id, 'account' => $account, 'realname' => $account, 'status' => 'delete');
|
||||
}
|
||||
}
|
||||
foreach($activeUsers as $account => $user) if(!isset($allUsers[$account])) $allUsers[$account] = $user;
|
||||
|
||||
/* <20><><EFBFBD>뵽zentao<61><6F><EFBFBD>ݿ<EFBFBD><DDBF>С<EFBFBD>*/
|
||||
$convertCount = 0;
|
||||
foreach($allUsers as $account => $user)
|
||||
{
|
||||
if(!$this->dao->dbh($this->dbh)->findByAccount($account)->from(TABLE_USER)->fetch('account'))
|
||||
{
|
||||
$this->dao->dbh($this->dbh)->insert(TABLE_USER)->data($user)->exec();
|
||||
$convertCount ++;
|
||||
}
|
||||
else
|
||||
{
|
||||
self::$info['users'][] = sprintf($this->lang->convert->errorUserExists, $account);
|
||||
}
|
||||
}
|
||||
return $convertCount;
|
||||
}
|
||||
|
||||
/* ת<><D7AA><EFBFBD><EFBFBD>ĿΪ<C4BF><CEAA>Ʒ<EFBFBD><C6B7>*/
|
||||
public function convertProject()
|
||||
{
|
||||
$projects = $this->dao->dbh($this->sourceDBH)->select("projectID AS id, projectName AS name, {$this->app->company->id} AS company")->from('BugProject')->fetchAll('id');
|
||||
foreach($projects as $projectID => $project)
|
||||
{
|
||||
unset($project->id);
|
||||
$this->dao->dbh($this->dbh)->insert(TABLE_PRODUCT)->data($project)->exec();
|
||||
$this->map['product'][$projectID] = $this->dao->lastInsertID();
|
||||
}
|
||||
return count($projects);
|
||||
}
|
||||
|
||||
/* ת<><D7AA>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3>ΪBug<75><67>ͼģ<CDBC>顣*/
|
||||
public function convertModule()
|
||||
{
|
||||
$this->map['module'][0] = 0;
|
||||
$modules = $this->dao
|
||||
->dbh($this->sourceDBH)
|
||||
->select(
|
||||
'moduleID AS id,
|
||||
projectID AS product,
|
||||
moduleName AS name,
|
||||
moduleGrade AS grade,
|
||||
parentID AS parent,
|
||||
"bug" AS view')
|
||||
->from('BugModule')
|
||||
->orderBy('id ASC')
|
||||
->fetchAll('id');
|
||||
foreach($modules as $moduleID => $module)
|
||||
{
|
||||
$module->product = $this->map['product'][$module->product];
|
||||
unset($module->id);
|
||||
$this->dao->dbh($this->dbh)->insert(TABLE_MODULE)->data($module)->exec();
|
||||
$this->map['module'][$moduleID] = $this->dao->lastInsertID();
|
||||
}
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD>parent<6E><74>*/
|
||||
foreach($this->map['module'] as $oldModuleID => $newModuleID)
|
||||
{
|
||||
$this->dao->dbh($this->dbh)->update(TABLE_MODULE)->set('parent')->eq($newModuleID)->where('parent')->eq($oldModuleID)->exec();
|
||||
}
|
||||
return count($modules);
|
||||
}
|
||||
|
||||
/* ת<><D7AA>Bug<75><67>*/
|
||||
public function convertBug()
|
||||
{
|
||||
$bugs = $this->dao
|
||||
->dbh($this->sourceDBH)
|
||||
->select('
|
||||
bugID AS id,
|
||||
projectID AS product,
|
||||
moduleID AS module,
|
||||
bugTitle AS title,
|
||||
bugSeverity AS severity,
|
||||
bugType AS type,
|
||||
bugOS AS os,
|
||||
bugStatus AS status,
|
||||
mailto,
|
||||
openedBy, openedDate, openedBuild,
|
||||
assignedTo, assignedDate,
|
||||
resolvedBy, resolution, resolvedBuild, resolvedDate,
|
||||
closedBy, closedDate,
|
||||
lastEditedBy, lastEditedDate,
|
||||
linkID as duplicateBug
|
||||
')
|
||||
->from('BugInfo')
|
||||
->orderBy('bugID')
|
||||
->fetchAll('id');
|
||||
foreach($bugs as $bugID => $bug)
|
||||
{
|
||||
$bugID = (int)$bugID;
|
||||
unset($bug->id);
|
||||
if($bug->assignedTo == 'Closed') $bug->assignedTo = 'closed';
|
||||
$bug->type = strtolower($bug->type);
|
||||
$bug->os = strtolower($bug->os);
|
||||
$bug->browser = 'all';
|
||||
$bug->resolution = str_replace(' ','', strtolower($bug->resolution));
|
||||
$bug->product = $this->map['product'][$bug->product];
|
||||
$bug->module = $this->map['module'][$bug->module];
|
||||
$this->dao->dbh($this->dbh)->insert(TABLE_BUG)->data($bug)->exec();
|
||||
$this->map['bug'][$bugID] = $this->dao->lastInsertID();
|
||||
}
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD>duplicateBug<75><67> */
|
||||
foreach($this->map['bug'] as $oldBugID => $newBugID)
|
||||
{
|
||||
$this->dao->dbh($this->dbh)->update(TABLE_BUG)->set('duplicateBug')->eq($newBugID)->where('duplicateBug')->eq($oldBugID)->exec();
|
||||
}
|
||||
return count($bugs);
|
||||
}
|
||||
|
||||
/* ת<><D7AA><EFBFBD><EFBFBD>ʷ<EFBFBD><CAB7>¼<EFBFBD><C2BC>*/
|
||||
public function convertAction()
|
||||
{
|
||||
$actions = $this->dao
|
||||
->dbh($this->sourceDBH)
|
||||
->select(
|
||||
"{$this->app->company->id} AS company,
|
||||
'bug' AS objectType,
|
||||
bugID AS objectID,
|
||||
userName AS actor,
|
||||
action,
|
||||
fullInfo AS comment,
|
||||
actionDate AS date")
|
||||
->from('BugHistory')
|
||||
->orderBy('bugID, historyID')
|
||||
->fetchGroup('objectID');
|
||||
$convertCount = 0;
|
||||
foreach($actions as $bugID => $bugActions)
|
||||
{
|
||||
/* <20><><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>֮<EFBFBD><D6AE><EFBFBD><EFBFBD>bugID<49><44>*/
|
||||
$bugID = (int)$bugID;
|
||||
$zentaoBugID = $this->map['bug'][$bugID];
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD>action<6F><6E>*/
|
||||
foreach($bugActions as $key => $action)
|
||||
{
|
||||
$action->objectID = $zentaoBugID;
|
||||
if($key == 0)
|
||||
{
|
||||
$this->dao->dbh($this->dbh)->update(TABLE_BUG)->set('steps')->eq($action->comment)->where('id')->eq($zentaoBugID)->exec();
|
||||
$action->comment = '';
|
||||
}
|
||||
$this->dao->dbh($this->dbh)->insert(TABLE_ACTION)->data($action)->exec();
|
||||
$convertCount ++;
|
||||
}
|
||||
}
|
||||
return $convertCount;
|
||||
}
|
||||
|
||||
/* ת<><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
public function convertFile()
|
||||
{
|
||||
$this->setPath();
|
||||
$files = $this->dao->dbh($this->sourceDBH)
|
||||
->select(
|
||||
"{$this->app->company->id} AS company,
|
||||
fileName AS pathname,
|
||||
fileTitle AS title,
|
||||
fileType AS extension,
|
||||
fileSize AS size,
|
||||
'bug' AS objectType,
|
||||
bugID AS objectID,
|
||||
addUser AS addedBy,
|
||||
addDate AS addedDate
|
||||
")
|
||||
->from('BugFile')
|
||||
->orderBy('fileID')
|
||||
->fetchAll();
|
||||
foreach($files as $file)
|
||||
{
|
||||
$file->objectID = $this->map['bug'][(int)$file->objectID];
|
||||
if(strpos($file->size, 'KB')) $file->size = (int)(str_replace('KB', '', $file->size) * 1024);
|
||||
if(strpos($file->size, 'MB')) $file->size = (int)(str_replace('MB', '', $file->size) * 1024 * 1024);
|
||||
$this->dao->dbh($this->dbh)->insert(TABLE_FILE)->data($file)->exec();
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>*/
|
||||
$soureFile = $this->filePath . $file->pathname;
|
||||
if(!file_exists($soureFile))
|
||||
{
|
||||
self::$info['files'][] = sprintf($this->lang->convert->errorFileNotExits, $soureFile);
|
||||
continue;
|
||||
}
|
||||
$targetFile = $this->app->getAppRoot() . "www/data/upload/{$this->app->company->id}/" . $file->pathname;
|
||||
$targetPath = dirname($targetFile);
|
||||
if(!is_dir($targetPath)) mkdir($targetPath, 0777, true);
|
||||
if(!copy($soureFile, $targetFile))
|
||||
{
|
||||
self::$info['files'][] = sprintf($this->lang->convert->errorCopyFailed, $targetFile);
|
||||
}
|
||||
}
|
||||
return count($files);
|
||||
}
|
||||
|
||||
/* <20><><EFBFBD>յ<EFBFBD><D5B5><EFBFBD>֮<EFBFBD><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݡ<EFBFBD>*/
|
||||
|
||||
289
trunk/module/convert/converter/bugfree1.php
Normal file
289
trunk/module/convert/converter/bugfree1.php
Normal file
@@ -0,0 +1,289 @@
|
||||
<?php
|
||||
/**
|
||||
* The model file of bugfree version 1 convert of ZenTaoMS.
|
||||
*
|
||||
* ZenTaoMS is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* ZenTaoMS is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with ZenTaoMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @copyright Copyright 2009-2010 Chunsheng Wang
|
||||
* @author Chunsheng Wang <wwccss@263.net>
|
||||
* @package convert
|
||||
* @version $Id$
|
||||
* @link http://www.zentao.cn
|
||||
*/
|
||||
class bugfree1ConvertModel extends bugfreeConvertModel
|
||||
{
|
||||
/* ִ<><D6B4>ת<EFBFBD><D7AA><EFBFBD><EFBFBD>*/
|
||||
public function execute()
|
||||
{
|
||||
$this->clear();
|
||||
$this->convertGroup();
|
||||
$result['users'] = $this->convertUser();
|
||||
$result['projects'] = $this->convertProject();
|
||||
$result['modules'] = $this->convertModule();
|
||||
$result['bugs'] = $this->convertBug();
|
||||
$result['actions'] = $this->convertAction();
|
||||
$result['files'] = $this->convertFile();
|
||||
$this->loadModel('tree')->fixModulePath();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/* ת<><D7AA><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD>顣*/
|
||||
public function convertGroup()
|
||||
{
|
||||
$groups = $this->dao->dbh($this->sourceDBH)
|
||||
->select("{$this->app->company->id} AS company, groupID AS id, groupName AS name, groupUser AS users")
|
||||
->from('BugGroup')
|
||||
->fetchAll('id');
|
||||
foreach($groups as $groupID => $group)
|
||||
{
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD>ֳ<EFBFBD><D6B3><EFBFBD><EFBFBD>顣*/
|
||||
$groupUsers = explode(',', $group->users);
|
||||
unset($group->id);
|
||||
unset($group->users);
|
||||
|
||||
/* <20><><EFBFBD>뵽group<75><70><EFBFBD>С<EFBFBD>*/
|
||||
$this->dao->dbh($this->dbh)->insert(TABLE_GROUP)->data($group)->exec();
|
||||
$zentaoGroupID = $this->dao->lastInsertId();
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD><CBBB><EFBFBD>group<75>Ķ<EFBFBD>Ӧ<EFBFBD><D3A6>ϵ<EFBFBD><CFB5>*/
|
||||
foreach($groupUsers as $account)
|
||||
{
|
||||
if(empty($account)) continue;
|
||||
$this->dao->dbh($this->dbh)->insert(TABLE_USERGROUP)->set('`group`')->eq($zentaoGroupID)->set('account')->eq($account)->exec();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ת<><D7AA><EFBFBD>û<EFBFBD><C3BB><EFBFBD>*/
|
||||
public function convertUser()
|
||||
{
|
||||
/* <20><>ѯ<EFBFBD><D1AF>ǰϵͳ<CFB5>д<EFBFBD><D0B4>ڵ<EFBFBD><DAB5>û<EFBFBD><C3BB><EFBFBD>*/
|
||||
$activeUsers = $this->dao
|
||||
->dbh($this->sourceDBH)
|
||||
->select("{$this->app->company->id} AS company, username AS account, userpassword AS password, realname, email")
|
||||
->from('BugUser')
|
||||
->orderBy('userID ASC')
|
||||
->fetchAll('account');
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>*/
|
||||
$allUsers = $this->dao->select("distinct(username) AS account")->from('BugHistory')->fetchPairs();
|
||||
|
||||
/* <20>ϲ<EFBFBD><CFB2><EFBFBD><EFBFBD>ߡ<EFBFBD>*/
|
||||
foreach($allUsers as $key => $account)
|
||||
{
|
||||
if(isset($activeUsers[$account]))
|
||||
{
|
||||
$allUsers[$key] = $activeUsers[$account];
|
||||
}
|
||||
else
|
||||
{
|
||||
$allUsers[$key] = array('company' => $this->app->company->id, 'account' => $account, 'realname' => $account, 'status' => 'delete');
|
||||
}
|
||||
}
|
||||
foreach($activeUsers as $account => $user) if(!isset($allUsers[$account])) $allUsers[$account] = $user;
|
||||
|
||||
/* <20><><EFBFBD>뵽zentao<61><6F><EFBFBD>ݿ<EFBFBD><DDBF>С<EFBFBD>*/
|
||||
$convertCount = 0;
|
||||
foreach($allUsers as $account => $user)
|
||||
{
|
||||
if(!$this->dao->dbh($this->dbh)->findByAccount($account)->from(TABLE_USER)->fetch('account'))
|
||||
{
|
||||
$this->dao->dbh($this->dbh)->insert(TABLE_USER)->data($user)->exec();
|
||||
$convertCount ++;
|
||||
}
|
||||
else
|
||||
{
|
||||
self::$info['users'][] = sprintf($this->lang->convert->errorUserExists, $account);
|
||||
}
|
||||
}
|
||||
return $convertCount;
|
||||
}
|
||||
|
||||
/* ת<><D7AA><EFBFBD><EFBFBD>ĿΪ<C4BF><CEAA>Ʒ<EFBFBD><C6B7>*/
|
||||
public function convertProject()
|
||||
{
|
||||
$projects = $this->dao->dbh($this->sourceDBH)->select("projectID AS id, projectName AS name, {$this->app->company->id} AS company")->from('BugProject')->fetchAll('id');
|
||||
foreach($projects as $projectID => $project)
|
||||
{
|
||||
unset($project->id);
|
||||
$this->dao->dbh($this->dbh)->insert(TABLE_PRODUCT)->data($project)->exec();
|
||||
$this->map['product'][$projectID] = $this->dao->lastInsertID();
|
||||
}
|
||||
return count($projects);
|
||||
}
|
||||
|
||||
/* ת<><D7AA>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3>ΪBug<75><67>ͼģ<CDBC>顣*/
|
||||
public function convertModule()
|
||||
{
|
||||
$this->map['module'][0] = 0;
|
||||
$modules = $this->dao
|
||||
->dbh($this->sourceDBH)
|
||||
->select(
|
||||
'moduleID AS id,
|
||||
projectID AS product,
|
||||
moduleName AS name,
|
||||
moduleGrade AS grade,
|
||||
parentID AS parent,
|
||||
"bug" AS view')
|
||||
->from('BugModule')
|
||||
->orderBy('id ASC')
|
||||
->fetchAll('id');
|
||||
foreach($modules as $moduleID => $module)
|
||||
{
|
||||
$module->product = $this->map['product'][$module->product];
|
||||
unset($module->id);
|
||||
$this->dao->dbh($this->dbh)->insert(TABLE_MODULE)->data($module)->exec();
|
||||
$this->map['module'][$moduleID] = $this->dao->lastInsertID();
|
||||
}
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD>parent<6E><74>*/
|
||||
foreach($this->map['module'] as $oldModuleID => $newModuleID)
|
||||
{
|
||||
$this->dao->dbh($this->dbh)->update(TABLE_MODULE)->set('parent')->eq($newModuleID)->where('parent')->eq($oldModuleID)->exec();
|
||||
}
|
||||
return count($modules);
|
||||
}
|
||||
|
||||
/* ת<><D7AA>Bug<75><67>*/
|
||||
public function convertBug()
|
||||
{
|
||||
$bugs = $this->dao
|
||||
->dbh($this->sourceDBH)
|
||||
->select('
|
||||
bugID AS id,
|
||||
projectID AS product,
|
||||
moduleID AS module,
|
||||
bugTitle AS title,
|
||||
bugSeverity AS severity,
|
||||
bugType AS type,
|
||||
bugOS AS os,
|
||||
bugStatus AS status,
|
||||
mailto,
|
||||
openedBy, openedDate, openedBuild,
|
||||
assignedTo, assignedDate,
|
||||
resolvedBy, resolution, resolvedBuild, resolvedDate,
|
||||
closedBy, closedDate,
|
||||
lastEditedBy, lastEditedDate,
|
||||
linkID as duplicateBug
|
||||
')
|
||||
->from('BugInfo')
|
||||
->orderBy('bugID')
|
||||
->fetchAll('id');
|
||||
foreach($bugs as $bugID => $bug)
|
||||
{
|
||||
/* <20><><EFBFBD><EFBFBD>Bug<75><67><EFBFBD>ݡ<EFBFBD>*/
|
||||
$bugID = (int)$bugID;
|
||||
unset($bug->id);
|
||||
if($bug->assignedTo == 'Closed') $bug->assignedTo = 'closed';
|
||||
$bug->type = strtolower($bug->type);
|
||||
$bug->os = strtolower($bug->os);
|
||||
$bug->browser = 'all';
|
||||
$bug->resolution = str_replace(' ','', strtolower($bug->resolution));
|
||||
$bug->product = $this->map['product'][$bug->product];
|
||||
$bug->module = $this->map['module'][$bug->module];
|
||||
$this->dao->dbh($this->dbh)->insert(TABLE_BUG)->data($bug)->exec();
|
||||
$this->map['bug'][$bugID] = $this->dao->lastInsertID();
|
||||
}
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD>duplicateBug<75><67> */
|
||||
foreach($this->map['bug'] as $oldBugID => $newBugID)
|
||||
{
|
||||
$this->dao->dbh($this->dbh)->update(TABLE_BUG)->set('duplicateBug')->eq($newBugID)->where('duplicateBug')->eq($oldBugID)->exec();
|
||||
}
|
||||
return count($bugs);
|
||||
}
|
||||
|
||||
/* ת<><D7AA><EFBFBD><EFBFBD>ʷ<EFBFBD><CAB7>¼<EFBFBD><C2BC>*/
|
||||
public function convertAction()
|
||||
{
|
||||
$actions = $this->dao
|
||||
->dbh($this->sourceDBH)
|
||||
->select(
|
||||
"{$this->app->company->id} AS company,
|
||||
'bug' AS objectType,
|
||||
bugID AS objectID,
|
||||
userName AS actor,
|
||||
action,
|
||||
fullInfo AS comment,
|
||||
actionDate AS date")
|
||||
->from('BugHistory')
|
||||
->orderBy('bugID, historyID')
|
||||
->fetchGroup('objectID');
|
||||
$convertCount = 0;
|
||||
foreach($actions as $bugID => $bugActions)
|
||||
{
|
||||
/* <20><><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>֮<EFBFBD><D6AE><EFBFBD><EFBFBD>bugID<49><44>*/
|
||||
$bugID = (int)$bugID;
|
||||
$zentaoBugID = $this->map['bug'][$bugID];
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD>action<6F><6E>*/
|
||||
foreach($bugActions as $key => $action)
|
||||
{
|
||||
$action->objectID = $zentaoBugID;
|
||||
if($key == 0)
|
||||
{
|
||||
$this->dao->dbh($this->dbh)->update(TABLE_BUG)->set('steps')->eq($action->comment)->where('id')->eq($zentaoBugID)->exec();
|
||||
$action->comment = '';
|
||||
}
|
||||
$this->dao->dbh($this->dbh)->insert(TABLE_ACTION)->data($action)->exec();
|
||||
$convertCount ++;
|
||||
}
|
||||
}
|
||||
return $convertCount;
|
||||
}
|
||||
|
||||
/* ת<><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
public function convertFile()
|
||||
{
|
||||
$this->setPath();
|
||||
$files = $this->dao->dbh($this->sourceDBH)
|
||||
->select(
|
||||
"{$this->app->company->id} AS company,
|
||||
fileName AS pathname,
|
||||
fileTitle AS title,
|
||||
fileType AS extension,
|
||||
fileSize AS size,
|
||||
'bug' AS objectType,
|
||||
bugID AS objectID,
|
||||
addUser AS addedBy,
|
||||
addDate AS addedDate
|
||||
")
|
||||
->from('BugFile')
|
||||
->orderBy('fileID')
|
||||
->fetchAll();
|
||||
foreach($files as $file)
|
||||
{
|
||||
$file->objectID = $this->map['bug'][(int)$file->objectID];
|
||||
if(strpos($file->size, 'KB')) $file->size = (int)(str_replace('KB', '', $file->size) * 1024);
|
||||
if(strpos($file->size, 'MB')) $file->size = (int)(str_replace('MB', '', $file->size) * 1024 * 1024);
|
||||
$this->dao->dbh($this->dbh)->insert(TABLE_FILE)->data($file)->exec();
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>*/
|
||||
$soureFile = $this->filePath . $file->pathname;
|
||||
if(!file_exists($soureFile))
|
||||
{
|
||||
self::$info['files'][] = sprintf($this->lang->convert->errorFileNotExits, $soureFile);
|
||||
continue;
|
||||
}
|
||||
$targetFile = $this->app->getAppRoot() . "www/data/upload/{$this->app->company->id}/" . $file->pathname;
|
||||
$targetPath = dirname($targetFile);
|
||||
if(!is_dir($targetPath)) mkdir($targetPath, 0777, true);
|
||||
if(!copy($soureFile, $targetFile))
|
||||
{
|
||||
self::$info['files'][] = sprintf($this->lang->convert->errorCopyFailed, $targetFile);
|
||||
}
|
||||
}
|
||||
return count($files);
|
||||
}
|
||||
}
|
||||
469
trunk/module/convert/converter/bugfree2.php
Normal file
469
trunk/module/convert/converter/bugfree2.php
Normal file
@@ -0,0 +1,469 @@
|
||||
<?php
|
||||
/**
|
||||
* The model file of bugfree2 convert of ZenTaoMS.
|
||||
*
|
||||
* ZenTaoMS is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* ZenTaoMS is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with ZenTaoMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @copyright Copyright 2009-2010 Chunsheng Wang
|
||||
* @author Chunsheng Wang <wwccss@263.net>
|
||||
* @package convert
|
||||
* @version $Id$
|
||||
* @link http://www.zentao.cn
|
||||
*/
|
||||
class bugfree2ConvertModel extends bugfreeConvertModel
|
||||
{
|
||||
/* ִ<><D6B4>ת<EFBFBD><D7AA><EFBFBD><EFBFBD>*/
|
||||
public function execute()
|
||||
{
|
||||
$this->clear();
|
||||
$this->setTable();
|
||||
$this->convertGroup();
|
||||
$result['users'] = $this->convertUser();
|
||||
$result['projects'] = $this->convertProject();
|
||||
$result['modules'] = $this->convertModule();
|
||||
$result['bugs'] = $this->convertBug();
|
||||
$result['cases'] = $this->convertCase();
|
||||
$result['results'] = $this->convertResult();
|
||||
$result['actions'] = $this->convertAction();
|
||||
$result['files'] = $this->convertFile();
|
||||
$this->loadModel('tree')->fixModulePath();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/* <20><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
public function setTable()
|
||||
{
|
||||
$dbPrefix = $this->post->dbPrefix;
|
||||
define('BUGFREE_TABLE_USER', $dbPrefix . 'TestUser');
|
||||
define('BUGFREE_TABLE_PROJECT', $dbPrefix . 'TestProject');
|
||||
define('BUGFREE_TABLE_MODULE', $dbPrefix . 'TestModule');
|
||||
define('BUGFREE_TABLE_BUGINFO', $dbPrefix . 'BugInfo');
|
||||
define('BUGFREE_TABLE_CASEINFO', $dbPrefix . 'CaseInfo');
|
||||
define('BUGFREE_TABLE_RESULTINFO', $dbPrefix . 'ResultInfo');
|
||||
define('BUGFREE_TABLE_ACTION', $dbPrefix . 'TestAction');
|
||||
define('BUGFREE_TABLE_FILE', $dbPrefix . 'TestFile');
|
||||
define('BUGFREE_TABLE_HISTORY', $dbPrefix . 'TestHistory');
|
||||
define('BUGFREE_TABLE_GROUP', $dbPrefix . 'TestGroup');
|
||||
}
|
||||
|
||||
/* ת<><D7AA><EFBFBD>û<EFBFBD><C3BB><EFBFBD>*/
|
||||
public function convertUser()
|
||||
{
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><D0B5>û<EFBFBD><C3BB>б<EFBFBD><D0B1><EFBFBD>*/
|
||||
$users = $this->dao
|
||||
->dbh($this->sourceDBH)
|
||||
->select("{$this->app->company->id} AS company, username AS account, userpassword AS password, realname, email, isDroped")
|
||||
->from(BUGFREE_TABLE_USER)
|
||||
->orderBy('userID ASC')
|
||||
->fetchAll('account');
|
||||
|
||||
/* ת<><D7AA>isDroped<65>ֶΡ<D6B6>*/
|
||||
foreach($users as $account => $user)
|
||||
{
|
||||
$user->status = $user->isDroped ? 'delete' : 'active';
|
||||
unset($user->isDroped);
|
||||
}
|
||||
|
||||
/* <20><><EFBFBD>뵽zentao<61><6F><EFBFBD>ݿ<EFBFBD><DDBF>С<EFBFBD>*/
|
||||
$convertCount = 0;
|
||||
foreach($users as $account => $user)
|
||||
{
|
||||
if(!$this->dao->dbh($this->dbh)->findByAccount($account)->from(TABLE_USER)->fetch('account'))
|
||||
{
|
||||
$this->dao->dbh($this->dbh)->insert(TABLE_USER)->data($user)->exec();
|
||||
$convertCount ++;
|
||||
}
|
||||
else
|
||||
{
|
||||
self::$info['users'][] = sprintf($this->lang->convert->errorUserExists, $account);
|
||||
}
|
||||
}
|
||||
return $convertCount;
|
||||
}
|
||||
|
||||
/* ת<><D7AA><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD>顣*/
|
||||
public function convertGroup()
|
||||
{
|
||||
$groups = $this->dao->dbh($this->sourceDBH)
|
||||
->select("{$this->app->company->id} AS company, groupID AS id, groupName AS name, groupUser AS users")
|
||||
->from(BUGFREE_TABLE_GROUP)
|
||||
->fetchAll('id');
|
||||
foreach($groups as $groupID => $group)
|
||||
{
|
||||
/* <20><><EFBFBD><EFBFBD>group<75><70><EFBFBD>ݡ<EFBFBD>*/
|
||||
if($group->name == '[All Users]') continue;
|
||||
$groupUsers = explode(',', $group->users);
|
||||
unset($group->id);
|
||||
unset($group->users);
|
||||
|
||||
/* <20><><EFBFBD>뵽group<75><70><EFBFBD><EFBFBD>*/
|
||||
$this->dao->dbh($this->dbh)->insert(TABLE_GROUP)->data($group)->exec();
|
||||
$zentaoGroupID = $this->dao->lastInsertId();
|
||||
|
||||
/* <20><><EFBFBD>뵽userGroup<75><70><EFBFBD><EFBFBD>*/
|
||||
foreach($groupUsers as $account)
|
||||
{
|
||||
if(empty($account)) continue;
|
||||
$this->dao->dbh($this->dbh)->insert(TABLE_USERGROUP)
|
||||
->set('`group`')->eq($zentaoGroupID)
|
||||
->set('account')->eq($account)
|
||||
->exec();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ת<><D7AA><EFBFBD><EFBFBD>ĿΪ<C4BF><CEAA>Ʒ<EFBFBD><C6B7>*/
|
||||
public function convertProject()
|
||||
{
|
||||
$projects = $this->dao->dbh($this->sourceDBH)
|
||||
->select("projectID AS id, projectName AS name, {$this->app->company->id} AS company, isDroped")
|
||||
->from(BUGFREE_TABLE_PROJECT)
|
||||
->fetchAll('id');
|
||||
foreach($projects as $projectID => $project)
|
||||
{
|
||||
$project->status = $project->isDroped ? 'delete' : 'active';
|
||||
unset($project->id);
|
||||
unset($project->isDroped);
|
||||
|
||||
$this->dao->dbh($this->dbh)->insert(TABLE_PRODUCT)->data($project)->exec();
|
||||
$this->map['product'][$projectID] = $this->dao->lastInsertID();
|
||||
}
|
||||
return count($projects);
|
||||
}
|
||||
|
||||
/* ת<><D7AA>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3>ΪBug<75><67>ͼģ<CDBC>顣*/
|
||||
public function convertModule()
|
||||
{
|
||||
$this->map['module'][0] = 0;
|
||||
$modules = $this->dao
|
||||
->dbh($this->sourceDBH)
|
||||
->select(
|
||||
'moduleID AS id,
|
||||
moduleType as view,
|
||||
projectID AS product,
|
||||
moduleName AS name,
|
||||
moduleGrade AS grade,
|
||||
parentID AS parent,
|
||||
displayOrder AS `order`')
|
||||
->from(BUGFREE_TABLE_MODULE)
|
||||
->orderBy('id ASC')
|
||||
->fetchAll('id');
|
||||
foreach($modules as $moduleID => $module)
|
||||
{
|
||||
$module->product = $this->map['product'][$module->product];
|
||||
$module->view = strtolower($module->view);
|
||||
unset($module->id);
|
||||
$this->dao->dbh($this->dbh)->insert(TABLE_MODULE)->data($module)->exec();
|
||||
$this->map['module'][$moduleID] = $this->dao->lastInsertID();
|
||||
}
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD>parent<6E><74>*/
|
||||
foreach($this->map['module'] as $oldModuleID => $newModuleID)
|
||||
{
|
||||
$this->dao->dbh($this->dbh)->update(TABLE_MODULE)->set('parent')->eq($newModuleID)->where('parent')->eq($oldModuleID)->exec();
|
||||
}
|
||||
return count($modules);
|
||||
}
|
||||
|
||||
/* ת<><D7AA>Bug<75><67>*/
|
||||
public function convertBug()
|
||||
{
|
||||
$bugs = $this->dao
|
||||
->dbh($this->sourceDBH)
|
||||
->select('
|
||||
bugID AS id,
|
||||
projectID AS product,
|
||||
moduleID AS module,
|
||||
bugTitle AS title,
|
||||
bugSeverity AS severity,
|
||||
bugPriority AS pri,
|
||||
bugType AS type,
|
||||
bugOS AS os,
|
||||
bugBrowser AS browser,
|
||||
bugMachine AS hardware,
|
||||
howFound AS found,
|
||||
reproSteps AS steps,
|
||||
bugStatus AS status,
|
||||
linkID AS linkBug,
|
||||
duplicateID AS duplicateBug,
|
||||
caseID AS `case`,
|
||||
1 AS caseVersion,
|
||||
resultID AS result,
|
||||
mailto,
|
||||
openedBy, openedDate, openedBuild,
|
||||
assignedTo, assignedDate,
|
||||
resolvedBy, resolution, resolvedBuild, resolvedDate,
|
||||
closedBy, closedDate,
|
||||
lastEditedBy, lastEditedDate,
|
||||
bugKeyword AS keyword
|
||||
')
|
||||
->from(BUGFREE_TABLE_BUGINFO)
|
||||
->where('isDroped')->eq(0)
|
||||
->orderBy('bugID')
|
||||
->fetchAll('id');
|
||||
foreach($bugs as $bugID => $bug)
|
||||
{
|
||||
/* <20><><EFBFBD><EFBFBD>Bug<75><67><EFBFBD>ݡ<EFBFBD>*/
|
||||
$bugID = (int)$bugID;
|
||||
unset($bug->id);
|
||||
|
||||
if($bug->assignedTo == 'Closed') $bug->assignedTo = 'closed';
|
||||
if($bug->assignedTo == 'Active') $bug->assignedTo = '';
|
||||
|
||||
$bug->type = strtolower($bug->type);
|
||||
$bug->found = strtolower($bug->found);
|
||||
$bug->status = strtolower($bug->status);
|
||||
$bug->os = strtolower($bug->os);
|
||||
$bug->browser= strtolower($bug->browser);
|
||||
|
||||
if($bug->os == 'winvista') $bug->os = 'vista';
|
||||
if($bug->browser == 'firefox3.0') $bug->browser = 'firefox3';
|
||||
if($bug->browser == 'firefox2.0') $bug->browser = 'firefox2';
|
||||
if($bug->openedBuild == 'N/A') $bug->openedBuild = '';
|
||||
if(!$bug->case) $bug->caseVersion = 0;
|
||||
|
||||
$bug->resolution = str_replace(' ', '', strtolower($bug->resolution));
|
||||
$bug->product = $this->map['product'][$bug->product];
|
||||
$bug->module = $this->map['module'][$bug->module];
|
||||
$this->dao->dbh($this->dbh)->insert(TABLE_BUG)->data($bug)->exec();
|
||||
$this->map['bug'][$bugID] = $this->dao->lastInsertID();
|
||||
}
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD>duplicateBug<75><67> */
|
||||
foreach($this->map['bug'] as $oldBugID => $newBugID)
|
||||
{
|
||||
$this->dao->dbh($this->dbh)->update(TABLE_BUG)->set('duplicateBug')->eq($newBugID)->where('duplicateBug')->eq($oldBugID)->exec();
|
||||
}
|
||||
return count($bugs);
|
||||
}
|
||||
|
||||
/* ת<><D7AA>case<73><65>*/
|
||||
public function convertCase()
|
||||
{
|
||||
$cases = $this->dao
|
||||
->dbh($this->sourceDBH)
|
||||
->select('
|
||||
caseID AS id,
|
||||
projectID AS product,
|
||||
moduleID AS module,
|
||||
caseTitle AS title,
|
||||
caseSteps AS step,
|
||||
casePriority AS pri,
|
||||
caseType AS type,
|
||||
caseStatus AS status,
|
||||
caseMethod AS executeType,
|
||||
casePlan AS scope,
|
||||
openedBy, openedDate,
|
||||
lastEditedBy, lastEditedDate,
|
||||
scriptedBy, scriptedDate, scriptStatus, scriptLocation,
|
||||
linkID AS linkCase,
|
||||
casekeyword AS keyword,
|
||||
DisplayOrder AS `order`,
|
||||
1 AS version,
|
||||
bugID
|
||||
')
|
||||
->from(BUGFREE_TABLE_CASEINFO)
|
||||
->where('isDroped')->eq(0)
|
||||
->orderBy('caseID')
|
||||
->fetchAll('id');
|
||||
foreach($cases as $caseID => $case)
|
||||
{
|
||||
/* <20><><EFBFBD><EFBFBD>case<73><65><EFBFBD><EFBFBD><EFBFBD>ݡ<EFBFBD>*/
|
||||
$caseID = (int)$caseID;
|
||||
$step = $case->step;
|
||||
$bugs = explode(',', $case->bugID);
|
||||
unset($case->id);
|
||||
unset($case->step);
|
||||
unset($case->bugID);
|
||||
|
||||
$case->type = strtolower($case->type);
|
||||
$case->status = strtolower($case->status);
|
||||
$case->executeType = strtolower($case->executeType);
|
||||
$case->scope = strtolower($case->scope);
|
||||
|
||||
if($case->type == 'configuration') $case->type = 'config';
|
||||
if($case->type == 'setup') $case->type = 'install';
|
||||
if($case->type == 'functional') $case->type = 'feature';
|
||||
if($case->status == 'active') $case->status = 'normal';
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD>Ʒ<EFBFBD><C6B7>ģ<EFBFBD><C4A3><EFBFBD>滻<EFBFBD><E6BBBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ<CFB5>е<EFBFBD>id<69><64>*/
|
||||
$case->product = $this->map['product'][$case->product];
|
||||
$case->module = $this->map['module'][$case->module];
|
||||
|
||||
/* <20><><EFBFBD>뵽case<73><65><EFBFBD>С<EFBFBD>*/
|
||||
$this->dao->dbh($this->dbh)->insert(TABLE_CASE)->data($case)->exec();
|
||||
$zentaoCaseID = $this->dao->lastInsertID();
|
||||
$this->map['case'][$caseID] = $zentaoCaseID;
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
$caseStep->case = $zentaoCaseID;
|
||||
$caseStep->version = 1;
|
||||
$caseStep->desc = $step;
|
||||
$this->dao->dbh($this->dbh)->insert(TABLE_CASESTEP)->data($caseStep)->exec();
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>bug<75><67>*/
|
||||
foreach($bugs as $bugID)
|
||||
{
|
||||
if(!isset($this->map['bug'][$bugID])) continue;
|
||||
$zentaoBugID = $this->map['bug'][$bugID];
|
||||
$this->dao->dbh($this->dbh)->update(TABLE_BUG)->set('`case`')->eq($zentaoCaseID)->where('id')->eq($zentaoBugID)->limit(1)->exec();
|
||||
}
|
||||
}
|
||||
return count($cases);
|
||||
}
|
||||
|
||||
/* ת<><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD>н<EFBFBD><D0BD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
public function convertResult()
|
||||
{
|
||||
$results = $this->dao->dbh($this->sourceDBH)
|
||||
->select('
|
||||
resultID AS id,
|
||||
caseID AS `case`,
|
||||
resultValue AS caseResult,
|
||||
1 AS version,
|
||||
openedDate as date,
|
||||
bugID
|
||||
')
|
||||
->from(BUGFREE_TABLE_RESULTINFO)
|
||||
->orderBy('id')
|
||||
->fetchAll('id');
|
||||
foreach($results as $resultID => $result)
|
||||
{
|
||||
unset($result->id);
|
||||
|
||||
/* <20><>¼<EFBFBD><C2BC>Ӧ<EFBFBD><D3A6>bug<75><67>Ϣ<EFBFBD><CFA2>*/
|
||||
$bugID = (int)$result->bugID;
|
||||
$zentaoBugID = $this->map['bug'][$bugID];
|
||||
unset($result->bugID);
|
||||
|
||||
/* <20><><EFBFBD>뵽testResult<6C><74><EFBFBD>С<EFBFBD>*/
|
||||
$this->dao->dbh($this->dbh)->insert(TABLE_TESTRESULT)->data($result)->exec();
|
||||
$zentaoResultID = $this->dao->lastInsertId();
|
||||
$this->map['result'][$resultID] = $zentaoResultID;
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD>bug<75><67><EFBFBD>е<EFBFBD>result<6C>ֶΡ<D6B6>*/
|
||||
$this->dao->dbh($this->dbh)->update(TABLE_BUG)->set('result')->eq($zentaoResultID)->where('id')->eq($zentaoBugID)->limit(1)->exec();
|
||||
}
|
||||
return count($results);
|
||||
}
|
||||
|
||||
/* ת<><D7AA><EFBFBD><EFBFBD>ʷ<EFBFBD><CAB7>¼<EFBFBD><C2BC>*/
|
||||
public function convertAction()
|
||||
{
|
||||
$actions = $this->dao
|
||||
->dbh($this->sourceDBH)
|
||||
->select("{$this->app->company->id} AS company,
|
||||
actionID AS id,
|
||||
actionTarget AS objectType,
|
||||
idValue AS objectID,
|
||||
actionUser AS actor,
|
||||
actionType AS action,
|
||||
actionDate AS date,
|
||||
actionNote AS comment
|
||||
")
|
||||
->from(BUGFREE_TABLE_ACTION)
|
||||
->where('actionTarget' != 'Result')
|
||||
->orderBy('actionID')
|
||||
->fetchAll('id');
|
||||
|
||||
foreach($actions as $actionID => $action)
|
||||
{
|
||||
$actionID = (int)$action->id;
|
||||
unset($action->id);
|
||||
$action->objectType = strtolower($action->objectType);
|
||||
$action->action = strtolower($action->action);
|
||||
$action->objectID = $this->map[$action->objectType][$action->objectID];
|
||||
|
||||
$this->dao->dbh($this->dbh)->insert(TABLE_ACTION)->data($action)->exec();
|
||||
$this->map['action'][$actionID] = $this->dao->lastInsertID();
|
||||
}
|
||||
return count($actions);
|
||||
}
|
||||
|
||||
/* ת<><D7AA><EFBFBD><EFBFBD>ʷ<EFBFBD>ļ<DEB8>¼<EFBFBD><C2BC>*/
|
||||
public function convertHistory()
|
||||
{
|
||||
$histories = $this->dao->dbh($this->sourceDBH)
|
||||
->select('actioID, actionField AS field, oldValue AS old, newValue AS new')
|
||||
->from(BUGFREE_TABLE_HISTORY)
|
||||
->orderBy('historyID')
|
||||
->fetchAll();
|
||||
foreach($histories as $history)
|
||||
{
|
||||
$history->actionID = $this->map['action'][$history->actionID];
|
||||
$this->dao->dbh($this->dbh)->insert(TABLE_HISTORY)->data($history)->exec();
|
||||
}
|
||||
}
|
||||
|
||||
/* ת<><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
public function convertFile()
|
||||
{
|
||||
$this->setPath();
|
||||
$files = $this->dao->dbh($this->sourceDBH)
|
||||
->select(
|
||||
"{$this->app->company->id} AS company,
|
||||
actionID,
|
||||
fileName AS pathname,
|
||||
fileTitle AS title,
|
||||
fileType AS extension,
|
||||
fileSize AS size
|
||||
")
|
||||
->from(BUGFREE_TABLE_FILE)
|
||||
->orderBy('fileID')
|
||||
->fetchAll();
|
||||
foreach($files as $file)
|
||||
{
|
||||
/* <20><><EFBFBD>Ҷ<EFBFBD>Ӧ<EFBFBD><D3A6>action<6F><6E>Ϣ<EFBFBD><CFA2><EFBFBD>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶΡ<D6B6>*/
|
||||
$zentaoActionID = $this->map['action'][$file->actionID];
|
||||
$zentaoAction = $this->dao->dbh($this->dbh)->findById($zentaoActionID)->from(TABLE_ACTION)->fetch();
|
||||
$file->objectType = $zentaoAction->objectType;
|
||||
$file->objectID = $zentaoAction->objectID;
|
||||
$file->addedBy = $zentaoAction->actor;
|
||||
$file->addedDate = $zentaoAction->date;
|
||||
unset($file->actionID);
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>С<EFBFBD><D0A1>*/
|
||||
if(strpos($file->size, 'KB')) $file->size = (int)(str_replace('KB', '', $file->size) * 1024);
|
||||
if(strpos($file->size, 'MB')) $file->size = (int)(str_replace('MB', '', $file->size) * 1024 * 1024);
|
||||
|
||||
/* <20><><EFBFBD>뵽<EFBFBD><EBB5BD><EFBFBD>ݿ⡣*/
|
||||
$this->dao->dbh($this->dbh)->insert(TABLE_FILE)->data($file)->exec();
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>*/
|
||||
$soureFile = $this->filePath . $file->pathname;
|
||||
if(!file_exists($soureFile))
|
||||
{
|
||||
self::$info['files'][] = sprintf($this->lang->convert->errorFileNotExits, $soureFile);
|
||||
continue;
|
||||
}
|
||||
$targetFile = $this->app->getAppRoot() . "www/data/upload/{$this->app->company->id}/" . $file->pathname;
|
||||
$targetPath = dirname($targetFile);
|
||||
if(!is_dir($targetPath)) mkdir($targetPath, 0777, true);
|
||||
if(!copy($soureFile, $targetFile))
|
||||
{
|
||||
self::$info['files'][] = sprintf($this->lang->convert->errorCopyFailed, $targetFile);
|
||||
}
|
||||
}
|
||||
return count($files);
|
||||
}
|
||||
|
||||
/* <20><><EFBFBD>յ<EFBFBD><D5B5><EFBFBD>֮<EFBFBD><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݡ<EFBFBD>*/
|
||||
public function clear()
|
||||
{
|
||||
foreach($this->session->state as $table => $maxID)
|
||||
{
|
||||
$this->dao->dbh($this->dbh)->delete()->from($table)->where('id')->gt($maxID)->exec();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -38,7 +38,7 @@ $lang->convert->source = '来源系统';
|
||||
$lang->convert->version = '版本';
|
||||
$lang->convert->mustSelectSource = "必须选择一个来源。";
|
||||
|
||||
$lang->convert->sourceList['BugFree'] = array('bugfree_1' => '1.x');
|
||||
$lang->convert->sourceList['BugFree'] = array('bugfree_1' => '1.x', 'bugfree_2' => '2.x');
|
||||
|
||||
$lang->convert->setting = '设置';
|
||||
$lang->convert->checkConfig = '检查配置';
|
||||
@@ -68,6 +68,8 @@ $lang->convert->bugfree->users = '用户';
|
||||
$lang->convert->bugfree->projects = '项目';
|
||||
$lang->convert->bugfree->modules = '模块';
|
||||
$lang->convert->bugfree->bugs = 'Bug';
|
||||
$lang->convert->bugfree->cases = '测试用例';
|
||||
$lang->convert->bugfree->results = '测试结果';
|
||||
$lang->convert->bugfree->actions = '历史记录';
|
||||
$lang->convert->bugfree->files = '附件';
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
echo html::hidden('dbUser', $this->post->dbUser);
|
||||
echo html::hidden('dbPassword', $this->post->dbPassword);
|
||||
echo html::hidden('dbName', $this->post->dbName);
|
||||
echo html::hidden('dbPrefix', $this->post->dbPrefix);
|
||||
echo html::hidden('installPath',$this->post->installPath);
|
||||
?>
|
||||
</form>
|
||||
|
||||
@@ -23,6 +23,20 @@
|
||||
<td><?php echo $result['bugs'];?></td>
|
||||
<td class='f-12px'><?php if(isset($info['bugs'])) echo join('<br />', $info['bugs']);?></td>
|
||||
</tr>
|
||||
<?php if($version > 1):?>
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->convert->bugfree->cases;?></th>
|
||||
<td><?php echo $result['cases'];?></td>
|
||||
<td class='f-12px'><?php if(isset($info['cases'])) echo join('<br />', $info['cases']);?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->convert->bugfree->results;?></th>
|
||||
<td><?php echo $result['results'];?></td>
|
||||
<td class='f-12px'><?php if(isset($info['results'])) echo join('<br />', $info['results']);?></td>
|
||||
</tr>
|
||||
|
||||
<?php endif;?>
|
||||
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->convert->bugfree->actions;?></th>
|
||||
<td><?php echo $result['actions'];?></td>
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
<tr>
|
||||
<th class='rowhead w-200px'><?php echo $lang->convert->dbHost;?></th>
|
||||
<td><?php echo html::input('dbHost', $config->db->host);?></td>
|
||||
<td><?php echo html::input('dbHost', $config->db->host, "class='text-3'");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->convert->dbPort;?></th>
|
||||
<td><?php echo html::input('dbPort', $config->db->port);?></td>
|
||||
<td><?php echo html::input('dbPort', $config->db->port, "class='text-3'");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->convert->dbUser;?></th>
|
||||
<td><?php echo html::input('dbUser', $config->db->user);?></td>
|
||||
<td><?php echo html::input('dbUser', $config->db->user, "class='text-3'");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->convert->dbPassword;?></th>
|
||||
<td><?php echo html::input('dbPassword', $config->db->password);?></td>
|
||||
<td><?php echo html::input('dbPassword', $config->db->password, "class='text-3'");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class='rowhead'><?php printf($lang->convert->dbName, $source);?></th>
|
||||
<td><?php echo html::input('dbName', $dbName);?></td>
|
||||
<td><?php echo html::input('dbName', $dbName, "class='text-3'");?></td>
|
||||
</tr>
|
||||
<!--
|
||||
<?php if($version > 1):?>
|
||||
<tr>
|
||||
<th class='rowhead'><?php printf($lang->convert->dbPrefix, $source);?></th>
|
||||
<td><?php echo html::input('dbPrefix', $tablePrefix);?></td>
|
||||
<td><?php echo html::input('dbPrefix', $tablePrefix, "class='text-3'");?></td>
|
||||
</tr>
|
||||
-->
|
||||
<?php endif;?>
|
||||
<tr>
|
||||
<th class='rowhead'><?php printf($lang->convert->installPath, $source);?></th>
|
||||
<td><?php echo html::input('installPath');?></td>
|
||||
<td><?php echo html::input('installPath', '', "class='text-3'");?></td>
|
||||
</tr>
|
||||
|
||||
@@ -97,10 +97,15 @@ $lang->testcase->priList[4] = 4;
|
||||
$lang->testcase->typeList[''] = '';
|
||||
$lang->testcase->typeList['feature'] = '功能测试';
|
||||
$lang->testcase->typeList['performance'] = '性能测试';
|
||||
$lang->testcase->typeList['config'] = '配置相关';
|
||||
$lang->testcase->typeList['install'] = '安装部署';
|
||||
$lang->testcase->typeList['security'] = '安全相关';
|
||||
$lang->testcase->typeList['other'] = '其他';
|
||||
|
||||
$lang->testcase->statusList[''] = '';
|
||||
$lang->testcase->statusList['normal'] = '正常';
|
||||
$lang->testcase->statusList['blocked'] = 'Blocked';
|
||||
$lang->testcase->statusList[''] = '';
|
||||
$lang->testcase->statusList['normal'] = '正常';
|
||||
$lang->testcase->statusList['blocked'] = '被阻塞';
|
||||
$lang->testcase->statusList['investigate'] = '研究中';
|
||||
|
||||
$lang->testcase->resultList['n/a'] = 'N/A';
|
||||
$lang->testcase->resultList['pass'] = '通过';
|
||||
|
||||
Reference in New Issue
Block a user