1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.ratings.internal; |
21 |
|
|
22 |
|
import org.xwiki.ratings.AverageRating; |
23 |
|
import org.xwiki.ratings.RatingsException; |
24 |
|
import org.xwiki.ratings.RatingsManager; |
25 |
|
|
26 |
|
import com.xpn.xwiki.XWikiContext; |
27 |
|
import com.xpn.xwiki.XWikiException; |
28 |
|
import com.xpn.xwiki.doc.XWikiDocument; |
29 |
|
import com.xpn.xwiki.objects.BaseObject; |
30 |
|
|
31 |
|
|
32 |
|
@version |
33 |
|
@see |
34 |
|
@since |
35 |
|
|
|
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 9 |
Complexity Density: 0.75 |
|
36 |
|
public class StoredAverageRating implements AverageRating |
37 |
|
{ |
38 |
|
private XWikiDocument document; |
39 |
|
|
40 |
|
private BaseObject object; |
41 |
|
|
42 |
|
private XWikiContext context; |
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
@param |
48 |
|
@param |
49 |
|
@param |
50 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
51 |
0 |
public StoredAverageRating(XWikiDocument document, BaseObject ratingObject, XWikiContext context)... |
52 |
|
{ |
53 |
0 |
this.document = document; |
54 |
0 |
this.context = context; |
55 |
0 |
this.object = ratingObject; |
56 |
|
} |
57 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
58 |
0 |
@Override... |
59 |
|
public int getNbVotes() |
60 |
|
{ |
61 |
0 |
return object.getIntValue(RatingsManager.AVERAGERATING_CLASS_FIELDNAME_NBVOTES); |
62 |
|
} |
63 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
64 |
0 |
@Override... |
65 |
|
public void setNbVotes(int nbVotes) |
66 |
|
{ |
67 |
0 |
object.setIntValue(RatingsManager.AVERAGERATING_CLASS_FIELDNAME_NBVOTES, nbVotes); |
68 |
|
} |
69 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
70 |
0 |
@Override... |
71 |
|
public float getAverageVote() |
72 |
|
{ |
73 |
0 |
return object.getFloatValue(RatingsManager.AVERAGERATING_CLASS_FIELDNAME_AVERAGEVOTE); |
74 |
|
} |
75 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
76 |
0 |
@Override... |
77 |
|
public void setAverageVote(float averageVote) |
78 |
|
{ |
79 |
0 |
object.setFloatValue(RatingsManager.AVERAGERATING_CLASS_FIELDNAME_AVERAGEVOTE, averageVote); |
80 |
|
} |
81 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
82 |
0 |
@Override... |
83 |
|
public String getMethod() |
84 |
|
{ |
85 |
0 |
return object.getStringValue(RatingsManager.AVERAGERATING_CLASS_FIELDNAME_AVERAGEVOTE_METHOD); |
86 |
|
} |
87 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
88 |
0 |
@Override... |
89 |
|
public void setMethod(String method) |
90 |
|
{ |
91 |
0 |
object.setStringValue(RatingsManager.AVERAGERATING_CLASS_FIELDNAME_AVERAGEVOTE_METHOD, method); |
92 |
|
} |
93 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
94 |
0 |
@Override... |
95 |
|
public void save() throws RatingsException |
96 |
|
{ |
97 |
0 |
try { |
98 |
0 |
context.getWiki().saveDocument(document, "Update rating", true, context); |
99 |
|
} catch (XWikiException e) { |
100 |
0 |
throw new RatingsException(e); |
101 |
|
} |
102 |
|
} |
103 |
|
} |