PageRenderTime 56ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/src/main/java/com/onresolve/jira/groovy/canned/CannedScript.java

https://bitbucket.org/sorin/jira-plugin-intellij
Java | 80 lines | 14 code | 10 blank | 56 comment | 0 complexity | 732357ee63e4818997d89ac8c846ba80 MD5 | raw file
  1. package com.onresolve.jira.groovy.canned;
  2. import com.atlassian.jira.util.ErrorCollection;
  3. import java.util.List;
  4. import java.util.Map;
  5. /**
  6. *
  7. */
  8. public interface CannedScript {
  9. /**
  10. * Returns the human-readable name of the script, eg "Awesome Script"
  11. * @return name of the script
  12. */
  13. String getName();
  14. /**
  15. * Returns a longer description which is displayed under the script name.
  16. * The return value is printed as in, so you can include html tags. You will need to
  17. * escape anything that needs escaping
  18. * @return description of the script
  19. */
  20. String getDescription();
  21. /**
  22. * Returns a list of categories which determine where in the UI this script will be displayed.
  23. * Currently valid categories are: ["Condition", "Validator", "Function", 'ADMIN']
  24. * You must provide at least one of these strings, more than one is also OK
  25. * @return list of categories
  26. */
  27. List getCategories();
  28. /**
  29. * Return a list of parameters required to run this script.
  30. * Each parameter is a map, and should at a minimum have a Name and Label key.
  31. * Type can be one of list, radio, shorttext, mediumtext, text, checkboxes.
  32. * For list, radio and checkbox types the Values key should return a Map of key->value options
  33. * See the shipped scripts for more details.
  34. * @param params Currently selected parameters, to allow for a wizard-type interface
  35. * @return selected values
  36. */
  37. List<CannedScriptArg> getParameters(Map params);
  38. /**
  39. * This is run before the script is run for real, and is responsible for sanity checking
  40. * the input arguments. It should return an {@link ErrorCollection} with field-specific and/or
  41. * general errors.
  42. *
  43. * @param params User selected inputs
  44. * @param forPreview set when the user has clicked the Preview button, but not when run by the workflow engine
  45. * @return An {@link ErrorCollection} or null
  46. */
  47. ErrorCollection doValidate(Map params, boolean forPreview);
  48. /**
  49. * The actual function provided by the built-in script.
  50. * @param params Input arguments specified by the user
  51. * @return No specific requirements here, however Conditions should set passesCondition to
  52. * true/false appropriately. If the return has a key "output" then the value of this
  53. * is shown in the Admin panel
  54. */
  55. Map doScript(Map params);
  56. /**
  57. * This mis-named method is called when the user clicks Preview, and the output of this is used as
  58. * the workflow function representation.
  59. * @param params User selected inputs
  60. * @param forPreview True when using the Admin panel, false when being called from a workflow functions page
  61. * @return An HTML preview string, eg what the script would actually do if the user clicked Run.
  62. */
  63. String getDescription(Map params, boolean forPreview);
  64. /**
  65. * This is for wizard, or multi-step UIs. Have a look at the examples for usages.
  66. * @param params User selected inputs
  67. * @return true if no other inputs are required, false otherwise.
  68. */
  69. Boolean isFinalParamsPage(Map params);
  70. }