org.olat.modules.fo
Class ForumManager

java.lang.Object
  extended by org.olat.core.logging.LogDelegator
      extended by org.olat.modules.fo.ForumManager

public class ForumManager
extends LogDelegator

Author:
Felix Jost

Method Summary
 Forum addAForum()
           
 void addTopMessage(Identity creator, Forum forum, Message topMessage)
           
 java.lang.Integer countMessagesByForumID(java.lang.Long forumkey)
           
 int countReadMessagesByUserAndForum(Identity identity, java.lang.Long forumkey)
          Implementation with one entry per message.
 Message createMessage()
          creates (in RAM only) a new Message
fill the values and use saveMessage to make it persistent
 void deleteForum(java.lang.Long forumKey)
           
 void deleteMessageTree(java.lang.Long forumKey, Message m)
           
 Message findMessage(java.lang.Long messageId)
           
 java.util.List<java.lang.Long> getAllForumKeys()
           
static ForumManager getInstance()
           
 OlatRootFolderImpl getMessageContainer(java.lang.Long forumKey, java.lang.Long messageKey)
           
 java.util.List<Message> getMessagesByForum(Forum forum)
           
 java.util.List<Message> getMessagesByForumID(java.lang.Long forum_id)
           
 java.util.List<Message> getNewMessageInfo(java.lang.Long forumKey, java.util.Date latestRead)
           
 java.util.Set<java.lang.Long> getReadSet(Identity identity, Forum forum)
           
 java.util.List<Message> getThread(java.lang.Long msgid)
           
 boolean hasChildren(Message m)
           
 Forum loadForum(java.lang.Long forumKey)
           
 Message loadMessage(java.lang.Long messageKey)
           
 void markAsRead(Identity identity, Message msg)
          Implementation with one entry per forum message.
 Message moveMessage(Message msg, Message topMsg)
          Moves the current message from the current thread in another thread.
 void replyToMessage(Message newMessage, Identity creator, Message replyToMessage)
          sets the parent and threadtop of the message automatically
 Message splitThread(Message msg)
          Splits the current thread starting from the current message.
 void updateCounters(Message m)
          Update the counters for words and characters
 void updateMessage(Message m, ForumChangedEvent event)
          Update message and fire MultiUserEvent, if any provided.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static ForumManager getInstance()
Returns:
the singleton

getThread

public java.util.List<Message> getThread(java.lang.Long msgid)
Parameters:
msgid - msg id of the topthread
Returns:
List messages

getAllForumKeys

public java.util.List<java.lang.Long> getAllForumKeys()

getMessagesByForum

public java.util.List<Message> getMessagesByForum(Forum forum)

getMessagesByForumID

public java.util.List<Message> getMessagesByForumID(java.lang.Long forum_id)
Parameters:
forum -
Returns:
List messages

countMessagesByForumID

public java.lang.Integer countMessagesByForumID(java.lang.Long forumkey)
Parameters:
forumkey -
Returns:
the count of all messages by this forum

countReadMessagesByUserAndForum

public int countReadMessagesByUserAndForum(Identity identity,
                                           java.lang.Long forumkey)
Implementation with one entry per message.

Parameters:
identity -
forumkey -
Returns:
number of read messages

getNewMessageInfo

public java.util.List<Message> getNewMessageInfo(java.lang.Long forumKey,
                                                 java.util.Date latestRead)
Parameters:
forumKey -
latestRead -
Returns:
a List of Object[] with a key(Long), title(String), a creator(Identity), and the lastmodified(Date) of the messages of the forum with the given key and with last modification after the "latestRead" Date

addAForum

public Forum addAForum()
Returns:
the newly created and persisted forum

loadForum

public Forum loadForum(java.lang.Long forumKey)
Parameters:
forumKey -
Returns:
the forum with the given key

deleteForum

public void deleteForum(java.lang.Long forumKey)
Parameters:
forumKey -

replyToMessage

public void replyToMessage(Message newMessage,
                           Identity creator,
                           Message replyToMessage)
sets the parent and threadtop of the message automatically

Parameters:
newMessage - the new message which has title and body set
creator -
replyToMessage -

addTopMessage

public void addTopMessage(Identity creator,
                          Forum forum,
                          Message topMessage)
Parameters:
creator -
forum -
topMessage -

loadMessage

public Message loadMessage(java.lang.Long messageKey)
Parameters:
messageKey -
Returns:
the message with the given messageKey

createMessage

public Message createMessage()
creates (in RAM only) a new Message
fill the values and use saveMessage to make it persistent

Returns:
the message
See Also:
saveMessage(Message)

updateMessage

public void updateMessage(Message m,
                          ForumChangedEvent event)
Update message and fire MultiUserEvent, if any provided. If a not null ForumChangedEvent object is provided, then fire event to listeners.

Parameters:
m -
event -

deleteMessageTree

public void deleteMessageTree(java.lang.Long forumKey,
                              Message m)
Parameters:
forumKey -
m -

hasChildren

public boolean hasChildren(Message m)
Parameters:
m -
Returns:
true if the message has children

getMessageContainer

public OlatRootFolderImpl getMessageContainer(java.lang.Long forumKey,
                                              java.lang.Long messageKey)
Parameters:
forumKey -
messageKey -
Returns:
the valid container for the attachments to place into

findMessage

public Message findMessage(java.lang.Long messageId)

splitThread

public Message splitThread(Message msg)
Splits the current thread starting from the current message. It updates the messages of the selected subthread by setting the Parent and the Threadtop.

Parameters:
msgid -
Returns:
the top message of the newly created thread.

moveMessage

public Message moveMessage(Message msg,
                           Message topMsg)
Moves the current message from the current thread in another thread.

Parameters:
msg -
topMsg -
Returns:
the moved message

getReadSet

public java.util.Set<java.lang.Long> getReadSet(Identity identity,
                                                Forum forum)
Parameters:
identity -
forum -
Returns:
a set with the read messages keys for the input identity and forum.

markAsRead

public void markAsRead(Identity identity,
                       Message msg)
Implementation with one entry per forum message. Adds a new entry into the ReadMessage for the input message and identity.

Parameters:
msg -
identity -

updateCounters

public void updateCounters(Message m)
Update the counters for words and characters

Parameters:
m - the message