/src/main/resources/com/onresolve/jira/groovy/canned/workflow/conditions/TestCondition.groovy
Groovy | 71 lines | 57 code | 13 blank | 1 comment | 3 complexity | 6e597c7bdc79292034576fc737b0a83f MD5 | raw file
- package com.onresolve.jira.groovy.canned.workflow.conditions
-
- import com.onresolve.jira.groovy.canned.CannedScript
- import com.atlassian.jira.ComponentManager
- import org.apache.log4j.Category
-
- import com.atlassian.jira.util.ErrorCollection
- import com.atlassian.jira.util.SimpleErrorCollection
-
- class TestCondition implements CannedScript{
-
- ComponentManager componentManager = ComponentManager.getInstance()
- Category log = Category.getInstance(TestCondition.class)
- def projectManager = componentManager.getProjectManager()
-
- String getName() {
- return "Sample condition"
- }
-
- String getDescription() {
- return "A condition used for testing with some <b>html</b>"
- }
-
- List getCategories() {
- ["Condition"]
- }
-
- List getParameters(Map params) {
- [
- [
- Name:"ProjectKey",
- Description:"Project key, ie one of " + componentManager.getProjectManager().getProjects()*.get("key"),
- ],
- [
- Name:"User",
- Description:"A user ID",
- ],
- ]
-
- }
-
- public ErrorCollection doValidate(Map params, boolean forPreview) {
- ErrorCollection errorCollection = new SimpleErrorCollection();
- Object projectKey = params["ProjectKey"]
- if (!projectKey) {
- errorCollection.addError "ProjectKey", "You must enter a project key"
- }
- else if (! projectManager.getProjectObjByKey(projectKey as String)) {
- errorCollection.addError "ProjectKey", "Project with key \"$projectKey\" not found"
- }
- errorCollection
- }
-
- Map doScript(Map params) {
- log.debug ("TestCondition.doScript with params: ${params}");
- log.debug ("project key: ${params['ProjectKey']}")
- params['passesCondition'] = true
- return params
- }
-
- String getDescription(Map params, boolean forPreview) {
- String projectKey = params['ProjectKey']
- def projectName = componentManager.getProjectManager().getProjectObjByKey(projectKey)?.getName() ?: "(Project not found)"
- // def projectName = "Some project"
- getName() + " : This is what the user sees when the args are validated OK - project <b>$projectName</b> will be checked"
- }
-
- public Boolean isFinalParamsPage(Map params) {
- true
- }
- }