[转]Dynamic Forms

本文转自:https://scriptrunner.adaptavist.com/6.5.0/jira/dynamic-forms.html

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.search.SearchProvider
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.web.bean.PagerFilter
import com.onresolve.scriptrunner.parameters.annotation.UserPicker

@UserPicker(label = "Assignee", description = "Issues with this assignee will be permanently deleted")
ApplicationUser user

// issues returned from that JQL will get deleted
final String searchQuery = "assignee = $user.name"

def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser)
def searchProvider = ComponentAccessor.getComponent(SearchProvider)
def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def issueService = ComponentAccessor.issueService
def query = jqlQueryParser.parseQuery(searchQuery)
def searchResults = searchProvider.search(query, loggedInUser, PagerFilter.unlimitedFilter)

searchResults.getIssues().each { issue ->
    def deleteValidationResult = issueService.validateDelete(loggedInUser, issue.id)
    assert deleteValidationResult.isValid() : deleteValidationResult.errorCollection

    def deleteResult = issueService.delete(loggedInUser, deleteValidationResult)
    assert deleteResult
}

 

 

https://docs.atlassian.com/software/jira/docs/api/7.6.1/com/atlassian/jira/bc/issue/IssueService.html

 

上一篇:Hadoop-常用端口


下一篇:基于MVC4+EasyUI的Web开发框架形成之旅--界面控件的使用