* [task#140044,done,2h,0h] Fix import jira affects version error.
This commit is contained in:
@@ -13,6 +13,7 @@ define('JIRA_ACTION', '`jiraaction`');
|
||||
define('JIRA_NODEASSOCIATION', '`nodeassociation`');
|
||||
define('JIRA_FILE', '`fileattachment`');
|
||||
define('JIRA_FIXVERSION', '`fixversion`');
|
||||
define('JIRA_AFFECTSVERSION', '`affectsversion`');
|
||||
define('JIRA_PRIORITY', '`priority`');
|
||||
define('JIRA_WORKFLOW', '`jiraworkflows`');
|
||||
define('JIRA_WORKFLOWSCHEME', '`workflowscheme`');
|
||||
@@ -53,6 +54,7 @@ $config->convert->objectTables['status'] = JIRA_ISSUESTATUS;
|
||||
$config->convert->objectTables['action'] = JIRA_ACTION;
|
||||
$config->convert->objectTables['file'] = JIRA_FILE;
|
||||
$config->convert->objectTables['fixversion'] = JIRA_FIXVERSION;
|
||||
$config->convert->objectTables['affectsversion'] = JIRA_AFFECTSVERSION;
|
||||
$config->convert->objectTables['priority'] = JIRA_PRIORITY;
|
||||
$config->convert->objectTables['membership'] = JIRA_MEMBERSHIP;
|
||||
$config->convert->objectTables['projectroleactor'] = JIRA_PROJECTROLEACTOR;
|
||||
|
||||
@@ -187,7 +187,7 @@ class convertModel extends model
|
||||
{
|
||||
$dataList = $this->dao->dbh($this->sourceDBH)->select('*')->from($table)->limit($lastID, $limit)->fetchAll();
|
||||
}
|
||||
elseif($module == 'fixversion')
|
||||
elseif($module == 'fixversion' || $module == 'affectsversion')
|
||||
{
|
||||
$dataList = array();
|
||||
}
|
||||
@@ -285,12 +285,13 @@ class convertModel extends model
|
||||
if(empty($dataList)) return array();
|
||||
}
|
||||
|
||||
foreach($dataList as $key => $data)
|
||||
if(in_array($module, array_keys($this->config->convert->objectTables)))
|
||||
{
|
||||
if(!in_array($module, array_keys($this->config->convert->objectTables))) continue;
|
||||
|
||||
$buildFunction = 'build' . ucfirst($module) . 'Data';
|
||||
$dataList[$key] = $this->$buildFunction($data);
|
||||
foreach($dataList as $key => $data)
|
||||
{
|
||||
$buildFunction = 'build' . ucfirst($module) . 'Data';
|
||||
$dataList[$key] = $this->$buildFunction($data);
|
||||
}
|
||||
}
|
||||
|
||||
return $dataList;
|
||||
@@ -310,7 +311,7 @@ class convertModel extends model
|
||||
$file = $filePath . $fileName;
|
||||
$handle = fopen($file, "r");
|
||||
|
||||
$tagList = array('<Action' => '</Action>', '<Project' => '</Project>', '<Status' => '</Status>', '<Resolution' => '</Resolution>', '<User' => '</User>', '<Issue' => '</Issue>', '<ChangeGroup' => '</ChangeGroup>', '<ChangeItem' => '</ChangeItem>', '<IssueLink' => '</IssueLink>', '<IssueLinkType' => '</IssueLinkType>', '<FileAttachment' => '</FileattAchment>', '<Version' => '</Version>', '<IssueType' => '</IssueType>', '<NodeAssociation' => '</NodeAssociation>', '<ApplicationUser' => '</ApplicationUser>', '<FieldScreenLayoutItem' => '<FieldScreenLayoutItem>', '<Workflow' => '</Workflow>', '<WorkflowScheme' => '</WorkflowScheme>', '<FieldConfigSchemeIssueType' => '</FieldConfigSchemeIssueType>', '<FieldConfigScheme' => '</FieldConfigScheme>', '<CustomField' => '</CustomField>', '<CustomFieldOption' => '</CustomFieldOption>', '<CustomFieldValue' => '</CustomFieldValue>', '<OSPropertyEntry' => '</OSPropertyEntry>', '<Worklog' => '</Worklog>', '<AuditLog' => '</AuditLog>', '<Group' => '</Group>', '<Membership' => '</Membership>', '<ProjectRoleActor' => '</ProjectRoleActor>', '<Priority' => '</Priority>', '<ConfigurationContext' => '</ConfigurationContext>', '<OptionConfiguration' => '</OptionConfiguration>', '<FixVersion' => '</FixVersion>');
|
||||
$tagList = array('<Action' => '</Action>', '<Project' => '</Project>', '<Status' => '</Status>', '<Resolution' => '</Resolution>', '<User' => '</User>', '<Issue' => '</Issue>', '<ChangeGroup' => '</ChangeGroup>', '<ChangeItem' => '</ChangeItem>', '<IssueLink' => '</IssueLink>', '<IssueLinkType' => '</IssueLinkType>', '<FileAttachment' => '</FileattAchment>', '<Version' => '</Version>', '<IssueType' => '</IssueType>', '<NodeAssociation' => '</NodeAssociation>', '<ApplicationUser' => '</ApplicationUser>', '<FieldScreenLayoutItem' => '<FieldScreenLayoutItem>', '<Workflow' => '</Workflow>', '<WorkflowScheme' => '</WorkflowScheme>', '<FieldConfigSchemeIssueType' => '</FieldConfigSchemeIssueType>', '<FieldConfigScheme' => '</FieldConfigScheme>', '<CustomField' => '</CustomField>', '<CustomFieldOption' => '</CustomFieldOption>', '<CustomFieldValue' => '</CustomFieldValue>', '<OSPropertyEntry' => '</OSPropertyEntry>', '<Worklog' => '</Worklog>', '<AuditLog' => '</AuditLog>', '<Group' => '</Group>', '<Membership' => '</Membership>', '<ProjectRoleActor' => '</ProjectRoleActor>', '<Priority' => '</Priority>', '<ConfigurationContext' => '</ConfigurationContext>', '<OptionConfiguration' => '</OptionConfiguration>', '<FixVersion' => '</FixVersion>', '<AffectsVersion' => '</AffectsVersion>');
|
||||
|
||||
while(!feof($handle))
|
||||
{
|
||||
@@ -450,7 +451,7 @@ EOT;
|
||||
*/
|
||||
public function deleteJiraFile(): void
|
||||
{
|
||||
$fileList = array('action', 'project', 'status', 'resolution', 'user', 'issue', 'changegroup', 'changeitem', 'issuelink', 'issuelinktype', 'fileattachment', 'version', 'issuetype', 'nodeassociation', 'applicationuser', 'fieldscreenlayoutitem', 'workflow', 'workflowscheme', 'fieldconfigscheme', 'fieldconfigschemeissuetype', 'customfield', 'customfieldoption', 'customfieldvalue', 'ospropertyentry', 'worklog', 'auditlog', 'group', 'membership', 'projectroleactor', 'priority', 'configurationcontext', 'optionconfiguration', 'fixversion');
|
||||
$fileList = array('action', 'project', 'status', 'resolution', 'user', 'issue', 'changegroup', 'changeitem', 'issuelink', 'issuelinktype', 'fileattachment', 'version', 'issuetype', 'nodeassociation', 'applicationuser', 'fieldscreenlayoutitem', 'workflow', 'workflowscheme', 'fieldconfigscheme', 'fieldconfigschemeissuetype', 'customfield', 'customfieldoption', 'customfieldvalue', 'ospropertyentry', 'worklog', 'auditlog', 'group', 'membership', 'projectroleactor', 'priority', 'configurationcontext', 'optionconfiguration', 'fixversion', 'affectsversion');
|
||||
foreach($fileList as $fileName)
|
||||
{
|
||||
$filePath = $this->app->getTmpRoot() . 'jirafile/' . $fileName . '.xml';
|
||||
|
||||
+44
-20
@@ -626,6 +626,23 @@ class convertTao extends convertModel
|
||||
return $fixVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建影响版本数据。
|
||||
* Build affects version data.
|
||||
*
|
||||
* @param array $data
|
||||
* @access protected
|
||||
* @return object
|
||||
*/
|
||||
protected function buildAffectsVersionData(array $data): object
|
||||
{
|
||||
$affectsVersion = new stdclass();
|
||||
$affectsVersion->issue = $data['issue'];
|
||||
$affectsVersion->version = $data['version'];
|
||||
|
||||
return $affectsVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Jira事务与禅道数据的关联关系。
|
||||
* Get Jira issue and ZenTao object links.
|
||||
@@ -892,6 +909,7 @@ class convertTao extends convertModel
|
||||
$versionGroup = array();
|
||||
$nodeassociation = $this->getJiraData($this->session->jiraMethod, 'nodeassociation');
|
||||
$fixVersion = $this->getJiraData($this->session->jiraMethod, 'fixversion');
|
||||
$affectsVersion = $this->getJiraData($this->session->jiraMethod, 'affectsversion');
|
||||
foreach($nodeassociation as $node)
|
||||
{
|
||||
foreach($node as $key => $value)
|
||||
@@ -917,6 +935,14 @@ class convertTao extends convertModel
|
||||
$data->relation = 'IssueFixVersion';
|
||||
$versionGroup[$version->version][] = $data;
|
||||
}
|
||||
foreach($affectsVersion as $version)
|
||||
{
|
||||
$data = new stdClass();
|
||||
$data->versionid = $version->version;
|
||||
$data->issueid = $version->issue;
|
||||
$data->relation = 'IssueVersion';
|
||||
$versionGroup[$version->version][] = $data;
|
||||
}
|
||||
|
||||
$versionRelation = $this->dao->dbh($this->dbh)->select('*')->from(JIRA_TMPRELATION)->where('AType')->eq('jversion')->fetchAll('AID');
|
||||
foreach($dataList as $data)
|
||||
@@ -1921,27 +1947,22 @@ class convertTao extends convertModel
|
||||
$issueType = zget($issueList[$issueID], 'BType', '');
|
||||
if(!$issueType || ($issueType != 'zstory' && $issueType != 'zbug')) continue;
|
||||
|
||||
if($issueType == 'zstory')
|
||||
if($issue->relation == 'IssueFixVersion')
|
||||
{
|
||||
$this->dao->dbh($this->dbh)->update(TABLE_BUILD)->set("stories = IF(stories IS NOT NULL, CONCAT(stories, ',$objectID'), '{$objectID}')")->where('id')->eq($buildID)->exec();
|
||||
}
|
||||
if($issueType == 'zbug')
|
||||
{
|
||||
$this->dao->dbh($this->dbh)->update(TABLE_BUILD)->set("bugs = IF(bugs IS NOT NULL, CONCAT(bugs, ',$objectID'), {$objectID})")->where('id')->eq($buildID)->exec();
|
||||
if(!isset($issue->relation)) continue;
|
||||
|
||||
if($issue->relation == 'IssueVersion')
|
||||
if($issueType == 'zstory')
|
||||
{
|
||||
$openBuilds = $this->dao->dbh($this->dbh)->select('openedBuild')->from(TABLE_BUG)->where('id')->eq($objectID)->fetch('openedBuild');
|
||||
$openBuilds = explode(',', str_replace('trunk', '', $openBuilds));
|
||||
$openBuilds[] = $buildID;
|
||||
$this->dao->dbh($this->dbh)->update(TABLE_BUG)->set('openedBuild')->eq(implode(',', array_filter(array_unique($openBuilds))))->where('id')->eq($objectID)->exec();
|
||||
$this->dao->dbh($this->dbh)->update(TABLE_BUILD)->set("`stories` = IF(`stories` IS NOT NULL, CONCAT(`stories`, ',$objectID'), '{$objectID}')")->where('id')->eq($buildID)->exec();
|
||||
}
|
||||
elseif($issue->relation == 'IssueFixVersion')
|
||||
if($issueType == 'zbug')
|
||||
{
|
||||
$this->dao->dbh($this->dbh)->update(TABLE_BUILD)->set("`bugs` = IF(`bugs` IS NOT NULL, CONCAT(`bugs`, ',$objectID'), {$objectID})")->where('id')->eq($buildID)->exec();
|
||||
$this->dao->dbh($this->dbh)->update(TABLE_BUG)->set('resolvedBuild')->eq($buildID)->where('id')->eq($objectID)->exec();
|
||||
}
|
||||
}
|
||||
if($issue->relation == 'IssueVersion' && $issueType == 'zbug')
|
||||
{
|
||||
$this->dao->dbh($this->dbh)->update(TABLE_BUG)->set("`openedBuild` = IF(`openedBuild` = 'trunk', $buildID, CONCAT(`openedBuild`, ',$buildID'))")->where('id')->eq($objectID)->exec();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1991,13 +2012,16 @@ class convertTao extends convertModel
|
||||
$issueType = zget($issueList[$issueID], 'BType', '');
|
||||
if(!$issueType || ($issueType != 'zstory' && $issueType != 'zbug')) continue;
|
||||
|
||||
if($issueType == 'zstory')
|
||||
if($issue->relation == 'IssueFixVersion')
|
||||
{
|
||||
$this->dao->dbh($this->dbh)->update(TABLE_RELEASE)->set("stories = IF(stories IS NOT NULL, CONCAT(stories, ',$objectID'), '{$objectID}')")->where('id')->eq($releaseID)->exec();
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->dao->dbh($this->dbh)->update(TABLE_RELEASE)->set("bugs = IF(bugs IS NOT NULL, CONCAT(bugs, ',$objectID'), '{$objectID}')")->where('id')->eq($releaseID)->exec();
|
||||
if($issueType == 'zstory')
|
||||
{
|
||||
$this->dao->dbh($this->dbh)->update(TABLE_RELEASE)->set("stories = IF(stories IS NOT NULL, CONCAT(stories, ',$objectID'), '{$objectID}')")->where('id')->eq($releaseID)->exec();
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->dao->dbh($this->dbh)->update(TABLE_RELEASE)->set("bugs = IF(bugs IS NOT NULL, CONCAT(bugs, ',$objectID'), '{$objectID}')")->where('id')->eq($releaseID)->exec();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user