示例#1
0
  @Override
  public Book save(BookDto bookDto) {

    Book book = bookDao.get(bookDto.getId());
    updateBookFields(book, bookDto);
    return save(book);
  }
示例#2
0
  @Override
  public Book save(Book book) {

    bookDao.add(book);
    deleteBookFromCategories(book.getId());

    if (book.getCategory() != null && categoryDao.get(book.getCategory()) != null) {

      Category category = categoryDao.get(book.getCategory());
      HashSet<String> booksSet = category.getBooks();
      if (booksSet == null) booksSet = new HashSet<String>();

      booksSet.add(book.getId());
      category.setBooks(booksSet);
      categoryDao.add(category);
    }

    bookDao.add(book);
    return get(book.getId());
  }
示例#3
0
  @Override
  public void delete(Book book) {

    deleteBookFromCategories(book.getId());
    bookDao.delete(book);
  }
示例#4
0
  @Override
  public void delete(String id) {

    deleteBookFromCategories(id);
    bookDao.delete(id);
  }
示例#5
0
  @Override
  public List<Book> getByAuthor(String author) {

    return bookDao.getByAuthor(author);
  }
示例#6
0
  @Override
  public List<Book> getByYear(short year) {

    return bookDao.getByYear(year);
  }
示例#7
0
  @Override
  public List<Book> getAll() {

    return bookDao.getAll();
  }
示例#8
0
  @Override
  public List<Book> getByTitle(String title) {

    return bookDao.getByTitle(title);
  }
示例#9
0
  @Override
  public Book get(String id) {

    return bookDao.get(id);
  }
示例#10
0
  @Override
  public void add(Book book) {

    bookDao.add(book);
  }
示例#11
0
 @Override
 public List<Book> get(int fromIndex, int toIndex) {
   return bookDao.get(fromIndex, toIndex);
 }
示例#12
0
  @Override
  public long count() {

    return bookDao.count();
  }
示例#13
0
  @Override
  public List<Book> find(String... words) {

    return bookDao.find(words);
  }