svn commit: r1760406 - in /ofbiz/trunk: framework/common/data/GeoData_JP.xml specialpurpose/ecommerce/groovyScripts/customer/ViewProfile.groovy specialpurpose/ecommerce/template/customer/ViewProfile.ftl

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

svn commit: r1760406 - in /ofbiz/trunk: framework/common/data/GeoData_JP.xml specialpurpose/ecommerce/groovyScripts/customer/ViewProfile.groovy specialpurpose/ecommerce/template/customer/ViewProfile.ftl

jleroux@apache.org
Author: jleroux
Date: Mon Sep 12 16:47:53 2016
New Revision: 1760406

URL: http://svn.apache.org/viewvc?rev=1760406&view=rev
Log:
Fixes: Display of State/Province for non US entities in the customer's profile of ecommerce
(OFBIZ-8231)

When I access url https://localhost:8443/ecommerce/control/viewprofile for my profile, State/Province display in addresses shows the geo-id, which is fine for US entities where the GeoID is the state code, but for non-us entities, the GeoID is often something like CountryCode-StateCode, which isn't very nice.

Thanks: fumiyoshi.to for report and patch

jleroux: I have slightly changed the patch for 2 reasons:
* check for null exceptions
* use not deprecated version of getRelatedOne()

Modified:
    ofbiz/trunk/framework/common/data/GeoData_JP.xml
    ofbiz/trunk/specialpurpose/ecommerce/groovyScripts/customer/ViewProfile.groovy
    ofbiz/trunk/specialpurpose/ecommerce/template/customer/ViewProfile.ftl

Modified: ofbiz/trunk/framework/common/data/GeoData_JP.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/data/GeoData_JP.xml?rev=1760406&r1=1760405&r2=1760406&view=diff
==============================================================================
--- ofbiz/trunk/framework/common/data/GeoData_JP.xml (original)
+++ ofbiz/trunk/framework/common/data/GeoData_JP.xml Mon Sep 12 16:47:53 2016
@@ -20,53 +20,53 @@ under the License.
 
 <entity-engine-xml>
 
-    <Geo abbreviation="01" geoCode="01" geoId="JP-01" geoName="北海道" geoTypeId="PROVINCE" wellKnownText="Hokkaido"/>
-    <Geo abbreviation="02" geoCode="02" geoId="JP-02" geoName="青森県" geoTypeId="PROVINCE" wellKnownText="Aomori"/>
-    <Geo abbreviation="03" geoCode="03" geoId="JP-03" geoName="岩手県" geoTypeId="PROVINCE" wellKnownText="Iwate"/>
-    <Geo abbreviation="04" geoCode="04" geoId="JP-04" geoName="宮城県" geoTypeId="PROVINCE" wellKnownText="Miyagi"/>
-    <Geo abbreviation="05" geoCode="05" geoId="JP-05" geoName="秋田県" geoTypeId="PROVINCE" wellKnownText="Akita"/>
-    <Geo abbreviation="06" geoCode="06" geoId="JP-06" geoName="山形県" geoTypeId="PROVINCE" wellKnownText="Yamagata"/>
-    <Geo abbreviation="07" geoCode="07" geoId="JP-07" geoName="福島県" geoTypeId="PROVINCE" wellKnownText="Fukushima"/>
-    <Geo abbreviation="08" geoCode="08" geoId="JP-08" geoName="茨城県" geoTypeId="PROVINCE" wellKnownText="Ibaraki"/>
-    <Geo abbreviation="09" geoCode="09" geoId="JP-09" geoName="栃木県" geoTypeId="PROVINCE" wellKnownText="Tochigi"/>
-    <Geo abbreviation="10" geoCode="10" geoId="JP-10" geoName="群馬県" geoTypeId="PROVINCE" wellKnownText="Gunma"/>
-    <Geo abbreviation="11" geoCode="11" geoId="JP-11" geoName="埼玉県" geoTypeId="PROVINCE" wellKnownText="Saitama"/>
-    <Geo abbreviation="12" geoCode="12" geoId="JP-12" geoName="千葉県" geoTypeId="PROVINCE" wellKnownText="Chiba"/>
-    <Geo abbreviation="13" geoCode="13" geoId="JP-13" geoName="東京都" geoTypeId="PROVINCE" wellKnownText="Tokyo"/>
-    <Geo abbreviation="14" geoCode="14" geoId="JP-14" geoName="神奈川県" geoTypeId="PROVINCE" wellKnownText="Kanagawa"/>
-    <Geo abbreviation="15" geoCode="15" geoId="JP-15" geoName="新潟県" geoTypeId="PROVINCE" wellKnownText="Niigata"/>
-    <Geo abbreviation="16" geoCode="16" geoId="JP-16" geoName="富山県" geoTypeId="PROVINCE" wellKnownText="Toyama"/>
-    <Geo abbreviation="17" geoCode="17" geoId="JP-17" geoName="石川県" geoTypeId="PROVINCE" wellKnownText="Ishikawa"/>
-    <Geo abbreviation="18" geoCode="18" geoId="JP-18" geoName="福井県" geoTypeId="PROVINCE" wellKnownText="Fukui"/>
-    <Geo abbreviation="19" geoCode="19" geoId="JP-19" geoName="山梨県" geoTypeId="PROVINCE" wellKnownText="Yamanashi"/>
-    <Geo abbreviation="20" geoCode="20" geoId="JP-20" geoName="長野県" geoTypeId="PROVINCE" wellKnownText="Nagano"/>
-    <Geo abbreviation="21" geoCode="21" geoId="JP-21" geoName="岐阜県" geoTypeId="PROVINCE" wellKnownText="Gifu"/>
-    <Geo abbreviation="22" geoCode="22" geoId="JP-22" geoName="静岡県" geoTypeId="PROVINCE" wellKnownText="Shizuoka"/>
-    <Geo abbreviation="23" geoCode="23" geoId="JP-23" geoName="愛知県" geoTypeId="PROVINCE" wellKnownText="Aichi"/>
-    <Geo abbreviation="24" geoCode="24" geoId="JP-24" geoName="三重県" geoTypeId="PROVINCE" wellKnownText="Mie"/>
-    <Geo abbreviation="25" geoCode="25" geoId="JP-25" geoName="滋賀県" geoTypeId="PROVINCE" wellKnownText="Shiga"/>
-    <Geo abbreviation="26" geoCode="26" geoId="JP-26" geoName="京都府" geoTypeId="PROVINCE" wellKnownText="Kyoto"/>
-    <Geo abbreviation="27" geoCode="27" geoId="JP-27" geoName="大阪府" geoTypeId="PROVINCE" wellKnownText="Osaka"/>
-    <Geo abbreviation="28" geoCode="28" geoId="JP-28" geoName="兵庫県" geoTypeId="PROVINCE" wellKnownText="Hyogo"/>
-    <Geo abbreviation="29" geoCode="29" geoId="JP-29" geoName="奈良県" geoTypeId="PROVINCE" wellKnownText="Nara"/>
-    <Geo abbreviation="30" geoCode="30" geoId="JP-30" geoName="和歌山県" geoTypeId="PROVINCE" wellKnownText="Wakayama"/>
-    <Geo abbreviation="31" geoCode="31" geoId="JP-31" geoName="鳥取県" geoTypeId="PROVINCE" wellKnownText="Tottori"/>
-    <Geo abbreviation="32" geoCode="32" geoId="JP-32" geoName="島根県" geoTypeId="PROVINCE" wellKnownText="Shimane"/>
-    <Geo abbreviation="33" geoCode="33" geoId="JP-33" geoName="岡山県" geoTypeId="PROVINCE" wellKnownText="Okayama"/>
-    <Geo abbreviation="34" geoCode="34" geoId="JP-34" geoName="広島県" geoTypeId="PROVINCE" wellKnownText="Hiroshima"/>
-    <Geo abbreviation="35" geoCode="35" geoId="JP-35" geoName="山口県" geoTypeId="PROVINCE" wellKnownText="Yamaguchi"/>
-    <Geo abbreviation="36" geoCode="36" geoId="JP-36" geoName="徳島県" geoTypeId="PROVINCE" wellKnownText="Tokushima"/>
-    <Geo abbreviation="37" geoCode="37" geoId="JP-37" geoName="香川県" geoTypeId="PROVINCE" wellKnownText="Kagawa"/>
-    <Geo abbreviation="38" geoCode="38" geoId="JP-38" geoName="愛媛県" geoTypeId="PROVINCE" wellKnownText="Ehime"/>
-    <Geo abbreviation="39" geoCode="39" geoId="JP-39" geoName="高知県" geoTypeId="PROVINCE" wellKnownText="Kochi"/>
-    <Geo abbreviation="40" geoCode="40" geoId="JP-40" geoName="福岡県" geoTypeId="PROVINCE" wellKnownText="Fukuoka"/>
-    <Geo abbreviation="41" geoCode="41" geoId="JP-41" geoName="佐賀県" geoTypeId="PROVINCE" wellKnownText="Saga"/>
-    <Geo abbreviation="42" geoCode="42" geoId="JP-42" geoName="長崎県" geoTypeId="PROVINCE" wellKnownText="Nagasaki"/>
-    <Geo abbreviation="43" geoCode="43" geoId="JP-43" geoName="熊本県" geoTypeId="PROVINCE" wellKnownText="Kumamoto"/>
-    <Geo abbreviation="44" geoCode="44" geoId="JP-44" geoName="大分県" geoTypeId="PROVINCE" wellKnownText="Oita"/>
-    <Geo abbreviation="45" geoCode="45" geoId="JP-45" geoName="宮崎県" geoTypeId="PROVINCE" wellKnownText="Miyazaki"/>
-    <Geo abbreviation="46" geoCode="46" geoId="JP-46" geoName="鹿児島県" geoTypeId="PROVINCE" wellKnownText="Kagoshima"/>
-    <Geo abbreviation="47" geoCode="47" geoId="JP-47" geoName="沖縄県" geoTypeId="PROVINCE" wellKnownText="Okinawa"/>
+    <Geo abbreviation="HK" geoCode="01" geoId="JP-01" geoName="北海道" geoTypeId="PROVINCE" wellKnownText="Hokkaido"/>
+    <Geo abbreviation="AO" geoCode="02" geoId="JP-02" geoName="青森県" geoTypeId="PROVINCE" wellKnownText="Aomori"/>
+    <Geo abbreviation="IT" geoCode="03" geoId="JP-03" geoName="岩手県" geoTypeId="PROVINCE" wellKnownText="Iwate"/>
+    <Geo abbreviation="MG" geoCode="04" geoId="JP-04" geoName="宮城県" geoTypeId="PROVINCE" wellKnownText="Miyagi"/>
+    <Geo abbreviation="AK" geoCode="05" geoId="JP-05" geoName="秋田県" geoTypeId="PROVINCE" wellKnownText="Akita"/>
+    <Geo abbreviation="YG" geoCode="06" geoId="JP-06" geoName="山形県" geoTypeId="PROVINCE" wellKnownText="Yamagata"/>
+    <Geo abbreviation="FS" geoCode="07" geoId="JP-07" geoName="福島県" geoTypeId="PROVINCE" wellKnownText="Fukushima"/>
+    <Geo abbreviation="IB" geoCode="08" geoId="JP-08" geoName="茨城県" geoTypeId="PROVINCE" wellKnownText="Ibaraki"/>
+    <Geo abbreviation="TC" geoCode="09" geoId="JP-09" geoName="栃木県" geoTypeId="PROVINCE" wellKnownText="Tochigi"/>
+    <Geo abbreviation="GU" geoCode="10" geoId="JP-10" geoName="群馬県" geoTypeId="PROVINCE" wellKnownText="Gunma"/>
+    <Geo abbreviation="ST" geoCode="11" geoId="JP-11" geoName="埼玉県" geoTypeId="PROVINCE" wellKnownText="Saitama"/>
+    <Geo abbreviation="CB" geoCode="12" geoId="JP-12" geoName="千葉県" geoTypeId="PROVINCE" wellKnownText="Chiba"/>
+    <Geo abbreviation="TY" geoCode="13" geoId="JP-13" geoName="東京都" geoTypeId="PROVINCE" wellKnownText="Tokyo"/>
+    <Geo abbreviation="KN" geoCode="14" geoId="JP-14" geoName="神奈川県" geoTypeId="PROVINCE" wellKnownText="Kanagawa"/>
+    <Geo abbreviation="NI" geoCode="15" geoId="JP-15" geoName="新潟県" geoTypeId="PROVINCE" wellKnownText="Niigata"/>
+    <Geo abbreviation="TM" geoCode="16" geoId="JP-16" geoName="富山県" geoTypeId="PROVINCE" wellKnownText="Toyama"/>
+    <Geo abbreviation="IS" geoCode="17" geoId="JP-17" geoName="石川県" geoTypeId="PROVINCE" wellKnownText="Ishikawa"/>
+    <Geo abbreviation="FI" geoCode="18" geoId="JP-18" geoName="福井県" geoTypeId="PROVINCE" wellKnownText="Fukui"/>
+    <Geo abbreviation="YN" geoCode="19" geoId="JP-19" geoName="山梨県" geoTypeId="PROVINCE" wellKnownText="Yamanashi"/>
+    <Geo abbreviation="NA" geoCode="20" geoId="JP-20" geoName="長野県" geoTypeId="PROVINCE" wellKnownText="Nagano"/>
+    <Geo abbreviation="GI" geoCode="21" geoId="JP-21" geoName="岐阜県" geoTypeId="PROVINCE" wellKnownText="Gifu"/>
+    <Geo abbreviation="SZ" geoCode="22" geoId="JP-22" geoName="静岡県" geoTypeId="PROVINCE" wellKnownText="Shizuoka"/>
+    <Geo abbreviation="AI" geoCode="23" geoId="JP-23" geoName="愛知県" geoTypeId="PROVINCE" wellKnownText="Aichi"/>
+    <Geo abbreviation="ME" geoCode="24" geoId="JP-24" geoName="三重県" geoTypeId="PROVINCE" wellKnownText="Mie"/>
+    <Geo abbreviation="SI" geoCode="25" geoId="JP-25" geoName="滋賀県" geoTypeId="PROVINCE" wellKnownText="Shiga"/>
+    <Geo abbreviation="KY" geoCode="26" geoId="JP-26" geoName="京都府" geoTypeId="PROVINCE" wellKnownText="Kyoto"/>
+    <Geo abbreviation="OS" geoCode="27" geoId="JP-27" geoName="大阪府" geoTypeId="PROVINCE" wellKnownText="Osaka"/>
+    <Geo abbreviation="HG" geoCode="28" geoId="JP-28" geoName="兵庫県" geoTypeId="PROVINCE" wellKnownText="Hyogo"/>
+    <Geo abbreviation="NR" geoCode="29" geoId="JP-29" geoName="奈良県" geoTypeId="PROVINCE" wellKnownText="Nara"/>
+    <Geo abbreviation="WA" geoCode="30" geoId="JP-30" geoName="和歌山県" geoTypeId="PROVINCE" wellKnownText="Wakayama"/>
+    <Geo abbreviation="TT" geoCode="31" geoId="JP-31" geoName="鳥取県" geoTypeId="PROVINCE" wellKnownText="Tottori"/>
+    <Geo abbreviation="SM" geoCode="32" geoId="JP-32" geoName="島根県" geoTypeId="PROVINCE" wellKnownText="Shimane"/>
+    <Geo abbreviation="OY" geoCode="33" geoId="JP-33" geoName="岡山県" geoTypeId="PROVINCE" wellKnownText="Okayama"/>
+    <Geo abbreviation="HS" geoCode="34" geoId="JP-34" geoName="広島県" geoTypeId="PROVINCE" wellKnownText="Hiroshima"/>
+    <Geo abbreviation="YA" geoCode="35" geoId="JP-35" geoName="山口県" geoTypeId="PROVINCE" wellKnownText="Yamaguchi"/>
+    <Geo abbreviation="TK" geoCode="36" geoId="JP-36" geoName="徳島県" geoTypeId="PROVINCE" wellKnownText="Tokushima"/>
+    <Geo abbreviation="KA" geoCode="37" geoId="JP-37" geoName="香川県" geoTypeId="PROVINCE" wellKnownText="Kagawa"/>
+    <Geo abbreviation="EH" geoCode="38" geoId="JP-38" geoName="愛媛県" geoTypeId="PROVINCE" wellKnownText="Ehime"/>
+    <Geo abbreviation="KO" geoCode="39" geoId="JP-39" geoName="高知県" geoTypeId="PROVINCE" wellKnownText="Kochi"/>
+    <Geo abbreviation="FO" geoCode="40" geoId="JP-40" geoName="福岡県" geoTypeId="PROVINCE" wellKnownText="Fukuoka"/>
+    <Geo abbreviation="SG" geoCode="41" geoId="JP-41" geoName="佐賀県" geoTypeId="PROVINCE" wellKnownText="Saga"/>
+    <Geo abbreviation="NS" geoCode="42" geoId="JP-42" geoName="長崎県" geoTypeId="PROVINCE" wellKnownText="Nagasaki"/>
+    <Geo abbreviation="KU" geoCode="43" geoId="JP-43" geoName="熊本県" geoTypeId="PROVINCE" wellKnownText="Kumamoto"/>
+    <Geo abbreviation="OI" geoCode="44" geoId="JP-44" geoName="大分県" geoTypeId="PROVINCE" wellKnownText="Oita"/>
+    <Geo abbreviation="MZ" geoCode="45" geoId="JP-45" geoName="宮崎県" geoTypeId="PROVINCE" wellKnownText="Miyazaki"/>
+    <Geo abbreviation="KG" geoCode="46" geoId="JP-46" geoName="鹿児島県" geoTypeId="PROVINCE" wellKnownText="Kagoshima"/>
+    <Geo abbreviation="OK" geoCode="47" geoId="JP-47" geoName="沖縄県" geoTypeId="PROVINCE" wellKnownText="Okinawa"/>
 
     <GeoAssoc geoId="JPN" geoIdTo="JP-01" geoAssocTypeId="REGIONS"/>
     <GeoAssoc geoId="JPN" geoIdTo="JP-02" geoAssocTypeId="REGIONS"/>

Modified: ofbiz/trunk/specialpurpose/ecommerce/groovyScripts/customer/ViewProfile.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/groovyScripts/customer/ViewProfile.groovy?rev=1760406&r1=1760405&r2=1760406&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ecommerce/groovyScripts/customer/ViewProfile.groovy (original)
+++ ofbiz/trunk/specialpurpose/ecommerce/groovyScripts/customer/ViewProfile.groovy Mon Sep 12 16:47:53 2016
@@ -86,4 +86,18 @@ if (userLogin) {
 
     partyAndContactMechList = from("PartyAndContactMech").where("partyId", partyId).orderBy("-fromDate").filterByDate().queryList();
     context.partyAndContactMechList = partyAndContactMechList;
+    
+    // state/province & country's name
+    if (partyContactMechValueMaps) {
+        partyContactMechValueMaps.each {
+            if (it.postalAddress) {
+                postalAddress = it.postalAddress;
+                countryGeo = postalAddress.getRelatedOne("CountryGeo", false);
+                if (countryGeo) it.countryGeoName = countryGeo.getString("geoName");
+                stateProvinceGeo = postalAddress.getRelatedOne("StateProvinceGeo", false);
+                if (stateProvinceGeo) it.stateProvinceGeoName = stateProvinceGeo.getString("geoName");
+                
+            }
+        }
+    }
 }

Modified: ofbiz/trunk/specialpurpose/ecommerce/template/customer/ViewProfile.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/template/customer/ViewProfile.ftl?rev=1760406&r1=1760405&r2=1760406&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ecommerce/template/customer/ViewProfile.ftl (original)
+++ ofbiz/trunk/specialpurpose/ecommerce/template/customer/ViewProfile.ftl Mon Sep 12 16:47:53 2016
@@ -154,8 +154,8 @@ under the License.
                     <#if postalAddress.attnName?has_content>${uiLabelMap.PartyAddrAttnName}: ${postalAddress.attnName}<br /></#if>
                     ${postalAddress.address1}<br />
                     <#if postalAddress.address2?has_content>${postalAddress.address2}<br /></#if>
-                    ${postalAddress.city}<#if postalAddress.stateProvinceGeoId?has_content>,&nbsp;${postalAddress.stateProvinceGeoId}</#if>&nbsp;${postalAddress.postalCode!}
-                    <#if postalAddress.countryGeoId?has_content><br />${postalAddress.countryGeoId}</#if>
+                    ${postalAddress.city}<#if partyContactMechValueMap.stateProvinceGeoName?has_content>,&nbsp;${partyContactMechValueMap.stateProvinceGeoName}</#if>&nbsp;${postalAddress.postalCode!}
+                    <#if partyContactMechValueMap.countryGeoName?has_content><br />${partyContactMechValueMap.countryGeoName}</#if>
                     <#if (!postalAddress.countryGeoId?has_content || postalAddress.countryGeoId! = "USA")>
                       <#assign addr1 = postalAddress.address1! />
                       <#if (addr1.indexOf(" ") > 0)>