public class JDBCRatingsDAO extends Object implements RatingsDAO
RatingsDAO
to store ratings on a JDBC-based database.Modifier and Type | Field and Description |
---|---|
protected static Object |
ADD_RATING_LOCK |
Constructor and Description |
---|
JDBCRatingsDAO(DAOManager daoManager)
Default constructor
|
Modifier and Type | Method and Description |
---|---|
void |
addRating(ResourceImpl resourceImpl,
String userID,
int rating)
Method to persist a rating.
|
void |
addRatings(ResourceImpl resource,
RatingDO[] ratingDOs)
Method to persist ratings.
|
void |
copyRatings(ResourceImpl fromResource,
ResourceImpl toResource)
Method to copy ratings.
|
float |
getAverageRating(ResourceImpl resourceImpl)
Method to get the average rating added to a given resource.
|
String[] |
getRatedUserNames(ResourceImpl resourceImpl)
Method to get users who rated the given resource.
|
int |
getRateID(ResourceImpl resourceImpl,
String userID)
Method to get a id of a rating added to a given resource.
|
RatingDO |
getRating(long ratingID)
Method to get a rating corresponding to the given id.
|
int |
getRating(ResourceImpl resourceImpl,
String userID)
Method to get a rating added to a given resource.
|
RatingDO |
getRatingDO(ResourceImpl resourceImpl,
String userID)
Method to get a rating added by the given user to the given resource.
|
RatingDO[] |
getResourceRatingDO(ResourceImpl resourceImpl)
Method to get ratings added by all users to the given resource.
|
ResourceImpl |
getResourceWithMinimumData(String path)
Gets the resource with sufficient data to differentiate it from another resource.
|
void |
moveRatingPaths(ResourceIDImpl source,
ResourceIDImpl target)
Method to move rating paths.
|
void |
moveRatings(ResourceIDImpl source,
ResourceIDImpl target)
Method to move ratings.
|
void |
removeRating(ResourceImpl resourceImpl,
int ratingID)
Method to remove rating added to a resource.
|
void |
removeRatings(ResourceImpl resourceImpl)
Method to remove all ratings added to a resource.
|
void |
removeVersionRatings(long regVersion)
Removes all ratings added to the given resource of a given version.
|
void |
updateRating(ResourceImpl resourceImpl,
int rateID,
int rating)
Method to update a rating added to a resource.
|
protected static final Object ADD_RATING_LOCK
public JDBCRatingsDAO(DAOManager daoManager)
daoManager
- instance of the data access object manager.public void addRating(ResourceImpl resourceImpl, String userID, int rating) throws RegistryException
RatingsDAO
addRating
in interface RatingsDAO
resourceImpl
- the resourceuserID
- the id of the user who added the rating.rating
- the rating to be persisted.RegistryException
- if some error occurs while adding a ratingpublic void copyRatings(ResourceImpl fromResource, ResourceImpl toResource) throws RegistryException
RatingsDAO
copyRatings
in interface RatingsDAO
fromResource
- the source resource.toResource
- the target resource.RegistryException
- if some error occurs while copying ratingspublic void addRatings(ResourceImpl resource, RatingDO[] ratingDOs) throws RegistryException
RatingsDAO
addRatings
in interface RatingsDAO
resource
- the resourceratingDOs
- the ratings to be persisted.RegistryException
- if some error occurs while adding ratingspublic void updateRating(ResourceImpl resourceImpl, int rateID, int rating) throws RegistryException
RatingsDAO
updateRating
in interface RatingsDAO
resourceImpl
- the resource.rateID
- the rate id.rating
- the rating.RegistryException
- if some error occurs while updating the rating.public void removeRating(ResourceImpl resourceImpl, int ratingID) throws RegistryException
RatingsDAO
removeRating
in interface RatingsDAO
resourceImpl
- the resource.RegistryException
- if some error occurs while removing ratings.public int getRateID(ResourceImpl resourceImpl, String userID) throws RegistryException
RatingsDAO
getRateID
in interface RatingsDAO
resourceImpl
- the resource.userID
- the id of the user who added the rating.RegistryException
- if an error occurs while getting the rate id.public float getAverageRating(ResourceImpl resourceImpl) throws RegistryException
RatingsDAO
getAverageRating
in interface RatingsDAO
resourceImpl
- the resource.RegistryException
- if an error occurs while getting the average rating.public RatingDO getRatingDO(ResourceImpl resourceImpl, String userID) throws RegistryException
RatingsDAO
getRatingDO
in interface RatingsDAO
resourceImpl
- the resource.userID
- the id of the user who added the rating.RegistryException
- if an error occurs while getting the rating.public int getRating(ResourceImpl resourceImpl, String userID) throws RegistryException
RatingsDAO
getRating
in interface RatingsDAO
resourceImpl
- the resource.userID
- the id of the user who added the rating.RegistryException
- if an error occurs while getting the rating.public RatingDO getRating(long ratingID) throws SQLException, RegistryException
ratingID
- the id of the rating.RegistryException
- if an error occurs while getting the resource path.SQLException
- if an error occurs while getting the rating.public void removeRatings(ResourceImpl resourceImpl) throws RegistryException
RatingsDAO
removeRatings
in interface RatingsDAO
resourceImpl
- the resource.RegistryException
- if some error occurs while removing ratings.public RatingDO[] getResourceRatingDO(ResourceImpl resourceImpl) throws RegistryException
RatingsDAO
getResourceRatingDO
in interface RatingsDAO
resourceImpl
- the resource.RegistryException
- if an error occurs while getting the rating.public String[] getRatedUserNames(ResourceImpl resourceImpl) throws RegistryException
RatingsDAO
getRatedUserNames
in interface RatingsDAO
resourceImpl
- the resource.RegistryException
- if an error occurs while getting the rating.public ResourceImpl getResourceWithMinimumData(String path) throws RegistryException
RatingsDAO
ResourceImpl
with the path, name and path identifier
of a resource.getResourceWithMinimumData
in interface RatingsDAO
path
- the path of the resource.RegistryException
- if an error occurs while retrieving resource data.public void moveRatings(ResourceIDImpl source, ResourceIDImpl target) throws RegistryException
RatingsDAO
moveRatings
in interface RatingsDAO
source
- the source resource.target
- the target resource.RegistryException
- if some error occurs while moving ratingspublic void moveRatingPaths(ResourceIDImpl source, ResourceIDImpl target) throws RegistryException
RatingsDAO
moveRatingPaths
in interface RatingsDAO
source
- the source resource.target
- the target resource.RegistryException
- if some error occurs while moving rating pathspublic void removeVersionRatings(long regVersion) throws RegistryException
RatingsDAO
removeVersionRatings
in interface RatingsDAO
regVersion
- the versionRegistryException
- if an error occurred while removing tags.Copyright © 2015 WSO2 Inc. All Rights Reserved.