public Integer recalculate(NodeRef ratedNode) { int result = 0; // If the node is not rateable, then it has no ratings in any scheme. if (nodeService.hasAspect(ratedNode, ContentModel.ASPECT_RATEABLE)) { List<ChildAssociationRef> ratingsNodes = ratingServiceImpl.getRatingNodeChildren(ratedNode, ratingSchemeName, null); // Filter by scheme for (ChildAssociationRef chAssRef : ratingsNodes) { NodeRef nextRatingNode = chAssRef.getChildRef(); Rating rating = ratingServiceImpl.getRatingFrom(nextRatingNode); if (ratingSchemeName.equals(rating.getScheme().getName())) { result++; } } } return result; } }
public Integer recalculate(NodeRef ratedNode) { int result = 0; // If the node is not rateable, then it has no ratings in any scheme. if (nodeService.hasAspect(ratedNode, ContentModel.ASPECT_RATEABLE)) { List<ChildAssociationRef> ratingsNodes = ratingServiceImpl.getRatingNodeChildren(ratedNode, ratingSchemeName, null); // Filter by scheme for (ChildAssociationRef chAssRef : ratingsNodes) { NodeRef nextRatingNode = chAssRef.getChildRef(); Rating rating = ratingServiceImpl.getRatingFrom(nextRatingNode); if (ratingSchemeName.equals(rating.getScheme().getName())) { result++; } } } return result; } }
public Float recalculate(NodeRef ratedNode) { float result = 0; // If the node is not rateable, then it has no ratings in any scheme. if (nodeService.hasAspect(ratedNode, ContentModel.ASPECT_RATEABLE)) { List<ChildAssociationRef> ratingsNodes = ratingServiceImpl.getRatingNodeChildren(ratedNode, ratingSchemeName, null); // Filter by scheme for (ChildAssociationRef chAssRef : ratingsNodes) { NodeRef nextRatingNode = chAssRef.getChildRef(); Rating rating = ratingServiceImpl.getRatingFrom(nextRatingNode); if (ratingSchemeName.equals(rating.getScheme().getName())) { result += rating.getScore(); } } } return result; } }
public Float recalculate(NodeRef ratedNode) { float result = 0; // If the node is not rateable, then it has no ratings in any scheme. if (nodeService.hasAspect(ratedNode, ContentModel.ASPECT_RATEABLE)) { List<ChildAssociationRef> ratingsNodes = ratingServiceImpl.getRatingNodeChildren(ratedNode, ratingSchemeName, null); // Filter by scheme for (ChildAssociationRef chAssRef : ratingsNodes) { NodeRef nextRatingNode = chAssRef.getChildRef(); Rating rating = ratingServiceImpl.getRatingFrom(nextRatingNode); if (ratingSchemeName.equals(rating.getScheme().getName())) { result += rating.getScore(); } } } return result; } }
public Void execute() throws Throwable { RATING_SERVICE.applyRating(testDoc_UserTwo, 2.0f, FIVE_STAR_SCHEME_NAME); // A new score in a different rating scheme by the same user should not fail. RATING_SERVICE.applyRating(testDoc_UserTwo, 1.0f, LIKES_SCHEME_NAME); // There should be two rating child nodes under the rated node. assertEquals("Wrong number of child nodes", 2 , NODE_SERVICE.getChildAssocs(testDoc_UserTwo).size()); List<Rating> ratings = RATING_SERVICE.getRatingsByCurrentUser(testDoc_UserTwo); assertEquals(2, ratings.size()); assertEquals(FIVE_STAR_SCHEME_NAME, ratings.get(0).getScheme().getName()); assertEquals(LIKES_SCHEME_NAME, ratings.get(1).getScheme().getName()); return null; } });