Search in sources :

Example 1 with GitHubPullRequest

use of org.eclipse.che.plugin.github.shared.GitHubPullRequest in project che by eclipse.

the class GitHubDTOFactory method createPullRequestsList.

/**
     * Create DTO object of GitHub pull-requests collection from given pull-request
     * @param ghPullRequest pull-request from kohsuke GitHub library
     * @return DTO object
     * @throws IOException
     */
public GitHubPullRequestList createPullRequestsList(GHPullRequest ghPullRequest) throws IOException {
    GitHubPullRequestList gitHubPullRequestList = DtoFactory.getInstance().createDto(GitHubPullRequestList.class);
    List<GitHubPullRequest> dtoPullRequestsList = new ArrayList<>();
    dtoPullRequestsList.add(createPullRequest(ghPullRequest));
    gitHubPullRequestList.setPullRequests(dtoPullRequestsList);
    return gitHubPullRequestList;
}
Also used : ArrayList(java.util.ArrayList) GitHubPullRequestList(org.eclipse.che.plugin.github.shared.GitHubPullRequestList) GitHubPullRequest(org.eclipse.che.plugin.github.shared.GitHubPullRequest)

Example 2 with GitHubPullRequest

use of org.eclipse.che.plugin.github.shared.GitHubPullRequest in project che by eclipse.

the class GitHubDTOFactory method createPullRequest.

/**
     * Create DTO object of GitHub pull-request from given pull-request
     * @param ghPullRequest pull-request from kohsuke GitHub library
     * @return DTO object
     * @throws IOException
     */
public GitHubPullRequest createPullRequest(GHPullRequest ghPullRequest) throws IOException {
    GitHubPullRequest dtoPullRequest = DtoFactory.getInstance().createDto(GitHubPullRequest.class);
    dtoPullRequest.setId(String.valueOf(ghPullRequest.getId()));
    dtoPullRequest.setUrl(String.valueOf(ghPullRequest.getUrl()));
    dtoPullRequest.setHtmlUrl(String.valueOf(ghPullRequest.getHtmlUrl()));
    dtoPullRequest.setNumber(String.valueOf(ghPullRequest.getNumber()));
    dtoPullRequest.setState(ghPullRequest.getState().toString());
    dtoPullRequest.setHead(createPullRequestHead(ghPullRequest.getHead()));
    dtoPullRequest.setMerged(ghPullRequest.isMerged());
    dtoPullRequest.setBody(ghPullRequest.getBody());
    dtoPullRequest.setTitle(ghPullRequest.getTitle());
    if (ghPullRequest.getMergedBy() != null) {
        dtoPullRequest.setMergedBy(createUser(ghPullRequest.getMergedBy()));
    }
    if (ghPullRequest.getMergeable() != null) {
        dtoPullRequest.setMergeable(ghPullRequest.getMergeable());
    }
    return dtoPullRequest;
}
Also used : GitHubPullRequest(org.eclipse.che.plugin.github.shared.GitHubPullRequest)

Example 3 with GitHubPullRequest

use of org.eclipse.che.plugin.github.shared.GitHubPullRequest in project che by eclipse.

the class GitHubDTOFactory method createPullRequestsList.

/**
     * Create DTO object of GitHub pull-requests collection from given pull-requests
     * @param ghPullRequestsList collection of pull-requests from kohsuke GitHub library
     * @return DTO object
     * @throws IOException
     */
public GitHubPullRequestList createPullRequestsList(PagedIterable<GHPullRequest> ghPullRequestsList) throws IOException {
    GitHubPullRequestList gitHubPullRequestList = DtoFactory.getInstance().createDto(GitHubPullRequestList.class);
    List<GitHubPullRequest> dtoPullRequestsList = new ArrayList<>();
    for (GHPullRequest ghPullRequest : ghPullRequestsList) {
        dtoPullRequestsList.add(createPullRequest(ghPullRequest));
    }
    gitHubPullRequestList.setPullRequests(dtoPullRequestsList);
    return gitHubPullRequestList;
}
Also used : GHPullRequest(org.kohsuke.github.GHPullRequest) ArrayList(java.util.ArrayList) GitHubPullRequestList(org.eclipse.che.plugin.github.shared.GitHubPullRequestList) GitHubPullRequest(org.eclipse.che.plugin.github.shared.GitHubPullRequest)

Aggregations

GitHubPullRequest (org.eclipse.che.plugin.github.shared.GitHubPullRequest)3 ArrayList (java.util.ArrayList)2 GitHubPullRequestList (org.eclipse.che.plugin.github.shared.GitHubPullRequestList)2 GHPullRequest (org.kohsuke.github.GHPullRequest)1