Merge branch 'DAO'
[proteocache.git] / server / compbio / controllers / DailyStatisticsController.java
index 75ab67a..403c220 100644 (file)
@@ -14,9 +14,11 @@ import compbio.engine.JobStatus;
 import compbio.beans.DateBean;
 import compbio.beans.TotalJobsStatisticBean;
 import compbio.cassandra.DateFormatter;
+
+import compbio.beans.Total;
 import compbio.cassandra.readers.CassandraReader;
 import compbio.cassandra.readers.DailyStatisticsReader;
-import compbio.cassandra.readers.ProteoDAO;
+
 
 /**
  * @author Alexander Sherstnev
@@ -61,8 +63,8 @@ public class DailyStatisticsController extends BasicController {
         *            the final date for the report (if option is set, date2 =
         *            today)
         * @param option
-        *            defined whether the whole time range of jobs is reported
-        *            (null means date1 and date2 are used)
+        *            defined whether the whole time range of jobs is reported (null
+        *            means date1 and date2 are used)
         * @return link to the report JSP page
         */
        @RequestMapping(value = "/stat/jobsdaily/results", method = RequestMethod.GET)
@@ -102,6 +104,14 @@ public class DailyStatisticsController extends BasicController {
                model.put("date2", date2);
                TotalJobsStatisticBean res = reader.query(longDate1, longDate2);
                model.put("result", res);
+               Map<String, Total> results = res.getDateTotal();
+               String csvline = "\'Date\',\'Total\',\'OK\',\'Stopped\',\'Error\',\'Timeout\'%0A";
+               for (Map.Entry<String, Total> entry : results.entrySet()) {
+                       csvline += "\'" + entry.getKey() + "\',\'" + entry.getValue().getTotal() + "\',\'" + entry.getValue().getTotalOK() + "\',\'"
+                                       + entry.getValue().getTotalStopped() + "\',\'" + entry.getValue().getTotalError() + "\',\'"
+                                       + entry.getValue().getTotalTimeOut() + "\'%0A";
+               }
+               model.put("csvfile", csvline);
                model.put("ndays", res.getDateTotal().size());
                final long endTime = System.currentTimeMillis();
                model.put("timeExecution", (endTime - startTime));