Ejemplo n.º 1
0
  private static BookBean createFilter(String id) {
    BibleBean bible = DaoFactory.createDao(BibleBean.class).get(Integer.parseInt(id));
    BookBean book = new BookBeanImpl();
    book.setBible(bible);

    return book;
  }
Ejemplo n.º 2
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);
  }
Ejemplo n.º 3
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());
  }
Ejemplo n.º 4
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());
  }