use of com.salesmanager.shop.populator.catalog.ReadableCategoryPopulator in project shopizer by shopizer-ecommerce.
the class ShoppingCategoryController method getSubCategories.
private List<ReadableCategory> getSubCategories(MerchantStore store, Category category, Map<Long, Long> productCount, Language language, Locale locale) throws Exception {
// sub categories
List<Category> subCategories = categoryService.listByParent(category, language);
ReadableCategoryPopulator populator = new ReadableCategoryPopulator();
List<ReadableCategory> subCategoryProxies = new ArrayList<ReadableCategory>();
for (Category sub : subCategories) {
ReadableCategory cProxy = populator.populate(sub, new ReadableCategory(), store, language);
if (productCount != null) {
Long total = productCount.get(cProxy.getId());
if (total != null) {
cProxy.setProductCount(total.intValue());
}
}
subCategoryProxies.add(cProxy);
}
return subCategoryProxies;
}
use of com.salesmanager.shop.populator.catalog.ReadableCategoryPopulator in project shopizer by shopizer-ecommerce.
the class SearchFacadeImpl method convertCategoryToReadableCategory.
private ReadableCategory convertCategoryToReadableCategory(MerchantStore merchantStore, Language language, Map<String, Long> productCategoryCount, Category category) {
ReadableCategoryPopulator populator = new ReadableCategoryPopulator();
try {
ReadableCategory categoryProxy = populator.populate(category, new ReadableCategory(), merchantStore, language);
Long total = productCategoryCount.get(categoryProxy.getCode());
if (total != null) {
categoryProxy.setProductCount(total.intValue());
}
return categoryProxy;
} catch (ConversionException e) {
throw new ConversionRuntimeException(e);
}
}
use of com.salesmanager.shop.populator.catalog.ReadableCategoryPopulator in project shopizer by shopizer-ecommerce.
the class CategoryFacadeImpl method getCategoryByFriendlyUrl.
@Override
public ReadableCategory getCategoryByFriendlyUrl(MerchantStore store, String friendlyUrl, Language language) throws Exception {
Validate.notNull(friendlyUrl, "Category search friendly URL must not be null");
ReadableCategoryPopulator categoryPopulator = new ReadableCategoryPopulator();
ReadableCategory readableCategory = new ReadableCategory();
Category category = categoryService.getBySeUrl(store, friendlyUrl);
categoryPopulator.populate(category, readableCategory, store, language);
return readableCategory;
}
use of com.salesmanager.shop.populator.catalog.ReadableCategoryPopulator in project shopizer by shopizer-ecommerce.
the class CategoryFacadeImpl method getByCode.
@Override
public ReadableCategory getByCode(MerchantStore store, String code, Language language) throws Exception {
Validate.notNull(code, "category code must not be null");
ReadableCategoryPopulator categoryPopulator = new ReadableCategoryPopulator();
ReadableCategory readableCategory = new ReadableCategory();
Category category = categoryService.getByCode(store, code);
categoryPopulator.populate(category, readableCategory, store, language);
return readableCategory;
}
use of com.salesmanager.shop.populator.catalog.ReadableCategoryPopulator in project shopizer by shopizer-ecommerce.
the class StoreFilter method getCategories.
/**
* @param store
* @param language
* @return
* @throws Exception
*/
// private Map<String, List<Category>> getCategories(MerchantStore store,
// Language language)
// throws Exception {
private Map<String, List<ReadableCategory>> getCategories(MerchantStore store, Language language) throws Exception {
// Map<String, List<Category>> objects = new ConcurrentHashMap<String,
// List<Category>>();
Map<String, List<ReadableCategory>> objects = new ConcurrentHashMap<String, List<ReadableCategory>>();
/**
* returns categories with required depth, 0 = root category, 1 = root +
* 1 layer child ...)
*/
List<Category> categories = categoryService.getListByDepth(store, 0, language);
ReadableCategoryPopulator readableCategoryPopulator = new ReadableCategoryPopulator();
Map<String, ReadableCategory> subs = new ConcurrentHashMap<String, ReadableCategory>();
if (categories != null && categories.size() > 0) {
// create a Map<String,List<Content>
for (Category category : categories) {
if (category.isVisible()) {
// if(category.getDepth().intValue()==0) {
// ReadableCategory readableCategory = new
// ReadableCategory();
// readableCategoryPopulator.populate(category,
// readableCategory, store, language);
Set<CategoryDescription> descriptions = category.getDescriptions();
for (CategoryDescription description : descriptions) {
Language lang = description.getLanguage();
ReadableCategory readableCategory = new ReadableCategory();
readableCategoryPopulator.populate(category, readableCategory, store, language);
String key = new StringBuilder().append(store.getId()).append("_").append(Constants.CATEGORIES_CACHE_KEY).append("-").append(lang.getCode()).toString();
if (category.getDepth().intValue() == 0) {
// List<Category> cacheCategories = null;
List<ReadableCategory> cacheCategories = null;
if (objects == null || objects.size() == 0) {
// objects = new HashMap<String,
// List<Category>>();
objects = new HashMap<String, List<ReadableCategory>>();
}
if (!objects.containsKey(key)) {
// cacheCategories = new ArrayList<Category>();
cacheCategories = new ArrayList<ReadableCategory>();
objects.put(key, cacheCategories);
} else {
cacheCategories = objects.get(key.toString());
if (cacheCategories == null) {
LOGGER.error("Cannot find categories key in cache " + key);
continue;
}
}
// cacheCategories.add(category);
cacheCategories.add(readableCategory);
} else {
subs.put(lang.getCode(), readableCategory);
}
}
}
}
}
return objects;
}
Aggregations