1 25 29 package org.jresearch.gossip.forms; 30 31 import java.util.Calendar ; 32 import java.util.Date ; 33 import java.util.TimeZone ; 34 35 import javax.servlet.http.HttpServletRequest ; 36 37 import org.apache.struts.action.ActionMapping; 38 import org.jresearch.gossip.IConst; 39 import org.jresearch.gossip.beans.LogSearchCriteria; 40 41 45 public class SearchLogForm extends ListForm { 46 47 private String from_d; 48 49 private String from_M; 50 51 private String from_y; 52 53 private String from_H; 54 55 private String from_m; 56 57 private String to_d; 58 59 private String to_M; 60 61 private String to_y; 62 63 private String to_H; 64 65 private String to_m; 66 67 private String logger; 68 69 private String log_level; 70 71 private String remote_ip; 72 73 private String user_name; 74 75 private String session_id; 76 77 private TimeZone tzone = TimeZone.getTimeZone(IConst.VALUES.GMT); 78 79 82 public SearchLogForm() { 83 setFields(); 84 } 85 86 89 private void setFields() { 90 91 Calendar cl = Calendar.getInstance(this.tzone); 92 cl.setTime(new Date (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 125 public void reset(ActionMapping mapping, HttpServletRequest request) { 126 this.tzone = TimeZone.getTimeZone((String ) request.getSession() 127 .getAttribute(IConst.SESSION.TIME_ZONE)); 128 setFields(); 129 } 130 131 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 147 public String getFrom_d() { 148 return this.from_d; 149 } 150 151 155 public void setFrom_d(String from_d) { 156 this.from_d = from_d; 157 } 158 159 162 public String getFrom_H() { 163 return from_H; 164 } 165 166 170 public void setFrom_H(String from_H) { 171 this.from_H = from_H; 172 } 173 174 177 public String getFrom_m() { 178 return from_m; 179 } 180 181 185 public void setFrom_m(String from_m) { 186 this.from_m = from_m; 187 } 188 189 192 public String getFrom_M() { 193 return from_M; 194 } 195 196 200 public void setFrom_M(String from_M) { 201 this.from_M = from_M; 202 } 203 204 207 public String getFrom_y() { 208 return from_y; 209 } 210 211 215 public void setFrom_y(String from_y) { 216 this.from_y = from_y; 217 } 218 219 222 public String getTo_d() { 223 return to_d; 224 } 225 226 230 public void setTo_d(String to_d) { 231 this.to_d = to_d; 232 } 233 234 237 public String getTo_H() { 238 return to_H; 239 } 240 241 245 public void setTo_H(String to_H) { 246 this.to_H = to_H; 247 } 248 249 252 public String getTo_m() { 253 return to_m; 254 } 255 256 260 public void setTo_m(String to_m) { 261 this.to_m = to_m; 262 } 263 264 267 public String getTo_M() { 268 return to_M; 269 } 270 271 275 public void setTo_M(String to_M) { 276 this.to_M = to_M; 277 } 278 279 282 public String getTo_y() { 283 return to_y; 284 } 285 286 290 public void setTo_y(String to_y) { 291 this.to_y = to_y; 292 } 293 294 297 public Date getFrom() { 298 Calendar 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 310 public String getLog_level() { 311 return log_level; 312 } 313 314 318 public void setLog_level(String log_level) { 319 this.log_level = log_level; 320 } 321 322 325 public String getLogger() { 326 return logger; 327 } 328 329 333 public void setLogger(String logger) { 334 this.logger = logger; 335 } 336 337 340 public String getRemote_ip() { 341 return remote_ip; 342 } 343 344 348 public void setRemote_ip(String remote_ip) { 349 this.remote_ip = remote_ip; 350 } 351 352 355 public String getSession_id() { 356 return session_id; 357 } 358 359 363 public void setSession_id(String session_id) { 364 this.session_id = session_id; 365 } 366 367 370 public Date getTo() { 371 Calendar 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 383 public String getUser_name() { 384 return user_name; 385 } 386 387 391 public void setUser_name(String user_name) { 392 this.user_name = user_name; 393 } 394 } | Popular Tags |