KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > jforum > dao > KarmaDAO


1 /*
2  * Copyright (c) 2003, Rafael Steil
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
45 import java.util.Date JavaDoc;
46 import java.util.List JavaDoc;
47 import java.util.Map JavaDoc;
48
49 import net.jforum.entities.Karma;
50 import net.jforum.entities.KarmaStatus;
51 import net.jforum.entities.User;
52
53 /**
54  * @author Rafael Steil
55  * @version $Id: KarmaDAO.java,v 1.4 2005/07/26 03:04:29 rafaelsteil Exp $
56  */

57 public interface KarmaDAO
58 {
59     /**
60      * Insert a new Karma.
61      *
62      * @param karma The karma to add. The instance should at
63      * least have set the karma status, the user who is receiving
64      * the karma and the user which is setting the karme.
65      * @throws Exception
66      */

67     public void addKarma(Karma karma) throws Exception JavaDoc;
68     
69     /**
70      * Gets the karma status of some user.
71      *
72      * @param userId The user id to get the karma status
73      * @return A <code>net.jforum.entities.KarmaStatus</code> instance
74      */

75     public KarmaStatus getUserKarma(int userId) throws Exception JavaDoc;
76     
77     /**
78      * Updates the karma status for some user.
79      * This method will store the user's karme in the
80      * users table.
81      *
82      * @param userId The id of the user to update
83      * @throws Exception
84      */

85     public void updateUserKarma(int userId) throws Exception JavaDoc;
86     
87     /**
88      * Checks if the user can add the karma.
89      * The method will search for existing entries in
90      * the karma table associated with the user id and post id
91      * passed as argument. If found, it means that the user
92      * already has voted, so we cannot allow him to vote one
93      * more time.
94      *
95      * @param userId The user id to check
96      * @param postId The post id to chekc
97      * @return <code>true</code> if the user hasn't voted on the
98      * post yet, or <code>false</code> otherwise.
99      * @throws Exception
100      */

101     public boolean userCanAddKarma(int userId, int postId) throws Exception JavaDoc;
102     
103     /**
104      * Gets the karma status of some post.
105      *
106      * @param postId The post id to get the karma status
107      * @return A <code>net.jforum.entities.KarmaStatus</code> instance
108      * @throws Exception
109      */

110     public KarmaStatus getPostKarma(int postId) throws Exception JavaDoc;
111     
112     /**
113      * Updates a karma
114      * @param karma The karma instance to update
115      */

116     public void update(Karma karma) throws Exception JavaDoc;
117     
118     /**
119      * Gets the votes the user made on some topic.
120      * @param topicId The topic id.
121      * @param userId TODO
122      *
123      * @return A <code>java.util.Map</code>, where the key is the post id and the
124      * value id the rate made by the user.
125      * @throws Exception
126      */

127     public Map JavaDoc getUserVotes(int topicId, int userId) throws Exception JavaDoc;
128     
129     /**
130      * @param user
131      * @throws Exception
132      */

133     public void getUserTotalKarma(User user) throws Exception JavaDoc;
134     
135     
136     /**
137      * Total points received, grouped by user and filtered by a range of dates.
138      *
139      * @param firstPeriod
140      * @param lastPeriod
141      * @return Returns a List of users ant your total votes.
142      * @throws Exception
143      */

144     public List JavaDoc getMostRatedUserByPeriod(int start, Date JavaDoc firstPeriod, Date JavaDoc lastPeriod, String JavaDoc orderField) throws Exception JavaDoc;
145 }
146
Popular Tags