001/*
002 * (C) Copyright 2006-2007 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     Nuxeo - initial API and implementation
018 *
019 * $Id$
020 */
021
022package org.nuxeo.ecm.platform.comment.web;
023
024import java.util.List;
025
026import javax.faces.event.ActionEvent;
027
028import org.nuxeo.ecm.core.api.DocumentModel;
029import org.nuxeo.ecm.platform.actions.Action;
030
031/**
032 * Provides comment manager related operations.
033 *
034 * @author <a href="mailto:glefter@nuxeo.com">George Lefter</a>
035 */
036public interface CommentManagerActions {
037
038    String CHILDREN_COMMENT_LIST = "CHILDREN_COMMENT_LIST";
039
040    /**
041     * @return available action for COMMENTS_ACTIONS
042     */
043    List<Action> getActionsForComment();
044
045    /**
046     * @return available action for given category
047     */
048    List<Action> getActionsForComment(String category);
049
050    /**
051     * Bean initialization method.
052     */
053    void initialize();
054
055    /**
056     * Clean all the bean's context variables.
057     */
058    void documentChanged();
059
060    /**
061     * Initializes uiComments with currentDocument.
062     */
063    void initComments();
064
065    /**
066     * Initializes uiComments with given Document.
067     */
068    void initComments(DocumentModel commentedDoc);
069
070    /**
071     * Initializes uiComments with currentDocument if uiComments is null.
072     *
073     * @return list of ThreadEntry for currentDocument
074     */
075    List<ThreadEntry> getCommentsAsThread();
076
077    /**
078     * Initialize uiComments with given Document if uiComments is null.
079     *
080     * @return list of ThreadEntry for given Document.
081     */
082    List<ThreadEntry> getCommentsAsThread(DocumentModel commentedDoc);
083
084    /**
085     * @return list of ThreadEntry for given Document.
086     */
087    List<ThreadEntry> getCommentsAsThreadOnDoc(DocumentModel doc);
088
089    String beginComment();
090
091    String cancelComment();
092
093    /**
094     * creates a new comment from
095     *
096     * @return null to avoid navigation
097     */
098    String addComment();
099
100    /**
101     * Same as addComment() method but using the given document instead of currentDocument.
102     *
103     * @return null to avoid navigation
104     */
105    String createComment(DocumentModel docToComment);
106
107    /**
108     * Add the given comment DocumentModel to commentableDoc.
109     */
110    DocumentModel addComment(DocumentModel comment);
111
112    String deleteComment();
113
114    String deleteComment(String commentId);
115
116    void destroy();
117
118    String getNewContent();
119
120    void setNewContent(String newContent);
121
122    String getPrincipalName();
123
124    boolean getPrincipalIsAdmin();
125
126    boolean getCommentStarted();
127
128    String getSavedReplyCommentId();
129
130    void setSavedReplyCommentId(String savedReplyCommentId);
131
132    boolean getShowCreateForm();
133
134    void setShowCreateForm(boolean flag);
135
136    void toggleCreateForm(ActionEvent event);
137
138    // List<UIComment> getUiComments();
139
140    /***
141     * Retrieves a given number of comments from currentDocument.
142     *
143     * @param commentNumber the number of comment to fetch
144     */
145    List<UIComment> getLastCommentsByDate(String commentNumber);
146
147    /***
148     * Retrieves a given number of comments from the given Document.
149     *
150     * @param commentNumber the number of comment to fetch
151     * @param commentedDoc
152     */
153    List<UIComment> getLastCommentsByDate(String commentNumber, DocumentModel commentedDoc);
154}