You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by mo...@apache.org on 2008/08/01 08:24:32 UTC

svn commit: r681605 - /ofbiz/trunk/applications/ecommerce/script/org/ofbiz/ecommerce/customer/CustomerEvents.xml

Author: mor
Date: Thu Jul 31 23:24:31 2008
New Revision: 681605

URL: http://svn.apache.org/viewvc?rev=681605&view=rev
Log:
Spliting the method createUpdatePersonAndUserLogin into even more smaller separate methods. Patch from Sumit Pandit and Rishi Solanki

Modified:
    ofbiz/trunk/applications/ecommerce/script/org/ofbiz/ecommerce/customer/CustomerEvents.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=681605&r1=681604&r2=681605&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 23:24:31 2008
@@ -847,7 +847,7 @@
 
     <!-- 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">
+            short-description="Create/Update Customer, Shipping Address and other contact details." login-required="false">
         <set field="shoppingCart" from-field="parameters.shoppingCart"/>
         <set field="partyId" from-field="parameters.partyId"/>
         <set field="userLogin" from-field="parameters.userLogin"/>
@@ -873,7 +873,14 @@
            <set field="shipToContactMechId" from-field="parameters.shipToContactMechId"/>
         </if-empty>
 
-        <call-simple-method method-name="createUpdatePersonAndUserLogin"/>
+        <call-simple-method method-name="createUpdatePerson"/>
+        <call-simple-method method-name="setAnonUserLogin"/>
+        
+        <set field="partyRoleContext.partyId" from-field="partyId"/>
+        <set field="partyRoleContext.roleTypeId" from-field="parameters.roleTypeId"/>
+        <set field="partyRoleContext.userLogin" from-field="userLogin"/>
+        <call-service service-name="createPartyRole" in-map-name="partyRoleContext"/>
+
         <call-simple-method method-name="createUpdateShippingAddress"/>
         <set field="parameters.phoneContactMechPurposeTypeId" value="PRIMARY_PHONE"/>
         <call-simple-method method-name="createUpdateTelecomNumber"/>
@@ -897,41 +904,16 @@
             <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}"/>
+    
+    <simple-method method-name="createUpdatePerson" short-description="Create and update a person" login-required="false">
         <call-map-processor xml-resource="org/ofbiz/ecommerce/customer/CheckoutMapProcs.xml"
                 processor-name="person" in-map-name="parameters" out-map-name="personMap"/>
-
+        <check-errors/>
         <set-service-fields service-name="createPerson"  map-name="personMap" to-map-name="personContext"/>
-        <set field="personContext.userLogin" from-field="userLogin"/>
         <if-empty field="partyId">
             <call-service service-name="createPerson" in-map-name="personContext">
                 <result-to-field result-name="partyId" field-name="partyId"/>
             </call-service>
-
-            <!-- the rest of the methods require a userLogin object; so if we are anonymous lets fake it -->
-            <if-empty field="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>
-                <!-- If an anonymous vistor is coming back, update the party id in the userLogin object -->
-                <if-compare field="userLogin.userLoginId" value="anonymous" operator="equals">
-                    <set field="userLogin.partyId" from-field="partyId"/>
-                </if-compare>
-            </else>
-            </if-empty>
-            <log level="info" message="userLogin is ${userLogin}"/>
-
-            <!-- Party role -->
-            <set field="parameters.roleTypeId" value="CUSTOMER"/>
-            <set field="partyRoleContext.partyId" from-field="partyId"/>
-            <set field="partyRoleContext.roleTypeId" from-field="parameters.roleTypeId"/>
-            <set field="partyRoleContext.userLogin" from-field="userLogin"/>
-            <call-service service-name="createPartyRole" in-map-name="partyRoleContext"/>
         <else><!-- If partyId already exists. -->
             <set field="personContext.partyId" from-field="partyId"/>
             <call-service service-name="updatePerson" in-map-name="personContext"/>
@@ -940,8 +922,50 @@
         </if-empty>
 
         <field-to-request field-name="partyId" request-name="partyId"/>
+        <set field="parameters.partyId" from-field="partyId"/>
+    </simple-method>
+    
+    <simple-method method-name="createUpdateUserLogin" short-description="Create and update a user login">
+        <if-empty field="userLogin">
+            <call-map-processor xml-resource="org/ofbiz/securityext/login/LoginMapProcs.xml"
+                processor-name="userLogin" in-map-name="parameters" out-map-name="userLoginMap"/>
+            <check-errors/>
+            <set-service-fields service-name="createUserLogin"  map-name="userLoginMap" to-map-name="userLoginCtx"/>
+            <call-service service-name="createUserLogin" in-map-name="userLoginCtx"/>
+        <else>
+            <call-map-processor xml-resource="org/ofbiz/securityext/login/LoginMapProcs.xml"
+                processor-name="updatePassword" in-map-name="parameters" out-map-name="passwordMap"/>
+            <check-errors/>
+            <set-service-fields service-name="updatePassword"  map-name="passwordMap" to-map-name="passwordCtx"/>
+            <call-service service-name="updatePassword" in-map-name="passwordCtx">
+                <result-to-field result-name="updatedUserLogin"/>
+            </call-service>
+            <set-current-user-login value-name="updatedUserLogin"/>
+            <session-to-field field-name="userLogin"/>
+            <if-compare field="userLogin.userLoginId" operator="equals" value="${updatedUserLogin.userLoginId}">
+                <field-to-session field-name="updatedUserLogin" session-name="userLogin"/>
+            </if-compare>
+            <session-to-field field-name="userLogin"/>
+        </else>
+        </if-empty>
+    </simple-method>
+    
+    <simple-method method-name="setAnonUserLogin" short-description="Set user login in the session" login-required="false">
+        <if-empty field="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>
+            <!-- If an anonymous vistor is coming back, update the party id in the userLogin object -->
+            <if-compare field="userLogin.userLoginId" operator="equals" value="anonymous">
+                <set field="userLogin.partyId" from-field="partyId"/>
+            </if-compare>
+        </else>
+        </if-empty>
         <field-to-request field-name="userLogin" request-name="userLogin"/>
-        <log level="info" message=" ${partyId}"/>
+        <log level="info" message="userLogin is ${userLogin}"/>
     </simple-method>
 
     <simple-method method-name="createUpdateTelecomNumber" short-description="Create and update phone number" login-required="false">
@@ -1295,4 +1319,5 @@
             ]]>
         </call-bsh>
     </simple-method>
+
 </simple-methods>