Created
March 29, 2014 20:09
-
-
Save jechlin/9861951 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package examples.docs | |
import com.almworks.jira.structure.api.PermissionLevel | |
import com.almworks.jira.structure.api.StructureServices | |
import com.atlassian.jira.component.ComponentAccessor | |
import com.atlassian.jira.issue.Issue | |
import com.onresolve.scriptrunner.runner.customisers.PluginModule | |
import com.onresolve.scriptrunner.runner.customisers.WithPlugin | |
@WithPlugin("com.almworks.jira.structure") | |
// Inject plugin module | |
@PluginModule | |
StructureServices structureServices | |
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser() | |
def issueManager = ComponentAccessor.getIssueManager() | |
//noinspection GroovyVariableNotAssigned | |
def structureManager = structureServices.getStructureManager() | |
Issue myIssue | |
if (! binding.hasVariable("issue")) { | |
log.warn ("No issue in context, presume running in console") | |
myIssue = issueManager.getIssueObject("GRV-90") | |
} | |
else { | |
myIssue = issue | |
} | |
def query = structureServices.getStructureQueryParser().parse("descendants of ${myIssue.key} and [resolution is empty]") | |
def structures = structureManager.getStructuresWithIssue(myIssue.id, user, PermissionLevel.VIEW, true) | |
passesCondition = structures.every {structure -> | |
def forest = structure.getForest(user, true) | |
def childrenClosedForStructure = query.executeIds(forest, user, false).isEmpty() | |
log.debug("All children closed for structure: ${structure.name}: $childrenClosedForStructure") | |
childrenClosedForStructure | |
} | |
log.debug("passesCondition: $passesCondition") | |
passesCondition |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment