Advertisement
Guest User

Untitled

a guest
Mar 4th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 2.74 KB | None | 0 0
  1. import com.atlassian.jira.component.ComponentAccessor
  2. import com.atlassian.jira.issue.MutableIssue
  3. import com.atlassian.jira.event.type.EventDispatchOption
  4. import com.atlassian.jira.issue.CustomFieldManager
  5. import com.atlassian.jira.issue.fields.CustomField
  6. import com.atlassian.jira.bc.issue.search.SearchService
  7. import com.atlassian.jira.web.bean.PagerFilter
  8. import org.apache.log4j.Category
  9.    
  10.    
  11. // Logs
  12.    
  13. Category log = log
  14. log.setLevel(org.apache.log4j.Level.DEBUG)
  15.    
  16.    
  17.    
  18.    
  19. // Manager
  20.    
  21. CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
  22. def issueManager = ComponentAccessor.getIssueManager()
  23. def currentKey = issue.getKey()
  24.    
  25.    
  26.    
  27.    
  28. // Constants
  29.    
  30. List<MutableIssue> listIssue = new ArrayList<MutableIssue>()
  31. def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
  32. SearchService searchService = ComponentAccessor.getComponent(SearchService.class)
  33. def jqlSearch = "issueFunction in parentsOf('issuekey = " + currentKey + "')"
  34. SearchService.ParseResult parseResult =  searchService.parseQuery(user, jqlSearch)
  35.    
  36.    
  37.    
  38. // Treatment
  39.  
  40. if (parseResult.isValid()) {
  41.     def searchResult = searchService.search(user, parseResult.getQuery(), PagerFilter.getUnlimitedFilter())
  42.     def jqlIssue = searchResult.issues.collect {issueManager.getIssueObject(it.id)}
  43.     for(MutableIssue issueSearch : jqlIssue){
  44.         log.debug("issue: " + issueSearch.getKey())
  45.         String currentIssue = issueSearch
  46.         listIssue.add(issueSearch)
  47.     }
  48. }
  49. else {
  50.     log.error("Invalid JQL: " + jqlSearch)
  51. }
  52.  
  53.  
  54. def actionPlan = listIssue[0]
  55.  
  56.  
  57. // Constants
  58.    
  59. List<MutableIssue> listIssueTopRisk = new ArrayList<MutableIssue>()
  60. def jqlSearchTopRisk = "issue in linkedissues(" + actionPlan + ")"
  61. SearchService.ParseResult parseResultTopRisk =  searchService.parseQuery(user, jqlSearchTopRisk)
  62.    
  63.    
  64.    
  65. // Treatment
  66.  
  67. if (parseResult.isValid()) {
  68.     def searchResult = searchService.search(user, parseResultTopRisk.getQuery(), PagerFilter.getUnlimitedFilter())
  69.     def jqlIssue = searchResult.issues.collect {issueManager.getIssueObject(it.id)}
  70.     for(MutableIssue issueSearch : jqlIssue){
  71.         log.debug("issue: " + issueSearch.getKey())
  72.         String currentIssue = issueSearch
  73.         listIssueTopRisk.add(issueSearch)
  74.     }
  75. }
  76. else {
  77.     log.error("Invalid JQL: " + jqlSearch)
  78. }
  79.  
  80. def topRisk = listIssueTopRisk[0]
  81. def topRiskAddress = "<a href=\"http://localhost:8080/browse/" + topRisk + "\">" + topRisk + "</a>"
  82. def summary = topRisk.getSummary()
  83. def avatar = "<img src='/secure/viewavatar?size=xsmall&amp;avatarId=10304&amp;avatarType=issuetype'/>"
  84.  
  85. def toRet = ""
  86. toRet = avatar + " " + topRiskAddress + " " + summary
  87.  
  88. return toRet
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement