Add the "Reload" and "CSV" buttons
[proteocache.git] / server / compbio / controllers / DailyStatisticsController.java
index 72ece7e..a9b51f1 100644 (file)
@@ -14,6 +14,7 @@ import compbio.engine.JobStatus;
 import compbio.cassandra.CassandraReader;
 import compbio.cassandra.DateBean;
 import compbio.cassandra.DateFormatter;
+import compbio.cassandra.Total;
 import compbio.cassandra.TotalJobsStatisticBean;
 import compbio.statistic.CassandraRequester;
 
@@ -60,8 +61,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)
@@ -101,6 +102,14 @@ public class DailyStatisticsController extends BasicController {
                model.put("date2", date2);
                TotalJobsStatisticBean res = cr.countJobs(date1, date2);
                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));