You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2008/11/30 21:32:48 UTC

svn commit: r721892 - /ofbiz/branches/release4.0/framework/entity/src/org/ofbiz/entity/condition/EntityOperator.java

Author: jleroux
Date: Sun Nov 30 12:32:48 2008
New Revision: 721892

URL: http://svn.apache.org/viewvc?rev=721892&view=rev
Log:
Merged by hand from 721887

Modified:
    ofbiz/branches/release4.0/framework/entity/src/org/ofbiz/entity/condition/EntityOperator.java

Modified: ofbiz/branches/release4.0/framework/entity/src/org/ofbiz/entity/condition/EntityOperator.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release4.0/framework/entity/src/org/ofbiz/entity/condition/EntityOperator.java?rev=721892&r1=721891&r2=721892&view=diff
==============================================================================
--- ofbiz/branches/release4.0/framework/entity/src/org/ofbiz/entity/condition/EntityOperator.java (original)
+++ ofbiz/branches/release4.0/framework/entity/src/org/ofbiz/entity/condition/EntityOperator.java Sun Nov 30 12:32:48 2008
@@ -132,7 +132,10 @@
         protected void makeRHSWhereStringValue(ModelEntity entity, List entityConditionParams, StringBuffer sb, ModelField field, Object rhs) { appendRHSList(entityConditionParams, sb, field, rhs); }
     };
     static { register( "in", IN ); }
-    public static final EntityComparisonOperator BETWEEN = new EntityComparisonOperator(ID_BETWEEN, "BETWEEN");
+    public static final EntityComparisonOperator BETWEEN = new EntityComparisonOperator(ID_BETWEEN, "BETWEEN") {
+        public boolean compare(Comparable lhs, Object rhs) { return EntityComparisonOperator.compareIn(lhs, rhs); }
+        protected void makeRHSWhereStringValue(ModelEntity entity, List entityConditionParams, StringBuffer sb, ModelField field, Object rhs, DatasourceInfo datasourceInfo) { appendRHSBetweenList(entityConditionParams, sb, field, rhs); }  
+    };
     static { register( "between", BETWEEN ); }
     public static final EntityComparisonOperator NOT = new EntityComparisonOperator(ID_NOT, "NOT");
     static { register( "not", NOT ); }
@@ -210,6 +213,21 @@
         }
         whereStringBuffer.append(')');
     }
+    
+    protected void appendRHSBetweenList(List entityConditionParams, StringBuffer whereStringBuffer, ModelField field, Object rhs) {
+        if (rhs instanceof Collection) {
+            Iterator rhsIter = ((Collection) rhs).iterator();
+
+            while (rhsIter.hasNext()) {
+                Object inObj = rhsIter.next();
+
+                addValue(whereStringBuffer, field, inObj, entityConditionParams);
+                if (rhsIter.hasNext()) {
+                    whereStringBuffer.append(" AND ");
+                }
+            }
+        } 
+    }    
 
     public Object eval(GenericDelegator delegator, Map map, Object lhs, Object rhs) {
         return castBoolean(mapMatches(delegator, map, lhs, rhs));