You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by sa...@apache.org on 2011/06/27 13:01:06 UTC

svn commit: r1140103 - in /ofbiz/trunk/framework/common: data/GeoData.xml entitydef/entitymodel.xml src/org/ofbiz/common/CommonWorkers.java

Author: sascharodekamp
Date: Mon Jun 27 11:01:06 2011
New Revision: 1140103

URL: http://svn.apache.org/viewvc?rev=1140103&view=rev
Log:
State dropdown only finds states and does not include county information (https://issues.apache.org/jira/browse/OFBIZ-4270) - I added a separte Entity which defines all countries which should show their states in the drop down list. It also checks states recursivly, to list all states (i.e.) for GB.


Orig Msg: If you are on this page https://demo-trunk.ofbiz.apache.org:8443/ecommerce/control/newcustomer select USA from the country drop down and it will display all the USA states, similarly it works just fine for Spain but if you try once again with either United Kingdom or France it will show "No States/Provinces exist".

Both UK and France have Counties saved in the datamodel but the form does not lookup in the correct location as they are not defined as State.

Modified:
    ofbiz/trunk/framework/common/data/GeoData.xml
    ofbiz/trunk/framework/common/entitydef/entitymodel.xml
    ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java

Modified: ofbiz/trunk/framework/common/data/GeoData.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/data/GeoData.xml?rev=1140103&r1=1140102&r2=1140103&view=diff
==============================================================================
--- ofbiz/trunk/framework/common/data/GeoData.xml (original)
+++ ofbiz/trunk/framework/common/data/GeoData.xml Mon Jun 27 11:01:06 2011
@@ -307,4 +307,11 @@ under the License.
     <GeoAssoc geoAssocTypeId="GROUP_MEMBER" geoIdTo="GBR" geoId="ENGL"/>
     <GeoAssoc geoAssocTypeId="GROUP_MEMBER" geoIdTo="GBR" geoId="NIRL"/>
     <GeoAssoc geoAssocTypeId="GROUP_MEMBER" geoIdTo="GBR" geoId="WALS"/>
+
+    <GeoWithState geoId="DEU" showStateList="1"/>
+    <GeoWithState geoId="GBR" showStateList="1"/>
+    <GeoWithState geoId="ENGL" showStateList="1"/>
+    <GeoWithState geoId="NIRL" showStateList="1"/>
+    <GeoWithState geoId="WALS" showStateList="1"/>
+    <GeoWithState geoId="SCOT" showStateList="1"/>
 </entity-engine-xml>

Modified: ofbiz/trunk/framework/common/entitydef/entitymodel.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/entitydef/entitymodel.xml?rev=1140103&r1=1140102&r2=1140103&view=diff
==============================================================================
--- ofbiz/trunk/framework/common/entitydef/entitymodel.xml (original)
+++ ofbiz/trunk/framework/common/entitydef/entitymodel.xml Mon Jun 27 11:01:06 2011
@@ -178,6 +178,15 @@ under the License.
         <key-map field-name="geoTypeId"/>
       </relation>
     </entity>
+    <entity entity-name="GeoWithState" package-name="org.ofbiz.common.geo" default-resource-name="CommonEntityLabels"
+        title="">
+        <field name="geoId" type="id-ne"></field>
+        <field name="showStateList" type="indicator"></field>
+        <prim-key field="geoId"/>
+        <relation rel-entity-name="Geo" type="one">
+            <key-map field-name="geoId"/>
+        </relation>
+    </entity>
     <entity entity-name="GeoAssoc" package-name="org.ofbiz.common.geo"
         title="Geographic Boundary Association Entity">
       <field name="geoId" type="id-ne"></field>
@@ -215,6 +224,20 @@ under the License.
             <key-map field-name="geoIdTo" rel-field-name="geoId"/>
         </view-link>
     </view-entity>
+    <view-entity entity-name="GeoAssocAndGeoToWithState" package-name="org.ofbiz.common.geo">
+        <member-entity entity-alias="GA" entity-name="GeoAssoc"/>
+        <member-entity entity-alias="GTO" entity-name="Geo"/>
+        <member-entity entity-alias="GWS" entity-name="GeoWithState"/>
+        <alias-all entity-alias="GTO"/>
+        <alias entity-alias="GA" name="geoIdFrom" field="geoId"/>
+        <alias entity-alias="GA" name="geoAssocTypeId"/>
+        <view-link entity-alias="GA"  rel-entity-alias="GTO">
+            <key-map field-name="geoIdTo"  rel-field-name="geoId"/>
+        </view-link>
+        <view-link entity-alias="GA"  rel-entity-alias="GWS">
+            <key-map field-name="geoId"  rel-field-name="geoId"/>
+        </view-link>
+    </view-entity>
     <entity entity-name="GeoAssocType" package-name="org.ofbiz.common.geo"
         title="Geographic Boundary Association Entity">
       <field name="geoAssocTypeId" type="id-ne"></field>

Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java?rev=1140103&r1=1140102&r2=1140103&view=diff
==============================================================================
--- ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java (original)
+++ ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java Mon Jun 27 11:01:06 2011
@@ -89,9 +89,8 @@ public class CommonWorkers {
 
     public static List<GenericValue> getStateList(Delegator delegator) {
         List<GenericValue> geoList = FastList.newInstance();
-        EntityCondition condition = EntityCondition.makeCondition(EntityOperator.OR,
-                EntityCondition.makeCondition("geoTypeId", "STATE"), EntityCondition.makeCondition("geoTypeId", "PROVINCE"),
-                EntityCondition.makeCondition("geoTypeId", "TERRITORY"), EntityCondition.makeCondition("geoTypeId", "MUNICIPALITY"));
+        EntityCondition condition = EntityCondition.makeCondition(EntityOperator.OR, EntityCondition.makeCondition("geoTypeId", "STATE"), EntityCondition.makeCondition("geoTypeId", "PROVINCE"), EntityCondition.makeCondition("geoTypeId", "TERRITORY"),
+                EntityCondition.makeCondition("geoTypeId", "MUNICIPALITY"));
         List<String> sortList = UtilMisc.toList("geoName");
         try {
             geoList = delegator.findList("Geo", condition, null, sortList, null, true);
@@ -113,14 +112,8 @@ public class CommonWorkers {
             // Load the system default country
             country = UtilProperties.getPropertyValue("general.properties", "country.geo.id.default");
         }
-        EntityCondition stateProvinceFindCond = EntityCondition.makeCondition(
-                EntityCondition.makeCondition("geoIdFrom", country),
-                EntityCondition.makeCondition("geoAssocTypeId", "REGIONS"),
-                EntityCondition.makeCondition(EntityOperator.OR,
-                        EntityCondition.makeCondition("geoTypeId", "STATE"),
-                        EntityCondition.makeCondition("geoTypeId", "PROVINCE"),
-                        EntityCondition.makeCondition("geoTypeId", "MUNICIPALITY"),
-                        EntityCondition.makeCondition("geoTypeId", "COUNTY")));
+
+        EntityCondition stateRegionFindCond = EntityCondition.makeCondition(EntityCondition.makeCondition("geoIdFrom", country));
 
         if (UtilValidate.isEmpty(listOrderBy)) {
             listOrderBy = "geoId";
@@ -129,7 +122,22 @@ public class CommonWorkers {
 
         List<GenericValue> geoList = FastList.newInstance();
         try {
-            geoList = delegator.findList("GeoAssocAndGeoTo", stateProvinceFindCond, null, sortList, null, true);
+            List<GenericValue> regionList = delegator.findList("GeoAssocAndGeoToWithState", stateRegionFindCond, null, sortList, null, true);
+            for (GenericValue region : regionList) {
+                if ("GROUP_MEMBER".equals(region.getString("geoAssocTypeId")) && "GROUP".equals(region.getString("geoTypeId")) && regionList.size() == 1) {
+                    List<GenericValue> tmpState = delegator.findList("GeoAssocAndGeoToWithState", EntityCondition.makeCondition("geoId", region.getString("geoIdFrom")), null, sortList, null, true);
+                    for (GenericValue state : tmpState) {
+                        geoList.addAll(getAssociatedStateList(delegator, state.getString("geoIdFrom"), listOrderBy));
+                    }
+                }
+            }
+
+            EntityCondition stateProvinceFindCond = EntityCondition.makeCondition(
+                    EntityCondition.makeCondition("geoIdFrom", country),
+                    EntityCondition.makeCondition("geoAssocTypeId", "REGIONS"),
+                    EntityCondition.makeCondition(EntityOperator.OR, EntityCondition.makeCondition("geoTypeId", "STATE"), EntityCondition.makeCondition("geoTypeId", "PROVINCE"), EntityCondition.makeCondition("geoTypeId", "MUNICIPALITY"),
+                            EntityCondition.makeCondition("geoTypeId", "COUNTY")));
+            geoList.addAll(delegator.findList("GeoAssocAndGeoToWithState", stateProvinceFindCond, null, sortList, null, true));
         } catch (GenericEntityException e) {
             Debug.logError(e, "Cannot lookup Geo", module);
         }



Re: svn commit: r1140103 - in /ofbiz/trunk/framework/common: data/GeoData.xml entitydef/entitymodel.xml src/org/ofbiz/common/CommonWorkers.java

Posted by Adam Heath <do...@brainfood.com>.
On 06/27/2011 06:01 AM, sascharodekamp@apache.org wrote:
> Author: sascharodekamp
> Date: Mon Jun 27 11:01:06 2011
> New Revision: 1140103
>
> URL: http://svn.apache.org/viewvc?rev=1140103&view=rev
> Log:
> State dropdown only finds states and does not include county information (https://issues.apache.org/jira/browse/OFBIZ-4270) - I added a separte Entity which defines all countries which should show their states in the drop down list. It also checks states recursivly, to list all states (i.e.) for GB.
>
>
> Orig Msg: If you are on this page https://demo-trunk.ofbiz.apache.org:8443/ecommerce/control/newcustomer select USA from the country drop down and it will display all the USA states, similarly it works just fine for Spain but if you try once again with either United Kingdom or France it will show "No States/Provinces exist".
>
> Both UK and France have Counties saved in the datamodel but the form does not lookup in the correct location as they are not defined as State.
>
> Modified:
>      ofbiz/trunk/framework/common/data/GeoData.xml
>      ofbiz/trunk/framework/common/entitydef/entitymodel.xml
>      ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java
>
> Modified: ofbiz/trunk/framework/common/entitydef/entitymodel.xml
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/entitydef/entitymodel.xml?rev=1140103&r1=1140102&r2=1140103&view=diff
> ==============================================================================
> --- ofbiz/trunk/framework/common/entitydef/entitymodel.xml (original)
> +++ ofbiz/trunk/framework/common/entitydef/entitymodel.xml Mon Jun 27 11:01:06 2011
> @@ -178,6 +178,15 @@ under the License.
>           <key-map field-name="geoTypeId"/>
>         </relation>
>       </entity>
> +<entity entity-name="GeoWithState" package-name="org.ofbiz.common.geo" default-resource-name="CommonEntityLabels"
> +        title="">

And the title would be?

ps: Just because this is my only comment on this commit, doesn't say 
anything about the rest of the changes.  I was doing some greps in the 
code base, fixing other entitydef titles, and saw this one, and 
thought I should respond directly to the commit.