alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

What this is

This file is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Other links

The source code

/*
 * Copyright (c) 2003, Rafael Steil
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, 
 * with or without modification, are permitted provided 
 * that the following conditions are met:
 * 
 * 1) Redistributions of source code must retain the above 
 * copyright notice, this list of conditions and the 
 * following  disclaimer.
 * 2)  Redistributions in binary form must reproduce the 
 * above copyright notice, this list of conditions and 
 * the following disclaimer in the documentation and/or 
 * other materials provided with the distribution.
 * 3) Neither the name of "Rafael Steil" nor 
 * the names of its contributors may be used to endorse 
 * or promote products derived from this software without 
 * specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT 
 * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 
 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 
 * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 
 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 
 * IN CONTRACT, STRICT LIABILITY, OR TORT 
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
 * 
 * Created on Jan 11, 2005 11:00:06 PM
 * The JForum Project
 * http://www.jforum.net
 */
package net.jforum.model;

import java.util.Date;
import java.util.List;
import java.util.Map;

import net.jforum.entities.Karma;
import net.jforum.entities.KarmaStatus;
import net.jforum.entities.User;

/**
 * @author Rafael Steil
 * @version $Id: KarmaModel.java,v 1.6 2005/02/21 14:31:07 rafaelsteil Exp $
 */
public interface KarmaModel
{
	/**
	 * Insert a new Karma.
	 * 
	 * @param karma The karma to add. The instance should at
	 * least have set the karma status, the user who is receiving
	 * the karma and the user which is setting the karme.
	 * @throws Exception
	 */
	public void addKarma(Karma karma) throws Exception;
	
	/**
	 * Gets the karma status of some user.
	 * 
	 * @param userId The user id to get the karma status
	 * @return A <code>net.jforum.entities.KarmaStatus instance
	 */
	public KarmaStatus getUserKarma(int userId) throws Exception;
	
	/**
	 * Updates the karma status for some user. 
	 * This method will store the user's karme in the
	 * users table. 
	 * 
	 * @param userId The id of the user to update
	 * @throws Exception
	 */
	public void updateUserKarma(int userId) throws Exception;
	
	/**
	 * Checks if the user can add the karma.
	 * The method will search for existing entries in
	 * the karma table associated with the user id and post id
	 * passed as argument. If found, it means that the user 
	 * already has voted, so we cannot allow him to vote one
	 * more time.
	 * 
	 * @param userId The user id to check
	 * @param postId The post id to chekc
	 * @return <code>true if the user hasn't voted on the
	 * post yet, or <code>false otherwise. 
	 * @throws Exception
	 */
	public boolean userCanAddKarma(int userId, int postId) throws Exception;
	
	/**
	 * Gets the karma status of some post.
	 * 
	 * @param postId The post id to get the karma status
	 * @return A <code>net.jforum.entities.KarmaStatus instance
	 * @throws Exception
	 */
	public KarmaStatus getPostKarma(int postId) throws Exception;
	
	/**
	 * Updates a karma
	 * @param karma The karma instance to update
	 */
	public void update(Karma karma) throws Exception;
	
	/**
	 * Gets the votes the user made on some topic.
	 * @param topicId The topic id.
	 * @param userId TODO
	 * 
	 * @return A <code>java.util.Map, where the key is the post id and the
	 * value id the rate made by the user.
	 * @throws Exception
	 */
	public Map getUserVotes(int topicId, int userId) throws Exception;
	
	/**
	 * @param user
	 * @throws Exception
	 */
	public void getUserTotalKarma(User user) throws Exception;
	
	
	/**
	 * Total points received, grouped by user and filtered by a range of dates.
	 * 
	 * @param firstPeriod
	 * @param lastPeriod
	 * @return Returns a List of users ant your total votes.
	 * @throws Exception
	 */
	public List getMostRatedUserByPeriod(int start, Date firstPeriod, Date lastPeriod, String orderField) throws Exception;
}
... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.