Author: hansbak
Date: Sun Jul 27 10:37:46 2008
New Revision: 680157

URL: http://svn.apache.org/viewvc?rev=680157&view=rev
Log:
check in create contactmech service if the contactmech infostring is already 
existing, if so do not create again

Modified:
    
ofbiz/trunk/applications/party/script/org/ofbiz/party/contact/PartyContactMechServices.xml
    ofbiz/trunk/applications/party/servicedef/secas.xml

Modified: 
ofbiz/trunk/applications/party/script/org/ofbiz/party/contact/PartyContactMechServices.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/script/org/ofbiz/party/contact/PartyContactMechServices.xml?rev=680157&r1=680156&r2=680157&view=diff
==============================================================================
--- 
ofbiz/trunk/applications/party/script/org/ofbiz/party/contact/PartyContactMechServices.xml
 (original)
+++ 
ofbiz/trunk/applications/party/script/org/ofbiz/party/contact/PartyContactMechServices.xml
 Sun Jul 27 10:37:46 2008
@@ -27,6 +27,28 @@
             <set field="parameters.partyId" from-field="userLogin.partyId"/>
         </if-empty>
         
+        <!-- check if the contact mech infostring is already existing if so, 
do not create a new one-->
+        <entity-and list-name="partyAndContactMechs" 
entity-name="PartyAndContactMech">
+            <field-map field-name="partyId" env-name="parameters.partyId"/>
+        </entity-and>
+        <iterate entry-name="partyAndContactMech" 
list-name="partyAndContactMechs">
+            <entity-one entity-name="ContactMechType" 
value-name="contactMechType">
+                <field-map field-name="contactMechTypeId" 
env-name="partyAndContactMech.contactMechTypeId"/>
+            </entity-one>
+            <if>
+                <condition>
+                    <and>
+                        <if-compare operator="equals" value="N" 
field="contactMechType.hasTable"/>
+                        <if-compare operator="equals" 
value="${partyAndContactMech.infoString}" field="parameters.infoString"/>
+                    </and>
+                </condition>
+                <then>
+                    <log level="info" message="Contact mechTypeId: 
${parameters.contactMechTypeId} already exists with value: 
${partyAndContactMech.infoString} for party: ${parameters.partyId}"/>
+                    <return response-code="success"/>                
+                </then>
+            </if>
+        </iterate>        
+        
         <if-empty field="parameters.contactMechId">
             <set-service-fields service-name="createContactMech" 
map-name="parameters" to-map-name="createContactMechMap"/>
             <call-service service-name="createContactMech" 
in-map-name="createContactMechMap">

Modified: ofbiz/trunk/applications/party/servicedef/secas.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/servicedef/secas.xml?rev=680157&r1=680156&r2=680157&view=diff
==============================================================================
--- ofbiz/trunk/applications/party/servicedef/secas.xml (original)
+++ ofbiz/trunk/applications/party/servicedef/secas.xml Sun Jul 27 10:37:46 2008
@@ -51,6 +51,7 @@
     <!-- NOTE: because we have an ECA on createPartyContactMech, we don't need 
to do it on createPartyPostalAddress, createPartyEmailAddress, 
createPartyTelecomNumber because those will call it -->
     <eca service="createPartyContactMech" event="commit">
         <condition field-name="contactMechPurposeTypeId" 
operator="is-not-empty"/>
+        <condition field-name="contactMechId" operator="is-not-empty"/>
         <action service="createPartyContactMechPurpose" mode="sync"/>
     </eca>
 


Reply via email to