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

java.lang.Object
  extended by org.wso2.carbon.registry.core.jdbc.dao.JDBCRatingsDAO
      extended by org.wso2.carbon.registry.core.jdbc.dao.JDBCRatingsVersionDAO
All Implemented Interfaces:
RatingsDAO

public class JDBCRatingsVersionDAO
extends JDBCRatingsDAO
implements RatingsDAO

An extension of JDBCRatingsDAO implements RatingsDAO to store ratings on a JDBC-based database, when versioning for ratings has been enabled.


Field Summary
 
Fields inherited from class org.wso2.carbon.registry.core.jdbc.dao.JDBCRatingsDAO
ADD_RATING_LOCK
 
Constructor Summary
JDBCRatingsVersionDAO(DAOManager daoManager)
          Default constructor
 
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.JDBCRatingsDAO
addRatings, getRating, removeRating, removeRatings, removeVersionRatings, updateRating
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.wso2.carbon.registry.core.dao.RatingsDAO
addRatings, getRating, removeRating, removeRatings, removeVersionRatings, updateRating
 

Constructor Detail

JDBCRatingsVersionDAO

public JDBCRatingsVersionDAO(DAOManager daoManager)
Default constructor

Parameters:
daoManager - instance of the data access object manager.
Method Detail

addRating

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

Specified by:
addRating in interface RatingsDAO
Overrides:
addRating in class JDBCRatingsDAO
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.

Specified by:
copyRatings in interface RatingsDAO
Overrides:
copyRatings in class JDBCRatingsDAO
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.

Specified by:
getRateID in interface RatingsDAO
Overrides:
getRateID in class JDBCRatingsDAO
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.

Specified by:
getAverageRating in interface RatingsDAO
Overrides:
getAverageRating in class JDBCRatingsDAO
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.

Specified by:
getRatingDO in interface RatingsDAO
Overrides:
getRatingDO in class JDBCRatingsDAO
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.

Specified by:
getResourceRatingDO in interface RatingsDAO
Overrides:
getResourceRatingDO in class JDBCRatingsDAO
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.

Specified by:
getRatedUserNames in interface RatingsDAO
Overrides:
getRatedUserNames in class JDBCRatingsDAO
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 JDBCRatingsDAO
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.

Specified by:
getResourceWithMinimumData in interface RatingsDAO
Overrides:
getResourceWithMinimumData in class JDBCRatingsDAO
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.

Specified by:
moveRatings in interface RatingsDAO
Overrides:
moveRatings in class JDBCRatingsDAO
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.

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


Copyright © 2014 WSO2 Inc. All Rights Reserved.