RatingService GET node ratings statistics via REST.

Added node rating stats to the ratings.get webscript (for each scheme):
    average (mean) of all ratings for this node.
    total (sum) of all ratings for this node.
    count of all ratings for this node.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@21108 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Neil McErlean
2010-07-12 16:07:08 +00:00
parent abf1ea6968
commit 7ebf2e5e6a
2 changed files with 15 additions and 1 deletions

View File

@@ -328,8 +328,15 @@ public class RatingServiceImpl implements RatingService
}
}
}
if (ratingCount == 0)
{
return -1;
}
else
{
return (float)ratingTotal / (float)ratingCount;
}
}
public int getRatingsCount(NodeRef targetNode, String ratingSchemeName)
{

View File

@@ -95,6 +95,13 @@ public interface RatingService
int getTotalRating(NodeRef targetNode, String ratingSchemeName);
/**
* This method returns the average (mean) rating in the specified scheme for the
* specified nodeRef. If there have been no ratings applied, -1 is returned.
* @param targetNode the node for which an average is sought.
* @param ratingSchemeName the rating scheme name in which the average is defined.
* @return the average (mean) value if there is one, else -1.
*/
float getAverageRating(NodeRef targetNode, String ratingSchemeName);
/**