Author: mor
Date: Thu Jul 31 05:20:38 2008
New Revision: 681354
URL: http://svn.apache.org/viewvc?rev=681354&view=rev
Log:
Splitting the method createUpdateCustomerAndShippingAddress on One Page
Checkout customer events into separate smaller methods. This way these methods
can be re-used in other methods. Thanks to Sumit Pandit, Jyotsna Rathore and
Brajesh Patel for their efforts ...
Modified:
ofbiz/trunk/applications/ecommerce/script/org/ofbiz/ecommerce/customer/CustomerEvents.xml
ofbiz/trunk/applications/ecommerce/webapp/ecommerce/WEB-INF/controller.xml
Modified:
ofbiz/trunk/applications/ecommerce/script/org/ofbiz/ecommerce/customer/CustomerEvents.xml
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/ecommerce/script/org/ofbiz/ecommerce/customer/CustomerEvents.xml?rev=681354&r1=681353&r2=681354&view=diff
==============================================================================
---
ofbiz/trunk/applications/ecommerce/script/org/ofbiz/ecommerce/customer/CustomerEvents.xml
(original)
+++
ofbiz/trunk/applications/ecommerce/script/org/ofbiz/ecommerce/customer/CustomerEvents.xml
Thu Jul 31 05:20:38 2008
@@ -844,8 +844,9 @@
</if-not-empty>
</if-not-empty>
</simple-method>
-
- <simple-method method-name="createUpdateCustomerAndShippingContact"
+
+ <!-- One page checkout process -->
+ <simple-method method-name="createUpdateCustomerAndShippingAddress"
short-description="Create/Update Customer, Shipping Address and
other contact details. Set shipping method type" login-required="false">
<set field="shoppingCart" from-field="parameters.shoppingCart"/>
<set field="partyId" from-field="parameters.partyId"/>
@@ -854,7 +855,7 @@
<if-empty field="userLogin">
<session-to-field field-name="userLogin" session-name="userLogin"/>
- </if-empty>
+ </if-empty>
<if-empty field="shoppingCart">
<session-to-field field-name="shoppingCart"/>
</if-empty>
@@ -871,19 +872,37 @@
<if-empty field="shipToContactMechId">
<set field="shipToContactMechId"
from-field="parameters.shipToContactMechId"/>
</if-empty>
- <set field="parameters.shipToName" value="${parameters.firstName}
${parameters.lastName}"/>
+ <call-simple-method method-name="createUpdatePersonAndUserLogin"/>
+ <call-simple-method method-name="createUpdateShippingAddress"/>
+ <set field="parameters.phoneContactMechPurposeTypeId"
value="PRIMARY_PHONE"/>
+ <call-simple-method method-name="createUpdateTelecomNumber"/>
+ <set field="parameters.emailContactMechPurposeTypeId"
value="PRIMARY_EMAIL"/>
+ <call-simple-method method-name="createUpdateEmailAddress"/>
+
+ <!-- Set partyId, in shoppingCart -->
+ <call-object-method obj-field-name="shoppingCart"
method-name="setUserLogin">
+ <field field-name="userLogin"
type="org.ofbiz.entity.GenericValue"/>
+ <field field-name="dispatcher"
type="org.ofbiz.service.LocalDispatcher"/>
+ </call-object-method>
+ <call-object-method obj-field-name="shoppingCart"
method-name="addContactMech">
+ <string value="SHIPPING_LOCATION"/>
+ <field field-name="parameters.shipToContactMechId"/>
+ </call-object-method>
+ <call-object-method obj-field-name="shoppingCart"
method-name="setShippingContactMechId">
+ <field field-name="parameters.shipToContactMechId"/>
+ </call-object-method>
+ <log level="info" message="updated shopping cart shipToContactMechId
${parameters.shipToContactMechId}"/>
+ <call-object-method obj-field-name="shoppingCart"
method-name="setOrderPartyId">
+ <field field-name="partyId"/>
+ </call-object-method>
+ </simple-method>
+
+ <simple-method method-name="createUpdatePersonAndUserLogin"
short-description="create and update person and user login"
login-required="false">
+ <set field="parameters.shipToName" value="${parameters.firstName}
${parameters.lastName}"/>
<call-map-processor
xml-resource="org/ofbiz/ecommerce/customer/CheckoutMapProcs.xml"
processor-name="person" in-map-name="parameters"
out-map-name="personMap"/>
- <call-map-processor
xml-resource="org/ofbiz/ecommerce/customer/CheckoutMapProcs.xml"
- processor-name="phoneNumber" in-map-name="parameters"
out-map-name="phoneContext"/>
- <call-map-processor
xml-resource="org/ofbiz/ecommerce/customer/CheckoutMapProcs.xml"
- processor-name="emailAddress" in-map-name="parameters"
out-map-name="emailAddressContext"/>
- <call-map-processor
xml-resource="org/ofbiz/ecommerce/customer/CheckoutMapProcs.xml"
- processor-name="shipToAddress" in-map-name="parameters"
out-map-name="shipToAddressContext"/>
- <check-errors/>
- <!-- person and userLogin -->
<set-service-fields service-name="createPerson" map-name="personMap"
to-map-name="personContext"/>
<set field="personContext.userLogin" from-field="userLogin"/>
<if-empty field="partyId">
@@ -893,8 +912,9 @@
<!-- the rest of the methods require a userLogin object; so if we
are anonymous lets fake it -->
<if-empty field="userLogin">
- <set field="ulLookup.userLoginId" value="anonymous"/>
- <find-by-primary-key entity-name="UserLogin"
map-name="ulLookup" value-name="userLogin"/>
+ <entity-one entity-name="UserLogin" value-name="userLogin">
+ <field-map field-name="userLoginId" value="anonymous"/>
+ </entity-one>
<set field="userLogin.partyId" from-field="partyId"/>
<set-current-user-login value-name="userLogin"/>
<else>
@@ -922,35 +942,17 @@
<field-to-request field-name="partyId" request-name="partyId"/>
<field-to-request field-name="userLogin" request-name="userLogin"/>
<log level="info" message=" ${partyId}"/>
+ </simple-method>
- <!-- Create Or Update ship to address.-->
- <set field="shipToAddressContext.partyId" from-field="partyId"/>
- <set field="shipToAddressContext.roleTypeId"
from-field="parameters.roleTypeId"/>
- <set field="shipToAddressContext.userLogin" from-field="userLogin"/>
+ <simple-method method-name="createUpdateTelecomNumber"
short-description="Create and update phone number" login-required="false">
+ <call-map-processor
xml-resource="org/ofbiz/ecommerce/customer/CheckoutMapProcs.xml"
+ processor-name="phoneNumber" in-map-name="parameters"
out-map-name="phoneContext"/>
- <if-empty field="shipToContactMechId">
- <set field="shipToAddressContext.contactMechPurposeTypeId"
value="SHIPPING_LOCATION"/>
- <call-service service-name="createPartyPostalAddress"
in-map-name="shipToAddressContext">
- <result-to-field result-name="contactMechId"
map-name="shipToAddressPurposeContext"/>
- <result-to-field result-name="contactMechId"
field-name="parameters.shipToContactMechId"/>
- </call-service>
- <log level="info" message="Shipping Postal Address created
shipToContactMechId is ${parameters.shipToContactMechId}"></log>
- <else>
- <set field="shipToAddressContext.contactMechId"
from-field="shipToContactMechId"/>
- <call-service service-name="updatePartyPostalAddress"
in-map-name="shipToAddressContext">
- <result-to-field result-name="contactMechId"
field-name="parameters.shipToContactMechId"/>
- </call-service>
- <log level="info" message="Shipping Postal Address Updated
shipToContactMechId is ${parameters.shipToContactMechId}"></log>
- </else>
- </if-empty>
- <field-to-request field-name="parameters.shipToContactMechId"
request-name="shipToContactMechId"/>
-
- <!-- Create or Update phone -->
<set field="phoneContext.partyId" from-field="partyId"/>
<set field="phoneContext.roleTypeId"
from-field="parameters.roleTypeId"/>
<set field="phoneContext.userLogin" from-field="userLogin"/>
<if-empty field="parameters.phoneContactMechId">
- <set field="phoneContext.contactMechPurposeTypeId"
value="PHONE_WORK"/>
+ <set field="phoneContext.contactMechPurposeTypeId"
from-field="parameters.phoneContactMechPurposeTypeId"/>
<call-service service-name="createPartyTelecomNumber"
in-map-name="phoneContext">
<result-to-field result-name="contactMechId"
field-name="parameters.phoneContactMechId"/>
</call-service>
@@ -965,12 +967,17 @@
</else>
</if-empty>
<field-to-request field-name="parameters.phoneContactMechId"
request-name="phoneContactMechId"/>
-
+ </simple-method>
+
+ <simple-method method-name="createUpdateEmailAddress"
short-description="Create and update phone number" login-required="false">
+ <call-map-processor
xml-resource="org/ofbiz/ecommerce/customer/CheckoutMapProcs.xml"
+ processor-name="emailAddress" in-map-name="parameters"
out-map-name="emailAddressContext"/>
+
<!-- Create Or Update email address -->
<set field="emailAddressContext.partyId" from-field="partyId"/>
<set field="emailAddressContext.userLogin" from-field="userLogin"/>
<if-empty field="parameters.emailContactMechId">
- <set field="emailAddressContext.contactMechPurposeTypeId"
value="PRIMARY_EMAIL" />
+ <set field="emailAddressContext.contactMechPurposeTypeId"
from-field="parameters.emailContactMechPurposeTypeId"/>
<call-service service-name="createPartyEmailAddress"
in-map-name="emailAddressContext">
<result-to-field result-name="contactMechId"
field-name="parameters.emailContactMechId"/>
</call-service>
@@ -985,23 +992,47 @@
</else>
</if-empty>
<field-to-request field-name="parameters.emailContactMechId"
request-name="emailContactMechId"/>
-
- <!-- Set partyId, in shoppingCart -->
- <call-object-method obj-field-name="shoppingCart"
method-name="setUserLogin">
- <field field-name="userLogin"
type="org.ofbiz.entity.GenericValue"/>
- <field field-name="dispatcher"
type="org.ofbiz.service.LocalDispatcher"/>
- </call-object-method>
- <call-object-method obj-field-name="shoppingCart"
method-name="addContactMech">
- <string value="SHIPPING_LOCATION"/>
- <field field-name="parameters.shipToContactMechId"/>
- </call-object-method>
- <call-object-method obj-field-name="shoppingCart"
method-name="setShippingContactMechId">
- <field field-name="parameters.shipToContactMechId"/>
- </call-object-method>
- <log level="info" message="updated shopping cart shipToContactMechId
${parameters.shipToContactMechId}"/>
- <call-object-method obj-field-name="shoppingCart"
method-name="setOrderPartyId">
- <field field-name="partyId"/>
- </call-object-method>
+ </simple-method>
+
+ <simple-method method-name="createUpdateShippingAddress"
short-description="create and update shipping address" login-required="false">
+ <call-map-processor
xml-resource="org/ofbiz/ecommerce/customer/CheckoutMapProcs.xml"
+ processor-name="shipToAddress" in-map-name="parameters"
out-map-name="shipToAddressCtx"/>
+ <check-errors/>
+ <set field="shipToAddressCtx.partyId" from-field="partyId"/>
+ <if-empty field="parameters.shipToContactMechId">
+ <set field="shipToAddressCtx.contactMechPurposeTypeId"
value="SHIPPING_LOCATION"/>
+ <call-service service-name="createPartyPostalAddress"
in-map-name="shipToAddressCtx">
+ <result-to-field result-name="contactMechId"
field-name="parameters.shipToContactMechId"/>
+ </call-service>
+ <log level="info" message="Shipping address created with
contactMechId ${parameters.shipToContactMechId}"/>
+ <else>
+ <if-compare-field field="parameters.shipToContactMechId"
operator="equals" to-field="parameters.billTocontactMechId">
+ <entity-and entity-name="PartyContactMechPurpose"
list-name="pcmpList">
+ <field-map field-name="contactMechId"
env-name="parameters.shipToContactMechId"/>
+ <field-map field-name="partyId" env-name="partyId"/>
+ <field-map field-name="contactMechPurposeTypeId"
value="SHIPPING_LOCATION"/>
+ </entity-and>
+ <filter-list-by-date list-name="pcmpList"/>
+ <first-from-list list-name="pcmpList" entry-name="pcmp"/>
+ <if-not-empty field="pcmp">
+ <set-service-fields
service-name="deletePartyContactMechPurposeIfExists" map-name="pcmp"
to-map-name="deletePartyContactMechPurposeCtx"/>
+ <call-service
service-name="deletePartyContactMechPurposeIfExists"
in-map-name="deletePartyContactMechPurposeCtx"/>
+ </if-not-empty>
+ <set field="shipToAddressCtx.contactMechPurposeTypeId"
value="SHIPPING_LOCATION"/>
+ <call-service service-name="createPartyPostalAddress"
in-map-name="shipToAddressCtx">
+ <result-to-field result-name="contactMechId"
field-name="parameters.shipToContactMechId"/>
+ </call-service>
+ <log level="info" message="Shipping address updated with
contactMechId ${parameters.shipToContactMechId}"/>
+ <else>
+ <call-service service-name="updatePartyPostalAddress"
in-map-name="shipToAddressCtx">
+ <result-to-field result-name="contactMechId"
field-name="parameters.shipToContactMechId"/>
+ </call-service>
+ <log level="info" message="Shipping address updated with
contactMechId ${parameters.shipToContactMechId}"/>
+ </else>
+ </if-compare-field>
+ </else>
+ </if-empty>
+ <field-to-request field-name="parameters.shipToContactMechId"
request-name="shipToContactMechId"/>
</simple-method>
<simple-method method-name="getShipOptions" short-description="Get
shipping options" login-required="false">
@@ -1128,10 +1159,15 @@
<call-object-method obj-field-name="shoppingCart"
method-name="getPartyId" ret-field-name="partyId"/>
<call-object-method obj-field-name="shoppingCart"
method-name="getUserLogin" ret-field-name="userLogin"/>
<call-object-method obj-field-name="shoppingCart"
method-name="getShippingContactMechId" ret-field-name="shipToContactMechId"/>
+ <else>
+ <set field="partyId" from-field="parameters.partyId"/>
+ <session-to-field field-name="userLogin"/>
+ <if-empty field="userLogin">
+ <set field="userLogin" from-field="parameters.userLogin"/>
+ </if-empty>
+ <set field="shipToContactMechId"
from-field="parameters.shipToContactMechId"/>
+ </else>
</if-not-empty>
- <if-empty field="parameters.shipToContactMechId">
- <set field="parameters.shipToContactMechId"
from-field="shipToContactMechId"/>
- </if-empty>
<set-current-user-login value-name="userLogin"/>
<!--=================== Validate Bill and Payment settings
================-->
Modified:
ofbiz/trunk/applications/ecommerce/webapp/ecommerce/WEB-INF/controller.xml
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/ecommerce/webapp/ecommerce/WEB-INF/controller.xml?rev=681354&r1=681353&r2=681354&view=diff
==============================================================================
--- ofbiz/trunk/applications/ecommerce/webapp/ecommerce/WEB-INF/controller.xml
(original)
+++ ofbiz/trunk/applications/ecommerce/webapp/ecommerce/WEB-INF/controller.xml
Thu Jul 31 05:20:38 2008
@@ -1600,7 +1600,7 @@
<request-map uri="createUpdateShippingAddress">
<security https="true" auth="false"/>
- <event type="jsonsimple"
path="org/ofbiz/ecommerce/customer/CustomerEvents.xml"
invoke="createUpdateCustomerAndShippingContact"/>
+ <event type="jsonsimple"
path="org/ofbiz/ecommerce/customer/CustomerEvents.xml"
invoke="createUpdateCustomerAndShippingAddress"/>
<response name="success" type="none"/>
<response name="error" type="none"/>
</request-map>