svn commit: r835729 - in /ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model: DynamicViewEntity.java ModelViewEntity.java

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

svn commit: r835729 - in /ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model: DynamicViewEntity.java ModelViewEntity.java

doogie-3
Author: doogie
Date: Fri Nov 13 03:59:34 2009
New Revision: 835729

URL: http://svn.apache.org/viewvc?rev=835729&view=rev
Log:
Allow for setting groupBy fields with just a simple list.

Modified:
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/DynamicViewEntity.java
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/DynamicViewEntity.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/DynamicViewEntity.java?rev=835729&r1=835728&r2=835729&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/DynamicViewEntity.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/DynamicViewEntity.java Fri Nov 13 03:59:34 2009
@@ -60,6 +60,9 @@
     /** List of aliases with information in addition to what is in the standard field list */
     protected List<ModelAlias> aliases = new ArrayList<ModelAlias>();
 
+    /** List of fields to group by */
+    protected List<String> groupBy;
+
     /** List of view links to define how entities are connected (or "joined") */
     protected List<ModelViewLink> viewLinks = new ArrayList<ModelViewLink>();
 
@@ -211,4 +214,14 @@
     public void addAllRelationsToList(List<ModelRelation> addList) {
         addList.addAll(this.relations);
     }
+
+    public void setGroupBy(List<String> groupBy) {
+        this.groupBy = groupBy;
+    }
+
+    public void addAllGroupByFieldsToList(List<String> addList) {
+        if (groupBy != null) {
+            addList.addAll(this.groupBy);
+        }
+    }
 }

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java?rev=835729&r1=835728&r2=835729&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java Fri Nov 13 03:59:34 2009
@@ -88,6 +88,9 @@
     /** A List of the Field objects for the View Entity, one for each GROUP BY field */
     protected List<ModelField> groupBys = FastList.newInstance();
 
+    /** List of field names to group by */
+    protected List<String> groupByFields = FastList.newInstance();
+
     protected Map<String, Map<String, ModelConversion>> conversions = FastMap.newInstance();
     
     protected ViewEntityCondition viewEntityCondition = null;
@@ -165,6 +168,8 @@
         // relations
         dynamicViewEntity.addAllRelationsToList(this.relations);
 
+        dynamicViewEntity.addAllGroupByFieldsToList(this.groupByFields);
+
         // finalize stuff
         // note that this doesn't result in a call to populateReverseLinks because a DynamicViewEntity should never be cached anyway, and will blow up when attempting to make the reverse links to the DynamicViewEntity
         this.populateFieldsBasic(modelReader);
@@ -430,7 +435,7 @@
             field.description = alias.description;
 
             // if this is a groupBy field, add it to the groupBys list
-            if (alias.groupBy) {
+            if (alias.groupBy || groupByFields.contains(alias.name)) {
                 this.groupBys.add(field);
             }