Advertisement
Guest User

Untitled

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