/** * @see * org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector#getTaskData(org.eclipse.mylyn.tasks.core.TaskRepository, * java.lang.String, org.eclipse.core.runtime.IProgressMonitor) */ public TaskData getTaskData(TaskRepository repository, String taskId, IProgressMonitor monitor) throws CoreException { GistService service = new GistService(createClient(repository)); try { TaskAttributeMapper mapper = dataHandler.getAttributeMapper(repository); Gist gist = service.getGist(taskId); TaskData data = new TaskData(mapper, getConnectorKind(), repository.getUrl(), gist.getId()); data.setPartial(false); dataHandler.fillTaskData(repository, data, gist); if (gist.getComments() > 0) dataHandler.fillComments(repository, data, service.getComments(gist.getId())); return data; } catch (IOException e) { throw new CoreException(GitHub.createWrappedStatus(e)); } }
@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)); } }
/** * @see * org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector#performQuery(org.eclipse.mylyn.tasks.core.TaskRepository, * org.eclipse.mylyn.tasks.core.IRepositoryQuery, * org.eclipse.mylyn.tasks.core.data.TaskDataCollector, * org.eclipse.mylyn.tasks.core.sync.ISynchronizationSession, * org.eclipse.core.runtime.IProgressMonitor) */ public IStatus performQuery( TaskRepository repository, IRepositoryQuery query, TaskDataCollector collector, ISynchronizationSession session, IProgressMonitor monitor) { IStatus status = Status.OK_STATUS; GistService service = new GistService(createClient(repository)); String user = query.getAttribute(IGistQueryConstants.USER); try { TaskAttributeMapper mapper = dataHandler.getAttributeMapper(repository); for (Gist gist : service.getGists(user)) { TaskData data = new TaskData(mapper, getConnectorKind(), repository.getUrl(), gist.getId()); data.setPartial(true); dataHandler.fillTaskData(repository, data, gist); collector.accept(data); } } catch (IOException e) { status = GitHub.createWrappedStatus(e); } return status; }