org.wso2.carbon.registry.core.jdbc.dao
Class RatingsVersionDAO

java.lang.Object
  extended by org.wso2.carbon.registry.core.jdbc.dao.RatingsDAO
      extended by org.wso2.carbon.registry.core.jdbc.dao.RatingsVersionDAO

public class RatingsVersionDAO
extends RatingsDAO

Data Access Object for Ratings when auto-versioning for ratings has been enabled.


Constructor Summary
RatingsVersionDAO()
           
 
Method Summary
 void addRating(ResourceImpl resourceImpl, String userID, int rating)
          Method to persist a rating.
 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.
 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.
 
Methods inherited from class org.wso2.carbon.registry.core.jdbc.dao.RatingsDAO
addRatings, getRating, removeRatings, updateRating
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RatingsVersionDAO

public RatingsVersionDAO()
Method Detail

addRating

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

Overrides:
addRating in class RatingsDAO
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

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

Overrides:
copyRatings in class RatingsDAO
Parameters:
fromResource - the source resource.
toResource - the target resource.
Throws:
RegistryException - if some error occurs while copying ratings

getRateID

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

Overrides:
getRateID in class RatingsDAO
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

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

Overrides:
getAverageRating in class RatingsDAO
Parameters:
resourceImpl - the resource.
Returns:
the average rating.
Throws:
RegistryException - if an error occurs while getting the average rating.

getRatingDO

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

Overrides:
getRatingDO in class RatingsDAO
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.

getResourceRatingDO

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

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

getRatedUserNames

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

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

getRating

public RatingDO getRating(long ratingID)
                   throws SQLException,
                          RegistryException
Method to get a rating corresponding to the given id.

Overrides:
getRating in class RatingsDAO
Parameters:
ratingID - the id of the rating.
Returns:
the rating data object.
Throws:
RegistryException - if an error occurs while getting the resource path.
SQLException - if an error occurs while getting the rating.

getResourceWithMinimumData

public 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.

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

moveRatings

public void moveRatings(ResourceIDImpl source,
                        ResourceIDImpl target)
                 throws RegistryException
Method to move ratings. This function is not applicable to versioned resources.

Overrides:
moveRatings in class RatingsDAO
Parameters:
source - the source resource.
target - the target resource.
Throws:
RegistryException - if some error occurs while moving ratings

moveRatingPaths

public void moveRatingPaths(ResourceIDImpl source,
                            ResourceIDImpl target)
                     throws RegistryException
Method to move rating paths. This function is not applicable to versioned resources.

Overrides:
moveRatingPaths in class RatingsDAO
Parameters:
source - the source resource.
target - the target resource.
Throws:
RegistryException - if some error occurs while moving rating paths


Copyright © 2010. All Rights Reserved.