Search in sources :

Example 1 with GitHubRepository

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

the class GithubImporterPagePresenter method onListLoaded.

/**
     * Perform actions when the list of repositories was loaded.
     *
     * @param gitHubRepositories
     *         loaded list of repositories
     * @param gitHubOrganizations
     */
protected void onListLoaded(@NotNull List<GitHubUser> gitHubOrganizations, @NotNull List<GitHubRepository> gitHubRepositories) {
    this.repositories = new HashMap<>();
    Map<String, String> login2OrgName = getLogin2OrgName(gitHubOrganizations);
    for (String orgName : login2OrgName.values()) {
        repositories.put(orgName, new ArrayList<GitHubRepository>());
    }
    for (GitHubRepository gitHubRepository : gitHubRepositories) {
        String orgName = login2OrgName.get(gitHubRepository.getOwnerLogin());
        if (orgName != null && repositories.containsKey(orgName)) {
            repositories.get(orgName).add(gitHubRepository);
        }
    }
    view.setAccountNames(repositories.keySet());
    refreshProjectList();
    view.showGithubPanel();
}
Also used : GitHubRepository(org.eclipse.che.plugin.github.shared.GitHubRepository)

Example 2 with GitHubRepository

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

the class GitHubDTOFactory method createRepositoriesList.

/**
     * Create DTO object of GitHub repositories collection from given repository
     * @param ghRepository repository from kohsuke GitHub library
     * @return DTO object
     * @throws IOException
     */
public GitHubRepositoryList createRepositoriesList(GHRepository ghRepository) throws ApiException, IOException {
    GitHubRepositoryList dtoRepositoriesList = DtoFactory.getInstance().createDto(GitHubRepositoryList.class);
    List<GitHubRepository> dtoRepositories = new ArrayList<>();
    dtoRepositories.add(createRepository(ghRepository));
    dtoRepositoriesList.setRepositories(dtoRepositories);
    return dtoRepositoriesList;
}
Also used : GitHubRepositoryList(org.eclipse.che.plugin.github.shared.GitHubRepositoryList) ArrayList(java.util.ArrayList) GitHubRepository(org.eclipse.che.plugin.github.shared.GitHubRepository)

Example 3 with GitHubRepository

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

the class GitHubDTOFactory method createRepository.

/**
     * Create DTO object of GitHub repository from given repository
     * @param ghRepository repository from kohsuke GitHub library
     * @return DTO object
     * @throws IOException
     */
public GitHubRepository createRepository(GHRepository ghRepository) throws ApiException, IOException {
    GitHubRepository dtoRepository = DtoFactory.getInstance().createDto(GitHubRepository.class);
    dtoRepository.setName(ghRepository.getName());
    dtoRepository.setUrl(String.valueOf(ghRepository.getUrl()));
    dtoRepository.setHomepage(ghRepository.getHomepage());
    dtoRepository.setForks(ghRepository.getForks());
    dtoRepository.setLanguage(ghRepository.getLanguage());
    dtoRepository.setFork(ghRepository.isFork());
    dtoRepository.setWatchers(ghRepository.getWatchers());
    dtoRepository.setPrivateRepo(ghRepository.isPrivate());
    dtoRepository.setSize(ghRepository.getSize());
    dtoRepository.setDescription(ghRepository.getDescription());
    dtoRepository.setSshUrl(ghRepository.getSshUrl());
    dtoRepository.setHtmlUrl(ghRepository.gitHttpTransportUrl());
    dtoRepository.setUpdatedAt(String.valueOf(ghRepository.getUpdatedAt()));
    dtoRepository.setGitUrl(ghRepository.getGitTransportUrl());
    dtoRepository.setHasWiki(ghRepository.hasWiki());
    dtoRepository.setCloneUrl(String.valueOf(ghRepository.getUrl()));
    dtoRepository.setSvnUrl(ghRepository.getSvnUrl());
    dtoRepository.setOpenedIssues(ghRepository.getOpenIssueCount());
    dtoRepository.setCreatedAt(String.valueOf(ghRepository.getCreatedAt()));
    dtoRepository.setPushedAt(String.valueOf(ghRepository.getPushedAt()));
    dtoRepository.setHasDownloads(ghRepository.hasDownloads());
    dtoRepository.setHasIssues(ghRepository.hasIssues());
    dtoRepository.setOwnerLogin(ghRepository.getOwnerName());
    if (ghRepository.isFork() && ghRepository.getParent() != null) {
        dtoRepository.setParent(createRepository(ghRepository.getParent()));
    }
    return dtoRepository;
}
Also used : GitHubRepository(org.eclipse.che.plugin.github.shared.GitHubRepository)

Example 4 with GitHubRepository

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

the class GithubImporterPagePresenter method refreshProjectList.

/**
     * Refresh project list on view.
     */
private void refreshProjectList() {
    List<ProjectData> projectsData = new ArrayList<>();
    String accountName = view.getAccountName();
    if (repositories.containsKey(accountName)) {
        List<GitHubRepository> repo = repositories.get(accountName);
        for (GitHubRepository repository : repo) {
            ProjectData projectData = new ProjectData(repository.getName(), repository.getDescription(), null, null, repository.getSshUrl(), repository.getGitUrl());
            projectsData.add(projectData);
        }
        Collections.sort(projectsData, new Comparator<ProjectData>() {

            @Override
            public int compare(ProjectData o1, ProjectData o2) {
                return o1.getName().compareTo(o2.getName());
            }
        });
        view.setRepositories(projectsData);
        view.reset();
        view.showGithubPanel();
    }
}
Also used : ArrayList(java.util.ArrayList) ProjectData(org.eclipse.che.plugin.github.ide.load.ProjectData) GitHubRepository(org.eclipse.che.plugin.github.shared.GitHubRepository)

Example 5 with GitHubRepository

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

the class GitHubDTOFactory method createRepositoriesList.

/**
     * Create DTO object of GitHub repositories collection from given repositories list
     * @param ghRepositoriesList collection of repositories from kohsuke GitHub library
     * @return DTO object
     * @throws IOException
     */
public GitHubRepositoryList createRepositoriesList(PagedIterable<GHRepository> ghRepositoriesList) throws ApiException, IOException {
    GitHubRepositoryList dtoRepositoriesList = DtoFactory.getInstance().createDto(GitHubRepositoryList.class);
    List<GitHubRepository> dtoRepositories = new ArrayList<>();
    for (GHRepository ghRepository : ghRepositoriesList) {
        dtoRepositories.add(createRepository(ghRepository));
    }
    dtoRepositoriesList.setRepositories(dtoRepositories);
    return dtoRepositoriesList;
}
Also used : GHRepository(org.kohsuke.github.GHRepository) GitHubRepositoryList(org.eclipse.che.plugin.github.shared.GitHubRepositoryList) ArrayList(java.util.ArrayList) GitHubRepository(org.eclipse.che.plugin.github.shared.GitHubRepository)

Aggregations

GitHubRepository (org.eclipse.che.plugin.github.shared.GitHubRepository)5 ArrayList (java.util.ArrayList)3 GitHubRepositoryList (org.eclipse.che.plugin.github.shared.GitHubRepositoryList)2 ProjectData (org.eclipse.che.plugin.github.ide.load.ProjectData)1 GHRepository (org.kohsuke.github.GHRepository)1