1 package compbio.stat.collector;
\r
3 import java.sql.SQLException;
\r
4 import java.sql.Timestamp;
\r
5 import java.util.Calendar;
\r
6 import java.util.Date;
\r
7 import java.util.GregorianCalendar;
\r
8 import java.util.Iterator;
\r
9 import java.util.Map;
\r
10 import java.util.TreeMap;
\r
12 import compbio.ws.client.Services;
\r
14 public class StatManager {
\r
16 static class DateRoller implements Iterator<Date> {
\r
17 final Date initDate;
\r
18 final Calendar calendar;
\r
20 public DateRoller(Date date) {
\r
21 this.initDate = date;
\r
22 calendar = GregorianCalendar.getInstance();
\r
23 calendar.setTime(date);
\r
24 calendar.add(Calendar.MONTH, -12);
\r
27 Date getCurrentDate() {
\r
32 public boolean hasNext() {
\r
33 return !calendar.getTime().equals(initDate);
\r
37 public Date next() {
\r
38 calendar.add(Calendar.MONTH, 1);
\r
39 return calendar.getTime();
\r
43 public void remove() {
\r
44 throw new UnsupportedOperationException();
\r
49 void getStats() throws SQLException {
\r
50 Calendar startTime = Calendar.getInstance();
\r
51 startTime.roll(Calendar.YEAR, false);
\r
52 Timestamp startDate = new Timestamp(startTime.getTimeInMillis());
\r
53 Timestamp stopDate = new Timestamp(new Date().getTime());
\r
54 StatDB statdb = null;
\r
56 statdb = new StatDB();
\r
59 Map<Services, StatProcessor> stats = new TreeMap<Services, StatProcessor>();
\r
60 for (Services service : Services.values()) {
\r
63 new StatProcessor(statdb.readData(startDate, stopDate,
\r
68 Map<Services, StatProcessor> statsCluster = new TreeMap<Services, StatProcessor>();
\r
69 for (Services service : Services.values()) {
\r
72 new StatProcessor(statdb.readData(startDate, stopDate,
\r
76 Map<Services, StatProcessor> statsLocal = new TreeMap<Services, StatProcessor>();
\r
77 for (Services service : Services.values()) {
\r
80 new StatProcessor(statdb.readData(startDate, stopDate,
\r