svn commit: r1162688 - /ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/category/CategoryTree.groovy

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1162688 - /ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/category/CategoryTree.groovy

hansbak-2
Author: hansbak
Date: Mon Aug 29 09:09:50 2011
New Revision: 1162688

URL: http://svn.apache.org/viewvc?rev=1162688&view=rev
Log:
comment put forward in jira OFBIZ-4375 by Atul Vani with addition by 'M'

Modified:
    ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/category/CategoryTree.groovy

Modified: ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/category/CategoryTree.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/category/CategoryTree.groovy?rev=1162688&r1=1162687&r2=1162688&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/category/CategoryTree.groovy (original)
+++ ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/category/CategoryTree.groovy Mon Aug 29 09:09:50 2011
@@ -22,69 +22,44 @@
  * should not contain order component's specific code.
  */
 import org.ofbiz.entity.util.EntityUtil;
-import org.ofbiz.base.util.*;
-import org.ofbiz.product.catalog.*;
-import org.ofbiz.product.category.*;
 import javolution.util.FastMap;
 import javolution.util.FastList;
-import javolution.util.FastList.*;
-import org.ofbiz.entity.*;
-import java.util.List;
 
 // Put the result of CategoryWorker.getRelatedCategories into the separateRootType function as attribute.
 // The separateRootType function will return the list of category of given catalog.
 // PLEASE NOTE : The structure of the list of separateRootType function is according to the JSON_DATA plugin of the jsTree.
 
-completedTree =  FastList.newInstance();
-
 List separateRootType(roots) {
     if(roots) {
-         prodRootTypeTree = FastList.newInstance();
-         def i = 0;
-        for(root in roots) {
-            prodCatalogMap2 = FastMap.newInstance();
-             prodCatalogTree2 = FastList.newInstance();
-            prodCatalogCategories = FastList.newInstance();
-            prodCatalog = root.getRelatedOne("ProductCategory");
-            
-            productCat = root.getRelatedOne("ProductCategory");
-            prodCatalogId = productCat.getString("productCategoryId");
-            prodCatalogMap2.put("productCategoryId", prodCatalogId);
-            prodCatalogMap2.put("categoryName", productCat.getString("categoryName"));
-            prodCatalogMap2.put("isCatalog", false)
-            prodCatalogMap.put("isCategoryType", true);
-            
-            i++;
-            
-            prodRootTypeTree.add(prodCatalogMap2);
+        prodRootTypeTree = [];
+        roots.each { root ->
+            prodCateMap = [:];
+            productCategory = root.getRelatedOne("ProductCategory");
+            prodCateMap.productCategoryId = productCategory.getString("productCategoryId");
+            prodCateMap.categoryName = productCategory.getString("categoryName");
+            prodCateMap.isCatalog = false;
+            prodCateMap.isCategoryType = true;
+            prodRootTypeTree.add(prodCateMap);
         }
         return prodRootTypeTree;
     }
 }
 
+completedTree =  [];
 // Get the Catalogs
 prodCatalogs = delegator.findByAnd("ProdCatalog");
-
-if (prodCatalogs.size() > 0) {
-    for (i = 0; i < prodCatalogs.size(); i++) {
-        
-        prodCatalogMap = FastMap.newInstance();
-        prodCatalog = prodCatalogs[i];
-        prodCatalogId = prodCatalog.getString("prodCatalogId");
-        prodCatalogMap.put("productCategoryId", prodCatalogId);
-        prodCatalogMap.put("categoryName", prodCatalog.getString("catalogName"));
-        prodCatalogMap.put("isCatalog", true);
-        prodCatalogMap.put("isCategoryType", false);
-        
+if (prodCatalogs) {
+    prodCatalogs.each { prodCatalog ->
+        prodCatalogMap = [:];
+        prodCatalogMap.productCategoryId = prodCatalog.getString("prodCatalogId");
+        prodCatalogMap.categoryName = prodCatalog.getString("catalogName");
+        prodCatalogMap.isCatalog = true;
+        prodCatalogMap.isCategoryType = false;
         prodCatalogCategories = EntityUtil.filterByDate(delegator.findByAnd("ProdCatalogCategory", ["prodCatalogId" : prodCatalog.prodCatalogId]));
-        
-        prodCatalogTree = FastList.newInstance();
-        
         if (prodCatalogCategories) {
-            prodCatalogTree = separateRootType(prodCatalogCategories);
-            prodCatalogMap.put("child", prodCatalogTree);
-            completedTree.add(prodCatalogMap);
+            prodCatalogMap.child = separateRootType(prodCatalogCategories);
         }
+        completedTree.add(prodCatalogMap);
     }
 }
 // The complete tree list for the category tree