Author: arunpatidar
Date: Sat Feb 24 07:49:54 2018
New Revision: 1825192

URL: http://svn.apache.org/viewvc?rev=1825192&view=rev
Log:
Fixed: Survey response data lost on loadCartFromOrder service. (OFBIZ-10232)
Thanks Suraj Khurana for your contribution.

Modified:
    
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java
    
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartServices.java

Modified: 
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java
URL: 
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java?rev=1825192&r1=1825191&r2=1825192&view=diff
==============================================================================
--- 
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java
 (original)
+++ 
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java
 Sat Feb 24 07:49:54 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;
@@ -3918,27 +3920,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/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartServices.java
URL: 
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartServices.java?rev=1825192&r1=1825191&r2=1825192&view=diff
==============================================================================
--- 
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartServices.java
 (original)
+++ 
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartServices.java
 Sat Feb 24 07:49:54 2018
@@ -511,7 +511,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"));


Reply via email to