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
Script object representing the rating service.
- Since:
- 3.4
- Author:
- Neil McErlean
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidapplyRating(ScriptNode node, float rating, String ratingSchemeName) Applies the given rating to the specified node using the specified ratingScheme.floatgetAverageRating(ScriptNode node, String ratingSchemeName) Gets the average (mean) rating by all users on the specified node in the specified scheme.floatGets the maximum allowed rating for the specified rating scheme.floatGets the minimum allowed rating for the specified rating scheme.floatgetRating(ScriptNode node, String ratingSchemeName) Gets the rating applied to the specified node in the specified scheme by the currently authenticated user.getRatingAppliedAt(ScriptNode node, String ratingSchemeName) Gets the rating applied date for the specified node in the specified scheme by the currently authenticated user.String[]Gets the names for rating schemes currently in the system.intgetRatingsCount(ScriptNode node, String ratingSchemeName) Gets the number of ratings applied to the specified node by all users in the specified scheme.floatgetTotalRating(ScriptNode node, String ratingSchemeName) Gets the total (sum) rating by all users on the specified node in the specified scheme.booleanisSelfRatingAllowed(String ratingSchemeName) This method checks whether self-rating is allowed for the specified rating scheme.voidremoveRating(ScriptNode node, String ratingSchemeName) Removes any rating by the current user in the specified scheme from the specified noderef.voidsetServiceRegistry(ServiceRegistry serviceRegistry) Set the service registryMethods inherited from class org.alfresco.repo.jscript.BaseScopableProcessorExtension
getScope, setScopeMethods inherited from class org.alfresco.repo.processor.BaseProcessorExtension
getExtensionName, register, setExtensionName, setProcessor
-
Constructor Details
-
ScriptRatingService
public ScriptRatingService()
-
-
Method Details
-
setServiceRegistry
Set the service registry- Parameters:
serviceRegistry- the service registry.
-
getRatingSchemeNames
Gets the names for rating schemes currently in the system.- Returns:
- String[]
-
getMin
Gets the minimum allowed rating for the specified rating scheme.- Parameters:
ratingSchemeName- String- Returns:
- float
-
getMax
Gets the maximum allowed rating for the specified rating scheme.- Parameters:
ratingSchemeName- String- Returns:
- float
-
isSelfRatingAllowed
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
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:
-
removeRating
Removes any rating by the current user in the specified scheme from the specified noderef.- Parameters:
node- ScriptNoderatingSchemeName- String
-
getRating
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
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
Gets the number of ratings applied to the specified node by all users in the specified scheme.- Parameters:
node- ScriptNoderatingSchemeName- String- Returns:
- int
-
getTotalRating
Gets the total (sum) rating by all users on the specified node in the specified scheme.- Parameters:
node- ScriptNoderatingSchemeName- String- Returns:
- float
-
getAverageRating
Gets the average (mean) rating by all users on the specified node in the specified scheme.- Parameters:
node- ScriptNoderatingSchemeName- * @param ratingSchemeName String- Returns:
- float
-