public PullRequest getPullRequest( final IRepositoryIdProvider repository, final int pullrequestId) { PullRequest pullrequest = null; try { pullrequest = service.getPullRequest(repository, pullrequestId); } catch (IOException e) { log.error( "IO Exception fetching PullRequest {}:{}", new Object[] {repository.generateId(), pullrequestId, e}); } return pullrequest; }
@Override public IStatus performQuery( TaskRepository repository, IRepositoryQuery query, TaskDataCollector collector, ISynchronizationSession session, IProgressMonitor monitor) { IStatus result = Status.OK_STATUS; List<String> statuses = QueryUtils.getAttributes(IssueService.FILTER_STATE, query); monitor.beginTask(Messages.PullRequestConnector_TaskFetching, statuses.size()); try { RepositoryId repo = getRepository(repository.getRepositoryUrl()); GitHubClient client = IssueConnector.createClient(repository); PullRequestService service = new PullRequestService(client); IssueService commentService = new IssueService(client); for (String status : statuses) { List<PullRequest> pulls = service.getPullRequests(repo, status); // collect task data for (PullRequest pr : pulls) { pr = service.getPullRequest(repo, pr.getNumber()); PullRequestComposite prComp = new PullRequestComposite(); prComp.setRequest(pr); List<Comment> comments = null; if (pr.getComments() > 0) comments = commentService.getComments( repo.getOwner(), repo.getName(), Integer.toString(pr.getNumber())); if (pr.getCommits() > 0) prComp.setCommits(service.getCommits(repo, pr.getNumber())); TaskData taskData = taskDataHandler.createTaskData(repository, monitor, repo, prComp, comments); collector.accept(taskData); } monitor.worked(1); } } catch (IOException e) { result = GitHub.createWrappedStatus(e); } monitor.done(); return result; }
@Override public TaskData getTaskData(TaskRepository repository, String taskId, IProgressMonitor monitor) throws CoreException { RepositoryId repo = getRepository(repository.getRepositoryUrl()); try { GitHubClient client = IssueConnector.createClient(repository); PullRequestService service = new PullRequestService(client); PullRequest pr = service.getPullRequest(repo, Integer.parseInt(taskId)); PullRequestComposite prComp = new PullRequestComposite(); prComp.setRequest(pr); IssueService commentService = new IssueService(client); List<Comment> comments = null; if (pr.getComments() > 0) comments = commentService.getComments(repo.getOwner(), repo.getName(), taskId); if (pr.getCommits() > 0) prComp.setCommits(service.getCommits(repo, pr.getNumber())); return taskDataHandler.createTaskData(repository, monitor, repo, prComp, comments); } catch (IOException e) { throw new CoreException(GitHub.createWrappedStatus(e)); } }