KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > mvnforum > db > PostDAO


1 /*
2  * $Header: /cvsroot/mvnforum/mvnforum/src/com/mvnforum/db/PostDAO.java,v 1.16 2006/04/14 17:05:26 minhnn Exp $
3  * $Author: minhnn $
4  * $Revision: 1.16 $
5  * $Date: 2006/04/14 17:05:26 $
6  *
7  * ====================================================================
8  *
9  * Copyright (C) 2002-2006 by MyVietnam.net
10  *
11  * All copyright notices regarding mvnForum MUST remain
12  * intact in the scripts and in the outputted HTML.
13  * The "powered by" text/logo with a link back to
14  * http://www.mvnForum.com and http://www.MyVietnam.net in
15  * the footer of the pages MUST remain visible when the pages
16  * are viewed on the internet or intranet.
17  *
18  * This program is free software; you can redistribute it and/or modify
19  * it under the terms of the GNU General Public License as published by
20  * the Free Software Foundation; either version 2 of the License, or
21  * any later version.
22  *
23  * This program is distributed in the hope that it will be useful,
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26  * GNU General Public License for more details.
27  *
28  * You should have received a copy of the GNU General Public License
29  * along with this program; if not, write to the Free Software
30  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31  *
32  * Support can be obtained from support forums at:
33  * http://www.mvnForum.com/mvnforum/index
34  *
35  * Correspondence and Marketing Questions can be sent to:
36  * info at MyVietnam net
37  *
38  * @author: Minh Nguyen
39  */

40 package com.mvnforum.db;
41
42 import java.sql.Timestamp JavaDoc;
43 import java.util.Collection JavaDoc;
44
45 import net.myvietnam.mvncore.exception.AssertionException;
46 import net.myvietnam.mvncore.exception.CreateException;
47 import net.myvietnam.mvncore.exception.DatabaseException;
48 import net.myvietnam.mvncore.exception.ObjectNotFoundException;
49 import net.myvietnam.mvncore.exception.ForeignKeyNotFoundException;
50
51 public interface PostDAO {
52
53     public static final String JavaDoc TABLE_NAME = DatabaseConfig.TABLE_PREFIX + "Post";
54
55     public void findByPrimaryKey(int postID)
56         throws ObjectNotFoundException, DatabaseException;
57
58     public int createPost(int parentPostID, int forumID, int threadID,
59                           int memberID, String JavaDoc memberName, String JavaDoc lastEditMemberName,
60                           String JavaDoc postTopic, String JavaDoc postBody, Timestamp JavaDoc postCreationDate,
61                           Timestamp JavaDoc postLastEditDate, String JavaDoc postCreationIP, String JavaDoc postLastEditIP,
62                           int postEditCount, int postFormatOption, int postOption,
63                           int postStatus, String JavaDoc postIcon, int postAttachCount)
64         throws CreateException, DatabaseException, ForeignKeyNotFoundException;
65
66     public void delete(int postID)
67         throws DatabaseException, ObjectNotFoundException;
68
69     public void delete_inThread(int threadID)
70         throws DatabaseException;
71
72     public void delete_inForum(int forumID)
73         throws DatabaseException;
74
75     public void update(int postID, // primary key
76
String JavaDoc lastEditMemberName, String JavaDoc postTopic, String JavaDoc postBody,
77                        Timestamp JavaDoc postLastEditDate, String JavaDoc postLastEditIP, int postFormatOption,
78                        int postOption, int postStatus, String JavaDoc postIcon)
79          throws ObjectNotFoundException, DatabaseException, ForeignKeyNotFoundException;
80
81     public void updateAttachCount(int postID, // primary key
82
int postAttachCount)
83         throws ObjectNotFoundException, DatabaseException;
84
85     public void updateStatus(int postID, // primary key
86
int postStatus)
87         throws ObjectNotFoundException, DatabaseException;
88
89     public void update_ForumID_inThread(int threadID, int forumID)
90         throws DatabaseException, ForeignKeyNotFoundException;
91
92     public void updateParentPostID(int oldParentPostID, int newParentPostID)
93         throws ObjectNotFoundException, DatabaseException;
94
95     public void increaseEditCount(int postID)
96         throws DatabaseException, ObjectNotFoundException;
97
98     public PostBean getPost(int postID)
99         throws ObjectNotFoundException, DatabaseException;
100
101     /**
102       * This method is used the get the first post of thread for moderation
103       *
104       * @param threadID
105       * @return
106       * @throws ObjectNotFoundException
107       * @throws DatabaseException
108       */

109     public PostBean getFirstPost_inThread(int threadID)
110         throws ObjectNotFoundException, DatabaseException;
111
112     public Collection JavaDoc getEnablePosts_inThread_limit(int threadID, int offset, int rowsToReturn)
113         throws IllegalArgumentException JavaDoc, DatabaseException;
114
115     public Collection JavaDoc getDisablePosts_inThread_limit(int threadID, int offset, int rowsToReturn)
116         throws IllegalArgumentException JavaDoc, DatabaseException;
117
118     public int getNumberOfEnablePosts_inThread(int threadID)
119         throws AssertionException, DatabaseException;
120
121     public int getNumberOfDisablePosts_inThread(int threadID)
122         throws AssertionException, DatabaseException;
123
124     public int getNumberOfPosts_inMember(int memberID)
125         throws AssertionException, DatabaseException;
126
127     /**
128      * This method could be used to update the statistics of the forum
129      *
130      * @param forumID int
131      * @throws AssertionException
132      * @throws DatabaseException
133      * @return int
134      */

135     public int getNumberOfEnablePosts_inForum(int forumID)
136         throws AssertionException, DatabaseException;
137
138     public int getNumberOfDisablePosts_inForum(int forumID)
139         throws AssertionException, DatabaseException;
140
141     /**
142      * This method could be used to check the total posts when compare with number of docs in lucene
143      *
144      * @throws AssertionException
145      * @throws DatabaseException
146      * @return int
147      */

148     public int getNumberOfPosts() throws AssertionException, DatabaseException;
149
150     /**
151      * This method could be used to get all post when rebuild lucene search index
152      *
153      * @throws DatabaseException
154      * @return Collection
155      */

156     public Collection JavaDoc getPosts() throws DatabaseException;
157
158     public int getMaxPostID()
159         throws AssertionException, DatabaseException;
160
161     /**
162      * This method could be used to get all post when rebuild lucene search index
163      *
164      * @throws DatabaseException
165      * @return Collection
166      */

167     public Collection JavaDoc getPosts_fromIDRange(int fromID, int toID)
168         throws IllegalArgumentException JavaDoc, DatabaseException;
169
170     /**
171      * This method could be used to get latest post in a thread to update
172      * thread statistics. It also could be used to get the latest posts
173      * when replying to a post
174      *
175      * @param threadID int
176      * @param rowsToReturn int
177      * @throws IllegalArgumentException
178      * @throws DatabaseException
179      * @return Collection
180      */

181     public Collection JavaDoc getLastEnablePosts_inThread_limit(int threadID, int rowsToReturn)
182         throws IllegalArgumentException JavaDoc, DatabaseException;
183
184     /**
185      * This method could be used to update forum statistics by getting one
186      * last post in a forum
187      *
188      * @param forumID int
189      * @param rowsToReturn int
190      * @throws IllegalArgumentException
191      * @throws DatabaseException
192      * @return Collection
193      */

194     public Collection JavaDoc getLastEnablePosts_inForum_limit(int forumID, int rowsToReturn)
195         throws IllegalArgumentException JavaDoc, DatabaseException;
196
197     public Collection JavaDoc getMostActiveMembers(Timestamp JavaDoc since, int rowsToReturn)
198         throws DatabaseException;
199
200     public Collection JavaDoc getMostActiveThreads(Timestamp JavaDoc since, int rowsToReturn)
201         throws DatabaseException;
202 }
203
Popular Tags