org.alfresco.repo.rating
Class RatingServiceImpl

java.lang.Object
  extended by org.alfresco.repo.rating.RatingServiceImpl
All Implemented Interfaces:
RatingService

public class RatingServiceImpl
extends java.lang.Object
implements RatingService


Constructor Summary
RatingServiceImpl()
           
 
Method Summary
 void applyRating(org.alfresco.service.cmr.repository.NodeRef targetNode, float rating, java.lang.String ratingSchemeName)
          This method applies the given rating to the specified target node.
 float getAverageRating(org.alfresco.service.cmr.repository.NodeRef targetNode, java.lang.String ratingSchemeName)
          This method returns the average (mean) rating in the specified scheme for the specified nodeRef.
 Rating getRatingByCurrentUser(org.alfresco.service.cmr.repository.NodeRef targetNode, java.lang.String ratingSchemeName)
          This method gets the Rating applied by the current user to the specified node in the specified RatingScheme - if there is one.
 RatingScheme getRatingScheme(java.lang.String ratingSchemeName)
          Returns the named rating scheme if there is one.
 java.util.Map getRatingSchemes()
          Returns the available rating schemes keyed by name.
 int getRatingsCount(org.alfresco.service.cmr.repository.NodeRef targetNode, java.lang.String ratingSchemeName)
          This method gets the number of individual ratings which have been applied to the specified node in the specified RatingScheme.
 float getTotalRating(org.alfresco.service.cmr.repository.NodeRef targetNode, java.lang.String ratingSchemeName)
          This method gets the total accumulated rating score for the specified node in the specified RatingScheme.
 Rating removeRatingByCurrentUser(org.alfresco.service.cmr.repository.NodeRef targetNode, java.lang.String ratingScheme)
          This method removes any Rating applied by the current user to the specified node in the specified RatingScheme.
 void setBehaviourFilter(BehaviourFilter behaviourFilter)
           
 void setNodeService(org.alfresco.service.cmr.repository.NodeService nodeService)
           
 void setRatingSchemeRegistry(RatingSchemeRegistry schemeRegistry)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RatingServiceImpl

public RatingServiceImpl()
Method Detail

setRatingSchemeRegistry

public void setRatingSchemeRegistry(RatingSchemeRegistry schemeRegistry)

setNodeService

public void setNodeService(org.alfresco.service.cmr.repository.NodeService nodeService)

setBehaviourFilter

public void setBehaviourFilter(BehaviourFilter behaviourFilter)

getRatingSchemes

public java.util.Map getRatingSchemes()
Description copied from interface: RatingService
Returns the available rating schemes keyed by name.

Specified by:
getRatingSchemes in interface RatingService
Returns:
The rating schemes.

getRatingScheme

public RatingScheme getRatingScheme(java.lang.String ratingSchemeName)
Description copied from interface: RatingService
Returns the named rating scheme if there is one.

Specified by:
getRatingScheme in interface RatingService
Parameters:
ratingSchemeName - name of the rating scheme.
Returns:
The rating schemes if one of that name is registered, else null.

applyRating

public void applyRating(org.alfresco.service.cmr.repository.NodeRef targetNode,
                        float rating,
                        java.lang.String ratingSchemeName)
                 throws RatingServiceException
Description copied from interface: RatingService
This method applies the given rating to the specified target node. If a rating from the current user in the specified scheme already exists, it will be replaced.

Note that only one rating scheme per user per targetNode is supported at present. If a user attempts to apply a second rating in a different rating scheme to any given target node, a RatingServiceException will be thrown.

Specified by:
applyRating in interface RatingService
Parameters:
targetNode - the node to which the rating is to be applied.
rating - the rating which is to be applied.
ratingSchemeName - the name of the rating scheme to use.
Throws:
RatingServiceException - if the rating is not within the range defined by the named scheme or if the named scheme is not registered or if the rating would result in multiple ratings by the same user.
See Also:
RatingService.getRatingSchemes(), RatingScheme

getRatingByCurrentUser

public Rating getRatingByCurrentUser(org.alfresco.service.cmr.repository.NodeRef targetNode,
                                     java.lang.String ratingSchemeName)
Description copied from interface: RatingService
This method gets the Rating applied by the current user to the specified node in the specified RatingScheme - if there is one.

Specified by:
getRatingByCurrentUser in interface RatingService
Parameters:
targetNode - the node on which the rating is sought.
Returns:
the Rating object if there is one, else null.
See Also:
RatingService.getRatingSchemes(), RatingScheme

removeRatingByCurrentUser

public Rating removeRatingByCurrentUser(org.alfresco.service.cmr.repository.NodeRef targetNode,
                                        java.lang.String ratingScheme)
Description copied from interface: RatingService
This method removes any Rating applied by the current user to the specified node in the specified RatingScheme.

Specified by:
removeRatingByCurrentUser in interface RatingService
Parameters:
targetNode - the node from which the rating is to be removed.
Returns:
the deleted Rating object if there was one, else null.
See Also:
RatingService.getRatingSchemes(), RatingScheme

getTotalRating

public float getTotalRating(org.alfresco.service.cmr.repository.NodeRef targetNode,
                            java.lang.String ratingSchemeName)
Description copied from interface: RatingService
This method gets the total accumulated rating score for the specified node in the specified RatingScheme. That is, the rating scores for all users for the specified node are summed to give the result.

Specified by:
getTotalRating in interface RatingService
Parameters:
targetNode - the node on which the rating total is sought.
Returns:
the sum of all individual ratings applied to this node in the specified scheme.
See Also:
RatingService.getRatingSchemes(), RatingScheme

getAverageRating

public float getAverageRating(org.alfresco.service.cmr.repository.NodeRef targetNode,
                              java.lang.String ratingSchemeName)
Description copied from interface: RatingService
This method returns the average (mean) rating in the specified scheme for the specified nodeRef. If there have been no ratings applied, -1 is returned.

Specified by:
getAverageRating in interface RatingService
Parameters:
targetNode - the node for which an average is sought.
ratingSchemeName - the rating scheme name in which the average is defined.
Returns:
the average (mean) value if there is one, else -1.

getRatingsCount

public int getRatingsCount(org.alfresco.service.cmr.repository.NodeRef targetNode,
                           java.lang.String ratingSchemeName)
Description copied from interface: RatingService
This method gets the number of individual ratings which have been applied to the specified node in the specified RatingScheme.

Specified by:
getRatingsCount in interface RatingService
Parameters:
targetNode - the node on which the rating is sought.
Returns:
the number of individual ratings applied to this node.
See Also:
RatingService.getRatingSchemes(), RatingScheme


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