svn commit: r464599 - in /incubator/ofbiz/trunk/applications/party: script/org/ofbiz/party/contact/ servicedef/ src/org/ofbiz/party/contact/

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

svn commit: r464599 - in /incubator/ofbiz/trunk/applications/party: script/org/ofbiz/party/contact/ servicedef/ src/org/ofbiz/party/contact/

jonesde
Author: jonesde
Date: Mon Oct 16 11:07:58 2006
New Revision: 464599

URL: http://svn.apache.org/viewvc?view=rev&rev=464599
Log:
Some more cleanups of the PartyContactMech related services; also removed ECAs that are redundant once this is done in a cleaner and more correct way; note that there is a lot of crap in there with weird dependencies and some other errors may be found (some changes here are based on that happening before), so there may be other changes needed in this area

Modified:
    incubator/ofbiz/trunk/applications/party/script/org/ofbiz/party/contact/ContactMechMapProcs.xml
    incubator/ofbiz/trunk/applications/party/script/org/ofbiz/party/contact/PartyContactMechMapProcs.xml
    incubator/ofbiz/trunk/applications/party/script/org/ofbiz/party/contact/PartyContactMechServices.xml
    incubator/ofbiz/trunk/applications/party/servicedef/secas.xml
    incubator/ofbiz/trunk/applications/party/src/org/ofbiz/party/contact/ContactMechServices.java

Modified: incubator/ofbiz/trunk/applications/party/script/org/ofbiz/party/contact/ContactMechMapProcs.xml
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/party/script/org/ofbiz/party/contact/ContactMechMapProcs.xml?view=diff&rev=464599&r1=464598&r2=464599
==============================================================================
--- incubator/ofbiz/trunk/applications/party/script/org/ofbiz/party/contact/ContactMechMapProcs.xml (original)
+++ incubator/ofbiz/trunk/applications/party/script/org/ofbiz/party/contact/ContactMechMapProcs.xml Mon Oct 16 11:07:58 2006
@@ -18,38 +18,6 @@
 <simple-map-processors xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="http://www.ofbiz.org/dtds/simple-methods.xsd">
     <!-- ContactMech map procs -->
-    <simple-map-processor name="contactMech">
-        <process field="contactMechTypeId"><copy/><not-empty><fail-property resource="PartyUiLabels" property="PartyContactMechTypeIdMissing"/></not-empty></process>
-        <process field="infoString"><copy/></process>
-    </simple-map-processor>
-    <simple-map-processor name="updateContactMech">
-        <process field="contactMechId"><copy/><not-empty><fail-property resource="PartyUiLabels" property="PartyContactMechIdMissing"/></not-empty></process>
-        <process field="contactMechTypeId"><copy/></process>
-        <process field="infoString"><copy/></process>
-    </simple-map-processor>
-
-    <simple-map-processor name="postalAddress">
-        <process field="contactMechId"><copy set-if-null="false"/></process>
-        <process field="toName"><copy/></process>
-        <process field="attnName"><copy/></process>
-        <process field="address1"><copy/><not-empty><fail-property resource="PartyUiLabels" property="PartyAddressLine1Missing"/></not-empty></process>
-        <process field="address2"><copy/></process>
-        <process field="directions"><copy/></process>
-        <process field="city"><copy/><not-empty><fail-property resource="PartyUiLabels" property="PartyCityMissing"/></not-empty></process>
-        <process field="stateProvinceGeoId"><copy/></process>
-        <process field="postalCode"><copy/><not-empty><fail-property resource="PartyUiLabels" property="PartyPostalCodeMissing"/></not-empty></process>
-        <process field="postalCodeExt"><copy/></process>
-        <process field="countryGeoId"><copy/></process>
-        <process field="postalCodeGeoId"><copy/></process>
-    </simple-map-processor>
-
-    <simple-map-processor name="telecomNumber">
-        <process field="contactMechId"><copy set-if-null="false"/></process>
-        <process field="countryCode"><copy/></process>
-        <process field="areaCode"><copy/></process>
-        <process field="askForName"><copy/></process>
-        <process field="contactNumber"><copy/><not-empty><fail-property resource="PartyUiLabels" property="PartyContactNumberMissing"/></not-empty></process>
-    </simple-map-processor>
 
     <simple-map-processor name="emailAddress">
         <process field="contactMechId"><copy set-if-null="false"/></process>

Modified: incubator/ofbiz/trunk/applications/party/script/org/ofbiz/party/contact/PartyContactMechMapProcs.xml
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/party/script/org/ofbiz/party/contact/PartyContactMechMapProcs.xml?view=diff&rev=464599&r1=464598&r2=464599
==============================================================================
--- incubator/ofbiz/trunk/applications/party/script/org/ofbiz/party/contact/PartyContactMechMapProcs.xml (original)
+++ incubator/ofbiz/trunk/applications/party/script/org/ofbiz/party/contact/PartyContactMechMapProcs.xml Mon Oct 16 11:07:58 2006
@@ -1,6 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!--
-
 Copyright 2001-2006 The Apache Software Foundation
 
 Licensed under the Apache License, Version 2.0 (the "License"); you may not
@@ -48,16 +47,6 @@
         <process field="allowSolicitation"><copy/></process>
     </simple-map-processor>
 
-    <simple-map-processor name="emailAddress">
-     <process field="contactMechId"><copy set-if-null="false"/></process>
-        <process field="partyId"><copy/></process>
-        <process field="emailAddress">
-            <copy to-field="infoString"/>
-            <not-empty><fail-property resource="PartyUiLabels" property="PartyEmailAddressMissing"/></not-empty>
-            <validate-method method="isEmail"><fail-property resource="PartyUiLabels" property="PartyEmailAddressNotFormattedCorrectly"/></validate-method></process>
-        <process field="allowSolicitation"><copy/></process>
-    </simple-map-processor>
-
     <!-- PartyContactMechPurpose map procs -->
     <simple-map-processor name="createPartyContactMechPurpose">
         <process field="partyId"><copy/></process>
@@ -72,6 +61,4 @@
             <not-empty><fail-property resource="PartyUiLabels" property="CommonFromDateMissing"/></not-empty>
             <convert type="Timestamp"><fail-property resource="PartyUiLabels" property="CommonFromDateNotValidDateTime"/></convert></process>
     </simple-map-processor>
-  
-   <!-- PartyContactMech -->
 </simple-map-processors>

Modified: incubator/ofbiz/trunk/applications/party/script/org/ofbiz/party/contact/PartyContactMechServices.xml
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/party/script/org/ofbiz/party/contact/PartyContactMechServices.xml?view=diff&rev=464599&r1=464598&r2=464599
==============================================================================
--- incubator/ofbiz/trunk/applications/party/script/org/ofbiz/party/contact/PartyContactMechServices.xml (original)
+++ incubator/ofbiz/trunk/applications/party/script/org/ofbiz/party/contact/PartyContactMechServices.xml Mon Oct 16 11:07:58 2006
@@ -19,8 +19,6 @@
 <simple-methods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:noNamespaceSchemaLocation="http://www.ofbiz.org/dtds/simple-methods.xsd">
     <simple-method method-name="createPartyContactMech" short-description="Create a PartyContactMech">
-        <log level="always" message="In createPartyContactMech parameters: ${parameters}"/>
-        
         <make-value entity-name="PartyContactMech" value-name="newValue"/>
         <make-value entity-name="PartyContactMech" value-name="newPartyContactMech"/><!-- DEJ20061016: is this really needed? doesn't seem to be used... -->
         <if-empty map-name="parameters" field-name="partyId">
@@ -34,9 +32,8 @@
         <check-errors/>
         
         <if-empty map-name="parameters" field-name="contactMechId">
-            <call-map-processor xml-resource="org/ofbiz/party/contact/ContactMechMapProcs.xml"
-                processor-name="contactMech" in-map-name="parameters" out-map-name="context"/>
-            <call-service service-name="createContactMech" in-map-name="context">
+            <set-service-fields service-name="createContactMech" map-name="parameters" to-map-name="createContactMechMap"/>
+            <call-service service-name="createContactMech" in-map-name="createContactMechMap">
                 <result-to-field result-name="contactMechId" map-name="newValue"/>
             </call-service>    
             <log level="info" message="ContactMech created"/>    
@@ -54,8 +51,6 @@
     </simple-method>
     
     <simple-method method-name="updatePartyContactMech" short-description="Update a PartyContactMech">
-        <log level="always" message="In updatePartyContactMech parameters: ${parameters}"/>
-        
         <make-value entity-name="PartyContactMech" value-name="newPartyContactMech"/>
         <if-empty map-name="parameters" field-name="partyId">
             <set field="parameters.partyId" from-field="userLogin.partyId"/>
@@ -80,12 +75,8 @@
         
         <!-- If we already have a new contactMechId don't update ContactMech -->
         <if-empty map-name="parameters" field-name="newContactMechId">                
-            <log level="info" message="Calling map procs"/>
-            <call-map-processor xml-resource="org/ofbiz/party/contact/ContactMechMapProcs.xml"
-                processor-name="updateContactMech" in-map-name="parameters" out-map-name="context"/>
-            <to-string field-name="contactMechId" map-name="context"/>
-            <log level="info" message="Calling generic updateContactMech method"/>
-            <call-service service-name="updateContactMech" in-map-name="context">
+            <set-service-fields service-name="updateContactMech" map-name="parameters" to-map-name="updateContactMechMap"/>
+            <call-service service-name="updateContactMech" in-map-name="updateContactMechMap">
                 <default-message>Contact Mechanism successfully updated.</default-message>
                 <result-to-field result-name="contactMechId" map-name="newPartyContactMech"/>
             </call-service>
@@ -164,12 +155,8 @@
         </if-compare-field>
         <check-errors/>
 
-        <make-value entity-name="PartyContactMech" value-name="newPartyContactMech"/>
-        <call-map-processor xml-resource="org/ofbiz/party/contact/ContactMechMapProcs.xml"
-                processor-name="postalAddress" in-map-name="parameters" out-map-name="context"/>
-        <check-errors/>
-
-        <call-service in-map-name="context" service-name="createPostalAddress">
+        <set-service-fields service-name="createPostalAddress" map-name="parameters" to-map-name="createPostalAddressMap"/>
+        <call-service in-map-name="createPostalAddressMap" service-name="createPostalAddress">
             <default-message>Postal Address successfully created</default-message>
             <result-to-field result-name="contactMechId" map-name="newPartyContactMech"/>
         </call-service>
@@ -198,11 +185,8 @@
         </if-compare-field>
         <check-errors/>
         
-        <call-map-processor xml-resource="org/ofbiz/party/contact/ContactMechMapProcs.xml"
-                processor-name="postalAddress" in-map-name="parameters" out-map-name="context"/>
-        <check-errors/>
-        <set field="context.partyId" from-field="parameters.partyId"/>
-        <call-service in-map-name="context" service-name="updatePostalAddress">
+        <set-service-fields service-name="updatePostalAddress" map-name="parameters" to-map-name="updatePostalAddressMap"/>
+        <call-service in-map-name="updatePostalAddressMap" service-name="updatePostalAddress">
             <default-message>Postal Address successfully updated</default-message>
             <result-to-field result-name="contactMechId" map-name="newPartyContactMech" field-name="contactMechId" />            
         </call-service>
@@ -229,11 +213,9 @@
         </if-compare-field>
         <check-errors/>
                 
-        <make-value entity-name="PartyContactMech" value-name="newPartyContactMech"/>
         <log level="info" message="Creating telecom number"/>
-        <call-map-processor xml-resource="org/ofbiz/party/contact/ContactMechMapProcs.xml"
-                processor-name="telecomNumber" in-map-name="parameters" out-map-name="context"/>          
-        <call-service in-map-name="context" service-name="createTelecomNumber">
+        <set-service-fields service-name="createTelecomNumber" map-name="parameters" to-map-name="createTelecomNumberMap"/>          
+        <call-service in-map-name="createTelecomNumberMap" service-name="createTelecomNumber">
             <default-message>Telecom number successfully created</default-message>
             <result-to-field result-name="contactMechId" map-name="newPartyContactMech"/>            
         </call-service>
@@ -261,9 +243,8 @@
         </if-compare-field>
         <check-errors/>
         
-        <call-map-processor xml-resource="org/ofbiz/party/contact/ContactMechMapProcs.xml"
-                processor-name="telecomNumber" in-map-name="parameters" out-map-name="context"/>          
-        <call-service in-map-name="context" service-name="updateTelecomNumber">
+        <set-service-fields service-name="updateTelecomNumber" map-name="parameters" to-map-name="updateTelecomNumberMap"/>          
+        <call-service service-name="updateTelecomNumber" in-map-name="updateTelecomNumberMap">
             <default-message>Telecom Number successfully updated</default-message>
             <result-to-field result-name="contactMechId" map-name="newPartyContactMech" field-name="contactMechId" />            
         </call-service>
@@ -290,13 +271,16 @@
                 <fail-property resource="PartyUiLabels" property="PartyPermissionErrorForThisParty"/>
             </check-permission>
         </if-compare-field>
+
+        <if-validate-method field-name="parameters.emailAddress" method="isEmail">
+            <else><add-error><fail-property resource="PartyUiLabels" property="PartyEmailAddressNotFormattedCorrectly"/></add-error></else>
+        </if-validate-method>
         <check-errors/>
                 
-        <call-map-processor xml-resource="org/ofbiz/party/contact/PartyContactMechMapProcs.xml"
-            processor-name="emailAddress" in-map-name="parameters" out-map-name="context"/>
-        <check-errors/>
-        <set field="context.contactMechTypeId" value="EMAIL_ADDRESS"/>
-        <call-service service-name="createPartyContactMech" in-map-name="context">
+        <set-service-fields service-name="createPartyContactMech" map-name="parameters" to-map-name="createPartyContactMechMap"/>
+        <set field="createPartyContactMechMap.infoString" from-field="parameters.emailAddress"/>
+        <set field="createPartyContactMechMap.contactMechTypeId" value="EMAIL_ADDRESS"/>
+        <call-service service-name="createPartyContactMech" in-map-name="createPartyContactMechMap">
             <default-message>Party Contact Mechanism successfully created.</default-message>
             <result-to-result result-name="contactMechId"/>
             <result-to-request result-name="contactMechId"/>
@@ -312,13 +296,16 @@
                 <fail-property resource="PartyUiLabels" property="PartyPermissionErrorForThisParty"/>
             </check-permission>
         </if-compare-field>
+
+        <if-validate-method field-name="parameters.emailAddress" method="isEmail">
+            <else><add-error><fail-property resource="PartyUiLabels" property="PartyEmailAddressNotFormattedCorrectly"/></add-error></else>
+        </if-validate-method>
         <check-errors/>
               
-        <call-map-processor xml-resource="org/ofbiz/party/contact/PartyContactMechMapProcs.xml"
-            processor-name="emailAddress" in-map-name="parameters" out-map-name="context"/>
-        <check-errors/>
-        <set field="context.contactMechTypeId" value="EMAIL_ADDRESS"/>
-        <call-service service-name="updatePartyContactMech" in-map-name="context">
+        <set-service-fields service-name="updatePartyContactMech" map-name="parameters" to-map-name="updatePartyContactMechMap"/>
+        <set field="updatePartyContactMechMap.infoString" from-field="parameters.emailAddress"/>
+        <set field="updatePartyContactMechMap.contactMechTypeId" value="EMAIL_ADDRESS"/>
+        <call-service service-name="updatePartyContactMech" in-map-name="updatePartyContactMechMap">
             <default-message>Party Contact Mechanism successfully updated.</default-message>
             <result-to-result result-name="contactMechId"/>
             <result-to-request result-name="contactMechId"/>
@@ -326,7 +313,6 @@
     </simple-method>
 
     <simple-method method-name="findPartyFromEmailAddress" short-description="Find partyId from email address">
-
         <set field="input.entityName" value="PartyAndContactMech"/>
         <set field="input.filterByDate" value="Y"/>
         <set field="input.inputFields.infoString" from-field="parameters.address"/>

Modified: incubator/ofbiz/trunk/applications/party/servicedef/secas.xml
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/party/servicedef/secas.xml?view=diff&rev=464599&r1=464598&r2=464599
==============================================================================
--- incubator/ofbiz/trunk/applications/party/servicedef/secas.xml (original)
+++ incubator/ofbiz/trunk/applications/party/servicedef/secas.xml Mon Oct 16 11:07:58 2006
@@ -46,22 +46,12 @@
     </eca>
     
     <!-- party contact mech service ECAs -->
+    <!-- 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"/>
         <action service="createPartyContactMechPurpose" mode="sync"/>
-    </eca>    
-    <eca service="createPartyPostalAddress" event="commit">
-        <condition field-name="contactMechPurposeTypeId" operator="is-not-empty"/>
-        <action service="createPartyContactMechPurpose" mode="sync"/>
-    </eca>
-    <eca service="createPartyEmailAddress" event="commit">
-        <condition field-name="contactMechPurposeTypeId" operator="is-not-empty"/>
-        <action service="createPartyContactMechPurpose" mode="sync"/>
-    </eca>        
-    <eca service="createPartyTelecomNumber" event="commit">
-        <condition field-name="contactMechPurposeTypeId" operator="is-not-empty"/>
-        <action service="createPartyContactMechPurpose" mode="sync"/>
     </eca>
+
     <eca service="createCommEventWorkEffort" event="invoke">
         <condition field-name="workEffortId" operator="is-empty"/>
         <action service="createWorkEffort" mode="sync" />

Modified: incubator/ofbiz/trunk/applications/party/src/org/ofbiz/party/contact/ContactMechServices.java
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/party/src/org/ofbiz/party/contact/ContactMechServices.java?view=diff&rev=464599&r1=464598&r2=464599
==============================================================================
--- incubator/ofbiz/trunk/applications/party/src/org/ofbiz/party/contact/ContactMechServices.java (original)
+++ incubator/ofbiz/trunk/applications/party/src/org/ofbiz/party/contact/ContactMechServices.java Mon Oct 16 11:07:58 2006
@@ -790,6 +790,7 @@
      *@return Map with the result of the service, the output parameters
      */
     public static Map createPartyContactMechPurpose(DispatchContext ctx, Map context) {
+        //Debug.logInfo(new Exception(), "In createPartyContactMechPurpose context: " + context, module);
         Map result = new HashMap();
         GenericDelegator delegator = ctx.getDelegator();
         Security security = ctx.getSecurity();
@@ -799,17 +800,19 @@
         String errMsg = null;
         Locale locale = (Locale) context.get("locale");
 
-        if (result.size() > 0)
+        if (result.size() > 0) {
             return result;
+        }
 
         // required parameters
         String contactMechId = (String) context.get("contactMechId");
         String contactMechPurposeTypeId = (String) context.get("contactMechPurposeTypeId");
 
         GenericValue tempVal = null;
-
         try {
-            List allPCMPs = EntityUtil.filterByDate(delegator.findByAnd("PartyContactMechPurpose", UtilMisc.toMap("partyId", partyId, "contactMechId", contactMechId, "contactMechPurposeTypeId", contactMechPurposeTypeId), null), true);
+            Map pcmpFindMap = UtilMisc.toMap("partyId", partyId, "contactMechId", contactMechId, "contactMechPurposeTypeId", contactMechPurposeTypeId);
+            //Debug.logInfo("pcmpFindMap = " + pcmpFindMap, module);
+            List allPCMPs = EntityUtil.filterByDate(delegator.findByAnd("PartyContactMechPurpose", pcmpFindMap), true);
 
             tempVal = EntityUtil.getFirst(allPCMPs);
         } catch (GenericEntityException e) {
@@ -821,7 +824,8 @@
 
         if (tempVal != null) {
             // exists already with valid date, show warning
-            errMsg = UtilProperties.getMessage(resource,"contactmechservices.could_not_create_new_purpose_already_exists", locale);
+            errMsg = UtilProperties.getMessage(resource, "contactmechservices.could_not_create_new_purpose_already_exists", locale);
+            errMsg += ": " + tempVal.getPrimaryKey().toString();
             return ServiceUtil.returnError(errMsg);
         } else {
             // no entry with a valid date range exists, create new with open thruDate