org.alfresco.repo.rating.script
Class ScriptRatingService

java.lang.Object
  extended by org.alfresco.repo.processor.BaseProcessorExtension
      extended by org.alfresco.repo.jscript.BaseScopableProcessorExtension
          extended by 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

Constructor Summary
ScriptRatingService()
           
 
Method Summary
 void applyRating(ScriptNode node, float rating, java.lang.String ratingSchemeName)
          Applies the given rating to the specified node using the specified ratingScheme.
 float getAverageRating(ScriptNode node, java.lang.String ratingSchemeName)
          Gets the average (mean) rating by all users on the specified node in the specified scheme.
 float getMax(java.lang.String ratingSchemeName)
          Gets the maximum allowed rating for the specified rating scheme.
 float getMin(java.lang.String ratingSchemeName)
          Gets the minimum allowed rating for the specified rating scheme.
 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.
 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.
 java.lang.String[] getRatingSchemeNames()
          Gets the names for rating schemes currently in the system.
 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.
 float getTotalRating(ScriptNode node, java.lang.String ratingSchemeName)
          Gets the total (sum) rating by all users on the specified node in the specified scheme.
 boolean isSelfRatingAllowed(java.lang.String ratingSchemeName)
          This method checks whether self-rating is allowed for the specified rating scheme.
 void removeRating(ScriptNode node, java.lang.String ratingSchemeName)
          Removes any rating by the current user in the specified scheme from the specified noderef.
 void setServiceRegistry(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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScriptRatingService

public ScriptRatingService()
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:

getMin

public float getMin(java.lang.String ratingSchemeName)
Gets the minimum allowed rating for the specified rating scheme.

Parameters:
ratingSchemeName -
Returns:

getMax

public float getMax(java.lang.String ratingSchemeName)
Gets the maximum allowed rating for the specified rating scheme.

Parameters:
ratingSchemeName -
Returns:

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:
true if users can rate their own content, else false.

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 a RatingServiceException.

Parameters:
node -
rating -
ratingSchemeName -
Throws:
RatingServiceException
See Also:
ScriptRatingService.getMin(String), ScriptRatingService.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 -
ratingSchemeName -

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 -
ratingSchemeName -
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 -
ratingSchemeName -
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 -
ratingSchemeName -
Returns:

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 -
ratingSchemeName -
Returns:

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 -
ratingSchemeName -
Returns:


Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.