本文介绍了JIRA Plugins SDK:如何查找更改的数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用JIRA插件sdk处理已更改的问题.
I am using the JIRA plugins sdk to work on changed Issues.
我已经实现了IssueListener,并且可以访问Issue本身和IssueEvent.
I´ve implemented an IssueListener and I have access to the Issue itself and the IssueEvent.
我如何找出我的问题的哪个属性(摘要,描述,估计...)?
推荐答案
更改日志可能包含已更改的内容,并且IssueEvent对象上有一个方法来获取此更改(getChangeLog
),并且它返回 GenericValue 对象.
The changelog is likely to contain what's been changed and there is a method on the IssueEvent object to get this (getChangeLog
) and it returns a GenericValue object.
这篇文章提供了一些代码与如何编写JIRA事件监听器.
相关代码段如下所示:
if (eventTypeId.equals(EventType.ISSUE_UPDATED_ID)) {
List<GenericValue> changeItems = null;
try {
GenericValue changeLog = issueEvent.getChangeLog();
changeItems = changeLog.internalDelegator.findByAnd("ChangeItem", EasyMap.build("group",changeLog.get("id")));
} catch (GenericEntityException e){
System.out.println(e.getMessage());
}
log.info("number of changes: {}",changeItems.size());
for (Iterator<GenericValue> iterator = changeItems.iterator(); iterator.hasNext();){
GenericValue changetemp = (GenericValue) iterator.next();
String field = changetemp.getString("field");
String oldstring = changetemp.getString("oldstring");
String newstring = changetemp.getString("newstring");
StringBuilder fullstring = new StringBuilder();
fullstring.append("Issue ");
fullstring.append(issue.getKey());
fullstring.append(" field ");
fullstring.append(field);
fullstring.append(" has been updated from ");
fullstring.append(oldstring);
fullstring.append(" to ");
fullstring.append(newstring);
log.info("changes {}", fullstring.toString());
/* Do something here if a particular field you are
looking for has being changed.
*/
if(field == "Component") changeAssignee(changetemp, issue, user);
}
}
这篇关于JIRA Plugins SDK:如何查找更改的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!