Added a removeRating method to the RatingService JS API.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@21163 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Neil McErlean
2010-07-14 13:38:20 +00:00
parent c2fa960543
commit dd816edd2b
2 changed files with 18 additions and 2 deletions

View File

@@ -104,6 +104,17 @@ public class ScriptRatingService extends BaseScopableProcessorExtension
ratingService.applyRating(node.getNodeRef(), rating, ratingSchemeName);
}
/**
* Removes any rating by the current user in the specified scheme from the specified
* noderef.
* @param node
* @param ratingSchemeName
*/
public void removeRating(ScriptNode node, String ratingSchemeName)
{
ratingService.removeRatingByCurrentUser(node.getNodeRef(), ratingSchemeName);
}
/**
* Gets the rating applied to the specified node in the specified scheme by
* the currently authenticated user.

View File

@@ -12,7 +12,7 @@ function testRatingSchemes()
test.assertEquals(5, ratingService.getMax('fiveStarRatingScheme'));
}
function testApplyAndGetRatings()
function testApplyUpdateDeleteRatings()
{
// Check the pristine state of the test node.
test.assertEquals(0, ratingService.getRatingsCount(testNode, 'fiveStarRatingScheme'));
@@ -39,8 +39,13 @@ function testApplyAndGetRatings()
test.assertEquals(1, ratingService.getRatingsCount(testNode, 'fiveStarRatingScheme'));
test.assertEquals(4.5, ratingService.getTotalRating(testNode, 'fiveStarRatingScheme'));
test.assertEquals(4.5, ratingService.getAverageRating(testNode, 'fiveStarRatingScheme'));
// Now delete them.
ratingService.removeRating(testNode, 'fiveStarRatingScheme');
test.assertEquals(-1, ratingService.getRating(testNode, 'fiveStarRatingScheme'));
}
// Execute tests
testRatingSchemes();
testApplyAndGetRatings();
testApplyUpdateDeleteRatings();