001: /*
002: * Copyright (c) JForum Team
003: * All rights reserved.
004: *
005: * Redistribution and use in source and binary forms,
006: * with or without modification, are permitted provided
007: * that the following conditions are met:
008: *
009: * 1) Redistributions of source code must retain the above
010: * copyright notice, this list of conditions and the
011: * following disclaimer.
012: * 2) Redistributions in binary form must reproduce the
013: * above copyright notice, this list of conditions and
014: * the following disclaimer in the documentation and/or
015: * other materials provided with the distribution.
016: * 3) Neither the name of "Rafael Steil" nor
017: * the names of its contributors may be used to endorse
018: * or promote products derived from this software without
019: * specific prior written permission.
020: *
021: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
022: * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
023: * EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
024: * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
025: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR
026: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
027: * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
028: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
029: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES
030: * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
031: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
032: * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
033: * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
034: * IN CONTRACT, STRICT LIABILITY, OR TORT
035: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
036: * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
037: * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
038: *
039: * Created on Jan 11, 2005 11:00:06 PM
040: * The JForum Project
041: * http://www.jforum.net
042: */
043: package net.jforum.dao;
044:
045: import java.util.Date;
046: import java.util.List;
047: import java.util.Map;
048:
049: import net.jforum.entities.Karma;
050: import net.jforum.entities.KarmaStatus;
051: import net.jforum.entities.User;
052:
053: /**
054: * @author Rafael Steil
055: * @version $Id: KarmaDAO.java,v 1.7 2007/08/01 22:30:04 rafaelsteil Exp $
056: */
057: public interface KarmaDAO {
058: /**
059: * Insert a new Karma.
060: *
061: * @param karma The karma to add. The instance should at
062: * least have set the karma status, the user who is receiving
063: * the karma and the user which is setting the karme.
064: */
065: public void addKarma(Karma karma);
066:
067: /**
068: * Gets the karma status of some user.
069: *
070: * @param userId The user id to get the karma status
071: * @return A <code>net.jforum.entities.KarmaStatus</code> instance
072: */
073: public KarmaStatus getUserKarma(int userId);
074:
075: /**
076: * Updates the karma status for some user.
077: * This method will store the user's karme in the
078: * users table.
079: *
080: * @param userId The id of the user to update
081: */
082: public void updateUserKarma(int userId);
083:
084: /**
085: * Checks if the user can add the karma.
086: * The method will search for existing entries in
087: * the karma table associated with the user id and post id
088: * passed as argument. If found, it means that the user
089: * already has voted, so we cannot allow him to vote one
090: * more time.
091: *
092: * @param userId The user id to check
093: * @param postId The post id to chekc
094: * @return <code>true</code> if the user hasn't voted on the
095: * post yet, or <code>false</code> otherwise.
096: */
097: public boolean userCanAddKarma(int userId, int postId);
098:
099: /**
100: * Gets the karma status of some post.
101: *
102: * @param postId The post id to get the karma status
103: * @return A <code>net.jforum.entities.KarmaStatus</code> instance
104: */
105: public KarmaStatus getPostKarma(int postId);
106:
107: /**
108: * Updates a karma
109: * @param karma The karma instance to update
110: */
111: public void update(Karma karma);
112:
113: /**
114: * Gets the votes the user made on some topic.
115: * @param topicId The topic id.
116: * @param userId
117: *
118: * @return A <code>java.util.Map</code>, where the key is the post id and the
119: * value id the rate made by the user.
120: */
121: public Map getUserVotes(int topicId, int userId);
122:
123: /**
124: * @param user User
125: */
126: public void getUserTotalKarma(User user);
127:
128: /**
129: * Total points received, grouped by user and filtered by a range of dates.
130: *
131: * @param firstPeriod Date
132: * @param lastPeriod Date
133: * @param start int
134: * @param orderField orderField
135: * @return Returns a List of users ant your total votes.
136: */
137: public List getMostRatedUserByPeriod(int start, Date firstPeriod,
138: Date lastPeriod, String orderField);
139: }
|