Obsolete Pages{{Obsolete}}
The official documentation is at: http://docs.alfresco.com
This page is a work in progress.
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.
likesRatingScheme
fiveStarRatingScheme
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:
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:
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.
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.
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.
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.
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.