@Override
 @Transactional(propagation = Propagation.REQUIRED)
 public Boolean deleteBook(int bookId) throws NoSuchEntityException, ForbiddenException {
   BookEntity book = bookDao.getNotNull(bookId);
   bookAvailabilityService.isBookAvailable(book);
   book.setStatus(BookStatusesEnum.DELETED);
   return bookDao.update(book).getStatus().equals(BookStatusesEnum.DELETED);
 }
 private Boolean setStatusAndUpdate(Collection<BookEntity> to, BookStatusesEnum statuses)
     throws ForbiddenException {
   for (BookEntity bookEntity : to) {
     bookAvailabilityService.isStatusChangeAvailable(bookEntity, statuses);
     bookEntity.setStatus(statuses);
     if (!bookDao.update(bookEntity).getStatus().equals(statuses)) {
       return false;
     }
   }
   return true;
 }
 @Override
 @Transactional
 public boolean changeStatus(int id, BookStatusesEnum status)
     throws NoSuchEntityException, ForbiddenException, WrongStatusException {
   if (status == null) throw new WrongStatusException();
   BookEntity book = bookDao.getNotNull(id);
   bookAvailabilityService.isStatusChangeAvailable(book, status);
   book.setStatus(status);
   if (status == BookStatusesEnum.ACTIVE) book.setDateChanged(new Date());
   book = bookDao.update(book);
   return book != null;
 }