package eu.dnetlib.functionality.rating.dao;

import java.util.List;
import eu.dnetlib.domain.functionality.Rating;

/**
 * This interface describes the actions available for rating.
 * @author thanos@di.uoa.gr
 *
 */
public interface RatingDAO {
	/**
	 * Save a new or update an existing rating.
	 * @param rating the rating to save
	 * @throws RatingDAOException if any errors occur
	 */
	public void rate(Rating rating) throws RatingDAOException;
	
	/**
	 * Search for existing ratings by user.
	 * @param userId the id of the user
	 * @return a list of all the ratings of the specified user, ordered by score 
	 * @throws RatingDAOException if any errors occur
	 */
	public List<Rating> searchByUser(String userId) throws RatingDAOException;
	
	/**
	 * Search for existing ratings by document.
	 * @param documentId the id of the document
	 * @return a list of all the ratings of the specified document, ordered by score
	 * @throws RatingDAOException if any errors occur
	 */
	public List<Rating> searchByDocument(String documentId) throws RatingDAOException;
	
	/**
	 * Get the top ratings.
	 * @param limit the maximum number of ratings to retrieve
	 * @return a list of exisitng ratings, ordered by score 
	 * @throws RatingDAOException if any errors occur
	 */
	public List<Rating> getTopRatings(int limit) throws RatingDAOException;
	
	/**
	 * Get the top documents.
	 * @param limit the maximum number of average ratings to retrieve
	 * @return a list of document average ratings, ordered by score
	 * @throws RatingDAOException if any errors occur
	 */
	public List<Rating> getTopDocuments(int limit) throws RatingDAOException;
}
