You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by as...@apache.org on 2009/09/17 13:31:48 UTC
svn commit: r816148 - in /ofbiz/trunk/specialpurpose/ebay: servicedef/
src/org/ofbiz/ebay/ webapp/ebay/WEB-INF/ webapp/ebay/WEB-INF/actions/find/
widget/
Author: ashish
Date: Thu Sep 17 11:31:48 2009
New Revision: 816148
URL: http://svn.apache.org/viewvc?rev=816148&view=rev
Log:
Provided option to see the list of orders from eBay first and then CSR can import the required orders in the system.
Thanks a lot Mridul & Rishi for discussing the better way to handle this case.
Added:
ofbiz/trunk/specialpurpose/ebay/webapp/ebay/WEB-INF/actions/find/eBayOrders.groovy (with props)
ofbiz/trunk/specialpurpose/ebay/webapp/ebay/WEB-INF/actions/find/updatedEbayOrders.groovy (with props)
Modified:
ofbiz/trunk/specialpurpose/ebay/servicedef/services.xml
ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/EbayOrderServices.java
ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/ImportOrdersFromEbay.java
ofbiz/trunk/specialpurpose/ebay/webapp/ebay/WEB-INF/controller.xml
ofbiz/trunk/specialpurpose/ebay/widget/EbayForms.xml
ofbiz/trunk/specialpurpose/ebay/widget/EbayScreens.xml
Modified: ofbiz/trunk/specialpurpose/ebay/servicedef/services.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebay/servicedef/services.xml?rev=816148&r1=816147&r2=816148&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebay/servicedef/services.xml (original)
+++ ofbiz/trunk/specialpurpose/ebay/servicedef/services.xml Thu Sep 17 11:31:48 2009
@@ -130,12 +130,7 @@
<attribute name="paidTime" type="String" mode="IN" optional="true"/>
<attribute name="shippedTime" type="String" mode="IN" optional="true"/>
<attribute name="ebayUserIdBuyer" type="String" mode="IN" optional="true"/>
- <attribute name="shippingAddressCtx" type="Map" mode="IN" optional="true"/>
- <attribute name="shippingServiceSelectedCtx" type="Map" mode="IN" optional="true"/>
- <attribute name="shippingDetailsCtx" type="Map" mode="IN" optional="true"/>
- <attribute name="checkoutStatusCtx" type="Map" mode="IN" optional="true"/>
- <attribute name="externalTransactionCtx" type="Map" mode="IN" optional="true"/>
- <attribute name="orderItemList" type="List" mode="IN" optional="true"/>
+ <attribute name="orderList" type="List" mode="IN" optional="true"/>
</service>
<service name="createEbayConfiguration" default-entity-name="EbayConfig" engine="entity-auto" invoke="create" auth="true">
Modified: ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/EbayOrderServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/EbayOrderServices.java?rev=816148&r1=816147&r2=816148&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/EbayOrderServices.java (original)
+++ ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/EbayOrderServices.java Thu Sep 17 11:31:48 2009
@@ -30,12 +30,15 @@
import java.util.Locale;
import java.util.Map;
+import javax.servlet.http.HttpServletRequest;
+
import javolution.util.FastList;
import javolution.util.FastMap;
import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.GeneralException;
import org.ofbiz.base.util.UtilDateTime;
+import org.ofbiz.base.util.UtilFormatOut;
import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.base.util.UtilProperties;
import org.ofbiz.base.util.UtilValidate;
@@ -44,6 +47,7 @@
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
import org.ofbiz.entity.util.EntityUtil;
+import org.ofbiz.minilang.method.entityops.FilterListByAnd;
import org.ofbiz.order.order.OrderChangeHelper;
import org.ofbiz.order.shoppingcart.CheckOutHelper;
import org.ofbiz.order.shoppingcart.ShoppingCart;
@@ -67,6 +71,8 @@
GenericDelegator delegator = dctx.getDelegator();
LocalDispatcher dispatcher = dctx.getDispatcher();
Locale locale = (Locale) context.get("locale");
+ orderImportSuccessMessageList.clear();
+ orderImportFailureMessageList.clear();
Map<String, Object> result = FastMap.newInstance();
try {
Map<String, Object> eBayConfigResult = EbayHelper.buildEbayConfig(context, delegator);
@@ -83,15 +89,6 @@
String errMsg = UtilProperties.getMessage(resource, "buildEbayConfig.exceptionInGetOrdersFromEbay" + e.getMessage(), locale);
return ServiceUtil.returnError(errMsg);
}
- if (orderImportSuccessMessageList != null && orderImportSuccessMessageList.size() > 0) {
- result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_SUCCESS);
- result.put(ModelService.SUCCESS_MESSAGE_LIST, orderImportSuccessMessageList);
- }
-
- if (orderImportFailureMessageList != null && orderImportFailureMessageList.size() > 0) {
- result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_FAIL);
- result.put(ModelService.ERROR_MESSAGE_LIST, orderImportFailureMessageList);
- }
return result;
}
@@ -100,12 +97,34 @@
LocalDispatcher dispatcher = dctx.getDispatcher();
Locale locale = (Locale) context.get("locale");
Map<String, Object> result = FastMap.newInstance();
+ String externalId = (String) context.get("externalId");
+ List orderList = (List) context.get("orderList");
try {
+ if (UtilValidate.isNotEmpty(orderList)) {
+ Iterator orderListIter = orderList.iterator();
+ while (orderListIter.hasNext()) {
+ Map orderMapCtx = (Map) orderListIter.next();
+ if (externalId.equals(orderMapCtx.get("externalId").toString())) {
+ context.clear();
+ context.putAll(orderMapCtx);
+ break;
+ }
+ }
+ }
result = createShoppingCart(delegator, dispatcher, locale, context, true);
} catch (Exception e) {
Debug.logError("Exception in importOrderFromEbay " + e, module);
return ServiceUtil.returnFailure(UtilProperties.getMessage(resource, "ordersImportFromEbay.exceptionInImportOrderFromEbay", locale));
}
+ if (UtilValidate.isNotEmpty(orderImportSuccessMessageList)) {
+ result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_SUCCESS);
+ result.put(ModelService.SUCCESS_MESSAGE_LIST, orderImportSuccessMessageList);
+ }
+
+ if (UtilValidate.isNotEmpty(orderImportSuccessMessageList)) {
+ result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_FAIL);
+ result.put(ModelService.ERROR_MESSAGE_LIST, orderImportFailureMessageList);
+ }
return result;
}
@@ -148,13 +167,17 @@
private static Map<String, Object> checkOrders(GenericDelegator delegator, LocalDispatcher dispatcher, Locale locale, Map<String, Object> context, String responseMsg) {
StringBuffer errorMessage = new StringBuffer();
+ Map<String, Object> result = FastMap.newInstance();
GenericValue userLogin = (GenericValue) context.get("userLogin");
List<GenericValue> orders = readGetOrdersResponse(responseMsg, locale, (String) context.get("productStoreId"), delegator, dispatcher, errorMessage, userLogin);
if (orders == null || orders.size() == 0) {
Debug.logError("No orders found", module);
return ServiceUtil.returnFailure(UtilProperties.getMessage(resource, "ordersImportFromEbay.noOrdersFound", locale));
}
- return ServiceUtil.returnSuccess();
+ if (UtilValidate.isNotEmpty(orders)) {
+ result.put("orderList", orders);
+ }
+ return result;
}
// Sample xml data that is being generated from GetOrders request
@@ -453,7 +476,7 @@
orderCtx.put("emailBuyer", buyersEmailId);
}
orderCtx.put("userLogin", userLogin);
- Map<String, Object> result = dispatcher.runSync("importEbayOrders", orderCtx);
+ //Map<String, Object> result = dispatcher.runSync("importEbayOrders", orderCtx);
fetchedOrders.add(orderCtx);
}
}
Modified: ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/ImportOrdersFromEbay.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/ImportOrdersFromEbay.java?rev=816148&r1=816147&r2=816148&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/ImportOrdersFromEbay.java (original)
+++ ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/ImportOrdersFromEbay.java Thu Sep 17 11:31:48 2009
@@ -88,6 +88,11 @@
Locale locale = (Locale) context.get("locale");
Map order = FastMap.newInstance();
Map result = FastMap.newInstance();
+ Debug.logInfo("The value of =============" + context.get("externalId"), module);
+ List orderList = (List) context.get("orderList");
+ if (UtilValidate.isNotEmpty(orderList)) {
+ Debug.logInfo("The value of list is ==============" + orderList, module);
+ }
try {
order.put("productStoreId", (String) context.get("productStoreId"));
order.put("userLogin", (GenericValue) context.get("userLogin"));
@@ -117,7 +122,7 @@
order.put("shippingAddressStateOrProvince", (String) context.get("shippingAddressStateOrProvince"));
order.put("shippingAddressCityName", (String) context.get("shippingAddressCityName"));
- result = createShoppingCart(delegator, dispatcher, locale, order, true);
+ //result = createShoppingCart(delegator, dispatcher, locale, order, true);
} catch (Exception e) {
Debug.logError("Exception in importOrderFromEbay " + e, module);
return ServiceUtil.returnFailure(UtilProperties.getMessage(resource, "ordersImportFromEbay.exceptionInImportOrderFromEbay", locale));
Added: ofbiz/trunk/specialpurpose/ebay/webapp/ebay/WEB-INF/actions/find/eBayOrders.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebay/webapp/ebay/WEB-INF/actions/find/eBayOrders.groovy?rev=816148&view=auto
==============================================================================
--- ofbiz/trunk/specialpurpose/ebay/webapp/ebay/WEB-INF/actions/find/eBayOrders.groovy (added)
+++ ofbiz/trunk/specialpurpose/ebay/webapp/ebay/WEB-INF/actions/find/eBayOrders.groovy Thu Sep 17 11:31:48 2009
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+if (parameters.orderList) {
+ session.setAttribute("orderList", parameters.orderList);
+}
\ No newline at end of file
Propchange: ofbiz/trunk/specialpurpose/ebay/webapp/ebay/WEB-INF/actions/find/eBayOrders.groovy
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ofbiz/trunk/specialpurpose/ebay/webapp/ebay/WEB-INF/actions/find/eBayOrders.groovy
------------------------------------------------------------------------------
svn:keywords = Date Rev Author URL Id
Propchange: ofbiz/trunk/specialpurpose/ebay/webapp/ebay/WEB-INF/actions/find/eBayOrders.groovy
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: ofbiz/trunk/specialpurpose/ebay/webapp/ebay/WEB-INF/actions/find/updatedEbayOrders.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebay/webapp/ebay/WEB-INF/actions/find/updatedEbayOrders.groovy?rev=816148&view=auto
==============================================================================
--- ofbiz/trunk/specialpurpose/ebay/webapp/ebay/WEB-INF/actions/find/updatedEbayOrders.groovy (added)
+++ ofbiz/trunk/specialpurpose/ebay/webapp/ebay/WEB-INF/actions/find/updatedEbayOrders.groovy Thu Sep 17 11:31:48 2009
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+if (session.getAttribute("orderList")) {
+ session.removeAttribute("orderList");
+ return "success";
+}
\ No newline at end of file
Propchange: ofbiz/trunk/specialpurpose/ebay/webapp/ebay/WEB-INF/actions/find/updatedEbayOrders.groovy
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ofbiz/trunk/specialpurpose/ebay/webapp/ebay/WEB-INF/actions/find/updatedEbayOrders.groovy
------------------------------------------------------------------------------
svn:keywords = Date Rev Author URL Id
Propchange: ofbiz/trunk/specialpurpose/ebay/webapp/ebay/WEB-INF/actions/find/updatedEbayOrders.groovy
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: ofbiz/trunk/specialpurpose/ebay/webapp/ebay/WEB-INF/controller.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebay/webapp/ebay/WEB-INF/controller.xml?rev=816148&r1=816147&r2=816148&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebay/webapp/ebay/WEB-INF/controller.xml (original)
+++ ofbiz/trunk/specialpurpose/ebay/webapp/ebay/WEB-INF/controller.xml Thu Sep 17 11:31:48 2009
@@ -131,9 +131,16 @@
<response name="failure" type="view" value="EbayOrders"/>
</request-map>
- <request-map uri="ImportEbayOrders">
+ <request-map uri="importEbayOrders">
<security https="true" auth="true"/>
<event type="service-multi" invoke="importEbayOrders"/>
+ <response name="success" type="request" value="updatedEbayOrders"/>
+ <response name="failure" type="view" value="EbayOrders"/>
+ </request-map>
+
+ <request-map uri="updatedEbayOrders">
+ <security https="true" auth="true"/>
+ <event type="groovy" path="component://ebay/webapp/ebay/WEB-INF/actions/find/" invoke="updatedEbayOrders.groovy"/>
<response name="success" type="view" value="EbayOrders"/>
<response name="failure" type="view" value="EbayOrders"/>
</request-map>
Modified: ofbiz/trunk/specialpurpose/ebay/widget/EbayForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebay/widget/EbayForms.xml?rev=816148&r1=816147&r2=816148&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebay/widget/EbayForms.xml (original)
+++ ofbiz/trunk/specialpurpose/ebay/widget/EbayForms.xml Thu Sep 17 11:31:48 2009
@@ -102,6 +102,26 @@
<field name="submitButton" title="${uiLabelMap.EbayImportOrdersFromEbay}"><submit button-type="button"/></field>
</form>
+ <form name="ListEbayOrders" type="multi" use-row-submit="true" list-name="orderList" target="importEbayOrders"
+ odd-row-style="alternate-row" default-table-style="basic-table hover-bar">
+ <field name="productStoreId"><hidden/></field>
+ <field name="externalId" title="${uiLabelMap.EbayEbayOrderId}"><display/></field>
+ <field name="orderId">
+ <hyperlink target="orderview" description="${orderId}">
+ <parameter param-name="orderId"/>
+ </hyperlink>
+ </field>
+ <field name="buyerName" map-name="shippingAddressCtx"><display/></field>
+ <field name="emailBuyer"><display/></field>
+ <field name="amountPaid"><display/></field>
+ <field name="createdDate"><display/></field>
+ <field name="paidTime"><hidden/></field>
+ <field name="shippedTime"><hidden/></field>
+ <field name="ebayUserIdBuyer"><hidden/></field>
+ <field name="_rowSubmit" title="${uiLabelMap.CommonSelect}"><check/></field>
+ <field name="submitButton" title="${uiLabelMap.EbayImportOrdersFromEbay}" widget-style="smallSubmit"><submit/></field>
+ </form>
+
<!-- Ebay configuration settings forms -->
<form name="ListEbayConfigurations" type="list" list-name="eBayConfigurations" target="updateEbayConfiguration"
odd-row-style="alternate-row" header-row-style="header-row-2" default-table-style="basic-table hover-bar">
Modified: ofbiz/trunk/specialpurpose/ebay/widget/EbayScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebay/widget/EbayScreens.xml?rev=816148&r1=816147&r2=816148&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebay/widget/EbayScreens.xml (original)
+++ ofbiz/trunk/specialpurpose/ebay/widget/EbayScreens.xml Thu Sep 17 11:31:48 2009
@@ -202,24 +202,29 @@
<set field="titleProperty" value="EbayEBayOrders"/>
<set field="headerItem" value="eBayOrders"/>
<set field="orderList" from-field="parameters.orderList"/>
+ <script location="component://ebay/webapp/ebay/WEB-INF/actions/find/eBayOrders.groovy"/>
</actions>
<widgets>
<decorator-screen name="permission-decorator" location="${parameters.mainDecoratorLocation}">
<decorator-section name="body">
- <container style="screenlet">
- <container style="screenlet-title-bar">
- <container style="h3">
- <label text="${uiLabelMap.EbayEBayOrders}"/>
- </container>
- </container>
- <container style="screenlet-body">
- <section>
- <widgets>
+ <section>
+ <condition>
+ <if-has-permission permission="EBAY" action="_VIEW"/>
+ </condition>
+ <widgets>
+ <decorator-screen name="FindScreenDecorator" location="component://common/widget/CommonScreens.xml">
+ <decorator-section name="search-options">
<include-form name="FindEbayOrders" location="component://ebay/widget/EbayForms.xml"/>
- </widgets>
- </section>
- </container>
- </container>
+ </decorator-section>
+ <decorator-section name="search-results">
+ <include-form name="ListEbayOrders" location="component://ebay/widget/EbayForms.xml"/>
+ </decorator-section>
+ </decorator-screen>
+ </widgets>
+ <fail-widgets>
+ <label style="h3">${uiLabelMap.EbayViewPermissionError}</label>
+ </fail-widgets>
+ </section>
</decorator-section>
</decorator-screen>
</widgets>