Author: ashish
Date: Wed Apr 14 10:14:28 2010
New Revision: 933906

URL: http://svn.apache.org/viewvc?rev=933906&view=rev
Log:
Applied patch from jira issue - OFBIZ-3697 - setLastInventoryCount Service 
should not be called hourly due to performance issues.
1) In case of large database, when there are so many products into the system, 
then setLastInventoryCount service consider all the products and update records 
for them.

2) So it will keep server busy for some time in every one hour. This logic 
should be improved.

3) Also setLastInventoryCount service does not take facilityId into the account 
while setting last inventory count in ProductFacility entity. 

Thanks Divesh & Pranay for the contribution. 

Modified:
    ofbiz/trunk/applications/product/data/ProductScheduledServices.xml
    ofbiz/trunk/applications/product/entitydef/eecas.xml
    
ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml
    ofbiz/trunk/applications/product/servicedef/services_facility.xml

Modified: ofbiz/trunk/applications/product/data/ProductScheduledServices.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/data/ProductScheduledServices.xml?rev=933906&r1=933905&r2=933906&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/data/ProductScheduledServices.xml 
(original)
+++ ofbiz/trunk/applications/product/data/ProductScheduledServices.xml Wed Apr 
14 10:14:28 2010
@@ -21,26 +21,6 @@ under the License.
 <entity-engine-xml>
     <JobSandbox jobId="8100" jobName="Purge Old Store Auto-Entered Promos" 
runTime="2000-01-01 00:00:00.000" serviceName="purgeOldStoreAutoPromos" 
poolId="pool" runAsUser="system" tempExprId="MIDNIGHT_DAILY" 
maxRecurrenceCount="-1"/>
 
-    <RecurrenceRule recurrenceRuleId="500" untilDateTime="" frequency="HOURLY" 
intervalNumber="1" countNumber="-1"/>
-    <RecurrenceInfo recurrenceInfoId="500" startDateTime="2008-05-14 
22:00:00.000" recurrenceRuleId="500" recurrenceCount="0"/>
-    <RuntimeData runtimeDataId="8801">
-        <runtimeInfo><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
-            <ofbiz-ser>
-                <map-HashMap>
-                    <map-Entry>
-                        <map-Key>
-                            <std-String value="recurrenceInfoId"/>
-                        </map-Key>
-                        <map-Value>
-                            <std-String value="500"/>
-                        </map-Value>
-                    </map-Entry>
-                </map-HashMap>
-            </ofbiz-ser>
-        ]]></runtimeInfo>
-    </RuntimeData>
-    <JobSandbox jobId="8801" jobName="Set Last Inventory Count on 
ProductFacility" runTime="2000-01-01 00:00:00.000" 
serviceName="setLastInventoryCount" runtimeDataId="8801" poolId="pool" 
runAsUser="system" recurrenceInfoId="500"/>
-
     <!--Data for scheduling the service productImportFromSpreadsheet -->
     <!--RecurrenceRule recurrenceRuleId="500" untilDateTime="" 
frequency="MINUTELY" intervalNumber="5" countNumber="-1"/>
     <RecurrenceInfo recurrenceInfoId="500" startDateTime="2006-06-06 
01:10:00.000" recurrenceRuleId="500" recurrenceCount="0"/>

Modified: ofbiz/trunk/applications/product/entitydef/eecas.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/entitydef/eecas.xml?rev=933906&r1=933905&r2=933906&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/entitydef/eecas.xml (original)
+++ ofbiz/trunk/applications/product/entitydef/eecas.xml Wed Apr 14 10:14:28 
2010
@@ -59,4 +59,8 @@ under the License.
     <eca entity="InventoryItemDetail" operation="create-store-remove" 
event="return">
         <action service="updateInventoryItemFromDetail" mode="sync"/>
     </eca>
+    <eca entity="InventoryItemDetail" operation="create-store-remove" 
event="return">
+        <condition field-name="availableToPromiseDiff" operator="not-equals" 
value="0" type="BigDecimal"/>
+        <action service="setLastInventoryCount" mode="sync"/>
+    </eca>
 </entity-eca>

Modified: 
ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml?rev=933906&r1=933905&r2=933906&view=diff
==============================================================================
--- 
ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml
 (original)
+++ 
ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml
 Wed Apr 14 10:14:28 2010
@@ -1310,21 +1310,28 @@ under the License.
         </else>
         </if-empty>
     </simple-method>
-    <simple-method method-name="setLastInventoryCount" 
short-description="Schedule service that updates stock availability of products 
hourly">
-        <entity-condition entity-name="ProductFacility" 
list="productFacilities" use-cache="true">
-            <use-iterator/>
-        </entity-condition>
-        <iterate list="productFacilities" entry="productFacility">
-            <set field="serviceInMap.productId" 
from-field="productFacility.productId"/>
-            <call-service service-name="getProductInventoryAvailable" 
in-map-name="serviceInMap">
-                <result-to-field result-name="availableToPromiseTotal"/>
-            </call-service>
-            <set field="productFacility.lastInventoryCount" 
from-field="availableToPromiseTotal"/>
-            <set-service-fields service-name="updateProductFacility" 
map="productFacility" to-map="productFacilityCtx"/>
-            <call-service service-name="updateProductFacility" 
in-map-name="productFacilityCtx"/>
-            <clear-field field="productFacility"/>
-            <clear-field field="productFacilityCtx"/>
-        </iterate>
+    <simple-method method-name="setLastInventoryCount" 
short-description="Service that updates stock availability of products">
+        <entity-one value-field="inventoryItem" entity-name="InventoryItem"  
auto-field-map="false">
+            <field-map field-name="inventoryItemId" 
from-field="parameters.inventoryItemId"/>
+        </entity-one>
+        <entity-and list="productFacilities" entity-name="ProductFacility">
+            <field-map field-name="productId" 
from-field="inventoryItem.productId" />
+        </entity-and>
+        <if-not-empty field="productFacilities">
+            <iterate list="productFacilities" entry="productFacility">
+                <set field="serviceInMap.productId" 
from-field="productFacility.productId"/>
+                <set field="serviceInMap.facilityId" 
from-field="productFacility.facilityId"/>
+                <call-service service-name="getInventoryAvailableByFacility" 
in-map-name="serviceInMap">
+                    <result-to-field result-name="availableToPromiseTotal"/>
+                </call-service>
+                <clear-field field="serviceInMap"/>
+                <set field="productFacility.lastInventoryCount" 
from-field="availableToPromiseTotal"/>
+                <set-service-fields service-name="updateProductFacility" 
map="productFacility" to-map="serviceInMap"/>
+                <call-service service-name="updateProductFacility" 
in-map-name="serviceInMap"/>
+                <clear-field field="productFacility"/>
+                <clear-field field="serviceInMap"/>
+            </iterate>
+        </if-not-empty>
     </simple-method>
     <simple-method method-name="createUpdateFacilityGeoPoint" 
short-description="Create or update GeoPoint assigned to facility">
         <if-empty field="parameters.geoPointId">

Modified: ofbiz/trunk/applications/product/servicedef/services_facility.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/servicedef/services_facility.xml?rev=933906&r1=933905&r2=933906&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/servicedef/services_facility.xml (original)
+++ ofbiz/trunk/applications/product/servicedef/services_facility.xml Wed Apr 
14 10:14:28 2010
@@ -927,8 +927,8 @@ under the License.
     </service>
     <service name="setLastInventoryCount" engine="simple"
                 
location="component://product/script/org/ofbiz/product/inventory/InventoryServices.xml"
 invoke="setLastInventoryCount">
-        <description>Schedule service that updates lastInventoryCount hourly 
for products available in facility</description>
-        <attribute name="recurrenceInfoId" mode="IN" type="String" 
optional="false"/>
+        <description>Service which run as EECA (on InventoryItemDetail entity) 
and updates lastInventoryCount for products available in facility in 
ProductFacility entity</description>
+        <attribute name="inventoryItemId" mode="IN" type="String" 
optional="false"/>
     </service>
     <service name="createUpdateFacilityGeoPoint" engine="simple" 
default-entity-name="GeoPoint"
                 
location="component://product/script/org/ofbiz/product/inventory/InventoryServices.xml"
 invoke="createUpdateFacilityGeoPoint">


Reply via email to