我正在为 Jira 编写一个插件,我需要添加自定义计算列以发布导航器。该列应显示要发布的最后评论。但在本专栏中的问题导航器值类似于“ClassName@123456”,而不是评论的正文。我应该怎么做才能将评论的正文返回到此列?
到目前为止的代码:
public class LastCommentField extends CalculatedCFType {
private CommentManager commentManager = null;
public LastCommentField(CommentManager commentManager) {
this.commentManager=commentManager;
}
public Object getValueFromIssue(CustomField field, Issue issue) {
Comment lastComment=null;
List<Comment> comments = commentManager.getComments(issue);
if(comments != null && !comments.isEmpty()) {
lastComment = (Comment)comments.get(comments.size() - 1);
}
return lastComment;
}
public String getStringFromSingularObject (Object object) {
return object.toString();
}
public Object getSingularObjectFromString(String value) {
return value;
}
}
最佳答案
此功能已存在于至少两个插件中,例如https://marketplace.atlassian.com/plugins/net.customware.jira.utils.customware-jira-utilities
但在上面的代码中,所使用的单一对象是一个注释对象,如 http://docs.atlassian.com/jira/4.4/com/atlassian/jira/issue/comments/Comment.html 中所述。 但你可能只想要一个字符串,所以试试
返回 lastComment.getBody();
关于java - Jira中的计算字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12562218/