You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by le...@apache.org on 2014/11/05 22:43:39 UTC
svn commit: r1636970 -
/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityQuery.java
Author: lektran
Date: Wed Nov 5 21:43:39 2014
New Revision: 1636970
URL: http://svn.apache.org/r1636970
Log:
Fix bug in EntityQuery where the moment specified in filterByDate(moment) was not being honoured. Adds a new method filterByDate(Timestamp, String...) to allow a moment to be specified when explicitly specifying filterByFieldNames. Thanks to Pritam Kute for the report
Modified:
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityQuery.java
Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityQuery.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityQuery.java?rev=1636970&r1=1636969&r2=1636970&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityQuery.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityQuery.java Wed Nov 5 21:43:39 2014
@@ -349,8 +349,18 @@ public class EntityQuery {
* @return this EntityQuery object, to enable chaining
*/
public EntityQuery filterByDate(String... filterByFieldName) {
+ return this.filterByDate(null, filterByFieldName);
+ }
+
+ /** Specifies whether the query should return only values that are active during the specified moment using the specified from/thru field name pairs.
+ *
+ * @param moment - Timestamp representing the moment in time that the values should be active during
+ * @param fromThruFieldName - String pairs representing the from/thru date field names e.g. "fromDate", "thruDate", "contactFromDate", "contactThruDate"
+ * @return this EntityQuery object, to enable chaining
+ */
+ public EntityQuery filterByDate(Timestamp moment, String... filterByFieldName) {
this.filterByDate = true;
- this.filterByDateMoment = null;
+ this.filterByDateMoment = moment;
if (filterByFieldName.length % 2 != 0) {
throw new IllegalArgumentException("You must pass an even sized array to this method, each pair should represent a from date field name and a thru date field name");
}
@@ -469,7 +479,7 @@ public class EntityQuery {
private EntityCondition makeDateCondition() {
List<EntityCondition> conditions = new ArrayList<EntityCondition>();
if (UtilValidate.isEmpty(this.filterByFieldNames)) {
- this.filterByDate("fromDate", "thruDate");
+ this.filterByDate(filterByDateMoment, "fromDate", "thruDate");
}
for (int i = 0; i < this.filterByFieldNames.size();) {