com.knowgate.hipergate
Class Address

java.lang.Object
  extended by com.knowgate.dataobjs.DBPersist
      extended by com.knowgate.hipergate.Address
All Implemented Interfaces:
java.util.Map
Direct Known Subclasses:
SalePoint, Warehouse

public class Address
extends DBPersist

Address

A generic postal address object for being associated to any other objects that may require address information.


Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Field Summary
static short ClassId
           
 
Fields inherited from class com.knowgate.dataobjs.DBPersist
AllVals, sAuditCls, sAuditUsr, sTransactId
 
Constructor Summary
Address()
          Create empty Address
Address(JDCConnection oConn, java.lang.String guAddr)
          Load Address from database
 
Method Summary
static boolean addLookupState(java.sql.Connection oConn, java.lang.String sGuWorkArea, java.lang.String sIdCountry, java.lang.String sNmState, java.util.HashMap oTranslations)
          Add a State for a given country at k_addresses_lookup table This methods checks whether the given State Name exists at k_addresses_lookup for a given country and, if not, then inserts it.
static boolean addLookupStreetType(java.sql.Connection oConn, java.lang.String sGuWorkArea, java.lang.String sTpStreet, java.util.HashMap oTranslations)
          Add a Street Type lookup value
 boolean delete(JDCConnection oConn)
          Delete Address Registers at k_welcome_packs, k_x_company_addr and k_x_contact_addr are deleted on cascade
static DBSubset getAddressesByCompanyName(JDCConnection oConn, java.lang.String sCompanyNm, java.lang.String sWorkArea)
          Get addresses given their company name This method difers from Company.getAddresses() in that getAddresses() takes the Company GUID and makes a query into k_x_company_addr table.
static java.lang.String getIdFromEmail(JDCConnection oConn, java.lang.String sEMail, java.lang.String sWorkArea)
          Get Address Unique Id. from its e-mail.
 boolean load(JDCConnection oConn, java.lang.Object[] PKVals)
          Load values set at table k_addresses This method trims the value of id_country column
 boolean load(JDCConnection oConn, java.lang.String sGuAddress)
          Load values set at table k_addresses This method trims the value of id_country column
static int nextLocalIndex(java.sql.Connection oConn, java.lang.String sLinkTable, java.lang.String sLinkField, java.lang.String sLinkValue)
          Get next free address index for a given object.
 boolean store(JDCConnection oConn)
          Store Address If gu_address is null a new GUID is automatically assigned.
 java.lang.String toXML()
          Get an XML dump for the DBPersist values.
 java.lang.String toXML(java.lang.String sIdent)
          Get an XML dump for the DBPersist values.
 java.lang.String toXML(java.lang.String sIdent, java.lang.String sDelim)
          Get an XML dump for the DBPersist values
 
Methods inherited from class com.knowgate.dataobjs.DBPersist
allcaps, allcaps, changelog, clear, clone, containsKey, containsValue, entrySet, exists, get, get, getAuditClassName, getCreationDate, getDate, getDateFormated, getDateShort, getDateTime, getDateTime24, getDecimal, getDecimalFormated, getDecimalFormated, getDouble, getDoubleFormated, getFloat, getFloatFormated, getInt, getInteger, getIntervalPart, getItemMap, getItems, getMoney, getShort, getSQLDate, getSQLTime, getString, getStringNull, getTable, getTable, getTableName, getTime, getTimeOfDay, getTimestamp, getUIdFromName, isEmpty, isNull, iterator, keySet, parseXML, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, putAll, putAll, remove, remove, replace, replace, replace, replace, replace, replace, replace, setAuditTransact, setAuditUser, size, toLowerCase, toUpperCase, toXML, values
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Field Detail

ClassId

public static final short ClassId
See Also:
Constant Field Values
Constructor Detail

Address

public Address()
Create empty Address


Address

public Address(JDCConnection oConn,
               java.lang.String guAddr)
        throws java.sql.SQLException
Load Address from database

Parameters:
oConn - Database Connection
guAddr - GUID of address to be loaded
Throws:
java.sql.SQLException
Method Detail

load

public boolean load(JDCConnection oConn,
                    java.lang.Object[] PKVals)
             throws java.sql.SQLException

Load values set at table k_addresses

This method trims the value of id_country column

Overrides:
load in class DBPersist
Parameters:
oConn - Database Connection
PKVals - An Array with a single String containing the GUID of the Address to be loaded
Returns:
true if Address was found, false otherwise.
Throws:
java.sql.SQLException
Since:
3.0

load

public boolean load(JDCConnection oConn,
                    java.lang.String sGuAddress)
             throws java.sql.SQLException

Load values set at table k_addresses

This method trims the value of id_country column

Overrides:
load in class DBPersist
Parameters:
oConn - JDCConnection
sGuAddress - String GUID of the Address to be loaded
Returns:
true if Address was found, false otherwise.
Throws:
java.sql.SQLException
Since:
3.0

delete

public boolean delete(JDCConnection oConn)
               throws java.sql.SQLException

Delete Address

Registers at k_welcome_packs, k_x_company_addr and k_x_contact_addr are deleted on cascade

Overrides:
delete in class DBPersist
Parameters:
oConn - Database Connection
Returns:
true if Address existed at k_addresses table.
Throws:
java.sql.SQLException

store

public boolean store(JDCConnection oConn)
              throws java.sql.SQLException

Store Address

If gu_address is null a new GUID is automatically assigned.
dt_modified field is set to current date.
For generating a new address index call nextLocalIndex() and set property ix_address.
For example:
this.put (DB.ix_address, Address.nextLocalIndex(Connection, "k_x_company_addr", "gu_company"))

Overrides:
store in class DBPersist
Parameters:
oConn - Database Connection
Returns:
boolean true if Address was stored for the first time, false if register already existed.
Throws:
java.sql.SQLException

toXML

public java.lang.String toXML(java.lang.String sIdent,
                              java.lang.String sDelim)
                       throws java.lang.IllegalStateException

Get an XML dump for the DBPersist values

Overrides:
toXML in class DBPersist
Parameters:
sIdent - Number of blank spaces for left padding at every line.
sDelim - Line delimiter (usually "\n" or "\r\n")
Returns:
XML String
Throws:
java.lang.IllegalStateException

toXML

public java.lang.String toXML(java.lang.String sIdent)

Get an XML dump for the DBPersist values.

Lines are delimited by a single Line Feed CHR(10) '\n' character.

Overrides:
toXML in class DBPersist
Parameters:
sIdent - Number of blank spaces for left padding at every line.
Returns:
XML String

toXML

public java.lang.String toXML()

Get an XML dump for the DBPersist values.

No left padding is placed to the left of each line.

Lines are delimited by a single Line Feed CHR(10) '\n' character.

Overrides:
toXML in class DBPersist
Returns:
XML String

nextLocalIndex

public static int nextLocalIndex(java.sql.Connection oConn,
                                 java.lang.String sLinkTable,
                                 java.lang.String sLinkField,
                                 java.lang.String sLinkValue)
                          throws java.sql.SQLException

Get next free address index for a given object.

Address indexes are integers assigned on a per object basis.

Parameters:
oConn - Database Connection
sLinkTable - Table used for linking addresses to instances of objects of a given class (for example "k_x_company_addr" or "k_x_contact_addr").
sLinkField - Foreign object column name at link table (for example "gu_company" or "gu_contact")
sLinkValue - Value for foreign object GUID
Returns:
SELECT COUNT(*)+1 FROM sLinkTable WHERE sLinkField = sLinkValue
Throws:
java.sql.SQLException

getIdFromEmail

public static java.lang.String getIdFromEmail(JDCConnection oConn,
                                              java.lang.String sEMail,
                                              java.lang.String sWorkArea)
                                       throws java.sql.SQLException

Get Address Unique Id. from its e-mail.

Parameters:
oConn - Database Connection
sEMail - Address e-mail (tx_email from k_addresses table)
sWorkArea - WorkArea filter. If null all WorkAreas are seached
Returns:
User Unique Id. or null if no Address was found with such e-mail.
Throws:
java.sql.SQLException
Since:
2.2

addLookupState

public static boolean addLookupState(java.sql.Connection oConn,
                                     java.lang.String sGuWorkArea,
                                     java.lang.String sIdCountry,
                                     java.lang.String sNmState,
                                     java.util.HashMap oTranslations)
                              throws java.sql.SQLException

Add a State for a given country at k_addresses_lookup table

This methods checks whether the given State Name exists at k_addresses_lookup for a given country and, if not, then inserts it.
Example of how to call this method:
Connection oConn = // Code to get connection ;
HashMap oTr = new HashMap();
oTr.put("en", "New York");
oTr.put("fr", "Nouveau York");
oTr.put("es", "Nueva York");
Address.addState(oConn, "0123456789ABCDEFGHIJKLMNOPQRST", "us", "NY", oTr);

Parameters:
oConn - Connection
sGuWorkArea - String GUID of WorkArea
sIdCountry - String Two letters country identifier from k_lu_countries table
sNmState - String Language Neutral State Name or Code
oTranslations - HashMap with one entry for each language Language codes must be those from id_language column of k_lu_languages table.
Returns:
boolean true if state was added, false if it already existed
Throws:
java.sql.SQLException
Since:
3.0

addLookupStreetType

public static boolean addLookupStreetType(java.sql.Connection oConn,
                                          java.lang.String sGuWorkArea,
                                          java.lang.String sTpStreet,
                                          java.util.HashMap oTranslations)
                                   throws java.sql.SQLException

Add a Street Type lookup value

Parameters:
oConn - Connection
sGuWorkArea - String GUID of WorkArea
sTpStreet - String Street Type Internal Value
oTranslations - HashMap with one entry for each language
Returns:
boolean true if new street type was added, false if it already existed
Throws:
java.sql.SQLException
Since:
3.0

getAddressesByCompanyName

public static DBSubset getAddressesByCompanyName(JDCConnection oConn,
                                                 java.lang.String sCompanyNm,
                                                 java.lang.String sWorkArea)
                                          throws java.sql.SQLException

Get addresses given their company name

This method difers from Company.getAddresses() in that getAddresses() takes the Company GUID and makes a query into k_x_company_addr table. getAddressesForCompany() instead tests the value of nm_company column at k_addresses table.

Parameters:
oConn - Connection
sCompanyNm - String Exact Company Name (case sensitive)
sWorkArea - String GUID of WorkArea where to search
Returns:
String Address GUID or null if no company with such legal number was found at given work area
Throws:
java.sql.SQLException
Since:
4.0