/** * Gets the minimum allowed rating for the specified rating scheme. * * @param ratingSchemeName String * @return float */ public float getMin(String ratingSchemeName) { return ratingService.getRatingScheme(ratingSchemeName).getMinRating(); }
/** * This method checks whether self-rating is allowed for the specified rating scheme. * If self-rating is allowed in the specified scheme, then the cm:creator of a node can apply a rating, * otherwise they cannot. * * @param ratingSchemeName the rating scheme bean name. * @return <code>true</code> if users can rate their own content, else <code>false</code>. */ public boolean isSelfRatingAllowed(String ratingSchemeName) { return ratingService.getRatingScheme(ratingSchemeName).isSelfRatingAllowed(); }
/** * Gets the maximum allowed rating for the specified rating scheme. * * @param ratingSchemeName String * @return float */ public float getMax(String ratingSchemeName) { return ratingService.getRatingScheme(ratingSchemeName).getMaxRating(); }
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; } });
/** * Gets the rating applied to the specified node in the specified scheme by * the currently authenticated user. * @param node ScriptNode * @param ratingSchemeName String * @return rating if there is one, else -1. * TODO -1 could be a valid rating. */ public float getRating(ScriptNode node, String ratingSchemeName) { final Rating ratingByCurrentUser = ratingService.getRatingByCurrentUser(node.getNodeRef(), ratingSchemeName); return ratingByCurrentUser == null ? -1f : ratingByCurrentUser.getScore(); }
/** * Gets the rating applied date for the specified node in the specified scheme by * the currently authenticated user. * @param node ScriptNode * @param ratingSchemeName String * @return rating applied date if there is one, else <code>null</code> */ public Date getRatingAppliedAt(ScriptNode node, String ratingSchemeName) { final Rating ratingByCurrentUser = ratingService.getRatingByCurrentUser(node.getNodeRef(), ratingSchemeName); return ratingByCurrentUser == null ? null : ratingByCurrentUser.getAppliedAt(); }
@Override public NodeRef execute() throws Throwable { RATING_SERVICE.applyRating(testDoc_UserOne, 11.0F, spinalTapScheme); return null; } });
/** * This method can be used to sort RatingSchemes by name. * @since 4.1.5 */ @Override public int compareTo(RatingScheme otherScheme) { return this.name.compareTo(otherScheme.getName()); } }
/** * Gets the total (sum) rating by all users on the specified node in the specified scheme. * @param node ScriptNode * @param ratingSchemeName String * @return float */ public float getTotalRating(ScriptNode node, String ratingSchemeName) { return ratingService.getTotalRating(node.getNodeRef(), ratingSchemeName); }
/** * Removes any rating by the current user in the specified scheme from the specified * noderef. * @param node ScriptNode * @param ratingSchemeName String */ public void removeRating(ScriptNode node, String ratingSchemeName) { ratingService.removeRatingByCurrentUser(node.getNodeRef(), ratingSchemeName); }
/** * Gets the number of ratings applied to the specified node by all users in the specified * scheme. * @param node ScriptNode * @param ratingSchemeName String * @return int */ public int getRatingsCount(ScriptNode node, String ratingSchemeName) { return ratingService.getRatingsCount(node.getNodeRef(), ratingSchemeName); }
/** * Gets the average (mean) rating by all users on the specified node in the specified scheme. * @param node ScriptNode * @param ratingSchemeName * @param ratingSchemeName String * @return float */ public float getAverageRating(ScriptNode node, String ratingSchemeName) { return ratingService.getAverageRating(node.getNodeRef(), ratingSchemeName); } }
/** * Gets the minimum allowed rating for the specified rating scheme. * * @param ratingSchemeName String * @return float */ public float getMin(String ratingSchemeName) { return ratingService.getRatingScheme(ratingSchemeName).getMinRating(); }
/** * Gets the maximum allowed rating for the specified rating scheme. * * @param ratingSchemeName String * @return float */ public float getMax(String ratingSchemeName) { return ratingService.getRatingScheme(ratingSchemeName).getMaxRating(); }
/** * Gets the rating applied to the specified node in the specified scheme by * the currently authenticated user. * @param node ScriptNode * @param ratingSchemeName String * @return rating if there is one, else -1. * TODO -1 could be a valid rating. */ public float getRating(ScriptNode node, String ratingSchemeName) { final Rating ratingByCurrentUser = ratingService.getRatingByCurrentUser(node.getNodeRef(), ratingSchemeName); return ratingByCurrentUser == null ? -1f : ratingByCurrentUser.getScore(); }
/** * Gets the rating applied date for the specified node in the specified scheme by * the currently authenticated user. * @param node ScriptNode * @param ratingSchemeName String * @return rating applied date if there is one, else <code>null</code> */ public Date getRatingAppliedAt(ScriptNode node, String ratingSchemeName) { final Rating ratingByCurrentUser = ratingService.getRatingByCurrentUser(node.getNodeRef(), ratingSchemeName); return ratingByCurrentUser == null ? null : ratingByCurrentUser.getAppliedAt(); }
/** * This method checks whether self-rating is allowed for the specified rating scheme. * If self-rating is allowed in the specified scheme, then the cm:creator of a node can apply a rating, * otherwise they cannot. * * @param ratingSchemeName the rating scheme bean name. * @return <code>true</code> if users can rate their own content, else <code>false</code>. */ public boolean isSelfRatingAllowed(String ratingSchemeName) { return ratingService.getRatingScheme(ratingSchemeName).isSelfRatingAllowed(); }
@Override public Void execute() throws Throwable { RATING_SERVICE.applyRating(nodeRef, illegalRating, schemeName); return null; } });
/** * This method can be used to sort RatingSchemes by name. * @since 4.1.5 */ @Override public int compareTo(RatingScheme otherScheme) { return this.name.compareTo(otherScheme.getName()); } }
@Override public Void doWork() throws Exception { ratingService.applyRating(targetNode, rating, ratingSchemeName); return null; }