I'm trying to write a plugin module to show subtask comments in the screen for a parent issue. Here's what I've got so far:
public class SubtaskCommentsIssueTabPanel extends AbstractIssueTabPanel implements IssueTabPanel { private static final Logger log = LoggerFactory.getLogger(SubtaskCommentsIssueTabPanel.class); public List getActions(Issue issue, User remoteUser) { List<IssueAction> issueactions = new ArrayList(); Collection<Issue> subtasks = ComponentAccessor.getSubTaskManager().getSubTaskObjects(issue); for (Issue subtask : subtasks) { List<Comment> comments = ComponentAccessor.getCommentManager().getComments(subtask); for (Comment comment : comments) { issueactions.add(comment); } } return issueactions; } public boolean showPanel(Issue issue, User remoteUser) { return true; } }
This doesn't compile, because on line 16 I'm trying to add a Comment to a List<IssueAction>. If I return a List<Comment>, then nothing appears in the new tab.
How can I make this work? Admittedly I'm new to Java as well so this process has involved a lot of throwing stuff at the wall and seeing what sticks.
import com.opensymphony.workflow.WorkflowContext import com.atlassian.jira.issue.Issue import com.atlassian.jira.ComponentManager import com.atlassian.jira.event.issue.AbstractIssueEventListener import com.atlassian.jira.event.issue.IssueEvent import org.apache.log4j.Logger import static org.apache.log4j.Level.DEBUG import com.atlassian.jira.bc.issue.IssueService.UpdateValidationResult import com.atlassian.jira.bc.issue.IssueService.IssueResult import com.atlassian.jira.bc.issue.IssueService import com.atlassian.jira.bc.issue.IssueService.TransitionValidationResult import com.atlassian.jira.issue.IssueInputParametersImpl import com.atlassian.jira.issue.IssueInputParameters import com.atlassian.jira.util.ErrorCollection import com.atlassian.jira.issue.index.IssueIndexManager import java.sql.Timestamp import com.atlassian.jira.issue.comments.CommentManager import com.atlassian.crowd.embedded.api.User import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.user.ApplicationUser import java.text.DateFormat import java.util.Date import java.text.SimpleDateFormat class SummaryStatusDate extends AbstractIssueEventListener { Logger log = Logger.getLogger(SummaryStatusDate.class) @Override void workflowEvent(IssueEvent event) { log.setLevel(org.apache.log4j.Level.DEBUG) def field = event.getChangeLog().getRelated('ChildChangeItem').any{it.field.toString().equalsIgnoreCase("Summary Updated")} if (field){ SimpleDateFormat format2 = new SimpleDateFormat("dd/MMM/yy hh:mm aa") def today = format2.format((new Date())) Issue issue = event.getIssue() ApplicationUser user = ComponentAccessor.getJiraAuthenticationContext().getUser() ComponentManager componentManager = ComponentManager.getInstance() CommentManager commentManager = componentManager.getCommentManager() commentManager.create(issue, user, "Summary Status Updated on " + today , false) } } }
This may help.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.