svn commit: r1650007 - in /ofbiz/branches/release14.12/applications: marketing/widget/sfa/ marketing/widget/sfa/forms/ party/script/org/ofbiz/party/party/ party/script/org/ofbiz/party/test/ party/servicedef/

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

svn commit: r1650007 - in /ofbiz/branches/release14.12/applications: marketing/widget/sfa/ marketing/widget/sfa/forms/ party/script/org/ofbiz/party/party/ party/script/org/ofbiz/party/test/ party/servicedef/

nmalin
Author: nmalin
Date: Wed Jan  7 08:19:07 2015
New Revision: 1650007

URL: http://svn.apache.org/r1650007
Log:
backport from trunk :
 * update the service createPartyRelationshipAndRole with two new service ensurePartyRoleFrom and ensurePartyRoleTo to have coherence between each service in this group (related to JIRA OFBIZ-5905) and correct call service from sfa's form.
 * clean sfa's from to convert bsh to groovy call and clean unnecessary value declaration
 * complete unit test to controle new service ensurePartyRoleFrom and ensurePartyRoleTo

Modified:
    ofbiz/branches/release14.12/applications/marketing/widget/sfa/ContactScreens.xml
    ofbiz/branches/release14.12/applications/marketing/widget/sfa/forms/AccountForms.xml
    ofbiz/branches/release14.12/applications/marketing/widget/sfa/forms/ContactForms.xml
    ofbiz/branches/release14.12/applications/marketing/widget/sfa/forms/LeadForms.xml
    ofbiz/branches/release14.12/applications/party/script/org/ofbiz/party/party/PartySimpleMethods.xml
    ofbiz/branches/release14.12/applications/party/script/org/ofbiz/party/test/PartyTests.xml
    ofbiz/branches/release14.12/applications/party/servicedef/services.xml

Modified: ofbiz/branches/release14.12/applications/marketing/widget/sfa/ContactScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/branches/release14.12/applications/marketing/widget/sfa/ContactScreens.xml?rev=1650007&r1=1650006&r2=1650007&view=diff
==============================================================================
--- ofbiz/branches/release14.12/applications/marketing/widget/sfa/ContactScreens.xml (original)
+++ ofbiz/branches/release14.12/applications/marketing/widget/sfa/ContactScreens.xml Wed Jan  7 08:19:07 2015
@@ -34,7 +34,7 @@ under the License.
                 <decorator-screen name="main-decorator" location="${parameters.mainDecoratorLocation}">
                     <decorator-section name="left-column">
                         <include-screen name="leftbar" location="component://marketing/widget/sfa/CommonScreens.xml"/>
-                    </decorator-section>                    
+                    </decorator-section>
                     <decorator-section name="body">
                         <section>
                             <widgets>

Modified: ofbiz/branches/release14.12/applications/marketing/widget/sfa/forms/AccountForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/branches/release14.12/applications/marketing/widget/sfa/forms/AccountForms.xml?rev=1650007&r1=1650006&r2=1650007&view=diff
==============================================================================
--- ofbiz/branches/release14.12/applications/marketing/widget/sfa/forms/AccountForms.xml (original)
+++ ofbiz/branches/release14.12/applications/marketing/widget/sfa/forms/AccountForms.xml Wed Jan  7 08:19:07 2015
@@ -49,8 +49,7 @@ under the License.
         <field name="postalCode" title="${uiLabelMap.CommonZipPostalCode}" tooltip="${uiLabelMap.CommonRequired}" widget-style="required">
             <text size="10" maxlength="30"/>
         </field>
-       <field name="stateProvinceGeoId" title="${uiLabelMap.CommonState}" widget-style="required"><drop-down allow-empty="false"/></field>      
-
+        <field name="stateProvinceGeoId" title="${uiLabelMap.CommonState}" widget-style="required"><drop-down allow-empty="false"/></field>
         <field name="countryGeoId" title="${uiLabelMap.CommonCountry}" tooltip="${uiLabelMap.CommonRequired}" widget-style="required">
             <drop-down no-current-selected-key="${defaultCountryGeoId}">
                 <entity-options entity-name="Geo" key-field-name="geoId" description="${geoName} - ${geoId}">
@@ -59,8 +58,6 @@ under the License.
                 </entity-options>
             </drop-down>
         </field>
-
-
         <field name="phoneTitle" title="${uiLabelMap.PartyPrimaryPhone}" title-area-style="group-label"><display/></field>
         <field name="countryCode" title="${uiLabelMap.CommonCountryCode}"><text size="4" maxlength="10"/></field>
         <field name="areaCode" title="${uiLabelMap.PartyAreaCode}"><text size="4" maxlength="10"/></field>
@@ -70,7 +67,7 @@ under the License.
         <field name="emailAddress" title="${uiLabelMap.CommonEmail}"><text size="50" maxlength="60"/></field>
         <field name="submitButton" title="${uiLabelMap.CommonSave}" widget-style="smallSubmit"><submit button-type="button"/></field>
     </form>
-    
+
     <form name="FindAccounts" id="FindAccounts" target="${currentUrl}" title="" type="single" default-map-name="parameters"
         header-row-style="header-row" default-table-style="basic-table">
         <field name="all"><hidden/></field>
@@ -99,21 +96,16 @@ under the License.
             <set field="parameters.statusId_op" value="notEqual"/>
             <set field="partyRelationshipTypeId" value="ACCOUNT"/>
             <set field="parameters.roleTypeId" from-field="roleTypeIdTo"/>
-            <set field="fieldList" value="${groovy:[&quot;partyId&quot;,&quot;roleTypeId&quot;]}" type="List"/>
-            <service service-name="performFind" result-map="result" result-map-list="listIt">
+            <set field="fieldList" value="${groovy:['partyId','roleTypeId']}" type="List"/>
+            <service service-name="performFind">
                 <field-map field-name="inputFields" from-field="parameters"/>
                 <field-map field-name="entityName" value="PartyRoleAndContactMechDetail"/>
                 <field-map field-name="orderBy" value="partyId"/>
                 <field-map field-name="distinct" value="Y"/>
-                <field-map field-name="fieldList" from-field="fieldList"/>
-                <field-map field-name="viewIndex" from-field="viewIndex"/>
-                <field-map field-name="viewSize" from-field="viewSize"/>
             </service>
         </actions>
         <row-actions>
-            <entity-one entity-name="Party" value-field="party">
-                <field-map field-name="partyId"/>
-            </entity-one>
+            <entity-one entity-name="Party" value-field="party" use-cache="true"/>
             <set field="partyName" value="${groovy:org.ofbiz.party.party.PartyHelper.getPartyName(party, true)}"/>
             <entity-and entity-name="PartyAndContactMech" list="emailAddresses" filter-by-date="true">
                 <field-map field-name="partyId"/>
@@ -150,7 +142,7 @@ under the License.
                 <parameter param-name="partyId"/>
             </hyperlink>
         </field>
-        <field name="emailAddress" title="${uiLabelMap.FormFieldTitle_emailAddress}"><display description="${emailAddresses[0].infoString}"/></field>
+        <field name="emailAddress"><display description="${emailAddresses[0].infoString}"/></field>
         <field name="telecomNumber" title="${uiLabelMap.PartyPhoneNumber}">
             <display description="${telecomNumber.tnCountryCode} ${telecomNumber.tnAreaCode} ${telecomNumber.tnContactNumber} ${telecomNumber.tnAskForName}"/>
         </field>
@@ -169,8 +161,7 @@ under the License.
         <field name="assignToMe" use-when="existRelationship==null&amp;&amp;!&quot;false&quot;.equals(parameters.get(&quot;all&quot;))"
                 title="${uiLabelMap.SfaAssignToMe}" widget-style="buttontext">
             <hyperlink target="createPartyRelationshipAndRole" description="${uiLabelMap.SfaAssignToMe}">
-                <parameter param-name="partyId" from-field="userLogin.partyId"/>
-                <parameter param-name="roleTypeId" from-field="roleTypeIdFrom"/>
+                <parameter param-name="partyIdFrom" from-field="userLogin.partyId"/>
                 <parameter param-name="roleTypeIdFrom"/>
                 <parameter param-name="roleTypeIdTo"/>
                 <parameter param-name="partyRelationshipTypeId"/>
@@ -196,15 +187,12 @@ under the License.
             <set field="parameters.partyStatusId" value="PARTY_DISABLED"/>
             <set field="parameters.partyStatusId_op" value="notEqual"/>
             <set field="parameters.partyRelationshipTypeId" value="ACCOUNT"/>
-            <set field="fieldList" value="${groovy:[&quot;partyIdFrom&quot;,&quot;partyId&quot;]}" type="List"/>
-            <service service-name="performFind" result-map="result" result-map-list="listIt">
+            <set field="fieldList" value="${groovy:['partyIdFrom','partyId']}" type="List"/>
+            <service service-name="performFind">
                 <field-map field-name="inputFields" from-field="parameters"/>
                 <field-map field-name="entityName" value="PartyRelationshipAndContactMechDetail"/>
                 <field-map field-name="orderBy" value="partyId"/>
                 <field-map field-name="distinct" value="Y"/>
-                <field-map field-name="fieldList" from-field="fieldList"/>
-                <field-map field-name="viewIndex" from-field="viewIndex"/>
-                <field-map field-name="viewSize" from-field="viewSize"/>
             </service>
         </actions>
         <field name="assignToMe"><hidden/></field>
@@ -242,7 +230,7 @@ under the License.
         </actions>
         <field name="infoString" title="${contactMechType.description}"><text-find/></field>
     </form>
-    
+
     <form name="listAccountLeads" extends="listAccounts">
         <actions>
             <set field="roleTypeIdTo" value="ACCOUNT_LEAD"/>
@@ -250,15 +238,12 @@ under the License.
             <set field="parameters.statusId_op" value="notEqual"/>
             <set field="partyRelationshipTypeId" value="ACCOUNT"/>
             <set field="parameters.roleTypeId" from-field="roleTypeIdTo"/>
-            <set field="fieldList" value="${groovy:[&quot;partyId&quot;,&quot;roleTypeId&quot;]}" type="List"/>
-            <service service-name="performFind" result-map="result" result-map-list="listIt">
+            <set field="fieldList" value="${groovy:['partyId','roleTypeId']}" type="List"/>
+            <service service-name="performFind">
                 <field-map field-name="inputFields" from-field="parameters"/>
                 <field-map field-name="entityName" value="PartyRoleAndContactMechDetail"/>
                 <field-map field-name="orderBy" value="partyId"/>
                 <field-map field-name="distinct" value="Y"/>
-                <field-map field-name="fieldList" from-field="fieldList"/>
-                <field-map field-name="viewIndex" from-field="viewIndex"/>
-                <field-map field-name="viewSize" from-field="viewSize"/>
             </service>
         </actions>
     </form>

Modified: ofbiz/branches/release14.12/applications/marketing/widget/sfa/forms/ContactForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/branches/release14.12/applications/marketing/widget/sfa/forms/ContactForms.xml?rev=1650007&r1=1650006&r2=1650007&view=diff
==============================================================================
--- ofbiz/branches/release14.12/applications/marketing/widget/sfa/forms/ContactForms.xml (original)
+++ ofbiz/branches/release14.12/applications/marketing/widget/sfa/forms/ContactForms.xml Wed Jan  7 08:19:07 2015
@@ -49,15 +49,12 @@ under the License.
             <set field="parameters.roleTypeId" from-field="roleTypeIdTo"/>
             <set field="parameters.statusId" value="PARTY_DISABLED"/>
             <set field="parameters.statusId_op" value="notEqual"/>
-            <set field="fieldList" value="${groovy:[&quot;partyId&quot;,&quot;roleTypeId&quot;]}" type="List"/>
-            <service service-name="performFind" result-map="result" result-map-list="listIt">
+            <set field="fieldList" value="${groovy:['partyId','roleTypeId']}" type="List"/>
+            <service service-name="performFind">
                 <field-map field-name="inputFields" from-field="parameters"/>
                 <field-map field-name="entityName" value="PartyRoleAndContactMechDetail"/>
                 <field-map field-name="orderBy" value="partyId"/>
                 <field-map field-name="distinct" value="Y"/>
-                <field-map field-name="fieldList" from-field="fieldList"/>
-                <field-map field-name="viewIndex" from-field="viewIndex"/>
-                <field-map field-name="viewSize" from-field="viewSize"/>
             </service>
         </actions>
         <field name="export" title="${uiLabelMap.SfaVCard}">
@@ -68,8 +65,7 @@ under the License.
         <field name="assignToMe" use-when="existRelationship==null&amp;&amp;!&quot;false&quot;.equals(parameters.get(&quot;all&quot;))"
                 title="${uiLabelMap.SfaAssignToMe}" widget-style="buttontext">
             <hyperlink target="createPartyRelationshipAndRole" description="${uiLabelMap.SfaAssignToMe}">
-                <parameter param-name="partyId" from-field="userLogin.partyId"/>
-                <parameter param-name="roleTypeId" from-field="roleTypeIdFrom"/>
+                <parameter param-name="partyIdFrom" from-field="userLogin.partyId"/>
                 <parameter param-name="roleTypeIdFrom"/>
                 <parameter param-name="roleTypeIdTo"/>
                 <parameter param-name="partyRelationshipTypeId"/>
@@ -97,15 +93,12 @@ under the License.
             <set field="parameters.partyStatusId" value="PARTY_DISABLED"/>
             <set field="parameters.partyStatusId_op" value="notEqual"/>
             <set field="parameters.partyRelationshipTypeId" value="EMPLOYMENT"/>
-            <set field="fieldList" value="${groovy:[&quot;partyIdFrom&quot;,&quot;partyId&quot;]}" type="List"/>
-            <service service-name="performFind" result-map="result" result-map-list="listIt">
+            <set field="fieldList" value="${groovy:['partyIdFrom','partyId']}" type="List"/>
+            <service service-name="performFind">
                 <field-map field-name="inputFields" from-field="parameters"/>
                 <field-map field-name="entityName" value="PartyRelationshipAndContactMechDetail"/>
                 <field-map field-name="orderBy" value="partyId"/>
                 <field-map field-name="distinct" value="Y"/>
-                <field-map field-name="fieldList" from-field="fieldList"/>
-                <field-map field-name="viewIndex" from-field="viewIndex"/>
-                <field-map field-name="viewSize" from-field="viewSize"/>
             </service>
         </actions>
         <field name="assignToMe"><hidden/></field>
@@ -159,12 +152,12 @@ under the License.
         </actions>
         <field name="partyIdTo" title="${uiLabelMap.AccountingToParty}" position="1">
             <drop-down allow-empty="false">
-               <list-options list-name="partyList" key-name="contact.partyId"  list-entry-name="contact" description="${bsh:org.ofbiz.party.party.PartyHelper.getPartyName(delegator, &quot;partyId&quot;, false)} ${contact.partyId}"/>
+               <list-options list-name="partyList" key-name="contact.partyId"  list-entry-name="contact" description="${groovy:org.ofbiz.party.party.PartyHelper.getPartyName(delegator, 'partyId', false)} ${contact.partyId}"/>
             </drop-down>
         </field>
         <field name="partyIdFrom" title="${uiLabelMap.AccountingFromParty}" position="2">
             <drop-down allow-empty="false">
-                <list-options list-name="partyList" key-name="contact.partyId"  list-entry-name="contact" description="${bsh:org.ofbiz.party.party.PartyHelper.getPartyName(delegator, &quot;partyId&quot;, false)} ${contact.partyId}"/>
+                <list-options list-name="partyList" key-name="contact.partyId"  list-entry-name="contact" description="${groovy:org.ofbiz.party.party.PartyHelper.getPartyName(delegator, 'partyId', false)} ${contact.partyId}"/>
             </drop-down>
         </field>
         <field name="submitButton" position="3" title="${uiLabelMap.SfaMergeContacts}" widget-style="buttontext" tooltip-style="button-text"><submit button-type="text-link"/></field>

Modified: ofbiz/branches/release14.12/applications/marketing/widget/sfa/forms/LeadForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/branches/release14.12/applications/marketing/widget/sfa/forms/LeadForms.xml?rev=1650007&r1=1650006&r2=1650007&view=diff
==============================================================================
--- ofbiz/branches/release14.12/applications/marketing/widget/sfa/forms/LeadForms.xml (original)
+++ ofbiz/branches/release14.12/applications/marketing/widget/sfa/forms/LeadForms.xml Wed Jan  7 08:19:07 2015
@@ -85,7 +85,7 @@ under the License.
         </field>
         <field name="partyGroupId" title="${uiLabelMap.SfaAccountName}" tooltip="${uiLabelMap.SfaSelectExistingAccountOrLeaveBlankToCreateNew}" use-when="parameters.get(&quot;partyGroupId&quot;)==&quot;&quot;">
             <drop-down allow-empty="true" current-description="">
-              <entity-options entity-name="PartyRole" description="${bsh:org.ofbiz.party.party.PartyHelper.getPartyName(delegator, &quot;${partyId}&quot;, false)} : [${partyId}]" key-field-name="partyId">
+              <entity-options entity-name="PartyRole" description="${groovy:org.ofbiz.party.party.PartyHelper.getPartyName(delegator, &quot;${partyId}&quot;, false)} : [${partyId}]" key-field-name="partyId">
                   <entity-constraint name="roleTypeId" operator="equals" value="ACCOUNT"/>
               </entity-options>
             </drop-down>
@@ -93,7 +93,7 @@ under the License.
         <field name="submitButton"><submit button-type="button"/></field>
     </form>
 
-    <form name="MergeLeads" type="single"  target="MergeLeads">
+    <form name="MergeLeads" type="single" target="MergeLeads">
         <actions>
             <set field="roleTypeId" value="LEAD"/>
             <set field="partyTypeId" value="PERSON"/>
@@ -102,12 +102,12 @@ under the License.
         </actions>
         <field name="partyIdTo" title="${uiLabelMap.AccountingToParty}" position="1">
             <drop-down allow-empty="false">
-               <list-options list-name="partyList" key-name="lead.partyId"  list-entry-name="lead" description="${bsh:org.ofbiz.party.party.PartyHelper.getPartyName(delegator, &quot;partyId&quot;, false)} ${lead.partyId}"/>
+               <list-options list-name="partyList" key-name="lead.partyId"  list-entry-name="lead" description="${groovy:org.ofbiz.party.party.PartyHelper.getPartyName(delegator, 'partyId', false)} ${lead.partyId}"/>
             </drop-down>
         </field>
         <field name="partyIdFrom" title="${uiLabelMap.AccountingFromParty}" position="2">
             <drop-down allow-empty="false">
-               <list-options list-name="partyList" key-name="lead.partyId"  list-entry-name="lead" description="${bsh:org.ofbiz.party.party.PartyHelper.getPartyName(delegator, &quot;partyId&quot;, false)} ${lead.partyId}"/>
+               <list-options list-name="partyList" key-name="lead.partyId"  list-entry-name="lead" description="${groovy:org.ofbiz.party.party.PartyHelper.getPartyName(delegator, 'partyId', false)} ${lead.partyId}"/>
             </drop-down>
         </field>
         <field name="submitButton" position="3" title="${uiLabelMap.SfaMergeLeads}" widget-style="buttontext" tooltip-style="button-text"><submit button-type="text-link"/></field>
@@ -152,9 +152,8 @@ under the License.
             <display-entity entity-name="DataSource"/>
         </field>
         <field name="fromDate"><display/></field>
-        
     </form>
-    
+
     <form name="FindLeads" target="${currentUrl}" extends="FindAccounts" extends-resource="component://marketing/widget/sfa/forms/AccountForms.xml">
         <field name="firstName" title="${uiLabelMap.PartyFirstName}"><text-find/></field>
         <field name="lastName" title="${uiLabelMap.PartyLastName}"><text-find/></field>
@@ -171,6 +170,7 @@ under the License.
             <sort-field name="submitButton"/>
         </sort-order>
     </form>
+
     <form name="listLeads" paginate-target="${currentUrl}"
             extends="listAccounts" extends-resource="component://marketing/widget/sfa/forms/AccountForms.xml">
         <actions>
@@ -183,24 +183,21 @@ under the License.
             <set field="parameters.statusId_op" value="notEqual"/>
             <set field="partyRelationshipTypeId" value="LEAD_OWNER"/>
             <set field="parameters.roleTypeId" from-field="roleTypeIdTo"/>
-            <set field="fieldList" value="${groovy:[&quot;partyId&quot;,&quot;roleTypeId&quot;]}" type="List"/>
-            <service service-name="performFind" result-map="result" result-map-list="listIt">
+            <set field="fieldList" value="${groovy:['partyId','roleTypeId']}" type="List"/>
+            <service service-name="performFind">
                 <field-map field-name="inputFields" from-field="parameters"/>
                 <field-map field-name="entityName" value="PartyRoleAndContactMechDetail"/>
                 <field-map field-name="orderBy" value="partyId"/>
                 <field-map field-name="distinct" value="Y"/>
-                <field-map field-name="fieldList" from-field="fieldList"/>
-                <field-map field-name="viewIndex" from-field="viewIndex"/>
-                <field-map field-name="viewSize" from-field="viewSize"/>
             </service>
         </actions>
     </form>
+
     <form name="ListLeads" extends="listLeads">
         <field name="assignToMe" use-when="existRelationship==null&amp;&amp;!&quot;false&quot;.equals(parameters.get(&quot;all&quot;))"
                 title="${uiLabelMap.SfaAssignToMe}" widget-style="buttontext">
             <hyperlink target="createPartyRelationshipAndRole" description="${uiLabelMap.SfaAssignToMe}">
-                <parameter param-name="partyId" from-field="userLogin.partyId"/>
-                <parameter param-name="roleTypeId" from-field="roleTypeIdFrom"/>
+                <parameter param-name="partyIdFrom" from-field="userLogin.partyId"/>
                 <parameter param-name="roleTypeIdFrom"/>
                 <parameter param-name="roleTypeIdTo"/>
                 <parameter param-name="partyRelationshipTypeId"/>
@@ -227,15 +224,12 @@ under the License.
             <set field="parameters.partyStatusId" value="PARTY_DISABLED"/>
             <set field="parameters.partyStatusId_op" value="notEqual"/>
             <set field="parameters.partyRelationshipTypeId" value="LEAD_OWNER"/>
-            <set field="fieldList" value="${groovy:[&quot;partyIdFrom&quot;,&quot;partyId&quot;]}" type="List"/>
-            <service service-name="performFind" result-map="result" result-map-list="listIt">
+            <set field="fieldList" value="${groovy:['partyIdFrom','partyId']}" type="List"/>
+            <service service-name="performFind">
                 <field-map field-name="inputFields" from-field="parameters"/>
                 <field-map field-name="entityName" value="PartyRelationshipAndContactMechDetail"/>
                 <field-map field-name="orderBy" value="partyId"/>
                 <field-map field-name="distinct" value="Y"/>
-                <field-map field-name="fieldList" from-field="fieldList"/>
-                <field-map field-name="viewIndex" from-field="viewIndex"/>
-                <field-map field-name="viewSize" from-field="viewSize"/>
             </service>
         </actions>
         <field name="assignToMe"><hidden/></field>

Modified: ofbiz/branches/release14.12/applications/party/script/org/ofbiz/party/party/PartySimpleMethods.xml
URL: http://svn.apache.org/viewvc/ofbiz/branches/release14.12/applications/party/script/org/ofbiz/party/party/PartySimpleMethods.xml?rev=1650007&r1=1650006&r2=1650007&view=diff
==============================================================================
--- ofbiz/branches/release14.12/applications/party/script/org/ofbiz/party/party/PartySimpleMethods.xml (original)
+++ ofbiz/branches/release14.12/applications/party/script/org/ofbiz/party/party/PartySimpleMethods.xml Wed Jan  7 08:19:07 2015
@@ -59,20 +59,30 @@ under the License.
             </else>
         </if-not-empty>
 
-        <if-empty field="parameters.roleTypeId">
-            <set field="lookupPKMap.roleTypeId" value="_NA_"/>
-        <else>
-            <set from-field="parameters.roleTypeId" field="lookupPKMap.roleTypeId"/>
-        </else>
-        </if-empty>
+        <!-- resolve the roleTypeId on this order roleTypeIdFrom, roleTypeIdTo, roleTypeId and if not find use _NA_-->
+        <if-not-empty field="parameters.roleTypeIdFrom">
+            <set field="lookupPKMap.roleTypeId" from-field="parameters.roleTypeIdFrom"/>
+            <else>
+                <if-not-empty field="parameters.roleTypeIdTo">
+                    <set field="lookupPKMap.roleTypeId" from-field="parameters.roleTypeIdTo"/>
+                    <else>
+                        <if-not-empty field="parameters.roleTypeId">
+                            <set from-field="parameters.roleTypeId" field="lookupPKMap.roleTypeId"/>
+                            <else>
+                                <set field="lookupPKMap.roleTypeId" value="_NA_"/>
+                            </else>
+                        </if-not-empty>
+                    </else>
+                </if-not-empty>
+            </else>
+        </if-not-empty>
         <if-not-empty field="lookupPKMap.partyId">
-            <find-by-primary-key entity-name="PartyRole" map="lookupPKMap" value-field="lookedUpValue"/>
+            <find-by-primary-key entity-name="PartyRole" map="lookupPKMap" value-field="lookedUpValue" use-cache="true"/>
             <if-empty field="lookedUpValue">
-                <make-value value-field="newValue" entity-name="PartyRole" map="lookupPKMap"/>
-                <create-value value-field="newValue"/>
+                <make-value value-field="partyRole" entity-name="PartyRole" map="lookupPKMap"/>
+                <create-value value-field="partyRole"/>
             </if-empty>
         </if-not-empty>
-
     </simple-method>
 
     <simple-method method-name="createPersonAndUserLogin" short-description="Creates a person and userlogin" login-required="false">
@@ -222,7 +232,7 @@ under the License.
             <call-service service-name="createPartyEmailAddress" in-map-name="emailAddressContext"/>
         </if-not-empty>
     </simple-method>
-    
+
     <simple-method method-name="deleteBillingAccount" short-description="delete billing account">
         <now-timestamp field="nowTimestamp"/>
         <set field="parameters.thruDate" from-field="nowTimestamp"/>

Modified: ofbiz/branches/release14.12/applications/party/script/org/ofbiz/party/test/PartyTests.xml
URL: http://svn.apache.org/viewvc/ofbiz/branches/release14.12/applications/party/script/org/ofbiz/party/test/PartyTests.xml?rev=1650007&r1=1650006&r2=1650007&view=diff
==============================================================================
--- ofbiz/branches/release14.12/applications/party/script/org/ofbiz/party/test/PartyTests.xml (original)
+++ ofbiz/branches/release14.12/applications/party/script/org/ofbiz/party/test/PartyTests.xml Wed Jan  7 08:19:07 2015
@@ -188,6 +188,42 @@ under the License.
             <if-compare-field field="partyRole.roleTypeId" operator="equals" to-field="roleTypeId"/>
         </assert>
         <check-errors/>
+        <!-- test ensure from -->
+        <set field="ensurePartyRoleFromCtx.userLogin" from-field="userLogin"/>
+        <set field="roleTypeId" value="CONTRACTOR"/>
+        <set field="ensurePartyRoleFromCtx.roleTypeIdFrom" from-field="roleTypeId"/>
+        <set field="ensurePartyRoleFromCtx.partyIdFrom" from-field="partyId"/>
+        <entity-one entity-name="PartyRole" value-field="partyRole"/>
+        <assert>
+            <if-empty field="partyRole"/>
+        </assert>
+        <check-errors/>
+        <call-service service-name="ensurePartyRoleFrom" in-map-name="ensurePartyRoleFromCtx"/>
+        <entity-one entity-name="PartyRole" value-field="partyRole"/>
+        <assert>
+            <not><if-empty field="partyRole"/></not>
+            <if-compare-field field="partyRole.partyId" operator="equals" to-field="partyId"/>
+            <if-compare-field field="partyRole.roleTypeId" operator="equals" to-field="roleTypeId"/>
+        </assert>
+        <check-errors/>
+        <!-- test ensure to -->
+        <set field="ensurePartyRoleToCtx.userLogin" from-field="userLogin"/>
+        <set field="roleTypeId" value="MANUFACTURER"/>
+        <set field="ensurePartyRoleToCtx.roleTypeIdTo" from-field="roleTypeId"/>
+        <set field="ensurePartyRoleToCtx.partyIdTo" from-field="partyId"/>
+        <entity-one entity-name="PartyRole" value-field="partyRole"/>
+        <assert>
+            <if-empty field="partyRole"/>
+        </assert>
+        <check-errors/>
+        <call-service service-name="ensurePartyRoleTo" in-map-name="ensurePartyRoleToCtx"/>
+        <entity-one entity-name="PartyRole" value-field="partyRole"/>
+        <assert>
+            <not><if-empty field="partyRole"/></not>
+            <if-compare-field field="partyRole.partyId" operator="equals" to-field="partyId"/>
+            <if-compare-field field="partyRole.roleTypeId" operator="equals" to-field="roleTypeId"/>
+        </assert>
+        <check-errors/>
     </simple-method>
 
     <simple-method method-name="testCreateNewCommEvent" short-description="test to create a new communication event" login-required="false">

Modified: ofbiz/branches/release14.12/applications/party/servicedef/services.xml
URL: http://svn.apache.org/viewvc/ofbiz/branches/release14.12/applications/party/servicedef/services.xml?rev=1650007&r1=1650006&r2=1650007&view=diff
==============================================================================
--- ofbiz/branches/release14.12/applications/party/servicedef/services.xml (original)
+++ ofbiz/branches/release14.12/applications/party/servicedef/services.xml Wed Jan  7 08:19:07 2015
@@ -274,7 +274,7 @@ under the License.
     <service name="ensurePartyRole" engine="simple"
             location="component://party/script/org/ofbiz/party/party/PartySimpleMethods.xml" invoke="ensureNaPartyRole" auth="false">
         <description>Ensure that the party is in the specified role.</description>
-        <attribute name="partyId" type="String" mode="IN" optional="true"/>
+        <attribute name="partyId" type="String" mode="IN" optional="false"/>
         <attribute name="roleTypeId" type="String" mode="IN" optional="false"/>
     </service>
     <service name="ensureNaPartyRole" engine="simple"
@@ -284,13 +284,20 @@ under the License.
     </service>
     <service name="ensureNaPartyRoleFrom" engine="simple"
             location="component://party/script/org/ofbiz/party/party/PartySimpleMethods.xml" invoke="ensureNaPartyRole" auth="true">
-        <description>Ensure that the party is in the _NA_ role.</description>
+        <description>Ensure that the party indicate by partyIdFrom is in the _NA_ role.</description>
         <attribute name="partyIdFrom" type="String" mode="IN" optional="false"/>
     </service>
-    <service name="ensureNaPartyRoleTo" engine="simple"
+    <service name="ensurePartyRoleFrom" engine="simple"
             location="component://party/script/org/ofbiz/party/party/PartySimpleMethods.xml" invoke="ensureNaPartyRole" auth="true">
-        <description>Ensure that the party is in the _NA_ role.</description>
+        <description>Ensure that the party indicate by partyIdFrom is in the roleTypeIdFrom specifc role. If roleTypeIdFrom isn't present use _NA_</description>
+        <attribute name="partyIdFrom" type="String" mode="IN" optional="false"/>
+        <attribute name="roleTypeIdFrom" type="String" mode="IN" optional="true"/>
+    </service>
+    <service name="ensurePartyRoleTo" engine="simple"
+            location="component://party/script/org/ofbiz/party/party/PartySimpleMethods.xml" invoke="ensureNaPartyRole" auth="true">
+        <description>Ensure that the party indicate by partyIdTo is in the roleTypeIdTo specific role. If roleTypeIdTo isn't present use _NA_</description>
         <attribute name="partyIdTo" type="String" mode="IN" optional="false"/>
+        <attribute name="roleTypeIdTo" type="String" mode="IN" optional="true"/>
     </service>
 
     <!-- Party Relationship services -->
@@ -335,12 +342,13 @@ under the License.
         <override name="roleTypeIdFrom" optional="true"/>
         <override name="roleTypeIdTo" optional="true"/>
     </service>
-    
+
     <service name="createPartyRelationshipAndRole" engine="group" auth="true">
-        <description>Create party's role and party's relationship</description>
+        <description>Create party's roles and party's relationship</description>
         <group>
-            <invoke name="createPartyRole" result-to-context="true"/>
-            <invoke name="createPartyRelationship" result-to-context="true"/>
+            <invoke name="ensurePartyRoleFrom"/>
+            <invoke name="ensurePartyRoleTo"/>
+            <invoke name="createPartyRelationship"/>
         </group>
     </service>
 
@@ -351,7 +359,7 @@ under the License.
         <auto-attributes include="nonpk" mode="IN" optional="true"/>
         <override name="partyRelationshipName" optional="false"/>
     </service>
-    
+
     <service name="createUpdatePartyRelationshipAndRoles" engine="java" default-entity-name="PartyRelationship"
         location="org.ofbiz.party.party.PartyRelationshipServices" invoke="createUpdatePartyRelationshipAndRoles" auth="true">
         <description>
@@ -365,7 +373,6 @@ under the License.
         <attribute name="partyId" type="String" mode="IN" optional="false"/>
         <override name="fromDate" optional="true"/>
     </service>
-        
 
     <service name="createPartyRelationshipContactAccount" engine="simple"
         location="component://party/script/org/ofbiz/party/party/PartyServices.xml" invoke="createPartyRelationshipContactAccount" auth="true">
@@ -692,7 +699,6 @@ under the License.
         <attribute name="identifications" mode="IN" type="Map" />
     </service>
 
-
     <!-- Vendor -->
     <service name="createVendor" default-entity-name="Vendor" engine="entity-auto" invoke="create" auth="true">
         <description>Create Vendor Information</description>
@@ -1337,12 +1343,12 @@ under the License.
         <attribute name="userLoginId" type="String" mode="IN" optional="false"/>
         <attribute name="productStoreId" type="String" mode="IN" optional="false"/>
     </service>
-    
+
     <service name="importParty" engine="java"
         location="org.ofbiz.party.party.PartyServices" invoke="importParty" auth="true">
         <description>Import an party with related main role, company and contact info in csv format, will ignore parties already entered</description>
         <permission-service service-name="partyGroupPermissionCheck" main-action="CREATE"/>
         <attribute mode="IN" name="uploadedFile" type="java.nio.ByteBuffer" optional="true" />
     </service>
-    
+
 </services>