Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2020
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.65 KB | None | 0 0
  1. import com.atlassian.jira.component.ComponentAccessor
  2. import com.atlassian.jira.user.ApplicationUser
  3. import com.atlassian.jira.issue.fields.config.FieldConfig
  4. import com.atlassian.jira.issue.customfields.option.LazyLoadedOption
  5. import com.atlassian.jira.issue.customfields.option.OptionsImpl
  6. import java.text.SimpleDateFormat
  7. import org.apache.log4j.Level
  8. import org.apache.log4j.Logger
  9. log = Logger.getLogger("com.tvpro.CreateIssue")
  10. log.setLevel(Level.DEBUG)
  11.  
  12. def locale = ComponentAccessor.applicationProperties.defaultLocale
  13. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd/MMM/yy HH:mm", locale)
  14. def linkMgr = ComponentAccessor.getIssueLinkManager()
  15. def issue = ComponentAccessor.getIssueManager().getIssueByCurrentKey("PP1-18842")
  16. def customField = ComponentAccessor.customFieldManager.getCustomFieldObject("customfield_11601")
  17. def dataVihodaEfira = ComponentAccessor.customFieldManager.getCustomFieldObject("customfield_11504") //Дата выхода рубрики в эфир
  18. def dataVihodaEfiraValue = simpleDateFormat.format(dataVihodaEfira.getValue(issue))
  19. log.debug("Дата выхода рубрики в эфир: " + dataVihodaEfiraValue)
  20.  
  21. def rubrika = ComponentAccessor.customFieldManager.getCustomFieldObject("customfield_10501") //Рубрика
  22. def rubrikaValue = rubrika.getValue(issue)?.optionId
  23. log.debug("Рубрика: " + rubrikaValue)
  24.  
  25. def znachimost = ComponentAccessor.customFieldManager.getCustomFieldObject("customfield_11508") //Значимость
  26. def znachimostValue = znachimost.getValue(issue)?.optionId
  27. log.debug("Значимость: " + znachimostValue)
  28.  
  29. def graficaDescription = ComponentAccessor.customFieldManager.getCustomFieldObject("customfield_11502") // Графика - описание идеи/расписание
  30. def graficaDescriptionValue = graficaDescription.getValue(issue)
  31. log.debug("Графика - описание идеи/расписание: " + graficaDescriptionValue)
  32.  
  33. def valueCF = customField.getValue(issue)*.value
  34. if ("Моушен" in valueCF) {
  35.  
  36. def issueTypeName = "Оперативная графика"
  37. //def summary = "Groovy Sunday 4"
  38. def issueService = ComponentAccessor.issueService
  39. def constantsManager = ComponentAccessor.constantsManager
  40. def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
  41. def projectId = ComponentAccessor.projectManager.getProjectByCurrentKey("SDTEST")
  42. log.debug(projectId.getId())
  43. def issueType = constantsManager.allIssueTypeObjects.findByName(issueTypeName)
  44. log.debug(issueType.id)
  45. def reporter = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
  46. log.debug(reporter.getKey())
  47. def priority = constantsManager.priorities.findByName("Major") ?: constantsManager.defaultPriority
  48. log.debug(priority.id)
  49. def issueInputParameters = issueService.newIssueInputParameters().with {
  50. setProjectId(projectId.getId())
  51. setIssueTypeId(issueType.id)
  52. setReporterId(reporter.getKey())
  53. setSummary(issue.summary)
  54. setPriorityId(priority.id)
  55. setDescription(graficaDescriptionValue)
  56. addCustomFieldValue("customfield_11504", dataVihodaEfiraValue)
  57. addCustomFieldValue("customfield_10501", rubrikaValue)
  58. addCustomFieldValue("customfield_11508", znachimostValue)
  59. //addCustomFieldValue("customfield_13503", "Шаблоны")
  60.  
  61. }
  62. def validationResult = issueService.validateCreate(loggedInUser, issueInputParameters)
  63. log.debug(validationResult.errorCollection)
  64. def result = issueService.create(loggedInUser, validationResult)
  65. log.debug(result.issue.id)
  66. linkMgr.createIssueLink(issue.id, result.issue.id, 10000, 1, loggedInUser)
  67.  
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement