コード例 #1
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;
  }
コード例 #2
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;
 }
コード例 #3
0
 @Override
 @Transactional(propagation = Propagation.REQUIRED)
 public Boolean deleteBook(
     Set<Integer> books_id, Set<Integer> authors_id, Set<Integer> publishers_id)
     throws NoSuchEntityException, ForbiddenException {
   List<BookEntity> booksToDelete = Lists.newArrayList();
   if (CollectionUtils.isNotEmpty(books_id)) {
     booksToDelete.addAll(bookDao.get(books_id));
   }
   if (CollectionUtils.isNotEmpty(authors_id)) {
     booksToDelete.addAll(bookDao.getBooksByAuthor(authors_id));
   }
   if (CollectionUtils.isNotEmpty(publishers_id)) {
     booksToDelete.addAll(bookDao.getBooksByPublisher(publishers_id));
   }
   if (CollectionUtils.isEmpty(booksToDelete)) {
     throw new NoSuchEntityException(BookEntity.class.getName());
   }
   return setStatusAndUpdate(booksToDelete, BookStatusesEnum.DELETED);
 }
コード例 #4
0
 @Override
 @Transactional(propagation = Propagation.REQUIRED)
 public List<BookEntity> getBooksByIds(
     Iterable<Integer> ids, int count, BookStatusesEnum statusEnum)
     throws NotSupportedFieldException, NoSuchEntityException, ForbiddenException {
   if (ids == null || !ids.iterator().hasNext()) return Lists.newArrayList();
   List<Criterion> criterions = Lists.newArrayList();
   if (statusEnum != null) {
     criterions.add(Restrictions.eq("status", statusEnum));
   } else {
     criterions.add(Restrictions.eq("status", BookStatusesEnum.ACTIVE));
   }
   criterions.add(Restrictions.in("id", Lists.newArrayList(ids)));
   List<BookEntity> res = bookDao.get(0, count, criterions);
   if (sessionUtils.isUserWithAnotherRole(RolesEnum.admin)) {
     if (statusEnum != null && !BookStatusesEnum.ACTIVE.equals(statusEnum)) {
       bookAvailabilityService.areBooksAvailable(res);
     }
   }
   return res;
 }