shopizer-uncached

Manage invisible category

1/5/2017 4:06:38 PM

Details

diff --git a/shopizer-shipping-distance-module/target/classes/META-INF/maven/com.shopizer/shopizer-shipping-distance-processor/pom.properties b/shopizer-shipping-distance-module/target/classes/META-INF/maven/com.shopizer/shopizer-shipping-distance-processor/pom.properties
index f05595e..8de083f 100644
--- a/shopizer-shipping-distance-module/target/classes/META-INF/maven/com.shopizer/shopizer-shipping-distance-processor/pom.properties
+++ b/shopizer-shipping-distance-module/target/classes/META-INF/maven/com.shopizer/shopizer-shipping-distance-processor/pom.properties
@@ -1,5 +1,5 @@
 #Generated by Maven Integration for Eclipse
-#Thu Jan 05 09:25:12 EST 2017
+#Thu Jan 05 12:13:33 EST 2017
 version=2.0.5-SNAPSHOT
 groupId=com.shopizer
 m2e.projectName=shopizer-shipping-distance-processor
diff --git a/sm-search/target/classes/META-INF/maven/com.shopizer/sm-search/pom.properties b/sm-search/target/classes/META-INF/maven/com.shopizer/sm-search/pom.properties
index b2e7848..4f001c2 100644
--- a/sm-search/target/classes/META-INF/maven/com.shopizer/sm-search/pom.properties
+++ b/sm-search/target/classes/META-INF/maven/com.shopizer/sm-search/pom.properties
@@ -1,5 +1,5 @@
 #Generated by Maven Integration for Eclipse
-#Thu Jan 05 09:25:16 EST 2017
+#Thu Jan 05 12:13:40 EST 2017
 version=2.0.5-SNAPSHOT
 groupId=com.shopizer
 m2e.projectName=sm-search
diff --git a/sm-shop/SALESMANAGER.h2.db b/sm-shop/SALESMANAGER.h2.db
index 231da43..4a0a8f1 100644
Binary files a/sm-shop/SALESMANAGER.h2.db and b/sm-shop/SALESMANAGER.h2.db differ
diff --git a/sm-shop/SALESMANAGER.lock.db b/sm-shop/SALESMANAGER.lock.db
index cb2dcc7..9e1dc99 100644
--- a/sm-shop/SALESMANAGER.lock.db
+++ b/sm-shop/SALESMANAGER.lock.db
@@ -1,4 +1,4 @@
 #FileLock
-#Thu Jan 05 09:26:18 EST 2017
-id=1596f05ebf868c32b30071c1446acce7899d1a5acd8
+#Thu Jan 05 13:01:50 EST 2017
+id=1596fcb41afecea71330662d56c999ae5e5ddb7766f
 method=file
diff --git a/sm-shop/src/main/java/com/salesmanager/shop/populator/order/ReadableOrderPopulator.java b/sm-shop/src/main/java/com/salesmanager/shop/populator/order/ReadableOrderPopulator.java
index b1b71be..4c712f8 100644
--- a/sm-shop/src/main/java/com/salesmanager/shop/populator/order/ReadableOrderPopulator.java
+++ b/sm-shop/src/main/java/com/salesmanager/shop/populator/order/ReadableOrderPopulator.java
@@ -62,8 +62,8 @@ public class ReadableOrderPopulator extends
 		if(source.getDelivery()!=null) {
 			ReadableDelivery address = new ReadableDelivery();
 			address.setCity(source.getDelivery().getCity());
-			address.setAddress(source.getDelivery().getAddress())
-;			address.setCompany(source.getDelivery().getCompany());
+			address.setAddress(source.getDelivery().getAddress());
+			address.setCompany(source.getDelivery().getCompany());
 			address.setFirstName(source.getDelivery().getFirstName());
 			address.setLastName(source.getDelivery().getLastName());
 			address.setPostalCode(source.getDelivery().getPostalCode());
diff --git a/sm-shop/src/main/java/com/salesmanager/shop/store/controller/category/ShoppingCategoryController.java b/sm-shop/src/main/java/com/salesmanager/shop/store/controller/category/ShoppingCategoryController.java
index b97a93e..f4c401d 100644
--- a/sm-shop/src/main/java/com/salesmanager/shop/store/controller/category/ShoppingCategoryController.java
+++ b/sm-shop/src/main/java/com/salesmanager/shop/store/controller/category/ShoppingCategoryController.java
@@ -151,6 +151,10 @@ public class ShoppingCategoryController {
 			
 		}
 		
+		if(!category.isVisible()) {
+			return PageBuilderUtils.buildHomePage(store);
+		}
+		
 		ReadableCategoryPopulator populator = new ReadableCategoryPopulator();
 		ReadableCategory categoryProxy = populator.populate(category, new ReadableCategory(), store, language);
 
@@ -178,7 +182,9 @@ public class ShoppingCategoryController {
 		List<Long> subIds = new ArrayList<Long>();
 		if(subCategs!=null && subCategs.size()>0) {
 			for(Category c : subCategs) {
-				subIds.add(c.getId());
+				if(c.isVisible()) {
+					subIds.add(c.getId());
+				}
 			}
 		}
 		subIds.add(category.getId());
@@ -212,7 +218,7 @@ public class ShoppingCategoryController {
 				//Boolean missedContent = (Boolean)cache.getFromCache(subCategoriesMissed.toString());
 
 				//if(missedContent==null) {
-					countProductsByCategories = getProductsByCategory(store, category, lineage, subCategs);
+					countProductsByCategories = getProductsByCategory(store, category, lineage, subIds);
 					subCategories = getSubCategories(store,category,countProductsByCategories,language,locale);
 					
 					if(subCategories!=null) {
@@ -223,7 +229,7 @@ public class ShoppingCategoryController {
 				//}
 			}
 		} else {
-			countProductsByCategories = getProductsByCategory(store, category, lineage, subCategs);
+			countProductsByCategories = getProductsByCategory(store, category, lineage, subIds);
 			subCategories = getSubCategories(store,category,countProductsByCategories,language,locale);
 		}
 
@@ -315,37 +321,33 @@ public class ShoppingCategoryController {
 		return manufacturerList;
 	}
 	
-	private Map<Long,Long> getProductsByCategory(MerchantStore store, Category category, String lineage, List<Category> subCategories) throws Exception {
+	private Map<Long,Long> getProductsByCategory(MerchantStore store, Category category, String lineage, List<Long> subIds) throws Exception {
 
-		if(subCategories.isEmpty()) {
+		if(subIds.isEmpty()) {
 			return null;
 		}
-		List<Long> ids = new ArrayList<Long>();
-		if(subCategories!=null && subCategories.size()>0) {
-			for(Category c : subCategories) {
-				ids.add(c.getId());
-			}
-		} 
 
-		List<Object[]> countProductsByCategories = categoryService.countProductsByCategories(store, ids);
+		List<Object[]> countProductsByCategories = categoryService.countProductsByCategories(store, subIds);
 		Map<Long, Long> countByCategories = new HashMap<Long,Long>();
 		
 		for(Object[] counts : countProductsByCategories) {
 			Category c = (Category)counts[0];
-			if(c.getParent().getId()==category.getId()) {
-				countByCategories.put(c.getId(), (Long)counts[1]);
-			} else {
-				//get lineage
-				String lin = c.getLineage();
-				String[] categoryPath = lin.split(Constants.CATEGORY_LINEAGE_DELIMITER);
-				for(int i=0 ; i<categoryPath.length; i++) {
-					String sId = categoryPath[i];
-					if(!StringUtils.isBlank(sId)) {
-							Long count = countByCategories.get(Long.parseLong(sId));
-							if(count!=null) {
-								count = count + (Long)counts[1];
-								countByCategories.put(Long.parseLong(sId), count);
-							}
+			if(c.getParent()!=null) {
+				if(c.getParent().getId()==category.getId()) {
+					countByCategories.put(c.getId(), (Long)counts[1]);
+				} else {
+					//get lineage
+					String lin = c.getLineage();
+					String[] categoryPath = lin.split(Constants.CATEGORY_LINEAGE_DELIMITER);
+					for(int i=0 ; i<categoryPath.length; i++) {
+						String sId = categoryPath[i];
+						if(!StringUtils.isBlank(sId)) {
+								Long count = countByCategories.get(Long.parseLong(sId));
+								if(count!=null) {
+									count = count + (Long)counts[1];
+									countByCategories.put(Long.parseLong(sId), count);
+								}
+						}
 					}
 				}
 			}
@@ -590,12 +592,7 @@ public class ShoppingCategoryController {
 		
 		try {
 
-			
-			/**
-			 * How to Spring MVC Rest web service - ajax / jquery
-			 * http://codetutr.com/2013/04/09/spring-mvc-easy-rest-based-json-services-with-responsebody/
-			 */
-			
+
 			MerchantStore merchantStore = (MerchantStore)request.getAttribute(Constants.MERCHANT_STORE);
 			List<BigDecimal> prices = new ArrayList<BigDecimal>();
 			
@@ -633,7 +630,9 @@ public class ShoppingCategoryController {
 			List<Long> ids = new ArrayList<Long>();
 			if(categories!=null && categories.size()>0) {
 				for(Category c : categories) {
-					ids.add(c.getId());
+					if(c.isVisible()) {
+						ids.add(c.getId());
+					}
 				}
 			} 
 			ids.add(cat.getId());
diff --git a/sm-shop/src/main/java/com/salesmanager/shop/utils/PageBuilderUtils.java b/sm-shop/src/main/java/com/salesmanager/shop/utils/PageBuilderUtils.java
index 7c48144..3c1a353 100644
--- a/sm-shop/src/main/java/com/salesmanager/shop/utils/PageBuilderUtils.java
+++ b/sm-shop/src/main/java/com/salesmanager/shop/utils/PageBuilderUtils.java
@@ -1,6 +1,7 @@
 package com.salesmanager.shop.utils;
 
 import com.salesmanager.core.model.merchant.MerchantStore;
+import com.salesmanager.shop.constants.Constants;
 import com.salesmanager.shop.store.controller.ControllerConstants;
 
 public class PageBuilderUtils {
@@ -8,5 +9,9 @@ public class PageBuilderUtils {
 	public static String build404(MerchantStore store) {
 		return new StringBuilder().append(ControllerConstants.Tiles.Pages.notFound).append(".").append(store.getStoreTemplate()).toString();
 	}
+	
+	public static String buildHomePage(MerchantStore store) {
+		return "redirect:" + Constants.SHOP_URI;
+	}
 
 }
diff --git a/sm-shop/target/m2e-wtp/web-resources/META-INF/maven/com.shopizer/sm-shop/pom.properties b/sm-shop/target/m2e-wtp/web-resources/META-INF/maven/com.shopizer/sm-shop/pom.properties
index 92366e3..a30e03e 100644
--- a/sm-shop/target/m2e-wtp/web-resources/META-INF/maven/com.shopizer/sm-shop/pom.properties
+++ b/sm-shop/target/m2e-wtp/web-resources/META-INF/maven/com.shopizer/sm-shop/pom.properties
@@ -1,5 +1,5 @@
 #Generated by Maven Integration for Eclipse
-#Thu Jan 05 09:25:19 EST 2017
+#Thu Jan 05 12:13:42 EST 2017
 version=2.0.5-SNAPSHOT
 groupId=com.shopizer
 m2e.projectName=sm-shop