com.knowgate.forums
Class NewsMessage

java.lang.Object
  extended by com.knowgate.dataobjs.DBPersist
      extended by com.knowgate.forums.NewsMessage
All Implemented Interfaces:
java.io.Serializable, java.util.Map

public class NewsMessage
extends DBPersist

NewsMessage

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 STATUS_DISCARDED
           
static short STATUS_EXPIRED
           
static short STATUS_PENDING
           
static short STATUS_VALIDATED
           
 
Fields inherited from class com.knowgate.dataobjs.DBPersist
AllVals, sAuditCls, sAuditUsr, sTransactId
 
Constructor Summary
NewsMessage()
          Create empty NewsMessage
NewsMessage(JDCConnection oConn, java.lang.String sGuMsg)
          Load NewsMessage from database
 
Method Summary
 int countVotes(JDCConnection oConn)
          Count number of votes of a message
 boolean delete(JDCConnection oConn)
          Delete NewsMessage.
static boolean delete(JDCConnection oConn, java.lang.String sNewsMsgGUID)
          Delete NewsMessage.
 DBSubset getAttachments(JDCConnection oConn)
          Get attachments
 boolean load(JDCConnection oConn, java.lang.Object[] aPK)
          Load the internal value set from a register at a database table
 boolean load(JDCConnection oConn, java.lang.String sGuMsg)
          Load message
 void move(JDCConnection oConn, java.lang.String sNewsGroupId)
          Move this message and all its replies to another NewsGroup
 java.lang.String post(JDCConnection oConn, java.lang.String sNewsGroupId, java.lang.String sThreadId, java.util.Date dtStart, java.util.Date dtEnd, short iStatus, java.lang.String sText)
          Post a Plain Text Message
 boolean store(JDCConnection oConn)
          Store NewsMessage Message is posted into a NewsGroup by setting gu_newsgrp property of NewsMessage to the GUID of newsMessage that will contain it.
 java.lang.String[] subscribers(JDCConnection oConn)
          Get e-mails subscribed to current message group or thread Only active subscribers with digest option not selected are returned
 java.util.HashMap<java.lang.String,NewsMessageTag> tags()
          Get tags for this message
 
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

STATUS_VALIDATED

public static final short STATUS_VALIDATED
See Also:
Constant Field Values

STATUS_PENDING

public static final short STATUS_PENDING
See Also:
Constant Field Values

STATUS_DISCARDED

public static final short STATUS_DISCARDED
See Also:
Constant Field Values

STATUS_EXPIRED

public static final short STATUS_EXPIRED
See Also:
Constant Field Values

ClassId

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

NewsMessage

public NewsMessage()
Create empty NewsMessage


NewsMessage

public NewsMessage(JDCConnection oConn,
                   java.lang.String sGuMsg)
            throws java.sql.SQLException
Load NewsMessage from database

Throws:
java.sql.SQLException
Since:
4.0
Method Detail

post

public java.lang.String post(JDCConnection oConn,
                             java.lang.String sNewsGroupId,
                             java.lang.String sThreadId,
                             java.util.Date dtStart,
                             java.util.Date dtEnd,
                             short iStatus,
                             java.lang.String sText)
                      throws java.sql.SQLException
Post a Plain Text Message

Parameters:
oConn - Database Conenction
sNewsGroupId - GUID of NewsGroup for posting
sThreadId - GUID of message thread (may be null)
dtStart - Start publishing date (may be null)
dtEnd - Expiration date (may be null)
iStatus - STATUS_VALIDATED or STATUS_PENDING
sText - Message Text
Returns:
GUID of new message
Throws:
java.sql.SQLException

load

public boolean load(JDCConnection oConn,
                    java.lang.String sGuMsg)
             throws java.sql.SQLException
Load message

Overrides:
load in class DBPersist
Parameters:
oConn - JDCConnection
sGuMsg - String Message GUID
Returns:
boolean true if message was successfully loaded, false if no message with such GUID was found
Throws:
java.sql.SQLException
Since:
3.0

getAttachments

public DBSubset getAttachments(JDCConnection oConn)
                        throws java.sql.SQLException
Get attachments

Parameters:
oConn - JDCConnection
Returns:
DBSubset listing attachments or null if this message has no attachments
Throws:
java.sql.SQLException
Since:
3.0

load

public boolean load(JDCConnection oConn,
                    java.lang.Object[] aPK)
             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
aPK - 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

store

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

Store NewsMessage

Message is posted into a NewsGroup by setting gu_newsgrp property of NewsMessage to the GUID of newsMessage that will contain it.
If gu_msg is null then a new GUID will be assigned.
If gu_thread_msg is null and gu_parent_msg is null then gu_thread_msg will be assigned the same value as gu_msg.
If gu_thread_msg is null and gu_parent_msg is not null then gu_thread_msg will be assigned the same the parent message thread.
If id_status is null then it will be assigned to NewsMessage.STATUS_PENDING.
If id_msg_type is null then it will be assigned to "TXT" by default.
If dt_start is null then message visibility will start inmediately.
If dt_end is null then message will never expire.
dt_published will be set to the currents system date if not passed as a parameter.
nu_thread_msgs will be updated in all messages from this thread by calling k_sp_count_thread_msgs stored procedure.
Column k_newsgroups.dt_last_update is automatically set to the current date each time a new message is stored.

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

move

public void move(JDCConnection oConn,
                 java.lang.String sNewsGroupId)
          throws java.sql.SQLException
Move this message and all its replies to another NewsGroup

Parameters:
oConn - Database Conenction
sNewsGroupId - GUID of the target NewsGroup
Throws:
java.sql.SQLException
Since:
5.0

delete

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

Delete NewsMessage.

Files attached to NewsMessage (stored as Products) are delete prior to the NewsMessage itself. Then k_sp_del_newsmsg stored procedure is called.

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

subscribers

public java.lang.String[] subscribers(JDCConnection oConn)
                               throws java.sql.SQLException

Get e-mails subscribed to current message group or thread

Only active subscribers with digest option not selected are returned

Parameters:
oConn - Database Connection
Returns:
Array of e-mail addresses as strings
Throws:
java.sql.SQLException
Since:
4.0

countVotes

public int countVotes(JDCConnection oConn)
               throws java.sql.SQLException
Count number of votes of a message

Parameters:
oConn - Database Connection
Returns:
Count of rows from k_newsmsg_vote table having gu_msg as current message
Throws:
java.sql.SQLException
Since:
4.0

tags

public java.util.HashMap<java.lang.String,NewsMessageTag> tags()
Get tags for this message

Returns:
HashMap of NewsMessageTag objects
Since:
5.0

delete

public static boolean delete(JDCConnection oConn,
                             java.lang.String sNewsMsgGUID)
                      throws java.sql.SQLException

Delete NewsMessage.

Files attached to NewsMessage (stored as Products) are delete prior to the NewsMessage itself. Then k_sp_del_newsmsg stored procedure is called.

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