use of org.xwiki.ratings.AverageRatingApi in project xwiki-platform by xwiki.
the class AbstractExtensionRESTResource method getExtensionRating.
protected ExtensionRating getExtensionRating(DocumentReference extensionDocumentReference) {
ExtensionRating extensionRating = this.extensionObjectFactory.createExtensionRating();
try {
AverageRatingApi averageRating = new AverageRatingApi(ratingsManager.getAverageRating(extensionDocumentReference));
extensionRating.setTotalVotes(averageRating.getNbVotes());
extensionRating.setAverageVote(averageRating.getAverageVote());
} catch (XWikiException e) {
extensionRating.setTotalVotes(0);
extensionRating.setAverageVote(0);
}
return extensionRating;
}
Aggregations