Search in sources :

Example 1 with Comment

use of li.naska.bgg.resource.v3.model.Thing.Comment in project bgg-api by tnaskali.

the class ThingsService method getPagedComments.

public Mono<Page<Comment>> getPagedComments(Integer id, PagingParams pagingParams) {
    PagingHelper helper = new PagingHelper(pagingParams.getSize(), pagingParams.getPage(), BGG_THING_COMMENTS_PAGE_SIZE);
    BggThingsQueryParams firstPageQueryParams = new BggThingsQueryParams();
    firstPageQueryParams.setId(id.toString());
    firstPageQueryParams.setComments(1);
    firstPageQueryParams.setPage(helper.getBggStartPage());
    firstPageQueryParams.setPagesize(BGG_THING_COMMENTS_PAGE_SIZE);
    return getThing(firstPageQueryParams).flatMap(thing -> helper.getBggPagesRange(thing.getNumcomments()).flatMapSequential(page -> {
        BggThingsQueryParams queryParams = new BggThingsQueryParams();
        queryParams.setId(id.toString());
        queryParams.setComments(1);
        queryParams.setPage(page);
        queryParams.setPagesize(BGG_THING_COMMENTS_PAGE_SIZE);
        return getThing(queryParams);
    }).flatMapIterable(Thing::getComments).collect(Collectors.toList()).map(list -> helper.buildPage(list, thing.getNumcomments())));
}
Also used : ThingsParamsMapper(li.naska.bgg.mapper.ThingsParamsMapper) CollectionParams(li.naska.bgg.resource.v3.model.CollectionParams) Version(li.naska.bgg.resource.v3.model.Thing.Version) ThingsParams(li.naska.bgg.resource.v3.model.ThingsParams) PagingHelper(li.naska.bgg.util.PagingHelper) Autowired(org.springframework.beans.factory.annotation.Autowired) Page(li.naska.bgg.util.Page) CollectionMapper(li.naska.bgg.mapper.CollectionMapper) BggCollectionRepository(li.naska.bgg.repository.BggCollectionRepository) Service(org.springframework.stereotype.Service) Things(com.boardgamegeek.thing.Things) BggCollectionQueryParams(li.naska.bgg.repository.model.BggCollectionQueryParams) Thing(li.naska.bgg.resource.v3.model.Thing) XmlProcessor(li.naska.bgg.util.XmlProcessor) BggThingsRepository(li.naska.bgg.repository.BggThingsRepository) Video(li.naska.bgg.resource.v3.model.Thing.Video) ResponseStatusException(org.springframework.web.server.ResponseStatusException) BggThingsQueryParams(li.naska.bgg.repository.model.BggThingsQueryParams) CollectionItemSubtype(com.boardgamegeek.enums.CollectionItemSubtype) Mono(reactor.core.publisher.Mono) MarketplaceListing(li.naska.bgg.resource.v3.model.Thing.MarketplaceListing) Collectors(java.util.stream.Collectors) Comment(li.naska.bgg.resource.v3.model.Thing.Comment) PagingParams(li.naska.bgg.util.PagingParams) CollectionParamsMapper(li.naska.bgg.mapper.CollectionParamsMapper) ThingMapper(li.naska.bgg.mapper.ThingMapper) HttpStatus(org.springframework.http.HttpStatus) Flux(reactor.core.publisher.Flux) List(java.util.List) Collection(li.naska.bgg.resource.v3.model.Collection) PagingHelper(li.naska.bgg.util.PagingHelper) BggThingsQueryParams(li.naska.bgg.repository.model.BggThingsQueryParams)

Example 2 with Comment

use of li.naska.bgg.resource.v3.model.Thing.Comment in project bgg-api by tnaskali.

the class ThingsService method getPagedRatings.

public Mono<Page<Comment>> getPagedRatings(Integer id, PagingParams pagingParams) {
    PagingHelper helper = new PagingHelper(pagingParams.getSize(), pagingParams.getPage(), BGG_THING_COMMENTS_PAGE_SIZE);
    BggThingsQueryParams firstPageQueryParams = new BggThingsQueryParams();
    firstPageQueryParams.setId(id.toString());
    firstPageQueryParams.setRatingcomments(1);
    firstPageQueryParams.setPage(helper.getBggStartPage());
    firstPageQueryParams.setPagesize(BGG_THING_COMMENTS_PAGE_SIZE);
    return getThing(firstPageQueryParams).flatMap(thing -> helper.getBggPagesRange(thing.getNumcomments()).flatMapSequential(page -> {
        BggThingsQueryParams queryParams = new BggThingsQueryParams();
        queryParams.setId(id.toString());
        queryParams.setRatingcomments(1);
        queryParams.setPage(page);
        queryParams.setPagesize(BGG_THING_COMMENTS_PAGE_SIZE);
        return getThing(queryParams);
    }).flatMapIterable(Thing::getComments).collect(Collectors.toList()).map(list -> helper.buildPage(list, thing.getNumcomments())));
}
Also used : ThingsParamsMapper(li.naska.bgg.mapper.ThingsParamsMapper) CollectionParams(li.naska.bgg.resource.v3.model.CollectionParams) Version(li.naska.bgg.resource.v3.model.Thing.Version) ThingsParams(li.naska.bgg.resource.v3.model.ThingsParams) PagingHelper(li.naska.bgg.util.PagingHelper) Autowired(org.springframework.beans.factory.annotation.Autowired) Page(li.naska.bgg.util.Page) CollectionMapper(li.naska.bgg.mapper.CollectionMapper) BggCollectionRepository(li.naska.bgg.repository.BggCollectionRepository) Service(org.springframework.stereotype.Service) Things(com.boardgamegeek.thing.Things) BggCollectionQueryParams(li.naska.bgg.repository.model.BggCollectionQueryParams) Thing(li.naska.bgg.resource.v3.model.Thing) XmlProcessor(li.naska.bgg.util.XmlProcessor) BggThingsRepository(li.naska.bgg.repository.BggThingsRepository) Video(li.naska.bgg.resource.v3.model.Thing.Video) ResponseStatusException(org.springframework.web.server.ResponseStatusException) BggThingsQueryParams(li.naska.bgg.repository.model.BggThingsQueryParams) CollectionItemSubtype(com.boardgamegeek.enums.CollectionItemSubtype) Mono(reactor.core.publisher.Mono) MarketplaceListing(li.naska.bgg.resource.v3.model.Thing.MarketplaceListing) Collectors(java.util.stream.Collectors) Comment(li.naska.bgg.resource.v3.model.Thing.Comment) PagingParams(li.naska.bgg.util.PagingParams) CollectionParamsMapper(li.naska.bgg.mapper.CollectionParamsMapper) ThingMapper(li.naska.bgg.mapper.ThingMapper) HttpStatus(org.springframework.http.HttpStatus) Flux(reactor.core.publisher.Flux) List(java.util.List) Collection(li.naska.bgg.resource.v3.model.Collection) PagingHelper(li.naska.bgg.util.PagingHelper) BggThingsQueryParams(li.naska.bgg.repository.model.BggThingsQueryParams)

Aggregations

CollectionItemSubtype (com.boardgamegeek.enums.CollectionItemSubtype)2 Things (com.boardgamegeek.thing.Things)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 CollectionMapper (li.naska.bgg.mapper.CollectionMapper)2 CollectionParamsMapper (li.naska.bgg.mapper.CollectionParamsMapper)2 ThingMapper (li.naska.bgg.mapper.ThingMapper)2 ThingsParamsMapper (li.naska.bgg.mapper.ThingsParamsMapper)2 BggCollectionRepository (li.naska.bgg.repository.BggCollectionRepository)2 BggThingsRepository (li.naska.bgg.repository.BggThingsRepository)2 BggCollectionQueryParams (li.naska.bgg.repository.model.BggCollectionQueryParams)2 BggThingsQueryParams (li.naska.bgg.repository.model.BggThingsQueryParams)2 Collection (li.naska.bgg.resource.v3.model.Collection)2 CollectionParams (li.naska.bgg.resource.v3.model.CollectionParams)2 Thing (li.naska.bgg.resource.v3.model.Thing)2 Comment (li.naska.bgg.resource.v3.model.Thing.Comment)2 MarketplaceListing (li.naska.bgg.resource.v3.model.Thing.MarketplaceListing)2 Version (li.naska.bgg.resource.v3.model.Thing.Version)2 Video (li.naska.bgg.resource.v3.model.Thing.Video)2 ThingsParams (li.naska.bgg.resource.v3.model.ThingsParams)2