You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ha...@apache.org on 2010/02/04 07:01:07 UTC
svn commit: r906373 [1/2] - in /ofbiz/trunk: ./
applications/product/script/org/ofbiz/product/inventory/
specialpurpose/ebaystore/ specialpurpose/ebaystore/config/
specialpurpose/ebaystore/script/org/ofbiz/ebaystore/
specialpurpose/ebaystore/servicedef...
Author: hansbak
Date: Thu Feb 4 06:01:06 2010
New Revision: 906373
URL: http://svn.apache.org/viewvc?rev=906373&view=rev
Log:
Ebaystore component update:
- update code and format in java file
- function update status of product(active,sold,unsold) from ebay inventory
- function and screen for cancel quantities that reservation
Modified:
ofbiz/trunk/.classpath
ofbiz/trunk/LICENSE
ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryReserveServices.xml
ofbiz/trunk/specialpurpose/ebaystore/config/EbayStoreUiLabels.xml
ofbiz/trunk/specialpurpose/ebaystore/ofbiz-component.xml
ofbiz/trunk/specialpurpose/ebaystore/script/org/ofbiz/ebaystore/EbayServices.xml
ofbiz/trunk/specialpurpose/ebaystore/servicedef/services.xml
ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStore.java
ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreInventoryServices.java
ofbiz/trunk/specialpurpose/ebaystore/webapp/ebaystore/WEB-INF/controller.xml
ofbiz/trunk/specialpurpose/ebaystore/widget/EbayInventoryForms.xml
ofbiz/trunk/specialpurpose/ebaystore/widget/EbayStoreScreens.xml
Modified: ofbiz/trunk/.classpath
URL: http://svn.apache.org/viewvc/ofbiz/trunk/.classpath?rev=906373&r1=906372&r2=906373&view=diff
==============================================================================
--- ofbiz/trunk/.classpath (original)
+++ ofbiz/trunk/.classpath Thu Feb 4 06:01:06 2010
@@ -227,6 +227,7 @@
<classpathentry kind="src" path="framework/widget/src"/>
<classpathentry kind="src" path="specialpurpose/assetmaint/src"/>
<classpathentry kind="src" path="specialpurpose/ebay/src"/>
+ <classpathentry kind="src" path="specialpurpose/ebaystore/src"/>
<classpathentry kind="src" path="specialpurpose/ecommerce/src"/>
<classpathentry kind="src" path="specialpurpose/googlebase/src"/>
<classpathentry kind="src" path="specialpurpose/googlecheckout/src"/>
Modified: ofbiz/trunk/LICENSE
URL: http://svn.apache.org/viewvc/ofbiz/trunk/LICENSE?rev=906373&r1=906372&r2=906373&view=diff
==============================================================================
--- ofbiz/trunk/LICENSE (original)
+++ ofbiz/trunk/LICENSE Thu Feb 4 06:01:06 2010
@@ -1990,10 +1990,10 @@
COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL):
ofbiz/trunk/framework/base/lib/juel-2.1.1.jar (contains the javax.el package)
ofbiz/trunk/framework/base/lib/mail.jar
-ofbiz/trunk/specialpurpose/ebay/lib/attributes.jar
-ofbiz/trunk/specialpurpose/ebay/lib/ebaysdkcore.jar
-ofbiz/trunk/specialpurpose/ebay/lib/helper.jar
-ofbiz/trunk/specialpurpose/ebay/lib/ebaycalls.jar
+ofbiz/trunk/specialpurpose/ebaystore/lib/attributes.jar
+ofbiz/trunk/specialpurpose/ebaystore/lib/ebaysdkcore.jar
+ofbiz/trunk/specialpurpose/ebaystore/lib/helper.jar
+ofbiz/trunk/specialpurpose/ebaystore/lib/ebaycalls.jar
=========================================================================
COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 1.
Modified: ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryReserveServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryReserveServices.xml?rev=906373&r1=906372&r2=906373&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryReserveServices.xml (original)
+++ ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryReserveServices.xml Thu Feb 4 06:01:06 2010
@@ -166,6 +166,8 @@
<calculate field="createDetailMap.availableToPromiseDiff">
<calcop field="parameters.quantityNotReserved" operator="negative"/>
</calculate>
+
+ <if-not-empty field="parameters.reserveReasonEnumId"><set from-field="parameters.reserveReasonEnumId" field="createDetailMap.reasonEnumId"/></if-not-empty>
<call-service service-name="createInventoryItemDetail" in-map-name="createDetailMap"/>
<clear-field field="createDetailMap"/>
@@ -233,6 +235,7 @@
<calculate field="createDetailMap.availableToPromiseDiff">
<calcop field="parameters.quantityNotReserved" operator="negative"/>
</calculate>
+ <if-not-empty field="parameters.reserveReasonEnumId"><set from-field="parameters.reserveReasonEnumId" field="createDetailMap.reasonEnumId"/></if-not-empty>
<call-service service-name="createInventoryItemDetail" in-map-name="createDetailMap"/>
<clear-field field="createDetailMap"/>
@@ -410,6 +413,12 @@
</if-compare>
</if-compare>
<if-compare field="inventoryItem.inventoryItemTypeId" operator="equals" value="NON_SERIAL_INV_ITEM">
+ <!-- check reasonenumId reserve for ebay inventory -->
+ <if-not-empty field="parameters.reserveReasonEnumId">
+ <if-compare field="parameters.reserveReasonEnumId" value="EBAY_INV_RES" operator="equals">
+ <set field="ebayReserveReasonEnumId" from-field="parameters.reserveReasonEnumId"/>
+ </if-compare>
+ </if-not-empty>
<!-- reduce atp on inventoryItem if availableToPromise greater than 0, if not the code at the end of this method will handle it -->
<if>
<condition>
@@ -435,26 +444,28 @@
<calculate field="createDetailMap.availableToPromiseDiff">
<calcop field="parameters.deductAmount" operator="negative"/>
</calculate>
+ <if-not-empty field="ebayReserveReasonEnumId"><set from-field="parameters.reserveReasonEnumId" field="createDetailMap.reasonEnumId"/></if-not-empty>
<call-service service-name="createInventoryItemDetail" in-map-name="createDetailMap"/>
<clear-field field="createDetailMap"/>
- <!-- create OrderItemShipGrpInvRes record -->
- <call-simple-method method-name="getPromisedDateTime"/>
- <set from-field="parameters.orderId" field="reserveOisgirMap.orderId"/>
- <set from-field="parameters.orderItemSeqId" field="reserveOisgirMap.orderItemSeqId"/>
- <set from-field="parameters.shipGroupSeqId" field="reserveOisgirMap.shipGroupSeqId"/>
- <set from-field="inventoryItem.inventoryItemId" field="reserveOisgirMap.inventoryItemId"/>
- <set from-field="parameters.reserveOrderEnumId" field="reserveOisgirMap.reserveOrderEnumId"/>
- <set from-field="parameters.reservedDatetime" field="reserveOisgirMap.reservedDatetime"/>
- <set from-field="parameters.deductAmount" field="reserveOisgirMap.quantity" type="BigDecimal"/>
- <set from-field="promisedDatetime" field="reserveOisgirMap.promisedDatetime"/>
- <set from-field="parameters.priority" field="reserveOisgirMap.priority"/>
- <if-not-empty field="parameters.sequenceId">
- <set field="reserveOisgirMap.sequenceId" from-field="parameters.sequenceId"/>
- </if-not-empty>
- <call-service service-name="reserveOrderItemInventory" in-map-name="reserveOisgirMap"/>
- <clear-field field="reserveOisgirMap"/>
-
+ <!-- create OrderItemShipGrpInvRes record and check for reserved from ebay don't need shipgroup-->
+ <if-empty field="ebayReserveReasonEnumId">
+ <call-simple-method method-name="getPromisedDateTime"/>
+ <set from-field="parameters.orderId" field="reserveOisgirMap.orderId"/>
+ <set from-field="parameters.orderItemSeqId" field="reserveOisgirMap.orderItemSeqId"/>
+ <set from-field="parameters.shipGroupSeqId" field="reserveOisgirMap.shipGroupSeqId"/>
+ <set from-field="inventoryItem.inventoryItemId" field="reserveOisgirMap.inventoryItemId"/>
+ <set from-field="parameters.reserveOrderEnumId" field="reserveOisgirMap.reserveOrderEnumId"/>
+ <set from-field="parameters.reservedDatetime" field="reserveOisgirMap.reservedDatetime"/>
+ <set from-field="parameters.deductAmount" field="reserveOisgirMap.quantity" type="BigDecimal"/>
+ <set from-field="promisedDatetime" field="reserveOisgirMap.promisedDatetime"/>
+ <set from-field="parameters.priority" field="reserveOisgirMap.priority"/>
+ <if-not-empty field="parameters.sequenceId">
+ <set field="reserveOisgirMap.sequenceId" from-field="parameters.sequenceId"/>
+ </if-not-empty>
+ <call-service service-name="reserveOrderItemInventory" in-map-name="reserveOisgirMap"/>
+ <clear-field field="reserveOisgirMap"/>
+ </if-empty>
<calculate field="parameters.quantityNotReserved">
<calcop operator="subtract" field="parameters.quantityNotReserved">
<calcop operator="get" field="parameters.deductAmount"/>
Modified: ofbiz/trunk/specialpurpose/ebaystore/config/EbayStoreUiLabels.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebaystore/config/EbayStoreUiLabels.xml?rev=906373&r1=906372&r2=906373&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebaystore/config/EbayStoreUiLabels.xml (original)
+++ ofbiz/trunk/specialpurpose/ebaystore/config/EbayStoreUiLabels.xml Thu Feb 4 06:01:06 2010
@@ -183,4 +183,7 @@
<property key="EbayUpdateInventory">
<value xml:lang="en">Update To Ebay Inventory</value>
</property>
+ <property key="EbayUpdateInventoryStatus">
+ <value xml:lang="en">Update Inventory Status</value>
+ </property>
</resource>
Modified: ofbiz/trunk/specialpurpose/ebaystore/ofbiz-component.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebaystore/ofbiz-component.xml?rev=906373&r1=906372&r2=906373&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebaystore/ofbiz-component.xml (original)
+++ ofbiz/trunk/specialpurpose/ebaystore/ofbiz-component.xml Thu Feb 4 06:01:06 2010
@@ -23,6 +23,7 @@
xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/ofbiz-component.xsd">
<resource-loader name="main" type="component"/>
<classpath type="dir" location="config"/>
+ <classpath type="jar" location="lib/*"/>
<classpath type="jar" location="build/lib/*"/>
<entity-resource type="model" reader-name="main" loader="main" location="entitydef/entitymodel.xml"/>
Modified: ofbiz/trunk/specialpurpose/ebaystore/script/org/ofbiz/ebaystore/EbayServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebaystore/script/org/ofbiz/ebaystore/EbayServices.xml?rev=906373&r1=906372&r2=906373&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebaystore/script/org/ofbiz/ebaystore/EbayServices.xml (original)
+++ ofbiz/trunk/specialpurpose/ebaystore/script/org/ofbiz/ebaystore/EbayServices.xml Thu Feb 4 06:01:06 2010
@@ -43,8 +43,8 @@
</simple-method>
- <!-- Store Inventory Services -->
- <simple-method method-name="reserveEbayStoreInventory" short-description="Reserve ofbiz Store product Inventory">
+ <!-- ebay Store Inventory Services -->
+ <simple-method method-name="reserveEbayProductInventory" short-description="Reserve product from ofbiz Store Inventory">
<entity-one entity-name="Product" value-field="product" use-cache="true"/>
<entity-one entity-name="ProductStore" value-field="productStore" >
<field-map field-name="productStoreId" from-field="parameters.productStoreId"/>
@@ -62,7 +62,13 @@
<return response-code="success"/>
</if-compare>
- <call-simple-method method-name="isStoreInventoryRequiredInline"/>
+ <set from-field="product.requireInventory" field="requireInventory"/>
+ <if-empty field="requireInventory">
+ <set from-field="productStore.requireInventory" field="requireInventory"/>
+ </if-empty>
+ <if-empty field="requireInventory">
+ <set value="Y" field="requireInventory"/>
+ </if-empty>
<set from-field="parameters.facilityId" field="facilityId"/>
<if-not-empty field="facilityId">
@@ -94,11 +100,13 @@
<set from-field="facilityId" field="callServiceMap.facilityId"/>
<set from-field="requireInventory" field="callServiceMap.requireInventory"/>
<set from-field="productStore.reserveOrderEnumId" field="callServiceMap.reserveOrderEnumId"/>
+ <set value="EBAY_INV_RES" field="callServiceMap.reserveReasonEnumId"/>
<call-service service-name="reserveEbayProductInventoryByStoreFacility" in-map-name="callServiceMap">
<results-to-map map-name="resultMap"/>
<result-to-field result-name="quantityNotReserved" field="qtyNotReserve"/>
<result-to-field result-name="successMessage" field="returnSuccessMessage"/>
</call-service>
+
<set field="defaultReserve" default-value="0"/>
<!-- if quantityNotReserved greater than 0 then ATP in ofbiz stock not have, it should be return message or log warring-->
<if-compare-field field="qtyNotReserve" operator="equals" type="BigDecimal" to-field="defaultReserve">
@@ -174,281 +182,145 @@
</else>
</if-empty>
</simple-method>
-
- <simple-method method-name="isStoreInventoryRequiredInline" short-description="Is Store Inventory Required" login-required="false">
- <set from-field="product.requireInventory" field="requireInventory"/>
- <if-empty field="requireInventory">
- <set from-field="productStore.requireInventory" field="requireInventory"/>
- </if-empty>
- <if-empty field="requireInventory">
- <set value="Y" field="requireInventory"/>
+ <simple-method method-name="updateEbayProductQtyReserved" short-description="Update or cancel an Product which are reserved quantity from inventory">
+ <entity-one entity-name="EbayProductStoreInventory" value-field="ebayProductStoreInventory">
+ <field-map field-name="productStoreId" from-field="parameters.productStoreId"/>
+ <field-map field-name="facilityId" from-field="parameters.facilityId"/>
+ <field-map field-name="productId" from-field="parameters.productId"/>
+ </entity-one>
+ <if-empty field="ebayProductStoreInventory">
+ <add-error><fail-message message="No Product found with id ${parameters.productId}."/></add-error>
+ <check-errors/>
</if-empty>
- </simple-method>
-
- <simple-method method-name="reserveEbayProductInventory" short-description="Reserve Inventory for a Product">
-
- <now-timestamp field="nowTimestamp"/>
-
- <!-- check the product; make sure its a physical item -->
- <entity-one entity-name="Product" value-field="product"/>
- <entity-one entity-name="Facility" value-field="facility" use-cache="true"/>
- <get-related-one value-field="product" relation-name="ProductType" to-value-field="productType"/>
- <if-compare field="productType.isPhysical" operator="equals" value="N">
- <set field="parameters.quantityNotReserved" value="0" type="BigDecimal"/>
+ <set field="actionType" from-field="parameters.actionType"/>
+ <set field="qtyInp" default-value="0" from-field="parameters.quantity"/>
+ <set field="atpListing" default-value="0" from-field="ebayProductStoreInventory.availableToPromiseListing"/>
+ <set field="qohReserved" default-value="0" from-field="ebayProductStoreInventory.quantityReserved"/>
+ <!--check qty input for increase or decrease -->
+ <!--field-to-result field="parameters.productStoreId" result-name="productStoreId"/>
+ <field-to-result field="parameters.facilityId" result-name="facilityId"/>
+ <field-to-result field="parameters.productId" result-name="productId"/-->
+ <if-compare field="actionType" value="ADD" operator="equals">
+ <set-service-fields service-name="reserveEbayProductInventory" map="parameters" to-map="reservedEbayProduct"/>
+ <call-service service-name="reserveEbayProductInventory" in-map-name="reservedEbayProduct"></call-service>
+ <return/>
<else>
-
- <set value="EBAY_INV_RES" field="parameters.reserveReasonEnumId"/>
- <set value="+datetimeReceived" field="orderByString"/>
- <set from-field="parameters.quantity" field="parameters.quantityNotReserved"/>
-
- <!-- first reserve against InventoryItems in FLT_PICKLOC type locations, then FLT_BULK locations, then InventoryItems with no locations -->
- <entity-condition entity-name="InventoryItemAndLocation" list="inventoryItemAndLocations">
- <condition-list combine="and">
- <condition-expr field-name="productId" from-field="parameters.productId"/>
- <condition-expr field-name="facilityId" from-field="parameters.facilityId" ignore-if-empty="true" ignore-if-null="true"/>
- <condition-expr field-name="containerId" from-field="parameters.containerId" ignore-if-empty="true" ignore-if-null="true"/>
- <condition-expr field-name="quantityOnHandTotal" operator="greater" value="0.0"/>
- <condition-expr field-name="locationTypeEnumId" operator="equals" value="FLT_PICKLOC"/>
- </condition-list>
- <order-by field-name="${orderByString}"/>
- </entity-condition>
- <iterate entry="inventoryItemAndLocation" list="inventoryItemAndLocations">
- <if-compare field="parameters.quantityNotReserved" operator="greater" value="0" type="Double">
- <!-- this is a little trick to get the InventoryItem value object without doing a query, possible since all fields on InventoryItem are also on InventoryItemAndLocation with the same names -->
- <make-value entity-name="InventoryItem" map="inventoryItemAndLocation" value-field="inventoryItem"/>
- <call-simple-method method-name="reserveForInventoryItemInline"/>
- </if-compare>
- </iterate>
- <!-- still some left? try the FLT_BULK locations -->
- <if-compare field="parameters.quantityNotReserved" operator="greater" value="0" type="BigDecimal">
- <entity-condition entity-name="InventoryItemAndLocation" list="inventoryItemAndLocations">
- <condition-list combine="and">
- <condition-expr field-name="productId" from-field="parameters.productId"/>
- <condition-expr field-name="facilityId" from-field="parameters.facilityId" ignore-if-empty="true" ignore-if-null="true"/>
- <condition-expr field-name="containerId" from-field="parameters.containerId" ignore-if-empty="true" ignore-if-null="true"/>
- <condition-expr field-name="quantityOnHandTotal" operator="greater" value="0.0"/>
- <condition-expr field-name="locationTypeEnumId" operator="equals" value="FLT_BULK"/>
- </condition-list>
- <order-by field-name="${orderByString}"/>
- </entity-condition>
- <iterate entry="inventoryItemAndLocation" list="inventoryItemAndLocations">
- <if-compare field="parameters.quantityNotReserved" operator="greater" value="0" type="Double">
- <!-- this is a little trick to get the InventoryItem value object without doing a query, possible since all fields on InventoryItem are also on InventoryItemAndLocation with the same names -->
- <make-value entity-name="InventoryItem" map="inventoryItemAndLocation" value-field="inventoryItem"/>
- <call-simple-method method-name="reserveForInventoryItemInline"/>
- </if-compare>
- </iterate>
- </if-compare>
-
- <!-- last of all try reserving in InventoryItems that have no locationSeqId, ie are not in any particular location -->
- <if-compare field="parameters.quantityNotReserved" operator="greater" value="0" type="BigDecimal">
- <entity-condition entity-name="InventoryItem" list="inventoryItems">
- <condition-list combine="and">
- <condition-expr field-name="productId" from-field="parameters.productId"/>
- <condition-expr field-name="facilityId" from-field="parameters.facilityId" ignore-if-empty="true" ignore-if-null="true"/>
- <condition-expr field-name="containerId" from-field="parameters.containerId" ignore-if-empty="true" ignore-if-null="true"/>
- <condition-expr field-name="quantityOnHandTotal" operator="greater" value="0.0"/>
- <condition-expr field-name="locationSeqId" operator="equals" from-field="nullField"/>
- </condition-list>
- <order-by field-name="${orderByString}"/>
- </entity-condition>
- <iterate entry="inventoryItem" list="inventoryItems">
- <if>
- <condition>
- <and>
- <if-compare field="parameters.quantityNotReserved" operator="greater" value="0" type="Double"/>
- <if-empty field="inventoryItem.locationSeqId"/>
- </and>
- </condition>
- <then>
- <call-simple-method method-name="reserveForInventoryItemInline"/>
- </then>
- </if>
- </iterate>
- </if-compare>
- <!--
- if inventory is not required for purchase and quantityNotReserved != 0:
- - subtract the remaining quantityNotReserved from the availableToPromise of the last non-serialized inventory item
- - or if none was found create a non-ser InventoryItem with availableToPromise = -quantityNotReserved
- -->
- <if-compare field="parameters.quantityNotReserved" operator="not-equals" value="0" type="BigDecimal">
- <if-compare field="parameters.requireInventory" operator="equals" value="Y">
- <!-- use this else pattern to accomplish the anything but Y logic, ie if not specified default to inventory NOT required -->
+ <!-- calculate for qty is used to create listing already, can not remove that qty until list is end or cancel listing-->
+ <calculate field="qtyToUsed" type="BigDecimal" >
+ <calcop operator="add">
+ <calcop operator="get" field="qohReserved"/>
+ <calcop operator="negative" field="atpListing"/>
+ </calcop>
+ </calculate>
+ <calculate field="qtyCanRemv" type="BigDecimal" >
+ <calcop operator="add">
+ <calcop operator="get" field="qohReserved"/>
+ <calcop operator="negative" field="qtyToUsed"/>
+ </calcop>
+ </calculate>
+ <if-compare field="qtyCanRemv" operator="greater" value="0">
+ <!-- auto remove only real qtys that we can remove then return quantity are remove to stock follow productStore, facility and productId -->
+ <set field="qtyToRemove" type="BigDecimal" default-value="0" value="${qtyInp}"/>
+ <if-compare field="qtyCanRemv" value="${qtyToRemove}" operator="greater-equals">
+ <call-simple-method method-name="removeEbayProductQtyReserved"/>
+ <log level="info" message="(${qtyToRemove}) product quantity was cancel from inventory with this transaction"></log>
<else>
- <if-not-empty field="lastNonSerInventoryItem">
- <!-- subtract from quantityNotReserved from the availableToPromise of existing inventory item -->
- <!-- instead of updating InventoryItem, add an InventoryItemDetail -->
- <set from-field="lastNonSerInventoryItem.inventoryItemId" field="createDetailMap.inventoryItemId"/>
- <set from-field="parameters.reserveReasonEnumId" field="createDetailMap.reasonEnumId"/>
- <calculate field="createDetailMap.availableToPromiseDiff">
- <calcop field="parameters.quantityNotReserved" operator="negative"/>
- </calculate>
- <call-service service-name="createInventoryItemDetail" in-map-name="createDetailMap"/>
- <clear-field field="createDetailMap"/>
-
- <!-- get the promiseDatetime -->
- <get-related-one value-field="lastNonSerInventoryItem" relation-name="ProductFacility" to-value-field="productFacility"/>
- <clear-field field="daysToShip"/>
- <set field="daysToShip" from-field="productFacility.daysToShip"/>
- <if-empty field="daysToShip">
- <!-- if the product does not have its own days to ship, use Facility.defaultDaysToShip, if not then use 30 days as a USA industry default -->
- <if-not-empty field="facility.defaultDaysToShip">
- <set field="daysToShip" from-field="facility.defaultDaysToShip" type="Long"/>
- <else>
- <set field="daysToShip" value="30" type="Long"/>
- </else>
- </if-not-empty>
- </if-empty>
- <!-- TODO: Convert this to a <set-calendar> operation -->
- <call-bsh><![CDATA[
- java.sql.Timestamp orderDate = orderHeader.getTimestamp("orderDate");
- com.ibm.icu.util.Calendar cal = com.ibm.icu.util.Calendar.getInstance();
- cal.setTimeInMillis(orderDate.getTime());
- cal.add(com.ibm.icu.util.Calendar.DAY_OF_YEAR, daysToShip.intValue());
- return org.ofbiz.base.util.UtilMisc.toMap("promisedDatetime", new java.sql.Timestamp(cal.getTimeInMillis()));
- ]]></call-bsh>
-
- <else>
- <!-- no non-ser inv item, create a non-ser InventoryItem with availableToPromise = -quantityNotReserved -->
- <clear-field field="createInventoryItemInMap"/>
- <clear-field field="createInventoryItemOutMap"/>
- <!-- the createInventoryItem service is run by the the system user here -->
- <entity-one entity-name="UserLogin" value-field="permUserLogin">
- <field-map field-name="userLoginId" value="system"/>
- </entity-one>
- <set from-field="parameters.productId" field="createInventoryItemInMap.productId"/>
- <set from-field="parameters.facilityId" field="createInventoryItemInMap.facilityId"/>
- <set from-field="parameters.containerId" field="createInventoryItemInMap.containerId"/>
- <set value="NON_SERIAL_INV_ITEM" field="createInventoryItemInMap.inventoryItemTypeId"/>
- <set from-field="permUserLogin" field="createInventoryItemInMap.userLogin"/>
- <call-service service-name="createInventoryItem" in-map-name="createInventoryItemInMap" include-user-login="false">
- <result-to-field result-name="inventoryItemId" field="createInventoryItemOutMap.inventoryItemId"/>
- </call-service>
- <entity-one entity-name="InventoryItem" value-field="newNonSerInventoryItem">
- <field-map field-name="inventoryItemId" from-field="createInventoryItemOutMap.inventoryItemId"/>
- </entity-one>
-
- <!-- also create a detail record with the quantities -->
- <set from-field="newNonSerInventoryItem.inventoryItemId" field="createDetailMap.inventoryItemId"/>
- <set from-field="parameters.reserveReasonEnumId" field="createDetailMap.reasonEnumId"/>
- <calculate field="createDetailMap.availableToPromiseDiff">
- <calcop field="parameters.quantityNotReserved" operator="negative"/>
- </calculate>
- <call-service service-name="createInventoryItemDetail" in-map-name="createDetailMap"/>
- <clear-field field="createDetailMap"/>
-
- <!-- get the promiseDatetime -->
- <get-related-one value-field="newNonSerInventoryItem" relation-name="ProductFacility" to-value-field="productFacility"/>
- <clear-field field="daysToShip"/>
- <set field="daysToShip" from-field="productFacility.daysToShip"/>
- <if-empty field="daysToShip">
- <!-- if the product does not have its own days to ship, use Facility.defaultDaysToShip, if not then use 30 days as a USA industry default -->
- <if-not-empty field="facility.defaultDaysToShip">
- <set field="daysToShip" from-field="facility.defaultDaysToShip" type="Long"/>
- <else>
- <set field="daysToShip" value="30" type="Long"/>
- </else>
- </if-not-empty>
- </if-empty>
- <!-- TODO: Convert this to a <set-calendar> operation -->
- <call-bsh><![CDATA[
- java.sql.Timestamp orderDate = orderHeader.getTimestamp("orderDate");
- com.ibm.icu.util.Calendar cal = com.ibm.icu.util.Calendar.getInstance();
- cal.setTimeInMillis(orderDate.getTime());
- cal.add(com.ibm.icu.util.Calendar.DAY_OF_YEAR, daysToShip.intValue());
- return org.ofbiz.base.util.UtilMisc.toMap("promisedDatetime", new java.sql.Timestamp(cal.getTimeInMillis()));
- ]]></call-bsh>
-
- </else>
- </if-not-empty>
-
- <set field="parameters.quantityNotReserved" value="0" type="BigDecimal"/>
+ <!-- calculate for over qty want to remove -->
+ <calculate field="qtyOverRemv" type="BigDecimal" >
+ <calcop operator="add">
+ <calcop operator="get" field="qtyToRemove"/>
+ <calcop operator="negative" field="qtyCanRemv"/>
+ </calcop>
+ </calculate>
+ <set field="qtyToRemove" type="BigDecimal" default-value="0" from-field="qtyCanRemv"/>
+ <call-simple-method method-name="removeEbayProductQtyReserved"/>
+ <set field="successMessage" value="${returnSuccessMessage} (${qtyToRemove}) product qty was canceled from this transaction and (${qtyOverRemv}) was fail because you reserved in inventory only ${qtyToRemove}. "/>
+ <field-to-result field="successMessage"/>
</else>
</if-compare>
- </if-compare>
- </else>
- </if-compare>
-
- <field-to-result field="parameters.quantityNotReserved" result-name="quantityNotReserved"/>
- </simple-method>
-
- <simple-method method-name="reserveForInventoryItemInline" short-description="Does a reservation for one InventoryItem, meant to be called in-line">
- <!-- only do something with this inventoryItem if there is more inventory to reserve -->
- <if-compare field="parameters.quantityNotReserved" operator="greater" value="0" type="BigDecimal">
-
- <if-compare value="SERIALIZED_INV_ITEM" operator="equals" field="inventoryItem.inventoryItemTypeId">
- <if-compare value="INV_AVAILABLE" operator="equals" field="inventoryItem.statusId">
- <!-- change status on inventoryItem -->
- <set value="INV_PROMISED" field="inventoryItem.statusId"/>
- <store-value value-field="inventoryItem"/>
-
- <clear-field field="reserveOisgirMap"/>
-
- <calculate field="parameters.quantityNotReserved">
- <calcop field="parameters.quantityNotReserved" operator="subtract"><number value="1.0"/></calcop>
+ <!-- update values in EbayProductStoreInventory -->
+ <calculate field="ebayProductStoreInventory.quantityReserved" type="BigDecimal" >
+ <calcop operator="add">
+ <calcop operator="get" field="qohReserved"/>
+ <calcop operator="negative" field="qtyToRemove"/>
+ </calcop>
</calculate>
+ <calculate field="ebayProductStoreInventory.availableToPromiseListing" type="BigDecimal" >
+ <calcop operator="add">
+ <calcop operator="get" field="atpListing"/>
+ <calcop operator="negative" field="qtyToRemove"/>
+ </calcop>
+ </calculate>
+ <store-value value-field="ebayProductStoreInventory"/>
+ <else>
+ <add-error><fail-message message="can not decrease quantity of product ${parameters.productId} because it already to used created listing."/></add-error>
+ <return/>
+ </else>
</if-compare>
- </if-compare>
- <if-compare field="inventoryItem.inventoryItemTypeId" operator="equals" value="NON_SERIAL_INV_ITEM">
- <!-- reduce atp on inventoryItem if availableToPromise greater than 0, if not the code at the end of this method will handle it -->
- <if>
- <condition>
- <and>
- <if-compare field="inventoryItem.statusId" operator="not-equals" value="ON_HOLD_NS"/>
- <if-compare field="inventoryItem.statusId" operator="not-equals" value="DEFECTIVE_NS"/>
- <not><if-empty field="inventoryItem.availableToPromiseTotal"/></not>
- <if-compare field="inventoryItem.availableToPromiseTotal" operator="greater" value="0" type="BigDecimal"/>
- </and>
- </condition>
- <then>
- <if-compare-field field="parameters.quantityNotReserved" to-field="inventoryItem.availableToPromiseTotal" operator="greater" type="BigDecimal">
- <set from-field="inventoryItem.availableToPromiseTotal" field="parameters.deductAmount"/>
- <else>
- <set from-field="parameters.quantityNotReserved" field="parameters.deductAmount"/>
- </else>
- </if-compare-field>
-
- <!-- instead of updating InventoryItem, add an InventoryItemDetail -->
- <set from-field="inventoryItem.inventoryItemId" field="createDetailMap.inventoryItemId"/>
- <set from-field="parameters.reserveReasonEnumId" field="createDetailMap.reasonEnumId"/>
- <calculate field="createDetailMap.availableToPromiseDiff">
- <calcop field="parameters.deductAmount" operator="negative"/>
- </calculate>
- <call-service service-name="createInventoryItemDetail" in-map-name="createDetailMap"/>
- <clear-field field="createDetailMap"/>
-
- <calculate field="parameters.quantityNotReserved">
- <calcop operator="subtract" field="parameters.quantityNotReserved">
- <calcop operator="get" field="parameters.deductAmount"/>
- </calcop>
- </calculate>
- </then>
- </if>
- <!-- keep track of the last non-serialized inventory item for use if inventory is not required for purchase -->
- <!-- use env variable named lastNonSerInventoryItem -->
- <set from-field="inventoryItem" field="lastNonSerInventoryItem"/>
- </if-compare>
+ </else>
</if-compare>
</simple-method>
- <simple-method method-name="getPromisedDateTime" short-description="Get Inventory Promised Date/Time">
- <!-- get the promiseDatetime -->
- <get-related-one value-field="inventoryItem" relation-name="ProductFacility" to-value-field="productFacility"/>
- <set field="daysToShip" from-field="productFacility.daysToShip"/>
- <if-empty field="daysToShip">
- <!-- if the product does not have its own days to ship, use Facility.defaultDaysToShip, if not then use 30 days as a USA industry default -->
- <set field="daysToShip" from-field="facility.defaultDaysToShip" type="Long"/>
- </if-empty>
- <if-empty field="daysToShip">
- <set field="daysToShip" value="30" type="Long"/>
- </if-empty>
- <!-- TODO: Convert this to a <set-calendar> operation -->
- <call-bsh><![CDATA[
- java.sql.Timestamp orderDate = orderHeader.getTimestamp("orderDate");
- com.ibm.icu.util.Calendar cal = com.ibm.icu.util.Calendar.getInstance();
- cal.setTimeInMillis(orderDate.getTime());
- cal.add(com.ibm.icu.util.Calendar.DAY_OF_YEAR, daysToShip.intValue());
- return org.ofbiz.base.util.UtilMisc.toMap("promisedDatetime", new java.sql.Timestamp(cal.getTimeInMillis()));
- ]]></call-bsh>
+ <simple-method method-name="removeEbayProductQtyReserved" short-description="remove reserved product qty and return quantity to inventory">
+ <!--for InventoryItems that have no locationSeqId -->
+ <set value="+datetimeReceived" field="orderByString"/>
+ <entity-condition entity-name="InventoryItem" list="inventoryItems">
+ <condition-list combine="and">
+ <condition-expr field-name="productId" from-field="parameters.productId"/>
+ <condition-expr field-name="facilityId" from-field="parameters.facilityId"/>
+ <condition-expr field-name="containerId" from-field="parameters.containerId" ignore-if-empty="true" ignore-if-null="true"/>
+ <condition-expr field-name="quantityOnHandTotal" operator="greater" value="0.0"/>
+ <condition-expr field-name="locationSeqId" operator="equals" from-field="nullField"/>
+ </condition-list>
+ <order-by field-name="${orderByString}"/>
+ </entity-condition>
+ <set field="qtyless" type="BigDecimal" default-value="0" from-field="qtyToRemove"/>
+ <iterate entry="inventoryItem" list="inventoryItems">
+ <if>
+ <condition>
+ <and>
+ <if-empty field="inventoryItem.locationSeqId"/>
+ </and>
+ </condition>
+ <then>
+ <get-related value-field="inventoryItem" relation-name="InventoryItemDetail" list="inventoryItemDetails"/>
+ <if-not-empty field="inventoryItemDetails">
+ <iterate entry="inventoryItemDetail" list="inventoryItemDetails">
+ <if>
+ <condition>
+ <and>
+ <if-compare field="inventoryItemDetail.reasonEnumId" value="EBAY_INV_RES" operator="equals"></if-compare>
+ <if-empty field="inventoryItemDetail.orderId"></if-empty>
+ <if-empty field="inventoryItemDetail.orderItemSeqId"></if-empty>
+ <if-compare field="inventoryItemDetail.availableToPromiseDiff" value="0" operator="not-equals"></if-compare>
+ </and>
+ </condition>
+ <then>
+ <if-compare field="qtyless" value="0" operator="greater">
+ <calculate field="qtyResult" type="BigDecimal" >
+ <calcop operator="add">
+ <calcop operator="get" field="inventoryItemDetail.availableToPromiseDiff"/>
+ <calcop operator="get" field="${qtyless}"/>
+ </calcop>
+ </calculate>
+ <if-compare field="qtyResult" value="0" operator="greater-equals">
+ <remove-value value-field="inventoryItemDetail"/>
+ <else>
+ <set field="inventoryItemDetail.availableToPromiseDiff" type="BigDecimal" from-field="qtyResult"/>
+ <store-value value-field="inventoryItemDetail"/>
+ </else>
+ </if-compare>
+ <set field="qtyless" type="BigDecimal" value="${qtyResult}"/>
+ <else>
+ <return/>
+ </else>
+ </if-compare>
+ </then>
+ </if>
+ </iterate>
+ </if-not-empty>
+ </then>
+ </if>
+ </iterate>
</simple-method>
</simple-methods>
\ No newline at end of file
Modified: ofbiz/trunk/specialpurpose/ebaystore/servicedef/services.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebaystore/servicedef/services.xml?rev=906373&r1=906372&r2=906373&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebaystore/servicedef/services.xml (original)
+++ ofbiz/trunk/specialpurpose/ebaystore/servicedef/services.xml Thu Feb 4 06:01:06 2010
@@ -103,7 +103,7 @@
<attribute name="storeDescFontSize" mode="IN" type="String" optional="true"/>
<attribute name="storeDescFontColor" mode="IN" type="String" optional="true"/>
<attribute name="storeCustomHeaderLayout" mode="IN" type="String" optional="false"/>
- <attribute name="storeCustomHeader" mode="IN" type="String" optional="false"/>
+ <attribute name="storeCustomHeader" mode="IN" type="String" allow-html="any" optional="true"/>
<attribute name="storeHeaderStyle" mode="IN" type="String" optional="false"/>
<attribute name="storeItemLayout" mode="IN" type="String" optional="false"/>
<attribute name="storeItemSortOrder" mode="IN" type="String" optional="false"/>
@@ -189,8 +189,8 @@
<attribute name="itemBlocked" type="Map" mode="OUT" optional="true"/>
</service>
<!-- ebay inventory -->
- <service name="reserveEbayStoreInventory" engine="simple"
- location="component://ebaystore/script/org/ofbiz/ebaystore/EbayServices.xml" invoke="reserveEbayStoreInventory">
+ <service name="reserveEbayProductInventory" engine="simple"
+ location="component://ebaystore/script/org/ofbiz/ebaystore/EbayServices.xml" invoke="reserveEbayProductInventory">
<description>Reserve Inventory in a Product Store</description>
<attribute name="productStoreId" type="String" mode="IN" optional="false"></attribute>
<attribute name="productId" type="String" mode="IN" optional="false"></attribute>
@@ -199,18 +199,23 @@
<attribute name="quantityNotReserved" type="BigDecimal" mode="OUT" optional="false"></attribute>
</service>
<service name="reserveEbayProductInventoryByStoreFacility" engine="simple"
- location="component://ebaystore/script/org/ofbiz/ebaystore/EbayServices.xml" invoke="reserveEbayProductInventory" auth="true">
- <description>Reserve Inventory for a Product By Facility
+ location="component://product/script/org/ofbiz/product/inventory/InventoryReserveServices.xml" invoke="reserveProductInventory" auth="true">
+ <description>Reserve product for ebay Inventory and make reserve for a Product By Facility
If requireInventory is Y the quantity not reserved is returned, if N then a negative
availableToPromise will be used to track quantity ordered beyond what is in stock.
</description>
<attribute name="productId" type="String" mode="IN" optional="false"/>
<attribute name="facilityId" type="String" mode="IN" optional="false"/>
+ <attribute name="orderId" type="String" mode="IN" optional="true"/>
+ <attribute name="orderItemSeqId" type="String" mode="IN" optional="true"/>
+ <attribute name="shipGroupSeqId" type="String" mode="IN" optional="true"/>
<attribute name="quantity" type="BigDecimal" mode="IN" optional="false"/>
<attribute name="reservedDatetime" type="Timestamp" mode="IN" optional="true"/>
<attribute name="requireInventory" type="String" mode="IN" optional="false"/>
<attribute name="reserveOrderEnumId" type="String" mode="IN" optional="true"/>
+ <attribute name="reserveReasonEnumId" type="String" mode="IN" optional="false"/>
<attribute name="sequenceId" type="Long" mode="IN" optional="true"/>
+ <attribute name="priority" type="String" mode="IN" optional="true"/>
<attribute name="quantityNotReserved" type="BigDecimal" mode="OUT" optional="false"/>
</service>
<service name="updateEbayStoreInventory" engine="java" transaction-timeout="3600"
@@ -227,5 +232,24 @@
<attribute name="productStoreId" type="String" mode="IN" optional="false"/>
<attribute name="folderId" type="String" mode="OUT" optional="false"></attribute>
</service>
+ <service name="updateEbayInventoryStatusByProductId" default-entity-name="EbayProductStoreInventory" engine="java" transaction-timeout="3600"
+ location="org.ofbiz.ebaystore.EbayStoreInventoryServices" invoke="updateEbayInventoryStatusByProductId" auth="true">
+ <description>update status Inventory from ebay store inventory</description>
+ <auto-attributes mode="INOUT" optional="false" include="pk"></auto-attributes>
+ <attribute name="folderId" type="String" mode="INOUT" optional="false"></attribute>
+ <attribute name="ebayProductId" type="Long" mode="IN" optional="false"></attribute>
+ </service>
+ <service name="updateEbayInventoryStatus" engine="java" transaction-timeout="7200"
+ location="org.ofbiz.ebaystore.EbayStoreInventoryServices" invoke="updateEbayInventoryStatus" auth="true">
+ <attribute name="productStoreId" type="String" mode="IN" optional="false"></attribute>
+ <attribute name="facilityId" type="String" mode="IN" optional="false"></attribute>
+ </service>
+ <service name="updateEbayProductQtyReserved" default-entity-name="EbayProductStoreInventory" engine="simple"
+ location="component://ebaystore/script/org/ofbiz/ebaystore/EbayServices.xml" invoke="updateEbayProductQtyReserved" auth="true">
+ <description>Update/cancel an Product quantity that reserved from inventory</description>
+ <auto-attributes include="pk" mode="IN" optional="false"/>
+ <attribute name="quantity" type="BigDecimal" mode="IN" optional="false"></attribute>
+ <attribute name="actionType" type="String" mode="IN" optional="false"></attribute>
+ </service>
</services>
\ No newline at end of file
Modified: ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStore.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStore.java?rev=906373&r1=906372&r2=906373&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStore.java (original)
+++ ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStore.java Thu Feb 4 06:01:06 2010
@@ -466,14 +466,14 @@
String userLoginId = null;
String password = null;
- if(context.get("productStoreId") != null){
+ if (context.get("productStoreId") != null) {
String partyId = null;
try {
List<GenericValue> productStoreRoles = delegator.findByAnd("ProductStoreRole", UtilMisc.toMap("productStoreId", context.get("productStoreId").toString(),"roleTypeId","EBAY_ACCOUNT"));
- if(productStoreRoles!=null){
+ if (productStoreRoles!=null) {
partyId= (String)productStoreRoles.get(0).get("partyId");
List<GenericValue> userLogin = delegator.findByAnd("UserLogin", UtilMisc.toMap("partyId", partyId));
- if(userLogin!=null){
+ if (userLogin!=null) {
userLoginId = (String)userLogin.get(0).get("userLoginId");
password = (String)userLogin.get(0).get("currentPassword");
}
@@ -490,10 +490,10 @@
try {
resp = (GetStoreResponseType)call.execute(req);
- if(resp != null && "SUCCESS".equals(resp.getAck().toString())){
+ if (resp != null && "SUCCESS".equals(resp.getAck().toString())) {
returnedStoreType = resp.getStore();
result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_SUCCESS);
- result.put(ModelService.SUCCESS_MESSAGE, UtilProperties.getMessage(resource, "EbayStoreLoadSuccess", locale));
+ //result.put(ModelService.SUCCESS_MESSAGE, UtilProperties.getMessage(resource, "EbayStoreLoadSuccess", locale));
// update product store in ofbiz
updateProductStore(dctx, context,returnedStoreType,(String)context.get("productStoreId"));
Map<String,Object> ebayResp = FastMap.newInstance();
@@ -501,7 +501,7 @@
ebayResp.put("storeUrl", returnedStoreType.getURL());
ebayResp.put("storeUrlPath", returnedStoreType.getURLPath());
String desc = returnedStoreType.getDescription();
- if(desc!=null) desc = desc.trim();
+ if (desc!=null) desc = desc.trim();
ebayResp.put("storeDesc", desc);
StoreLogoType logoType = returnedStoreType.getLogo();
@@ -526,13 +526,13 @@
ebayResp.put("storeNameColor",fontType.getNameColor());
ebayResp.put("storeTitleColor",fontType.getTitleColor());
- if(fontType!=null){// basic & advance theme
+ if (fontType!=null) {// basic & advance theme
String themeId = themeType.getThemeID().toString().concat("-").concat(colorSchemeType.getColorSchemeID().toString());
context.put("themeId", themeId);
Map<String,Object> results = retrieveThemeColorSchemeByThemeId(dctx,context);
- if(results!=null){
+ if (results!=null) {
Map<String,Object> storeFontScheme = (Map<String,Object>)results.get("storeFontScheme");
- if(storeFontScheme!=null){
+ if (storeFontScheme!=null) {
ebayResp.put("storeDescFontFace",storeFontScheme.get("storeFontTypeFontDescValue"));
ebayResp.put("storeDescSizeCode", storeFontScheme.get("storeDescSizeValue"));
@@ -548,10 +548,10 @@
StoreHeaderStyleCodeType storeHeaderStyleCodeType = returnedStoreType.getHeaderStyle();
ebayResp.put("storeHeaderStyle", storeHeaderStyleCodeType.value());
StoreHeaderStyleCodeType[] storeHeaderStyleCodeList = storeHeaderStyleCodeType.values();
- if(storeHeaderStyleCodeList != null){
+ if (storeHeaderStyleCodeList != null) {
List<Map<String,Object>> storeHeaderStyleList = FastList.newInstance();
int i=0;
- while(i<storeHeaderStyleCodeList.length){
+ while (i<storeHeaderStyleCodeList.length) {
Map<String,Object> storeHeaderStyleMap = FastMap.newInstance();
StoreHeaderStyleCodeType storeHeaderStyleCode = storeHeaderStyleCodeList[i];
storeHeaderStyleMap.put("storeHeaderStyleName",storeHeaderStyleCode.name());
@@ -567,10 +567,10 @@
StoreItemListLayoutCodeType storeItemListLayoutCodeType = returnedStoreType.getItemListLayout();
ebayResp.put("storeItemLayoutSelected", storeItemListLayoutCodeType.value());
StoreItemListLayoutCodeType[] storeItemListLayoutCodeTypeList = storeItemListLayoutCodeType.values();
- if(storeItemListLayoutCodeTypeList!=null){
+ if (storeItemListLayoutCodeTypeList!=null) {
List<Map<String,Object>> storeItemListLayoutCodeList = FastList.newInstance();
int i=0;
- while(i<storeItemListLayoutCodeTypeList.length){
+ while (i<storeItemListLayoutCodeTypeList.length) {
Map<String,Object> storeItemListLayoutCodeMap = FastMap.newInstance();
StoreItemListLayoutCodeType storeItemListLayoutCode = storeItemListLayoutCodeTypeList[i];
storeItemListLayoutCodeMap.put("storeItemLayoutName",storeItemListLayoutCode.name());
@@ -583,10 +583,10 @@
StoreItemListSortOrderCodeType storeItemListSortOrderCodeType = returnedStoreType.getItemListSortOrder();
ebayResp.put("storeItemSortOrderSelected", storeItemListSortOrderCodeType.value());
StoreItemListSortOrderCodeType[] storeItemListSortOrderCodeTypeList = storeItemListSortOrderCodeType.values();
- if(storeItemListSortOrderCodeTypeList!=null){
+ if (storeItemListSortOrderCodeTypeList!=null) {
List<Map<String,Object>> storeItemSortOrderCodeList = FastList.newInstance();
int i=0;
- while(i<storeItemListSortOrderCodeTypeList.length){
+ while (i<storeItemListSortOrderCodeTypeList.length) {
Map<String,Object> storeItemSortOrderCodeMap = FastMap.newInstance();
StoreItemListSortOrderCodeType storeItemListLayoutCode = storeItemListSortOrderCodeTypeList[i];
storeItemSortOrderCodeMap.put("storeItemSortLayoutName",storeItemListLayoutCode.name());
@@ -601,10 +601,10 @@
StoreCustomHeaderLayoutCodeType storeCustomHeaderLayoutCodeType = returnedStoreType.getCustomHeaderLayout();
ebayResp.put("storeCustomHeaderLayout",storeCustomHeaderLayoutCodeType.value());
StoreCustomHeaderLayoutCodeType[] storeCustomHeaderLayoutCodeTypeList = storeCustomHeaderLayoutCodeType.values();
- if(storeCustomHeaderLayoutCodeTypeList!=null){
+ if (storeCustomHeaderLayoutCodeTypeList!=null) {
List<Map<String,Object>> storeCustomHeaderLayoutList = FastList.newInstance();
int i=0;
- while(i<storeCustomHeaderLayoutCodeTypeList.length){
+ while (i<storeCustomHeaderLayoutCodeTypeList.length) {
Map<String,Object> storeCustomHeaderLayoutMap = FastMap.newInstance();
StoreCustomHeaderLayoutCodeType StoreCustomHeaderLayoutCode = storeCustomHeaderLayoutCodeTypeList[i];
storeCustomHeaderLayoutMap.put("storeCustomHeaderLayoutName",StoreCustomHeaderLayoutCode.name());
@@ -616,7 +616,7 @@
}
StoreCustomListingHeaderType storeCustomListingHeaderType = returnedStoreType.getCustomListingHeader();
- if(storeCustomListingHeaderType!=null){
+ if (storeCustomListingHeaderType!=null) {
StoreCustomListingHeaderDisplayCodeType storeCustomListingHeaderDisplayCodeType = storeCustomListingHeaderType.getDisplayType();
ebayResp.put("isLogo",storeCustomListingHeaderType.isLogo());
ebayResp.put("isSearchBox",storeCustomListingHeaderType.isSearchBox());
@@ -626,10 +626,10 @@
ebayResp.put("storeCustomListingHeaderDisplayName",storeCustomListingHeaderDisplayCodeType.name());
ebayResp.put("storeCustomListingHeaderDisplayValue",storeCustomListingHeaderDisplayCodeType.value());
StoreCustomListingHeaderDisplayCodeType[] storeCustomListingHeaderDisplayCodeTypeList = storeCustomListingHeaderDisplayCodeType.values();
- if(storeCustomListingHeaderDisplayCodeTypeList != null){
+ if (storeCustomListingHeaderDisplayCodeTypeList != null) {
List<Map<String,Object>> storeCustomListingHeaderDisplayCodeList = FastList.newInstance();
int i=0;
- while(i<storeCustomListingHeaderDisplayCodeTypeList.length){
+ while (i<storeCustomListingHeaderDisplayCodeTypeList.length) {
Map<String,Object> storeCustomListingHeaderDisplayCodeMap = FastMap.newInstance();
StoreCustomListingHeaderDisplayCodeType storeCustomListingHeaderDisplayCode = storeCustomListingHeaderDisplayCodeTypeList[i];
storeCustomListingHeaderDisplayCodeMap.put("storeCustomHeaderLayoutName",storeCustomListingHeaderDisplayCode.name());
@@ -645,10 +645,10 @@
MerchDisplayCodeType merchDisplayCodeType = returnedStoreType.getMerchDisplay();
ebayResp.put("storeMerchDisplay",merchDisplayCodeType.value());
MerchDisplayCodeType[] merchDisplayCodeTypeList = merchDisplayCodeType.values();
- if(merchDisplayCodeTypeList!=null){
+ if (merchDisplayCodeTypeList!=null) {
List<Map<String,Object>> merchDisplayCodeList = FastList.newInstance();
int i=0;
- while(i<merchDisplayCodeTypeList.length){
+ while (i<merchDisplayCodeTypeList.length) {
Map<String,Object> merchDisplayCodeMap = FastMap.newInstance();
MerchDisplayCodeType merchDisplayCode = merchDisplayCodeTypeList[i];
merchDisplayCodeMap.put("merchDisplayCodeName",merchDisplayCode.name());
@@ -663,10 +663,10 @@
ebayResp.put("storeLastOpenedTime", calendar.getTime().toString());
ebayResp.put("storeSubscriptionLevel",returnedStoreType.getSubscriptionLevel().value());
StoreSubscriptionLevelCodeType[] storeSubscriptionlevelList = returnedStoreType.getSubscriptionLevel().values();
- if(storeSubscriptionlevelList!=null){
+ if (storeSubscriptionlevelList!=null) {
List<Map<String,Object>> storeSubscriptionLevelCodeList = FastList.newInstance();
int i=0;
- while(i<storeSubscriptionlevelList.length){
+ while (i<storeSubscriptionlevelList.length) {
Map<String,Object> storeSubscriptionLevelCodeMap = FastMap.newInstance();
StoreSubscriptionLevelCodeType storeSubscriptionLevelCode= storeSubscriptionlevelList[i];
storeSubscriptionLevelCodeMap.put("storeSubscriptionLevelCodeName", storeSubscriptionLevelCode.name());
@@ -678,7 +678,7 @@
}
result.put("ebayStore", ebayResp);
- }else{
+ } else {
result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_ERROR);
result.put(ModelService.ERROR_MESSAGE,resp.getAck().toString()+":"+resp.getMessage());
}
@@ -698,7 +698,6 @@
public static void updateProductStore(DispatchContext dctx,Map<String,Object> context,StoreType returnStoreType,String productStoreId){
LocalDispatcher dispatcher = dctx.getDispatcher();
- Delegator delegator = dctx.getDelegator();
try{
Map<String,Object> inMap = FastMap.newInstance();
if(returnStoreType != null){
@@ -723,17 +722,16 @@
GetStoreOptionsRequestType req = null;
GetStoreOptionsResponseType resp = null;
StoreThemeArrayType returnedBasicThemeArray = null;
- StoreThemeArrayType returnedAdvanceThemeArray = null;
try {
- if(context.get("productStoreId") != null){
+ if (context.get("productStoreId") != null) {
String themeId = (String)context.get("themeId");
GetStoreOptionsCall call = new GetStoreOptionsCall(EbayStoreHelper.getApiContext((String)context.get("productStoreId"), locale, delegator));
req = new GetStoreOptionsRequestType();
resp = (GetStoreOptionsResponseType) call.execute(req);
- if(resp != null && "SUCCESS".equals(resp.getAck().toString())){
+ if (resp != null && "SUCCESS".equals(resp.getAck().toString())) {
returnedBasicThemeArray = resp.getBasicThemeArray();
StoreThemeType[] storeBasicTheme = returnedBasicThemeArray.getTheme();
@@ -743,14 +741,12 @@
themeId = themeId.substring(0,themeId.indexOf("-"));
Map<String,Object> storeColorSchemeMap = null;
- boolean flag = false;
- while(i<storeBasicTheme.length){
-
+ while (i<storeBasicTheme.length) {
StoreThemeType storeThemeType = (StoreThemeType)storeBasicTheme[i];
- if(themeId.equals(storeThemeType.getThemeID().toString())){
+ if (themeId.equals(storeThemeType.getThemeID().toString())) {
StoreColorSchemeType colorSchemeType = storeThemeType.getColorScheme();
- if(colorSchemeType!=null){
- if(colorSchemeId.equals(colorSchemeType.getColorSchemeID().toString())){
+ if (colorSchemeType!=null) {
+ if (colorSchemeId.equals(colorSchemeType.getColorSchemeID().toString())) {
// get font,size and color
storeColorSchemeMap = FastMap.newInstance();
StoreFontType storeFontType = colorSchemeType.getFont();
@@ -762,7 +758,6 @@
storeColorSchemeMap.put("storeFontTypeFontDescValue",storeFontType.getDescFace().value());
storeColorSchemeMap.put("storeDescSizeValue",storeFontType.getDescSize().value());
- flag=true;
break;
}
}
@@ -791,18 +786,18 @@
StoreLogoArrayType returnedLogoArray = null;
GetStoreOptionsResponseType resp = null;
try {
- if(context.get("productStoreId") != null){
+ if (context.get("productStoreId") != null) {
GetStoreOptionsCall call = new GetStoreOptionsCall(EbayStoreHelper.getApiContext((String)context.get("productStoreId"), locale, delegator));
req = new GetStoreOptionsRequestType();
resp = (GetStoreOptionsResponseType) call.execute(req);
- if(resp != null && "SUCCESS".equals(resp.getAck().toString())){
+ if (resp != null && "SUCCESS".equals(resp.getAck().toString())) {
returnedLogoArray = resp.getLogoArray();
int i=0;
List<Map<String,Object>> logoList = FastList.newInstance();
- while(i<returnedLogoArray.getLogoLength()){
+ while (i<returnedLogoArray.getLogoLength()) {
Map<String,Object> logo = FastMap.newInstance();
StoreLogoType storeLogoType = (StoreLogoType)returnedLogoArray.getLogo(i);
logo.put("storeLogoId", storeLogoType.getLogoID());
@@ -832,18 +827,18 @@
StoreThemeArrayType returnedBasicThemeArray = null;
GetStoreOptionsResponseType resp = null;
try {
- if(context.get("productStoreId") != null){
+ if (context.get("productStoreId") != null) {
GetStoreOptionsCall call = new GetStoreOptionsCall(EbayStoreHelper.getApiContext((String)context.get("productStoreId"), locale, delegator));
req = new GetStoreOptionsRequestType();
resp = (GetStoreOptionsResponseType) call.execute(req);
StoreColorSchemeType storeFontColorSchemeType = null;
- if(resp != null && "SUCCESS".equals(resp.getAck().toString())){
+ if (resp != null && "SUCCESS".equals(resp.getAck().toString())) {
returnedBasicThemeArray = resp.getBasicThemeArray();
int i=0;
List<Map<String,Object>> themeList = FastList.newInstance();
- while(i<returnedBasicThemeArray.getThemeLength()){
+ while (i<returnedBasicThemeArray.getThemeLength()) {
Map<String,Object> basictheme = FastMap.newInstance();
StoreThemeType storeBasicThemeType = (StoreThemeType)returnedBasicThemeArray.getTheme(i);
basictheme.put("storeThemeId", storeBasicThemeType.getThemeID());
@@ -853,10 +848,9 @@
basictheme.put("storeColorSchemeId",storeColorSchemeType.getColorSchemeID());
basictheme.put("storeColorSchemeName",storeColorSchemeType.getName());
- if(storeFontColorSchemeType == null){
+ if (storeFontColorSchemeType == null) {
storeFontColorSchemeType = storeBasicThemeType.getColorScheme();
}
-
themeList.add(basictheme);
i++;
}
Modified: ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreInventoryServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreInventoryServices.java?rev=906373&r1=906372&r2=906373&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreInventoryServices.java (original)
+++ ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreInventoryServices.java Thu Feb 4 06:01:06 2010
@@ -1,5 +1,7 @@
package org.ofbiz.ebaystore;
+import java.math.BigDecimal;
+import java.util.List;
import java.util.Locale;
import java.util.Map;
import javolution.util.FastMap;
@@ -9,6 +11,8 @@
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
import org.ofbiz.service.DispatchContext;
+import org.ofbiz.service.GenericServiceException;
+import org.ofbiz.service.LocalDispatcher;
import org.ofbiz.service.ServiceUtil;
import com.ebay.sdk.ApiException;
import com.ebay.sdk.SdkException;
@@ -30,6 +34,7 @@
import com.ebay.soap.eBLBaseComponents.ReviseSellingManagerProductResponseType;
import com.ebay.soap.eBLBaseComponents.SellingManagerFolderDetailsType;
import com.ebay.soap.eBLBaseComponents.SellingManagerProductDetailsType;
+import com.ebay.soap.eBLBaseComponents.SellingManagerProductInventoryStatusType;
import com.ebay.soap.eBLBaseComponents.SellingManagerProductType;
public class EbayStoreInventoryServices {
@@ -50,7 +55,7 @@
boolean checkProd = false;
boolean status = false;
try {
- if(context.get("productStoreId") == null || context.get("productId") == null || context.get("folderId") == null){
+ if (context.get("productStoreId") == null || context.get("productId") == null || context.get("folderId") == null) {
result = ServiceUtil.returnError("The process was required productStoreId, productId and ebay inventory folderId.");
result.put("productStoreId", context.get("productStoreId"));
result.put("facilityId", context.get("facilityId"));
@@ -61,17 +66,17 @@
String productId = (String)context.get("productId");
String folderId = (String)context.get("folderId");
// start upload/update products which selected to an ebay inventory
- if(folderId != null){
+ if (folderId != null) {
GetSellingManagerInventoryCall invenCall = new GetSellingManagerInventoryCall(EbayStoreHelper.getApiContext((String)context.get("productStoreId"), locale, delegator));
invenReq = new GetSellingManagerInventoryRequestType();
invenResp = (GetSellingManagerInventoryResponseType) invenCall.execute(invenReq);
- if(invenResp != null && "SUCCESS".equals(invenResp.getAck().toString())){
+ if (invenResp != null && "SUCCESS".equals(invenResp.getAck().toString())) {
GenericValue ebayProductStoreInventory = delegator.findByPrimaryKey("EbayProductStoreInventory", UtilMisc.toMap("productId", productId,"facilityId",context.get("facilityId"),"productStoreId",context.get("productStoreId")));
SellingManagerProductType[] sellingManagerProductTypeList = invenResp.getSellingManagerProduct();
- for(SellingManagerProductType sellingManagerProductType : sellingManagerProductTypeList){
+ for (SellingManagerProductType sellingManagerProductType : sellingManagerProductTypeList){
SellingManagerProductDetailsType sellingManagerProductDetailsType = sellingManagerProductType.getSellingManagerProductDetails();
- if(String.valueOf(sellingManagerProductDetailsType.getFolderID()).equals(folderId) && String.valueOf(sellingManagerProductDetailsType.getProductID()).equals(String.valueOf(ebayProductStoreInventory.getLong("ebayProductId"))) && String.valueOf(sellingManagerProductDetailsType.getCustomLabel()).equals(productId)){
+ if (String.valueOf(sellingManagerProductDetailsType.getFolderID()).equals(folderId) && String.valueOf(sellingManagerProductDetailsType.getProductID()).equals(String.valueOf(ebayProductStoreInventory.getLong("ebayProductId"))) && String.valueOf(sellingManagerProductDetailsType.getCustomLabel()).equals(productId)){
checkProd = true;
break;
}
@@ -79,15 +84,15 @@
}
// checkProduct is true then update detail but is false do create new one.
- if(checkProd == true){
+ if (checkProd) {
status = updateProductInEbayInventoryFolder(dctx,context);
- }else {
+ } else {
status = createNewProductInEbayInventoryFolder(dctx,context);
}
- if(status == true){
+ if (status) {
Debug.logInfo("Done to updated product ".concat(context.get("productId").toString()), module);
result = ServiceUtil.returnSuccess("Updated ebay store inventory in folder "+context.get("folderId")+" success..");
- }else{
+ } else {
result = ServiceUtil.returnError("Fail to update ebay store inventory.");
}
}
@@ -115,7 +120,7 @@
boolean flag = false;
try {
- if(context.get("productStoreId") != null && context.get("productId")!=null && context.get("folderId")!=null){
+ if (context.get("productStoreId") != null && context.get("productId")!=null && context.get("folderId")!=null) {
String productId = (String)context.get("productId");
String folderId = (String)context.get("folderId");
AddSellingManagerProductCall productCall = new AddSellingManagerProductCall(EbayStoreHelper.getApiContext((String)context.get("productStoreId"), locale, delegator));
@@ -127,16 +132,16 @@
sellingManagerProductDetailsType.setProductName((delegator.findByPrimaryKey("Product", UtilMisc.toMap("productId", productId))).getString("internalName"));
//Must keep productId in SKU NUMBER because ebay allow productId field only long value.
sellingManagerProductDetailsType.setCustomLabel(productId);
- if(ebayProductStoreInventory!=null) sellingManagerProductDetailsType.setQuantityAvailable(ebayProductStoreInventory.getBigDecimal("availableToPromiseListing").intValue());
+ if (ebayProductStoreInventory!=null) sellingManagerProductDetailsType.setQuantityAvailable(ebayProductStoreInventory.getBigDecimal("availableToPromiseListing").intValue());
productReq.setSellingManagerProductDetails(sellingManagerProductDetailsType);
productResp = (AddSellingManagerProductResponseType) productCall.execute(productReq);
- if(productResp != null && "SUCCESS".equals(productResp.getAck().toString())){
+ if (productResp != null && "SUCCESS".equals(productResp.getAck().toString())) {
flag = true;
ebayProductStoreInventory.put("ebayProductId", productResp.getSellingManagerProductDetails().getProductID());
ebayProductStoreInventory.put("folderId", folderId);
ebayProductStoreInventory.store();
- }else{
+ } else {
Debug.logError("Fail to create inventory product ".concat(productId).concat("in productStore ").concat(context.get("productStoreId").toString()).concat(" message from ebay : ").concat(productResp.getMessage()), module);
}
}
@@ -161,7 +166,7 @@
boolean flag = false;
try {
- if(context.get("productStoreId") != null && context.get("productId")!=null && context.get("folderId")!=null){
+ if (context.get("productStoreId") != null && context.get("productId")!=null && context.get("folderId")!=null) {
String productId = (String)context.get("productId");
String folderId = (String)context.get("folderId");
ReviseSellingManagerProductCall call = new ReviseSellingManagerProductCall(EbayStoreHelper.getApiContext((String)context.get("productStoreId"), locale, delegator));
@@ -169,11 +174,11 @@
SellingManagerProductDetailsType sellingManagerProductDetailsType = new SellingManagerProductDetailsType();
GenericValue ebayProductStoreInventory = delegator.findByPrimaryKey("EbayProductStoreInventory", UtilMisc.toMap("productId", productId,"facilityId",context.get("facilityId"),"productStoreId",context.get("productStoreId")));
Long ebayProductId = null;
- if(ebayProductStoreInventory !=null && ebayProductStoreInventory.getLong("ebayProductId")==null){
+ if (ebayProductStoreInventory !=null && ebayProductStoreInventory.getLong("ebayProductId")==null) {
Debug.logError("Can not update product "+productId+" has no ebay product Id in EbayProductStoreInventory. ", module);
return flag;
}
- if(ebayProductStoreInventory!=null && ebayProductStoreInventory.getLong("ebayProductId")!=null){
+ if (ebayProductStoreInventory!=null && ebayProductStoreInventory.getLong("ebayProductId")!=null) {
ebayProductId = ebayProductStoreInventory.getLong("ebayProductId");
}
sellingManagerProductDetailsType.setProductID(ebayProductId);
@@ -181,16 +186,16 @@
sellingManagerProductDetailsType.setProductName((delegator.findByPrimaryKey("Product", UtilMisc.toMap("productId", productId))).getString("internalName"));
//Must keep productId in SKU NUMBER because ebay allow productId field only long value.
sellingManagerProductDetailsType.setCustomLabel(productId);
- if(ebayProductStoreInventory!=null) sellingManagerProductDetailsType.setQuantityAvailable(ebayProductStoreInventory.getBigDecimal("availableToPromiseListing").intValue());
+ if (ebayProductStoreInventory!=null) sellingManagerProductDetailsType.setQuantityAvailable(ebayProductStoreInventory.getBigDecimal("availableToPromiseListing").intValue());
req.setSellingManagerProductDetails(sellingManagerProductDetailsType);
resp = (ReviseSellingManagerProductResponseType) call.execute(req);
- if(resp != null && "SUCCESS".equals(resp.getAck().toString())){
+ if (resp != null && "SUCCESS".equals(resp.getAck().toString())) {
flag = true;
ebayProductStoreInventory.put("ebayProductId", ebayProductId);
ebayProductStoreInventory.put("folderId", folderId);
ebayProductStoreInventory.store();
- }else{
+ } else {
Debug.logError("Fail to update inventory product ".concat(productId).concat("in productStore ").concat(context.get("productStoreId").toString()).concat(" message from ebay : ").concat(resp.getMessage()), module);
}
}
@@ -215,24 +220,24 @@
boolean flag = false;
try {
- if(context.get("productStoreId") != null){
+ if (context.get("productStoreId") != null) {
GetSellingManagerInventoryFolderCall call = new GetSellingManagerInventoryFolderCall(EbayStoreHelper.getApiContext((String)context.get("productStoreId"), locale, delegator));
req = new GetSellingManagerInventoryFolderRequestType();
resp = (GetSellingManagerInventoryFolderResponseType) call.execute(req);
- if(resp != null && "SUCCESS".equals(resp.getAck().toString())){
+ if (resp != null && "SUCCESS".equals(resp.getAck().toString())) {
SellingManagerFolderDetailsType sellingManagerFolderDetailsType = resp.getFolder();
- if(sellingManagerFolderDetailsType!=null){
+ if (sellingManagerFolderDetailsType!=null) {
SellingManagerFolderDetailsType[] SellingManagerFolderDetailsTypeList = sellingManagerFolderDetailsType.getChildFolder();
- for(SellingManagerFolderDetailsType sellingManagerFolderDetails : SellingManagerFolderDetailsTypeList){
+ for (SellingManagerFolderDetailsType sellingManagerFolderDetails : SellingManagerFolderDetailsTypeList) {
Debug.logInfo("ebay inventory folders name ".concat(sellingManagerFolderDetails.getFolderName()), module);
- if(sellingManagerFolderDetails.getFolderName().equals(defaultFolderName)){
+ if (sellingManagerFolderDetails.getFolderName().equals(defaultFolderName)) {
folderId = String.valueOf(sellingManagerFolderDetails.getFolderID());
flag = true;
break;
}
}
}
- if(flag == false){
+ if (!flag) {
folderId = createNewFolderInEbayStoreInventory(dctx,context);
}
}
@@ -245,7 +250,7 @@
} catch (SdkException e) {
result = ServiceUtil.returnFailure(e.getMessage());
}
- if(result.get("responseMessage")!=null && result.get("responseMessage").equals("fail")) folderId = null;
+ if (result.get("responseMessage")!=null && result.get("responseMessage").equals("fail")) folderId = null;
result.put("folderId", folderId);
Debug.logInfo("service return result "+ result, module);
return result;
@@ -259,14 +264,14 @@
AddSellingManagerInventoryFolderResponseType resp = null;
try {
- if(context.get("productStoreId") != null){
+ if (context.get("productStoreId") != null) {
AddSellingManagerInventoryFolderCall call = new AddSellingManagerInventoryFolderCall(EbayStoreHelper.getApiContext((String)context.get("productStoreId"), locale, delegator));
req = new AddSellingManagerInventoryFolderRequestType();
req.setFolderName(defaultFolderName);//req.setComment(value);//req.setParentFolderID(value)
resp = (AddSellingManagerInventoryFolderResponseType) call.execute(req);
- if(resp != null && "SUCCESS".equals(resp.getAck().toString())) {
+ if (resp != null && "SUCCESS".equals(resp.getAck().toString())) {
folderId = String.valueOf(resp.getFolderID());
- }else {
+ } else {
Debug.logError("The problem with create new folder on ebay site.", module);
return folderId;
}
@@ -280,4 +285,84 @@
}
return folderId;
}
+ /* update inventory status from ebay store inventory */
+ public static Map<String,Object> updateEbayInventoryStatusByProductId(DispatchContext dctx, Map<String,Object> context){
+ Locale locale = (Locale) context.get("locale");
+ Map<String,Object> result = FastMap.newInstance();
+ Delegator delegator = dctx.getDelegator();
+ String productStoreId = (String)context.get("productStoreId");
+ String facilityId = (String)context.get("facilityId");
+ String folderId = (String)context.get("folderId");
+ String productId = (String)context.get("productId");
+ String ebayProductId = null;
+ GetSellingManagerInventoryRequestType req = null;
+ GetSellingManagerInventoryResponseType resp = null;
+ GenericValue ebayProductStoreInventory = null;
+
+ if (context.get("ebayProductId") != null) {
+ ebayProductId = String.valueOf(context.get("ebayProductId"));
+ }
+ try {
+ if (productStoreId != null && ebayProductId != null) {
+ ebayProductStoreInventory = delegator.findByPrimaryKey("EbayProductStoreInventory", UtilMisc.toMap("productId", productId,"facilityId",facilityId,"productStoreId",productStoreId));
+ GetSellingManagerInventoryCall call = new GetSellingManagerInventoryCall(EbayStoreHelper.getApiContext(productStoreId, locale, delegator));
+ req = new GetSellingManagerInventoryRequestType();
+ resp = (GetSellingManagerInventoryResponseType) call.execute(req);
+ if (resp != null && "SUCCESS".equals(resp.getAck().toString())) {
+ SellingManagerProductType[] sellingManagerProductTypeList = resp.getSellingManagerProduct();
+ for (SellingManagerProductType sellingManagerProductType : sellingManagerProductTypeList) {
+ SellingManagerProductDetailsType productDetail = sellingManagerProductType.getSellingManagerProductDetails();
+ if (String.valueOf(productDetail.getFolderID()).equals(folderId) && String.valueOf(productDetail.getProductID()).equals(ebayProductId) && String.valueOf(productDetail.getCustomLabel()).equals(productId)) {
+ SellingManagerProductInventoryStatusType prodInventoryStatus = sellingManagerProductType.getSellingManagerProductInventoryStatus();
+ ebayProductStoreInventory.put("activeListing",new BigDecimal(prodInventoryStatus.getQuantityActive()));
+ ebayProductStoreInventory.put("scheduled",new BigDecimal(prodInventoryStatus.getQuantityScheduled()));
+ ebayProductStoreInventory.put("sold",new BigDecimal(prodInventoryStatus.getQuantitySold()));
+ ebayProductStoreInventory.put("unSold",new BigDecimal(prodInventoryStatus.getQuantityUnsold()));
+ ebayProductStoreInventory.store();
+ result = ServiceUtil.returnSuccess("Updated inventory status of product ".concat(productId));
+ break;
+ }
+ }
+ } else {
+ Debug.logError("The problem with get manage inventory detail from ebay site.", module);
+ }
+ }
+ } catch (ApiException e) {
+ result = ServiceUtil.returnFailure(e.getMessage());
+ } catch (SdkSoapException e) {
+ result = ServiceUtil.returnFailure(e.getMessage());
+ } catch (SdkException e) {
+ result = ServiceUtil.returnFailure(e.getMessage());
+ } catch (GenericEntityException e) {
+ result = ServiceUtil.returnFailure(e.getMessage());
+ }
+ result.put("productStoreId", context.get("productStoreId"));
+ result.put("facilityId", context.get("facilityId"));
+ result.put("folderId", context.get("folderId"));
+ result.put("productId", productId);
+ return result;
+ }
+ public static Map<String,Object> updateEbayInventoryStatus(DispatchContext dctx, Map<String,Object> context){
+ LocalDispatcher dispatcher = dctx.getDispatcher();
+ Map<String,Object> result = FastMap.newInstance();
+ Delegator delegator = dctx.getDelegator();
+ List<GenericValue> ebayProductStoreInventoryList = null;
+
+ try {
+ if (context.get("productStoreId") != null && context.get("facilityId") != null) {
+ ebayProductStoreInventoryList = delegator.findByAnd("EbayProductStoreInventory", UtilMisc.toMap("facilityId",(String)context.get("facilityId"),"productStoreId",(String)context.get("productStoreId")));
+ for (GenericValue ebayProductStoreInventory : ebayProductStoreInventoryList) {
+ if (ebayProductStoreInventory.get("ebayProductId") != null) {
+ dispatcher.runSync("updateEbayInventoryStatusByProductId",UtilMisc.toMap("productStoreId",(String)context.get("productStoreId"),"facilityId",(String)context.get("facilityId"),"folderId",ebayProductStoreInventory.get("folderId"),"productId",ebayProductStoreInventory.get("productId"),"ebayProductId",ebayProductStoreInventory.get("ebayProductId"),"userLogin",context.get("userLogin")));
+ }
+ }
+ }
+ } catch (GenericEntityException e) {
+ result = ServiceUtil.returnFailure(e.getMessage());
+ } catch (GenericServiceException e) {
+ result = ServiceUtil.returnFailure(e.getMessage());
+ }
+ result = ServiceUtil.returnSuccess();
+ return result;
+ }
}
Modified: ofbiz/trunk/specialpurpose/ebaystore/webapp/ebaystore/WEB-INF/controller.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebaystore/webapp/ebaystore/WEB-INF/controller.xml?rev=906373&r1=906372&r2=906373&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebaystore/webapp/ebaystore/WEB-INF/controller.xml (original)
+++ ofbiz/trunk/specialpurpose/ebaystore/webapp/ebaystore/WEB-INF/controller.xml Thu Feb 4 06:01:06 2010
@@ -139,7 +139,7 @@
</request-map>
<request-map uri="reserveProductInventory">
<security https="true" auth="true"/>
- <event type="service" invoke="reserveEbayStoreInventory"/>
+ <event type="service" invoke="reserveEbayProductInventory"/>
<response name="success" type="view" value="reserveEbayProductInventory"/>
</request-map>
<request-map uri="updateEbayStoreInventory">
@@ -147,6 +147,25 @@
<event type="service-multi" invoke="updateEbayStoreInventory"/>
<response name="success" type="view" value="ebayLoadStoreInventory"/>
</request-map>
+ <request-map uri="updateEbayStoreInventory">
+ <security https="true" auth="true"/>
+ <event type="service-multi" invoke="updateEbayStoreInventory"/>
+ <response name="success" type="view" value="ebayLoadStoreInventory"/>
+ </request-map>
+ <request-map uri="updateEbayInventoryStatus">
+ <security https="true" auth="true"/>
+ <event type="service" invoke="updateEbayInventoryStatus"/>
+ <response name="success" type="view" value="ebayLoadStoreInventory"/>
+ </request-map>
+ <request-map uri="updateQuantityReserved">
+ <security https="true" auth="true"/>
+ <response name="success" type="view" value="updateQuantityReserved"/>
+ </request-map>
+ <request-map uri="updateProductQuantityReserved">
+ <security https="true" auth="true"/>
+ <event type="service" invoke="updateEbayProductQtyReserved"/>
+ <response name="success" type="view" value="ebayLoadStoreInventory"/>
+ </request-map>
<!-- end of request mappings -->
<!-- View Mappings -->
@@ -172,5 +191,6 @@
<view-map name="ebayStoreInventory" type="screen" page="component://ebaystore/widget/EbayStoreScreens.xml#ebayStoreInventory"/>
<view-map name="ebayLoadStoreInventory" type="screen" page="component://ebaystore/widget/EbayStoreScreens.xml#ebayLoadStoreInventory"/>
<view-map name="reserveEbayProductInventory" type="screen" page="component://ebaystore/widget/EbayStoreScreens.xml#reserveEbayProductInventory"/>
+ <view-map name="updateQuantityReserved" type="screen" page="component://ebaystore/widget/EbayStoreScreens.xml#updateQuantityReserved"/>
<!-- end of view mappings -->
</site-conf>