com.knowgate.crm
Class ContactLoader

java.lang.Object
  extended by com.knowgate.crm.ContactLoader
All Implemented Interfaces:
ImportLoader

public class ContactLoader
extends java.lang.Object
implements ImportLoader

Load Contact, Company and Address data from a single source

Contact loader creates or updates simultaneously registers at k_companies, k_contacts and k_addresses tables and the links between them k_x_contact_addr.


Field Summary
static int bo_active
           
static int bo_change_pwd
           
static int bo_private
           
static int contact_person
           
static int coord_x
           
static int coord_y
           
static int de_company
           
static int de_title
           
static int direct_phone
           
static int dt_birth
           
static int dt_created
           
static int dt_drivelic
           
static int dt_founded
           
static int dt_modified
           
static int dt_pwd_expires
           
static int fax_phone
           
static int gu_address
           
static int gu_company
           
static int gu_contact
           
static int gu_geozone
           
static int gu_sales_man
           
static int gu_workarea
           
static int gu_writer
           
static int home_phone
           
static int id_address_ref
           
static int id_company_ref
           
static int id_company_status
           
static int id_contact_ref
           
static int id_contact_status
           
static int id_country
           
static int id_gender
           
static int id_legal
           
static int id_sector
           
static int id_state
           
static int im_revenue
           
static int ix_address
           
static int mn_city
           
static int MODE_APPEND
           
static int MODE_APPENDUPDATE
           
static int MODE_UPDATE
           
static int mov_phone
           
static int nm_commercial
           
static int nm_country
           
static int nm_legal
           
static int nm_state
           
static int nm_street
           
static int NO_DUPLICATED_MAILS
           
static int NO_DUPLICATED_NAMES
           
static int nu_employees
           
static int nu_street
           
static int ny_age
           
static int other_phone
           
static int po_box
           
static int sn_drivelic
           
static int sn_passport
           
static int tp_company
           
static int tp_location
           
static int tp_passport
           
static int tp_street
           
static int tx_addr1
           
static int tx_addr2
           
static int tx_challenge
           
static int tx_comments
           
static int tx_dept
           
static int tx_division
           
static int tx_email
           
static int tx_email_alt
           
static int tx_franchise
           
static int tx_name
           
static int tx_nickname
           
static int tx_pwd
           
static int tx_remarks
           
static int tx_reply
           
static int tx_salutation
           
static int tx_surname
           
static int url_addr
           
static int work_phone
           
static int WRITE_ADDRESSES
           
static int WRITE_COMPANIES
           
static int WRITE_CONTACTS
           
static int WRITE_LOOKUPS
           
static int zipcode
           
 
Fields inherited from interface com.knowgate.hipergate.datamodel.ImportLoader
LOOUKP_TR_COLUMNS, LOOUKP_TR_COUNT
 
Constructor Summary
ContactLoader()
          Default construtor
ContactLoader(java.sql.Connection oConn)
          Create ContactLoader and call prepare() on Connection
 
Method Summary
 void close()
          Close prepared statements This method must always be called before object is destroyed or else
 int columnCount()
          Get columns count
 java.lang.String[] columnNames()
          Get array of column names
 java.lang.Object get(int iColumnIndex)
          Get column by index
 java.lang.Object get(java.lang.String sColumnName)
          Get column by name
 int getColumnIndex(java.lang.String sColumnName)
          Get column index at ColumnNames array given its name This method performs binary search assuming that ColumnNames is sorted in ascending order
 void prepare(java.sql.Connection oConn, ColumnList oColList)
          Prepare statements for execution This method needs to be called only once if the default constructor was used.
 void put(int iColumnIndex, java.lang.Object oValue)
          Put value for a given column
 void put(java.lang.String sColumnName, java.lang.Object oValue)
          Put value for a given column If a previous value already exists then it is replaced
 void putAll(java.util.Map oValues)
          Put all values from a map on their corresponding columns matching by name
 void setAllColumnsToNull()
          Set all column values to null
 void store(java.sql.Connection oConn, java.lang.String sWorkArea, int iFlags)
          Store properties curently held in RAM into the database
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MODE_APPEND

public static final int MODE_APPEND
See Also:
Constant Field Values

MODE_UPDATE

public static final int MODE_UPDATE
See Also:
Constant Field Values

MODE_APPENDUPDATE

public static final int MODE_APPENDUPDATE
See Also:
Constant Field Values

WRITE_LOOKUPS

public static final int WRITE_LOOKUPS
See Also:
Constant Field Values

WRITE_COMPANIES

public static final int WRITE_COMPANIES
See Also:
Constant Field Values

WRITE_CONTACTS

public static final int WRITE_CONTACTS
See Also:
Constant Field Values

WRITE_ADDRESSES

public static final int WRITE_ADDRESSES
See Also:
Constant Field Values

NO_DUPLICATED_NAMES

public static final int NO_DUPLICATED_NAMES
See Also:
Constant Field Values

NO_DUPLICATED_MAILS

public static final int NO_DUPLICATED_MAILS
See Also:
Constant Field Values

bo_active

public static int bo_active

bo_change_pwd

public static int bo_change_pwd

bo_private

public static int bo_private

contact_person

public static int contact_person

coord_x

public static int coord_x

coord_y

public static int coord_y

de_company

public static int de_company

de_title

public static int de_title

direct_phone

public static int direct_phone

dt_birth

public static int dt_birth

dt_created

public static int dt_created

dt_drivelic

public static int dt_drivelic

dt_founded

public static int dt_founded

dt_modified

public static int dt_modified

dt_pwd_expires

public static int dt_pwd_expires

fax_phone

public static int fax_phone

gu_address

public static int gu_address

gu_company

public static int gu_company

gu_contact

public static int gu_contact

gu_geozone

public static int gu_geozone

gu_sales_man

public static int gu_sales_man

gu_workarea

public static int gu_workarea

gu_writer

public static int gu_writer

home_phone

public static int home_phone

id_address_ref

public static int id_address_ref

id_company_ref

public static int id_company_ref

id_company_status

public static int id_company_status

id_contact_ref

public static int id_contact_ref

id_contact_status

public static int id_contact_status

id_country

public static int id_country

id_gender

public static int id_gender

id_legal

public static int id_legal

id_sector

public static int id_sector

id_state

public static int id_state

im_revenue

public static int im_revenue

ix_address

public static int ix_address

mn_city

public static int mn_city

mov_phone

public static int mov_phone

nm_commercial

public static int nm_commercial

nm_country

public static int nm_country

nm_legal

public static int nm_legal

nm_state

public static int nm_state

nm_street

public static int nm_street

nu_employees

public static int nu_employees

nu_street

public static int nu_street

ny_age

public static int ny_age

other_phone

public static int other_phone

po_box

public static int po_box

sn_drivelic

public static int sn_drivelic

sn_passport

public static int sn_passport

tp_company

public static int tp_company

tp_location

public static int tp_location

tp_passport

public static int tp_passport

tp_street

public static int tp_street

tx_addr1

public static int tx_addr1

tx_addr2

public static int tx_addr2

tx_challenge

public static int tx_challenge

tx_comments

public static int tx_comments

tx_dept

public static int tx_dept

tx_division

public static int tx_division

tx_email

public static int tx_email

tx_email_alt

public static int tx_email_alt

tx_franchise

public static int tx_franchise

tx_name

public static int tx_name

tx_nickname

public static int tx_nickname

tx_pwd

public static int tx_pwd

tx_remarks

public static int tx_remarks

tx_reply

public static int tx_reply

tx_salutation

public static int tx_salutation

tx_surname

public static int tx_surname

url_addr

public static int url_addr

work_phone

public static int work_phone

zipcode

public static int zipcode
Constructor Detail

ContactLoader

public ContactLoader()
Default construtor


ContactLoader

public ContactLoader(java.sql.Connection oConn)
              throws java.sql.SQLException
Create ContactLoader and call prepare() on Connection

Parameters:
oConn - Connection
Throws:
java.sql.SQLException
Method Detail

setAllColumnsToNull

public void setAllColumnsToNull()
Set all column values to null

Specified by:
setAllColumnsToNull in interface ImportLoader

getColumnIndex

public int getColumnIndex(java.lang.String sColumnName)

Get column index at ColumnNames array given its name

This method performs binary search assuming that ColumnNames is sorted in ascending order

Specified by:
getColumnIndex in interface ImportLoader
Parameters:
sColumnName - String Column name (case insensitive)
Returns:
int Column index or -1 if not found

columnCount

public int columnCount()
Description copied from interface: ImportLoader
Get columns count

Specified by:
columnCount in interface ImportLoader
Returns:
int

columnNames

public java.lang.String[] columnNames()
                               throws java.lang.IllegalStateException
Description copied from interface: ImportLoader
Get array of column names

Specified by:
columnNames in interface ImportLoader
Returns:
String[]
Throws:
java.lang.IllegalStateException

put

public void put(int iColumnIndex,
                java.lang.Object oValue)
         throws java.lang.ArrayIndexOutOfBoundsException
Put value for a given column

Specified by:
put in interface ImportLoader
Parameters:
iColumnIndex - Column index [0..getColumnCount()-1]
oValue - Value for column
Throws:
java.lang.ArrayIndexOutOfBoundsException

put

public void put(java.lang.String sColumnName,
                java.lang.Object oValue)
         throws java.lang.ArrayIndexOutOfBoundsException

Put value for a given column

If a previous value already exists then it is replaced

Specified by:
put in interface ImportLoader
Parameters:
sColumnName - Column name (case sensitive)
oValue - Value for column
Throws:
java.lang.ArrayIndexOutOfBoundsException

putAll

public void putAll(java.util.Map oValues)
Put all values from a map on their corresponding columns matching by name

Parameters:
oValues - Map

get

public java.lang.Object get(int iColumnIndex)
                     throws java.lang.ArrayIndexOutOfBoundsException
Get column by index

Specified by:
get in interface ImportLoader
Parameters:
iColumnIndex - int Colunm index [0..getColumnCount()-1]
Returns:
Object Column value
Throws:
java.lang.ArrayIndexOutOfBoundsException

get

public java.lang.Object get(java.lang.String sColumnName)
                     throws java.lang.ArrayIndexOutOfBoundsException
Get column by name

Specified by:
get in interface ImportLoader
Parameters:
sColumnName - String Column name (case sensitive)
Returns:
Object Column value
Throws:
java.lang.ArrayIndexOutOfBoundsException - If no column with sucjh name was found

prepare

public void prepare(java.sql.Connection oConn,
                    ColumnList oColList)
             throws java.sql.SQLException

Prepare statements for execution

This method needs to be called only once if the default constructor was used.
If ContactLoader(Connection) constructor was used, there is no need to call prepare() and a SQLException will be raised if the attempt is made.
It is neccesary to call close() always for prepared instances as a failure to do so will leave open cursors on the database causing it eventually to stop.

Specified by:
prepare in interface ImportLoader
Parameters:
oConn - Connection Open JDBC database connection
oColList - ColumnList This parameter is ignored
Throws:
java.sql.SQLException

close

public void close()
           throws java.sql.SQLException

Close prepared statements

This method must always be called before object is destroyed or else

Specified by:
close in interface ImportLoader
Throws:
java.sql.SQLException

store

public void store(java.sql.Connection oConn,
                  java.lang.String sWorkArea,
                  int iFlags)
           throws java.sql.SQLException,
                  java.lang.IllegalArgumentException,
                  java.lang.NullPointerException,
                  java.lang.ClassCastException
Store properties curently held in RAM into the database

Specified by:
store in interface ImportLoader
Parameters:
oConn - Opened JDBC connection
sWorkArea - String GUID of WorkArea to which inserted data will belong
iFlags - int A boolean combination of {MODE_APPEND|MODE_UPDATE|WRITE_COMPANIES|WRITE_CONTACTS|WRITE_ADDRESSES|WRITE_LOOKUPS|NO_DUPLICATED_NAMES|NO_DUPLICATED_MAILS}
Throws:
java.sql.SQLException
java.lang.IllegalArgumentException
java.lang.NullPointerException
java.lang.ClassCastException