import compbio.engine.archive.ArchivedJob;
/**
+ * Spring controller for supporting job queries. This version works in the
+ * servlet style.
+ *
* @author Alexander Sherstnev
* @author Natasha Sherstneva
- * @version 1.0 Dec 2013
+ * @version 1.0
+ * @since Dec 2013
*/
@Controller
public class JobController extends BasicController {
/**
* form a report page for a job execution time statistics.
*
+ * @param date1
+ * initial date for requested statistics
+ * @param date2
+ * final date for requested statistics
+ * @param alldates
+ * All available jobs are analyzed if alldates="AllDates,off"
* @param model
* MVC model
* @return link to the JSP query page
*/
@RequestMapping(value = "/stat/exectime/results", method = RequestMethod.GET)
public String findExecTimeData(@RequestParam("date1") String date1, @RequestParam("date2") String date2,
- @RequestParam(value = "option", required = false) String option, Map<String, Object> model) {
+ @RequestParam(value = "option", required = false) String alldates, Map<String, Object> model) {
model.put("username", getPrincipalName());
final long startTime = System.currentTimeMillis();
Calendar loccal = Calendar.getInstance();
ExecutionTimeReader reader = new ExecutionTimeReader();
- if (option.equals("AllDates,off")) {
+ if (alldates.equals("AllDates,off")) {
date1 = theEaerlistDate;
date2 = theCurrentDate;
}
-
+
// dates in string format
String trimmeddate1 = date1.replaceAll("\\s", "");
String trimmeddate2 = date2.replaceAll("\\s", "");
model.put("date2", date2);
return "query/JobTimeExecution";
}
-
+
if (longDate1 < CassandraReader.earliestDate())
longDate1 = CassandraReader.earliestDate();
if (longDate2 > loccal.getTimeInMillis())
date2 = DateFormatter.DateLongToString(longDate2, formaterYYMMDD);
model.put("date1", date1);
model.put("date2", date2);
- model.put("option", option);
- ExecutionTimeBean res = reader.query(longDate1, longDate2);;
+ model.put("option", alldates);
+ ExecutionTimeBean res = reader.query(longDate1, longDate2);
+ ;
model.put("result", res);
Map<String, TotalExecutionTime> results = res.getDateTotal();
- String csvline = "";
+ StringBuilder csvline = new StringBuilder("");
if (0 < res.getDateTotal().size()) {
- csvline = "\'Date\',\'Total\',\'0-30 sec\',\'30-60 sec\',\'1-2 min\',\'2-10 min\',\'more 10 min\'%0A";
+ csvline.append("\'Date\',\'Total\',\'0-30 sec\',\'30-60 sec\',\'1-2 min\',\'2-10 min\',\'more 10 min\'%0A");
for (Map.Entry<String, TotalExecutionTime> entry : results.entrySet()) {
- csvline += "\'" + entry.getKey() + "\',\'" + entry.getValue().getTotal() + "\',\'" + entry.getValue().getTotal0_30s() + "\',\'"
- + entry.getValue().getTotal30_60s() + "\',\'" + entry.getValue().getTotal1_2m() + "\',\'"
- + entry.getValue().getTotal2_10m() + "\',\'" + entry.getValue().getTotal10m() + "\'%0A";
+ csvline.append("\'" + entry.getKey() + "\',\'" + entry.getValue().getTotal() + "\',\'" + entry.getValue().getTotal0_30s()
+ + "\',\'" + entry.getValue().getTotal30_60s() + "\',\'" + entry.getValue().getTotal1_2m() + "\',\'"
+ + entry.getValue().getTotal2_10m() + "\',\'" + entry.getValue().getTotal10m() + "\'%0A");
}
}
- model.put("csvfile", csvline);
+ model.put("csvfile", csvline.toString());
model.put("ndays", res.getDateTotal().size() - 1);
final long endTime = System.currentTimeMillis();
model.put("timeExecution", (endTime - startTime));
}
/**
- * form a query page for a job. The servlet should no be visible to users at
- * all.
+ * form result page for one job with a given job ID.
*
+ * @param jobid
+ * job ID
* @param model
* MVC model
+ *
* @return link to the JSP query page
* @throws IOException
*/
model.put("timeExecution", (endTime - startTime));
model.put("IdJob", jobid);
+ // prepare archive file for the job for downloading
ArchivedJob aj = new ArchivedJob(jobid);
try {
model.put("jobarchive", aj.prepareJobArchiveToWeb());