1 package compbio.stat.servlet;
\r
3 import java.io.IOException;
\r
4 import java.sql.SQLException;
\r
5 import java.sql.Timestamp;
\r
6 import java.util.Calendar;
\r
7 import java.util.Date;
\r
8 import java.util.Map;
\r
9 import java.util.TreeMap;
\r
11 import javax.servlet.RequestDispatcher;
\r
12 import javax.servlet.ServletException;
\r
13 import javax.servlet.http.HttpServlet;
\r
14 import javax.servlet.http.HttpServletRequest;
\r
15 import javax.servlet.http.HttpServletResponse;
\r
17 import compbio.stat.collector.StatDB;
\r
18 import compbio.stat.collector.StatProcessor;
\r
19 import compbio.ws.client.Services;
\r
21 public class YearStat extends HttpServlet {
\r
24 protected void doGet(HttpServletRequest req, HttpServletResponse resp)
\r
25 throws ServletException, IOException {
\r
27 Calendar startTime = Calendar.getInstance();
\r
28 startTime.roll(Calendar.YEAR, false);
\r
29 Timestamp startDate = new Timestamp(startTime.getTimeInMillis());
\r
30 Timestamp stopDate = new Timestamp(new Date().getTime());
\r
31 StatDB statdb = null;
\r
33 statdb = new StatDB();
\r
35 Map<Services, StatProcessor> stats = new TreeMap<Services, StatProcessor>();
\r
36 for (Services service : Services.values()) {
\r
39 new StatProcessor(statdb.readData(startDate, stopDate,
\r
43 Map<Services, StatProcessor> statsCluster = new TreeMap<Services, StatProcessor>();
\r
44 for (Services service : Services.values()) {
\r
47 new StatProcessor(statdb.readData(startDate, stopDate,
\r
51 Map<Services, StatProcessor> statsLocal = new TreeMap<Services, StatProcessor>();
\r
52 for (Services service : Services.values()) {
\r
55 new StatProcessor(statdb.readData(startDate, stopDate,
\r
58 req.setAttribute("stat", stats);
\r
59 req.setAttribute("statTotal", Totals.sumStats(stats));
\r
61 req.setAttribute("statCluster", statsCluster);
\r
62 req.setAttribute("statLocal", statsLocal);
\r
63 req.setAttribute("startDate", startDate.getTime());
\r
64 req.setAttribute("stopDate", stopDate.getTime());
\r
66 RequestDispatcher dispatcher = req
\r
67 .getRequestDispatcher("statpages/Statistics.jsp");
\r
68 dispatcher.forward(req, resp);
\r
70 } catch (SQLException e) {
\r
71 // TODO Auto-generated catch block
\r
72 e.printStackTrace();
\r