You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by mr...@apache.org on 2008/01/19 18:46:01 UTC
svn commit: r613432 -
/ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryServices.java
Author: mrisaliti
Date: Sat Jan 19 09:46:01 2008
New Revision: 613432
URL: http://svn.apache.org/viewvc?rev=613432&view=rev
Log:
Get the real field name from the order by field removing ascending/descending order, to retrieve the correct entity name in the method CategoryServices.getCategoryFindEntityName
Modified:
ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryServices.java
Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryServices.java?rev=613432&r1=613431&r2=613432&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryServices.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryServices.java Sat Jan 19 09:46:01 2008
@@ -29,6 +29,7 @@
import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.UtilDateTime;
import org.ofbiz.base.util.UtilMisc;
+import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
@@ -157,6 +158,26 @@
Iterator orderByFieldIter = orderByFields.iterator();
while (orderByFieldIter.hasNext()) {
String orderByField = (String) orderByFieldIter.next();
+
+ // Get the real field name from the order by field removing ascending/descending order
+ if (UtilValidate.isNotEmpty(orderByField)) {
+ int startPos = 0, endPos = orderByField.length();
+
+ if (orderByField.endsWith(" DESC")) {
+ endPos -= 5;
+ } else if (orderByField.endsWith(" ASC")) {
+ endPos -= 4;
+ } else if (orderByField.startsWith("-")) {
+ startPos++;
+ } else if (orderByField.startsWith("+")) {
+ startPos++;
+ }
+
+ if (startPos != 0 || endPos != orderByField.length()) {
+ orderByField = orderByField.substring(startPos, endPos);
+ }
+ }
+
if (!productCategoryMemberModel.isField(orderByField)) {
if (productModel.isField(orderByField)) {
entityName = "ProductAndCategoryMember";