Search in sources :

Example 1 with CommentEntityManager

use of org.activiti.engine.impl.persistence.entity.CommentEntityManager in project Activiti by Activiti.

the class DeleteCommentCmd method execute.

public Void execute(CommandContext commandContext) {
    CommentEntityManager commentManager = commandContext.getCommentEntityManager();
    if (commentId != null) {
        // Delete for an individual comment
        Comment comment = commentManager.findComment(commentId);
        if (comment == null) {
            throw new ActivitiObjectNotFoundException("Comment with id '" + commentId + "' doesn't exists.", Comment.class);
        }
        commentManager.delete((CommentEntity) comment);
    } else {
        // Delete all comments on a task of process
        ArrayList<Comment> comments = new ArrayList<Comment>();
        if (processInstanceId != null) {
            comments.addAll(commentManager.findCommentsByProcessInstanceId(processInstanceId));
        }
        if (taskId != null) {
            comments.addAll(commentManager.findCommentsByTaskId(taskId));
        }
        for (Comment comment : comments) {
            commentManager.delete((CommentEntity) comment);
        }
    }
    return null;
}
Also used : Comment(org.activiti.engine.task.Comment) CommentEntityManager(org.activiti.engine.impl.persistence.entity.CommentEntityManager) ArrayList(java.util.ArrayList) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException)

Aggregations

ArrayList (java.util.ArrayList)1 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)1 CommentEntityManager (org.activiti.engine.impl.persistence.entity.CommentEntityManager)1 Comment (org.activiti.engine.task.Comment)1