Author: sascharodekamp
Date: Wed Aug 3 09:12:31 2011 New Revision: 1153402 URL: http://svn.apache.org/viewvc?rev=1153402&view=rev Log: Improvement: OFBIZ-4270 - State dropdown only finds states and does not include county information Reorganized and extend the Data structure, now it is possible to store additional country postal code regex data 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=1153402&r1=1153401&r2=1153402&view=diff ============================================================================== --- ofbiz/trunk/framework/common/data/GeoData.xml (original) +++ ofbiz/trunk/framework/common/data/GeoData.xml Wed Aug 3 09:12:31 2011 @@ -308,22 +308,23 @@ under the License. <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"/> - <GeoWithState geoId="USA" showStateList="1"/> - <GeoWithState geoId="CAN" showStateList="1"/> - <GeoWithState geoId="AUS" showStateList="1"/> - <GeoWithState geoId="BGR" showStateList="1"/> - <GeoWithState geoId="BRA" showStateList="1"/> - <GeoWithState geoId="CHN" showStateList="1"/> - <GeoWithState geoId="COL" showStateList="1"/> - <GeoWithState geoId="MEX" showStateList="1"/> - <GeoWithState geoId="NLD" showStateList="1"/> - <GeoWithState geoId="POL" showStateList="1"/> - <GeoWithState geoId="IND" showStateList="1"/> - <GeoWithState geoId="ITA" showStateList="1"/> + <CountryAddressFormat geoId="DEU" stateProvinceGeoAssocTypeId="REGIONS" requireStateProvinceId="" requirePostalCode="" postalCodeRegex="" hasPostalCodeExt="" requirePostalCodeExt="" addressFormat=""/> + <CountryAddressFormat geoId="GBR" stateProvinceGeoAssocTypeId="GROUP_MEMBER" requireStateProvinceId="" requirePostalCode="" postalCodeRegex="" hasPostalCodeExt="" requirePostalCodeExt="" addressFormat=""/> + <CountryAddressFormat geoId="ENGL" stateProvinceGeoAssocTypeId="REGIONS" requireStateProvinceId="" requirePostalCode="" postalCodeRegex="" hasPostalCodeExt="" requirePostalCodeExt="" addressFormat=""/> + <CountryAddressFormat geoId="NIRL" stateProvinceGeoAssocTypeId="REGIONS" requireStateProvinceId="" requirePostalCode="" postalCodeRegex="" hasPostalCodeExt="" requirePostalCodeExt="" addressFormat=""/> + <CountryAddressFormat geoId="WALS" stateProvinceGeoAssocTypeId="REGIONS" requireStateProvinceId="" requirePostalCode="" postalCodeRegex="" hasPostalCodeExt="" requirePostalCodeExt="" addressFormat=""/> + <CountryAddressFormat geoId="SCOT" stateProvinceGeoAssocTypeId="REGIONS" requireStateProvinceId="" requirePostalCode="" postalCodeRegex="" hasPostalCodeExt="" requirePostalCodeExt="" addressFormat=""/> + <CountryAddressFormat geoId="USA" stateProvinceGeoAssocTypeId="REGIONS" requireStateProvinceId="" requirePostalCode="" postalCodeRegex="" hasPostalCodeExt="" requirePostalCodeExt="" addressFormat=""/> + <CountryAddressFormat geoId="CAN" stateProvinceGeoAssocTypeId="REGIONS" requireStateProvinceId="" requirePostalCode="" postalCodeRegex="" hasPostalCodeExt="" requirePostalCodeExt="" addressFormat=""/> + <CountryAddressFormat geoId="AUS" stateProvinceGeoAssocTypeId="REGIONS" requireStateProvinceId="" requirePostalCode="" postalCodeRegex="" hasPostalCodeExt="" requirePostalCodeExt="" addressFormat=""/> + <CountryAddressFormat geoId="BGR" stateProvinceGeoAssocTypeId="REGIONS" requireStateProvinceId="" requirePostalCode="" postalCodeRegex="" hasPostalCodeExt="" requirePostalCodeExt="" addressFormat=""/> + <CountryAddressFormat geoId="BRA" stateProvinceGeoAssocTypeId="REGIONS" requireStateProvinceId="" requirePostalCode="" postalCodeRegex="" hasPostalCodeExt="" requirePostalCodeExt="" addressFormat=""/> + <CountryAddressFormat geoId="CHN" stateProvinceGeoAssocTypeId="REGIONS" requireStateProvinceId="" requirePostalCode="" postalCodeRegex="" hasPostalCodeExt="" requirePostalCodeExt="" addressFormat=""/> + <CountryAddressFormat geoId="COL" stateProvinceGeoAssocTypeId="REGIONS" requireStateProvinceId="" requirePostalCode="" postalCodeRegex="" hasPostalCodeExt="" requirePostalCodeExt="" addressFormat=""/> + <CountryAddressFormat geoId="MEX" stateProvinceGeoAssocTypeId="REGIONS" requireStateProvinceId="" requirePostalCode="" postalCodeRegex="" hasPostalCodeExt="" requirePostalCodeExt="" addressFormat=""/> + <CountryAddressFormat geoId="NLD" stateProvinceGeoAssocTypeId="REGIONS" requireStateProvinceId="" requirePostalCode="" postalCodeRegex="" hasPostalCodeExt="" requirePostalCodeExt="" addressFormat=""/> + <CountryAddressFormat geoId="POL" stateProvinceGeoAssocTypeId="REGIONS" requireStateProvinceId="" requirePostalCode="" postalCodeRegex="" hasPostalCodeExt="" requirePostalCodeExt="" addressFormat=""/> + <CountryAddressFormat geoId="IND" stateProvinceGeoAssocTypeId="REGIONS" requireStateProvinceId="" requirePostalCode="" postalCodeRegex="" hasPostalCodeExt="" requirePostalCodeExt="" addressFormat=""/> + <CountryAddressFormat geoId="ITA" stateProvinceGeoAssocTypeId="REGIONS" requireStateProvinceId="" requirePostalCode="" postalCodeRegex="" hasPostalCodeExt="" requirePostalCodeExt="" addressFormat=""/> + <CountryAddressFormat geoId="FRA" stateProvinceGeoAssocTypeId="null" requireStateProvinceId="" requirePostalCode="" postalCodeRegex="" hasPostalCodeExt="" requirePostalCodeExt="" addressFormat=""/> </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=1153402&r1=1153401&r2=1153402&view=diff ============================================================================== --- ofbiz/trunk/framework/common/entitydef/entitymodel.xml (original) +++ ofbiz/trunk/framework/common/entitydef/entitymodel.xml Wed Aug 3 09:12:31 2011 @@ -164,6 +164,24 @@ under the License. <key-map field-name="countryCode"/> </view-link> </view-entity> + <entity entity-name="CountryAddressFormat" package-name="org.ofbiz.common.geo" default-resource-name="CommonEntityLabels" + title=""> + <field name="geoId" type="id-ne"></field> + <field name="stateProvinceGeoAssocTypeId" type="id"></field> + <field name="requireStateProvinceId" type="id"></field> + <field name="requirePostalCode" type="indicator"></field> + <field name="postalCodeRegex" type="long-varchar"></field> + <field name="hasPostalCodeExt" type="indicator"></field> + <field name="requirePostalCodeExt" type="indicator"></field> + <field name="addressFormat" type="long-varchar"></field> + <prim-key field="geoId"/> + <relation rel-entity-name="Geo" type="one"> + <key-map field-name="geoId"/> + </relation> + <relation type="one" fk-name="CNY_ADR_GEO_TYPE" rel-entity-name="GeoAssocType" > + <key-map field-name="geoAssocTypeId" rel-field-name="stateProvinceGeoAssocTypeId"/> + </relation> + </entity> <entity entity-name="Geo" package-name="org.ofbiz.common.geo" default-resource-name="CommonEntityLabels" title="Geographic Boundary Entity"> <field name="geoId" type="id-ne"></field> @@ -178,15 +196,6 @@ 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> @@ -227,7 +236,7 @@ under the License. <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"/> + <member-entity entity-alias="GWS" entity-name="CountryAddressFormat"/> <alias-all entity-alias="GTO"/> <alias entity-alias="GA" name="geoIdFrom" field="geoId"/> <alias entity-alias="GA" name="geoAssocTypeId"/> @@ -236,6 +245,7 @@ under the License. </view-link> <view-link entity-alias="GA" rel-entity-alias="GWS"> <key-map field-name="geoId" rel-field-name="geoId"/> + <key-map field-name="geoAssocTypeId" rel-field-name="stateProvinceGeoAssocTypeId"/> </view-link> </view-entity> <entity entity-name="GeoAssocType" package-name="org.ofbiz.common.geo" 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=1153402&r1=1153401&r2=1153402&view=diff ============================================================================== --- ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java (original) +++ ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java Wed Aug 3 09:12:31 2011 @@ -113,8 +113,6 @@ public class CommonWorkers { country = UtilProperties.getPropertyValue("general.properties", "country.geo.id.default"); } - EntityCondition stateRegionFindCond = EntityCondition.makeCondition(EntityCondition.makeCondition("geoIdFrom", country)); - if (UtilValidate.isEmpty(listOrderBy)) { listOrderBy = "geoId"; } @@ -122,16 +120,20 @@ public class CommonWorkers { List<GenericValue> geoList = FastList.newInstance(); try { + // Check if the country is a country group and get recursively the + // states + EntityCondition stateRegionFindCond = EntityCondition.makeCondition(EntityCondition.makeCondition("geoIdFrom", country), EntityCondition.makeCondition("geoAssocTypeId", "GROUP_MEMBER"), EntityCondition.makeCondition("geoTypeId", "GROUP")); 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); + if (regionList.size() == 1) { + for (GenericValue region : regionList) { + List<GenericValue> tmpState = delegator.findList("GeoAssocAndGeoTo", EntityCondition.makeCondition("geoId", region.getString("geoIdFrom")), null, sortList, null, true); for (GenericValue state : tmpState) { geoList.addAll(getAssociatedStateList(delegator, state.getString("geoIdFrom"), listOrderBy)); } } } + // get all related states EntityCondition stateProvinceFindCond = EntityCondition.makeCondition( EntityCondition.makeCondition("geoIdFrom", country), EntityCondition.makeCondition("geoAssocTypeId", "REGIONS"), |
Free forum by Nabble | Edit this page |