Add the "Reload" and "CSV" buttons
[proteocache.git] / server / compbio / controllers / JobController.java
index 4819e75..254fdc2 100644 (file)
@@ -14,7 +14,6 @@ import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RequestParam;
 
 import compbio.statistic.CassandraRequester;
-import compbio.cassandra.CassandraNativeConnector;
 import compbio.cassandra.DataBase;
 import compbio.engine.archive.ArchivedJob;
 
@@ -91,6 +90,23 @@ public class JobController extends BasicController {
                model.put("option", option);
                List<DataBase> res = sp.extractExecutionTime(date1, date2);
                model.put("result", res);
+               String csvline = "";
+               if (0 < res.size()) {
+                       csvline = "\'Date\',\'Total\',\'0-30 sec\',\'30-60 sec\',\'1-2 min\',\'2-10 min\',\'more 10 min\'%0A";
+                       for (DataBase entry : res) {
+                               List<Integer> counts = entry.getTimeRez();
+                               int total = 0;
+                               for (int i = 0; i < counts.size(); ++i) {
+                                       total += counts.get(i);
+                               }
+                               csvline += "\'" + entry.getDate() + "\',\'" + total;
+                               for (int i = 0; i < counts.size(); ++i) {
+                                       csvline += "\',\'" + counts.get(i);
+                               }
+                               csvline += "\'%0A";
+                       }
+               }
+               model.put("csvfile", csvline);
                model.put("ndays", res.size() - 1);
                final long endTime = System.currentTimeMillis();
                model.put("timeExecution", (endTime - startTime));
@@ -131,8 +147,7 @@ public class JobController extends BasicController {
         * 
         * @param indate
         *            date in milliseconds from 1 Jan 1970
-        * @return date 
-        *            in the form of yyyy/mm/dd
+        * @return date in the form of yyyy/mm/dd
         */
        private String DateFormatYYMMDD(long indate) {
                SimpleDateFormat datformat = new SimpleDateFormat("yyyy/MM/dd");