KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jresearch > gossip > dao > drivers > mssql > MSSqlForumQueries


1 /*
2  * $Id: MSSqlForumQueries.java,v 1.3 2005/06/07 12:32:25 bel70 Exp $
3  *
4  * ***** BEGIN LICENSE BLOCK *****
5  * The contents of this file are subject to the Mozilla Public License
6  * Version 1.1 (the "License"); you may not use this file except in
7  * compliance with the License. You may obtain a copy of the License
8  * at http://www.mozilla.org/MPL/
9  *
10  * Software distributed under the License is distributed on an "AS IS"
11  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
12  * the License for the specific language governing rights and
13  * limitations under the License.
14  *
15  * The Original Code is JGossip forum code.
16  *
17  * The Initial Developer of the Original Code is the JResearch, Org.
18  * Portions created by the Initial Developer are Copyright (C) 2004
19  * the Initial Developer. All Rights Reserved.
20  *
21  * Contributor(s):
22  * Simone Chiaretta <simo@users.sourceforge.net>
23  *
24  * ***** END LICENSE BLOCK ***** */

25 package org.jresearch.gossip.dao.drivers.mssql;
26
27 import org.jresearch.gossip.dao.drivers.ForumQueries;
28
29 /**
30  * MSSqlForumQueries
31  *
32  * @author <a HREF="simo@sourceforge.net">S. Chiaretta</a>
33  * @version $version$ $Date: 2005/06/07 12:32:25 $
34  */

35 class MSSqlForumQueries extends ForumQueries {
36
37     /**
38      * @see org.jresearch.gossip.dao.drivers.ForumQueries#getSql_COUNT_LOG_ENTRIES()
39      */

40     public String JavaDoc getSql_COUNT_LOG_ENTRIES() {
41         return COUNT_LOG_ENTRIES;
42     }
43
44     /**
45      * @see org.jresearch.gossip.dao.drivers.ForumQueries#getSql_GET_LAST_MESS()
46      */

47     public String JavaDoc getSql_GET_LAST_MESS() {
48         return GET_LAST_MESS;
49     }
50
51     /**
52      * @see org.jresearch.gossip.dao.drivers.ForumQueries#getSql_GET_ROOT_MESS()
53      */

54     public String JavaDoc getSql_GET_ROOT_MESS() {
55         return GET_ROOT_MESS;
56     }
57
58     /**
59      * @see org.jresearch.gossip.dao.drivers.ForumQueries#getSql_GET_LAST_TOPICS_IN_FORUM()
60      */

61     public String JavaDoc getSql_GET_LAST_TOPICS_IN_FORUM() {
62         return GET_LAST_TOPICS_IN_FORUM;
63     }
64
65     /**
66      * @see org.jresearch.gossip.dao.drivers.ForumQueries#getSql_GET_LAST_TOPICS()
67      */

68     public String JavaDoc getSql_GET_LAST_TOPICS() {
69         return GET_LAST_TOPICS;
70     }
71
72     /**
73      * @see org.jresearch.gossip.dao.drivers.ForumQueries#getSql_GET_NEW_THREADS_ALL()
74      */

75     public String JavaDoc getSql_GET_LAST_UPDATED_TOPICS_ALL() {
76         return GET_NEW_THREADS_ALL;
77     }
78
79     /**
80      * @see org.jresearch.gossip.dao.drivers.ForumQueries#getSql_GET_NEW_THREADS()
81      */

82     public String JavaDoc getSql_GET_LAST_UPDATED_TOPICS() {
83         return GET_NEW_THREADS;
84     }
85
86     /**
87      * @see org.jresearch.gossip.dao.drivers.ForumQueries#getSql_LOG_ENTRIES_ASC()
88      */

89     public String JavaDoc getSql_GET_LOG_ENTRIES_ASC() {
90         return GET_LOG_ENTRIES_DESC;
91     }
92
93     /**
94      * @see org.jresearch.gossip.dao.drivers.ForumQueries#getSql_LOG_ENTRIES_DESC()
95      */

96     public String JavaDoc getSql_GET_LOG_ENTRIES_DESC() {
97         return GET_LOG_ENTRIES_DESC;
98     }
99
100     /**
101      * @see org.jresearch.gossip.dao.drivers.ForumQueries#getSql_GET_OLD_TOPICS()
102      */

103     public String JavaDoc getSql_GET_OLD_TOPICS() {
104         return GET_OLD_TOPICS;
105     }
106
107     /**
108      * @see org.jresearch.gossip.dao.drivers.ForumQueries#getSql_GET_THREAD_LAST_INTIME()
109      */

110     public String JavaDoc getSql_GET_THREAD_LAST_INTIME() {
111         return GET_THREAD_LAST_INTIME;
112     }
113
114     /**
115      * @see org.jresearch.gossip.dao.drivers.ForumQueries#getSql_GET_THREAD_LAST_MESS()
116      */

117     public String JavaDoc getSql_GET_THREAD_LAST_MESS() {
118         return GET_THREAD_LAST_MESS;
119     }
120
121     /**
122      * @see org.jresearch.gossip.dao.drivers.ForumQueries#getSql_GET_THREAD_MESSAGES()
123      */

124     public String JavaDoc getSql_GET_THREAD_MESSAGES() {
125         return GET_THREAD_MESSAGES;
126     }
127
128     /**
129      * @see org.jresearch.gossip.dao.drivers.ForumQueries#getSql_GET_THREAD_SUBJ()
130      */

131     public String JavaDoc getSql_GET_THREAD_SUBJ() {
132         return GET_THREAD_SUBJ;
133     }
134
135     /**
136      * @see org.jresearch.gossip.dao.drivers.ForumQueries#getSql_GET_THREADS()
137      */

138     public String JavaDoc getSql_GET_THREADS() {
139         return GET_THREADS;
140     }
141
142     /**
143      * @see org.jresearch.gossip.dao.drivers.ForumQueries#getSql_GET_USER_SUBSCRIPTIONS()
144      */

145     public String JavaDoc getSql_GET_USER_SUBSCRIPTIONS() {
146         return GET_USER_SUBSCRIPTIONS;
147     }
148
149     /**
150      * @see org.jresearch.gossip.dao.drivers.ForumQueries#getSql_SEARCH_QUERY_END()
151      */

152     public String JavaDoc getSql_SEARCH_QUERY_END() {
153         return SEARCH_QUERY_END;
154     }
155
156     /**
157      * @see org.jresearch.gossip.dao.drivers.ForumQueries#getSql_SEARCH_QUERY_SUFF_COUNT()
158      */

159     public String JavaDoc getSql_SEARCH_QUERY_SUFF_COUNT() {
160         return SEARCH_QUERY_SUFF_COUNT;
161     }
162
163     /**
164      * @see org.jresearch.gossip.dao.drivers.ForumQueries#getSql_SEARCH_QUERY_SUFF()
165      */

166     public String JavaDoc getSql_SEARCH_QUERY_SUFF() {
167         return SEARCH_QUERY_SUFF;
168     }
169
170     /**
171      * @see org.jresearch.gossip.dao.drivers.ForumQueries#getSql_GET_MESS_POS_BY_INTIME()
172      */

173     public String JavaDoc getSql_GET_MESS_POS_BY_INTIME() {
174         return GET_MESS_POS_BY_INTIME;
175     }
176
177     private static final String JavaDoc COUNT_LOG_ENTRIES = "SELECT count(log_date) as tot_log_entries "
178             + " FROM jrf_audit_log "
179             + " WHERE CAST(SUBSTRING(log_date, 1, 19) AS DATETIME) >= ? AND CAST(SUBSTRING(log_date, 1, 19) AS DATETIME) <= ? AND "
180             + " logger LIKE ? AND "
181             + " log_level LIKE ? AND "
182             + " remote_ip LIKE ? AND "
183             + " session_id LIKE ? AND "
184             + " user_name LIKE ? ";
185
186     private static final String JavaDoc GET_LAST_MESS = "SELECT TOP 1 jrf_message.sender AS m_from,jrf_thread.lintime AS t_stamp,"
187             + "jrf_message.centents AS cont,jrf_thread.sortby ,jrf_message.id, jrf_thread.threadid AS tid FROM jrf_message, jrf_thread WHERE "
188             + "jrf_thread.lintime = jrf_message.intime AND jrf_thread.threadid = jrf_message.threadid "
189             + "AND jrf_thread.forumid =? ORDER BY lintime DESC";
190
191     private static final String JavaDoc GET_ROOT_MESS = "SELECT TOP 1"
192             + " jrf_message.sender,jrf_thread.lintime AS t_stamp, jrf_message.centents, "
193             + " jrf_message.id, jrf_message.heading as subject, jrf_message.ip, jrf_thread.threadid AS tid , jrf_thread.sortby "
194             + "FROM jrf_thread, jrf_message " + "WHERE "
195             + " jrf_thread.threadid = ? AND "
196             + " jrf_message.threadid = jrf_thread.threadid "
197             + "ORDER BY jrf_thread.lintime ASC ";
198
199     private static final String JavaDoc GET_LAST_TOPICS_IN_FORUM = "EXEC sp_GET_LAST_TOPICS_IN_FORUM ?,?,?";
200
201     private static final String JavaDoc GET_LAST_TOPICS = "EXEC sp_GET_LAST_TOPICS ?,?";
202
203     private static final String JavaDoc GET_LOG_ENTRIES_ASC = "EXEC sp_GET_LOG_ENTRIES_ASC ?,?,?,?,?,?,?,?,?";
204
205     private static final String JavaDoc GET_LOG_ENTRIES_DESC = "EXEC sp_GET_LOG_ENTRIES_DESC ?,?,?,?,?,?,?,?,?";
206
207     private static final String JavaDoc GET_NEW_THREADS = "EXEC sp_GET_NEW_THREADS ?,?,?";
208
209     private static final String JavaDoc GET_NEW_THREADS_ALL = "EXEC sp_GET_NEW_THREADS_ALL ?,?,?";
210
211     private static final String JavaDoc GET_OLD_TOPICS = "SELECT jrf_thread.threadid, count(jrf_message.id) AS cc FROM jrf_thread, jrf_message WHERE jrf_thread.threadid = jrf_message.threadid AND TO_DAYS(GETDATE()) - TO_DAYS(jrf_thread.lintime) > ? GROUP BY jrf_thread.threadid";
212
213     private static final String JavaDoc GET_THREAD_LAST_INTIME = "SELECT TOP 1 intime FROM jrf_message WHERE threadid = ? ORDER BY intime DESC";
214
215     private static final String JavaDoc GET_THREAD_LAST_MESS = "SELECT TOP 1 sender, intime, centents,id FROM jrf_message WHERE jrf_message.threadid =? ORDER BY intime DESC";
216
217     private static final String JavaDoc GET_THREAD_MESSAGES = "EXEC sp_GET_THREAD_MESSAGES ?,?,?";
218
219     private static final String JavaDoc GET_THREAD_SUBJ = "SELECT TOP 1 heading FROM jrf_message WHERE threadid = ? ORDER BY intime";
220
221     private static final String JavaDoc GET_THREADS = "EXEC sp_GET_THREADS ?,?,?";
222
223     private static final String JavaDoc GET_USER_SUBSCRIPTIONS = "EXEC sp_GET_USER_SUBSCRIPTIONS ?,?,?";
224
225     private static final String JavaDoc SEARCH_QUERY_END = " ORDER BY jrf_message.intime DESC";
226
227     private static final String JavaDoc SEARCH_QUERY_SUFF = "SELECT TOP 50 jrf_thread.forumid, jrf_message.centents, jrf_message.sender, jrf_thread.threadid, jrf_message.intime, jrf_message.id, jrf_message.heading, jrf_forum.locked FROM jrf_message LEFT JOIN jrf_thread on jrf_message.threadid=jrf_thread.threadid LEFT JOIN jrf_forum ON jrf_thread.forumid=jrf_forum.forumid";
228
229     private static final String JavaDoc SEARCH_QUERY_SUFF_COUNT = "SELECT count(jrf_message.id),1 as intime FROM jrf_message LEFT JOIN jrf_thread on jrf_message.threadid=jrf_thread.threadid LEFT JOIN jrf_forum ON jrf_thread.forumid=jrf_forum.forumid";
230
231     private static final String JavaDoc GET_MESS_POS_BY_INTIME = "SELECT count(id) FROM jrf_message WHERE threadid=? AND intime<=? GROUP BY intime ORDER BY intime";
232 }
233
Popular Tags