svn commit: r783603 - in /ofbiz/trunk: applications/party/script/org/ofbiz/party/contact/ applications/party/servicedef/ applications/party/widget/partymgr/ framework/base/src/org/ofbiz/base/util/

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

svn commit: r783603 - in /ofbiz/trunk: applications/party/script/org/ofbiz/party/contact/ applications/party/servicedef/ applications/party/widget/partymgr/ framework/base/src/org/ofbiz/base/util/

hansbak-2
Author: hansbak
Date: Thu Jun 11 02:14:32 2009
New Revision: 783603

URL: http://svn.apache.org/viewvc?rev=783603&view=rev
Log:
make the party viewprofile request also working when only an emailaddress or telephone number is provided. usefull when this url is called from other webbased systems.

Modified:
    ofbiz/trunk/applications/party/script/org/ofbiz/party/contact/PartyContactMechServices.xml
    ofbiz/trunk/applications/party/servicedef/services.xml
    ofbiz/trunk/applications/party/widget/partymgr/PartyScreens.xml
    ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilParse.java

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=783603&r1=783602&r2=783603&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 Thu Jun 11 02:14:32 2009
@@ -301,25 +301,75 @@
         </if-empty>
         <set field="input.inputFields.infoString_ic" from-field="parameters.caseInsensitive"/>
         <log level="info" message="findPartyFromEmailAddress with case insensitive search: ${parameters.caseInsensitive}"/>
-
+        
         <if-empty field="parameters.fromDate">
             <now-timestamp field="input.filterByDateValue"/>
             <else>
                 <set field="input.filterByDateValue" from-field="parameters.fromDate"/>
             </else>
         </if-empty>
-
+        
         <call-service service-name="performFindItem" in-map-name="input">
             <results-to-map map-name="results"/>
         </call-service>
-
+        
         <if-not-empty field="results.item">
             <field-to-result field="results.item.partyId" result-name="partyId"/>
             <field-to-result field="results.item.contactMechId" result-name="contactMechId"/>
         </if-not-empty>
-
+        
     </simple-method>
+    
+    <simple-method method-name="findPartyFromTelephone" short-description="Find partyId from the telephone number">
 
+        <entity-and entity-name="PartyAndContactMech" list="contactMechs" filter-by-date="true">
+            <field-map field-name="contactMechTypeId" value="TELECOM_NUMBER"/>
+        </entity-and>
+        
+        <set field="inputString" from-field="parameters.telno"/>
+        <call-simple-method method-name="removeTelnoChar"/>
+        <set field="inputTelno" from-field="inputString"/>
+        
+        <iterate entry="contactMech" list="contactMechs">
+            <set field="inputString" from-field="contactMech.tnContactNumber"/>
+            <call-simple-method method-name="removeTelnoChar"/>
+            <set field="telno" from-field="inputString"/>
+            <if-compare-field field="inputTelno" operator="equals" to-field="telno">
+                <set field="partyId" from-field="contactMech.partyId"/>
+            </if-compare-field>
+            <set field="telno" value="${contactMech.tnAreaCode}${telno}"/>
+            <if-compare-field field="inputTelno" operator="equals" to-field="telno">
+                <set field="partyId" from-field="contactMech.partyId"/>
+            </if-compare-field>
+            <set field="telno" value="${contactMech.tnCountryCode}${telno}"/>
+            <if-compare-field field="inputTelno" operator="equals" to-field="telno">
+                <set field="partyId" from-field="contactMech.partyId"/>
+            </if-compare-field>
+            <set field="telno" value="+${telno}"/>
+            <if-compare-field field="inputTelno" operator="equals" to-field="telno">
+                <set field="partyId" from-field="contactMech.partyId"/>
+            </if-compare-field>
+        </iterate>
+        <if-not-empty field="partyId">
+            <field-to-result field="partyId"/>
+            <field-to-result field="contactMech.contactMechId" result-name="contactMechId"/>
+        </if-not-empty>
+    </simple-method>
+    
+    <simple-method method-name="removeTelnoChar" short-description="remove a string from another string">
+        <set field="removeString" value="-"/>
+        <call-class-method class-name="org.ofbiz.base.util.UtilParse" method-name="removeStringFromString" ret-field="inputString">
+            <field field="inputString" type="String"/>
+            <field field="removeString" type="String"/>
+        </call-class-method>
+        <set field="removeString" value=" "/>
+        <call-class-method class-name="org.ofbiz.base.util.UtilParse" method-name="removeStringFromString" ret-field="inputString">
+            <field field="inputString" type="String"/>
+            <field field="removeString" type="String"/>
+        </call-class-method>
+    </simple-method>
+    
+    
     <simple-method method-name="createPostalAddressAndPurposes" short-description="Create postal address, purposes and set them defaults" login-required="false">
         <call-service service-name="createPartyPostalAddress" in-map-name="parameters">
             <result-to-field result-name="contactMechId" field="parameters.contactMechId"/>

Modified: ofbiz/trunk/applications/party/servicedef/services.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/servicedef/services.xml?rev=783603&r1=783602&r2=783603&view=diff
==============================================================================
--- ofbiz/trunk/applications/party/servicedef/services.xml (original)
+++ ofbiz/trunk/applications/party/servicedef/services.xml Thu Jun 11 02:14:32 2009
@@ -389,7 +389,7 @@
     </service>
     <!-- Party ContachMech reverse find -->
     <service name="findPartyFromEmailAddress" engine="simple"
-            location="component://party/script/org/ofbiz/party/contact/PartyContactMechServices.xml" invoke="findPartyFromEmailAddress" auth="true">
+        location="component://party/script/org/ofbiz/party/contact/PartyContactMechServices.xml" invoke="findPartyFromEmailAddress" auth="true">
         <description>Find the partyId/contactMechId for a specific email address, if not found do not return a value</description>
         <attribute name="address" type="String" mode="IN" optional="false"/>
         <attribute name="caseInsensitive" type="String" mode="IN" optional="true"/>
@@ -398,6 +398,13 @@
         <attribute name="partyId" type="String" mode="OUT" optional="true"/>
         <attribute name="contactMechId" type="String" mode="OUT" optional="true"/>
     </service>
+    <service name="findPartyFromTelephone" engine="simple"
+        location="component://party/script/org/ofbiz/party/contact/PartyContactMechServices.xml" invoke="findPartyFromTelephone" auth="true">
+        <description>Find the partyId/contactMechId for a specific telephone number, if not found do not return a value</description>
+        <attribute name="telno" type="String" mode="IN" optional="false"/>
+        <attribute name="partyId" type="String" mode="OUT" optional="true"/>
+        <attribute name="contactMechId" type="String" mode="OUT" optional="true"/>
+    </service>
     <service name="createPartyPostalAddress" engine="simple"
             location="component://party/script/org/ofbiz/party/contact/PartyContactMechServices.xml" invoke="createPartyPostalAddress" auth="true">
         <description>Create a Postal Address</description>

Modified: ofbiz/trunk/applications/party/widget/partymgr/PartyScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/widget/partymgr/PartyScreens.xml?rev=783603&r1=783602&r2=783603&view=diff
==============================================================================
--- ofbiz/trunk/applications/party/widget/partymgr/PartyScreens.xml (original)
+++ ofbiz/trunk/applications/party/widget/partymgr/PartyScreens.xml Thu Jun 11 02:14:32 2009
@@ -87,6 +87,40 @@
                     <decorator-section name="body">
                         <section>
                             <condition>
+                                <and>
+                                    <if-empty field="partyId"/>
+                                    <not><if-empty field="parameters.telno"/></not>
+                                </and>
+                            </condition>
+                            <actions>
+                                <service service-name="findPartyFromTelephone" auto-field-map="true" result-map="telnoMap"/>
+                                <entity-one entity-name="Party" value-field="party">
+                                    <field-map field-name="partyId" from-field="telnoMap.partyId"/>
+                                </entity-one>
+                                <set field="parameters.partyId" from-field="party.partyId"/>
+                            </actions>
+                            <widgets/>
+                        </section>
+                        <section>
+                            <condition>
+                                <and>
+                                    <if-empty field="partyId"/>
+                                    <not><if-empty field="parameters.email"/></not>
+                                </and>
+                            </condition>
+                            <actions>
+                                <service service-name="findPartyFromEmailAddress" result-map="emailMap">
+                                    <field-map field-name="address" from-field="parameters.email"/>
+                                </service>
+                                <entity-one entity-name="Party" value-field="party">
+                                    <field-map field-name="partyId" from-field="emailMap.partyId"/>
+                                </entity-one>
+                                <set field="parameters.partyId" from-field="party.partyId"/>
+                            </actions>
+                            <widgets/>
+                        </section>
+                        <section>
+                            <condition>
                                 <not><if-empty field="party"/></not>
                             </condition>
                             <widgets>

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilParse.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilParse.java?rev=783603&r1=783602&r2=783603&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilParse.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilParse.java Thu Jun 11 02:14:32 2009
@@ -35,4 +35,17 @@
         }
         return new BigDecimal(bigDecimalString);
     }
+
+    /**
+     *
+     * to be used in minilanguage to remove all occurrencies of removeString from inputString
+     *
+     * @param inputString
+     * @param removeString
+     * @return
+     */
+    public static String removeStringFromString(String inputString, String removeString) {
+     return(inputString.replaceAll(removeString, ""));
+    }
+
 }