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: * This file creating date: Feb 23, 2003 / 2:43:40 PM
040: * The JForum Project
041: * http://www.jforum.net
042: */
043: package net.jforum.dao;
044:
045: import java.util.List;
046:
047: import net.jforum.entities.Forum;
048: import net.jforum.entities.ForumStats;
049: import net.jforum.entities.LastPostInfo;
050:
051: /**
052: * Model interface for {@link net.jforum.entities.Forum}.
053: * This interface defines methods which are expected to be
054: * implementd by a specific data access driver. The intention is
055: * to provide all functionality needed to update, insert, delete and
056: * select some specific data.
057: *
058: * @author Rafael Steil
059: * @version $Id: ForumDAO.java,v 1.12 2006/08/28 23:22:27 rafaelsteil Exp $
060: */
061: public interface ForumDAO {
062: /**
063: * Gets a specific <code>Forum</code>.
064: *
065: * @param forumId The ForumID to search
066: * @return <code>Forum</code>object containing all the information
067: * @see #selectAll
068: */
069: public Forum selectById(int forumId);
070:
071: /**
072: * Selects all forums data from the database.
073: *
074: * @return ArrayList with the forums found
075: * @see #selectById
076: */
077: public List selectAll();
078:
079: /**
080: * Sets the forum's order one level up.
081: * When you call this method on a specific forum, the forum that
082: * is one level up will be sent down one level, and the forum which
083: * you are sending up wil take the order position of the forum which
084: * was sent down.
085: *
086: * @param forum The forum to change its order
087: * @param related The forum which comes before the forum we want to change
088: * @return The changed forum, with the new order set
089: */
090: public Forum setOrderUp(Forum forum, Forum related);
091:
092: /**
093: * Sets the forum's order one level down.
094: * For more information, take a look at @link #setOrderUp method.
095: * The only different between both is that this method sends the
096: * forum order down.
097: *
098: * @param forum The forum to change its order
099: * @param related The forum which comes after the forum we want to change
100: * @return The changed forum, with the new order set
101: */
102: public Forum setOrderDown(Forum forum, Forum related);
103:
104: /**
105: * Delete a forum.
106: *
107: * @param forumId The forum ID to delete
108: */
109: public void delete(int forumId);
110:
111: /**
112: * Updates a Forum.
113: *
114: * @param forum Reference to a <code>Forum</code> object to update
115: */
116: public void update(Forum forum);
117:
118: /**
119: * Adds a new Forum.
120: *
121: * @param forum Reference to a valid and configured <code>Forum</code> object
122: * @return The forum's ID
123: */
124: public int addNew(Forum forum);
125:
126: /**
127: * Sets the last topic of a forum
128: *
129: * @param forumId The forum ID to update
130: * @param postId Last post ID
131: */
132: public void setLastPost(int forumId, int postId);
133:
134: /**
135: * Increments the total number of topics of a forum
136: *
137: * @param forumId The forum ID to update
138: * @param count Increment a total of <code>count</code> elements
139: */
140: public void incrementTotalTopics(int forumId, int count);
141:
142: /**
143: * Decrements the total number of topics of a forum
144: *
145: * @param forumId The forum ID to update
146: * @param count Decrement a total of <code>count</code> elements
147: */
148: public void decrementTotalTopics(int forumId, int count);
149:
150: /**
151: * Gets information about the latest message posted in some forum.
152: *
153: * @param forumId the forum's id to inspect
154: * @return A {@link LastPostInfo} instance
155: */
156: public LastPostInfo getLastPostInfo(int forumId);
157:
158: /**
159: * Get all moderators of some forum
160: * @param forumId the forum's id to inspect
161: * @return a list with all moderators. Each entry is an instance of
162: * {@link net.jforum.entities.ModeratorInfo}
163: */
164: public List getModeratorList(int forumId);
165:
166: /**
167: * Gets the total number of messages of a forum
168: * @return int
169: */
170: public int getTotalMessages();
171:
172: /**
173: * Gets the total number os topics of some forum
174: *
175: * @return Total of topics
176: * @param forumId int
177: */
178: public int getTotalTopics(int forumId);
179:
180: /**
181: * Gets the last post id associated to the forum
182: *
183: * @param forumId The forum id
184: * @return int
185: */
186: public int getMaxPostId(int forumId);
187:
188: /**
189: * Move the topics to a new forum
190: *
191: * @param topics The topics id array
192: * @param fromForumId The original forum id
193: * @param toForumId The destination forum id
194: */
195: public void moveTopics(String[] topics, int fromForumId,
196: int toForumId);
197:
198: /**
199: * Check if the forum has unread topics.
200: *
201: * @param forumId The forum's id to check
202: * @param lastVisit The last visit time the user has seen the forum
203: * @return An <code>java.util.List</code> instance, where each entry is a
204: * <code>net.jforum.entities.Topic</code> instance.
205: */
206: public List checkUnreadTopics(int forumId, long lastVisit);
207:
208: /**
209: * Enable or disabled moderation for the forum.
210: *
211: * @param categoryId The main category for the forum
212: * @param status a boolean value representing the desired status
213: */
214: public void setModerated(int categoryId, boolean status);
215:
216: /**
217: * Ges general statistics from the board
218: * @return ForumStats
219: */
220: public ForumStats getBoardStatus();
221:
222: //codes below are added by socialnework@gmail.com for "watching forum" purpose
223: /**
224: * Get the users to notify
225: *
226: * @param forum The forum
227: * @return <code>ArrayList</code> of <code>User</code> objects. Each
228: * entry is an user who will receive the new topic in the forum notification
229: * */
230: public List notifyUsers(Forum forum);
231:
232: /**
233: * Subscribe the user for notification of new topic in the forum
234: * Added by socialnetwork@gmail.com
235: *
236: * @param forumId int
237: * @param userId int
238: */
239: public void subscribeUser(int forumId, int userId);
240:
241: /**
242: * Return the subscrition status of the user on the forum.
243: * Added by socialnetwork@gmail.com
244: *
245: * @param forumId int
246: * @param userId int
247: * @return boolean
248: */
249: public boolean isUserSubscribed(int forumId, int userId);
250:
251: /**
252: * Remove the user's subscription of the forum
253: *
254: * @param forumId The forum id
255: * @param userId the User id
256: */
257: public void removeSubscription(int forumId, int userId);
258:
259: /**
260: * Clean all subscriptions of some forum
261: *
262: * @param forumId The forum id
263: */
264: public void removeSubscriptionByForum(int forumId);
265:
266: /**
267: * Given an email address, finds the forum Id
268: * @param listEmail the email of the forum
269: * @return the forum id of the given email, or 0 if not found
270: */
271: public int discoverForumId(String listEmail);
272: }
|