You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ap...@apache.org on 2009/06/05 08:14:02 UTC

svn commit: r781921 - in /ofbiz/trunk/applications: marketing/script/org/ofbiz/sfa/lead/LeadServices.xml marketing/servicedef/services.xml party/script/org/ofbiz/party/party/PartySimpleMethods.xml

Author: apatel
Date: Fri Jun  5 06:14:01 2009
New Revision: 781921

URL: http://svn.apache.org/viewvc?rev=781921&view=rev
Log:
cleaned up createlead service.

Modified:
    ofbiz/trunk/applications/marketing/script/org/ofbiz/sfa/lead/LeadServices.xml
    ofbiz/trunk/applications/marketing/servicedef/services.xml
    ofbiz/trunk/applications/party/script/org/ofbiz/party/party/PartySimpleMethods.xml

Modified: ofbiz/trunk/applications/marketing/script/org/ofbiz/sfa/lead/LeadServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/marketing/script/org/ofbiz/sfa/lead/LeadServices.xml?rev=781921&r1=781920&r2=781921&view=diff
==============================================================================
--- ofbiz/trunk/applications/marketing/script/org/ofbiz/sfa/lead/LeadServices.xml (original)
+++ ofbiz/trunk/applications/marketing/script/org/ofbiz/sfa/lead/LeadServices.xml Fri Jun  5 06:14:01 2009
@@ -21,81 +21,87 @@
 <simple-methods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/simple-methods.xsd">
 
-    <simple-method method-name="createLead"  short-description="create Lead Person or Lead Group">
-        <set field="parameters.roleTypeId" value="LEAD"/>
-        <if-compare field="parameters.quickAdd" operator="not-equals" value="Y">
-            <call-simple-method method-name="createPersonRoleAndContactMechs" xml-resource="component://party/script/org/ofbiz/party/party/PartySimpleMethods.xml"/>
-        <else>
-            <call-map-processor processor-name="person" in-map-name="parameters" out-map-name="personCtx"
-                xml-resource="component://party/script/org/ofbiz/party/party/PartyMapProcs.xml"/>
-            <call-service service-name="createPerson" in-map-name="personCtx">
-                <result-to-field result-name="partyId" field="partyId"/>
-                <result-to-result result-name="partyId" service-result-name="partyId"/>
-            </call-service>
-            <if-not-empty field="parameters.roleTypeId">
-                <set field="createPartyRoleCtx.partyId" from-field="partyId"/>
-                <set field="createPartyRoleCtx.roleTypeId" from-field="parameters.roleTypeId"/>
-                <call-service service-name="createPartyRole" in-map-name="createPartyRoleCtx"/>
-            </if-not-empty>
-            <if-not-empty field="parameters.emailAddress">
-                <call-map-processor in-map-name="parameters" out-map-name="emailAddressCtx">
-                    <simple-map-processor name="emailAddress">
-                        <process field="emailAddress">
-                            <copy/><validate-method method="isEmail"><fail-property resource="PartyUiLabels" property="PartyEmailAddressNotFormattedCorrectly"/></validate-method>
-                        </process>
-                    </simple-map-processor>
-                </call-map-processor>
+    <simple-method method-name="createLead"  short-description="">
+        <!-- Check if Person or PartyGroup name is supplied -->
+        <if>
+            <condition>
+                <and>
+                    <or>
+                        <if-empty field="parameters.firstName"/>
+                        <if-empty field="parameters.lastName"/>
+                    </or>
+                    <if-empty field="parameters.groupName"/>
+                </and>
+            </condition>
+            <then>
+                <add-error><fail-message message="Please enter person first name or last name or Company name"/></add-error>
+            </then>
+        </if>
+        <check-errors/>
+        <set field="createPartyRoleCtx.partyId" from-field="userLogin.partyId"/>
+        <set field="createPartyRoleCtx.roleTypeId" value="OWNER"/>
+        <call-service service-name="createPartyRole" in-map-name="createPartyRoleCtx"/>
+        <if>
+            <condition>
+                <and>
+                    <not><if-empty field="parameters.firstName"/></not>
+                    <not><if-empty field="parameters.lastName"/></not>
+                </and>
+            </condition>
+            <then>
+                <set field="parameters.roleTypeId" value="LEAD"/>
+                <call-simple-method method-name="createPersonRoleAndContactMechs" xml-resource="component://party/script/org/ofbiz/party/party/PartySimpleMethods.xml"/>
                 <check-errors/>
-                <set field="emailAddressCtx.partyId" from-field="partyId"/>
-                <set field="emailAddressCtx.contactMechPurposeTypeId" value="PRIMARY_EMAIL"/>
-                <call-service service-name="createPartyEmailAddress" in-map-name="emailAddressCtx">
-                    <result-to-field result-name="contactMechId" field="emailContactMechId"/>
-                    <result-to-result result-name="contactMechId" service-result-name="contactMechId"/>
-                </call-service>
+                <set field="partyRelationshipCtx.partyIdFrom" from-field="userLogin.partyId"/>
+                <set field="partyRelationshipCtx.partyIdTo" from-field="partyId"/>
+                <set field="partyRelationshipCtx.roleTypeIdFrom" value="OWNER"/>
+                <set field="partyRelationshipCtx.roleTypeIdTo" value="LEAD"/>
+                <set field="partyRelationshipCtx.partyRelationshipTypeId" value="LEAD_OWNER"/>
+                <call-service service-name="createPartyRelationship" in-map-name="partyRelationshipCtx"/>
+                <check-errors/>
+        
+                <set field="updatePartyStatusCtx.partyId" from-field="partyId"/>
+                <set field="updatePartyStatusCtx.statusId" value="LEAD_ASSIGNED"/>
+                <call-service service-name="setPartyStatus" in-map-name="updatePartyStatusCtx"/>
+            </then>
+        </if>
+        <!-- Now create PartyGroup corresponding to the companyName, if its not null and then set up relationship of Person and PartyGroup as Employee and title -->
+        <if-not-empty field="parameters.groupName">
+            <set field="parameters.partyTypeId" value="PARTY_GROUP"/>
+            <set field="parameters.roleTypeId" value="ACCOUNT_LEAD"/>
+            <if-empty field="partyId">
+                <!-- In case we have any contact mech data then associate with party group  -->
+                <call-simple-method method-name="createPartyGroupRoleAndContactMechs" xml-resource="component://party/script/org/ofbiz/party/party/PartySimpleMethods.xml"/>
+                <set field="partyGroupPartyId" from-field="partyId"/>
+                <clear-field field="partyId"/>
+                <else>
+                    <call-map-processor processor-name="partyGroup" in-map-name="parameters" out-map-name="partyGroupCtx"
+                        xml-resource="component://party/script/org/ofbiz/party/party/PartyMapProcs.xml"/>
+                    <call-service service-name="createPartyGroup" in-map-name="partyGroupCtx">
+                        <result-to-field result-name="partyId" field="partyGroupPartyId"/>
+                    </call-service>
+                    <set field="createPartyRoleCtx.partyId" from-field="partyGroupPartyId"/>
+                    <set field="createPartyRoleCtx.roleTypeId" value="ACCOUNT_LEAD"/>
+                    <call-service service-name="createPartyRole" in-map-name="createPartyRoleCtx"/>
+                    <check-errors/>
+                </else>
+            </if-empty>
+            
+            <if-not-empty field="partyId">
+                <set field="partyRelationshipCtx.partyIdFrom" from-field="partyGroupPartyId"/>
+                <set field="partyRelationshipCtx.partyIdTo" from-field="partyId"/>
+                <set field="partyRelationshipCtx.roleTypeIdFrom" value="ACCOUNT_LEAD"/>
+                <set field="partyRelationshipCtx.roleTypeIdTo" value="LEAD"/>
+                <set field="partyRelationshipCtx.positionTitle" from-field="parameters.title"/>
+                <set field="partyRelationshipCtx.partyRelationshipTypeId" value="EMPLOYMENT"/>
+                <call-service service-name="createPartyRelationship" in-map-name="partyRelationshipCtx"/>
             </if-not-empty>
-        </else>
-        </if-compare>
-
-        <if-not-empty field="userLogin.partyId">
-
-            <set field="createPartyRoleCtx.partyId" from-field="userLogin.partyId"/>
-            <set field="createPartyRoleCtx.roleTypeId" value="OWNER"/>
-            <call-service service-name="createPartyRole" in-map-name="createPartyRoleCtx"/>
-
             <set field="partyRelationshipCtx.partyIdFrom" from-field="userLogin.partyId"/>
-            <set field="partyRelationshipCtx.partyIdTo" from-field="partyId"/>
+            <set field="partyRelationshipCtx.partyIdTo" from-field="partyGroupPartyId"/>
             <set field="partyRelationshipCtx.roleTypeIdFrom" value="OWNER"/>
-            <set field="partyRelationshipCtx.roleTypeIdTo" value="LEAD"/>
+            <set field="partyRelationshipCtx.roleTypeIdTo" value="ACCOUNT_LEAD"/>
             <set field="partyRelationshipCtx.partyRelationshipTypeId" value="LEAD_OWNER"/>
             <call-service service-name="createPartyRelationship" in-map-name="partyRelationshipCtx"/>
-
-            <set field="updatePartyCtx.partyId" from-field="partyId"/>
-            <set field="updatePartyCtx.statusId" value="LEAD_ASSIGNED"/>
-            <call-service service-name="setPartyStatus" in-map-name="updatePartyCtx"/>
-        </if-not-empty>
-        <!-- Now create PartyGroup corresponding to the companyName, if its not null and then set up relationship of Person and PartyGroup as Employee and title -->
-        <if-not-empty field="parameters.groupName">
-            <set field="parameters.partyTypeId" value="PARTY_GROUP"/>
-            <call-map-processor processor-name="partyGroup" in-map-name="parameters" out-map-name="partyGroupCtx"
-                xml-resource="component://party/script/org/ofbiz/party/party/PartyMapProcs.xml"/>
-            <call-service service-name="createPartyGroup" in-map-name="partyGroupCtx">
-                <result-to-field result-name="partyId" field="partyGroupPartyId"/>
-            </call-service>
-            <set field="createPartyRoleCtx.partyId" from-field="partyGroupPartyId"/>
-            <set field="createPartyRoleCtx.roleTypeId" value="ACCOUNT_LEAD"/>
-            <call-service service-name="createPartyRole" in-map-name="createPartyRoleCtx"/>
-
-            <set field="createPartyRoleCtx.partyId" from-field="partyId"/>
-            <set field="createPartyRoleCtx.roleTypeId" value="LEAD"/>
-            <call-service service-name="createPartyRole" in-map-name="createPartyRoleCtx"/>
-
-            <set field="partyRelationshipCtx.partyIdFrom" from-field="partyGroupPartyId"/>
-            <set field="partyRelationshipCtx.partyIdTo" from-field="partyId"/>
-            <set field="partyRelationshipCtx.roleTypeIdFrom" value="ACCOUNT_LEAD"/>
-            <set field="partyRelationshipCtx.roleTypeIdTo" value="LEAD"/>
-            <set field="partyRelationshipCtx.positionTitle" from-field="parameters.title"/>
-            <set field="partyRelationshipCtx.partyRelationshipTypeId" value="EMPLOYMENT"/>
-            <call-service service-name="createPartyRelationship" in-map-name="partyRelationshipCtx"/>
         </if-not-empty>
 
         <if-not-empty field="parameters.dataSourceId">
@@ -104,6 +110,7 @@
             <call-service service-name="createPartyDataSource" in-map-name="partyDataSourceCtx"/>
         </if-not-empty>
         <field-to-result field="partyId"/>
+        <field-to-result field="partyGroupPartyId"/>
         <field-to-result field="parameters.roleTypeId" result-name="roleTypeId"/>
     </simple-method>
 

Modified: ofbiz/trunk/applications/marketing/servicedef/services.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/marketing/servicedef/services.xml?rev=781921&r1=781920&r2=781921&view=diff
==============================================================================
--- ofbiz/trunk/applications/marketing/servicedef/services.xml (original)
+++ ofbiz/trunk/applications/marketing/servicedef/services.xml Fri Jun  5 06:14:01 2009
@@ -390,7 +390,10 @@
 
     <!-- lead services -->
     <service name="createLead" engine="simple" location="component://marketing/script/org/ofbiz/sfa/lead/LeadServices.xml" invoke="createLead">
-        <description>Create a Lead Person or Group</description>
+        <description>
+            Sales Lead can be just a person or a person representing a company or a company (party group).
+            createLead works 1) If person information is passed. 2) If company (party group) information is passed. 3) If Person and company (party group) information is passed. 
+        </description>
         <auto-attributes entity-name="Person" mode="IN" optional="true">
             <exclude field-name="partyId"/>
         </auto-attributes>
@@ -400,8 +403,6 @@
         <auto-attributes entity-name="TelecomNumber" mode="IN" optional="true">
             <exclude field-name="contactMechId"/>
         </auto-attributes>
-        <attribute name="partyId" type="String" mode="OUT"/>
-        <attribute name="contactMechId" type="String" mode="OUT" optional="true"/>
         <attribute name="emailAddress" type="String" mode="IN" optional="true"/>
         <attribute name="groupName" type="String" mode="IN" optional="true"/>
         <attribute name="title" type="String" mode="IN" optional="true"/>
@@ -409,10 +410,13 @@
         <attribute name="officeSiteName" type="String" mode="IN" optional="true"/>
         <attribute name="partyIdFrom" type="String" mode="IN" optional="true"/>
         <attribute name="dataSourceId" type="String" mode="IN" optional="true"/>
-        <attribute name="roleTypeId" type="String" mode="OUT"/>
-        <attribute name="quickAdd" type="String" mode="IN" optional="true"/>
         <attribute name="extension" type="String" mode="IN" optional="true"/>
         <attribute name="contactListId" type="String" mode="IN" optional="true"/>
+
+        <attribute name="partyId" type="String" mode="OUT" optional="true"/>
+        <attribute name="partyGroupPartyId" type="String" mode="OUT" optional="true"/>
+        <attribute name="roleTypeId" type="String" mode="OUT" optional="true"/>
+        <attribute name="contactMechId" type="String" mode="OUT" optional="true"/>
     </service>
     <service name="createContact" engine="simple"
         location="component://marketing/script/org/ofbiz/sfa/contact/ContactServices.xml" invoke="createContact">

Modified: ofbiz/trunk/applications/party/script/org/ofbiz/party/party/PartySimpleMethods.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/script/org/ofbiz/party/party/PartySimpleMethods.xml?rev=781921&r1=781920&r2=781921&view=diff
==============================================================================
--- ofbiz/trunk/applications/party/script/org/ofbiz/party/party/PartySimpleMethods.xml (original)
+++ ofbiz/trunk/applications/party/script/org/ofbiz/party/party/PartySimpleMethods.xml Fri Jun  5 06:14:01 2009
@@ -97,8 +97,10 @@
         <call-map-processor processor-name="person" in-map-name="parameters" out-map-name="personContext"
             xml-resource="component://party/script/org/ofbiz/party/party/PartyMapProcs.xml"/>
 
-        <call-map-processor processor-name="postalAddress" in-map-name="parameters" out-map-name="postalAddressContext"
-            xml-resource="component://party/script/org/ofbiz/party/contact/PartyContactMechMapProcs.xml"/>
+        <if-not-empty field="parameters.address1">
+            <call-map-processor processor-name="postalAddress" in-map-name="parameters" out-map-name="postalAddressContext"
+                xml-resource="component://party/script/org/ofbiz/party/contact/PartyContactMechMapProcs.xml"/>
+        </if-not-empty>
 
         <if-not-empty field="parameters.contactNumber">
             <call-map-processor processor-name="telecomNumber" in-map-name="parameters" out-map-name="telecomNumberContext"
@@ -164,13 +166,13 @@
         <call-service service-name="createPartyGroup" in-map-name="partyGroupContext">
             <result-to-field result-name="partyId" field="partyId"/>
         </call-service>
-
+        <check-errors/>
         <if-not-empty field="parameters.roleTypeId">
             <set field="createPartyRoleCtx.partyId" from-field="partyId"/>
             <set field="createPartyRoleCtx.roleTypeId" from-field="parameters.roleTypeId"/>
             <call-service service-name="createPartyRole" in-map-name="createPartyRoleCtx"/>
         </if-not-empty>
-
+        <check-errors/>
         <set field="postalAddContactMechPurpTypeId" from-field="parameters.postalAddContactMechPurpTypeId"/>
         <set field="contactNumber" from-field="parameters.contactNumber"/>
         <set field="phoneContactMechPurpTypeId" from-field="parameters.phoneContactMechPurpTypeId"/>
@@ -183,11 +185,13 @@
          createPersonRoleAndContactMechs and createPartyGroupRoleAndContactMechs simple methods -->
     <simple-method method-name="createPartyContactMechs" short-description="Create Contact Mechs">
         <!-- postal address -->
-        <set field="postalAddressContext.partyId" from-field="partyId"/>
-        <set field="postalAddressContext.contactMechPurposeTypeId" value="GENERAL_LOCATION"/>
-        <call-service service-name="createPartyPostalAddress" in-map-name="postalAddressContext">
-            <result-to-field result-name="contactMechId" field="postalAddressContext.contactMechId"/>
-        </call-service>
+        <if-not-empty field="postalAddressContext">
+            <set field="postalAddressContext.partyId" from-field="partyId"/>
+            <set field="postalAddressContext.contactMechPurposeTypeId" value="GENERAL_LOCATION"/>
+            <call-service service-name="createPartyPostalAddress" in-map-name="postalAddressContext">
+                <result-to-field result-name="contactMechId" field="postalAddressContext.contactMechId"/>
+            </call-service>
+        </if-not-empty>
 
         <if-not-empty field="postalAddContactMechPurpTypeId">
             <set-service-fields service-name="createPartyContactMechPurpose" map="postalAddressContext" to-map="serviceCtx"/>
@@ -196,7 +200,7 @@
         </if-not-empty>
 
         <!-- phone number -->
-        <if-not-empty field="contactNumber">
+        <if-not-empty field="telecomNumberContext">
             <set field="telecomNumberContext.partyId" from-field="partyId"/>
             <set field="telecomNumberContext.contactMechPurposeTypeId" value="PRIMARY_PHONE"/>
             <if-not-empty field="phoneContactMechPurpTypeId"> <!-- override with purpose present in parameters, if any (This field is not used now, just here for future implementations) -->
@@ -206,7 +210,7 @@
         </if-not-empty>
 
         <!-- email address -->
-        <if-not-empty field="emailAddress">
+        <if-not-empty field="emailAddressContext">
             <set field="emailAddressContext.partyId" from-field="partyId"/>
             <set field="emailAddressContext.contactMechPurposeTypeId" value="PRIMARY_EMAIL"/>
             <if-not-empty field="emailContactMechPurpTypeId"> <!-- override with purpose present in parameters, if any (This field is not used now, just here for future implementations) -->