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();
}
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;
}
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;
}
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();
}
}
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;
}
Aggregations