return localStat;\r
}\r
\r
- public static Map<Date, StatCollection> getStats(int monthsToReport)\r
+ public static Map<Date, Totals> getStats(int monthsToReport)\r
throws SQLException {\r
Calendar fromCal = GregorianCalendar.getInstance();\r
fromCal.add(Calendar.MONTH, -monthsToReport);\r
return getStats(fromCal.getTime());\r
}\r
\r
- public static Map<Date, StatCollection> getStats(Date fromDate)\r
- throws SQLException {\r
- Map<Date, StatCollection> allstats = new TreeMap<Date, StatCollection>();\r
+ public static Map<Date, Totals> getStats(Date fromDate) throws SQLException {\r
+ Map<Date, Totals> allstats = new TreeMap<Date, Totals>();\r
\r
Calendar fromCal = GregorianCalendar.getInstance();\r
fromCal.setTime(fromDate);\r
\r
Calendar toCal = GregorianCalendar.getInstance();\r
toCal.setTime(new Date());\r
-\r
if (fromCal.after(toCal)) {\r
throw new AssertionError("From Date must be before ToDate! ");\r
}\r
-\r
- while (true) {\r
+ while (fromCal.before(toCal)) {\r
Date from = fromCal.getTime();\r
fromCal.add(Calendar.MONTH, 1);\r
- if (toCal.before(fromCal)) {\r
- allstats.put(toCal.getTime(),\r
- StatCollection.newStatCollecton(from, toCal.getTime()));\r
- break;\r
- }\r
- // System.out.println("!" + from + " !!! " + fromCal.getTime());\r
- allstats.put(from,\r
- StatCollection.newStatCollecton(from, fromCal.getTime()));\r
+ allstats.put(from, getJobCounts(from, fromCal.getTime()));\r
}\r
return allstats;\r
}\r
- public static Map<Date, Totals> getTotalStats(\r
- Map<Date, StatCollection> detailedStats) {\r
- Map<Date, Totals> totals = new TreeMap<Date, Totals>();\r
- for (Map.Entry<Date, StatCollection> stat : detailedStats.entrySet()) {\r
- totals.put(stat.getKey(), Totals.sumStats(stat.getValue().allStat));\r
- }\r
- return totals;\r
+\r
+ private static Totals getJobCounts(Date from, Date to) throws SQLException {\r
+ StatDB db = new StatDB();\r
+ Totals t = new Totals();\r
+ Timestamp fromTime = new Timestamp(from.getTime());\r
+ Timestamp toTime = new Timestamp(to.getTime());\r
+ t.total = db.getTotalJobsCount(fromTime, toTime);\r
+ t.incomplete = db.getIncompleteCount(fromTime, toTime);\r
+ t.abandoned = db.getAbandonedCount(fromTime, toTime);\r
+ t.cancelled = db.getCancelledCount(fromTime, toTime);\r
+ return t;\r
}\r
\r
- static StatCollection newStatCollecton(Date startDate, Date endDate)\r
+ public static StatCollection newStatCollecton(Date startDate, Date endDate)\r
throws SQLException {\r
\r
Timestamp startStamp = new Timestamp(startDate.getTime());\r