* Code for jira.
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
<?php
|
||||
define('JIRA_USER', 'app_user`');
|
||||
define('JIRA_USER', 'app_user`');
|
||||
define('JIRA_USERINFO', 'cwd_user`');
|
||||
define('JIRA_PROJECT', 'project`');
|
||||
define('JIRA_ISSUE', 'jiraissue`');
|
||||
define('JIRA_ISSUE', 'jiraissue`');
|
||||
define('JIRA_ISSUETYPE', 'issuetype');
|
||||
define('JIRA_ISSUELINK', 'issuelink');
|
||||
define('JIRA_ISSUELINKTYPE', 'issuelinktype');
|
||||
|
||||
@@ -286,21 +286,101 @@ class convert extends control
|
||||
|
||||
public function mapJira2Zentao($type = 'db', $dbName = '')
|
||||
{
|
||||
$this->app->loadLang('story');
|
||||
$this->app->loadLang('bug');
|
||||
$this->app->loadLang('task');
|
||||
|
||||
if($_POST)
|
||||
{
|
||||
a($_POST);die;
|
||||
$this->session->set('linkType', $_POST);
|
||||
|
||||
$response['result'] = 'success';
|
||||
$response['message'] = $this->lang->saveSuccess;
|
||||
$response['locate'] = $this->createLink('convert', 'initJiraUser', "type=$type");
|
||||
return print($this->send($response));
|
||||
}
|
||||
|
||||
if($type == 'db')
|
||||
{
|
||||
$this->convert->connectDB($dbName);
|
||||
$issueTypePairs = $this->convert->getIssueTypePairs();
|
||||
$linkTypePairs = $this->convert->getLinkTypePairs();
|
||||
$dbh = $this->convert->connectDB($dbName);
|
||||
|
||||
$issueTypePairs = $this->dao->dbh($dbh)->select('ID,pname')->from(JIRA_ISSUETYPE)->fetchPairs();
|
||||
$linkTypePairs = $this->dao->dbh($dbh)->select('ID,LINKNAME')->from(JIRA_ISSUELINKTYPE)->fetchPairs();
|
||||
$resolutions = $this->dao->dbh($dbh)->select('ID,pname')->from(JIRA_RESOLUTION)->fetchPairs();
|
||||
$statusList = $this->dao->dbh($dbh)->select('ID,pname')->from(JIRA_ISSUESTATUS)->fetchPairs();
|
||||
}
|
||||
|
||||
$this->view->title = $this->lang->convert->jira->mapJira2Zentao;
|
||||
$this->view->issueTypePairs = $issueTypePairs;
|
||||
$this->view->linkTypePairs = $linkTypePairs;
|
||||
$this->view->resolutions = $resolutions;
|
||||
$this->view->statusList = $statusList;
|
||||
$this->display();
|
||||
}
|
||||
|
||||
public function initJiraUser($type = 'db')
|
||||
{
|
||||
$this->app->loadLang('user');
|
||||
|
||||
if($_POST)
|
||||
{
|
||||
if(!$this->post->password1 || !$this->post->password2)
|
||||
{
|
||||
$response['result'] = 'fail';
|
||||
$response['message'] = $this->lang->convert->jira->passwordEmpty;
|
||||
return print($this->send($response));
|
||||
}
|
||||
|
||||
if($this->post->password1 != $this->post->password2)
|
||||
{
|
||||
$response['result'] = 'fail';
|
||||
$response['message'] = $this->lang->convert->jira->passwordDifferent;
|
||||
return print($this->send($response));
|
||||
}
|
||||
|
||||
$jiraUser['password'] = md5($this->post->password1);
|
||||
$jiraUser['group'] = $this->post->group;
|
||||
$this->session->set('jiraUser', $jiraUser);
|
||||
|
||||
$response['result'] = 'success';
|
||||
$response['message'] = $this->lang->saveSuccess;
|
||||
$response['locate'] = $this->createLink('convert', 'importJira', "type=$type");
|
||||
return print($this->send($response));
|
||||
}
|
||||
|
||||
$this->view->title = $this->lang->convert->jira->initJiraUser;
|
||||
$this->view->groups = $this->loadModel('group')->getPairs();
|
||||
$this->display();
|
||||
}
|
||||
|
||||
public function importJira($method = 'db', $type = 'user', $lastID = 0)
|
||||
{
|
||||
set_time_limit(0);
|
||||
|
||||
if($method = 'db')
|
||||
{
|
||||
if(helper::isAjaxRequest())
|
||||
{
|
||||
$result = $this->convert->importJiraFromDB($type, $lastID);
|
||||
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
if(isset($result['finished']) and $result['finished'])
|
||||
{
|
||||
return $this->send(array('result' => 'finished', 'message' => $this->lang->convert->jira->importSuccessfully));
|
||||
}
|
||||
else
|
||||
{
|
||||
$type = zget($this->lang->convert->jira->objectList, $result['type'], $result['type']);
|
||||
return $this->send(array('result' => 'unfinished', 'message' => sprintf($this->lang->convert->jira->importResult, $type, $type, $result['count']), 'type' => $type, 'count' => $result['count'], 'next' => inlink('importJira', "type={$result['type']}&lastID={$result['lastID']}") ));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//$this->convert->importJiraFromFile();
|
||||
}
|
||||
|
||||
$this->view->type = $type;
|
||||
$this->view->title = $this->lang->convert->jira->importJira;
|
||||
$this->display();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,22 +116,39 @@ $lang->convert->issue->zentao = '禅道';
|
||||
$lang->convert->issue->goto = '转换为';
|
||||
|
||||
$lang->convert->jira = new stdclass();
|
||||
$lang->convert->jira->method = '选择导入方式';
|
||||
$lang->convert->jira->next = '下一步';
|
||||
$lang->convert->jira->importFromDB = '从数据库导入';
|
||||
$lang->convert->jira->importFromFile = '从文件导入';
|
||||
$lang->convert->jira->mapJira2Zentao = '设置对应关系';
|
||||
$lang->convert->jira->dbNameNotice = '请输入Jira数据库名字';
|
||||
$lang->convert->jira->importNotice = '注意:导入数据有风险!请务必确保如下操作步骤依次完成,再进行合并。';
|
||||
$lang->convert->jira->dbDesc = '<p>如果您的Jira使用Mysql数据库, 请选择此方式</p>';
|
||||
$lang->convert->jira->fileDesc = '<p>如果您的Jira使用非Mysql数据库, 请选择此方式</p>';
|
||||
$lang->convert->jira->jiraObject = 'Jira Issues';
|
||||
$lang->convert->jira->zentaoObject = '禅道对象';
|
||||
$lang->convert->jira->jiraLinkType = 'Jira 关联关系';
|
||||
$lang->convert->jira->zentaoLinkType = '禅道关联关系';
|
||||
$lang->convert->jira->method = '选择导入方式';
|
||||
$lang->convert->jira->next = '下一步';
|
||||
$lang->convert->jira->importFromDB = '从数据库导入';
|
||||
$lang->convert->jira->importFromFile = '从文件导入';
|
||||
$lang->convert->jira->mapJira2Zentao = '设置对应关系';
|
||||
$lang->convert->jira->dbNameNotice = '请输入Jira数据库名字';
|
||||
$lang->convert->jira->importNotice = '注意:导入数据有风险!请务必确保如下操作步骤依次完成,再进行合并。';
|
||||
$lang->convert->jira->dbDesc = '<p>如果您的Jira使用Mysql数据库, 请选择此方式</p>';
|
||||
$lang->convert->jira->fileDesc = '<p>如果您的Jira使用非Mysql数据库, 请选择此方式</p>';
|
||||
$lang->convert->jira->jiraObject = 'Jira Issues';
|
||||
$lang->convert->jira->zentaoObject = '禅道对象';
|
||||
$lang->convert->jira->jiraLinkType = 'Jira 关联关系';
|
||||
$lang->convert->jira->zentaoLinkType = '禅道关联关系';
|
||||
$lang->convert->jira->jiraResolution = 'Jira 解决方案';
|
||||
$lang->convert->jira->zentaoResolution = '禅道Bug解决方案';
|
||||
$lang->convert->jira->zentaoReason = '禅道需求关闭原因';
|
||||
$lang->convert->jira->jiraStatus = 'Jira Issues 状态';
|
||||
$lang->convert->jira->storyStatus = '禅道需求状态';
|
||||
$lang->convert->jira->storyStage = '禅道需求阶段';
|
||||
$lang->convert->jira->bugStatus = '禅道Bug状态';
|
||||
$lang->convert->jira->taskStatus = '禅道任务状态';
|
||||
$lang->convert->jira->initJiraUser = '设置Jira用户';
|
||||
$lang->convert->jira->importJira = '导入Jira';
|
||||
$lang->convert->jira->start = '开始导入';
|
||||
|
||||
$lang->convert->jira->dbNameEmpty = 'Jira数据库名字不能为空!';
|
||||
$lang->convert->jira->invalidDB = '无效的数据库名!';
|
||||
$lang->convert->jira->dbNameEmpty = 'Jira数据库名字不能为空!';
|
||||
$lang->convert->jira->invalidDB = '无效的数据库名!';
|
||||
$lang->convert->jira->passwordNotice = "<span class='text-red'>设置Jira用户导入到禅道后的默认密码,用户后续可以在禅道中自行修改密码。</span>";
|
||||
$lang->convert->jira->groupNotice = "<span class='text-red'>设置Jira用户导入到禅道后的默认权限分组。</span>";
|
||||
$lang->convert->jira->passwordDifferent = '两次密码不一致!';
|
||||
$lang->convert->jira->passwordEmpty = '密码不能为空!';
|
||||
$lang->convert->jira->importSuccessfully = 'Jira导入完成!';
|
||||
$lang->convert->jira->importResult = "导入 %s 数据, 已导入 <strong class='%scount'>%s</strong> 条记录;";
|
||||
|
||||
$lang->convert->jira->zentaoObjectList['task'] = '任务';
|
||||
$lang->convert->jira->zentaoObjectList['requirement'] = '用户需求';
|
||||
@@ -150,3 +167,10 @@ $lang->convert->jira->importSteps['db'][4] = "上述步骤完成后,请输
|
||||
$lang->convert->jira->importSteps['file'][1] = '备份禅道数据库,备份Jira数据库。';
|
||||
$lang->convert->jira->importSteps['file'][2] = '将Jira数据库导入到禅道使用的Mysql中,名字和禅道数据库区别开来。';
|
||||
$lang->convert->jira->importSteps['file'][3] = "将Jira附件目录放到 <strong class='text-red'>%s</strong> 下。";
|
||||
|
||||
$lang->convert->jira->objectList['user'] = '用户';
|
||||
$lang->convert->jira->objectList['project'] = '项目';
|
||||
$lang->convert->jira->objectList['issue'] = 'Issue';
|
||||
$lang->convert->jira->objectList['build'] = '版本';
|
||||
//$lang->convert->jira->objectList['relates'] = '关联关系';
|
||||
$lang->convert->jira->objectList['file'] = '附件';
|
||||
|
||||
@@ -94,13 +94,26 @@ class convertModel extends model
|
||||
$this->session->set('state', $state);
|
||||
}
|
||||
|
||||
public function getIssueTypePairs()
|
||||
public function importJiraFromDB($type = '', $lastID = 0)
|
||||
{
|
||||
return $this->dao->dbh($this->sourceDBH)->select('ID,pname')->from(JIRA_ISSUETYPE)->fetchPairs();
|
||||
$limit = 1000;
|
||||
$nextObject = false;
|
||||
if(empty($type)) $type = key($this->lang->convert->jira->objectList);
|
||||
|
||||
foreach($this->lang->convert->jira->objectList as $module => $moduleName)
|
||||
{
|
||||
if($module != $type and !$nextObject) continue;
|
||||
if($module == $type) $nextObject = true;
|
||||
|
||||
while(true)
|
||||
{
|
||||
$query = $this->buildQuery($module);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getLinkTypePairs()
|
||||
public function buildQuery($module)
|
||||
{
|
||||
return $this->dao->dbh($this->sourceDBH)->select('ID,LINKNAME')->from(JIRA_ISSUELINKTYPE)->fetchPairs();
|
||||
if($module == 'user')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<?php echo $lang->convert->jira->mapJira2Zentao;?>
|
||||
</h2>
|
||||
</div>
|
||||
<form class='main-form' method='post' target='hiddenwin'>
|
||||
<form class='main-form form-ajax' method='post'>
|
||||
<table class='table table-form'>
|
||||
<thead>
|
||||
<tr class='text-center'>
|
||||
@@ -27,8 +27,8 @@
|
||||
<tbody>
|
||||
<?php foreach($issueTypePairs as $id => $name):?>
|
||||
<tr>
|
||||
<td><?php echo html::select('jiraObjects[]', $issueTypePairs, $id, "class='form-control chosen'");?></td>
|
||||
<td><?php echo html::select('zentaoObjects[]', $lang->convert->jira->zentaoObjectList, '', "class='form-control chosen'");?></td>
|
||||
<td><?php echo html::select('jiraObject[]', $issueTypePairs, $id, "class='form-control chosen'");?></td>
|
||||
<td><?php echo html::select('zentaoObject[]', $lang->convert->jira->zentaoObjectList, '', "class='form-control chosen'");?></td>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
</tbody>
|
||||
@@ -44,14 +44,56 @@
|
||||
<tbody>
|
||||
<?php foreach($linkTypePairs as $id => $name):?>
|
||||
<tr>
|
||||
<td><?php echo html::select('jiraObjects[]', $linkTypePairs, $id, "class='form-control chosen'");?></td>
|
||||
<td><?php echo html::select('zentaoObjects[]', $lang->convert->jira->zentaoLinkTypeList, '', "class='form-control chosen'");?></td>
|
||||
<td><?php echo html::select('jiraLinkType[]', $linkTypePairs, $id, "class='form-control chosen'");?></td>
|
||||
<td><?php echo html::select('zentaoLinkType[]', $lang->convert->jira->zentaoLinkTypeList, '', "class='form-control chosen'");?></td>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
</tbody>
|
||||
</table>
|
||||
<hr />
|
||||
<table class='table table-form'>
|
||||
<thead>
|
||||
<tr class='text-center'>
|
||||
<th><?php echo $lang->convert->jira->jiraResolution;?></th>
|
||||
<th><?php echo $lang->convert->jira->zentaoResolution;?></th>
|
||||
<th><?php echo $lang->convert->jira->zentaoReason;?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach($resolutions as $id => $name):?>
|
||||
<tr>
|
||||
<td><?php echo html::select('jiraResolution[]', $resolutions, $id, "class='form-control chosen'");?></td>
|
||||
<td><?php echo html::select('zentaoResolution[]', $lang->bug->resolutionList, '', "class='form-control chosen'");?></td>
|
||||
<td><?php echo html::select('zentaoReason[]', $lang->story->reasonList, '', "class='form-control chosen'");?></td>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
</tbody>
|
||||
</table>
|
||||
<hr />
|
||||
<table class='table table-form'>
|
||||
<thead>
|
||||
<tr class='text-center'>
|
||||
<th><?php echo $lang->convert->jira->jiraStatus;?></th>
|
||||
<th><?php echo $lang->convert->jira->storyStatus;?></th>
|
||||
<th><?php echo $lang->convert->jira->storyStage;?></th>
|
||||
<th><?php echo $lang->convert->jira->taskStatus;?></th>
|
||||
<th><?php echo $lang->convert->jira->bugStatus;?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach($statusList as $id => $name):?>
|
||||
<tr>
|
||||
<td><?php echo html::select('jiraStatus[]', $statusList, $id, "class='form-control chosen'");?></td>
|
||||
<td><?php echo html::select('storyStatus[]', $lang->story->statusList, '', "class='form-control chosen'");?></td>
|
||||
<td><?php echo html::select('storyStage[]', $lang->story->stageList, '', "class='form-control chosen'");?></td>
|
||||
<td><?php echo html::select('taskStatus[]', $lang->task->statusList, '', "class='form-control chosen'");?></td>
|
||||
<td><?php echo html::select('bugStatus[]', $lang->bug->statusList, '', "class='form-control chosen'");?></td>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="2" class="text-center form-actions"><?php echo html::submitButton();?></td>
|
||||
<td colspan="5" class="text-center form-actions"><?php echo html::submitButton($lang->convert->jira->next);?></td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
|
||||
Reference in New Issue
Block a user