final MarketArea currentMarketArea = requestData.getMarketArea();
final String catalogType = request.getParameter(RequestConstants.REQUEST_PARAMETER_CATALOG_TYPE);
CatalogPojo catalogPojo = new CatalogPojo();
if("master".equals(catalogType)){
final CatalogMaster catalogMaster = catalogService.getMasterCatalogById(currentMarketArea.getCatalog().getCatalogMaster().getId());
Set<CatalogCategoryMaster> catalogCategories = new HashSet<CatalogCategoryMaster>();
if(catalogMaster.getCatalogCategories() != null){
for (Iterator<CatalogCategoryMaster> iterator = catalogMaster.getCatalogCategories().iterator(); iterator.hasNext();) {
CatalogCategoryMaster categoryMaster = (CatalogCategoryMaster) iterator.next();
CatalogCategoryMaster reloadedCategoryMaster = catalogCategoryService.getMasterCatalogCategoryById(categoryMaster.getId(), new FetchPlan(categoryMasterFetchPlans));
Set<CatalogCategoryMaster> reloadedSubCategories = new HashSet<CatalogCategoryMaster>();
if(reloadedCategoryMaster.getSortedChildCatalogCategories() != null){
for (Iterator<CatalogCategoryMaster> iteratorSubCategories = reloadedCategoryMaster.getSortedChildCatalogCategories().iterator(); iteratorSubCategories.hasNext();) {
CatalogCategoryMaster subCategory = (CatalogCategoryMaster) iteratorSubCategories.next();
CatalogCategoryMaster reloadedSubCategory = catalogCategoryService.getMasterCatalogCategoryById(subCategory.getId(), new FetchPlan(categoryMasterFetchPlans));
reloadedSubCategories.add(reloadedSubCategory);
}
}
reloadedCategoryMaster.setCatalogCategories(reloadedSubCategories);
catalogCategories.add(reloadedCategoryMaster);
}
}
catalogMaster.setCatalogCategories(new HashSet<CatalogCategoryMaster>(catalogCategories));
try {
catalogPojo = (CatalogPojo) catalogPojoService.buildMasterCatalog(catalogMaster);
} catch (Exception e) {
logger.error("", e);