use of com.github.pockethub.android.GetFilterLabels in project PocketHub by pockethub.
the class AccountDataManager method getIssueFilters.
/**
* Get bookmarked issue filters
* <p/>
* This method may perform network I/O and should never be called on the
* UI-thread
*
* @return non-null but possibly empty collection of issue filters
*/
public List<IssueFilter> getIssueFilters() {
List<GetFilters> filters = dbCache.database.getIssue_filterQueries().getFilters().executeAsList();
List<IssueFilter> issueFilters = new ArrayList<>();
for (GetFilters f : filters) {
Users owner = dbCache.database.getOrganizationsQueries().selectUser(f.getOwnerId()).executeAsOne();
Repository.Builder builder = Repository.builder().id(f.getRepoId()).name(f.getName()).owner(User.builder().id(owner.getId()).login(owner.getLogin()).name(owner.getName()).avatarUrl(owner.getAvatarurl()).build()).isPrivate(f.getPrivate()).isFork(f.getFork()).description(f.getDescription()).forksCount(f.getForks()).watchersCount(f.getWatchers()).language(f.getLanguage()).hasIssues(f.getHasIssues()).mirrorUrl(f.getMirrorUrl()).permissions(Permissions.builder().admin(f.getPermissions_admin()).pull(f.getPermissions_pull()).push(f.getPermissions_push()).build());
if (f.getOrgId() != null) {
Users org = dbCache.database.getOrganizationsQueries().selectUser(f.getOrgId()).executeAsOne();
builder.organization(User.builder().id(org.getId()).login(org.getLogin()).name(org.getName()).avatarUrl(org.getAvatarurl()).build());
}
Repository repo = builder.build();
IssueFilter filter = new IssueFilter(repo, f.getId());
if (f.getLogin() != null) {
filter.setAssignee(User.builder().id(f.getId__()).name(f.getName_()).login(f.getLogin()).avatarUrl(f.getAvatarurl()).build());
}
if (f.getMilestone_id() != null) {
filter.setMilestone(Milestone.builder().id(f.getMilestone_id()).build());
}
filter.setDirection(f.getDirection());
filter.setOpen(f.getOpen());
filter.setSortType(f.getSort_type());
List<GetFilterLabels> filterLabels = dbCache.database.getIssue_filterQueries().getFilterLabels(filter.getId()).executeAsList();
for (GetFilterLabels filterLabel : filterLabels) {
filter.addLabel(Label.builder().name(filterLabel.getName()).color(filterLabel.getColor()).build());
}
issueFilters.add(filter);
}
return issueFilters;
}
Aggregations