Package org.alfresco.repo.rating
Class RatingServiceImpl
- java.lang.Object
-
- org.alfresco.repo.rating.RatingServiceImpl
-
- All Implemented Interfaces:
RatingService,Extensible
public class RatingServiceImpl extends java.lang.Object implements RatingService, Extensible
-
-
Field Summary
Fields Modifier and Type Field Description ExtendedTrait<RatingServiceTrait>ratingServiceTrait
-
Constructor Summary
Constructors Constructor Description RatingServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidapplyRating(org.alfresco.service.cmr.repository.NodeRef targetNode, float rating, java.lang.String ratingSchemeName)This method applies the given rating to the specified target node.floatgetAverageRating(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.RatinggetRatingByCurrentUser(org.alfresco.service.cmr.repository.NodeRef targetNode, java.lang.String ratingSchemeName)This method gets theRatingapplied by the current user to the specified node in the specifiedRatingScheme- if there is one.java.io.SerializablegetRatingRollup(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<Rating>getRatingsByCurrentUser(org.alfresco.service.cmr.repository.NodeRef targetNode)This method gets theratingsapplied by the current user to the specified node.RatingSchemegetRatingScheme(java.lang.String ratingSchemeName)Returns the namedrating schemeif there is one.java.util.Map<java.lang.String,RatingScheme>getRatingSchemes()Returns the availablerating schemeskeyed by name.intgetRatingsCount(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 specifiedRatingScheme.floatgetTotalRating(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 specifiedRatingScheme.<M extends Trait>
ExtendedTrait<M>getTrait(java.lang.Class<? extends M> traitAPI)RatingremoveRatingByCurrentUser(org.alfresco.service.cmr.repository.NodeRef targetNode, java.lang.String ratingScheme)This method removes anyRatingapplied by the current user to the specified node in the specifiedRatingScheme.voidsetBehaviourFilter(BehaviourFilter behaviourFilter)voidsetDictionaryService(org.alfresco.service.cmr.dictionary.DictionaryService dictionaryService)voidsetNodeService(org.alfresco.service.cmr.repository.NodeService nodeService)voidsetRatingSchemeRegistry(RatingSchemeRegistry schemeRegistry)voidsetRollupNamingConventions(RatingNamingConventionsUtil namingConventions)
-
-
-
Field Detail
-
ratingServiceTrait
public final ExtendedTrait<RatingServiceTrait> ratingServiceTrait
-
-
Method Detail
-
setRatingSchemeRegistry
public void setRatingSchemeRegistry(RatingSchemeRegistry schemeRegistry)
-
setDictionaryService
public void setDictionaryService(org.alfresco.service.cmr.dictionary.DictionaryService dictionaryService)
-
setNodeService
public void setNodeService(org.alfresco.service.cmr.repository.NodeService nodeService)
-
setBehaviourFilter
public void setBehaviourFilter(BehaviourFilter behaviourFilter)
-
setRollupNamingConventions
public void setRollupNamingConventions(RatingNamingConventionsUtil namingConventions)
-
getRatingSchemes
public java.util.Map<java.lang.String,RatingScheme> getRatingSchemes()
Description copied from interface:RatingServiceReturns the availablerating schemeskeyed by name.- Specified by:
getRatingSchemesin interfaceRatingService- Returns:
- The
rating schemes.
-
getRatingScheme
public RatingScheme getRatingScheme(java.lang.String ratingSchemeName)
Description copied from interface:RatingServiceReturns the namedrating schemeif there is one.- Specified by:
getRatingSchemein interfaceRatingService- Parameters:
ratingSchemeName- name of the rating scheme.- Returns:
- The
rating schemesif one of that name is registered, elsenull.
-
applyRating
public void applyRating(org.alfresco.service.cmr.repository.NodeRef targetNode, float rating, java.lang.String ratingSchemeName) throws RatingServiceExceptionDescription copied from interface:RatingServiceThis 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:
applyRatingin interfaceRatingService- 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
-
getRatingByCurrentUser
public Rating getRatingByCurrentUser(org.alfresco.service.cmr.repository.NodeRef targetNode, java.lang.String ratingSchemeName)
Description copied from interface:RatingServiceThis method gets theRatingapplied by the current user to the specified node in the specifiedRatingScheme- if there is one.- Specified by:
getRatingByCurrentUserin interfaceRatingService- 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:
RatingService.getRatingSchemes(),RatingScheme
-
getRatingsByCurrentUser
public java.util.List<Rating> getRatingsByCurrentUser(org.alfresco.service.cmr.repository.NodeRef targetNode)
Description copied from interface:RatingServiceThis method gets theratingsapplied by the current user to the specified node.- Specified by:
getRatingsByCurrentUserin interfaceRatingService- 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:
RatingService.getRatingSchemes(),RatingScheme
-
removeRatingByCurrentUser
public Rating removeRatingByCurrentUser(org.alfresco.service.cmr.repository.NodeRef targetNode, java.lang.String ratingScheme)
Description copied from interface:RatingServiceThis method removes anyRatingapplied by the current user to the specified node in the specifiedRatingScheme.- Specified by:
removeRatingByCurrentUserin interfaceRatingService- Parameters:
targetNode- the node from which the rating is to be removed.ratingScheme- the rating scheme name to use.- 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:RatingServiceThis method gets the total accumulated rating score for the specified node in the specifiedRatingScheme. That is, the rating scores for all users for the specified node are summed to give the result.- Specified by:
getTotalRatingin interfaceRatingService- 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:
RatingService.getRatingSchemes(),RatingScheme
-
getAverageRating
public float getAverageRating(org.alfresco.service.cmr.repository.NodeRef targetNode, java.lang.String ratingSchemeName)Description copied from interface:RatingServiceThis 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:
getAverageRatingin interfaceRatingService- 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:RatingServiceThis method gets the number of individual ratings which have been applied to the specified node in the specifiedRatingScheme.- Specified by:
getRatingsCountin interfaceRatingService- 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:
RatingService.getRatingSchemes(),RatingScheme
-
getRatingRollup
public java.io.Serializable getRatingRollup(org.alfresco.service.cmr.repository.NodeRef targetNode, java.lang.String ratingSchemeName, java.lang.String ratingRollupName)Description copied from interface:RatingServiceThis 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 thecm:ratingchild 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 variouscm:ratingchild nodes and persisting them as individual properties on thecm:rateablenode itself, we are able to support indexing, searching and sorting of such properties.- Specified by:
getRatingRollupin interfaceRatingService- 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 inAbstractRatingRollupAlgorithm.getRollupName().- Returns:
- A value for the rolled up property, which will depend of course on the rollup requested.
-
getTrait
public <M extends Trait> ExtendedTrait<M> getTrait(java.lang.Class<? extends M> traitAPI)
- Specified by:
getTraitin interfaceExtensible
-
-