From 2ac16a22d252c658aa3f578afdf75c62a2ba476e Mon Sep 17 00:00:00 2001 From: mjudd Date: Sun, 24 Jun 2007 07:33:58 +0000 Subject: [PATCH] Feature Request http://sourceforge.net/tracker/index.php?func=detail&aid=1741222&group_id=176962&atid=879335 --- .../interfaces/PostcodeInterface.java | 59 ++ .../interfaces/PostcodeLookupInterface.java | 43 + base/src/org/adempiere/model/Postcode.java | 177 ++++ base/src/org/compiere/model/X_C_Country.java | 756 ++++++++++-------- .../org/compiere/grid/ed/VLocationDialog.java | 202 ++++- migration/320-trunk/014_postcode_lookup.sql | 62 ++ .../postgresql/014_postcode_lookup.sql | 62 ++ 7 files changed, 1027 insertions(+), 334 deletions(-) create mode 100644 base/src/org/adempiere/interfaces/PostcodeInterface.java create mode 100644 base/src/org/adempiere/interfaces/PostcodeLookupInterface.java create mode 100644 base/src/org/adempiere/model/Postcode.java create mode 100644 migration/320-trunk/014_postcode_lookup.sql create mode 100644 migration/320-trunk/postgresql/014_postcode_lookup.sql diff --git a/base/src/org/adempiere/interfaces/PostcodeInterface.java b/base/src/org/adempiere/interfaces/PostcodeInterface.java new file mode 100644 index 0000000000..fd790f9885 --- /dev/null +++ b/base/src/org/adempiere/interfaces/PostcodeInterface.java @@ -0,0 +1,59 @@ +/********************************************************************** + * This file is part of Adempiere ERP Bazaar * + * http://www.adempiere.org * + * * + * Copyright (C) Akuna Ltd. * + * Copyright (C) Contributors * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License * + * as published by the Free Software Foundation; either version 2 * + * of the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * + * MA 02110-1301, USA. * + * * + * Contributors: * + * - Michael Judd (mjudd@users.sf.net) * + **********************************************************************/ +package org.adempiere.interfaces; + + +/** + * Interfce for Postcode Lookup Web Service. + * http://sourceforge.net/tracker/index.php?func=detail&aid=1741222&group_id=176962&atid=879335 + * The Postcode Structure + */ +public interface PostcodeInterface +{ + public int size(); + + + public String getAddr(); + public void setAddr(String newAddr); + public String getStreet1(); + public void setStreet1(String newStreet1); + public String getStreet2(); + public void setStreet2(String newStreet2); + public String getStreet3(); + public void setStreet3(String newStreet3); + public String getStreet4(); + public void setStreet4(String newStreet4); + public String getCity(); + public void setCity(String newCity); + public String getRegion(); + public void setRegion(String newRegion); + public String getPostcode(); + public void setPostcode(String newPostcode); + public String getCountry(); + public void setCountry(String newCountry); + public String getCountryCode(); + public void setCountryCode(String newCountryCode); +} \ No newline at end of file diff --git a/base/src/org/adempiere/interfaces/PostcodeLookupInterface.java b/base/src/org/adempiere/interfaces/PostcodeLookupInterface.java new file mode 100644 index 0000000000..266b1c37ad --- /dev/null +++ b/base/src/org/adempiere/interfaces/PostcodeLookupInterface.java @@ -0,0 +1,43 @@ +/********************************************************************** + * This file is part of Adempiere ERP Bazaar * + * http://www.adempiere.org * + * * + * Copyright (C) Akuna Ltd. * + * Copyright (C) Contributors * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License * + * as published by the Free Software Foundation; either version 2 * + * of the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * + * MA 02110-1301, USA. * + * * + * Contributors: * + * - Michael Judd (mjudd@users.sf.net) * + **********************************************************************/ + +package org.adempiere.interfaces; + +import java.util.HashMap; + +/** + * Interfce for Postcode Lookup Web Service. + * http://sourceforge.net/tracker/index.php?func=detail&aid=1741222&group_id=176962&atid=879335 + * The Postcode lookup class interface + */ +public interface PostcodeLookupInterface { + public int lookupPostcode(String postcode); + public void setPassword(String password); + public void setClientID(String clientID); + public void setServerUrl(String serverUrl); + public HashMap getPostCodeData(); + public PostcodeLookupInterface newInstance(); +} diff --git a/base/src/org/adempiere/model/Postcode.java b/base/src/org/adempiere/model/Postcode.java new file mode 100644 index 0000000000..ead4544030 --- /dev/null +++ b/base/src/org/adempiere/model/Postcode.java @@ -0,0 +1,177 @@ +/********************************************************************** + * This file is part of Adempiere ERP Bazaar * + * http://www.adempiere.org * + * * + * Copyright (C) Akuna Group Ltd. * + * Copyright (C) Contributors * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License * + * as published by the Free Software Foundation; either version 2 * + * of the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * + * MA 02110-1301, USA. * + * * + * Contributors: * + * - Michael Judd (mjudd@users.sf.net) * + **********************************************************************/ + +package org.adempiere.model; + +import org.adempiere.interfaces.*; + +public class Postcode implements PostcodeInterface +{ + + // required implementation by interface + private String Street1; + private String Street2; + private String Street3; + private String Street4; + private String City; + private String Region; + private String Postcode; + private String Country; + + // UK Postcode specific + private String Addr; // Full address in one variable + private String CountryCode; // Two Letter ISO Country Code + private String TradCounty; // Traditional County (Region) + private String AdminCounty; // Administrative County + private String LonLocation; // London Location + + public int size() + { + return 1; + } + + public String getAddr() + { + return Addr; + } + + public void setAddr(String newAddr) + { + Addr = newAddr; + } + + public String getStreet1() + { + return Street1; + } + + public void setStreet1(String newStreet1) + { + Street1 = newStreet1; + } + public String getStreet2() + { + return Street2; + } + + public void setStreet2(String newStreet2) + { + Street2 = newStreet2; + } + public String getStreet3() + { + return Street3; + } + + public void setStreet3(String newStreet3) + { + Street3 = newStreet3; + } + public String getStreet4() + { + return Street4; + } + + public void setStreet4(String newStreet4) + { + Street4 = newStreet4; + } + + public String getCity() + { + return City; + } + + public void setCity(String newCity) + { + City = newCity; + } + + public String getRegion() + { + return Region; + } + + public void setRegion(String newRegion) + { + Region = newRegion; + } + public String getPostcode() + { + return Postcode; + } + + public void setPostcode(String newPostcode) + { + Postcode = newPostcode; + } + public String getCountry() + { + return Country; + } + + public void setCountry(String newCountry) + { + Country = newCountry; + } + public String getCountryCode() + { + return CountryCode; + } + + public void setCountryCode(String newCountryCode) + { + CountryCode = newCountryCode; + } + public String getTradCounty() + { + return TradCounty; + } + + public void setTradCounty(String newTradCounty) + { + TradCounty = newTradCounty; + } + public String getAdminCounty() + { + return AdminCounty; + } + + public void setAdminCounty(String newAdminCounty) + { + AdminCounty = newAdminCounty; + } + public String getLonLocation() + { + return LonLocation; + } + + public void setLonLocation(String newLonLocation) + { + LonLocation = newLonLocation; + } + +} diff --git a/base/src/org/compiere/model/X_C_Country.java b/base/src/org/compiere/model/X_C_Country.java index 7c93529490..e5896fd32f 100644 --- a/base/src/org/compiere/model/X_C_Country.java +++ b/base/src/org/compiere/model/X_C_Country.java @@ -1,475 +1,571 @@ /****************************************************************************** * Product: Adempiere ERP & CRM Smart Business Solution * * Copyright (C) 1999-2007 ComPiere, Inc. All Rights Reserved. * - * This program is free software; + * This program is free software; you can redistribute it and/or modify it * * under the terms version 2 of the GNU General Public License as published * * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; + * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * - * with this program; + * with this program; if not, write to the Free Software Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * * For the text or an alternative of this public license, you may reach us * * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * * or via info@compiere.org or http://www.compiere.org/license.html * *****************************************************************************/ -package org.compiere.model; +package org.compiere.model; /** Generated Model - DO NOT CHANGE */ -import java.util.*; -import java.sql.*; -import java.math.*; -import org.compiere.util.*; +import java.util.*; +import java.sql.*; +import java.math.*; +import org.compiere.util.*; /** Generated Model for C_Country * @author Adempiere (generated) * @version Release 3.2.0 - $Id$ */ -public class X_C_Country extends PO -{ +public class X_C_Country extends PO +{ /** Standard Constructor @param ctx context @param C_Country_ID id @param trxName transaction */ -public X_C_Country (Properties ctx, int C_Country_ID, String trxName) -{ -super (ctx, C_Country_ID, trxName); -/** if (C_Country_ID == 0) -{ -setC_Country_ID (0); -setCountryCode (null); -setDisplaySequence (null); // @C@, @R@ @P@ -setHasPostal_Add (false); -setHasRegion (false); -setIsAddressLinesLocalReverse (false); -setIsAddressLinesReverse (false); -setName (null); -} +public X_C_Country (Properties ctx, int C_Country_ID, String trxName) +{ +super (ctx, C_Country_ID, trxName); +/** if (C_Country_ID == 0) +{ +setC_Country_ID (0); +setCountryCode (null); +setDisplaySequence (null); // @C@, @R@ @P@ +setHasPostal_Add (false); +setHasRegion (false); +setIsAddressLinesLocalReverse (false); +setIsAddressLinesReverse (false); +setName (null); +} */ -} +} /** Load Constructor @param ctx context @param rs result set @param trxName transaction */ -public X_C_Country (Properties ctx, ResultSet rs, String trxName) -{ -super (ctx, rs, trxName); -} -/** AD_Table_ID=170 */ -public static final int Table_ID=MTable.getTable_ID("C_Country"); - +public X_C_Country (Properties ctx, ResultSet rs, String trxName) +{ +super (ctx, rs, trxName); +} /** TableName=C_Country */ -public static final String Table_Name="C_Country"; +public static final String Table_Name="C_Country"; -protected static KeyNamePair Model = new KeyNamePair(Table_ID,"C_Country"); +/** AD_Table_ID=170 */ +public static final int Table_ID=MTable.getTable_ID(Table_Name); -protected BigDecimal accessLevel = BigDecimal.valueOf(6); +protected static KeyNamePair Model = new KeyNamePair(Table_ID, Table_Name); + +protected BigDecimal accessLevel = BigDecimal.valueOf(6); /** AccessLevel @return 6 - System - Client */ -protected int get_AccessLevel() -{ -return accessLevel.intValue(); -} +protected int get_AccessLevel() +{ +return accessLevel.intValue(); +} /** Load Meta Data @param ctx context @return PO Info */ -protected POInfo initPO (Properties ctx) -{ -POInfo poi = POInfo.getPOInfo (ctx, Table_ID); -return poi; -} +protected POInfo initPO (Properties ctx) +{ +POInfo poi = POInfo.getPOInfo (ctx, Table_ID); +return poi; +} /** Info @return info */ -public String toString() -{ -StringBuffer sb = new StringBuffer ("X_C_Country[").append(get_ID()).append("]"); -return sb.toString(); -} +public String toString() +{ +StringBuffer sb = new StringBuffer ("X_C_Country[").append(get_ID()).append("]"); +return sb.toString(); +} /** AD_Language AD_Reference_ID=106 */ -public static final int AD_LANGUAGE_AD_Reference_ID=106; +public static final int AD_LANGUAGE_AD_Reference_ID=106; /** Set Language. @param AD_Language Language for this entity */ -public void setAD_Language (String AD_Language) -{ -if (AD_Language != null && AD_Language.length() > 6) -{ -log.warning("Length > 6 - truncated"); -AD_Language = AD_Language.substring(0,5); -} -set_Value ("AD_Language", AD_Language); -} +public void setAD_Language (String AD_Language) +{ +if (AD_Language != null && AD_Language.length() > 6) +{ +log.warning("Length > 6 - truncated"); +AD_Language = AD_Language.substring(0,5); +} +set_Value ("AD_Language", AD_Language); +} /** Get Language. @return Language for this entity */ -public String getAD_Language() -{ -return (String)get_Value("AD_Language"); -} +public String getAD_Language() +{ +return (String)get_Value("AD_Language"); +} /** Column name AD_Language */ -public static final String COLUMNNAME_AD_Language = "AD_Language"; +public static final String COLUMNNAME_AD_Language = "AD_Language"; /** Set Country. @param C_Country_ID Country */ -public void setC_Country_ID (int C_Country_ID) -{ -if (C_Country_ID < 1) throw new IllegalArgumentException ("C_Country_ID is mandatory."); -set_ValueNoCheck ("C_Country_ID", Integer.valueOf(C_Country_ID)); -} +public void setC_Country_ID (int C_Country_ID) +{ +if (C_Country_ID < 1) throw new IllegalArgumentException ("C_Country_ID is mandatory."); +set_ValueNoCheck ("C_Country_ID", Integer.valueOf(C_Country_ID)); +} /** Get Country. @return Country */ -public int getC_Country_ID() -{ -Integer ii = (Integer)get_Value("C_Country_ID"); -if (ii == null) return 0; -return ii.intValue(); -} +public int getC_Country_ID() +{ +Integer ii = (Integer)get_Value("C_Country_ID"); +if (ii == null) return 0; +return ii.intValue(); +} /** Column name C_Country_ID */ -public static final String COLUMNNAME_C_Country_ID = "C_Country_ID"; +public static final String COLUMNNAME_C_Country_ID = "C_Country_ID"; /** Set Currency. @param C_Currency_ID The Currency for this record */ -public void setC_Currency_ID (int C_Currency_ID) -{ -if (C_Currency_ID <= 0) set_Value ("C_Currency_ID", null); +public void setC_Currency_ID (int C_Currency_ID) +{ +if (C_Currency_ID <= 0) set_Value ("C_Currency_ID", null); else -set_Value ("C_Currency_ID", Integer.valueOf(C_Currency_ID)); -} +set_Value ("C_Currency_ID", Integer.valueOf(C_Currency_ID)); +} /** Get Currency. @return The Currency for this record */ -public int getC_Currency_ID() -{ -Integer ii = (Integer)get_Value("C_Currency_ID"); -if (ii == null) return 0; -return ii.intValue(); -} +public int getC_Currency_ID() +{ +Integer ii = (Integer)get_Value("C_Currency_ID"); +if (ii == null) return 0; +return ii.intValue(); +} /** Column name C_Currency_ID */ -public static final String COLUMNNAME_C_Currency_ID = "C_Currency_ID"; +public static final String COLUMNNAME_C_Currency_ID = "C_Currency_ID"; /** Set ISO Country Code. @param CountryCode Upper-case two-letter alphanumeric ISO Country code according to ISO 3166-1 - http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html */ -public void setCountryCode (String CountryCode) -{ -if (CountryCode == null) throw new IllegalArgumentException ("CountryCode is mandatory."); -if (CountryCode.length() > 2) -{ -log.warning("Length > 2 - truncated"); -CountryCode = CountryCode.substring(0,1); -} -set_Value ("CountryCode", CountryCode); -} +public void setCountryCode (String CountryCode) +{ +if (CountryCode == null) throw new IllegalArgumentException ("CountryCode is mandatory."); +if (CountryCode.length() > 2) +{ +log.warning("Length > 2 - truncated"); +CountryCode = CountryCode.substring(0,1); +} +set_Value ("CountryCode", CountryCode); +} /** Get ISO Country Code. @return Upper-case two-letter alphanumeric ISO Country code according to ISO 3166-1 - http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html */ -public String getCountryCode() -{ -return (String)get_Value("CountryCode"); -} +public String getCountryCode() +{ +return (String)get_Value("CountryCode"); +} /** Column name CountryCode */ -public static final String COLUMNNAME_CountryCode = "CountryCode"; +public static final String COLUMNNAME_CountryCode = "CountryCode"; /** Set Description. @param Description Optional short description of the record */ -public void setDescription (String Description) -{ -if (Description != null && Description.length() > 255) -{ -log.warning("Length > 255 - truncated"); -Description = Description.substring(0,254); -} -set_Value ("Description", Description); -} +public void setDescription (String Description) +{ +if (Description != null && Description.length() > 255) +{ +log.warning("Length > 255 - truncated"); +Description = Description.substring(0,254); +} +set_Value ("Description", Description); +} /** Get Description. @return Optional short description of the record */ -public String getDescription() -{ -return (String)get_Value("Description"); -} +public String getDescription() +{ +return (String)get_Value("Description"); +} /** Column name Description */ -public static final String COLUMNNAME_Description = "Description"; +public static final String COLUMNNAME_Description = "Description"; /** Set Address Print Format. @param DisplaySequence Format for printing this Address */ -public void setDisplaySequence (String DisplaySequence) -{ -if (DisplaySequence == null) throw new IllegalArgumentException ("DisplaySequence is mandatory."); -if (DisplaySequence.length() > 20) -{ -log.warning("Length > 20 - truncated"); -DisplaySequence = DisplaySequence.substring(0,19); -} -set_Value ("DisplaySequence", DisplaySequence); -} +public void setDisplaySequence (String DisplaySequence) +{ +if (DisplaySequence == null) throw new IllegalArgumentException ("DisplaySequence is mandatory."); +if (DisplaySequence.length() > 20) +{ +log.warning("Length > 20 - truncated"); +DisplaySequence = DisplaySequence.substring(0,19); +} +set_Value ("DisplaySequence", DisplaySequence); +} /** Get Address Print Format. @return Format for printing this Address */ -public String getDisplaySequence() -{ -return (String)get_Value("DisplaySequence"); -} +public String getDisplaySequence() +{ +return (String)get_Value("DisplaySequence"); +} /** Column name DisplaySequence */ -public static final String COLUMNNAME_DisplaySequence = "DisplaySequence"; +public static final String COLUMNNAME_DisplaySequence = "DisplaySequence"; /** Set Local Address Format. @param DisplaySequenceLocal Format for printing this Address locally */ -public void setDisplaySequenceLocal (String DisplaySequenceLocal) -{ -if (DisplaySequenceLocal != null && DisplaySequenceLocal.length() > 20) -{ -log.warning("Length > 20 - truncated"); -DisplaySequenceLocal = DisplaySequenceLocal.substring(0,19); -} -set_Value ("DisplaySequenceLocal", DisplaySequenceLocal); -} +public void setDisplaySequenceLocal (String DisplaySequenceLocal) +{ +if (DisplaySequenceLocal != null && DisplaySequenceLocal.length() > 20) +{ +log.warning("Length > 20 - truncated"); +DisplaySequenceLocal = DisplaySequenceLocal.substring(0,19); +} +set_Value ("DisplaySequenceLocal", DisplaySequenceLocal); +} /** Get Local Address Format. @return Format for printing this Address locally */ -public String getDisplaySequenceLocal() -{ -return (String)get_Value("DisplaySequenceLocal"); -} +public String getDisplaySequenceLocal() +{ +return (String)get_Value("DisplaySequenceLocal"); +} /** Column name DisplaySequenceLocal */ -public static final String COLUMNNAME_DisplaySequenceLocal = "DisplaySequenceLocal"; +public static final String COLUMNNAME_DisplaySequenceLocal = "DisplaySequenceLocal"; /** Set Bank Account No Format. @param ExpressionBankAccountNo Format of the Bank Account */ -public void setExpressionBankAccountNo (String ExpressionBankAccountNo) -{ -if (ExpressionBankAccountNo != null && ExpressionBankAccountNo.length() > 20) -{ -log.warning("Length > 20 - truncated"); -ExpressionBankAccountNo = ExpressionBankAccountNo.substring(0,19); -} -set_Value ("ExpressionBankAccountNo", ExpressionBankAccountNo); -} +public void setExpressionBankAccountNo (String ExpressionBankAccountNo) +{ +if (ExpressionBankAccountNo != null && ExpressionBankAccountNo.length() > 20) +{ +log.warning("Length > 20 - truncated"); +ExpressionBankAccountNo = ExpressionBankAccountNo.substring(0,19); +} +set_Value ("ExpressionBankAccountNo", ExpressionBankAccountNo); +} /** Get Bank Account No Format. @return Format of the Bank Account */ -public String getExpressionBankAccountNo() -{ -return (String)get_Value("ExpressionBankAccountNo"); -} +public String getExpressionBankAccountNo() +{ +return (String)get_Value("ExpressionBankAccountNo"); +} /** Column name ExpressionBankAccountNo */ -public static final String COLUMNNAME_ExpressionBankAccountNo = "ExpressionBankAccountNo"; +public static final String COLUMNNAME_ExpressionBankAccountNo = "ExpressionBankAccountNo"; /** Set Bank Routing No Format. @param ExpressionBankRoutingNo Format of the Bank Routing Number */ -public void setExpressionBankRoutingNo (String ExpressionBankRoutingNo) -{ -if (ExpressionBankRoutingNo != null && ExpressionBankRoutingNo.length() > 20) -{ -log.warning("Length > 20 - truncated"); -ExpressionBankRoutingNo = ExpressionBankRoutingNo.substring(0,19); -} -set_Value ("ExpressionBankRoutingNo", ExpressionBankRoutingNo); -} +public void setExpressionBankRoutingNo (String ExpressionBankRoutingNo) +{ +if (ExpressionBankRoutingNo != null && ExpressionBankRoutingNo.length() > 20) +{ +log.warning("Length > 20 - truncated"); +ExpressionBankRoutingNo = ExpressionBankRoutingNo.substring(0,19); +} +set_Value ("ExpressionBankRoutingNo", ExpressionBankRoutingNo); +} /** Get Bank Routing No Format. @return Format of the Bank Routing Number */ -public String getExpressionBankRoutingNo() -{ -return (String)get_Value("ExpressionBankRoutingNo"); -} +public String getExpressionBankRoutingNo() +{ +return (String)get_Value("ExpressionBankRoutingNo"); +} /** Column name ExpressionBankRoutingNo */ -public static final String COLUMNNAME_ExpressionBankRoutingNo = "ExpressionBankRoutingNo"; +public static final String COLUMNNAME_ExpressionBankRoutingNo = "ExpressionBankRoutingNo"; /** Set Phone Format. -@param ExpressionPhone Format of the phone; +@param ExpressionPhone Format of the phone; Can contain fixed format elements, Variables: "_lLoOaAcCa09" */ -public void setExpressionPhone (String ExpressionPhone) -{ -if (ExpressionPhone != null && ExpressionPhone.length() > 20) -{ -log.warning("Length > 20 - truncated"); -ExpressionPhone = ExpressionPhone.substring(0,19); -} -set_Value ("ExpressionPhone", ExpressionPhone); -} +public void setExpressionPhone (String ExpressionPhone) +{ +if (ExpressionPhone != null && ExpressionPhone.length() > 20) +{ +log.warning("Length > 20 - truncated"); +ExpressionPhone = ExpressionPhone.substring(0,19); +} +set_Value ("ExpressionPhone", ExpressionPhone); +} /** Get Phone Format. -@return Format of the phone; +@return Format of the phone; Can contain fixed format elements, Variables: "_lLoOaAcCa09" */ -public String getExpressionPhone() -{ -return (String)get_Value("ExpressionPhone"); -} +public String getExpressionPhone() +{ +return (String)get_Value("ExpressionPhone"); +} /** Column name ExpressionPhone */ -public static final String COLUMNNAME_ExpressionPhone = "ExpressionPhone"; +public static final String COLUMNNAME_ExpressionPhone = "ExpressionPhone"; /** Set Postal Code Format. -@param ExpressionPostal Format of the postal code; +@param ExpressionPostal Format of the postal code; Can contain fixed format elements, Variables: "_lLoOaAcCa09" */ -public void setExpressionPostal (String ExpressionPostal) -{ -if (ExpressionPostal != null && ExpressionPostal.length() > 20) -{ -log.warning("Length > 20 - truncated"); -ExpressionPostal = ExpressionPostal.substring(0,19); -} -set_Value ("ExpressionPostal", ExpressionPostal); -} +public void setExpressionPostal (String ExpressionPostal) +{ +if (ExpressionPostal != null && ExpressionPostal.length() > 20) +{ +log.warning("Length > 20 - truncated"); +ExpressionPostal = ExpressionPostal.substring(0,19); +} +set_Value ("ExpressionPostal", ExpressionPostal); +} /** Get Postal Code Format. -@return Format of the postal code; +@return Format of the postal code; Can contain fixed format elements, Variables: "_lLoOaAcCa09" */ -public String getExpressionPostal() -{ -return (String)get_Value("ExpressionPostal"); -} +public String getExpressionPostal() +{ +return (String)get_Value("ExpressionPostal"); +} /** Column name ExpressionPostal */ -public static final String COLUMNNAME_ExpressionPostal = "ExpressionPostal"; +public static final String COLUMNNAME_ExpressionPostal = "ExpressionPostal"; /** Set Additional Postal Format. -@param ExpressionPostal_Add Format of the value; +@param ExpressionPostal_Add Format of the value; Can contain fixed format elements, Variables: "_lLoOaAcCa09" */ -public void setExpressionPostal_Add (String ExpressionPostal_Add) -{ -if (ExpressionPostal_Add != null && ExpressionPostal_Add.length() > 20) -{ -log.warning("Length > 20 - truncated"); -ExpressionPostal_Add = ExpressionPostal_Add.substring(0,19); -} -set_Value ("ExpressionPostal_Add", ExpressionPostal_Add); -} +public void setExpressionPostal_Add (String ExpressionPostal_Add) +{ +if (ExpressionPostal_Add != null && ExpressionPostal_Add.length() > 20) +{ +log.warning("Length > 20 - truncated"); +ExpressionPostal_Add = ExpressionPostal_Add.substring(0,19); +} +set_Value ("ExpressionPostal_Add", ExpressionPostal_Add); +} /** Get Additional Postal Format. -@return Format of the value; +@return Format of the value; Can contain fixed format elements, Variables: "_lLoOaAcCa09" */ -public String getExpressionPostal_Add() -{ -return (String)get_Value("ExpressionPostal_Add"); -} +public String getExpressionPostal_Add() +{ +return (String)get_Value("ExpressionPostal_Add"); +} /** Column name ExpressionPostal_Add */ -public static final String COLUMNNAME_ExpressionPostal_Add = "ExpressionPostal_Add"; +public static final String COLUMNNAME_ExpressionPostal_Add = "ExpressionPostal_Add"; /** Set Additional Postal code. @param HasPostal_Add Has Additional Postal Code */ -public void setHasPostal_Add (boolean HasPostal_Add) -{ -set_Value ("HasPostal_Add", Boolean.valueOf(HasPostal_Add)); -} +public void setHasPostal_Add (boolean HasPostal_Add) +{ +set_Value ("HasPostal_Add", Boolean.valueOf(HasPostal_Add)); +} /** Get Additional Postal code. @return Has Additional Postal Code */ -public boolean isHasPostal_Add() -{ -Object oo = get_Value("HasPostal_Add"); -if (oo != null) -{ - if (oo instanceof Boolean) return ((Boolean)oo).booleanValue(); - return "Y".equals(oo); -} -return false; -} +public boolean isHasPostal_Add() +{ +Object oo = get_Value("HasPostal_Add"); +if (oo != null) +{ + if (oo instanceof Boolean) return ((Boolean)oo).booleanValue(); + return "Y".equals(oo); +} +return false; +} /** Column name HasPostal_Add */ -public static final String COLUMNNAME_HasPostal_Add = "HasPostal_Add"; +public static final String COLUMNNAME_HasPostal_Add = "HasPostal_Add"; /** Set Country has Region. @param HasRegion Country contains Regions */ -public void setHasRegion (boolean HasRegion) -{ -set_Value ("HasRegion", Boolean.valueOf(HasRegion)); -} +public void setHasRegion (boolean HasRegion) +{ +set_Value ("HasRegion", Boolean.valueOf(HasRegion)); +} /** Get Country has Region. @return Country contains Regions */ -public boolean isHasRegion() -{ -Object oo = get_Value("HasRegion"); -if (oo != null) -{ - if (oo instanceof Boolean) return ((Boolean)oo).booleanValue(); - return "Y".equals(oo); -} -return false; -} +public boolean isHasRegion() +{ +Object oo = get_Value("HasRegion"); +if (oo != null) +{ + if (oo instanceof Boolean) return ((Boolean)oo).booleanValue(); + return "Y".equals(oo); +} +return false; +} /** Column name HasRegion */ -public static final String COLUMNNAME_HasRegion = "HasRegion"; +public static final String COLUMNNAME_HasRegion = "HasRegion"; /** Set Reverse Local Address Lines. @param IsAddressLinesLocalReverse Print Local Address in reverse Order */ -public void setIsAddressLinesLocalReverse (boolean IsAddressLinesLocalReverse) -{ -set_Value ("IsAddressLinesLocalReverse", Boolean.valueOf(IsAddressLinesLocalReverse)); -} +public void setIsAddressLinesLocalReverse (boolean IsAddressLinesLocalReverse) +{ +set_Value ("IsAddressLinesLocalReverse", Boolean.valueOf(IsAddressLinesLocalReverse)); +} /** Get Reverse Local Address Lines. @return Print Local Address in reverse Order */ -public boolean isAddressLinesLocalReverse() -{ -Object oo = get_Value("IsAddressLinesLocalReverse"); -if (oo != null) -{ - if (oo instanceof Boolean) return ((Boolean)oo).booleanValue(); - return "Y".equals(oo); -} -return false; -} +public boolean isAddressLinesLocalReverse() +{ +Object oo = get_Value("IsAddressLinesLocalReverse"); +if (oo != null) +{ + if (oo instanceof Boolean) return ((Boolean)oo).booleanValue(); + return "Y".equals(oo); +} +return false; +} /** Column name IsAddressLinesLocalReverse */ -public static final String COLUMNNAME_IsAddressLinesLocalReverse = "IsAddressLinesLocalReverse"; +public static final String COLUMNNAME_IsAddressLinesLocalReverse = "IsAddressLinesLocalReverse"; /** Set Reverse Address Lines. @param IsAddressLinesReverse Print Address in reverse Order */ -public void setIsAddressLinesReverse (boolean IsAddressLinesReverse) -{ -set_Value ("IsAddressLinesReverse", Boolean.valueOf(IsAddressLinesReverse)); -} +public void setIsAddressLinesReverse (boolean IsAddressLinesReverse) +{ +set_Value ("IsAddressLinesReverse", Boolean.valueOf(IsAddressLinesReverse)); +} /** Get Reverse Address Lines. @return Print Address in reverse Order */ -public boolean isAddressLinesReverse() -{ -Object oo = get_Value("IsAddressLinesReverse"); -if (oo != null) -{ - if (oo instanceof Boolean) return ((Boolean)oo).booleanValue(); - return "Y".equals(oo); -} -return false; -} +public boolean isAddressLinesReverse() +{ +Object oo = get_Value("IsAddressLinesReverse"); +if (oo != null) +{ + if (oo instanceof Boolean) return ((Boolean)oo).booleanValue(); + return "Y".equals(oo); +} +return false; +} /** Column name IsAddressLinesReverse */ -public static final String COLUMNNAME_IsAddressLinesReverse = "IsAddressLinesReverse"; +public static final String COLUMNNAME_IsAddressLinesReverse = "IsAddressLinesReverse"; +/** Set IsPostcodeLookup. +@param IsPostcodeLookup IsPostcodeLookup */ +public void setIsPostcodeLookup (boolean IsPostcodeLookup) +{ +set_Value ("IsPostcodeLookup", Boolean.valueOf(IsPostcodeLookup)); +} +/** Get IsPostcodeLookup. +@return IsPostcodeLookup */ +public boolean isPostcodeLookup() +{ +Object oo = get_Value("IsPostcodeLookup"); +if (oo != null) +{ + if (oo instanceof Boolean) return ((Boolean)oo).booleanValue(); + return "Y".equals(oo); +} +return false; +} +/** Column name IsPostcodeLookup */ +public static final String COLUMNNAME_IsPostcodeLookup = "IsPostcodeLookup"; +/** Set LookupClassName. +@param LookupClassName LookupClassName */ +public void setLookupClassName (String LookupClassName) +{ +if (LookupClassName != null && LookupClassName.length() > 255) +{ +log.warning("Length > 255 - truncated"); +LookupClassName = LookupClassName.substring(0,254); +} +set_Value ("LookupClassName", LookupClassName); +} +/** Get LookupClassName. +@return LookupClassName */ +public String getLookupClassName() +{ +return (String)get_Value("LookupClassName"); +} +/** Column name LookupClassName */ +public static final String COLUMNNAME_LookupClassName = "LookupClassName"; +/** Set LookupClientID. +@param LookupClientID LookupClientID */ +public void setLookupClientID (String LookupClientID) +{ +if (LookupClientID != null && LookupClientID.length() > 50) +{ +log.warning("Length > 50 - truncated"); +LookupClientID = LookupClientID.substring(0,49); +} +set_Value ("LookupClientID", LookupClientID); +} +/** Get LookupClientID. +@return LookupClientID */ +public String getLookupClientID() +{ +return (String)get_Value("LookupClientID"); +} +/** Column name LookupClientID */ +public static final String COLUMNNAME_LookupClientID = "LookupClientID"; +/** Set LookupPassword. +@param LookupPassword LookupPassword */ +public void setLookupPassword (String LookupPassword) +{ +if (LookupPassword != null && LookupPassword.length() > 50) +{ +log.warning("Length > 50 - truncated"); +LookupPassword = LookupPassword.substring(0,49); +} +set_Value ("LookupPassword", LookupPassword); +} +/** Get LookupPassword. +@return LookupPassword */ +public String getLookupPassword() +{ +return (String)get_Value("LookupPassword"); +} +/** Column name LookupPassword */ +public static final String COLUMNNAME_LookupPassword = "LookupPassword"; +/** Set LookupUrl. +@param LookupUrl LookupUrl */ +public void setLookupUrl (String LookupUrl) +{ +if (LookupUrl != null && LookupUrl.length() > 100) +{ +log.warning("Length > 100 - truncated"); +LookupUrl = LookupUrl.substring(0,99); +} +set_Value ("LookupUrl", LookupUrl); +} +/** Get LookupUrl. +@return LookupUrl */ +public String getLookupUrl() +{ +return (String)get_Value("LookupUrl"); +} +/** Column name LookupUrl */ +public static final String COLUMNNAME_LookupUrl = "LookupUrl"; /** Set Media Size. @param MediaSize Java Media Size */ -public void setMediaSize (String MediaSize) -{ -if (MediaSize != null && MediaSize.length() > 40) -{ -log.warning("Length > 40 - truncated"); -MediaSize = MediaSize.substring(0,39); -} -set_Value ("MediaSize", MediaSize); -} +public void setMediaSize (String MediaSize) +{ +if (MediaSize != null && MediaSize.length() > 40) +{ +log.warning("Length > 40 - truncated"); +MediaSize = MediaSize.substring(0,39); +} +set_Value ("MediaSize", MediaSize); +} /** Get Media Size. @return Java Media Size */ -public String getMediaSize() -{ -return (String)get_Value("MediaSize"); -} +public String getMediaSize() +{ +return (String)get_Value("MediaSize"); +} /** Column name MediaSize */ -public static final String COLUMNNAME_MediaSize = "MediaSize"; +public static final String COLUMNNAME_MediaSize = "MediaSize"; /** Set Name. @param Name Alphanumeric identifier of the entity */ -public void setName (String Name) -{ -if (Name == null) throw new IllegalArgumentException ("Name is mandatory."); -if (Name.length() > 60) -{ -log.warning("Length > 60 - truncated"); -Name = Name.substring(0,59); -} -set_Value ("Name", Name); -} +public void setName (String Name) +{ +if (Name == null) throw new IllegalArgumentException ("Name is mandatory."); +if (Name.length() > 60) +{ +log.warning("Length > 60 - truncated"); +Name = Name.substring(0,59); +} +set_Value ("Name", Name); +} /** Get Name. @return Alphanumeric identifier of the entity */ -public String getName() -{ -return (String)get_Value("Name"); -} +public String getName() +{ +return (String)get_Value("Name"); +} /** Get Record ID/ColumnName @return ID/ColumnName pair -*/public KeyNamePair getKeyNamePair() -{ -return new KeyNamePair(get_ID(), getName()); -} +*/public KeyNamePair getKeyNamePair() +{ +return new KeyNamePair(get_ID(), getName()); +} /** Column name Name */ -public static final String COLUMNNAME_Name = "Name"; +public static final String COLUMNNAME_Name = "Name"; /** Set Region. @param RegionName Name of the Region */ -public void setRegionName (String RegionName) -{ -if (RegionName != null && RegionName.length() > 60) -{ -log.warning("Length > 60 - truncated"); -RegionName = RegionName.substring(0,59); -} -set_Value ("RegionName", RegionName); -} +public void setRegionName (String RegionName) +{ +if (RegionName != null && RegionName.length() > 60) +{ +log.warning("Length > 60 - truncated"); +RegionName = RegionName.substring(0,59); +} +set_Value ("RegionName", RegionName); +} /** Get Region. @return Name of the Region */ -public String getRegionName() -{ -return (String)get_Value("RegionName"); -} +public String getRegionName() +{ +return (String)get_Value("RegionName"); +} /** Column name RegionName */ -public static final String COLUMNNAME_RegionName = "RegionName"; -} +public static final String COLUMNNAME_RegionName = "RegionName"; +} diff --git a/client/src/org/compiere/grid/ed/VLocationDialog.java b/client/src/org/compiere/grid/ed/VLocationDialog.java index 6fbb22f7d8..23e5bf3bb2 100644 --- a/client/src/org/compiere/grid/ed/VLocationDialog.java +++ b/client/src/org/compiere/grid/ed/VLocationDialog.java @@ -26,6 +26,9 @@ import org.compiere.model.*; import org.compiere.swing.*; import org.compiere.util.*; +import org.adempiere.interfaces.*; +import org.adempiere.model.*; + /** * Dialog to enter Location Info (Address) * @@ -35,6 +38,15 @@ import org.compiere.util.*; public class VLocationDialog extends CDialog implements ActionListener { + + /** Lookup result */ + //private Object[][] data = null; + + /** Lookup result header */ + private Object[] header = null; + + //private int m_WindowNo = 0; + /** * Constructor * @@ -45,6 +57,7 @@ public class VLocationDialog extends CDialog public VLocationDialog (Frame frame, String title, MLocation location) { super(frame, title, true); + //m_WindowNo = WindowNo; try { jbInit(); @@ -61,7 +74,6 @@ public class VLocationDialog extends CDialog setTitle(Msg.getMsg(Env.getCtx(), "LocationNew")); else setTitle(Msg.getMsg(Env.getCtx(), "LocationUpdate")); - // Current Country MCountry.setDisplayLanguage(Env.getAD_Language(Env.getCtx())); @@ -76,7 +88,10 @@ public class VLocationDialog extends CDialog // initLocation(); fCountry.addActionListener(this); + fOnline.addActionListener(this); AEnv.positionCenterWindow(frame, this); + + } // VLocationDialog private boolean m_change = false; @@ -103,6 +118,7 @@ public class VLocationDialog extends CDialog private CLabel lRegion = new CLabel(Msg.getMsg(Env.getCtx(), "Region")); private CLabel lPostal = new CLabel(Msg.getMsg(Env.getCtx(), "Postal")); private CLabel lPostalAdd = new CLabel(Msg.getMsg(Env.getCtx(), "PostalAdd")); + private CLabel lOnline = new CLabel(""); // dummy to use addLine without error.... private CTextField fAddress1 = new CTextField(20); // length=60 private CTextField fAddress2 = new CTextField(20); // length=60 private CTextField fAddress3 = new CTextField(20); // length=60 @@ -112,6 +128,7 @@ public class VLocationDialog extends CDialog private CComboBox fRegion; private CTextField fPostal = new CTextField(5); // length=10 private CTextField fPostalAdd = new CTextField(5); // length=10 + private CButton fOnline = new CButton(); // private GridBagConstraints gbc = new GridBagConstraints(); private Insets labelInsets = new Insets(2,15,2,0); // top,left,bottom,right @@ -191,6 +208,10 @@ public class VLocationDialog extends CDialog else if (s.startsWith("R") && m_location.getCountry().isHasRegion()) addLine(line++, lRegion, fRegion); } + + + addLine(line++, lOnline, fOnline); + // Country Last addLine(line++, lCountry, fCountry); @@ -204,11 +225,19 @@ public class VLocationDialog extends CDialog fCity.setText(m_location.getCity()); fPostal.setText(m_location.getPostal()); fPostalAdd.setText(m_location.getPostal_Add()); + fOnline.setText(Msg.getMsg(Env.getCtx(), "Online")); if (m_location.getCountry().isHasRegion()) { lRegion.setText(m_location.getCountry().getRegionName()); fRegion.setSelectedItem(m_location.getRegion()); } + + // disable online if this country doesn't have post code lookup + if (m_location.getCountry().isPostcodeLookup()) + fOnline.setEnabled(true); + else + fOnline.setEnabled(false); + fCountry.setSelectedItem(country); } // Update UI @@ -237,7 +266,9 @@ public class VLocationDialog extends CDialog gbc.gridx = 1; gbc.weightx = 1.0; gbc.fill = GridBagConstraints.NONE; + gbc.insets = fieldInsets; mainPanel.add(field, gbc); + } // addLine @@ -265,11 +296,38 @@ public class VLocationDialog extends CDialog // Modifier for Mouse selection is 16 - for any key selection 0 MCountry c = (MCountry)fCountry.getSelectedItem(); m_location.setCountry(c); - // refrseh + + // refresh online button for new country + if (c.isPostcodeLookup()) + fOnline.setEnabled(true); + else + fOnline.setEnabled(false); + + // update the region name if regions are enabled for this country + if (c.isHasRegion()) + { + lRegion.setText(c.getRegionName()); + fRegion.setSelectedItem(m_location.getRegion()); + + // TODO: fix bug that occurs when the new region name is shorter than the old region name + } + + // refrseh mainPanel.removeAll(); + initLocation(); fCountry.requestFocus(); // allows to use Keybord selection } + else if (e.getSource() == fOnline) + { + + // check to see if we have a postcode lookup plugin for this country + MCountry c = (MCountry)fCountry.getSelectedItem(); + if (c.isPostcodeLookup()) + { + lookupPostcode(c, fPostal.getText()); + } + } } // actionPerformed /** @@ -294,7 +352,7 @@ public class VLocationDialog extends CDialog } else m_location.setC_Region_ID(0); - // Save chnages + // Save changes m_location.save(); } // actionOK @@ -315,5 +373,141 @@ public class VLocationDialog extends CDialog { return m_location; } // getValue - + /** + * lookupPostcode + * + * + * @param country + * @param postcode + * @return + */ + private String lookupPostcode(MCountry country, String postcode) + { + // Initialise the lookup class. + PostcodeLookupInterface pcLookup = null; + try { + PostcodeLookupInterface pcLookupTmp = (PostcodeLookupInterface) Class + .forName(country.getLookupClassName()).newInstance(); + pcLookup = pcLookupTmp.newInstance(); + } catch (Exception e) { + e.printStackTrace(); + return "lookupAddress(): " + e.getMessage(); + } + + // remove any spaces from the postcode and convert to upper case + postcode = postcode.replaceAll(" ", "").toUpperCase(); + log.fine("Looking up postcode: " + postcode); + + // Lookup postcode on server. + pcLookup.setServerUrl(country.getLookupUrl()); + pcLookup.setClientID(country.getLookupClientID()); + pcLookup.setPassword(country.getLookupPassword()); + if (pcLookup.lookupPostcode(postcode)==1){ + // Success + fillLocation(pcLookup.getPostCodeData(), country); + fAddress1.requestFocusInWindow(); + } else + return "Postcode Lookup Error"; + + return ""; + } + /** + * Fills the location field using the information retrieved from postcode + * servers. + * + * @param ctx + * Context + * @param pkeyData + * Lookup results + * @param windowNo + * Window No. + * @param tab + * Tab + * @param field + * Field + */ + private void fillLocation(HashMap postcodeData, MCountry country) { + + // If it's not empty warn the user. + if (fAddress1 != null || fAddress2 != null + || fAddress3 != null + || fAddress4 != null || fCity != null) { + String warningMsg = "Existing address information will be overwritten. Proceed?"; + String warningTitle = "Warning"; + int response = JOptionPane.showConfirmDialog(null, warningMsg, + warningTitle, JOptionPane.YES_NO_OPTION); + if (response == JOptionPane.NO_OPTION) + return; + } + + + Set pcodeKeys = postcodeData.keySet(); + Iterator iterator = pcodeKeys.iterator(); + header = null; + + // Allocate the header array + header = new Object[pcodeKeys.size()]; + + String headerStr = null; + + // need to check how many records returned + // TODO - check number of records returns - size() method is incorrect + if (pcodeKeys.size() > 2) + { + // TODO: Implement ResultData Grid and get return (for premises level data) + System.out.println("Too many postcodes returned from Postcode Lookup - need to Implement ResultData"); + } else + { + for (int i = 0; (headerStr = (iterator.hasNext() ? iterator.next() : null)) != null + || iterator.hasNext(); i++) { + header[i] = headerStr; + Postcode values = (Postcode) postcodeData.get(headerStr); + + // Overwrite the values in location field. + fAddress1.setText(values.getStreet1()); + fCity.setText(values.getCity()); + fPostal.setText(values.getPostcode()); + + // Do region lookup + if (country.isHasRegion()) + { + // get all regions for this country + MRegion[] regions = MRegion.getRegions(country.getCtx(), country.getC_Country_ID()); + + // If regions were loaded + if ( regions.length > 0) + { + // loop through regions array to attempt a region match - don't finish loop if region found + boolean found = false; + for (i = 0; i < regions.length && !found; i++) + { + + if (regions[i].getName().equals(values.getRegion()) ) + { + // found county + fRegion.setSelectedItem(regions[i]); + log.fine("Found region: " + regions[i].getName()); + found = true; + } + } + if (!found) + { + // add new region + MRegion region = new MRegion(country, values.getRegion()); + if (region.save()) + { + log.fine("Added new region from web service: " + values.getRegion()); + fRegion.setSelectedItem(values); + } else + log.severe("Error saving new region: " + region.getName()); + + } + } else + log.severe("Region lookup failed for Country: " + country.getName()); + + } + } + } + + } } // VLocationDialog diff --git a/migration/320-trunk/014_postcode_lookup.sql b/migration/320-trunk/014_postcode_lookup.sql new file mode 100644 index 0000000000..3325190f2b --- /dev/null +++ b/migration/320-trunk/014_postcode_lookup.sql @@ -0,0 +1,62 @@ +--- +-- Feature 1741222 - Add Post code lookup infrastructure +-- http://sourceforge.net/tracker/index.php?func=detail&aid=1741222&group_id=176962&atid=879335 +-- + +--- Modify C_COUNTRY Table +ALTER TABLE C_COUNTRY ADD + IsPostcodeLookup CHAR(1) DEFAULT 'N' NOT NULL; +ALTER TABLE C_COUNTRY ADD + LookupClassname VARCHAR(255) DEFAULT NULL NULL; +ALTER TABLE C_COUNTRY ADD + LookupClientID VARCHAR(50) DEFAULT NULL NULL; +ALTER TABLE C_COUNTRY ADD + LookupPassword VARCHAR(50) DEFAULT NULL NULL; +ALTER TABLE C_COUNTRY ADD + LookupUrl VARCHAR(100) DEFAULT NULL NULL; + +-- Add Postcode Constraint +ALTER TABLE C_COUNTRY ADD CHECK (IsPostcodeLookup IN ('Y','N')); + +-- Insert Element Definitions + +INSERT INTO ad_element VALUES (51000, 0, 0, 'Y', '2007-06-19 22:43:07', 100, '2007-06-19 23:09:22', 100, 'IsPostcodeLookup', 'D', 'IsPostcodeLookup', 'IsPostcodeLookup', NULL, NULL, NULL, NULL, NULL, NULL); +INSERT INTO ad_element VALUES (51001, 0, 0, 'Y', '2007-06-19 22:43:07', 100, '2007-06-19 23:09:54', 100, 'LookupClassName', 'D', 'LookupClassName', 'LookupClassName', NULL, NULL, NULL, NULL, NULL, NULL); +INSERT INTO ad_element VALUES (51002, 0, 0, 'Y', '2007-06-19 22:43:07', 100, '2007-06-19 23:10:06', 100, 'LookupClientID', 'D', 'LookupClientID', 'LookupClientID', NULL, NULL, NULL, NULL, NULL, NULL); +INSERT INTO ad_element VALUES (51003, 0, 0, 'Y', '2007-06-19 22:43:07', 100, '2007-06-19 23:10:19', 100, 'LookupUrl', 'D', 'LookupUrl', 'LookupUrl', NULL, NULL, NULL, NULL, NULL, NULL); +INSERT INTO ad_element VALUES (51004, 0, 0, 'Y', '2007-06-22 02:03:37', 100, '2007-06-22 02:04:31', 100, 'LookupPassword', 'D', 'LookupPassword', 'LookupPassword', NULL, NULL, NULL, NULL, NULL, NULL); + +-- Insert Column Definitions +INSERT INTO ad_column VALUES (51000, 0, 0, 'Y', '2007-06-19 22:43:07', '2007-06-19 23:14:47', 100, 100, 'IsPostcodeLookup', NULL, NULL, 0, 'D', 'IsPostcodeLookup', 170, 20, NULL, NULL, 1, 'N', 'N', 'N', 'N', 'Y', NULL, 'N', NULL, 'N', 'N', NULL, NULL, NULL, NULL, 'N', 51000, NULL, 'N', 'N', NULL, NULL); +INSERT INTO ad_column VALUES (51001, 0, 0, 'Y', '2007-06-19 22:43:07', '2007-06-19 23:04:48', 100, 100, 'LookupClassName', NULL, NULL, 0, 'D', 'LookupClassName', 170, 10, NULL, NULL, 255, NULL, 'N', 'N', 'N', 'Y', NULL, 'N', NULL, 'N', 'N', NULL, NULL, NULL, NULL, 'N', 51001, NULL, 'N', 'N', NULL, NULL); +INSERT INTO ad_column VALUES (51002, 0, 0, 'Y', '2007-06-19 22:43:07', '2007-06-19 23:04:48', 100, 100, 'LookupClientID', NULL, NULL, 0, 'D', 'LookupClientID', 170, 10, NULL, NULL, 50, NULL, 'N', 'N', 'N', 'Y', NULL, 'N', NULL, 'N', 'N', NULL, NULL, NULL, NULL, 'N', 51002, NULL, 'N', 'N', NULL, NULL); +INSERT INTO ad_column VALUES (51003, 0, 0, 'Y', '2007-06-19 22:43:07', '2007-06-19 23:04:48', 100, 100, 'LookupUrl', NULL, NULL, 0, 'D', 'LookupUrl', 170, 10, NULL, NULL, 100, NULL, 'N', 'N', 'N', 'Y', NULL, 'N', NULL, 'N', 'N', NULL, NULL, NULL, NULL, 'N', 51003, NULL, 'N', 'N', NULL, NULL); +INSERT INTO ad_column VALUES (51004, 0, 0, 'Y', '2007-06-22 02:03:37', '2007-06-22 02:05:17', 100, 100, 'LookupPassword', NULL, NULL, 0, 'D', 'LookupPassword', 170, 10, NULL, NULL, 50, NULL, 'N', 'N', 'N', 'Y', NULL, 'N', NULL, 'N', 'N', NULL, NULL, NULL, NULL, 'N', 51004, NULL, 'N', 'N', NULL, NULL); + +-- Insert Field Definitions +INSERT INTO ad_field VALUES (51000, 0, 0, 'Y', '2007-06-19 23:17:05', 100, '2007-06-19 23:17:05', 100, 'IsPostcodeLookup', NULL, NULL, 'Y', 135, 51000, NULL, 'Y', NULL, 1, 'N', 220, NULL, 'N', 'N', 'N', 'N', 'D', NULL, NULL, NULL); +INSERT INTO ad_field VALUES (51001, 0, 0, 'Y', '2007-06-19 23:17:06', 100, '2007-06-20 09:10:31', 100, 'LookupClassName', NULL, NULL, 'Y', 135, 51001, NULL, 'Y', '@IsPostcodeLookup@ = ''Y''', 255, 'N', 260, NULL, 'N', 'N', 'N', 'N', 'D', NULL, NULL, NULL); +INSERT INTO ad_field VALUES (51002, 0, 0, 'Y', '2007-06-19 23:17:06', 100, '2007-06-20 09:10:17', 100, 'LookupClientID', NULL, NULL, 'Y', 135, 51002, NULL, 'Y', '@IsPostcodeLookup@ = ''Y''', 50, 'N', 240, NULL, 'N', 'N', 'N', 'N', 'D', NULL, NULL, NULL); +INSERT INTO ad_field VALUES (51003, 0, 0, 'Y', '2007-06-19 23:17:06', 100, '2007-06-20 09:10:12', 100, 'LookupUrl', NULL, NULL, 'Y', 135, 51003, NULL, 'Y', '@IsPostcodeLookup@ = ''Y''', 100, 'N', 230, NULL, 'N', 'N', 'N', 'N', 'D', NULL, NULL, NULL); +INSERT INTO ad_field VALUES (51004, 0, 0, 'Y', '2007-06-19 23:17:06', 100, '2007-06-22 02:07:11', 100, 'LookupPassword', NULL, NULL, 'Y', 135, 51004, NULL, 'Y', '@IsPostcodeLookup@ = ''Y''', 50, 'N', 250, NULL, 'N', 'N', 'N', 'N', 'D', NULL, NULL, NULL); + +-- Update Sequences +UPDATE ad_sequence + SET currentnextsys = (SELECT MAX (ad_element_id) + 1 + FROM ad_element + WHERE ad_element_id < 1000000) + WHERE NAME = 'AD_Element'; + +UPDATE ad_sequence + SET currentnextsys = (SELECT MAX (ad_column_id) + 1 + FROM ad_column + WHERE ad_column_id < 1000000) + WHERE NAME = 'AD_Column'; + +UPDATE ad_sequence + SET currentnextsys = (SELECT MAX (ad_field_id) + 1 + FROM ad_field + WHERE ad_field_id < 1000000) + WHERE NAME = 'AD_Field'; + +COMMIT; \ No newline at end of file diff --git a/migration/320-trunk/postgresql/014_postcode_lookup.sql b/migration/320-trunk/postgresql/014_postcode_lookup.sql new file mode 100644 index 0000000000..3325190f2b --- /dev/null +++ b/migration/320-trunk/postgresql/014_postcode_lookup.sql @@ -0,0 +1,62 @@ +--- +-- Feature 1741222 - Add Post code lookup infrastructure +-- http://sourceforge.net/tracker/index.php?func=detail&aid=1741222&group_id=176962&atid=879335 +-- + +--- Modify C_COUNTRY Table +ALTER TABLE C_COUNTRY ADD + IsPostcodeLookup CHAR(1) DEFAULT 'N' NOT NULL; +ALTER TABLE C_COUNTRY ADD + LookupClassname VARCHAR(255) DEFAULT NULL NULL; +ALTER TABLE C_COUNTRY ADD + LookupClientID VARCHAR(50) DEFAULT NULL NULL; +ALTER TABLE C_COUNTRY ADD + LookupPassword VARCHAR(50) DEFAULT NULL NULL; +ALTER TABLE C_COUNTRY ADD + LookupUrl VARCHAR(100) DEFAULT NULL NULL; + +-- Add Postcode Constraint +ALTER TABLE C_COUNTRY ADD CHECK (IsPostcodeLookup IN ('Y','N')); + +-- Insert Element Definitions + +INSERT INTO ad_element VALUES (51000, 0, 0, 'Y', '2007-06-19 22:43:07', 100, '2007-06-19 23:09:22', 100, 'IsPostcodeLookup', 'D', 'IsPostcodeLookup', 'IsPostcodeLookup', NULL, NULL, NULL, NULL, NULL, NULL); +INSERT INTO ad_element VALUES (51001, 0, 0, 'Y', '2007-06-19 22:43:07', 100, '2007-06-19 23:09:54', 100, 'LookupClassName', 'D', 'LookupClassName', 'LookupClassName', NULL, NULL, NULL, NULL, NULL, NULL); +INSERT INTO ad_element VALUES (51002, 0, 0, 'Y', '2007-06-19 22:43:07', 100, '2007-06-19 23:10:06', 100, 'LookupClientID', 'D', 'LookupClientID', 'LookupClientID', NULL, NULL, NULL, NULL, NULL, NULL); +INSERT INTO ad_element VALUES (51003, 0, 0, 'Y', '2007-06-19 22:43:07', 100, '2007-06-19 23:10:19', 100, 'LookupUrl', 'D', 'LookupUrl', 'LookupUrl', NULL, NULL, NULL, NULL, NULL, NULL); +INSERT INTO ad_element VALUES (51004, 0, 0, 'Y', '2007-06-22 02:03:37', 100, '2007-06-22 02:04:31', 100, 'LookupPassword', 'D', 'LookupPassword', 'LookupPassword', NULL, NULL, NULL, NULL, NULL, NULL); + +-- Insert Column Definitions +INSERT INTO ad_column VALUES (51000, 0, 0, 'Y', '2007-06-19 22:43:07', '2007-06-19 23:14:47', 100, 100, 'IsPostcodeLookup', NULL, NULL, 0, 'D', 'IsPostcodeLookup', 170, 20, NULL, NULL, 1, 'N', 'N', 'N', 'N', 'Y', NULL, 'N', NULL, 'N', 'N', NULL, NULL, NULL, NULL, 'N', 51000, NULL, 'N', 'N', NULL, NULL); +INSERT INTO ad_column VALUES (51001, 0, 0, 'Y', '2007-06-19 22:43:07', '2007-06-19 23:04:48', 100, 100, 'LookupClassName', NULL, NULL, 0, 'D', 'LookupClassName', 170, 10, NULL, NULL, 255, NULL, 'N', 'N', 'N', 'Y', NULL, 'N', NULL, 'N', 'N', NULL, NULL, NULL, NULL, 'N', 51001, NULL, 'N', 'N', NULL, NULL); +INSERT INTO ad_column VALUES (51002, 0, 0, 'Y', '2007-06-19 22:43:07', '2007-06-19 23:04:48', 100, 100, 'LookupClientID', NULL, NULL, 0, 'D', 'LookupClientID', 170, 10, NULL, NULL, 50, NULL, 'N', 'N', 'N', 'Y', NULL, 'N', NULL, 'N', 'N', NULL, NULL, NULL, NULL, 'N', 51002, NULL, 'N', 'N', NULL, NULL); +INSERT INTO ad_column VALUES (51003, 0, 0, 'Y', '2007-06-19 22:43:07', '2007-06-19 23:04:48', 100, 100, 'LookupUrl', NULL, NULL, 0, 'D', 'LookupUrl', 170, 10, NULL, NULL, 100, NULL, 'N', 'N', 'N', 'Y', NULL, 'N', NULL, 'N', 'N', NULL, NULL, NULL, NULL, 'N', 51003, NULL, 'N', 'N', NULL, NULL); +INSERT INTO ad_column VALUES (51004, 0, 0, 'Y', '2007-06-22 02:03:37', '2007-06-22 02:05:17', 100, 100, 'LookupPassword', NULL, NULL, 0, 'D', 'LookupPassword', 170, 10, NULL, NULL, 50, NULL, 'N', 'N', 'N', 'Y', NULL, 'N', NULL, 'N', 'N', NULL, NULL, NULL, NULL, 'N', 51004, NULL, 'N', 'N', NULL, NULL); + +-- Insert Field Definitions +INSERT INTO ad_field VALUES (51000, 0, 0, 'Y', '2007-06-19 23:17:05', 100, '2007-06-19 23:17:05', 100, 'IsPostcodeLookup', NULL, NULL, 'Y', 135, 51000, NULL, 'Y', NULL, 1, 'N', 220, NULL, 'N', 'N', 'N', 'N', 'D', NULL, NULL, NULL); +INSERT INTO ad_field VALUES (51001, 0, 0, 'Y', '2007-06-19 23:17:06', 100, '2007-06-20 09:10:31', 100, 'LookupClassName', NULL, NULL, 'Y', 135, 51001, NULL, 'Y', '@IsPostcodeLookup@ = ''Y''', 255, 'N', 260, NULL, 'N', 'N', 'N', 'N', 'D', NULL, NULL, NULL); +INSERT INTO ad_field VALUES (51002, 0, 0, 'Y', '2007-06-19 23:17:06', 100, '2007-06-20 09:10:17', 100, 'LookupClientID', NULL, NULL, 'Y', 135, 51002, NULL, 'Y', '@IsPostcodeLookup@ = ''Y''', 50, 'N', 240, NULL, 'N', 'N', 'N', 'N', 'D', NULL, NULL, NULL); +INSERT INTO ad_field VALUES (51003, 0, 0, 'Y', '2007-06-19 23:17:06', 100, '2007-06-20 09:10:12', 100, 'LookupUrl', NULL, NULL, 'Y', 135, 51003, NULL, 'Y', '@IsPostcodeLookup@ = ''Y''', 100, 'N', 230, NULL, 'N', 'N', 'N', 'N', 'D', NULL, NULL, NULL); +INSERT INTO ad_field VALUES (51004, 0, 0, 'Y', '2007-06-19 23:17:06', 100, '2007-06-22 02:07:11', 100, 'LookupPassword', NULL, NULL, 'Y', 135, 51004, NULL, 'Y', '@IsPostcodeLookup@ = ''Y''', 50, 'N', 250, NULL, 'N', 'N', 'N', 'N', 'D', NULL, NULL, NULL); + +-- Update Sequences +UPDATE ad_sequence + SET currentnextsys = (SELECT MAX (ad_element_id) + 1 + FROM ad_element + WHERE ad_element_id < 1000000) + WHERE NAME = 'AD_Element'; + +UPDATE ad_sequence + SET currentnextsys = (SELECT MAX (ad_column_id) + 1 + FROM ad_column + WHERE ad_column_id < 1000000) + WHERE NAME = 'AD_Column'; + +UPDATE ad_sequence + SET currentnextsys = (SELECT MAX (ad_field_id) + 1 + FROM ad_field + WHERE ad_field_id < 1000000) + WHERE NAME = 'AD_Field'; + +COMMIT; \ No newline at end of file