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 Dec 29, 2004 2:00:00 PM
040: * The JForum Project
041: * http://www.jforum.net
042: */
043: package net.jforum.dao;
044:
045: import net.jforum.entities.Poll;
046:
047: public interface PollDAO {
048:
049: /**
050: * Gets a specific <code>Poll</code>.
051: *
052: * @param pollId The Poll ID to search
053: * @return <code>Poll</code>object containing all the information
054: */
055: public Poll selectById(int pollId);
056:
057: /**
058: * Delete a Poll.
059: *
060: * @param pollId The Poll to delete
061: */
062: public void delete(int pollId);
063:
064: /**
065: * Delete a Poll.
066: *
067: * @param topicId The topic id for the poll to delete
068: */
069: public void deleteByTopicId(int topicId);
070:
071: /**
072: * Updates a Poll.
073: *
074: * @param poll Reference to a <code>Poll</code> object to update
075: */
076: public void update(Poll poll);
077:
078: /**
079: * Adds a new Poll.
080: *
081: * @param poll Poll Reference to a valid and configured <code>Poll</code> object
082: * @return The new ID
083: */
084: public int addNew(Poll poll);
085:
086: /**
087: * Increments the vote count on the poll for the given poll id and option id
088: * @param pollId the poll id that the vote is for
089: * @param optionId the option that was selected for the poll
090: * @param userId int
091: * @param ipAddress String
092: */
093: public void voteOnPoll(int pollId, int optionId, int userId,
094: String ipAddress);
095:
096: /**
097: * Tells if the user has already voted on the given poll
098: * @param pollId the poll id that is being checked
099: * @param userId the user id to check the vote for
100: * @return true if the user has already voted on the given poll
101: */
102: public boolean hasUserVotedOnPoll(int pollId, int userId);
103:
104: /**
105: * Tells if any user has already voted on the given poll from the given IP
106: * @param pollId the poll id that is being checked
107: * @param ipAddress the IP address of the user to check the vote for
108: * @return true if the user has already voted on the given poll
109: */
110: public boolean hasUserVotedOnPoll(int pollId, String ipAddress);
111: }
|