예제 #1
0
  public static Books fetchAll(Long start, Long pages) {
    Pagination<BookBean> beans =
        DaoFactory.createDao(BookBean.class)
            .list(new ServiceParams().withStart(start).withPages(pages));
    List<Book> books = new ArrayList<Book>();

    for (BookBean bean : beans.getElements()) {
      books.add(ResourceToEntityParser.parse(Book.class, bean));
    }

    return new Books().withBooks(books).withSize(beans.getSize());
  }
예제 #2
0
  public static Books fetchBooksByBible(String id, Long start, Long pages) {
    if (!id.matches("\\d+")) {
      return null;
    }

    BookBean filter = createFilter(id);
    if (filter.getBible() == null) {
      return null;
    }

    Pagination<BookBean> beans =
        DaoFactory.createDao(BookBean.class)
            .list(filter, new ServiceParams().withStart(start).withPages(pages));

    List<Book> books = new ArrayList<Book>();

    for (BookBean bean : beans.getElements()) {
      books.add(ResourceToEntityParser.parse(Book.class, bean));
    }

    return new Books().withBooks(books).withSize(beans.getSize());
  }