Allow for setting groupBy fields with just a simple list.

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@835729 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Adam Heath
2009-11-13 03:59:34 +00:00
parent 6ce844153f
commit 4e69fb0764
2 changed files with 19 additions and 1 deletions
@@ -60,6 +60,9 @@ public class DynamicViewEntity {
/** 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 class DynamicViewEntity {
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);
}
}
}
@@ -88,6 +88,9 @@ public class ModelViewEntity extends ModelEntity {
/** 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 @@ public class ModelViewEntity extends ModelEntity {
// 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 @@ public class ModelViewEntity extends ModelEntity {
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);
}