Package org.alfresco.repo.rating.script
Class ScriptRatingService
- java.lang.Object
-
- org.alfresco.repo.processor.BaseProcessorExtension
-
- org.alfresco.repo.jscript.BaseScopableProcessorExtension
-
- org.alfresco.repo.rating.script.ScriptRatingService
-
- All Implemented Interfaces:
org.alfresco.processor.ProcessorExtension,Scopeable
public class ScriptRatingService extends BaseScopableProcessorExtension
Script object representing the rating service.- Since:
- 3.4
- Author:
- Neil McErlean
-
-
Constructor Summary
Constructors Constructor Description ScriptRatingService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidapplyRating(ScriptNode node, float rating, java.lang.String ratingSchemeName)Applies the given rating to the specified node using the specified ratingScheme.floatgetAverageRating(ScriptNode node, java.lang.String ratingSchemeName)Gets the average (mean) rating by all users on the specified node in the specified scheme.floatgetMax(java.lang.String ratingSchemeName)Gets the maximum allowed rating for the specified rating scheme.floatgetMin(java.lang.String ratingSchemeName)Gets the minimum allowed rating for the specified rating scheme.floatgetRating(ScriptNode node, java.lang.String ratingSchemeName)Gets the rating applied to the specified node in the specified scheme by the currently authenticated user.java.util.DategetRatingAppliedAt(ScriptNode node, java.lang.String ratingSchemeName)Gets the rating applied date for the specified node in the specified scheme by the currently authenticated user.java.lang.String[]getRatingSchemeNames()Gets the names for rating schemes currently in the system.intgetRatingsCount(ScriptNode node, java.lang.String ratingSchemeName)Gets the number of ratings applied to the specified node by all users in the specified scheme.floatgetTotalRating(ScriptNode node, java.lang.String ratingSchemeName)Gets the total (sum) rating by all users on the specified node in the specified scheme.booleanisSelfRatingAllowed(java.lang.String ratingSchemeName)This method checks whether self-rating is allowed for the specified rating scheme.voidremoveRating(ScriptNode node, java.lang.String ratingSchemeName)Removes any rating by the current user in the specified scheme from the specified noderef.voidsetServiceRegistry(ServiceRegistry serviceRegistry)Set the service registry-
Methods inherited from class org.alfresco.repo.jscript.BaseScopableProcessorExtension
getScope, setScope
-
Methods inherited from class org.alfresco.repo.processor.BaseProcessorExtension
getExtensionName, register, setExtensionName, setProcessor
-
-
-
-
Method Detail
-
setServiceRegistry
public void setServiceRegistry(ServiceRegistry serviceRegistry)
Set the service registry- Parameters:
serviceRegistry- the service registry.
-
getRatingSchemeNames
public java.lang.String[] getRatingSchemeNames()
Gets the names for rating schemes currently in the system.- Returns:
- String[]
-
getMin
public float getMin(java.lang.String ratingSchemeName)
Gets the minimum allowed rating for the specified rating scheme.- Parameters:
ratingSchemeName- String- Returns:
- float
-
getMax
public float getMax(java.lang.String ratingSchemeName)
Gets the maximum allowed rating for the specified rating scheme.- Parameters:
ratingSchemeName- String- Returns:
- float
-
isSelfRatingAllowed
public boolean isSelfRatingAllowed(java.lang.String ratingSchemeName)
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.- Parameters:
ratingSchemeName- the rating scheme bean name.- Returns:
trueif users can rate their own content, elsefalse.
-
applyRating
public void applyRating(ScriptNode node, float rating, java.lang.String ratingSchemeName)
Applies the given rating to the specified node using the specified ratingScheme. It is the responsibility of the caller to ensure that the rating scheme exists and that the rating is within the limits defined for that scheme. Furthermore, only one rating scheme per user per target node is supported. Any attempt by one user to apply a second rating in a different scheme will result in aRatingServiceException.- Parameters:
node- ScriptNoderating- floatratingSchemeName- String- Throws:
RatingServiceException- See Also:
getMin(String),getMax(String)
-
removeRating
public void removeRating(ScriptNode node, java.lang.String ratingSchemeName)
Removes any rating by the current user in the specified scheme from the specified noderef.- Parameters:
node- ScriptNoderatingSchemeName- String
-
getRating
public float getRating(ScriptNode node, java.lang.String ratingSchemeName)
Gets the rating applied to the specified node in the specified scheme by the currently authenticated user.- Parameters:
node- ScriptNoderatingSchemeName- String- Returns:
- rating if there is one, else -1. TODO -1 could be a valid rating.
-
getRatingAppliedAt
public java.util.Date getRatingAppliedAt(ScriptNode node, java.lang.String ratingSchemeName)
Gets the rating applied date for the specified node in the specified scheme by the currently authenticated user.- Parameters:
node- ScriptNoderatingSchemeName- String- Returns:
- rating applied date if there is one, else
null
-
getRatingsCount
public int getRatingsCount(ScriptNode node, java.lang.String ratingSchemeName)
Gets the number of ratings applied to the specified node by all users in the specified scheme.- Parameters:
node- ScriptNoderatingSchemeName- String- Returns:
- int
-
getTotalRating
public float getTotalRating(ScriptNode node, java.lang.String ratingSchemeName)
Gets the total (sum) rating by all users on the specified node in the specified scheme.- Parameters:
node- ScriptNoderatingSchemeName- String- Returns:
- float
-
getAverageRating
public float getAverageRating(ScriptNode node, java.lang.String ratingSchemeName)
Gets the average (mean) rating by all users on the specified node in the specified scheme.- Parameters:
node- ScriptNoderatingSchemeName- * @param ratingSchemeName String- Returns:
- float
-
-