PageRenderTime 48ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/src/test/resources/examples/BlockedOnScriptedField.groovy

https://bitbucket.org/sorin/jira-plugin-intellij
Groovy | 49 lines | 40 code | 8 blank | 1 comment | 6 complexity | 02d6547c3021ecbee138d1216f448779 MD5 | raw file
  1. package examples
  2. import com.atlassian.jira.ComponentManager
  3. import groovy.xml.MarkupBuilder
  4. import com.atlassian.jira.issue.Issue
  5. import com.atlassian.jira.ManagerFactory
  6. import com.atlassian.jira.config.properties.APKeys
  7. def componentManager = ComponentManager.getInstance()
  8. def issueLinkManager = componentManager.getIssueLinkManager()
  9. def baseUrl = ManagerFactory.getApplicationProperties().getString(APKeys.JIRA_BASEURL)
  10. // def issue = componentManager.getIssueManager().getIssueObject("JRA-1056")
  11. def List<Issue> blockingIssues = []
  12. issueLinkManager.getOutwardLinks(issue.id).each {issueLink ->
  13. if (issueLink.issueLinkType.name == "Depends") {
  14. def linkedIssue = issueLink.destinationObject
  15. if (!linkedIssue.assigneeId && !linkedIssue.resolution) {
  16. blockingIssues.add(linkedIssue)
  17. }
  18. }
  19. }
  20. if (blockingIssues) {
  21. StringWriter writer = new StringWriter()
  22. MarkupBuilder builder = new MarkupBuilder(writer)
  23. builder.div (class:"aui-message error shadowed") {
  24. p (class: "title") {
  25. span (class: "aui-icon icon-error", "")
  26. strong ("This issue is dependent on the following unresolved, unassigned issue(s):")
  27. }
  28. ul {
  29. blockingIssues.each {anIssue ->
  30. li {
  31. a(href:"$baseUrl/browse/${anIssue.key}", anIssue.key)
  32. i(": ${anIssue.summary} (${anIssue.statusObject.name})")
  33. }
  34. }
  35. }
  36. }
  37. return writer
  38. }
  39. else {
  40. return null
  41. }