org.wso2.carbon.registry.core.dao
Interface RatingsDAO

All Known Implementing Classes:
JDBCRatingsDAO, JDBCRatingsVersionDAO

public interface RatingsDAO

Data Access Object for Ratings


Method Summary
 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.
 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 rateID)
          Method to remove rating added to a resource.
 void removeRatings(ResourceImpl resourceImpl)
          Method to remove all ratings added to a resource.
 void removeVersionRatings(long version)
          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.
 

Method Detail

addRating

void addRating(ResourceImpl resourceImpl,
               String userID,
               int rating)
               throws RegistryException
Method to persist a rating.

Parameters:
resourceImpl - the resource
userID - the id of the user who added the rating.
rating - the rating to be persisted.
Throws:
RegistryException - if some error occurs while adding a rating

copyRatings

void copyRatings(ResourceImpl fromResource,
                 ResourceImpl toResource)
                 throws RegistryException
Method to copy ratings.

Parameters:
fromResource - the source resource.
toResource - the target resource.
Throws:
RegistryException - if some error occurs while copying ratings

addRatings

void addRatings(ResourceImpl resource,
                RatingDO[] ratingDOs)
                throws RegistryException
Method to persist ratings.

Parameters:
resource - the resource
ratingDOs - the ratings to be persisted.
Throws:
RegistryException - if some error occurs while adding ratings

updateRating

void updateRating(ResourceImpl resourceImpl,
                  int rateID,
                  int rating)
                  throws RegistryException
Method to update a rating added to a resource.

Parameters:
resourceImpl - the resource.
rateID - the rate id.
rating - the rating.
Throws:
RegistryException - if some error occurs while updating the rating.

getRateID

int getRateID(ResourceImpl resourceImpl,
              String userID)
              throws RegistryException
Method to get a id of a rating added to a given resource.

Parameters:
resourceImpl - the resource.
userID - the id of the user who added the rating.
Returns:
the rate id.
Throws:
RegistryException - if an error occurs while getting the rate id.

getAverageRating

float getAverageRating(ResourceImpl resourceImpl)
                       throws RegistryException
Method to get the average rating added to a given resource.

Parameters:
resourceImpl - the resource.
Returns:
the average rating.
Throws:
RegistryException - if an error occurs while getting the average rating.

getRatingDO

RatingDO getRatingDO(ResourceImpl resourceImpl,
                     String userID)
                     throws RegistryException
Method to get a rating added by the given user to the given resource.

Parameters:
resourceImpl - the resource.
userID - the id of the user who added the rating.
Returns:
the rating data object.
Throws:
RegistryException - if an error occurs while getting the rating.

getRating

int getRating(ResourceImpl resourceImpl,
              String userID)
              throws RegistryException
Method to get a rating added to a given resource.

Parameters:
resourceImpl - the resource.
userID - the id of the user who added the rating.
Returns:
the rating.
Throws:
RegistryException - if an error occurs while getting the rating.

removeRatings

void removeRatings(ResourceImpl resourceImpl)
                   throws RegistryException
Method to remove all ratings added to a resource.

Parameters:
resourceImpl - the resource.
Throws:
RegistryException - if some error occurs while removing ratings.

removeRating

void removeRating(ResourceImpl resourceImpl,
                  int rateID)
                  throws RegistryException
Method to remove rating added to a resource.

Parameters:
resourceImpl - the resource.
Throws:
RegistryException - if some error occurs while removing ratings.

getResourceRatingDO

RatingDO[] getResourceRatingDO(ResourceImpl resourceImpl)
                               throws RegistryException
Method to get ratings added by all users to the given resource.

Parameters:
resourceImpl - the resource.
Returns:
array of rating data objects.
Throws:
RegistryException - if an error occurs while getting the rating.

getRatedUserNames

String[] getRatedUserNames(ResourceImpl resourceImpl)
                           throws RegistryException
Method to get users who rated the given resource.

Parameters:
resourceImpl - the resource.
Returns:
array of user names.
Throws:
RegistryException - if an error occurs while getting the rating.

getResourceWithMinimumData

ResourceImpl getResourceWithMinimumData(String path)
                                        throws RegistryException
Gets the resource with sufficient data to differentiate it from another resource. This would populate a ResourceImpl with the path, name and path identifier of a resource.

Parameters:
path - the path of the resource.
Returns:
the resource with minimum data.
Throws:
RegistryException - if an error occurs while retrieving resource data.

moveRatings

void moveRatings(ResourceIDImpl source,
                 ResourceIDImpl target)
                 throws RegistryException
Method to move ratings.

Parameters:
source - the source resource.
target - the target resource.
Throws:
RegistryException - if some error occurs while moving ratings

moveRatingPaths

void moveRatingPaths(ResourceIDImpl source,
                     ResourceIDImpl target)
                     throws RegistryException
Method to move rating paths. This function will move the paths from one path id to another regardless of the resource name.

Parameters:
source - the source resource.
target - the target resource.
Throws:
RegistryException - if some error occurs while moving rating paths

removeVersionRatings

void removeVersionRatings(long version)
                          throws RegistryException
Removes all ratings added to the given resource of a given version. This applies only to versioned resources.

Parameters:
version - the version
Throws:
RegistryException - if an error occurred while removing tags.


Copyright © 2014 WSO2 Inc. All Rights Reserved.