com.knowgate.crm
Class Contact

java.lang.Object
  extended bycom.knowgate.dataobjs.DBPersist
      extended bycom.knowgate.crm.Contact
All Implemented Interfaces:
java.util.Map

public class Contact
extends DBPersist

Contact

Copyright: Copyright (c) KnowGate 2003

Version:
3.0

Nested Class Summary
 
Nested classes inherited from class java.util.Map
java.util.Map.Entry
 
Field Summary
static short ClassId
           
 
Fields inherited from class com.knowgate.dataobjs.DBPersist
AllVals, sAuditCls, sAuditUsr, sTransactId
 
Constructor Summary
Contact()
          Create Empty Contact.
Contact(JDCConnection oConn, java.lang.String sIdContact)
          Create Contact and load fields from database.
Contact(java.lang.String sIdContact)
          Create Contact and set gu_contact field.
 
Method Summary
 boolean addAddress(JDCConnection oConn, java.lang.String sAddrGUID)
          Add an Address to this Contact
 boolean addBankAccount(JDCConnection oConn, java.lang.String sFullBankAccount)
          Add a bank account to this Contact
static boolean addLookupJobTitle(java.sql.Connection oConn, java.lang.String sGuWorkArea, java.lang.String sDeTitle, java.util.HashMap oTranslations)
          Add a Job Title lookup value
static boolean addLookupPassportType(java.sql.Connection oConn, java.lang.String sGuWorkArea, java.lang.String sTpPassport, java.util.HashMap oTranslations)
          Add a Street Type lookup value
 boolean delete(JDCConnection oConn)
          Delete Contact.
static boolean delete(JDCConnection oConn, java.lang.String sContactGUID)
          Delete Contact.
 Address getAddress(JDCConnection oConn, int iIndex)
          Get Contact Address by index
 Address getAddress(JDCConnection oConn, java.lang.String sTpLocation)
          Get Contact Address by location type
 DBSubset getAddresses(JDCConnection oConn)
          Get Contact Addresses
 boolean store(JDCConnection oConn)
          Store Contact
 
Methods inherited from class com.knowgate.dataobjs.DBPersist
allcaps, allcaps, changelog, clear, clone, containsKey, containsValue, entrySet, exists, get, get, getAuditClassName, getCreationDate, getDate, getDateFormated, getDateShort, getDecimal, getDecimalFormated, getDouble, getDoubleFormated, getFloat, getFloatFormated, getInt, getInteger, getItemMap, getItems, getShort, getString, getStringNull, getTable, getTable, getTableName, getTime, getTimeOfDay, getTimestamp, getUIdFromName, isEmpty, isNull, iterator, keySet, load, load, parseXML, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, putAll, putAll, remove, remove, replace, replace, replace, replace, setAuditTransact, setAuditUser, size, toLowerCase, toUpperCase, toXML, toXML, 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

Contact

public Contact()
Create Empty Contact.


Contact

public Contact(java.lang.String sIdContact)
        throws java.sql.SQLException
Create Contact and set gu_contact field. Does not load other fields from database.

Parameters:
sIdContact - Contact GUID

Contact

public Contact(JDCConnection oConn,
               java.lang.String sIdContact)
        throws java.sql.SQLException
Create Contact and load fields from database.

Parameters:
oConn - Database Connection
sIdContact - Contact GUID
Method Detail

store

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

Store Contact

Automatically generates gu_contact GUID and dt_modified DATE if not explicitly set.
If gu_company field is null and nm_legal field is not null then gu_company field is automatically looked up at k_companies table and put in this DBPersist before storing it.

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

delete

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

Overrides:
delete in class DBPersist
Parameters:
oConn - Database connection
Returns:
true if register was successfully erased, false if not.
Throws:
java.sql.SQLException

addAddress

public boolean addAddress(JDCConnection oConn,
                          java.lang.String sAddrGUID)
                   throws java.sql.SQLException

Add an Address to this Contact

If contact is already associated to the given address then a foreign key violation is thrown

Parameters:
oConn - Database Connection
Throws:
java.sql.SQLException
Since:
3.0

addBankAccount

public boolean addBankAccount(JDCConnection oConn,
                              java.lang.String sFullBankAccount)
                       throws java.sql.SQLException

Add a bank account to this Contact

If contact is already associated to the given bank account then a foreign key violation SQLException is thrown

Parameters:
oConn - Database Connection
Throws:
java.sql.SQLException
Since:
3.0

getAddress

public Address getAddress(JDCConnection oConn,
                          int iIndex)
                   throws java.sql.SQLException
Get Contact Address by index

Parameters:
oConn - JDCConnection
iIndex - int Address index as set at column ix_address of k_addresses table
Returns:
Address or null if no Address with such index was found
Throws:
java.sql.SQLException
Since:
3.0

getAddress

public Address getAddress(JDCConnection oConn,
                          java.lang.String sTpLocation)
                   throws java.sql.SQLException
Get Contact Address by location type

Parameters:
oConn - JDCConnection
sTpLocation - String Address type as set at column tp_location of k_addresses table
Returns:
Address or null if no Address with such location type was found
Throws:
java.sql.SQLException
Since:
2.2

getAddresses

public DBSubset getAddresses(JDCConnection oConn)
                      throws java.sql.SQLException

Get Contact Addresses

Parameters:
oConn - Database Connection
Returns:
A DBSubset with all columns from k_addresses for Contact
Throws:
java.sql.SQLException
java.lang.NullPointerException - If gu_contact is null

delete

public static boolean delete(JDCConnection oConn,
                             java.lang.String sContactGUID)
                      throws java.sql.SQLException
Delete Contact. The delete step by step is as follws:
If k_x_meeting_contact table exists, then Contact is deleted from Meetings.
If k_orders table exists, then Orders for this Contact are deleted.
All Contact Attachments are deleted.
Stored Procedure k_sp_del_contact is called

Parameters:
oConn - Database Connection
sContactGUID - GUID of Contact to be deleted
Throws:
java.sql.SQLException

addLookupPassportType

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

Add a Street Type lookup value

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

addLookupJobTitle

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

Add a Job Title lookup value

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