use of li.naska.bgg.resource.v3.model.Thread in project bgg-api by tnaskali.
the class ForumsService method getPagedThreads.
public Mono<Page<Thread>> getPagedThreads(Integer id, PagingParams pagingParams) {
PagingHelper helper = new PagingHelper(pagingParams.getSize(), pagingParams.getPage(), BGG_FORUM_THREADS_PAGE_SIZE);
BggForumQueryParams firstPageQueryParams = new BggForumQueryParams();
firstPageQueryParams.setId(id);
firstPageQueryParams.setPage(helper.getBggStartPage());
return getForum(firstPageQueryParams).flatMap(forum -> helper.getBggPagesRange(forum.getNumthreads()).flatMapSequential(page -> {
if (page == helper.getBggStartPage()) {
return Mono.just(forum);
}
BggForumQueryParams queryParams = new BggForumQueryParams();
queryParams.setId(id);
queryParams.setPage(page);
return getForum(queryParams);
}).flatMapIterable(Forum::getThreads).collect(Collectors.toList()).map(list -> helper.buildPage(list, forum.getNumthreads())));
}
use of li.naska.bgg.resource.v3.model.Thread in project bgg-api by tnaskali.
the class ForumsService method getThread.
public Mono<Thread> getThread(Integer id, ThreadParams params) {
BggThreadQueryParams queryParams = threadParamsMapper.toBggModel(params);
queryParams.setId(id);
return threadsRepository.getThread(queryParams).map(xml -> xmlProcessor.toJavaObject(xml, com.boardgamegeek.thread.Thread.class)).map(threadMapper::fromBggModel);
}
Aggregations