svn commit: r708036 - /ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/FindGeneric.groovy

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

svn commit: r708036 - /ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/FindGeneric.groovy

jleroux@apache.org
Author: jleroux
Date: Sun Oct 26 13:51:59 2008
New Revision: 708036

URL: http://svn.apache.org/viewvc?rev=708036&view=rev
Log:
A simplified patch from Marco Risaliti "Errors listing entity in Webtools" (https://issues.apache.org/jira/browse/OFBIZ-1944) - OFBIZ-1944

Modified:
    ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/FindGeneric.groovy

Modified: ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/FindGeneric.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/FindGeneric.groovy?rev=708036&r1=708035&r2=708036&view=diff
==============================================================================
--- ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/FindGeneric.groovy (original)
+++ ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/FindGeneric.groovy Sun Oct 26 13:51:59 2008
@@ -22,6 +22,8 @@
 import org.ofbiz.security.Security;
 import org.ofbiz.entity.model.ModelReader;
 import org.ofbiz.entity.model.ModelEntity;
+import org.ofbiz.entity.model.ModelViewEntity;
+import org.ofbiz.entity.model.ModelViewEntity.ModelAlias;
 import org.ofbiz.entity.model.ModelField;
 import org.ofbiz.entity.model.ModelFieldType;
 import org.ofbiz.entity.GenericEntity;
@@ -40,12 +42,27 @@
 import java.sql.Time;
 import javolution.util.FastList;
 import javolution.util.FastMap;
+import javolution.util.FastSet;
 
 entityName = parameters.entityName;
 
 ModelReader reader = delegator.getModelReader();
 ModelEntity modelEntity = reader.getModelEntity(entityName);
 
+groupByFields = FastList.newInstance();
+functionFields = FastList.newInstance();
+
+if (modelEntity instanceof ModelViewEntity) {    
+    aliases = modelEntity.getAliasesCopy()
+    for (ModelAlias alias : aliases) {
+        if (alias.getGroupBy()) {
+            groupByFields.add(alias.getName());        
+        } else if (alias.getFunction()) {
+            functionFields.add(alias.getName());
+        }
+    }
+}
+
 context.entityName = modelEntity.getEntityName();
 context.plainTableName = modelEntity.getPlainTableName();
 
@@ -143,7 +160,21 @@
             EntityFindOptions efo = new EntityFindOptions();
             efo.setResultSetType(EntityFindOptions.TYPE_SCROLL_INSENSITIVE);
             EntityListIterator resultEli = null;
-            resultEli = delegator.find(entityName, condition, null, null, null, efo);
+            fieldsToSelect = [];
+            
+            if (groupByFields || functionFields) {
+                fieldsToSelect = FastSet.newInstance();
+
+                for (ModelField groupByField : groupByFields) {
+                    fieldsToSelect.add(groupByField);
+                }
+
+                for (String functionField : functionFields) {
+                    fieldsToSelect.add(functionField)
+                }
+            }
+            
+            resultEli = delegator.find(entityName, condition, null, fieldsToSelect, null, efo);
             resultPartialList = resultEli.getPartialList(lowIndex, highIndex - lowIndex + 1);
             
             arraySize = resultEli.getResultsSizeAfterPartialList();