com.knowgate.crm
Class Contact

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

public class Contact
extends DBPersist

Contact

Copyright: Copyright (c) KnowGate 2003


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
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 If contact is already associated to the given address then a foreign key violation is thrown
 Attachment addAttachment(JDCConnection oConn, java.lang.String sGuWriter, java.lang.String sDirPath, java.lang.String sFileName, boolean bDeleteOriginalFile)
          Add an Attachment to a Contact
 Attachment addAttachment(JDCConnection oConn, java.lang.String sGuWriter, java.lang.String sDirPath, java.lang.String sFileName, java.lang.String sDescription, boolean bDeleteOriginalFile)
          Add an Attachment to a Contact
 void addAttachments(JDCConnection oConn, java.lang.String sGuWriter, java.lang.String sDirPath, boolean bDeleteOriginalFiles)
          Attach all files from a given directory
 boolean addBankAccount(JDCConnection oConn, java.lang.String sFullBankAccount)
          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
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
 int addToACLGroups(JDCConnection oConn, java.lang.String sGroupList)
          Add Contact to a set of security restrictions groups.
 int clearACLGroups(JDCConnection oConn)
          Remove contact from all security restrictions groups
 boolean delete(JDCConnection oConn)
          Delete Contact.
static boolean delete(JDCConnection oConn, java.lang.String sContactGUID)
          Delete Contact.
 DBSubset getActiveBankAccounts(JDCConnection oConn)
          Get active bank accounts for this 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
 DBSubset getAllBankAccounts(JDCConnection oConn)
          Get all bank accounts associated with Contact
 Attachment[] getAttachments(JDCConnection oConn)
          Get array of products attached to this Contact
 DBSubset getGroups(JDCConnection oConn)
          Get groups that may have access to this contact.
 DBSubset getUnactiveBankAccounts(JDCConnection oConn)
          Get unactive bank accounts for this Contact
 WelcomePack getWelcomePack(JDCConnection oConn)
          Get most recent WelCome Pack associated to this contact
 boolean removeAttachment(JDCConnection oConn, int iPgAttachment)
          Remove attachment
 int removeFromACLGroup(JDCConnection oConn, java.lang.String sIdGroup)
          Remove Contact from security restrictions group.
 boolean store(JDCConnection oConn)
          Store Contact Automatically generates gu_contact GUID and dt_modified DATE if not explicitly set.
 java.lang.String toXML(JDCConnection oConn, java.lang.String sIdent, java.lang.String sDelim)
          Get an XML dump for Contact and its associated addresses
 
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, load, load, 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, 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
Throws:
java.sql.SQLException

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
Throws:
java.sql.SQLException
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:
boolean true if 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

getGroups

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

Get groups that may have access to this contact.

Parameters:
oConn - Database Connection
Returns:
A DBSubset with a 1 column containing each group unique identifier (gu_acl_group).
Throws:
java.sql.SQLException
Since:
4.0

addToACLGroups

public int addToACLGroups(JDCConnection oConn,
                          java.lang.String sGroupList)
                   throws java.sql.SQLException

Add Contact to a set of security restrictions groups.

Insert new registers at k_x_group_contact table.

Parameters:
oConn - Database Connection
sGroupList - A string of comma delimited ACLGroup GUIDs to with this ACLUser must be added.
Throws:
java.sql.SQLException - May throw a primary key constraint violation if contact already belongs to group.
Since:
4.0

clearACLGroups

public int clearACLGroups(JDCConnection oConn)
                   throws java.sql.SQLException

Remove contact from all security restrictions groups

Parameters:
oConn - Database Connection
Returns:
Count of groups from witch user was removed.
Throws:
java.sql.SQLException
Since:
4.0

removeFromACLGroup

public int removeFromACLGroup(JDCConnection oConn,
                              java.lang.String sIdGroup)
                       throws java.sql.SQLException

Remove Contact from security restrictions group.

remove register from k_x_group_user table.

Parameters:
oConn - Database Connection
sIdGroup - Group Unique Identifier.
Throws:
java.sql.SQLException
Since:
4.0

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

getAllBankAccounts

public DBSubset getAllBankAccounts(JDCConnection oConn)
                            throws java.sql.SQLException,
                                   java.lang.IllegalStateException
Get all bank accounts associated with Contact

Parameters:
oConn - JDCConnection
Returns:
DBSubset nu_bank_acc,dt_created,bo_active,tp_account,nm_bank,tx_addr,nm_cardholder,nu_card,tp_card,tx_expire,nu_pin,nu_cvv2,im_credit_limit,de_bank_acc
Throws:
java.sql.SQLException
java.lang.IllegalStateException - if gu_contact or gu_workarea are not set
Since:
3.0

getActiveBankAccounts

public DBSubset getActiveBankAccounts(JDCConnection oConn)
                               throws java.sql.SQLException,
                                      java.lang.IllegalStateException
Get active bank accounts for this Contact

Parameters:
oConn - JDCConnection
Returns:
DBSubset nu_bank_acc,dt_created,tp_account,nm_bank,tx_addr,nm_cardholder,nu_card,tp_card,tx_expire,nu_pin,nu_cvv2,im_credit_limit,de_bank_acc
Throws:
java.sql.SQLException
java.lang.IllegalStateException - if gu_contact or gu_workarea are not set
Since:
3.0

getUnactiveBankAccounts

public DBSubset getUnactiveBankAccounts(JDCConnection oConn)
                                 throws java.sql.SQLException,
                                        java.lang.IllegalStateException
Get unactive bank accounts for this Contact

Parameters:
oConn - JDCConnection
Returns:
DBSubset nu_bank_acc,dt_created,tp_account,nm_bank,tx_addr,nm_cardholder,nu_card,tp_card,tx_expire,nu_pin,nu_cvv2,im_credit_limit,de_bank_acc
Throws:
java.sql.SQLException
java.lang.IllegalStateException - if gu_contact or gu_workarea are not set
Since:
3.0

addAttachment

public Attachment addAttachment(JDCConnection oConn,
                                java.lang.String sGuWriter,
                                java.lang.String sDirPath,
                                java.lang.String sFileName,
                                boolean bDeleteOriginalFile)
                         throws java.sql.SQLException,
                                java.lang.NullPointerException,
                                java.io.FileNotFoundException,
                                java.lang.Exception
Add an Attachment to a Contact

Parameters:
oConn - JDCConnection
sGuWriter - String GUID of user (from k_users table) who is uploading the attachment
sDirPath - String Physical path (directory) where file to be attached ir located
sFileName - String Name of file to be attached
bDeleteOriginalFile - boolean true if original file must be deleted after being attached
Returns:
Attachment
Throws:
java.sql.SQLException
java.lang.NullPointerException
java.io.FileNotFoundException
java.lang.Exception
Since:
3.0

addAttachment

public Attachment addAttachment(JDCConnection oConn,
                                java.lang.String sGuWriter,
                                java.lang.String sDirPath,
                                java.lang.String sFileName,
                                java.lang.String sDescription,
                                boolean bDeleteOriginalFile)
                         throws java.sql.SQLException,
                                java.lang.NullPointerException,
                                java.io.FileNotFoundException,
                                java.lang.Exception
Add an Attachment to a Contact

Parameters:
oConn - JDCConnection
sGuWriter - String GUID of user (from k_users table) who is uploading the attachment
sDirPath - String Physical path (directory) where file to be attached ir located
sFileName - String Name of file to be attached
sDescription - String File Description (up to 254 characters)
bDeleteOriginalFile - boolean true if original file must be deleted after being attached
Returns:
Attachment
Throws:
java.sql.SQLException
java.lang.NullPointerException
java.io.FileNotFoundException
java.lang.Exception
Since:
4.0

addAttachments

public void addAttachments(JDCConnection oConn,
                           java.lang.String sGuWriter,
                           java.lang.String sDirPath,
                           boolean bDeleteOriginalFiles)
                    throws java.sql.SQLException,
                           java.lang.NullPointerException,
                           java.io.FileNotFoundException,
                           java.lang.Exception
Attach all files from a given directory

Parameters:
oConn - JDCConnection
sGuWriter - String GUID of user attaching the files
sDirPath - String Directory Path
bDeleteOriginalFiles - boolean true if original files must be deleted after being attached
Throws:
java.sql.SQLException
java.lang.NullPointerException
java.io.FileNotFoundException
java.lang.Exception
Since:
3.0

removeAttachment

public boolean removeAttachment(JDCConnection oConn,
                                int iPgAttachment)
                         throws java.sql.SQLException
Remove attachment

Parameters:
oConn - JDCConnection
iPgAttachment - int
Returns:
boolean
Throws:
java.sql.SQLException
java.lang.NullPointerException
Since:
3.0

getAttachments

public Attachment[] getAttachments(JDCConnection oConn)
                            throws java.sql.SQLException,
                                   java.lang.NullPointerException
Get array of products attached to this Contact

Parameters:
oConn - JDCConnection
Returns:
Attachment[] array or null if no products are attached to this contact
Throws:
java.sql.SQLException
java.lang.NullPointerException - if gu_contact is null
Since:
3.0

getWelcomePack

public WelcomePack getWelcomePack(JDCConnection oConn)
                           throws java.sql.SQLException
Get most recent WelCome Pack associated to this contact

Parameters:
oConn - JDCConnection
Returns:
WelcomePack
Throws:
java.sql.SQLException
Since:
3.0

toXML

public java.lang.String toXML(JDCConnection oConn,
                              java.lang.String sIdent,
                              java.lang.String sDelim)
                       throws java.lang.IllegalStateException,
                              java.sql.SQLException

Get an XML dump for Contact and its associated addresses

Parameters:
sIdent - Number of blank spaces for left padding at every line.
sDelim - Line delimiter (usually "\n" or "\r\n")
Throws:
java.lang.IllegalStateException - If XML method is invoked before Contact object is loaded
java.sql.SQLException
Since:
4.0

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