PageRenderTime 45ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/src/main/resources/com/onresolve/jira/groovy/canned/workflow/postfunctions/TestPostfunction.groovy

https://bitbucket.org/sorin/jira-plugin-intellij
Groovy | 70 lines | 56 code | 13 blank | 1 comment | 3 complexity | a0defda769f2017804d830198a32e80c MD5 | raw file
  1. package com.onresolve.jira.groovy.canned.workflow.postfunctions
  2. import com.atlassian.jira.ComponentManager
  3. import com.atlassian.jira.util.ErrorCollection
  4. import com.atlassian.jira.util.SimpleErrorCollection
  5. import com.onresolve.jira.groovy.canned.CannedScript
  6. import org.apache.log4j.Category
  7. class TestPostfunction implements CannedScript{
  8. ComponentManager componentManager = ComponentManager.getInstance()
  9. Category log = Category.getInstance(TestPostfunction.class)
  10. def projectManager = componentManager.getProjectManager()
  11. String getName() {
  12. return "Sample postfunction"
  13. }
  14. String getDescription() {
  15. return "A postfunction used for testing with some <b>html</b>"
  16. }
  17. List getCategories() {
  18. ["Function"]
  19. }
  20. List getParameters(Map params) {
  21. [
  22. [
  23. Name:"ProjectKey",
  24. Description:"Project key, ie one of " + componentManager.getProjectManager().getProjects()*.get("key"),
  25. ],
  26. [
  27. Name:"User",
  28. Description:"A user ID",
  29. ],
  30. ]
  31. }
  32. public ErrorCollection doValidate(Map params, boolean forPreview) {
  33. ErrorCollection errorCollection = new SimpleErrorCollection();
  34. Object projectKey = params["ProjectKey"]
  35. if (!projectKey) {
  36. errorCollection.addError "ProjectKey", "You must enter a project key"
  37. }
  38. else if (! projectManager.getProjectObjByKey(projectKey as String)) {
  39. errorCollection.addError "ProjectKey", "Project with key \"$projectKey\" not found"
  40. }
  41. errorCollection
  42. }
  43. Map doScript(Map params) {
  44. log.debug ("TestCondition.doScript with params: ${params}");
  45. log.debug ("project key: ${params['ProjectKey']}")
  46. return params
  47. }
  48. String getDescription(Map params, boolean forPreview) {
  49. String projectKey = params['ProjectKey']
  50. // def projectName = componentManager.getProjectManager().getProjectObjByKey(projectKey)?.getName() ?: "(Project not found)"
  51. def projectName = "Some project"
  52. getName() + " : This is what the user sees when the args are validated OK - project <b>$projectName</b> will be checked. <b>Postfunction</b>"
  53. }
  54. public Boolean isFinalParamsPage(Map params) {
  55. true
  56. }
  57. }