Re: svn commit: r1627940 - /ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityQuery.java

2014-10-01 Thread Hans Bakker

Hi Scott,

this is indeed nice, although a duplicate of an existing featureyes 
every advantage often has a disadvantage. :-)


However, can you please add a junit test? These days in the continuous 
integration age i do not think it is acceptable anymore adding new 
functions to the existing API without Junit test?


Regards,
Hans


On 27/09/14 16:22, lekt...@apache.org wrote:

Author: lektran
Date: Sat Sep 27 09:22:31 2014
New Revision: 1627940

URL:http://svn.apache.org/r1627940
Log:
OFBIZ-4053 Implement an entity query builder to be used as a friendlier API for 
executing entity queries.

Entry point is the static EntityQuery.use(Delegator) method which will then 
return an EntityQuery instance whose methods support method chaining to set 
query options.
The query can then be executed using the first(), list(), iterator() and one() 
methods which respectively return:
- The first result from a result set
- The full list of results from a result set
- An EntityListIterator to iterate over a result set
- The single record from a query that will return only one record (such as a 
lookup by primary key)

Added:
 ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityQuery.java   
(with props)

Added: 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=1627940view=auto
==
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityQuery.java 
(added)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityQuery.java Sat 
Sep 27 09:22:31 2014
@@ -0,0 +1,416 @@
+/***
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * License); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ 
***/
+package org.ofbiz.entity.util;
+
+import java.sql.Timestamp;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.UtilMisc;
+import org.ofbiz.entity.Delegator;
+import org.ofbiz.entity.GenericEntityException;
+import org.ofbiz.entity.GenericValue;
+import org.ofbiz.entity.condition.EntityCondition;
+import org.ofbiz.entity.model.DynamicViewEntity;
+import org.ofbiz.entity.util.EntityFindOptions;
+import org.ofbiz.entity.util.EntityListIterator;
+import org.ofbiz.entity.util.EntityUtil;
+
+/**
+ * Used to setup various options for and subsequently execute entity queries.
+ *
+ * All methods to set options modify the EntityQuery instance then return this 
modified object to allow method call chaining. It is
+ * important to note that this object is not immutable and is modified 
internally, and returning EntityQuery is just a
+ * self reference for convenience.
+ *
+ * After a query the object can be further modified and then used to perform 
another query if desired.
+ */
+public class EntityQuery {
+
+public static final String module = EntityQuery.class.getName();
+
+private Delegator delegator;
+private String entityName = null;
+private DynamicViewEntity dynamicViewEntity = null;
+private boolean useCache = false;
+private EntityCondition whereEntityCondition = null;
+private SetString fieldsToSelect = null;
+private ListString orderBy = null;
+private Integer resultSetType = EntityFindOptions.TYPE_FORWARD_ONLY;
+private Integer fetchSize = null;
+private Integer maxRows = null;
+private Boolean distinct = null;
+private EntityCondition havingEntityCondition = null;
+private boolean filterByDate = false;
+private Timestamp filterByDateMoment;
+
+
+
+/** Construct an EntityQuery object for use against the specified Delegator
+ * @param delegator - The delegator instance to use for the query
+ * @return Returns a new EntityQuery object
+ */
+public static EntityQuery use(Delegator delegator) {
+return new EntityQuery(delegator);
+}
+
+/** Construct an EntityQuery object for use against the specified Delegator
+ * @param delegator - The delegator instance to 

Re: svn commit: r1627940 - /ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityQuery.java

2014-09-30 Thread Pranay Pandey

+1

Thanks Scott.

Pranay Pandey
HotWax Media
http://www.hotwaxmedia.com



On Sep 27, 2014, at 3:29 PM, Jacopo Cappellato 
jacopo.cappell...@hotwaxmedia.com wrote:

 This is really an amazing contribution! Thank you Scott.
 
 Jacopo
 
 On Sep 27, 2014, at 11:22 AM, lekt...@apache.org wrote:
 
 Author: lektran
 Date: Sat Sep 27 09:22:31 2014
 New Revision: 1627940
 
 URL: http://svn.apache.org/r1627940
 Log:
 OFBIZ-4053 Implement an entity query builder to be used as a friendlier API 
 for executing entity queries.
 
 Entry point is the static EntityQuery.use(Delegator) method which will then 
 return an EntityQuery instance whose methods support method chaining to set 
 query options.
 The query can then be executed using the first(), list(), iterator() and 
 one() methods which respectively return:
 - The first result from a result set
 - The full list of results from a result set
 - An EntityListIterator to iterate over a result set
 - The single record from a query that will return only one record (such as a 
 lookup by primary key)
 
 Added:
   ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityQuery.java   
 (with props)
 
 Added: 
 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=1627940view=auto
 ==
 --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityQuery.java 
 (added)
 +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityQuery.java 
 Sat Sep 27 09:22:31 2014
 @@ -0,0 +1,416 @@
 +/***
 + * Licensed to the Apache Software Foundation (ASF) under one
 + * or more contributor license agreements.  See the NOTICE file
 + * distributed with this work for additional information
 + * regarding copyright ownership.  The ASF licenses this file
 + * to you under the Apache License, Version 2.0 (the
 + * License); you may not use this file except in compliance
 + * with the License.  You may obtain a copy of the License at
 + *
 + * http://www.apache.org/licenses/LICENSE-2.0
 + *
 + * Unless required by applicable law or agreed to in writing,
 + * software distributed under the License is distributed on an
 + * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 + * KIND, either express or implied.  See the License for the
 + * specific language governing permissions and limitations
 + * under the License.
 + 
 ***/
 +package org.ofbiz.entity.util;
 +
 +import java.sql.Timestamp;
 +import java.util.Arrays;
 +import java.util.List;
 +import java.util.Map;
 +import java.util.Set;
 +
 +import org.ofbiz.base.util.Debug;
 +import org.ofbiz.base.util.UtilMisc;
 +import org.ofbiz.entity.Delegator;
 +import org.ofbiz.entity.GenericEntityException;
 +import org.ofbiz.entity.GenericValue;
 +import org.ofbiz.entity.condition.EntityCondition;
 +import org.ofbiz.entity.model.DynamicViewEntity;
 +import org.ofbiz.entity.util.EntityFindOptions;
 +import org.ofbiz.entity.util.EntityListIterator;
 +import org.ofbiz.entity.util.EntityUtil;
 +
 +/**
 + * Used to setup various options for and subsequently execute entity 
 queries.
 + *
 + * All methods to set options modify the EntityQuery instance then return 
 this modified object to allow method call chaining. It is
 + * important to note that this object is not immutable and is modified 
 internally, and returning EntityQuery is just a
 + * self reference for convenience.
 + *
 + * After a query the object can be further modified and then used to 
 perform another query if desired.
 + */
 +public class EntityQuery {
 +
 +public static final String module = EntityQuery.class.getName();
 +
 +private Delegator delegator;
 +private String entityName = null;
 +private DynamicViewEntity dynamicViewEntity = null;
 +private boolean useCache = false;
 +private EntityCondition whereEntityCondition = null;
 +private SetString fieldsToSelect = null;
 +private ListString orderBy = null;
 +private Integer resultSetType = EntityFindOptions.TYPE_FORWARD_ONLY;
 +private Integer fetchSize = null;
 +private Integer maxRows = null;
 +private Boolean distinct = null;
 +private EntityCondition havingEntityCondition = null;
 +private boolean filterByDate = false;
 +private Timestamp filterByDateMoment;
 +
 +
 +
 +/** Construct an EntityQuery object for use against the specified 
 Delegator
 + * @param delegator - The delegator instance to use for the query
 + * @return Returns a new EntityQuery object
 + */
 +public static EntityQuery use(Delegator delegator) {
 +return new EntityQuery(delegator);
 +}
 +
 +/** Construct an EntityQuery object for use against the specified 
 Delegator
 + * @param 

Re: svn commit: r1627940 - /ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityQuery.java

2014-09-29 Thread Scott Gray
Thanks Jacopo!  I've begun converting the accounting component to use 
EntityQuery in r1628288, if anyone wants to help please feel free :-)

Regards
Scott

On 27/09/2014, at 9:59 pm, Jacopo Cappellato 
jacopo.cappell...@hotwaxmedia.com wrote:

 This is really an amazing contribution! Thank you Scott.
 
 Jacopo
 
 On Sep 27, 2014, at 11:22 AM, lekt...@apache.org wrote:
 
 Author: lektran
 Date: Sat Sep 27 09:22:31 2014
 New Revision: 1627940
 
 URL: http://svn.apache.org/r1627940
 Log:
 OFBIZ-4053 Implement an entity query builder to be used as a friendlier API 
 for executing entity queries.
 
 Entry point is the static EntityQuery.use(Delegator) method which will then 
 return an EntityQuery instance whose methods support method chaining to set 
 query options.
 The query can then be executed using the first(), list(), iterator() and 
 one() methods which respectively return:
 - The first result from a result set
 - The full list of results from a result set
 - An EntityListIterator to iterate over a result set
 - The single record from a query that will return only one record (such as a 
 lookup by primary key)
 
 Added:
   ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityQuery.java   
 (with props)
 
 Added: 
 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=1627940view=auto
 ==
 --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityQuery.java 
 (added)
 +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityQuery.java 
 Sat Sep 27 09:22:31 2014
 @@ -0,0 +1,416 @@
 +/***
 + * Licensed to the Apache Software Foundation (ASF) under one
 + * or more contributor license agreements.  See the NOTICE file
 + * distributed with this work for additional information
 + * regarding copyright ownership.  The ASF licenses this file
 + * to you under the Apache License, Version 2.0 (the
 + * License); you may not use this file except in compliance
 + * with the License.  You may obtain a copy of the License at
 + *
 + * http://www.apache.org/licenses/LICENSE-2.0
 + *
 + * Unless required by applicable law or agreed to in writing,
 + * software distributed under the License is distributed on an
 + * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 + * KIND, either express or implied.  See the License for the
 + * specific language governing permissions and limitations
 + * under the License.
 + 
 ***/
 +package org.ofbiz.entity.util;
 +
 +import java.sql.Timestamp;
 +import java.util.Arrays;
 +import java.util.List;
 +import java.util.Map;
 +import java.util.Set;
 +
 +import org.ofbiz.base.util.Debug;
 +import org.ofbiz.base.util.UtilMisc;
 +import org.ofbiz.entity.Delegator;
 +import org.ofbiz.entity.GenericEntityException;
 +import org.ofbiz.entity.GenericValue;
 +import org.ofbiz.entity.condition.EntityCondition;
 +import org.ofbiz.entity.model.DynamicViewEntity;
 +import org.ofbiz.entity.util.EntityFindOptions;
 +import org.ofbiz.entity.util.EntityListIterator;
 +import org.ofbiz.entity.util.EntityUtil;
 +
 +/**
 + * Used to setup various options for and subsequently execute entity 
 queries.
 + *
 + * All methods to set options modify the EntityQuery instance then return 
 this modified object to allow method call chaining. It is
 + * important to note that this object is not immutable and is modified 
 internally, and returning EntityQuery is just a
 + * self reference for convenience.
 + *
 + * After a query the object can be further modified and then used to 
 perform another query if desired.
 + */
 +public class EntityQuery {
 +
 +public static final String module = EntityQuery.class.getName();
 +
 +private Delegator delegator;
 +private String entityName = null;
 +private DynamicViewEntity dynamicViewEntity = null;
 +private boolean useCache = false;
 +private EntityCondition whereEntityCondition = null;
 +private SetString fieldsToSelect = null;
 +private ListString orderBy = null;
 +private Integer resultSetType = EntityFindOptions.TYPE_FORWARD_ONLY;
 +private Integer fetchSize = null;
 +private Integer maxRows = null;
 +private Boolean distinct = null;
 +private EntityCondition havingEntityCondition = null;
 +private boolean filterByDate = false;
 +private Timestamp filterByDateMoment;
 +
 +
 +
 +/** Construct an EntityQuery object for use against the specified 
 Delegator
 + * @param delegator - The delegator instance to use for the query
 + * @return Returns a new EntityQuery object
 + */
 +public static EntityQuery use(Delegator delegator) {
 +return new EntityQuery(delegator);
 +}
 +
 +/** Construct an 

Re: svn commit: r1627940 - /ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityQuery.java

2014-09-27 Thread Jacopo Cappellato
This is really an amazing contribution! Thank you Scott.

Jacopo

On Sep 27, 2014, at 11:22 AM, lekt...@apache.org wrote:

 Author: lektran
 Date: Sat Sep 27 09:22:31 2014
 New Revision: 1627940
 
 URL: http://svn.apache.org/r1627940
 Log:
 OFBIZ-4053 Implement an entity query builder to be used as a friendlier API 
 for executing entity queries.
 
 Entry point is the static EntityQuery.use(Delegator) method which will then 
 return an EntityQuery instance whose methods support method chaining to set 
 query options.
 The query can then be executed using the first(), list(), iterator() and 
 one() methods which respectively return:
 - The first result from a result set
 - The full list of results from a result set
 - An EntityListIterator to iterate over a result set
 - The single record from a query that will return only one record (such as a 
 lookup by primary key)
 
 Added:
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityQuery.java   
 (with props)
 
 Added: 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=1627940view=auto
 ==
 --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityQuery.java 
 (added)
 +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityQuery.java 
 Sat Sep 27 09:22:31 2014
 @@ -0,0 +1,416 @@
 +/***
 + * Licensed to the Apache Software Foundation (ASF) under one
 + * or more contributor license agreements.  See the NOTICE file
 + * distributed with this work for additional information
 + * regarding copyright ownership.  The ASF licenses this file
 + * to you under the Apache License, Version 2.0 (the
 + * License); you may not use this file except in compliance
 + * with the License.  You may obtain a copy of the License at
 + *
 + * http://www.apache.org/licenses/LICENSE-2.0
 + *
 + * Unless required by applicable law or agreed to in writing,
 + * software distributed under the License is distributed on an
 + * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 + * KIND, either express or implied.  See the License for the
 + * specific language governing permissions and limitations
 + * under the License.
 + 
 ***/
 +package org.ofbiz.entity.util;
 +
 +import java.sql.Timestamp;
 +import java.util.Arrays;
 +import java.util.List;
 +import java.util.Map;
 +import java.util.Set;
 +
 +import org.ofbiz.base.util.Debug;
 +import org.ofbiz.base.util.UtilMisc;
 +import org.ofbiz.entity.Delegator;
 +import org.ofbiz.entity.GenericEntityException;
 +import org.ofbiz.entity.GenericValue;
 +import org.ofbiz.entity.condition.EntityCondition;
 +import org.ofbiz.entity.model.DynamicViewEntity;
 +import org.ofbiz.entity.util.EntityFindOptions;
 +import org.ofbiz.entity.util.EntityListIterator;
 +import org.ofbiz.entity.util.EntityUtil;
 +
 +/**
 + * Used to setup various options for and subsequently execute entity queries.
 + *
 + * All methods to set options modify the EntityQuery instance then return 
 this modified object to allow method call chaining. It is
 + * important to note that this object is not immutable and is modified 
 internally, and returning EntityQuery is just a
 + * self reference for convenience.
 + *
 + * After a query the object can be further modified and then used to perform 
 another query if desired.
 + */
 +public class EntityQuery {
 +
 +public static final String module = EntityQuery.class.getName();
 +
 +private Delegator delegator;
 +private String entityName = null;
 +private DynamicViewEntity dynamicViewEntity = null;
 +private boolean useCache = false;
 +private EntityCondition whereEntityCondition = null;
 +private SetString fieldsToSelect = null;
 +private ListString orderBy = null;
 +private Integer resultSetType = EntityFindOptions.TYPE_FORWARD_ONLY;
 +private Integer fetchSize = null;
 +private Integer maxRows = null;
 +private Boolean distinct = null;
 +private EntityCondition havingEntityCondition = null;
 +private boolean filterByDate = false;
 +private Timestamp filterByDateMoment;
 +
 +
 +
 +/** Construct an EntityQuery object for use against the specified 
 Delegator
 + * @param delegator - The delegator instance to use for the query
 + * @return Returns a new EntityQuery object
 + */
 +public static EntityQuery use(Delegator delegator) {
 +return new EntityQuery(delegator);
 +}
 +
 +/** Construct an EntityQuery object for use against the specified 
 Delegator
 + * @param delegator - The delegator instance to use for the query
 + * @return Returns a new EntityQuery object
 + */
 +public EntityQuery(Delegator delegator) {
 +