com.knowgate.crm
Class DirectList

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

public class DirectList
extends DistributionList

DirectList

A subclass of DistributionList with methods for loading List Members from text files.

Copyright: Copyright (c) KnowGate 2003-2006


Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Field Summary
static int CHECK_INVALID_EMAIL
           
static int CHECK_INVALID_FORMAT
           
static int CHECK_INVALID_NAME
           
static int CHECK_INVALID_SALUTATION
           
static int CHECK_INVALID_SURNAME
           
static int CHECK_NAME_TOO_LONG
           
static int CHECK_OK
           
static int CHECK_SALUTATION_TOO_LONG
           
static int CHECK_SURNAME_TOO_LONG
           
static short ClassId
           
 
Fields inherited from class com.knowgate.crm.DistributionList
TYPE_BLACK, TYPE_DIRECT, TYPE_DYNAMIC, TYPE_STATIC
 
Fields inherited from class com.knowgate.dataobjs.DBPersist
AllVals, sAuditCls, sAuditUsr, sTransactId
 
Constructor Summary
DirectList()
          Default constructor
DirectList(java.lang.String sCharSetName)
          Constructor
 
Method Summary
 int errorLine()
          Get last error line
 int getColumnPosition(java.lang.String sColumnName)
           
 java.lang.String getField(int iCol, int iRow)
          Get value for a field at a given row and column.
 java.lang.String getField(java.lang.String sCol, int iRow)
          Get value for a field at a given row and column.
 java.lang.String getLine(int iLine)
          Get line from a parsed file.
 int getLineCount()
          Get line count after parsing a text file
 int[] parseFile(java.lang.String sFilePath, java.lang.String sFileDescriptor)
          Parse a delimited text file
 void removeFromList(JDCConnection oConn, java.lang.String sListId)
          Remove members from a Static, Direct or Black Distribution List.
 void updateList(JDCConnection oConn, java.lang.String sListId, short iStatus)
          Adds members to a Static, Direct or Black Distribution List.
 
Methods inherited from class com.knowgate.crm.DistributionList
activeCompanies, activeContacts, activeMembers, append, blackList, clone, contains, delete, delete, memberCount, overwrite, print, store, substract
 
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

CHECK_OK

public static final int CHECK_OK
See Also:
Constant Field Values

CHECK_INVALID_EMAIL

public static final int CHECK_INVALID_EMAIL
See Also:
Constant Field Values

CHECK_NAME_TOO_LONG

public static final int CHECK_NAME_TOO_LONG
See Also:
Constant Field Values

CHECK_SURNAME_TOO_LONG

public static final int CHECK_SURNAME_TOO_LONG
See Also:
Constant Field Values

CHECK_INVALID_FORMAT

public static final int CHECK_INVALID_FORMAT
See Also:
Constant Field Values

CHECK_SALUTATION_TOO_LONG

public static final int CHECK_SALUTATION_TOO_LONG
See Also:
Constant Field Values

CHECK_INVALID_NAME

public static final int CHECK_INVALID_NAME
See Also:
Constant Field Values

CHECK_INVALID_SURNAME

public static final int CHECK_INVALID_SURNAME
See Also:
Constant Field Values

CHECK_INVALID_SALUTATION

public static final int CHECK_INVALID_SALUTATION
See Also:
Constant Field Values

ClassId

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

DirectList

public DirectList()
Default constructor


DirectList

public DirectList(java.lang.String sCharSetName)
Constructor

Parameters:
String - Name of character set to be used when parsing files (ISO-8859-1, UTF-8, etc.)
Since:
3.0
Method Detail

errorLine

public int errorLine()
Get last error line

Returns:
int

getLineCount

public int getLineCount()
Get line count after parsing a text file

Returns:
int

parseFile

public int[] parseFile(java.lang.String sFilePath,
                       java.lang.String sFileDescriptor)
                throws java.lang.ArrayIndexOutOfBoundsException,
                       java.lang.NullPointerException,
                       java.lang.IllegalArgumentException,
                       java.io.UnsupportedEncodingException,
                       java.io.IOException,
                       java.io.FileNotFoundException
Parse a delimited text file

Parameters:
sFilePath - File Path
sFileDescriptor - Delimited Column List.
The only valid column names are { tx_email, tx_name, tx_surname, id_format, tx_salutation }.
Column names may be delimited by ',' ';' or '\t'. Columns names may be quoted.
Returns:
Array of status for each parsed line.
CHECK_OKLine is OK
CHECK_INVALID_EMAILtx_email is longer than 100 characters or it is rejected by method Gadgets.checkEMail()
CHECK_NAME_TOO_LONGtx_name is longer than 100 characters
CHECK_INVALID_NAMEtx_name contains forbidden characters { ',' ';' '`' '¨' '?' '"' }
CHECK_SURNAME_TOO_LONGtx_surname is longer than 100 characters
CHECK_INVALID_SURNAMEtx_surname contains forbidden characters { ',' ';' '`' '¨' '?' '"' }
CHECK_INVALID_FORMATid_format is longer than 4 characters
CHECK_SALUTATION_TOO_LONGtx_salutation is longer than 16 characters
CHECK_INVALID_SALUTATIONtx_salutation contains forbidden characters { ',' ';' '`' '¨' '?' '"' }
Throws:
java.lang.ArrayIndexOutOfBoundsException
java.io.FileNotFoundException
java.lang.IllegalArgumentException
java.io.IOException
java.lang.NullPointerException
java.io.UnsupportedEncodingException
See Also:
CSVParser

getColumnPosition

public int getColumnPosition(java.lang.String sColumnName)
Parameters:
sColumnName - Column Name
Returns:
Zero based index for column position or -1 if column was not found.

getLine

public java.lang.String getLine(int iLine)
                         throws java.lang.IllegalStateException

Get line from a parsed file.

Lines are delimited by the Line Feed (LF, CHAR(10), '\n') character

Parameters:
iLine - Line Number [0..getLineCount()-1]
Returns:
Full Text for Line. If iLine<0 or iLine>=getLineCount() then null
Throws:
java.lang.IllegalStateException - If parseFile() has not been called prior to getLine()

getField

public java.lang.String getField(int iCol,
                                 int iRow)
                          throws java.lang.ArrayIndexOutOfBoundsException

Get value for a field at a given row and column.

Column indexes are zero based. Row indexes range from 0 to getLineCount()-1.

Parameters:
iCol - Column Index
iRow - Row Index
Returns:
Field Value
Throws:
java.lang.IllegalStateException - If parseFile() method was not called prior to getField()
java.lang.ArrayIndexOutOfBoundsException - If Column or Row Index is out of bounds.

getField

public java.lang.String getField(java.lang.String sCol,
                                 int iRow)
                          throws java.lang.ArrayIndexOutOfBoundsException

Get value for a field at a given row and column.

Parameters:
sCol - Column Name
iRow - Row Name
Throws:
java.lang.ArrayIndexOutOfBoundsException

updateList

public void updateList(JDCConnection oConn,
                       java.lang.String sListId,
                       short iStatus)
                throws java.lang.IllegalArgumentException,
                       java.lang.IllegalStateException,
                       java.lang.ClassCastException,
                       java.sql.SQLException

Adds members to a Static, Direct or Black Distribution List.

Parameters:
oConn - Database connection
sListId - DistributionList GUID
iStatus - 1 if loaded members are to be set as active, 0 if loaded member are to be set as unactive.
Throws:
java.lang.IllegalArgumentException - If DistributionList does not exist.
java.lang.ClassCastException - If sListId type is DYNAMIC.
java.lang.IllegalStateException - If parseFile() has not been called prior to updateList()
java.lang.StringIndexOutOfBoundsException - If a row if malformed
java.sql.SQLException

removeFromList

public void removeFromList(JDCConnection oConn,
                           java.lang.String sListId)
                    throws java.lang.IllegalArgumentException,
                           java.sql.SQLException,
                           java.lang.ClassCastException

Remove members from a Static, Direct or Black Distribution List.

Members are matched by their e-mail address (tx_email column)

Parameters:
oConn - Database connection
sListId - DistributionList GUID
Throws:
java.lang.IllegalArgumentException - If DistributionList does not exist.
java.lang.ClassCastException - If sListId type is DYNAMIC
java.lang.IllegalStateException - If parseFile() has not been called prior to updateList()
java.sql.SQLException