コード例 #1
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);
 }
コード例 #2
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;
 }