com.knowgate.crm
Class DistributionList

java.lang.Object
  extended by com.knowgate.dataobjs.DBPersist
      extended by com.knowgate.crm.DistributionList
All Implemented Interfaces:
java.io.Serializable, java.util.Map
Direct Known Subclasses:
DirectList

public class DistributionList
extends DBPersist

Distribution List

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Field Summary
static short ClassId
           
static short TYPE_BLACK
           
static short TYPE_DIRECT
           
static short TYPE_DYNAMIC
           
static short TYPE_STATIC
           
 
Fields inherited from class com.knowgate.dataobjs.DBPersist
AllVals, sAuditCls, sAuditUsr, sTransactId
 
Constructor Summary
DistributionList()
           
DistributionList(JDCConnection oConn, java.lang.String sListGUID)
          Create and load distribution list
DistributionList(JDCConnection oConn, java.lang.String sListDesc, java.lang.String sWorkAreaGUID)
          Create a distribution list and load its by name
 
Method Summary
 java.lang.String activeCompanies(JDCConnection oConn)
          Get GUIDs for all active companies
 java.lang.String activeContacts(JDCConnection oConn)
          Get GUIDs for all active contacts
 java.lang.String activeMembers(JDCConnection oConn)
          Get e-mail address for all active members
 int addCompany(java.sql.Connection oConn, java.lang.String sCompanyGUID)
          Add Contact e-mails to Static, Direct or Black List If Contact has several addresses then all of them are added to the list
 int addContact(java.sql.Connection oConn, java.lang.String sContactGUID)
          Add Contact e-mails to Static, Direct or Black List If Contact has several addresses then all of them are added to the list
 void append(JDCConnection oConn, java.lang.String sListGUID)
          Append members of a list to this DistributionList.
 java.lang.String blackList(JDCConnection oConn)
          Get associated Black List GUID The Black List is that witch tp_list=BLACK_LIST AND gu_query=this.gu_list
 java.lang.String clone(JDCConnection oConn)
          Clone this DistributionList.
 boolean contains(JDCConnection oConn, java.lang.String sMember)
          Find out if list contains a particular member Member is searched at k_x_list_members table either at gu_company and gu_contact or tx_email.
 boolean delete(JDCConnection oConn)
          Delete a register from database The deleted register will be the one matching this DBPersist primary key, as set at constructor or load() method.
static boolean delete(JDCConnection oConn, java.lang.String sListGUID)
          Delete Distribution List Call k_sp_del_list stored procedure.
 int deleteDuplicates(JDCConnection oConn)
          Delete duplicated e-mails from a static or direct list.
 boolean load(JDCConnection oConn, java.lang.Object[] PKVals)
          Load the internal value set from a register at a database table
 boolean load(JDCConnection oConn, java.lang.String sGuList)
          Load the internal value set from a register at a database table
 int memberCount(JDCConnection oConn)
          Count active members of this list
 void overwrite(JDCConnection oConn, java.lang.String sListGUID)
          Overwrite members of this DistributionList with members of given DistributionList.
 java.lang.String print(JDCConnection oConn, boolean bPrintHeader)
          Print List Members to a String.
 boolean store(JDCConnection oConn)
          Store DistributionList Automatically generates gu_list GUID if not explicitly set.
 void substract(JDCConnection oConn, java.lang.String sListGUID)
          Remove from this DistributionList those members present at given DistributionList.
 
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, getStringHtml, 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, replace, setAuditTransact, setAuditUser, setCreationDate, 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

TYPE_STATIC

public static final short TYPE_STATIC
See Also:
Constant Field Values

TYPE_DYNAMIC

public static final short TYPE_DYNAMIC
See Also:
Constant Field Values

TYPE_DIRECT

public static final short TYPE_DIRECT
See Also:
Constant Field Values

TYPE_BLACK

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

DistributionList

public DistributionList()

DistributionList

public DistributionList(JDCConnection oConn,
                        java.lang.String sListGUID)
                 throws java.sql.SQLException
Create and load distribution list

Parameters:
oConn - JDCConnection HDBC Connection
sListGUID - String List GUID
Throws:
java.sql.SQLException

DistributionList

public DistributionList(JDCConnection oConn,
                        java.lang.String sListDesc,
                        java.lang.String sWorkAreaGUID)
                 throws java.sql.SQLException
Create a distribution list and load its by name

Parameters:
oConn - JDCConnection JDBC Connection
sListDesc - String List Description
sWorkAreaGUID - String GUID of WorkArea to which list belongs
Throws:
java.sql.SQLException
Method Detail

memberCount

public int memberCount(JDCConnection oConn)
                throws java.sql.SQLException
Count active members of this list

Parameters:
oConn - JDBC Database Connection
Returns:
Count of members of this list which bo_active field is not zero.
Throws:
java.sql.SQLException

activeMembers

public java.lang.String activeMembers(JDCConnection oConn)
                               throws java.sql.SQLException,
                                      java.lang.IllegalStateException
Get e-mail address for all active members

Parameters:
oConn - JDBC Database Connection
Returns:
String with e-mail addresses delimited by commas
Throws:
java.sql.SQLException
java.lang.IllegalStateException

activeContacts

public java.lang.String activeContacts(JDCConnection oConn)
                                throws java.sql.SQLException
Get GUIDs for all active contacts

Parameters:
oConn - JDBC Database Connection
Returns:
String with GUIDs delimited by commas
Throws:
java.sql.SQLException

activeCompanies

public java.lang.String activeCompanies(JDCConnection oConn)
                                 throws java.sql.SQLException
Get GUIDs for all active companies

Parameters:
oConn - JDBC Database Connection
Returns:
String with GUIDs delimited by commas
Throws:
java.sql.SQLException

contains

public boolean contains(JDCConnection oConn,
                        java.lang.String sMember)
                 throws java.sql.SQLException

Find out if list contains a particular member

Member is searched at k_x_list_members table either at gu_company and gu_contact or tx_email. If list is Dynamic or Static, member is searched at gu_company and gu_contact. If list is Direct or Black, member is searched at tx_email

Parameters:
oConn - Database Connection
sMember - If this is a Static or Dynamic list then sMember must be the GUID of Contact or Company searched.
If this is a Direct or Black list then sMember must be an e-mail address.
Returns:
true if sMember is contained in list.
Take into account that the member may be unactive or blocked and still be contained at the list.
Unactive (k_x_list_members.bo_active=0) and blocked (present at black list) members should not receive any e-mails.
Throws:
java.sql.SQLException

load

public boolean load(JDCConnection oConn,
                    java.lang.Object[] PKVals)
             throws java.sql.SQLException
Description copied from class: DBPersist

Load the internal value set from a register at a database table

Overrides:
load in class DBPersist
Parameters:
oConn - Database Connection
PKVals - Primary key values in order of appearance
Returns:
true if a register was found, false if no register was found with such primary key.
Throws:
java.sql.SQLException

load

public boolean load(JDCConnection oConn,
                    java.lang.String sGuList)
             throws java.sql.SQLException
Description copied from class: DBPersist

Load the internal value set from a register at a database table

Overrides:
load in class DBPersist
Parameters:
oConn - JDCConnection
sGuList - String Primary key value
Returns:
true if a register was found, false if no register was found with such primary key.
Throws:
java.sql.SQLException

store

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

Store DistributionList

Automatically generates gu_list GUID if not explicitly set. If value gu_category is set then this list is added to that category and removed from any previous category to which it belonged.

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
Description copied from class: DBPersist

Delete a register from database

The deleted register will be the one matching this DBPersist primary key, as set at constructor or load() method.

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

blackList

public java.lang.String blackList(JDCConnection oConn)
                           throws java.sql.SQLException,
                                  java.lang.IllegalStateException

Get associated Black List GUID

The Black List is that witch tp_list=BLACK_LIST AND gu_query=this.gu_list

Parameters:
oConn - Database Connection
Returns:
Black List GUID or null if there is no associated Black List.
Throws:
java.sql.SQLException
java.lang.IllegalStateException - if this DistributionList has not been previously loaded

addContact

public int addContact(java.sql.Connection oConn,
                      java.lang.String sContactGUID)
               throws java.lang.IllegalStateException,
                      java.sql.SQLException

Add Contact e-mails to Static, Direct or Black List

If Contact has several addresses then all of them are added to the list

Parameters:
oConn - Database Connection
Contact - GUID
Returns:
Black List GUID or null if there is no associated Black List.
Throws:
java.sql.SQLException
java.lang.IllegalStateException - if this DistributionList has not been previously loaded
Since:
5.0

addCompany

public int addCompany(java.sql.Connection oConn,
                      java.lang.String sCompanyGUID)
               throws java.lang.IllegalStateException,
                      java.sql.SQLException

Add Contact e-mails to Static, Direct or Black List

If Contact has several addresses then all of them are added to the list

Parameters:
oConn - Database Connection
Contact - GUID
Returns:
Black List GUID or null if there is no associated Black List.
Throws:
java.sql.SQLException
java.lang.IllegalStateException - if this DistributionList has not been previously loaded
Since:
6.0

append

public void append(JDCConnection oConn,
                   java.lang.String sListGUID)
            throws java.sql.SQLException,
                   java.lang.IllegalArgumentException,
                   java.lang.IllegalStateException,
                   java.lang.ClassCastException

Append members of a list to this DistributionList.

Members that where already present are not touched. Results are placed at this DistributionList.

Parameters:
oConn - Database Connection
sListGUID - GUID of DistributionList to be appended
Throws:
java.sql.SQLException
java.lang.IllegalArgumentException - If sListGUID==null
java.lang.IllegalStateException - If this.gu_list is not set
java.lang.ClassCastException - If this DistributionList type is DYNAMIC

overwrite

public void overwrite(JDCConnection oConn,
                      java.lang.String sListGUID)
               throws java.sql.SQLException,
                      java.lang.IllegalArgumentException,
                      java.lang.ClassCastException,
                      java.lang.IllegalStateException
Overwrite members of this DistributionList with members of given DistributionList. Members of sListGUID not present at this list are NOT appended.

Parameters:
oConn - Database Connection
Throws:
java.sql.SQLException
java.lang.IllegalArgumentException - If sListGUID==null
java.lang.IllegalStateException - If this.gu_list is not set
java.lang.ClassCastException - If this DistributionList type is DYNAMIC

substract

public void substract(JDCConnection oConn,
                      java.lang.String sListGUID)
               throws java.sql.SQLException,
                      java.lang.IllegalArgumentException,
                      java.lang.IllegalStateException,
                      java.lang.ClassCastException
Remove from this DistributionList those members present at given DistributionList.

Parameters:
oConn - Database Connection
Throws:
java.sql.SQLException
java.lang.IllegalArgumentException - If sListGUID==null
java.lang.IllegalStateException - If this.gu_list is not set
java.lang.ClassCastException - If this DistributionList type is DYNAMIC

clone

public java.lang.String clone(JDCConnection oConn)
                       throws java.sql.SQLException
Clone this DistributionList. The associated Black List, if it exists, is also cloned and associated to the new clone.

Parameters:
oConn - Database Connection
Returns:
New DistributionList GUID
Throws:
java.sql.SQLException

deleteDuplicates

public int deleteDuplicates(JDCConnection oConn)
                     throws java.sql.SQLException,
                            java.lang.IllegalStateException,
                            java.lang.UnsupportedOperationException

Delete duplicated e-mails from a static or direct list.

This method calls k_sp_del_duplicates stored procedure for PostgreSQL, MySQL and Microsoft SQL Server. For Oracle a direct DELETE statement is executed using ROWID for removing duplicate e-mails.

Parameters:
oConn - Database Connection
Returns:
Count of deleted members
Throws:
java.sql.SQLException - If the list type is not STATIC or DIRECT.
java.lang.IllegalStateException - is this DistributionList has not been previously loaded
java.lang.UnsupportedOperationException - if the underlying RDBMS is not PostgreSQL, MySQL, SQL Server or Oracle.
Since:
6.0

print

public java.lang.String print(JDCConnection oConn,
                              boolean bPrintHeader)
                       throws java.sql.SQLException
Print List Members to a String.

Parameters:
oConn - Database Connection
bPrintHeader - true if column names are to be printed at first row.
Returns:
Comma delimited String with one Member per line.
Throws:
java.sql.SQLException

delete

public static boolean delete(JDCConnection oConn,
                             java.lang.String sListGUID)
                      throws java.sql.SQLException
Delete Distribution List Call k_sp_del_list stored procedure.
Associated Black List (if present) is also deleted.

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