KarmaDAO.java
Upload User: gdxydsw
Upload Date: 2019-01-29
Package Size: 16721k
Code Size: 4k
Category:

Java Develop

Development Platform:

Java

  1. /*
  2.  * Copyright (c) JForum Team
  3.  * All rights reserved.
  4.  * 
  5.  * Redistribution and use in source and binary forms, 
  6.  * with or without modification, are permitted provided 
  7.  * that the following conditions are met:
  8.  * 
  9.  * 1) Redistributions of source code must retain the above 
  10.  * copyright notice, this list of conditions and the 
  11.  * following  disclaimer.
  12.  * 2)  Redistributions in binary form must reproduce the 
  13.  * above copyright notice, this list of conditions and 
  14.  * the following disclaimer in the documentation and/or 
  15.  * other materials provided with the distribution.
  16.  * 3) Neither the name of "Rafael Steil" nor 
  17.  * the names of its contributors may be used to endorse 
  18.  * or promote products derived from this software without 
  19.  * specific prior written permission.
  20.  * 
  21.  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT 
  22.  * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
  23.  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 
  24.  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
  25.  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
  26.  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 
  27.  * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 
  28.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
  29.  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
  30.  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
  31.  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 
  32.  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
  33.  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 
  34.  * IN CONTRACT, STRICT LIABILITY, OR TORT 
  35.  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
  36.  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
  37.  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
  38.  * 
  39.  * Created on Jan 11, 2005 11:00:06 PM
  40.  * The JForum Project
  41.  * http://www.jforum.net
  42.  */
  43. package net.jforum.dao;
  44. import java.util.Date;
  45. import java.util.List;
  46. import java.util.Map;
  47. import net.jforum.entities.Karma;
  48. import net.jforum.entities.KarmaStatus;
  49. import net.jforum.entities.User;
  50. /**
  51.  * @author Rafael Steil
  52.  * @version $Id: KarmaDAO.java,v 1.7 2007/08/01 22:30:04 rafaelsteil Exp $
  53.  */
  54. public interface KarmaDAO
  55. {
  56. /**
  57.  * Insert a new Karma.
  58.  * 
  59.  * @param karma The karma to add. The instance should at
  60.  * least have set the karma status, the user who is receiving
  61.  * the karma and the user which is setting the karme.
  62.  */
  63. public void addKarma(Karma karma) ;
  64. /**
  65.  * Gets the karma status of some user.
  66.  * 
  67.  * @param userId The user id to get the karma status
  68.  * @return A <code>net.jforum.entities.KarmaStatus</code> instance
  69.  */
  70. public KarmaStatus getUserKarma(int userId) ;
  71. /**
  72.  * Updates the karma status for some user. 
  73.  * This method will store the user's karme in the
  74.  * users table. 
  75.  * 
  76.  * @param userId The id of the user to update
  77.  */
  78. public void updateUserKarma(int userId) ;
  79. /**
  80.  * Checks if the user can add the karma.
  81.  * The method will search for existing entries in
  82.  * the karma table associated with the user id and post id
  83.  * passed as argument. If found, it means that the user 
  84.  * already has voted, so we cannot allow him to vote one
  85.  * more time.
  86.  * 
  87.  * @param userId The user id to check
  88.  * @param postId The post id to chekc
  89.  * @return <code>true</code> if the user hasn't voted on the
  90.  * post yet, or <code>false</code> otherwise. 
  91.  */
  92. public boolean userCanAddKarma(int userId, int postId) ;
  93. /**
  94.  * Gets the karma status of some post.
  95.  * 
  96.  * @param postId The post id to get the karma status
  97.  * @return A <code>net.jforum.entities.KarmaStatus</code> instance
  98.  */
  99. public KarmaStatus getPostKarma(int postId) ;
  100. /**
  101.  * Updates a karma
  102.  * @param karma The karma instance to update
  103.  */
  104. public void update(Karma karma) ;
  105. /**
  106.  * Gets the votes the user made on some topic.
  107.  * @param topicId The topic id.
  108.  * @param userId 
  109.  * 
  110.  * @return A <code>java.util.Map</code>, where the key is the post id and the
  111.  * value id the rate made by the user.
  112.  */
  113. public Map getUserVotes(int topicId, int userId) ;
  114. /**
  115.  * @param user User
  116.  */
  117. public void getUserTotalKarma(User user) ;
  118. /**
  119.  * Total points received, grouped by user and filtered by a range of dates.
  120.  * 
  121.  * @param firstPeriod Date
  122.  * @param lastPeriod Date
  123.      * @param start int
  124.      * @param orderField orderField
  125.  * @return Returns a List of users ant your total votes.
  126.  */
  127. public List getMostRatedUserByPeriod(int start, Date firstPeriod, Date lastPeriod, String orderField) ;
  128. }