Class VirtualRatingServiceExtension

All Implemented Interfaces:
RatingServiceExtension, RatingService

public class VirtualRatingServiceExtension extends SpringBeanExtension<RatingServiceExtension,RatingServiceTrait> implements RatingServiceExtension
  • Constructor Details

    • VirtualRatingServiceExtension

      public VirtualRatingServiceExtension()
  • Method Details

    • setSmartStore

      public void setSmartStore(VirtualStore smartStore)
    • applyRating

      public void applyRating(NodeRef targetNode, float rating, String ratingSchemeName)
      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.
      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.
      See Also:
    • getRatingsCount

      public int getRatingsCount(NodeRef targetNode, 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.
      ratingSchemeName - the rating scheme name to use.
      Returns:
      the number of individual ratings applied to this node.
      See Also:
    • getTotalRating

      public float getTotalRating(NodeRef targetNode, 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.
      ratingSchemeName - the rating scheme name to use.
      Returns:
      the sum of all individual ratings applied to this node in the specified scheme.
      See Also:
    • getAverageRating

      public float getAverageRating(NodeRef targetNode, 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.
    • getRatingByCurrentUser

      public Rating getRatingByCurrentUser(NodeRef targetNode, 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.
      ratingSchemeName - the rating scheme name to use.
      Returns:
      the Rating object if there is one, else null.
      See Also:
    • getRatingsByCurrentUser

      public List<Rating> getRatingsByCurrentUser(NodeRef targetNode)
      Description copied from interface: RatingService
      This method gets the ratings applied by the current user to the specified node.
      Specified by:
      getRatingsByCurrentUser in interface RatingService
      Parameters:
      targetNode - the node on which the ratings are sought.
      Returns:
      a List of Rating objects if there are any, else Collections.emptyList().
      See Also:
    • removeRatingByCurrentUser

      public Rating removeRatingByCurrentUser(NodeRef targetNode, String ratingSchemeName)
      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.
      ratingSchemeName - the rating scheme name to use.
      Returns:
      the deleted Rating object if there was one, else null.
      See Also:
    • getRatingRollup

      public Serializable getRatingRollup(NodeRef targetNode, String ratingSchemeName, String ratingRollupName)
      Description copied from interface: RatingService
      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.

      Specified by:
      getRatingRollup in interface RatingService
      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.
    • getRatingSchemes

      public Map<String,RatingScheme> 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(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.