Package com.logicaldoc.core.document

# Interface RatingDAO

All Superinterfaces:
  `PersistentObjectDAO<Rating>`

All Known Implementing Classes:
  `HibernateRatingDAO`

public interface RatingDAO extends PersistentObjectDAO<Rating>
DAO service for ratings

Since:
  6.1
Author:
  Matteo Caruso - LogicalDOC

## Field Summary

### Fields inherited from interface com.logicaldoc.core.PersistentObjectDAO

`ENTITY`

## Method Summary

Modifier and Type
Method
Description
`List<Rating>`
`findByDocId(long docId)`
Finds the ratings stored for the given document id
`Rating`
`findByDocIdAndUserId(long docId, long userId)`
Finds the rating for the given user id and the given document id
`Rating`
`findVotesByDocId(long docId)`
Returns a rating that contains count and average of vote on the given document
`static RatingDAO`
`get()`
Gets the object available in the application context
`void`
`store(Rating rating, DocumentHistory transaction)`
Stores a rating and saves the document's history
`int`
`updateDocumentRating(long docId, DocumentHistory transaction)`
Updates the document's rating with the votes average

### Methods inherited from interface com.logicaldoc.core.PersistentObjectDAO

`bulkUpdate, count, count, count, delete, delete, deleteAll, deleteAll, evict, evict, findAll, findAll, findAllIds, findAllIds, findById, findById, findByObjectQuery, findByQuery, findByQuery, findByWhere, findByWhere, findIdsByWhere, findIdsByWhere, getDatabaseMetadata, getDbms, initialize, initialize, isMariaDB, isMySQL, isOracle, isPostgreSQL, isSQLServer, jdbcUpdate, jdbcUpdate, query, query, queryForDouble, queryForDouble, queryForInt, queryForInt, queryForList, queryForList, queryForList, queryForLong, queryForLong, queryForObject, queryForObject, queryForResultSet, queryForString, queryForString, store`

## Method Details

### get

static RatingDAO get()
Gets the object available in the application context

Returns:
  the instance of this object in the application context

### store

void store(Rating rating, DocumentHistory transaction) throws PersistenceException
Stores a rating and saves the document's history

Parameters:
  `rating` - the rating
  `transaction` - session informations
Throws:
  `PersistenceException` - error at data layer

### updateDocumentRating

int updateDocumentRating(long docId, DocumentHistory transaction) throws PersistenceException
Updates the document's rating with the votes average

Parameters:
  `docId` - Identifier of the document
  `transaction` - session informations
Returns:
  the new rating
Throws:
  `PersistenceException` - raised in case of database error

### findVotesByDocId

Rating findVotesByDocId(long docId) throws PersistenceException
Returns a rating that contains count and average of vote on the given document

Parameters:
  `docId` - ID of the document
Returns:
  the rating for the document
Throws:
  `PersistenceException` - Error in the database

### findByDocIdAndUserId

Rating findByDocIdAndUserId(long docId, long userId) throws PersistenceException
Finds the rating for the given user id and the given document id

Parameters:
  `docId` - ID of the document
  `userId` - ID of the user
Returns:
  the vote of the given user on the document
Throws:
  `PersistenceException` - Error in the database

### findByDocId

List<Rating> findByDocId(long docId) throws PersistenceException
Finds the ratings stored for the given document id

Parameters:
  `docId` - ID of the document
Returns:
  the list of ratings
Throws:
  `PersistenceException` - Error in the database