示例#1
0
  public static Book fetchBookById(String id) {
    if (!id.matches("\\d+")) {
      return null;
    }

    BookBean book = DaoFactory.createDao(BookBean.class).get(Integer.parseInt(id));
    return (book == null) ? null : ResourceToEntityParser.parse(Book.class, book);
  }
示例#2
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());
  }
示例#3
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());
  }