@Unstable public abstract class AbstractScriptRatingsManager extends Object implements RatingsScriptServiceAPI
RatingsScriptService
.
It relies internally on a dedicated instance of RatingsManager
: the method
setRatingsManager(RatingsManager)
needs to be called when any concrete class is instantiated.Constructor and Description |
---|
AbstractScriptRatingsManager() |
Modifier and Type | Method and Description |
---|---|
Optional<AverageRating> |
getAverageRating(org.xwiki.model.reference.EntityReference reference)
Retrieve the average rating of a specific reference.
|
RatingsConfiguration |
getConfiguration() |
List<Rating> |
getCurrentUserRatings(int offset,
int limit,
boolean asc)
Retrieve all the ratings of the current user.
|
Optional<Rating> |
getRating(org.xwiki.model.reference.EntityReference reference,
org.xwiki.user.UserReference author)
Retrieve the rating performed by the given author on the given reference.
|
List<Rating> |
getRatings(org.xwiki.model.reference.EntityReference reference,
int offset,
int limit)
Retrieve ratings information for the given reference on the given manager.
|
List<Rating> |
getRatings(org.xwiki.model.reference.EntityReference reference,
int offset,
int limit,
boolean asc)
Retrieve ratings information for the given reference on the given manager.
|
boolean |
isExcludedFromRatings(org.xwiki.model.reference.EntityReference entityReference)
Define if the given reference is excluded from ratings.
|
Optional<Rating> |
setRating(org.xwiki.model.reference.EntityReference reference,
int vote)
Allows to save a rating for the given reference, with the current user reference.
|
Optional<Rating> |
setRating(org.xwiki.model.reference.EntityReference reference,
org.xwiki.user.UserReference userReference,
int vote)
Allows to save a rating for the given reference, with the given user reference.
|
public Optional<Rating> setRating(org.xwiki.model.reference.EntityReference reference, int vote)
RatingsScriptServiceAPI
setRating
in interface RatingsScriptServiceAPI
reference
- the reference for which to save a rating.vote
- the rating to save.Rating
value, or empty in case of problem or if the rating is 0 and
the configuration doesn't allow to save 0 values (see RatingsConfiguration.isZeroStored()
).public Optional<Rating> setRating(org.xwiki.model.reference.EntityReference reference, org.xwiki.user.UserReference userReference, int vote)
RatingsScriptServiceAPI
setRating
in interface RatingsScriptServiceAPI
reference
- the reference for which to save a rating.userReference
- the reference of the user who performs the rating.vote
- the rating to save.Rating
value, or empty in case of problem or if the rating is 0 and
the configuration doesn't allow to save 0 values (see RatingsConfiguration.isZeroStored()
).public List<Rating> getRatings(org.xwiki.model.reference.EntityReference reference, int offset, int limit)
RatingsScriptServiceAPI
getRatings
in interface RatingsScriptServiceAPI
reference
- the reference for which to retrieve rating information.offset
- the offset at which to start for retrieving information.limit
- the limit number of information to retrieve.limit
values sorted by
updated date in descending order.public List<Rating> getRatings(org.xwiki.model.reference.EntityReference reference, int offset, int limit, boolean asc)
RatingsScriptServiceAPI
getRatings
in interface RatingsScriptServiceAPI
reference
- the reference for which to retrieve rating information.offset
- the offset at which to start for retrieving information.limit
- the limit number of information to retrieve.asc
- if true
return the results sorted by updated date in ascending order, else in descending orderlimit
values.public Optional<AverageRating> getAverageRating(org.xwiki.model.reference.EntityReference reference)
RatingsScriptServiceAPI
getAverageRating
in interface RatingsScriptServiceAPI
reference
- the reference for which to retrieve the average rating information.public Optional<Rating> getRating(org.xwiki.model.reference.EntityReference reference, org.xwiki.user.UserReference author)
RatingsScriptServiceAPI
getRating
in interface RatingsScriptServiceAPI
reference
- the entity being ratedauthor
- the author of the ratepublic List<Rating> getCurrentUserRatings(int offset, int limit, boolean asc)
RatingsScriptServiceAPI
getCurrentUserRatings
in interface RatingsScriptServiceAPI
offset
- offset of ratings to start retrieve.limit
- maximum number of ratings to retrieve.asc
- if the results should be ordered in updated date ascending or descending order.public RatingsConfiguration getConfiguration()
getConfiguration
in interface RatingsScriptServiceAPI
public boolean isExcludedFromRatings(org.xwiki.model.reference.EntityReference entityReference)
RatingsScriptServiceAPI
isExcludedFromRatings
in interface RatingsScriptServiceAPI
entityReference
- the reference to check.true
only if the given reference is excluded from ratings.Copyright © 2004–2021 XWiki. All rights reserved.