cancel
Showing results for 
Search instead for 
Did you mean: 
resplin
Elite Collaborator
Elite Collaborator

Obsolete Pages{{Obsolete}}

The official documentation is at: http://docs.alfresco.com



This page is a work in progress.


Introduction


Alfresco 3.4 adds a partial implementation of a Rating Service. At the time of writing (just prior to the launch of Alfresco 3.4 Community Edition) there is support in the Java Services layer for content ratings, but there is no User Interface for this service.

The Rating Service is intended to support application developers and third parties who wish to define Rating Schemes for their content. A rating scheme is a defined system of ratings for content which is identified by a unique name and which provides a minimum and maximum allowed rating.

This page describes the design of the service, describes the out-of-the-box Rating Schemes that are available in 3.4 and how users can extend Alfresco with new rating schemes.

Obviously the full value of the service will be realised with the addition of a UI.


Out of the box rating schemes


likesRatingScheme


This scheme is essentially a marker on a piece of content. User X likes content item Y. It has minRating == maxRating == 1.

fiveStarRatingScheme


The scheme allows users to rate content on a scale from 1 to 5.

Design


Content Model


The rating content model has been added to contentModel.xml.

We define a cm:rateable aspect which is applied to a node which has been rated. That aspect defines a child-association to a new cm:rating type which is where the data is held. The name of this association will be the user name of the rater, prefixed by cm: e.g. cm:neil.

The cm:rating type defines three properties:


  • cm:ratingScore a float value for the rating applied.
  • cm:ratingScheme a text value for the rating scheme in which this rating was applied.
  • cm:ratedAt a datetime value which records when this rating was applied.

Spring configuration


The spring beans for the rating service are defined in rating-services-context.xml. That spring context file defines the standard beans for an Alfresco foundation service:


  • ratingService is the bean for the service itself.
  • RatingService is the ProxyFactoryBean which proxies the ratingService bean and injects interceptors:
  • RatingService_transaction is the interceptor which injects transaction handling
  • RatingService_security is the interceptor which injects security handling.

Aside from these standard beans, we have a ratingSchemeRegistry bean which stores the rating schemes registered in the system.
The built-in rating schemes are defined as spring beans e.g. (likesRatingScheme) which extend the baseRatingScheme bean. That parent bean provides automatic registration of schemes on startup.

Note that it is the name of the spring bean for the rating scheme which is used as the name throughout the code.


Java Foundation API


The rating service is exposed as a public service interface: org.alfresco.service.cmr.rating.RatingService. By using this class, client code can get the registered rating schemes and their metadata (min, max, name). There are also methods for applying ratings to nodes, retrieving ratings and removing them. For any specified scheme you can also get the total rating, the number of individual ratings and the average (mean) rating for a node.


JavaScript API


There is a JavaScript API class which provides equivalent methods to the Java layer service class. See org.alfresco.repo.rating.script.ScriptRatingService for details.


REST API


  • ratingdefinitions.get.desc.xml
  • ratings.get.desc.xml
  • rating.post.desc.xml
  • rating.delete.desc.xml

Adding new rating schemes


New rating schemes can be added via spring injection. You simply need to define a bean which has baseRatingScheme as its parent bean, add properties for minRating and maxRating and the scheme will be automatically registered with the system on startup.


Limitations


A single piece of content can be rated by many users in many different rating schemes, but a single user cannot rate a single piece of content in multiple schemes. If a user has rated a piece of content in scheme A, that rating must be deleted before a new rating in scheme B can be applied.


Roadmap


  • Share UI
  • Support for rolling up rating statistics into higher level container objects. e.g. how many pieces of content under folder X are 'liked'.
  • Integration with the ActivityService so that feeds can incorporate updates on how users are rating content (Share).

3.4
Social Computing
Core Repository Services