View Javadoc
1   /*
2    * Copyright (C) 2003-2007 eXo Platform SAS.
3    *
4    * This program is free software; you can redistribute it and/or
5    * modify it under the terms of the GNU Affero General Public License
6    * as published by the Free Software Foundation; either version 3
7    * of the License, or (at your option) any later version.
8    *
9    * This program is distributed in the hope that it will be useful,
10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12   * GNU General Public License for more details.
13   *
14   * You should have received a copy of the GNU General Public License
15   * along with this program; if not, see<http://www.gnu.org/licenses/>.
16   */
17  package org.exoplatform.services.cms.voting;
18  
19  import javax.jcr.Node;
20  
21  /**
22   * Created by The eXo Platform SAS
23   * Author : Pham Xuan Hoa
24   *          hoa.pham@exoplatform.com
25   * Jan 17, 2007
26   */
27  public interface VotingService {
28  
29    /**
30     * Voting the document is specified by the node by giving the rate, username, and language params
31     * Any language belongs to this document can be voted.
32     * This method uses variables to store values which are voted from user for all kind languages
33     * of this document
34     * @param document        The node document for voting
35     * @param rate            The number rate for voting
36     * @param userName        The username of current user is voting.
37     *                        Can not be <code>null</code>
38     * @param language        The language of this document for voting
39     *                        Can not be <code>null</code>
40     * @see                   Node
41     * @throws Exception
42     */
43    public void vote(Node document, double rate, String userName, String language) throws Exception;
44  
45    /**
46     * Gets total voting for all kind languages of this document is specified by node
47     * @param node            The node document is specified to get total voting
48     * @see                   Node
49     * @return
50     * @throws Exception
51     */
52    public long getVoteTotal(Node node) throws Exception;
53  
54    /**
55     * Check if user had already voted on the given node or not
56     * 
57     * @param node the node that will be voted
58     * @param userName the name of user had voted
59     * @param language language of to-be-voted node
60     * @return
61     * @throws Exception
62     */
63    public boolean isVoted(Node node, String userName, String language) throws Exception;
64    
65    /**
66     * returns user's vote value on the given node
67     * 
68     * @param node the node that will be voted
69     * @param userName the name of user had voted
70     * @param language language of to-be-voted node
71     * @return
72     * @throws Exception
73     */  
74    public double getVoteValueOfUser(Node node, String userName, String language) throws Exception; 
75  
76  }