[ofbiz-framework] branch trunk updated: Improved: Introduce support for having condition in EntityQuery#queryList method(OFBIZ-11846)

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

[ofbiz-framework] branch trunk updated: Improved: Introduce support for having condition in EntityQuery#queryList method(OFBIZ-11846)

Pawan Verma-2
This is an automated email from the ASF dual-hosted git repository.

pawan pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 5c27d7a  Improved: Introduce support for having condition in EntityQuery#queryList method(OFBIZ-11846)
5c27d7a is described below

commit 5c27d7ad5bc7017048293ad2be356a0214dd36de
Author: Pawan Verma <[hidden email]>
AuthorDate: Sat Jul 11 09:36:13 2020 +0530

    Improved: Introduce support for having condition in EntityQuery#queryList method(OFBIZ-11846)
   
    Thanks, Nitish and Suraj for review.
---
 .../java/org/apache/ofbiz/entity/Delegator.java    | 29 ++++++++++++++++++++++
 .../org/apache/ofbiz/entity/GenericDelegator.java  | 16 ++++++++++--
 .../org/apache/ofbiz/entity/util/EntityQuery.java  |  4 +--
 3 files changed, 45 insertions(+), 4 deletions(-)

diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/Delegator.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/Delegator.java
index 4b7213c..4b7bf2e 100644
--- a/framework/entity/src/main/java/org/apache/ofbiz/entity/Delegator.java
+++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/Delegator.java
@@ -343,6 +343,35 @@ public interface Delegator {
      * Finds GenericValues by the conditions specified in the EntityCondition
      * object, the the EntityCondition javadoc for more details.
      *
+     * @param entityName
+     *            The name of the Entity as defined in the entity XML file
+     * @param entityCondition
+     *            The EntityCondition object that specifies how to constrain
+     *            this query before any groupings are done (if this is a view
+     *            entity with group-by aliases)
+     * @param havingEntityCondition
+     *            The EntityCondition object that specifies how to constrain
+     *            this query after any groupings are done (if this is a view
+     *            entity with group-by aliases)
+     * @param fieldsToSelect
+     *            The fields of the named entity to get from the database; if
+     *            empty or null all fields will be retrieved
+     * @param orderBy
+     *            The fields of the named entity to order the query by;
+     *            optionally add a " ASC" for ascending or " DESC" for
+     *            descending
+     * @param findOptions
+     *            An instance of EntityFindOptions that specifies advanced query
+     *            options. See the EntityFindOptions JavaDoc for more details.
+     * @return List of GenericValue objects representing the result
+     */
+    List<GenericValue> findList(String entityName, EntityCondition entityCondition, EntityCondition havingEntityCondition, Set<String> fieldsToSelect,
+                                List<String> orderBy, EntityFindOptions findOptions, boolean useCache) throws GenericEntityException;
+
+    /**
+     * Finds GenericValues by the conditions specified in the EntityCondition
+     * object, the the EntityCondition javadoc for more details.
+     *
      * @param dynamicViewEntity
      *            The DynamicViewEntity to use for the entity model for this
      *            query; generally created on the fly for limited use
diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/GenericDelegator.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/GenericDelegator.java
index 3988742..9f9c5b1 100644
--- a/framework/entity/src/main/java/org/apache/ofbiz/entity/GenericDelegator.java
+++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/GenericDelegator.java
@@ -1546,10 +1546,22 @@ public class GenericDelegator implements Delegator {
     }
 
     /* (non-Javadoc)
+     * @see org.apache.ofbiz.entity.Delegator#findList(java.lang.String, org.apache.ofbiz.entity.condition.EntityCondition,
+     *  org.apache.ofbiz.entity.condition.EntityCondition, org.apache.ofbiz.entity.condition.EntityCondition, java.util.Set,
+     *  java.util.List, org.apache.ofbiz.entity.util.EntityFindOptions, boolean)
+     */
+    @Override
+    public List<GenericValue> findList(String entityName, EntityCondition entityCondition, Set<String> fieldsToSelect, List<String> orderBy,
+                                       EntityFindOptions findOptions, boolean useCache) throws GenericEntityException {
+        return findList(entityName, entityCondition, null, fieldsToSelect, orderBy, findOptions, useCache);
+    }
+
+    /* (non-Javadoc)
      * @see org.apache.ofbiz.entity.Delegator#findList(java.lang.String, org.apache.ofbiz.entity.condition.EntityCondition, java.util.Set, java.util.List, org.apache.ofbiz.entity.util.EntityFindOptions, boolean)
      */
     @Override
-    public List<GenericValue> findList(String entityName, EntityCondition entityCondition, Set<String> fieldsToSelect, List<String> orderBy, EntityFindOptions findOptions, boolean useCache) throws GenericEntityException {
+    public List<GenericValue> findList(String entityName, EntityCondition entityCondition, EntityCondition havingCondition,
+                  Set<String> fieldsToSelect, List<String> orderBy, EntityFindOptions findOptions, boolean useCache) throws GenericEntityException {
 
         EntityEcaRuleRunner<?> ecaRunner = null;
         GenericValue dummyValue = null;
@@ -1572,7 +1584,7 @@ public class GenericDelegator implements Delegator {
             }
 
             List<GenericValue> list = null;
-            try (EntityListIterator eli = this.find(entityName, entityCondition, null, fieldsToSelect, orderBy, findOptions)) {
+            try (EntityListIterator eli = this.find(entityName, entityCondition, havingCondition, fieldsToSelect, orderBy, findOptions)) {
                 list = eli.getCompleteList();
             }
 
diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/util/EntityQuery.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/util/EntityQuery.java
index 7fcb67c..f759134 100644
--- a/framework/entity/src/main/java/org/apache/ofbiz/entity/util/EntityQuery.java
+++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/util/EntityQuery.java
@@ -472,8 +472,8 @@ public class EntityQuery {
             findOptions = efo;
         }
         List<GenericValue> result = null;
-        if (dynamicViewEntity == null && this.havingEntityCondition == null) {
-            result = delegator.findList(entityName, makeWhereCondition(useCache), fieldsToSelect, orderBy, findOptions, useCache);
+        if (dynamicViewEntity == null) {
+            result = delegator.findList(entityName, makeWhereCondition(useCache), havingEntityCondition, fieldsToSelect, orderBy, findOptions, useCache);
         } else {
             try (EntityListIterator it = queryIterator()) {
                 result = it.getCompleteList();