You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ad...@apache.org on 2013/05/11 18:12:05 UTC

svn commit: r1481367 - in /ofbiz/trunk: applications/product/webapp/facility/WEB-INF/actions/shipment/FindShipment.groovy framework/entity/src/org/ofbiz/entity/model/ModelEntity.java

Author: adrianc
Date: Sat May 11 16:12:05 2013
New Revision: 1481367

URL: http://svn.apache.org/r1481367
Log:
Reverted revision 1480891 and fixed the problem it tried to fix.

Modified:
    ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/FindShipment.groovy
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java

Modified: ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/FindShipment.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/FindShipment.groovy?rev=1481367&r1=1481366&r2=1481367&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/FindShipment.groovy (original)
+++ ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/FindShipment.groovy Sat May 11 16:12:05 2013
@@ -132,15 +132,25 @@ if ("Y".equals(lookupFlag)) {
         lowIndex = viewIndex * viewSize + 1;
         highIndex = (viewIndex + 1) * viewSize;
         findOpts.setMaxRows(highIndex);
-        findOpts.setOffset(lowIndex);
-
+        
         if (!orderReturnValue) {
-            shipmentList = delegator.findList("Shipment", mainCond, null, orderBy, findOpts, false);
-            shipmentListSize = shipmentList.size();
+            // using list iterator
+            orli = delegator.find("Shipment", mainCond, null, null, orderBy, findOpts);
+    
+            shipmentListSize = orli.getResultsSizeAfterPartialList();
             if (highIndex > shipmentListSize) {
                 highIndex = shipmentListSize;
             }
-
+    
+            // get the partial list for this page
+            if (shipmentListSize > 0) {
+                shipmentList = orli.getPartialList(lowIndex, viewSize);
+            } else {
+                shipmentList = [] as ArrayList;
+            }
+    
+            // close the list iterator
+            orli.close();
         }
         
         if (orderReturnValue) {
@@ -192,7 +202,7 @@ if ("Y".equals(lookupFlag)) {
         // only commit the transaction if we started one... this will throw an exception if it fails
         TransactionUtil.commit(beganTransaction);
     }
-
+    
     context.shipmentList = shipmentList;
     context.listSize = shipmentListSize;
     context.highIndex = highIndex;

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java?rev=1481367&r1=1481366&r2=1481367&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java Sat May 11 16:12:05 2013
@@ -93,6 +93,10 @@ public class ModelEntity implements Comp
      * A single lock is used for all ModelField collections so collection updates are atomic. */
     private final Object fieldsLock = new Object();
 
+    /** Model fields in the order they were defined. This list duplicates the values in fieldsMap, but
+     *  we must keep the list in its original sequence for SQL DISTINCT operations to work properly. */
+    private final List<ModelField> fieldsList = new ArrayList<ModelField>();
+
     private final Map<String, ModelField> fieldsMap = new HashMap<String, ModelField>();
 
     /** A List of the Field objects for the Entity, one for each Primary Key */
@@ -264,6 +268,7 @@ public class ModelEntity implements Comp
         if (!newField.getIsPk()) {
             this.nopks.add(newField);
         }
+        this.fieldsList.add(newField);
         this.fieldsMap.put(newField.getName(), newField);
     }
 
@@ -352,6 +357,7 @@ public class ModelEntity implements Comp
             }
             // add to the entity as a new field
             synchronized (fieldsLock) {
+                this.fieldsList.add(newField);
                 this.fieldsMap.put(newField.getName(), newField);
                 if (!newField.getIsPk()) {
                     // this will always be true for now as extend-entity fields are always nonpks
@@ -572,22 +578,20 @@ public class ModelEntity implements Comp
 
     public int getFieldsSize() {
         synchronized (fieldsLock) {
-            return this.fieldsMap.size();
+            return this.fieldsList.size();
         }
     }
 
     public Iterator<ModelField> getFieldsIterator() {
         synchronized (fieldsLock) {
-            List<ModelField> newList = new ArrayList<ModelField>(fieldsMap.size());
-            newList.addAll(this.fieldsMap.values());
+            List<ModelField> newList = new ArrayList<ModelField>(this.fieldsList);
             return newList.iterator();
         }
     }
 
     public List<ModelField> getFieldsUnmodifiable() {
         synchronized (fieldsLock) {
-            List<ModelField> newList = new ArrayList<ModelField>(fieldsMap.size());
-            newList.addAll(this.fieldsMap.values());
+            List<ModelField> newList = new ArrayList<ModelField>(this.fieldsList);
             return Collections.unmodifiableList(newList);
         }
     }
@@ -610,6 +614,7 @@ public class ModelEntity implements Comp
         if (field == null)
             return;
         synchronized (fieldsLock) {
+            this.fieldsList.add(field);
             fieldsMap.put(field.getName(), field);
             if (field.getIsPk()) {
                 pks.add(field);
@@ -625,6 +630,7 @@ public class ModelEntity implements Comp
         synchronized (fieldsLock) {
             ModelField field = fieldsMap.remove(fieldName);
             if (field != null) {
+                this.fieldsList.remove(field);
                 if (field.getIsPk()) {
                     pks.remove(field);
                 } else {
@@ -1547,7 +1553,7 @@ public class ModelEntity implements Comp
         // for classProperties add field names AND relationship names to get a nice, complete chart
         List<String> classPropertiesList = new LinkedList<String>();
         topLevelMap.put("classProperties", classPropertiesList);
-        for (ModelField field: this.fieldsMap.values()) {
+        for (ModelField field: this.fieldsList) {
             if (field.getIsAutoCreatedInternal()) continue;
             if (field.getIsPk()) {
                 classPropertiesList.add(field.getName() + "*");
@@ -1565,7 +1571,7 @@ public class ModelEntity implements Comp
         // attributes
         List<Map<String, Object>> attributesList = new LinkedList<Map<String, Object>>();
         topLevelMap.put("attributes", attributesList);
-        for (ModelField field: this.fieldsMap.values()) {
+        for (ModelField field: this.fieldsList) {
             if (field.getIsAutoCreatedInternal()) continue;
 
             ModelFieldType fieldType = modelFieldTypeReader.getModelFieldType(field.getType());