Search in sources :

Example 1 with Thread

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())));
}
Also used : BggForumListsRepository(li.naska.bgg.repository.BggForumListsRepository) BggThreadsRepository(li.naska.bgg.repository.BggThreadsRepository) Thread(li.naska.bgg.resource.v3.model.Thread) BggForumsRepository(li.naska.bgg.repository.BggForumsRepository) BggForumsQueryParams(li.naska.bgg.repository.model.BggForumsQueryParams) ThreadParamsMapper(li.naska.bgg.mapper.ThreadParamsMapper) PagingHelper(li.naska.bgg.util.PagingHelper) Autowired(org.springframework.beans.factory.annotation.Autowired) Page(li.naska.bgg.util.Page) ThreadMapper(li.naska.bgg.mapper.ThreadMapper) Service(org.springframework.stereotype.Service) ForumMapper(li.naska.bgg.mapper.ForumMapper) BggThreadQueryParams(li.naska.bgg.repository.model.BggThreadQueryParams) ForumsParams(li.naska.bgg.resource.v3.model.ForumsParams) XmlProcessor(li.naska.bgg.util.XmlProcessor) ThreadParams(li.naska.bgg.resource.v3.model.ThreadParams) ItemType(com.boardgamegeek.enums.ItemType) BggForumQueryParams(li.naska.bgg.repository.model.BggForumQueryParams) Mono(reactor.core.publisher.Mono) Collectors(java.util.stream.Collectors) PagingParams(li.naska.bgg.util.PagingParams) Forum(li.naska.bgg.resource.v3.model.Forum) Flux(reactor.core.publisher.Flux) List(java.util.List) Forums(com.boardgamegeek.forumlist.Forums) ForumListsParamsMapper(li.naska.bgg.mapper.ForumListsParamsMapper) PagingHelper(li.naska.bgg.util.PagingHelper) BggForumQueryParams(li.naska.bgg.repository.model.BggForumQueryParams)

Example 2 with Thread

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);
}
Also used : BggForumListsRepository(li.naska.bgg.repository.BggForumListsRepository) BggThreadsRepository(li.naska.bgg.repository.BggThreadsRepository) Thread(li.naska.bgg.resource.v3.model.Thread) BggForumsRepository(li.naska.bgg.repository.BggForumsRepository) BggForumsQueryParams(li.naska.bgg.repository.model.BggForumsQueryParams) ThreadParamsMapper(li.naska.bgg.mapper.ThreadParamsMapper) PagingHelper(li.naska.bgg.util.PagingHelper) Autowired(org.springframework.beans.factory.annotation.Autowired) Page(li.naska.bgg.util.Page) ThreadMapper(li.naska.bgg.mapper.ThreadMapper) Service(org.springframework.stereotype.Service) ForumMapper(li.naska.bgg.mapper.ForumMapper) BggThreadQueryParams(li.naska.bgg.repository.model.BggThreadQueryParams) ForumsParams(li.naska.bgg.resource.v3.model.ForumsParams) XmlProcessor(li.naska.bgg.util.XmlProcessor) ThreadParams(li.naska.bgg.resource.v3.model.ThreadParams) ItemType(com.boardgamegeek.enums.ItemType) BggForumQueryParams(li.naska.bgg.repository.model.BggForumQueryParams) Mono(reactor.core.publisher.Mono) Collectors(java.util.stream.Collectors) PagingParams(li.naska.bgg.util.PagingParams) Forum(li.naska.bgg.resource.v3.model.Forum) Flux(reactor.core.publisher.Flux) List(java.util.List) Forums(com.boardgamegeek.forumlist.Forums) ForumListsParamsMapper(li.naska.bgg.mapper.ForumListsParamsMapper) BggThreadQueryParams(li.naska.bgg.repository.model.BggThreadQueryParams)

Aggregations

ItemType (com.boardgamegeek.enums.ItemType)2 Forums (com.boardgamegeek.forumlist.Forums)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 ForumListsParamsMapper (li.naska.bgg.mapper.ForumListsParamsMapper)2 ForumMapper (li.naska.bgg.mapper.ForumMapper)2 ThreadMapper (li.naska.bgg.mapper.ThreadMapper)2 ThreadParamsMapper (li.naska.bgg.mapper.ThreadParamsMapper)2 BggForumListsRepository (li.naska.bgg.repository.BggForumListsRepository)2 BggForumsRepository (li.naska.bgg.repository.BggForumsRepository)2 BggThreadsRepository (li.naska.bgg.repository.BggThreadsRepository)2 BggForumQueryParams (li.naska.bgg.repository.model.BggForumQueryParams)2 BggForumsQueryParams (li.naska.bgg.repository.model.BggForumsQueryParams)2 BggThreadQueryParams (li.naska.bgg.repository.model.BggThreadQueryParams)2 Forum (li.naska.bgg.resource.v3.model.Forum)2 ForumsParams (li.naska.bgg.resource.v3.model.ForumsParams)2 Thread (li.naska.bgg.resource.v3.model.Thread)2 ThreadParams (li.naska.bgg.resource.v3.model.ThreadParams)2 Page (li.naska.bgg.util.Page)2 PagingHelper (li.naska.bgg.util.PagingHelper)2