KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jresearch > gossip > forms > SearchLogForm


1 /*
2  * $$Id: SearchLogForm.java,v 1.3 2005/06/07 12:32:17 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  * Dmitry Belov <bel@jresearch.org>
23  *
24  * ***** END LICENSE BLOCK ***** */

25 /*
26  * Created on 13.08.2004
27  *
28  */

29 package org.jresearch.gossip.forms;
30
31 import java.util.Calendar JavaDoc;
32 import java.util.Date JavaDoc;
33 import java.util.TimeZone JavaDoc;
34
35 import javax.servlet.http.HttpServletRequest JavaDoc;
36
37 import org.apache.struts.action.ActionMapping;
38 import org.jresearch.gossip.IConst;
39 import org.jresearch.gossip.beans.LogSearchCriteria;
40
41 /**
42  * @author dbelov
43  *
44  */

45 public class SearchLogForm extends ListForm {
46
47     private String JavaDoc from_d;
48
49     private String JavaDoc from_M;
50
51     private String JavaDoc from_y;
52
53     private String JavaDoc from_H;
54
55     private String JavaDoc from_m;
56
57     private String JavaDoc to_d;
58
59     private String JavaDoc to_M;
60
61     private String JavaDoc to_y;
62
63     private String JavaDoc to_H;
64
65     private String JavaDoc to_m;
66
67     private String JavaDoc logger;
68
69     private String JavaDoc log_level;
70
71     private String JavaDoc remote_ip;
72
73     private String JavaDoc user_name;
74
75     private String JavaDoc session_id;
76
77     private TimeZone JavaDoc tzone = TimeZone.getTimeZone(IConst.VALUES.GMT);
78
79     /**
80      *
81      */

82     public SearchLogForm() {
83         setFields();
84     }
85
86     /**
87      *
88      */

89     private void setFields() {
90
91         Calendar JavaDoc cl = Calendar.getInstance(this.tzone);
92         cl.setTime(new Date JavaDoc(0));
93
94         this.from_d = Integer.toString(cl.get(Calendar.DATE));
95         this.from_M = Integer.toString(cl.get(Calendar.MONTH));
96         this.from_y = Integer.toString(cl.get(Calendar.YEAR));
97         this.from_H = Integer.toString(cl.get(Calendar.HOUR_OF_DAY));
98         this.from_m = Integer.toString(cl.get(Calendar.MINUTE));
99
100         cl = Calendar.getInstance(this.tzone);
101
102         this.to_d = Integer.toString(cl.get(Calendar.DATE));
103         this.to_M = Integer.toString(cl.get(Calendar.MONTH));
104         this.to_y = Integer.toString(cl.get(Calendar.YEAR));
105         this.to_H = Integer.toString(cl.get(Calendar.HOUR_OF_DAY));
106         this.to_m = Integer.toString(cl.get(Calendar.MINUTE));
107
108         this.logger = "";
109         this.log_level = "";
110         this.remote_ip = "";
111         this.user_name = "";
112         this.session_id = "";
113         super.setBlock("0");
114
115     }
116
117     /**
118      * Reset all properties to their default values.
119      *
120      * @param mapping
121      * The mapping used to select this instance
122      * @param request
123      * The servlet request we are processing
124      */

125     public void reset(ActionMapping mapping, HttpServletRequest JavaDoc request) {
126         this.tzone = TimeZone.getTimeZone((String JavaDoc) request.getSession()
127                 .getAttribute(IConst.SESSION.TIME_ZONE));
128         setFields();
129     }
130
131     /**
132      * @return
133      */

134     public LogSearchCriteria getSearchCriteria() {
135         return new LogSearchCriteria(getFrom(), getTo(),
136                 logger.equals("") ? IConst.VALUES.ALL : logger.trim(),
137                 log_level.equals("") ? IConst.VALUES.ALL : log_level.trim(),
138                 remote_ip.equals("") ? IConst.VALUES.ALL : remote_ip.trim(),
139                 user_name.equals("") ? IConst.VALUES.ALL : user_name.trim(),
140                 session_id.equals("") ? IConst.VALUES.ALL : session_id.trim(),
141                 true);
142     }
143
144     /**
145      * @return Returns the from_d.
146      */

147     public String JavaDoc getFrom_d() {
148         return this.from_d;
149     }
150
151     /**
152      * @param from_d
153      * The from_d to set.
154      */

155     public void setFrom_d(String JavaDoc from_d) {
156         this.from_d = from_d;
157     }
158
159     /**
160      * @return Returns the from_H.
161      */

162     public String JavaDoc getFrom_H() {
163         return from_H;
164     }
165
166     /**
167      * @param from_H
168      * The from_H to set.
169      */

170     public void setFrom_H(String JavaDoc from_H) {
171         this.from_H = from_H;
172     }
173
174     /**
175      * @return Returns the from_m.
176      */

177     public String JavaDoc getFrom_m() {
178         return from_m;
179     }
180
181     /**
182      * @param from_m
183      * The from_m to set.
184      */

185     public void setFrom_m(String JavaDoc from_m) {
186         this.from_m = from_m;
187     }
188
189     /**
190      * @return Returns the from_M.
191      */

192     public String JavaDoc getFrom_M() {
193         return from_M;
194     }
195
196     /**
197      * @param from_M
198      * The from_M to set.
199      */

200     public void setFrom_M(String JavaDoc from_M) {
201         this.from_M = from_M;
202     }
203
204     /**
205      * @return Returns the from_y.
206      */

207     public String JavaDoc getFrom_y() {
208         return from_y;
209     }
210
211     /**
212      * @param from_y
213      * The from_y to set.
214      */

215     public void setFrom_y(String JavaDoc from_y) {
216         this.from_y = from_y;
217     }
218
219     /**
220      * @return Returns the to_d.
221      */

222     public String JavaDoc getTo_d() {
223         return to_d;
224     }
225
226     /**
227      * @param to_d
228      * The to_d to set.
229      */

230     public void setTo_d(String JavaDoc to_d) {
231         this.to_d = to_d;
232     }
233
234     /**
235      * @return Returns the to_H.
236      */

237     public String JavaDoc getTo_H() {
238         return to_H;
239     }
240
241     /**
242      * @param to_H
243      * The to_H to set.
244      */

245     public void setTo_H(String JavaDoc to_H) {
246         this.to_H = to_H;
247     }
248
249     /**
250      * @return Returns the to_m.
251      */

252     public String JavaDoc getTo_m() {
253         return to_m;
254     }
255
256     /**
257      * @param to_m
258      * The to_m to set.
259      */

260     public void setTo_m(String JavaDoc to_m) {
261         this.to_m = to_m;
262     }
263
264     /**
265      * @return Returns the to_M.
266      */

267     public String JavaDoc getTo_M() {
268         return to_M;
269     }
270
271     /**
272      * @param to_M
273      * The to_M to set.
274      */

275     public void setTo_M(String JavaDoc to_M) {
276         this.to_M = to_M;
277     }
278
279     /**
280      * @return Returns the to_y.
281      */

282     public String JavaDoc getTo_y() {
283         return to_y;
284     }
285
286     /**
287      * @param to_y
288      * The to_y to set.
289      */

290     public void setTo_y(String JavaDoc to_y) {
291         this.to_y = to_y;
292     }
293
294     /**
295      * @return Returns the from.
296      */

297     public Date JavaDoc getFrom() {
298         Calendar JavaDoc cl = Calendar.getInstance(this.tzone);
299         cl.set(Calendar.DATE, Integer.parseInt(this.from_d));
300         cl.set(Calendar.MONTH, Integer.parseInt(this.from_M));
301         cl.set(Calendar.YEAR, Integer.parseInt(this.from_y));
302         cl.set(Calendar.HOUR_OF_DAY, Integer.parseInt(this.from_H));
303         cl.set(Calendar.MINUTE, Integer.parseInt(this.from_m));
304         return cl.getTime();
305     }
306
307     /**
308      * @return Returns the log_level.
309      */

310     public String JavaDoc getLog_level() {
311         return log_level;
312     }
313
314     /**
315      * @param log_level
316      * The log_level to set.
317      */

318     public void setLog_level(String JavaDoc log_level) {
319         this.log_level = log_level;
320     }
321
322     /**
323      * @return Returns the logger.
324      */

325     public String JavaDoc getLogger() {
326         return logger;
327     }
328
329     /**
330      * @param logger
331      * The logger to set.
332      */

333     public void setLogger(String JavaDoc logger) {
334         this.logger = logger;
335     }
336
337     /**
338      * @return Returns the remote_ip.
339      */

340     public String JavaDoc getRemote_ip() {
341         return remote_ip;
342     }
343
344     /**
345      * @param remote_ip
346      * The remote_ip to set.
347      */

348     public void setRemote_ip(String JavaDoc remote_ip) {
349         this.remote_ip = remote_ip;
350     }
351
352     /**
353      * @return Returns the session_id.
354      */

355     public String JavaDoc getSession_id() {
356         return session_id;
357     }
358
359     /**
360      * @param session_id
361      * The session_id to set.
362      */

363     public void setSession_id(String JavaDoc session_id) {
364         this.session_id = session_id;
365     }
366
367     /**
368      * @return Returns the to.
369      */

370     public Date JavaDoc getTo() {
371         Calendar JavaDoc cl = Calendar.getInstance(this.tzone);
372         cl.set(Calendar.DATE, Integer.parseInt(this.to_d));
373         cl.set(Calendar.MONTH, Integer.parseInt(this.to_M));
374         cl.set(Calendar.YEAR, Integer.parseInt(this.to_y));
375         cl.set(Calendar.HOUR_OF_DAY, Integer.parseInt(this.to_H));
376         cl.set(Calendar.MINUTE, Integer.parseInt(this.to_m));
377         return cl.getTime();
378     }
379
380     /**
381      * @return Returns the user_name.
382      */

383     public String JavaDoc getUser_name() {
384         return user_name;
385     }
386
387     /**
388      * @param user_name
389      * The user_name to set.
390      */

391     public void setUser_name(String JavaDoc user_name) {
392         this.user_name = user_name;
393     }
394 }
Popular Tags