org.olat.core.commons.services.commentAndRating
Class UserCommentsManager

java.lang.Object
  extended by org.olat.core.logging.LogDelegator
      extended by org.olat.core.commons.services.commentAndRating.UserCommentsManager
Direct Known Subclasses:
UserCommentsManagerImpl

public abstract class UserCommentsManager
extends LogDelegator

Description:
The user comment manager provides methods to comment any given OLATResourceable object. To use this manager, make sure a proper implementation for the bean 'org.olat.core.commons.services.commentAndRating.UserCommentsManager' is defined in the spring configuration.

Initial Date: 23.11.2009

Author:
gnaegi

Constructor Summary
UserCommentsManager()
           
 
Method Summary
abstract  java.lang.Long countComments()
           
abstract  UserComment createComment(Identity creator, java.lang.String commentText)
          Create a new comment for the configured resource
abstract  int deleteAllComments()
          Delete all comments and replies for the configured resource and sub path
abstract  int deleteAllCommentsIgnoringSubPath()
          Delete all comments and replies for the configured resource while ignoring the sub path.
abstract  int deleteComment(UserComment comment, boolean deleteReplies)
          Delete a comment
abstract  java.util.List<UserComment> getComments()
          Get a list of user comments for the configured resource
static UserCommentsManager getInstance(OLATResourceable ores, java.lang.String subpath)
          Factory method to create a comment manager for the given OLATResourceable.
 void init(OLATResourceable ores, java.lang.String subpath)
          Helper method to set the olat resource for this manager
abstract  UserComment reloadComment(UserComment comment)
          Reload the given user comment with the most recent version from the database
abstract  UserComment replyTo(UserComment originalComment, Identity creator, java.lang.String replyCommentText)
          Reply to an existing comment
abstract  UserComment updateComment(UserComment comment, java.lang.String newCommentText)
          Update a comment.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UserCommentsManager

public UserCommentsManager()
Method Detail

getInstance

public static final UserCommentsManager getInstance(OLATResourceable ores,
                                                    java.lang.String subpath)
Factory method to create a comment manager for the given OLATResourceable. Note that this manager is statefully initialized with the OLATResourceable.

Parameters:
ores - The olat resourceable that provides a typename and a type id
subpath - an optional string that defines any subpath. Use this when your ores is not specific enough
Returns:

init

public void init(OLATResourceable ores,
                 java.lang.String subpath)
Helper method to set the olat resource for this manager

Parameters:
ores -
subpath -

countComments

public abstract java.lang.Long countComments()
Returns:
The number of comments for the configured resource. 0 if no comments are available.

getComments

public abstract java.util.List<UserComment> getComments()
Get a list of user comments for the configured resource


createComment

public abstract UserComment createComment(Identity creator,
                                          java.lang.String commentText)
Create a new comment for the configured resource

Parameters:
creator - The author of the comment
comment - The commentText
Returns:

reloadComment

public abstract UserComment reloadComment(UserComment comment)
Reload the given user comment with the most recent version from the database

Returns:
the reloaded user comment or NULL if the comment does not exist anymore

replyTo

public abstract UserComment replyTo(UserComment originalComment,
                                    Identity creator,
                                    java.lang.String replyCommentText)
Reply to an existing comment

Parameters:
originalComment - The comment to which the user replied
creator - The author of the reply
replyCommentText - The reply text
Returns:
The reply or NULL if the given original comment has been deleted in the meantime

updateComment

public abstract UserComment updateComment(UserComment comment,
                                          java.lang.String newCommentText)
Update a comment. This will first reload the comment object and then update this new object to reduce stale object issues. Make sure you replace your object in your data model with the returned user comment object.

Parameters:
comment - The comment which should be updated
newCommentText - The updated comment text
Returns:
the updated comment object. Might be a different object than the comment riven as attribute or NULL if the comment has been deleted in the meantime and could not be updated at all.

deleteComment

public abstract int deleteComment(UserComment comment,
                                  boolean deleteReplies)
Delete a comment

Parameters:
comment -
deleteReplies - true: cascade delete comment, also any existing replies; false: don't delete replies, unlink them so they appear as new comments
int - number of deleted comments (including replies)

deleteAllComments

public abstract int deleteAllComments()
Delete all comments and replies for the configured resource and sub path

Returns:
the number of deleted comments

deleteAllCommentsIgnoringSubPath

public abstract int deleteAllCommentsIgnoringSubPath()
Delete all comments and replies for the configured resource while ignoring the sub path. Use this to delete all comments e.g. from a blog for all blog posts in one query

Returns: