Class ForumsDAO
java.lang.Object
org.silverpeas.components.forums.service.ForumsDAO
Class managing database accesses for forums.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddLastVisit(Connection con, String userId, int messageId) Adds an access date to the message corresponding to the message id by the user.voidaddModerator(Connection con, ForumPK forumPK, String userId) Adds the role of moderator to the user on the forum corresponding to the primary key.intcreateForum(Connection con, ForumPK forumPK, String forumName, String forumDescription, String forumCreator, int forumParent, String categoryId) Creates a forum.intcreateMessage(Connection con, String messageTitle, String messageAuthor, Date messageDate, int forumId, int messageParent, String status) Creates a message.voiddeleteAllForums(Connection con, String instanceId) voiddeleteForum(Connection con, ForumPK forumPK) Deletes the forum corresponding to the primary key.voiddeleteMessage(Connection con, MessagePK messagePK) Deletes the message corresponding to the primary key.voiddeleteVisit(Connection con, String userId, int messageId) Deletes the access date of the user to the message corresponding to the message id.intgetAuthorNbMessages(Connection con, String userId, String status) getForum(Connection con, ForumPK forumPK) getForumCreatorId(Connection con, int forumId) getForumDetail(Connection con, ForumPK forumPK) getForumInstanceId(Connection con, int forumId) getForumName(Connection con, int forumId) intgetForumParentId(Connection con, int forumId) getForumsList(Connection con, ForumPK forumPK) getForumsListByCategory(Connection con, ForumPK forumPK, String categoryId) getForumSonsIds(Connection con, ForumPK forumPK) getLastMessage(Connection con, ForumPK forumPK, String status) getLastMessage(Connection con, ForumPK forumPK, List<String> messageParentIds, String status) getLastMessageRSS(Connection con, String instanceId) getLastVisit(Connection con, String userId, List<String> messageIds) getMessage(Connection con, MessagePK messagePK) intgetMessageParentId(Connection con, int messageId) getMessagesIds(Connection con, ForumPK forumPK, int messageParentId) getMessagesList(Connection con, ForumPK forumPK) getMessageSons(Connection con, MessagePK messagePK) getMessageTitle(Connection con, int messageId) getModerators(Connection con, int forumId) intgetNbMessages(Connection con, int forumId, String type, String status) intgetNbResponses(Connection con, int forumId, int messageId, String status) getSubjectsIds(Connection con, ForumPK forumPK) booleanisForumActive(Connection con, int forumId) booleanisModerator(Connection con, ForumPK forumPK, String userId) voidlockForum(Connection con, ForumPK forumPK, int level) Locks the forum corresponding to the primary key.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.voidremoveAllModerators(Connection con, ForumPK forumPK) Removes the role of moderator to all users on the forum corresponding to the primary key.voidremoveModerator(Connection con, ForumPK forumPK, String userId) Removes the role of moderator to the user on the forum corresponding to the primary key.selectByForumPKs(Connection con, Collection<ForumPK> forumPKs) intunlockForum(Connection con, ForumPK forumPK, int level) Unlocks the forum corresponding to the primary key.voidupdateForum(Connection con, ForumPK forumPK, String forumName, String forumDescription, int forumParent, String categoryId) Updates the forum corresponding to the primary key.voidupdateMessage(Connection con, MessagePK messagePK, String title, String status) Updates the message corresponding to the primary key.
-
Constructor Details
-
ForumsDAO
public ForumsDAO()
-
-
Method Details
-
selectByForumPKs
public 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.
-
getForumsList
- 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.
-
getForumsListByCategory
public 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.
-
getForumSonsIds
- 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.
-
getForum
- 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.
-
getForumName
- 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.
-
isForumActive
- 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.
-
getForumParentId
- 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.
-
getForumInstanceId
- 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.
-
getForumCreatorId
- 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.
-
lockForum
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.
-
unlockForum
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:
- the operation status. 0 is ok, any other values are an error code.
- Throws:
SQLException- An SQL exception.
-
createForum
public 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.
-
updateForum
public 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.
-
deleteForum
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.
-
deleteAllForums
- Throws:
SQLException
-
getMessagesList
- 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.
-
getMessagesIds
public 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.
-
getSubjectsIds
- 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.
-
getNbMessages
public 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.
-
getAuthorNbMessages
- 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.
-
getNbResponses
- 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.
-
getLastMessage
- 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.
-
getLastMessageRSS
- 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.
-
getLastMessage
public 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.
-
getMessage
- 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.
-
getMessageTitle
- Parameters:
con- The connection to the database.messageId- The id of the message.- Returns:
- The title of the message.
- Throws:
SQLException- An SQL exception.
-
getMessageParentId
- 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.
-
createMessage
public 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.
-
updateMessage
public 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.
-
deleteMessage
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.
-
getMessageSons
- 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.
-
isModerator
- 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.
-
addModerator
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.
-
removeModerator
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.
-
removeAllModerators
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.
-
getModerators
- Throws:
SQLException
-
moveMessage
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.
-
getForumDetail
- 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.
-
getLastVisit
public 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.
-
addLastVisit
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.
-
deleteVisit
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.
-