svn commit: r1825193 - in /ofbiz/ofbiz-framework/branches/release17.12: ./ applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/

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

svn commit: r1825193 - in /ofbiz/ofbiz-framework/branches/release17.12: ./ applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/

Arun Patidar-4
Author: arunpatidar
Date: Sat Feb 24 07:54:20 2018
New Revision: 1825193

URL: http://svn.apache.org/viewvc?rev=1825193&view=rev
Log:
Applied fix from trunk for revision: 1825192
===

Fixed: Survey response data lost on loadCartFromOrder service. (OFBIZ-10232)
Thanks Suraj Khurana for your contribution.

Modified:
    ofbiz/ofbiz-framework/branches/release17.12/   (props changed)
    ofbiz/ofbiz-framework/branches/release17.12/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java
    ofbiz/ofbiz-framework/branches/release17.12/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartServices.java

Propchange: ofbiz/ofbiz-framework/branches/release17.12/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Feb 24 07:54:20 2018
@@ -10,4 +10,4 @@
 /ofbiz/branches/json-integration-refactoring:1634077-1635900
 /ofbiz/branches/multitenant20100310:921280-927264
 /ofbiz/branches/release13.07:1547657
-/ofbiz/ofbiz-framework/trunk:1819499,1819598,1819800,1819805,1819811,1820038,1820262,1820374-1820375,1820441,1820457,1820644,1820658,1820790,1820823,1820949,1820966,1821012,1821036,1821112,1821115,1821144,1821186,1821219,1821226,1821230,1821386,1821600,1821613,1821628,1821965,1822125,1822310,1822377,1822383,1822393,1822882,1823324,1823467,1823562,1823876,1824260,1824314,1824316,1824732,1824803,1824847,1824855
+/ofbiz/ofbiz-framework/trunk:1819499,1819598,1819800,1819805,1819811,1820038,1820262,1820374-1820375,1820441,1820457,1820644,1820658,1820790,1820823,1820949,1820966,1821012,1821036,1821112,1821115,1821144,1821186,1821219,1821226,1821230,1821386,1821600,1821613,1821628,1821965,1822125,1822310,1822377,1822383,1822393,1822882,1823324,1823467,1823562,1823876,1824260,1824314,1824316,1824732,1824803,1824847,1824855,1825192

Modified: ofbiz/ofbiz-framework/branches/release17.12/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/branches/release17.12/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java?rev=1825193&r1=1825192&r2=1825193&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/branches/release17.12/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java (original)
+++ ofbiz/ofbiz-framework/branches/release17.12/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java Sat Feb 24 07:54:20 2018
@@ -56,6 +56,8 @@ import org.apache.ofbiz.entity.Delegator
 import org.apache.ofbiz.entity.GenericEntityException;
 import org.apache.ofbiz.entity.GenericPK;
 import org.apache.ofbiz.entity.GenericValue;
+import org.apache.ofbiz.entity.condition.EntityCondition;
+import org.apache.ofbiz.entity.condition.EntityOperator;
 import org.apache.ofbiz.entity.util.EntityQuery;
 import org.apache.ofbiz.entity.util.EntityUtil;
 import org.apache.ofbiz.entity.util.EntityUtilProperties;
@@ -3903,27 +3905,18 @@ public class ShoppingCart implements Ite
         List<GenericValue> allInfos = new LinkedList<>();
         for (ShoppingCartItem item : this) {
             List<String> responses = UtilGenerics.checkList(item.getAttribute("surveyResponses"));
-            GenericValue response = null;
             if (responses != null) {
-                for (String responseId : responses) {
-                    try {
-                        response = this.getDelegator().findOne("SurveyResponse", UtilMisc.toMap("surveyResponseId", responseId), false);
-                    } catch (GenericEntityException e) {
-                        Debug.logError(e, "Unable to obtain SurveyResponse record for ID : " + responseId, module);
+                try {
+                    List<GenericValue> surveyResponses = EntityQuery.use(getDelegator()).from("SurveyResponse").where(EntityCondition.makeCondition("surveyResponseId", EntityOperator.IN, responses)).queryList();
+                    if (surveyResponses != null) {
+                        for (GenericValue surveyResponse : surveyResponses) {
+                            surveyResponse.set("orderItemSeqId", item.getOrderItemSeqId());
+                            allInfos.add(surveyResponse);
+                        }
                     }
+                } catch (GenericEntityException e) {
+                    Debug.logError(e, "Unable to obtain SurveyResponse record", module);
                 }
-             // this case is executed when user selects "Create as new Order" for Gift cards
-             } else {
-                 String surveyResponseId = (String) item.getAttribute("surveyResponseId");
-                 try {
-                     response = this.getDelegator().findOne("SurveyResponse", UtilMisc.toMap("surveyResponseId", surveyResponseId), false);
-                 } catch (GenericEntityException e) {
-                     Debug.logError(e, "Unable to obtain SurveyResponse record for ID : " + surveyResponseId, module);
-                 }
-            }
-            if (response != null) {
-                response.set("orderItemSeqId", item.getOrderItemSeqId());
-                allInfos.add(response);
             }
         }
         return allInfos;

Modified: ofbiz/ofbiz-framework/branches/release17.12/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartServices.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/branches/release17.12/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartServices.java?rev=1825193&r1=1825192&r2=1825193&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/branches/release17.12/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartServices.java (original)
+++ ofbiz/ofbiz-framework/branches/release17.12/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartServices.java Sat Feb 24 07:54:20 2018
@@ -507,7 +507,7 @@ public class ShoppingCartServices {
                 }
                 // attach surveyResponseId for each item
                 if (UtilValidate.isNotEmpty(surveyResponseResult)){
-                    cartItem.setAttribute("surveyResponseId",surveyResponseResult.get("surveyResponseId"));
+                    cartItem.setAttribute("surveyResponses", UtilMisc.toList(surveyResponseResult.get("surveyResponseId")));
                 }
                 // attach addition item information
                 cartItem.setStatusId(item.getString("statusId"));