KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * Copyright (c) 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  * This file creating date: Feb 23, 2003 / 2:43:40 PM
40  * The JForum Project
41  * http://www.jforum.net
42  */

43 package net.jforum.dao;
44
45 import java.util.List JavaDoc;
46
47 import net.jforum.entities.Forum;
48 import net.jforum.entities.ForumStats;
49 import net.jforum.entities.LastPostInfo;
50
51 /**
52 * Model interface for {@link net.jforum.Forum}.
53  * This interface defines methods which are expected to be
54  * implementd by a specific data access driver. The intention is
55  * to provide all functionality needed to update, insert, delete and
56  * select some specific data.
57  *
58  * @author Rafael Steil
59  * @version $Id: ForumDAO.java,v 1.9 2006/02/21 13:59:48 rafaelsteil Exp $
60  */

61 public interface ForumDAO
62 {
63     /**
64      * Gets a specific <code>Forum</code>.
65      *
66      * @param forumId The ForumID to search
67      * @return <code>Forum</code>object containing all the information
68      * @throws Exception
69      * @see #selectAll
70      */

71     public Forum selectById(int forumId) throws Exception JavaDoc;
72     
73     /**
74      * Selects all forums data from the database.
75      *
76      * @return ArrayList with the forums found
77      * @throws Exception
78      * @see #selectById
79      */

80     public List JavaDoc selectAll() throws Exception JavaDoc;
81     
82     /**
83      * Sets the forum's order one level up.
84      * When you call this method on a specific forum, the forum that
85      * is one level up will be sent down one level, and the forum which
86      * you are sending up wil take the order position of the forum which
87      * was sent down.
88      *
89      * @param forum The forum to change its order
90      * @param related The forum which comes before the forum we want to change
91      * @throws Exception
92      * @return The changed forum, with the new order set
93      */

94     public Forum setOrderUp(Forum forum, Forum related) throws Exception JavaDoc;
95     
96     /**
97      * Sets the forum's order one level down.
98      * For more information, take a look at @link #setOrderUp method.
99      * The only different between both is that this method sends the
100      * forum order down.
101      *
102      * @param forum The forum to change its order
103      * @param related The forum which comes after the forum we want to change
104      * @throws Exception
105      * @return The changed forum, with the new order set
106      */

107     public Forum setOrderDown(Forum forum, Forum related) throws Exception JavaDoc;
108     
109     /**
110      * Delete a forum.
111      *
112      * @param forumId The forum ID to delete
113      * @throws Exception
114      * @see #canDelete(int)
115      */

116     public void delete(int forumId) throws Exception JavaDoc;
117         
118     /**
119      * Updates a Forum.
120      *
121      * @param forum Reference to a <code>Forum</code> object to update
122      * @throws Exception
123      * @see #update(int)
124      */

125     public void update(Forum forum) throws Exception JavaDoc;
126     
127     /**
128      * Adds a new Forum.
129      *
130      * @param forum Reference to a valid and configured <code>Forum</code> object
131      * @return The forum's ID
132      * @throws Exception
133      */

134     public int addNew(Forum forum) throws Exception JavaDoc;
135     
136     /**
137      * Sets the last topic of a forum
138      *
139      * @param forumId The forum ID to update
140      * @param postId Last post ID
141      * @throws Exception
142      */

143     public void setLastPost(int forumId, int postId) throws Exception JavaDoc;
144
145     /**
146      * Increments the total number of topics of a forum
147      *
148      * @param forumId The forum ID to update
149      * @param count Increment a total of <code>count</code> elements
150      * @throws Exception
151      */

152     public void incrementTotalTopics(int forumId, int count) throws Exception JavaDoc;
153     
154     /**
155      * Decrements the total number of topics of a forum
156      *
157      * @param forumId The forum ID to update
158      * @param count Decrement a total of <code>count</code> elements
159      * @throws Exception
160      */

161     public void decrementTotalTopics(int forumId, int count) throws Exception JavaDoc;
162
163     /**
164      * Gets information about the latest message posted in some forum.
165      *
166      * @param forumId the forum's id to inspect
167      * @return A {@link LastPostInfo} instance
168      * @throws Exception
169      */

170     public LastPostInfo getLastPostInfo(int forumId) throws Exception JavaDoc;
171
172     /**
173      * Get all moderators of some forum
174      * @param forumId the forum's id to inspect
175      * @return a list with all moderators. Each entry is an instance of
176      * {@link net.jforum.entities.ModeratorInfo}
177      * @throws Exception
178      */

179     public List JavaDoc getModeratorList(int forumId) throws Exception JavaDoc;
180     
181     /**
182      * Gets the total number of messages of a forum
183      *
184      * @param forumId The forum ID
185      * @throws Exception
186      */

187     public int getTotalMessages() throws Exception JavaDoc;
188     
189     /**
190      * Gets the total number os topics of some forum
191      *
192      * @return Total of topics
193      * @throws Exception
194      */

195     public int getTotalTopics(int forumId) throws Exception JavaDoc;
196
197     
198     /**
199      * Gets the last post id associated to the forum
200      *
201      * @param forumId The forum id
202      * @throws Exception
203      */

204     public int getMaxPostId(int forumId) throws Exception JavaDoc;
205     
206     /**
207      * Move the topics to a new forum
208      *
209      * @param topics The topics id array
210      * @param fromForumId The original forum id
211      * @param toForumId The destination forum id
212      * @throws Exception
213      */

214     public void moveTopics(String JavaDoc[] topics, int fromForumId, int toForumId) throws Exception JavaDoc;
215     
216     /**
217      * Check if the forum has unread topics.
218      *
219      * @param forumId The forum's id to check
220      * @param lastVisit The last visit time the user has seen the forum
221      * @return An <code>java.util.List</code> instance, where each entry is a
222      * <code>net.jforum.entities.Topic</code> instance.
223      * @throws Exception
224      */

225     public List JavaDoc checkUnreadTopics(int forumId, long lastVisit) throws Exception JavaDoc;
226     
227     /**
228      * Enable or disabled moderation for the forum.
229      *
230      * @param categoryId The main category for the forum
231      * @param status a boolean value representing the desired status
232      * @throws Exception
233      */

234     public void setModerated(int categoryId, boolean status) throws Exception JavaDoc;
235     
236     /**
237      * Ges general statistics from the board
238      * @return
239      * @throws Exception
240      */

241     public ForumStats getBoardStatus() throws Exception JavaDoc;
242     
243     
244     //codes below are added by socialnework@gmail.com for "watching forum" purpose
245
/**
246      * Get the users to notify
247      *
248      * @param forum The forum
249      * @return <code>ArrayList</code> of <code>User</code> objects. Each
250      * entry is an user who will receive the new topic in the forum notification
251      * @throws Exception
252      * */

253     public List JavaDoc notifyUsers(Forum forum) throws Exception JavaDoc;
254     
255     
256     /**
257      * Subscribe the user for notification of new topic in the forum
258      * Added by socialnetwork@gmail.com
259      *
260      * @param forumId
261      * @param userId
262      * @throws Exception
263      */

264     public void subscribeUser(int forumId, int userId) throws Exception JavaDoc;
265     
266     /**
267      * Return the subscrition status of the user on the forum.
268      * Added by socialnetwork@gmail.com
269      *
270      * @param forumId
271      * @param userId
272      * @return
273      * @throws Exception
274      */

275     public boolean isUserSubscribed(int forumId, int userId) throws Exception JavaDoc;
276     
277     /**
278      * Remove the user's subscription of the forum
279      *
280      * @param forumId The forum id
281      * @param userId the User id
282      * @throws Exception
283      */

284     public void removeSubscription(int forumId, int userId) throws Exception JavaDoc;
285     
286     /**
287      * Clean all subscriptions of some forum
288      *
289      * @param forumId The forum id
290      * @throws Exception
291      */

292     public void removeSubscriptionByForum(int forumId) throws Exception JavaDoc;
293
294     
295 }
Popular Tags