svn commit: r1304207 - /ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryWorker.java

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

svn commit: r1304207 - /ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryWorker.java

jleroux@apache.org
Author: jleroux
Date: Fri Mar 23 06:41:56 2012
New Revision: 1304207

URL: http://svn.apache.org/viewvc?rev=1304207&view=rev
Log:
A patch from Markus M. May "Minor Refactoring in CategoryWorker - use delegator instead of request in getRelatedCategoriesRet" https://issues.apache.org/jira/browse/OFBIZ-4738

The method getRelatedCategoriesRet uses the request, the final called method could be called using the delegator directly easily. I have refactored the method accordingly.

Modified:
    ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryWorker.java

Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryWorker.java?rev=1304207&r1=1304206&r2=1304207&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryWorker.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryWorker.java Fri Mar 23 06:41:56 2012
@@ -135,11 +135,16 @@ public class CategoryWorker {
     }
 
     public static List<GenericValue> getRelatedCategoriesRet(ServletRequest request, String attributeName, String parentId, boolean limitView, boolean excludeEmpty, boolean recursive) {
+      Delegator delegator = (Delegator) request.getAttribute("delegator");
+
+      return getRelatedCategoriesRet(delegator, attributeName, parentId, limitView, excludeEmpty, false);
+    }
+
+    public static List<GenericValue> getRelatedCategoriesRet(Delegator delegator, String attributeName, String parentId, boolean limitView, boolean excludeEmpty, boolean recursive) {
         List<GenericValue> categories = FastList.newInstance();
 
         if (Debug.verboseOn()) Debug.logVerbose("[CategoryWorker.getRelatedCategories] ParentID: " + parentId, module);
 
-        Delegator delegator = (Delegator) request.getAttribute("delegator");
         List<GenericValue> rollups = null;
 
         try {
@@ -169,13 +174,13 @@ public class CategoryWorker {
                             //Debug.logInfo("Child : " + cv.getString("productCategoryId") + " is not empty.", module);
                             categories.add(cv);
                             if (recursive) {
-                                categories.addAll(getRelatedCategoriesRet(request, attributeName, cv.getString("productCategoryId"), limitView, excludeEmpty, recursive));
+                                categories.addAll(getRelatedCategoriesRet(delegator, attributeName, cv.getString("productCategoryId"), limitView, excludeEmpty, recursive));
                             }
                         }
                     } else {
                         categories.add(cv);
                         if (recursive) {
-                            categories.addAll(getRelatedCategoriesRet(request, attributeName, cv.getString("productCategoryId"), limitView, excludeEmpty, recursive));
+                            categories.addAll(getRelatedCategoriesRet(delegator, attributeName, cv.getString("productCategoryId"), limitView, excludeEmpty, recursive));
                         }
                     }
                 }