SHARE
TWEET

Untitled

a guest Mar 26th, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import com.atlassian.jira.component.ComponentAccessor
  2. import groovy.sql.Sql
  3. import java.sql.Connection
  4. import org.ofbiz.core.entity.ConnectionFactory
  5. import org.ofbiz.core.entity.DelegatorInterface
  6. import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
  7. import com.atlassian.jira.event.type.EventDispatchOption
  8. import com.atlassian.jira.issue.ModifiedValue
  9. import com.atlassian.jira.issue.Issue
  10. import com.atlassian.jira.issue.MutableIssue
  11.  
  12. def issue = ComponentAccessor.getIssueManager().getIssueObject('TII-840')
  13. log.debug ("ID задачи: " + issue.id)
  14. def delegator = (DelegatorInterface) ComponentAccessor.getComponent(DelegatorInterface)
  15. String helperName = delegator.getGroupHelperName("default")
  16. def issueId = issue.id
  17. def changeHolder = new DefaultIssueChangeHolder()
  18. int result
  19. def sqlStmt = """
  20.     SELECT SUM("SECONDS_PER_DAY") as val
  21.     FROM public."AO_2D3BEA_PLAN_ALLOCATION"
  22.     WHERE "PLAN_ITEM_ID" = $issueId;
  23. """
  24.  
  25. Connection conn = ConnectionFactory.getConnection(helperName)
  26. Sql sql = new Sql(conn)
  27. try {
  28.     StringBuffer sb = new StringBuffer()
  29.     sql.eachRow(sqlStmt) {
  30.         result =it.val
  31.     }
  32.     log.debug ("Сумма запланированного времени в секундах: " + result)
  33. }
  34. finally {
  35.     sql.close()
  36. }
  37.  
  38. int hours=result/3600
  39. int minutes=result%3600/60
  40. log.debug ("Получаем часы: " + hours)
  41. log.debug ("Получаем минуты: " + minutes)
  42.  
  43. def issueManager = ComponentAccessor.getIssueManager()
  44. def user =  ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();
  45. issue.setOriginalEstimate(hours)
  46. issueManager.updateIssue(user,issue, EventDispatchOption.ISSUE_UPDATED,false)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top