org.alfresco.service.cmr.rating
Interface RatingService

All Known Implementing Classes:
RatingServiceImpl

public interface RatingService

Interface for public and internal rating operations.

The RatingService can be used to manage ratings on any content node in the repository. These ratings are defined by rating schemes which are injected via spring (see rating-service-context.xml). The rating schemes define a minimum and a maximum score value for that scheme.

Ratings can be applied, updated and removed.

Since:
3.4

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.
 java.io.Serializable getRatingRollup(org.alfresco.service.cmr.repository.NodeRef targetNode, java.lang.String ratingSchemeName, java.lang.String ratingRollupName)
          This method returns a 'rolled up' property value for the specified targetNode.
 java.util.List getRatingsByCurrentUser(org.alfresco.service.cmr.repository.NodeRef targetNode)
          This method gets the ratings applied by the current user to the specified node.
 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 ratingSchemeName)
          This method removes any Rating applied by the current user to the specified node in the specified RatingScheme.
 

Method Detail

getRatingSchemes

@NotAuditable
java.util.Map getRatingSchemes()
Returns the available rating schemes keyed by name.

Returns:
The rating schemes.

getRatingScheme

@NotAuditable
RatingScheme getRatingScheme(java.lang.String ratingSchemeName)
Returns the named rating scheme if there is one.

Parameters:
ratingSchemeName - name of the rating scheme.
Returns:
The rating schemes if one of that name is registered, else null.

applyRating

@NotAuditable
void applyRating(org.alfresco.service.cmr.repository.NodeRef targetNode,
                              float rating,
                              java.lang.String ratingSchemeName)
                 throws RatingServiceException
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.

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.
See Also:
RatingService.getRatingSchemes(), RatingScheme

getRatingsCount

@NotAuditable
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.

Parameters:
targetNode - the node on which the rating is sought.
ratingScheme - the rating scheme to use.
Returns:
the number of individual ratings applied to this node.
See Also:
RatingService.getRatingSchemes(), RatingScheme

getTotalRating

@NotAuditable
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. That is, the rating scores for all users for the specified node are summed to give the result.

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

getAverageRating

@NotAuditable
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. If there have been no ratings applied, -1 is returned.

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.

getRatingByCurrentUser

@NotAuditable
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.

Parameters:
targetNode - the node on which the rating is sought.
ratingScheme - the rating scheme to use.
Returns:
the Rating object if there is one, else null.
See Also:
RatingService.getRatingSchemes(), RatingScheme

getRatingsByCurrentUser

@NotAuditable
java.util.List getRatingsByCurrentUser(org.alfresco.service.cmr.repository.NodeRef targetNode)
This method gets the ratings applied by the current user to the specified node.

Parameters:
targetNode - the node on which the ratings are sought.
Returns:
a List of Rating objects if there are any, else Collections.emptyList().
Since:
3.5
See Also:
RatingService.getRatingSchemes(), RatingScheme

removeRatingByCurrentUser

@NotAuditable
Rating removeRatingByCurrentUser(org.alfresco.service.cmr.repository.NodeRef targetNode,
                                              java.lang.String ratingSchemeName)
This method removes any Rating applied by the current user to the specified node in the specified RatingScheme.

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

getRatingRollup

@NotAuditable
java.io.Serializable getRatingRollup(org.alfresco.service.cmr.repository.NodeRef targetNode,
                                                  java.lang.String ratingSchemeName,
                                                  java.lang.String ratingRollupName)
This method returns a 'rolled up' property value for the specified targetNode. Examples of rolled up property values are 'ratingTotal', 'ratingCount', but other values can be added.

Rolled up properties in the RatingService are stored as properties on the rated node and have their values calculated by running a fixed algorithm on properties stored across the cm:rating child nodes. An example of such a roll up would be 'ratingTotal' which would be the sum of all ratings applied to the targetNode in the specified rating scheme.

By rolling up property values from the various cm:rating child nodes and persisting them as individual properties on the cm:rateable node itself, we are able to support indexing, searching and sorting of such properties.

Parameters:
targetNode - the rated node whose rolled up property we wish to read.
ratingSchemeName - the rating scheme name in which the property is relevant.
ratingRollupName - the name of the rating rollup property, as given in AbstractRatingRollupAlgorithm.getRollupName().
Returns:
A value for the rolled up property, which will depend of course on the rollup requested.
Since:
3.5


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