svn commit: r432136 - in /incubator/ofbiz/trunk/applications: order/script/org/ofbiz/order/shoppinglist/ order/servicedef/ product/entitydef/ product/webapp/catalog/store/

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r432136 - in /incubator/ofbiz/trunk/applications: order/script/org/ofbiz/order/shoppinglist/ order/servicedef/ product/entitydef/ product/webapp/catalog/store/

jonesde
Author: jonesde
Date: Wed Aug 16 21:02:58 2006
New Revision: 432136

URL: http://svn.apache.org/viewvc?rev=432136&view=rev
Log:
Applied patch from Tim Ruppert to implement the auto-suggestion shopping list; also added indicator to ProductStore to turn it on and off (off by default); Apache Jira #OFBIZ-159

Modified:
    incubator/ofbiz/trunk/applications/order/script/org/ofbiz/order/shoppinglist/ShoppingListServices.xml
    incubator/ofbiz/trunk/applications/order/servicedef/secas.xml
    incubator/ofbiz/trunk/applications/order/servicedef/services_shoppinglist.xml
    incubator/ofbiz/trunk/applications/product/entitydef/entitymodel.xml
    incubator/ofbiz/trunk/applications/product/webapp/catalog/store/ProductStoreForms.xml

Modified: incubator/ofbiz/trunk/applications/order/script/org/ofbiz/order/shoppinglist/ShoppingListServices.xml
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/order/script/org/ofbiz/order/shoppinglist/ShoppingListServices.xml?rev=432136&r1=432135&r2=432136&view=diff
==============================================================================
--- incubator/ofbiz/trunk/applications/order/script/org/ofbiz/order/shoppinglist/ShoppingListServices.xml (original)
+++ incubator/ofbiz/trunk/applications/order/script/org/ofbiz/order/shoppinglist/ShoppingListServices.xml Wed Aug 16 21:02:58 2006
@@ -173,6 +173,26 @@
         </if-compare-field>
     </simple-method>
 
+    <simple-method method-name="addDistinctShoppingListItem"
+                   short-description="Adds a shopping list item if one with the same productId does not exist">
+        <log level="info" message="In addDistinctShoppingListItem" />
+        <entity-condition entity-name="ShoppingListItem" list-name="shoppingListItemList">
+            <condition-expr field-name="shoppingListId" env-name="parameters.shoppingListId" />
+        </entity-condition>
+
+        <iterate list-name="shoppingListItemList" entry-name="shoppingListItem">
+            <if-compare-field field-name="parameters.productId" operator="equals" to-field-name="shoppingListItem.productId">
+                <log level="info" message="In shopingListItem ${shoppingListItem.productId}" />
+                <field-to-result field-name="shoppingListItem.shoppingListItemSeqId" result-name="shoppingListItemSeqId" />
+                <return />
+            </if-compare-field>
+        </iterate>
+        <log level="info" message="Right before createShoppingListItem" />
+        <call-service service-name="createShoppingListItem" in-map-name="parameters">
+            <result-to-result result-name="shoppingListItemSeqId" />
+        </call-service>
+    </simple-method>    
+
     <simple-method method-name="calculateShoppingListDeepTotalPrice" short-description="Calculate Deep Total Price for a ShoppingList">
         <set field="parentMethodName" value="calculateShoppingListDeepTotalPrice"/>
         <set field="permissionAction" value="VIEW"/>
@@ -259,5 +279,98 @@
                 <add-error><fail-property resource="OrderErrorUiLabels" property="OrderSecurityErrorToRunForAnotherParty"/></add-error>
             </then>
         </if>
+    </simple-method>
+    <simple-method method-name="addSuggestionsToShoppingList" short-description="Add suggestions to a shopping list">
+        <!-- first check the ProductStore.enableAutoSuggestionList indicator -->
+        <entity-one entity-name="OrderHeader" value-name="orderHeader"/>
+        <if-empty field-name="orderHeader.productStoreId"><return/></if-empty>
+        
+        <entity-one entity-name="ProductStore" value-name="productStore" auto-field-map="false">
+            <field-map field-name="productStoreId" env-name="orderHeader.productStoreId"/>
+        </entity-one>
+        <if-compare field-name="productStore.enableAutoSuggestionList" operator="not-equals" value="Y"><return/></if-compare>
+        
+        <entity-condition entity-name="OrderRole" list-name="orderRoleList">
+            <condition-list combine="and">
+                <condition-expr field-name="orderId" env-name="parameters.orderId" />
+                <condition-expr field-name="roleTypeId" value="PLACING_CUSTOMER" />
+            </condition-list>
+        </entity-condition>
+        <first-from-list list-name="orderRoleList" entry-name="orderRole" />
+        <log level="info" message="After orderRoleList" />
+
+        <entity-condition entity-name="ShoppingList" list-name="shoppingListList">
+            <condition-list combine="and">
+                <condition-expr field-name="partyId" env-name="orderRole.partyId" />
+                <condition-expr field-name="listName" value="Auto Suggestions" />
+            </condition-list>
+        </entity-condition>
+        <first-from-list list-name="shoppingListList" entry-name="shoppingList" />
+        <if-empty field-name="shoppingList">
+            <set field="createShoppingListInMap.partyId" from-field="orderRole.partyId" />
+            <set field="createShoppingListInMap.listName" value="Auto Suggestions" />
+            <set field="createShoppingListInMap.shoppingListTypeId" value="SLT_WISH_LIST" />
+            <call-service service-name="createShoppingList" in-map-name="createShoppingListInMap">
+                <result-to-field result-name="shoppingListId" />
+            </call-service>
+        <else>
+            <set field="shoppingListId" from-field="shoppingList.shoppingListId" />
+        </else>            
+        </if-empty>
+
+        <log level="info" message="Before iterating orderItemList" />
+        <entity-condition entity-name="OrderItem" list-name="orderItemList">
+            <condition-expr field-name="orderId" env-name="parameters.orderId" />
+            <order-by field-name="orderItemSeqId" />
+        </entity-condition>
+        <iterate list-name="orderItemList" entry-name="orderItem">
+            <if-not-empty field-name="orderItem.productId">
+                <log level="info" message="Found orderItem.productId [${orderItem.productId}]" />
+                <entity-condition entity-name="ProductAssoc" list-name="compProductAssocList" filter-by-date="true">
+                    <condition-list combine="and">
+                        <condition-expr field-name="productId" env-name="orderItem.productId" />
+                        <condition-expr field-name="productAssocTypeId" value="PRODUCT_COMPLEMENT" />
+                    </condition-list>
+                </entity-condition>
+                <log level="info" message="productAssocList = ${compProductAssocList}" />
+                <iterate list-name="compProductAssocList" entry-name="compProductAssoc">
+                    <log level="info" message="looping on assoc list" />
+                    <clear-field field-name="shoppingListParameters" />
+                    <set field="shoppingListParameters.productId" from-field="compProductAssoc.productIdTo" />
+                    <set field="shoppingListParameters.shoppingListId" from-field="shoppingListId" />
+                    <set field="shoppingListParameters.quantity" value="1" type="Double" />
+                    <call-service service-name="addDistinctShoppingListItem" in-map-name="shoppingListParameters" />
+                </iterate>
+                <entity-one entity-name="Product" value-name="product" auto-field-map="false" >
+                    <field-map field-name="productId" env-name="orderItem.productId" />
+                </entity-one>
+                <if-compare field-name="product.isVariant" operator="equals" value="Y">
+                    <entity-condition entity-name="ProductAssoc" list-name="virtualProductAssocList" filter-by-date="true">
+                        <condition-list combine="and">
+                            <condition-expr field-name="productIdTo" env-name="orderItem.productId" />
+                            <condition-expr field-name="productAssocTypeId" value="PRODUCT_VARIANT" />
+                        </condition-list>
+                    </entity-condition>
+                    <first-from-list list-name="virtualProductAssocList" entry-name="virtualProductAssoc" />
+                    <if-not-empty field-name="virtualProductAssoc">
+                        <entity-condition entity-name="ProductAssoc" list-name="compProductAssocList" filter-by-date="true">
+                            <condition-list combine="and">
+                                <condition-expr field-name="productId" env-name="virtualProductAssoc.productId" />
+                                <condition-expr field-name="productAssocTypeId" value="PRODUCT_COMPLEMENT" />
+                            </condition-list>
+                        </entity-condition>
+                        <log level="info" message="productAssocList = ${compProductAssocList}" />
+                        <iterate list-name="compProductAssocList" entry-name="compProductAssoc">
+                            <log level="info" message="looping on assoc list #2" />
+                            <clear-field field-name="shoppingListParameters" />
+                            <set field="shoppingListParameters.productId" from-field="compProductAssoc.productIdTo" />
+                            <set field="shoppingListParameters.shoppingListId" from-field="shoppingListId" />
+                            <set field="shoppingListParameters.quantity" value="1" type="Double" />
+                            <call-service service-name="addDistinctShoppingListItem" in-map-name="shoppingListParameters" />
+                        </iterate>
+                    </if-not-empty>
+                </if-compare>
+            </if-not-empty>
+        </iterate>
     </simple-method>
 </simple-methods>

Modified: incubator/ofbiz/trunk/applications/order/servicedef/secas.xml
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/order/servicedef/secas.xml?rev=432136&r1=432135&r2=432136&view=diff
==============================================================================
--- incubator/ofbiz/trunk/applications/order/servicedef/secas.xml (original)
+++ incubator/ofbiz/trunk/applications/order/servicedef/secas.xml Wed Aug 16 21:02:58 2006
@@ -21,6 +21,7 @@
     <!-- order item status changes -->
     <eca service="storeOrder" event="return">
         <action service="resetGrandTotal" mode="sync"/>
+        <action service="addSuggestionsToShoppingList" mode="async" persist="true"/>
     </eca>
     <eca service="changeOrderItemStatus" event="commit">
         <condition field-name="statusId" operator="equals" value="ITEM_CANCELLED"/>

Modified: incubator/ofbiz/trunk/applications/order/servicedef/services_shoppinglist.xml
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/order/servicedef/services_shoppinglist.xml?rev=432136&r1=432135&r2=432136&view=diff
==============================================================================
--- incubator/ofbiz/trunk/applications/order/servicedef/services_shoppinglist.xml (original)
+++ incubator/ofbiz/trunk/applications/order/servicedef/services_shoppinglist.xml Wed Aug 16 21:02:58 2006
@@ -122,5 +122,18 @@
         <attribute name="shoppingListId" type="String" mode="IN" optional="false"/>
         <attribute name="shoppingListItemSeqId" type="String" mode="IN" optional="false"/>
     </service>
+    <service name="addSuggestionsToShoppingList" engine="simple" auth="true"
+            location="org/ofbiz/order/shoppinglist/ShoppingListServices.xml" invoke="addSuggestionsToShoppingList">
+        <description>Add suggestions to a shopping list</description>
+        <attribute name="orderId" type="String" mode="IN" optional="false"/>
+    </service>
+    <service name="addDistinctShoppingListItem" engine="simple" auth="true"
+            location="org/ofbiz/order/shoppinglist/ShoppingListServices.xml" invoke="addDistinctShoppingListItem">
+        <description>Adds a shopping list item if one with the same productId does not exist</description>
+        <implements service="shoppingListItemInterface"/>
+        <attribute name="shoppingListId" type="String" mode="IN" optional="false"/>
+        <attribute name="productStoreId" type="String" mode="INOUT" optional="true"/>
+        <attribute name="productId" type="String" mode="IN" optional="false"/>
+        <attribute name="shoppingListItemSeqId" type="String" mode="OUT" optional="false"/>
+    </service>
 </services>
-

Modified: incubator/ofbiz/trunk/applications/product/entitydef/entitymodel.xml
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/product/entitydef/entitymodel.xml?rev=432136&r1=432135&r2=432136&view=diff
==============================================================================
--- incubator/ofbiz/trunk/applications/product/entitydef/entitymodel.xml (original)
+++ incubator/ofbiz/trunk/applications/product/entitydef/entitymodel.xml Wed Aug 16 21:02:58 2006
@@ -3065,6 +3065,7 @@
       <field name="showTaxIsExempt" type="indicator"><description>default Y; if set to N do not show isExempt checkbox for PartyTaxAuthInfo, always force to N</description></field>
       <field name="vatTaxAuthGeoId" type="id"></field>
       <field name="vatTaxAuthPartyId" type="id"></field>
+      <field name="enableAutoSuggestionList" type="indicator"><description>The auto-suggestion list is a special ShoppingList that the addSuggestionsToShoppingList service will maintain for cross-sells of ordered items.</description></field>
       <field name="enableDigProdUpload" type="indicator"></field>
       <field name="digProdUploadCategoryId" type="id"></field>
       <field name="autoOrderCcTryExp" type="indicator"><description>For auto-orders try other Credit Card expiration dates (if date is wrong or general failure where type not known)?</description></field>

Modified: incubator/ofbiz/trunk/applications/product/webapp/catalog/store/ProductStoreForms.xml
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/product/webapp/catalog/store/ProductStoreForms.xml?rev=432136&r1=432135&r2=432136&view=diff
==============================================================================
--- incubator/ofbiz/trunk/applications/product/webapp/catalog/store/ProductStoreForms.xml (original)
+++ incubator/ofbiz/trunk/applications/product/webapp/catalog/store/ProductStoreForms.xml Wed Aug 16 21:02:58 2006
@@ -203,6 +203,9 @@
             <drop-down allow-empty="false" no-current-selected-key="N"><option key="Y" description="${uiLabelMap.CommonY}"/><option key="N" description="${uiLabelMap.CommonN}"/></drop-down>
         </field>
         <field name="digProdUploadCategoryId"><lookup target-form-name="LookupProductCategory"/></field>
+        <field name="enableAutoSuggestionList" widget-style="selectBox">
+            <drop-down allow-empty="false" no-current-selected-key="N"><option key="Y" description="${uiLabelMap.CommonY}"/><option key="N" description="${uiLabelMap.CommonN}"/></drop-down>
+        </field>
         
         <field name="submitButton" title="${uiLabelMap.CommonUpdate}" widget-style="smallSubmit"><submit button-type="button"/></field>
     </form>