@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; }
@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; }
@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; }