* @deprecated - use the CommentAndRatingService instead. Still here in case we want to migrate the ratings
*/
@Deprecated
public void storePageRating(final UserRequest ureq, final Locale locale, final String bundleName, final String page, final float rating) {
final String key = calculateCombinedKey(locale, bundleName, page);
final Preferences guiPrefs = ureq.getUserSession().getGuiPreferences();
// 1) Update community rating
CoordinatorManager.getCoordinator().getSyncer().doInSync(contextHelpRatingEventBus,new SyncerExecutor(){
public void execute() {
Object[] statsValues = contextHelpRatings.get(key);
if (statsValues == null) {
// create new data object for this page
statsValues = new Object[2];
statsValues[0] = new Double(rating);
statsValues[1] = new Integer(1);
} else {
Float lastRating = (Float) guiPrefs.get(ContextHelpModule.class, GUI_PREFS_PREFIX + key);
// update data object for this page
Double cummulatedRatings = (Double) statsValues[0];
double newValue = cummulatedRatings.doubleValue() + rating - (lastRating == null ? 0 : lastRating.doubleValue());
statsValues[0] = new Double(newValue > 0 ? newValue : 0);
Integer numberOfRatings = (Integer) statsValues[1];
int newRatingCount = numberOfRatings.intValue() + (lastRating == null ? 1 : 0);
statsValues[1] = new Integer(newRatingCount);
}
// notify everybody about this change (including ourselfs) to update local context help ratings
ContextHelpRatingEvent ratingEvent = new ContextHelpRatingEvent(key, statsValues);
CoordinatorManager.getCoordinator().getEventBus().fireEventToListenersOf(ratingEvent, contextHelpRatingEventBus);
// now save in filesystem
XStreamHelper.writeObject(contextHelpRatingFile, contextHelpRatings);
}
});
// 2) Update user rating
guiPrefs.putAndSave(ContextHelpModule.class, GUI_PREFS_PREFIX + key, new Float(rating));
}