@Override public Number countBooksForCatalog(SubCategoryEntity subCategoryEntity, BookStatusesEnum status) throws ForbiddenException, AuthRequiredException { bookAvailabilityService.areBooksWithStatusAvailable(status); if (subCategoryEntity == null) { throw new IllegalArgumentException(); } Collection<Integer> integers = Sets.newHashSet(); integers.add(subCategoryEntity.getId()); return bookDao.countBySubCategories(integers, status); }
@Override public Number countBooksWithLanguage(LanguageEntity languageEntity, BookStatusesEnum status) throws ForbiddenException, AuthRequiredException { bookAvailabilityService.areBooksWithStatusAvailable(status); if (languageEntity == null) { return bookDao.countBooks(status); } Collection<Integer> integers = Sets.newHashSet(); integers.add(languageEntity.getId()); return bookDao.countBySubCategories(integers, status); }
@Override public Number countBooksForCatalog( Set<String> categories, Set<String> subcategories, BookStatusesEnum status) throws ForbiddenException, AuthRequiredException { bookAvailabilityService.areBooksWithStatusAvailable(status); if (CollectionUtils.isEmpty(categories) && CollectionUtils.isEmpty(subcategories)) { return bookDao.countBooks(status); } Collection<Integer> integers = subcategoryDao.collectSubcategoryIdsByPriority(categories, subcategories); return bookDao.countBySubCategories(integers, status); }
@Override public Number countBooksForCatalog(CategoryEntity categoryEntity, BookStatusesEnum status) throws ForbiddenException, AuthRequiredException { bookAvailabilityService.areBooksWithStatusAvailable(status); if (categoryEntity == null) { return bookDao.countBooks(status); } Collection<Integer> integers = Sets.newHashSet(); if (CollectionUtils.isNotEmpty(categoryEntity.getSubcategories())) { for (SubCategoryEntity sce : categoryEntity.getSubcategories()) integers.add(sce.getId()); } return bookDao.countBySubCategories(integers, status); }