Class ForumsDAO
- java.lang.Object
- 
- org.silverpeas.components.forums.service.ForumsDAO
 
- 
 public class ForumsDAO extends Object Class managing database accesses for forums.
- 
- 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static voidaddLastVisit(Connection con, String userId, int messageId)Adds an access date to the message corresponding to the message id by the user.static voidaddModerator(Connection con, ForumPK forumPK, String userId)Adds the role of moderator to the user on the forum corresponding to the primary key.static intcreateForum(Connection con, ForumPK forumPK, String forumName, String forumDescription, String forumCreator, int forumParent, String categoryId)Creates a forum.static intcreateMessage(Connection con, String messageTitle, String messageAuthor, Date messageDate, int forumId, int messageParent, String status)Creates a message.static voiddeleteAllForums(Connection con, String instanceId)static voiddeleteForum(Connection con, ForumPK forumPK)Deletes the forum corresponding to the primary key.static voiddeleteMessage(Connection con, MessagePK messagePK)Deletes the message corresponding to the primary key.static voiddeleteVisit(Connection con, String userId, int messageId)Deletes the access date of the user to the message corresponding to the message id.static Collection<String>getAllMessageSons(Connection con, MessagePK messagePK)static intgetAuthorNbMessages(Connection con, String userId, String status)static ForumgetForum(Connection con, ForumPK forumPK)static StringgetForumCreatorId(Connection con, int forumId)static ForumDetailgetForumDetail(Connection con, ForumPK forumPK)static StringgetForumInstanceId(Connection con, int forumId)static StringgetForumName(Connection con, int forumId)static intgetForumParentId(Connection con, int forumId)static Collection<Forum>getForumsByKeys(Connection con, Collection<ForumPK> forumPKs)static List<String>getForumsIds(Connection con, ForumPK forumPK)static List<Forum>getForumsList(Connection con, ForumPK forumPK)static List<Forum>getForumsListByCategory(Connection con, ForumPK forumPK, String categoryId)static List<String>getForumSonsIds(Connection con, ForumPK forumPK)static MessagegetLastMessage(Connection con, ForumPK forumPK, String status)static MessagegetLastMessage(Connection con, ForumPK forumPK, List<String> messageParentIds, String status)static Collection<String>getLastMessageRSS(Connection con, String instanceId)static List<Message>getLastThreads(Connection con, ForumPK[] forumPKs, int count)static DategetLastVisit(Connection con, String userId, int messageId)static DategetLastVisit(Connection con, String userId, List<String> messageIds)static MessagegetMessage(Connection con, MessagePK messagePK)static ListgetMessageInfos(Connection con, MessagePK messagePK)static intgetMessageParentId(Connection con, int messageId)static Collection<Message>getMessagesByKeys(Connection con, Collection<MessagePK> messagePKs)static List<String>getMessagesIds(Connection con, ForumPK forumPK)static List<String>getMessagesIds(Connection con, ForumPK forumPK, int messageParentId)static List<Message>getMessagesList(Connection con, ForumPK forumPK)static Collection<String>getMessageSons(Connection con, MessagePK messagePK)static StringgetMessageTitle(Connection con, int messageId)static List<Moderator>getModerators(Connection con, int forumId)static intgetNbMessages(Connection con, int forumId, String type, String status)static intgetNbResponses(Connection con, int forumId, int messageId, String status)static Collection<Message>getNotAnsweredLastThreads(Connection con, ForumPK[] forumPKs, int count)static List<String>getSubjectsIds(Connection con, ForumPK forumPK)static MessagegetThread(Connection con, MessagePK messagePK)static Collection<Message>getThreadsByKeys(Connection con, Collection<MessagePK> messagePKs)static booleanisForumActive(Connection con, int forumId)static booleanisModerator(Connection con, ForumPK forumPK, String userId)static voidlockForum(Connection con, ForumPK forumPK, int level)Locks the forum corresponding to the primary key.static voidmoveMessage(Connection con, MessagePK messagePK, ForumPK forumPK)Moves the message corresponding to the message primary key from a previous forum to the one corresponding to the forum primary key.static voidremoveAllModerators(Connection con, ForumPK forumPK)Removes the role of moderator to all users on the forum corresponding to the primary key.static voidremoveModerator(Connection con, ForumPK forumPK, String userId)Removes the role of moderator to the user on the forum corresponding to the primary key.static Collection<ForumDetail>selectByForumPKs(Connection con, Collection<ForumPK> forumPKs)static intunlockForum(Connection con, ForumPK forumPK, int level)Unlocks the forum corresponding to the primary key.static voidupdateForum(Connection con, ForumPK forumPK, String forumName, String forumDescription, int forumParent, String categoryId)Updates the forum corresponding to the primary key.static voidupdateMessage(Connection con, MessagePK messagePK, String title, String status)Updates the message corresponding to the primary key.
 
- 
- 
- 
Method Detail- 
selectByForumPKspublic static Collection<ForumDetail> selectByForumPKs(Connection con, Collection<ForumPK> forumPKs) throws SQLException - Parameters:
- con- The connection to the database.
- forumPKs- The list of forums primary keys.
- Returns:
- The list of forums corresponding to the primary keys (ForumDetail).
- Throws:
- SQLException- An SQL exception.
 
 - 
getForumsByKeyspublic static Collection<Forum> getForumsByKeys(Connection con, Collection<ForumPK> forumPKs) throws SQLException - Parameters:
- con- The connection to the database.
- forumPKs- The list of forums primary keys.
- Returns:
- The list of forums corresponding to the primary keys (Forum).
- Throws:
- SQLException- An SQL exception.
 
 - 
getMessagesByKeyspublic static Collection<Message> getMessagesByKeys(Connection con, Collection<MessagePK> messagePKs) throws SQLException - Parameters:
- con- The connection to the database.
- messagePKs- The list of messages primary keys.
- Returns:
- The list of messages corresponding to the primary keys (Message).
- Throws:
- SQLException- An SQL exception.
 
 - 
getThreadsByKeyspublic static Collection<Message> getThreadsByKeys(Connection con, Collection<MessagePK> messagePKs) throws SQLException - Parameters:
- con- The connection to the database.
- messagePKs- The list of messages primary keys.
- Returns:
- The list of threads corresponding to the primary keys (Message).
- Throws:
- SQLException- An SQL exception.
 
 - 
getForumsListpublic static List<Forum> getForumsList(Connection con, ForumPK forumPK) throws SQLException - Parameters:
- con- The connection to the database.
- forumPK- The primary key of the forum.
- Returns:
- The list of forums corresponding to the primary key (Forum).
- Throws:
- SQLException- An SQL exception.
 
 - 
getForumsIdspublic static List<String> getForumsIds(Connection con, ForumPK forumPK) throws SQLException - Parameters:
- con- The connection to the database.
- forumPK- The primary key of the forum.
- Returns:
- The list of ids of forums corresponding to the primary key.
- Throws:
- SQLException- An SQL exception.
 
 - 
getForumsListByCategorypublic static List<Forum> getForumsListByCategory(Connection con, ForumPK forumPK, String categoryId) throws SQLException - Parameters:
- con- The connection to the database.
- forumPK- The primary key of the forum.
- categoryId- The id of the category.
- Returns:
- The list of forums corresponding to the primary key and the category id.
- Throws:
- SQLException- An SQL exception.
 
 - 
getForumSonsIdspublic static List<String> getForumSonsIds(Connection con, ForumPK forumPK) throws SQLException - Parameters:
- con- The connection to the database.
- forumPK- The primary key of the forum.
- Returns:
- The list of ids of forums which parent is the forum corresponding to the primary key.
- Throws:
- SQLException- An SQL exception.
 
 - 
getForumpublic static Forum getForum(Connection con, ForumPK forumPK) throws SQLException - Parameters:
- con- The connection to the database.
- forumPK- The primary key of the forum.
- Returns:
- The forum corresponding to the primary key (Forum).
- Throws:
- SQLException- An SQL exception.
 
 - 
getForumNamepublic static String getForumName(Connection con, int forumId) throws SQLException - Parameters:
- con- The connection to the database.
- forumId- The id of the forum.
- Returns:
- The name corresponding to the forum id.
- Throws:
- SQLException- An SQL exception.
 
 - 
isForumActivepublic static boolean isForumActive(Connection con, int forumId) throws SQLException - Parameters:
- con- The connection to the database.
- forumId- The id of the forum.
- Returns:
- True if the forum is active.
- Throws:
- SQLException- An SQL exception.
 
 - 
getForumParentIdpublic static int getForumParentId(Connection con, int forumId) throws SQLException - Parameters:
- con- The connection to the database.
- forumId- The id of the forum.
- Returns:
- The id of the parent of the forum.
- Throws:
- SQLException- An SQL exception.
 
 - 
getForumInstanceIdpublic static String getForumInstanceId(Connection con, int forumId) throws SQLException - Parameters:
- con- The connection to the database.
- forumId- The id of the forum.
- Returns:
- The instance id corresponding to the forum id.
- Throws:
- SQLException- An SQL exception.
 
 - 
getForumCreatorIdpublic static String getForumCreatorId(Connection con, int forumId) throws SQLException - Parameters:
- con- The connection to the database.
- forumId- The id of the forum.
- Returns:
- The id of the creator of the forum.
- Throws:
- SQLException- An SQL exception.
 
 - 
lockForumpublic static void lockForum(Connection con, ForumPK forumPK, int level) throws SQLException Locks the forum corresponding to the primary key.- Parameters:
- con- The connection to the database.
- forumPK- The primary key of the forum.
- level- The lock level.
- Throws:
- SQLException- An SQL exception.
 
 - 
unlockForumpublic static int unlockForum(Connection con, ForumPK forumPK, int level) throws SQLException Unlocks the forum corresponding to the primary key.- Parameters:
- con- The connection to the database.
- forumPK- The primary key of the forum.
- level- The lock level.
- Returns:
- Throws:
- SQLException- An SQL exception.
 
 - 
createForumpublic static int createForum(Connection con, ForumPK forumPK, String forumName, String forumDescription, String forumCreator, int forumParent, String categoryId) throws SQLException Creates a forum.- Parameters:
- con- The connection to the database.
- forumPK- The primary key of the forum.
- forumName- The name of the forum.
- forumDescription- The description of the forum.
- forumCreator- The creator of the forum.
- forumParent- The id of the forum's parent forum.
- categoryId- The id of the category.
- Returns:
- The id of the newly created forum.
- Throws:
- SQLException- An SQL exception.
 
 - 
updateForumpublic static void updateForum(Connection con, ForumPK forumPK, String forumName, String forumDescription, int forumParent, String categoryId) throws SQLException Updates the forum corresponding to the primary key.- Parameters:
- con- The connection to the database.
- forumPK- The primary key of the forum.
- forumName- The name of the forum.
- forumDescription- The description of the forum.
- forumParent- The id of the forum's parent forum.
- categoryId- The id of the category.
- Throws:
- SQLException- An SQL exception.
 
 - 
deleteForumpublic static void deleteForum(Connection con, ForumPK forumPK) throws SQLException Deletes the forum corresponding to the primary key.- Parameters:
- con- The connection to the database.
- forumPK- The primary key of the forum.
- Throws:
- SQLException- An SQL exception.
 
 - 
deleteAllForumspublic static void deleteAllForums(Connection con, String instanceId) throws SQLException - Throws:
- SQLException
 
 - 
getMessagesListpublic static List<Message> getMessagesList(Connection con, ForumPK forumPK) throws SQLException - Parameters:
- con- The connection to the database.
- forumPK- The primary key of the forum.
- Returns:
- The list of messages of the forum corresponding to the primary key (Message).
- Throws:
- SQLException- An SQL exception.
 
 - 
getMessagesIdspublic static List<String> getMessagesIds(Connection con, ForumPK forumPK, int messageParentId) throws SQLException - Parameters:
- con- The connection to the database.
- forumPK- The primary key of the forum.
- messageParentId- The id of the message's parent message.
- Returns:
- The list of ids of messages of the forum corresponding to the primary key and which parent message corresponds to the message id (if it is valued).
- Throws:
- SQLException- An SQL exception.
 
 - 
getMessagesIdspublic static List<String> getMessagesIds(Connection con, ForumPK forumPK) throws SQLException - Parameters:
- con- The connection to the database.
- forumPK- The primary key of the forum.
- Returns:
- The list of ids of messages of the forum corresponding to the primary key.
- Throws:
- SQLException- An SQL exception.
 
 - 
getSubjectsIdspublic static List<String> getSubjectsIds(Connection con, ForumPK forumPK) throws SQLException - Parameters:
- con- The connection to the database.
- forumPK- The primary key of the forum.
- Returns:
- The list of ids of threads of the forum corresponding to the primary key.
- Throws:
- SQLException- An SQL exception.
 
 - 
getNbMessagespublic static int getNbMessages(Connection con, int forumId, String type, String status) throws SQLException - Parameters:
- con- The connection to the database.
- forumId- The id of the forum.
- type- The type of the searched messages.
- Returns:
- The number of messages corresponding to the forum id and the type (threads or not).
- Throws:
- SQLException- An SQL exception.
 
 - 
getAuthorNbMessagespublic static int getAuthorNbMessages(Connection con, String userId, String status) throws SQLException - Parameters:
- con- The connection to the database.
- userId- The user's id.
- Returns:
- The number of messages written by the author corresponding to the user id.
- Throws:
- SQLException- An SQL exception.
 
 - 
getNbResponsespublic static int getNbResponses(Connection con, int forumId, int messageId, String status) - Parameters:
- con- The connection to the database.
- forumId- The id of the forum.
- messageId- The id of the message.
- Returns:
- The number of responses to the message corresponding to the message id and the forum id.
 
 - 
getLastMessagepublic static Message getLastMessage(Connection con, ForumPK forumPK, String status) throws SQLException - Parameters:
- con- The connection to the database.
- forumPK- The primary key of the forum.
- Returns:
- The last message of the forum corresponding to the forum id.
- Throws:
- SQLException- An SQL exception.
 
 - 
getLastThreadspublic static List<Message> getLastThreads(Connection con, ForumPK[] forumPKs, int count) throws SQLException - Parameters:
- con- The connection to the database.
- forumPKs- The list of forums primary keys.
- count- The maximum number of returned threads.
- Returns:
- The last 'count' threads from the forums corresponding to the primary keys.
- Throws:
- SQLException- An SQL exception.
 
 - 
getNotAnsweredLastThreadspublic static Collection<Message> getNotAnsweredLastThreads(Connection con, ForumPK[] forumPKs, int count) throws SQLException - Parameters:
- con- The connection to the database.
- forumPKs- The list of forums primary keys.
- count- The maximum number of returned threads.
- Returns:
- The last not answered 'count' threads from the forums corresponding to the primary keys.
- Throws:
- SQLException- An SQL exception.
 
 - 
getLastMessageRSSpublic static Collection<String> getLastMessageRSS(Connection con, String instanceId) throws SQLException - Parameters:
- con- The connection to the database.
- instanceId- The id of the forums instance.
- Returns:
- The list of ids of messages from the forums corresponding to the instance id.
- Throws:
- SQLException- An SQL exception.
 
 - 
getLastMessagepublic static Message getLastMessage(Connection con, ForumPK forumPK, List<String> messageParentIds, String status) throws SQLException - Parameters:
- con- The connection to the database.
- forumPK- The primary key of the forum.
- messageParentIds- The ids of the parent messages.
- Returns:
- The last message from the forum corresponding to the primary key among the messages which id or parent message id belong to the list.
- Throws:
- SQLException- An SQL exception.
 
 - 
getMessageInfospublic static List getMessageInfos(Connection con, MessagePK messagePK) throws SQLException - Parameters:
- con- The connection to the database.
- messagePK- The primary key of the message.
- Returns:
- The message corresponding to the primary key (Vector).
- Throws:
- SQLException- An SQL exception.
 
 - 
getMessagepublic static Message getMessage(Connection con, MessagePK messagePK) throws SQLException - Parameters:
- con- The connection to the database.
- messagePK- The primary key of the message.
- Returns:
- The message corresponding to the primary key (Message).
- Throws:
- SQLException- An SQL exception.
 
 - 
getMessageTitlepublic static String getMessageTitle(Connection con, int messageId) throws SQLException - Parameters:
- con- The connection to the database.
- messageId- The id of the message.
- Returns:
- The title of the message..
- Throws:
- SQLException- An SQL exception.
 
 - 
getMessageParentIdpublic static int getMessageParentId(Connection con, int messageId) throws SQLException - Parameters:
- con- The connection to the database.
- messageId- The id of the message.
- Returns:
- The id of the parent of the message..
- Throws:
- SQLException- An SQL exception.
 
 - 
getThreadpublic static Message getThread(Connection con, MessagePK messagePK) throws SQLException - Parameters:
- con- The connection to the database.
- messagePK- The primary key of the message.
- Returns:
- The thread corresponding to the primary key (Message).
- Throws:
- SQLException- An SQL exception.
 
 - 
createMessagepublic static int createMessage(Connection con, String messageTitle, String messageAuthor, Date messageDate, int forumId, int messageParent, String status) throws SQLException Creates a message.- Parameters:
- con- The connection to the database.
- messageTitle- The title of the message.
- messageAuthor- The author of the message.
- messageDate- The date of creation of the message.
- forumId- The id of the parent forum.
- messageParent- The id of the parent message.
- Returns:
- The id of the newly created message.
- Throws:
- SQLException- An SQL exception.
 
 - 
updateMessagepublic static void updateMessage(Connection con, MessagePK messagePK, String title, String status) throws SQLException Updates the message corresponding to the primary key.- Parameters:
- con- The connection to the database.
- messagePK- The primary key of the message.
- title- The title of the message.
- Throws:
- SQLException- An SQL exception.
 
 - 
deleteMessagepublic static void deleteMessage(Connection con, MessagePK messagePK) throws SQLException Deletes the message corresponding to the primary key.- Parameters:
- con- The connection to the database.
- messagePK- The primary key of the message.
- Throws:
- SQLException- An SQL exception.
 
 - 
getMessageSonspublic static Collection<String> getMessageSons(Connection con, MessagePK messagePK) throws SQLException - Parameters:
- con- The connection to the database.
- messagePK- The primary key of the message.
- Returns:
- The list of ids of the messages which parent is the message corresponding to the primary key.
- Throws:
- SQLException- An SQL exception.
 
 - 
isModeratorpublic static boolean isModerator(Connection con, ForumPK forumPK, String userId) throws SQLException - Parameters:
- con- The connection to the database.
- forumPK- The primary key of the forum.
- userId- The user's id.
- Returns:
- True if the user owns the role of moderator on the forum corresponding to the primary key, else false.
- Throws:
- SQLException- An SQL exception.
 
 - 
addModeratorpublic static void addModerator(Connection con, ForumPK forumPK, String userId) throws SQLException Adds the role of moderator to the user on the forum corresponding to the primary key.- Parameters:
- con- The connection to the database.
- forumPK- The primary key of the forum.
- userId- The user's id.
- Throws:
- SQLException- An SQL exception.
 
 - 
removeModeratorpublic static void removeModerator(Connection con, ForumPK forumPK, String userId) throws SQLException Removes the role of moderator to the user on the forum corresponding to the primary key.- Parameters:
- con- The connection to the database.
- forumPK- The primary key of the forum.
- userId- The user's id.
- Throws:
- SQLException- An SQL exception.
 
 - 
removeAllModeratorspublic static void removeAllModerators(Connection con, ForumPK forumPK) throws SQLException Removes the role of moderator to all users on the forum corresponding to the primary key.- Parameters:
- con- The connection to the database.
- forumPK- The primary key of the forum.
- Throws:
- SQLException- An SQL exception.
 
 - 
getModeratorspublic static List<Moderator> getModerators(Connection con, int forumId) throws SQLException - Throws:
- SQLException
 
 - 
moveMessagepublic static void moveMessage(Connection con, MessagePK messagePK, ForumPK forumPK) throws SQLException Moves the message corresponding to the message primary key from a previous forum to the one corresponding to the forum primary key.- Parameters:
- con- The connection to the database.
- messagePK- The primary key of the message.
- forumPK- The primary key of the forum.
- Throws:
- SQLException- An SQL exception.
 
 - 
getAllMessageSonspublic static Collection<String> getAllMessageSons(Connection con, MessagePK messagePK) throws SQLException - Parameters:
- con- The connection to the database.
- messagePK- The primary key of the message.
- Returns:
- The list of ids of messages which parent is the message corresponding to the primary key.
- Throws:
- SQLException- An SQL exception.
 
 - 
getForumDetailpublic static ForumDetail getForumDetail(Connection con, ForumPK forumPK) throws SQLException - Parameters:
- con- The connection to the database.
- forumPK- The primary key of the forum.
- Returns:
- The forum corresponding to the primary key (ForumDetail).
- Throws:
- SQLException- An SQL exception.
 
 - 
getLastVisitpublic static Date getLastVisit(Connection con, String userId, int messageId) throws SQLException - Parameters:
- con- The connection to the database.
- userId- The user's id.
- messageId- The id of the message.
- Returns:
- The last access date to the message corresponding to the message id.
- Throws:
- SQLException- An SQL exception.
 
 - 
getLastVisitpublic static Date getLastVisit(Connection con, String userId, List<String> messageIds) throws SQLException - Parameters:
- con- The connection to the database.
- userId- The user's id.
- messageIds- The list of ids of the messages.
- Returns:
- The last access date of the user to the messages corresponding to the list of primary keys.
- Throws:
- SQLException- An SQL exception.
 
 - 
addLastVisitpublic static void addLastVisit(Connection con, String userId, int messageId) throws SQLException Adds an access date to the message corresponding to the message id by the user.- Parameters:
- con- The connection to the database.
- userId- The user's id.
- messageId- The id of the message.
- Throws:
- SQLException- An SQL exception.
 
 - 
deleteVisitpublic static void deleteVisit(Connection con, String userId, int messageId) throws SQLException Deletes the access date of the user to the message corresponding to the message id.- Parameters:
- con- The connection to the database.
- userId- The user's id.
- messageId- The id of the message.
- Throws:
- SQLException- An SQL exception.
 
 
- 
 
-