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

/examples/bootsy/src/Bootsy/Jira/JiraService.boo

http://concurrent-boo.googlecode.com/
Boo | 88 lines | 62 code | 26 blank | 0 comment | 9 complexity | 049148a986aa25b207f6b6b4915fc3df MD5 | raw file
Possible License(s): CC-BY-3.0
  1. namespace Bootsy.Jira
  2. import System
  3. import Bootsy.Jira.RPC
  4. class JiraService(IJiraService):
  5. private static final AuthCookieKey = object()
  6. private static final ResolutionsKey = object()
  7. private static final TopTicketsKey = object()
  8. [getter(SoapService)]
  9. private final _jira = JiraSoapServiceService()
  10. private final _cache = ConcurrentBoo.ComputationCache()
  11. private final _configuration as IJiraServiceConfiguration
  12. def constructor([required] configuration as IJiraServiceConfiguration):
  13. _configuration = configuration
  14. def SearchIssues(terms as string):
  15. return _jira.getIssuesFromTextSearch(GetAuthCookie(), terms)
  16. def GetProgressReport():
  17. return GetIssuesFromFilter("10221")
  18. def GetTop(count as int):
  19. return array(issue.Value as RemoteIssue for issue in GetTop_(count))
  20. def GetTop_(count as int):
  21. return array(GetIssue_(ticket) for ticket in GetTopTickets()[:count])
  22. def GetIssue(ticket as string) as RemoteIssue:
  23. return GetIssue_(ticket).Value
  24. def GetIssuesFromFilter(filterId as string) as (RemoteIssue):
  25. return GetIssuesFromFilter_(filterId).Value
  26. def GetIssuesFromFilter_(filterId as string):
  27. return _cache.Get(filterId, { _jira.getIssuesFromFilter(GetAuthCookie(), filterId) })
  28. def GetIssue_(ticket as string):
  29. return _cache.Get(ticket, { _jira.getIssue(GetAuthCookie(), ticket) })
  30. def GetResolutionName(id as string):
  31. if id is null: return "Open"
  32. resolution = GetResolution(id)
  33. if resolution is null: return "Open"
  34. return resolution.name
  35. def GetResolution(id as string):
  36. for r in GetResolutions():
  37. if r.id == id: return r
  38. def GetResolutions() as (RemoteResolution):
  39. return GetResolutions_().Value
  40. def GetResolutions_():
  41. return _cache.Get(ResolutionsKey, { _jira.getResolutions(GetAuthCookie()) })
  42. def GetAuthCookie() as string:
  43. return GetAuthCookie_().Value
  44. def GetAuthCookie_():
  45. return _cache.Get(AuthCookieKey, { _jira.login(_configuration.Login, _configuration.Password) })
  46. def GetSavedFilters():
  47. return _jira.getSavedFilters(GetAuthCookie())
  48. def GetTopTickets() as (string):
  49. return GetTopTickets_().Value
  50. def GetTopTickets_():
  51. return _cache.Get(TopTicketsKey, FetchTopTickets)
  52. def FetchTopTickets():
  53. return array(ticket for ticket in FetchTopTickets_())
  54. private def FetchTopTickets_():
  55. page = HtmlAgilityPack.HtmlWeb().Load("http://tracker.db4o.com/browse/COR?report=com.atlassian.jira.plugin.system.project:popularissues-panel")
  56. topRows = page.CreateNavigator().Select("//div[@class='header']/h3[text()='Popular Issues']/../../table/tr")
  57. for topRow as HtmlAgilityPack.HtmlNodeNavigator in topRows:
  58. link as HtmlAgilityPack.HtmlNodeNavigator, = topRow.Select("td[6]/a")
  59. href = link.CurrentNode.GetAttributeValue("href", "")
  60. // href should look like '/browse/COR-36'
  61. yield href.Split(char('/'))[-1]