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;
}
Aggregations