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/11/10 09:37:41 UTC
svn commit: r834385 - in /ofbiz/trunk/specialpurpose/googlecheckout:
servicedef/secas.xml src/org/ofbiz/googlecheckout/GoogleRequestServices.java
Author: ashish
Date: Tue Nov 10 08:37:40 2009
New Revision: 834385
URL: http://svn.apache.org/viewvc?rev=834385&view=rev
Log:
Applied patch from jira issue OFBIZ-3158 - Send item shipped request from OFBiz to Google in a collection instead of sending multiple request for each item shipped.
Following points are covered in this implementation:
1) Send item shipped request from OFBiz to Google in a collection instead of sending multiple request for each item shipped.
2) Also show limitation messages for Google orders, while updating manual adjustments from order detail page.
Thanks Pranay / Arun for the contribution.
Modified:
ofbiz/trunk/specialpurpose/googlecheckout/servicedef/secas.xml
ofbiz/trunk/specialpurpose/googlecheckout/src/org/ofbiz/googlecheckout/GoogleRequestServices.java
Modified: ofbiz/trunk/specialpurpose/googlecheckout/servicedef/secas.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/googlecheckout/servicedef/secas.xml?rev=834385&r1=834384&r2=834385&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/googlecheckout/servicedef/secas.xml (original)
+++ ofbiz/trunk/specialpurpose/googlecheckout/servicedef/secas.xml Tue Nov 10 08:37:40 2009
@@ -68,4 +68,10 @@
<eca service="createOrderAdjustment" event="in-validate" run-on-failure="false">
<action service="catchEditGoogleOrder" mode="sync" result-to-context="true" ignore-failure="false"/>
</eca>
+ <eca service="updateOrderAdjustment" event="in-validate" run-on-failure="false">
+ <action service="catchEditGoogleOrder" mode="sync" result-to-context="true" ignore-failure="false"/>
+ </eca>
+ <eca service="deleteOrderAdjustment" event="in-validate" run-on-failure="false">
+ <action service="catchEditGoogleOrder" mode="sync" result-to-context="true" ignore-failure="false"/>
+ </eca>
</service-eca>
\ No newline at end of file
Modified: ofbiz/trunk/specialpurpose/googlecheckout/src/org/ofbiz/googlecheckout/GoogleRequestServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/googlecheckout/src/org/ofbiz/googlecheckout/GoogleRequestServices.java?rev=834385&r1=834384&r2=834385&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/googlecheckout/src/org/ofbiz/googlecheckout/GoogleRequestServices.java (original)
+++ ofbiz/trunk/specialpurpose/googlecheckout/src/org/ofbiz/googlecheckout/GoogleRequestServices.java Tue Nov 10 08:37:40 2009
@@ -508,73 +508,67 @@
}
return ServiceUtil.returnSuccess();
}
-
+
private static void sendItemsShipped(Delegator delegator, String shipmentId) throws GeneralException {
List<GenericValue> issued = delegator.findByAnd("ItemIssuance", UtilMisc.toMap("shipmentId", shipmentId));
- if (issued != null && issued.size() > 0) {
- for (GenericValue issue : issued) {
- GenericValue orderItem = issue.getRelatedOne("OrderItem");
- String shipmentItemSeqId = issue.getString("shipmentItemSeqId");
- String productId = orderItem.getString("productId");
- String orderId = issue.getString("orderId");
- GenericValue order = findGoogleOrder(delegator, orderId);
-
- if (order != null) {
- MerchantInfo mInfo = getMerchantInfo(delegator, getProductStoreFromOrder(order));
- if (mInfo == null) {
- Debug.logInfo("Cannot find Google MerchantInfo for Order #" + orderId, module);
- continue;
- }
-
- String externalId = order.getString("externalId");
-
- // locate the shipment package content record
- Map<String, ? extends Object> spcLup = UtilMisc.toMap("shipmentId", shipmentId, "shipmentItemSeqId", shipmentItemSeqId);
-
- List<GenericValue> spc = delegator.findByAnd("ShipmentPackageContent", spcLup);
- GenericValue packageContent = EntityUtil.getFirst(spc);
- String carrier = null;
-
- if (packageContent != null) {
- GenericValue shipPackage = packageContent.getRelatedOne("ShipmentPackage");
-
- if (shipPackage != null) {
- List<GenericValue> prs = shipPackage.getRelated("ShipmentPackageRouteSeg");
- GenericValue packageRoute = EntityUtil.getFirst(prs);
-
- if (packageRoute != null) {
- List<GenericValue> srs = packageRoute.getRelated("ShipmentRouteSegment");
- GenericValue route = EntityUtil.getFirst(srs);
- String track = packageRoute.getString("trackingCode");
-
- if (route != null) {
- carrier = route.getString("carrierPartyId");
+ if (UtilValidate.isNotEmpty(issued)) {
+ try {
+ ShipItemsRequest isr = null;
+ for (GenericValue issue : issued) {
+ GenericValue orderItem = issue.getRelatedOne("OrderItem");
+ String shipmentItemSeqId = issue.getString("shipmentItemSeqId");
+ String productId = orderItem.getString("productId");
+ String orderId = issue.getString("orderId");
+ GenericValue order = findGoogleOrder(delegator, orderId);
+ if (UtilValidate.isNotEmpty(order)) {
+ MerchantInfo mInfo = getMerchantInfo(delegator, getProductStoreFromOrder(order));
+ if (UtilValidate.isEmpty(mInfo)) {
+ Debug.logInfo("Cannot find Google MerchantInfo for Order #" + orderId, module);
+ continue;
+ }
+ String externalId = order.getString("externalId");
+ if (UtilValidate.isEmpty(isr)) {
+ isr = new ShipItemsRequest(mInfo, externalId);
+ }
+ // locate the shipment package content record
+ Map<String, ? extends Object> spcLup = UtilMisc.toMap("shipmentId", shipmentId, "shipmentItemSeqId", shipmentItemSeqId);
+ List<GenericValue> spc = delegator.findByAnd("ShipmentPackageContent", spcLup);
+ GenericValue packageContent = EntityUtil.getFirst(spc);
+ String carrier = null;
+ if (UtilValidate.isNotEmpty(packageContent)) {
+ GenericValue shipPackage = packageContent.getRelatedOne("ShipmentPackage");
+ if (UtilValidate.isNotEmpty(shipPackage)) {
+ List<GenericValue> prs = shipPackage.getRelated("ShipmentPackageRouteSeg");
+ GenericValue packageRoute = EntityUtil.getFirst(prs);
+ if (UtilValidate.isNotEmpty(packageRoute)) {
+ List<GenericValue> srs = packageRoute.getRelated("ShipmentRouteSegment");
+ GenericValue route = EntityUtil.getFirst(srs);
+ String track = packageRoute.getString("trackingCode");
+ if (UtilValidate.isNotEmpty(route)) {
+ carrier = route.getString("carrierPartyId");
if (UtilValidate.isEmpty(track)) {
track = route.getString("trackingIdNumber");
}
if (track == null) {
track = "";
}
-
- try {
- ShipItemsRequest isr = new ShipItemsRequest(mInfo, externalId);
- isr.addItemShippingInformation(productId, carrier, track);
- Debug.logInfo("Sending item shipped notification: " + productId + " / " + carrier + " / " + track, module);
- Debug.logInfo("Using merchantInfo : " + mInfo.getMerchantId() + " #" + externalId, module);
- isr.send();
- } catch (CheckoutException e) {
- Debug.logError(e, module);
- throw new GeneralException(e);
- }
+ isr.addItemShippingInformation(productId, carrier, track);
+ Debug.logInfo("Sending item shipped notification: " + productId + " / " + carrier + " / " + track, module);
+ Debug.logInfo("Using merchantInfo : " + mInfo.getMerchantId() + " #" + externalId, module);
}
}
}
}
}
}
+ isr.send();
+ } catch (CheckoutException e) {
+ Debug.logError(e, module);
+ throw new GeneralException(e);
+ }
}
}
-
+
public static GenericValue findGoogleOrder(Delegator delegator, String orderId) {
GenericValue order = null;
try {