コード例 #1
0
 @Override
 // @Transactional
 public Integer update(BookView bookView)
     throws ValidationException, IllegalDatabaseStateException, ForbiddenException,
         NoSuchEntityException, AuthRequiredException {
   BookEntity bookEntity = bookCreationService.updateFields(bookView);
   return bookEntity.getId();
 }
コード例 #2
0
 @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);
 }
コード例 #3
0
 @Override
 @Transactional(propagation = Propagation.REQUIRED)
 public Integer update(BookEntity book)
     throws ValidationException, IllegalDatabaseStateException, ForbiddenException,
         NoSuchEntityException, AuthRequiredException {
   bookAvailabilityService.isCurrentUsersBook(book);
   BookEntity bookEntity = bookDao.update(book);
   return bookEntity.getId();
 }
コード例 #4
0
 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;
 }
コード例 #5
0
 @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;
 }
コード例 #6
0
  @Override
  @Transactional
  public List<AuthorEntity> getBookAuthors(int id) throws NoSuchEntityException {
    BookEntity book = bookDao.getNotNull(id);
    List<AuthorEntity> list = Lists.newArrayList();

    if (book.getBookToAuthor() != null) {
      for (BookAuthorEntity b2a : book.getBookToAuthor()) list.add(b2a.getAuthor());
    }

    return list;
  }
コード例 #7
0
 @Override
 @Transactional
 public List<KeywordEntity> getBookKeywords(int bookId) throws NoSuchEntityException {
   BookEntity bookEntity = bookDao.getNotNull(bookId);
   List<KeywordEntity> res = null;
   if ((bookEntity != null)
       && (bookEntity.getBookToKeywords() != null)
       && (bookEntity.getBookToKeywords().size() > 0)) {
     res = new ArrayList<KeywordEntity>();
     for (BookKeywordEntity key : bookEntity.getBookToKeywords()) res.add(key.getKeyword());
   }
   return res;
 }
コード例 #8
0
 @Override
 @Transactional(propagation = Propagation.REQUIRED)
 public Set<BookOnPortalEntity> getBookPortals(int bookId) throws NoSuchEntityException {
   BookEntity book = bookDao.getNotNull(bookId);
   try {
     bookAvailabilityService.isCurrentUsersBook(book);
     return book.getBookPortals();
   } catch (ForbiddenException e) {
     if (book.getBookPortals() == null || book.getBookPortals().size() == 0) return null;
     Set<BookOnPortalEntity> list = new HashSet<BookOnPortalEntity>();
     for (BookOnPortalEntity portal : book.getBookPortals())
       if (BookPortalStatusEnum.ACTIVE.equals(portal.getStatus())) list.add(portal);
     return list;
   }
 }
コード例 #9
0
 @Override
 @Transactional(propagation = Propagation.REQUIRED)
 public Integer get(String isbn) throws NoSuchEntityException, IllegalDatabaseStateException {
   BookEntity book = bookDao.getByIsbnNotNull(isbn);
   return book.getId();
 }