1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.ratings

File ReputationAlgorithm.java

 

Code metrics

0
0
0
1
100
17
0
-
-
0
-

Classes

Class Line # Actions
ReputationAlgorithm 34 0 - 0 0
-1.0 -
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.ratings;
21   
22    import java.util.Map;
23   
24    import org.xwiki.component.annotation.Role;
25    import org.xwiki.model.reference.DocumentReference;
26   
27    /**
28    * Algorithm to calculate a user's reputation.
29    *
30    * @version $Id: 86cf6421ce5dd487a0020238138e99da2cbba257 $
31    * @since 6.4M3
32    */
33    @Role
 
34    public interface ReputationAlgorithm
35    {
36   
37    /**
38    * Gets current ratings manager.
39    *
40    * @param documentRef the document which the ratings are for
41    * @return the current RatingsManager
42    */
43    RatingsManager getRatingsManager(DocumentReference documentRef);
44   
45    /**
46    * Updates reputation after a vote.
47    *
48    * @param documentRef document on which the rating occurred
49    * @param rating rating set
50    * @param oldVote previous vote value
51    */
52    void updateReputation(DocumentReference documentRef, Rating rating, int oldVote);
53   
54    /**
55    * Recalculates the contributor reputation. Only the creator of the document will have it's reputation updated.
56    *
57    * @param voter Voter that will have it's reputation updated
58    * @param documentRef the document that was rated
59    * @param rating the new rating of the element, including who did the rating
60    * @param oldVote previous vote of the user
61    * @return AverageRating of the voter
62    * @throws ReputationException when an error occurs while calculating the new reputation
63    */
64    AverageRating calcNewVoterReputation(DocumentReference voter, DocumentReference documentRef, Rating rating,
65    int oldVote) throws ReputationException;
66   
67    /**
68    * Recalculates the contributors reputation.
69    *
70    * @param documentRef the document that was rated
71    * @param rating the new rating of the element, including who did the rating
72    * @param oldVote previous vote of the user
73    * @return map of AverageRating of each contributor of the page that has an updated reputation
74    * @throws ReputationException when an error occurs while calculating the new reputation
75    */
76    Map<String, AverageRating> calcNewAuthorsReputation(DocumentReference documentRef, Rating rating, int oldVote)
77    throws ReputationException;
78   
79    /**
80    * Recalculates the contributor reputation. Only the creator of the document will have his reputation updated.
81    *
82    * @param contributor the contributor that will have his reputation updated
83    * @param documentRef the document that was rated
84    * @param rating new rating of the element, including who did the rating
85    * @param oldVote previous vote of the user
86    * @return AverageRating of the contributor
87    * @throws ReputationException when an error occurs while calculating the new reputation
88    */
89    AverageRating calcNewContributorReputation(DocumentReference contributor, DocumentReference documentRef,
90    Rating rating, int oldVote) throws ReputationException;
91   
92    /**
93    * Recalculates all the reputations of the wiki. The result is given as a set of AverageRating objects that can be
94    * saved on the user page.
95    *
96    * @return map of AverageRating of each user of the wiki
97    * @throws ReputationException when an error occurs while recalculating all the user reputations
98    */
99    Map<String, AverageRating> recalcAllReputation() throws ReputationException;
100    }