X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=server%2Fcompbio%2Fcontrollers%2FJobController.java;h=49a12adae96e5b46c67728fc48de5867a9e3e2f6;hb=6823d2f36ff55b7ab11d674e3fe4d04dc57d6bbf;hp=a2b952cd92be0ea0a3c040631e7ff7e90a5b8d66;hpb=daa7e16fa1815c285bf465b69c8aa1a4ae36c0b9;p=proteocache.git diff --git a/server/compbio/controllers/JobController.java b/server/compbio/controllers/JobController.java index a2b952c..49a12ad 100644 --- a/server/compbio/controllers/JobController.java +++ b/server/compbio/controllers/JobController.java @@ -7,6 +7,7 @@ import java.util.Date; import java.util.List; import java.util.Map; +import org.apache.log4j.Logger; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @@ -14,6 +15,7 @@ import org.springframework.web.bind.annotation.RequestParam; import compbio.statistic.CassandraRequester; import compbio.cassandra.DataBase; +import compbio.cassandra.readers.JobReader; import compbio.engine.archive.ArchivedJob; /** @@ -23,11 +25,12 @@ import compbio.engine.archive.ArchivedJob; */ @Controller public class JobController extends BasicController { + private static Logger log = Logger.getLogger(JobController.class); /** - * form a query page for job execution time statistics. The servlet should be - * available for users and admins only. By defaults the report time range is - * from the earliest day with jobs to today ("Query for all dates" is + * form a query page for job execution time statistics. The servlet should + * be available for users and admins only. By defaults the report time range + * is from the earliest day with jobs to today ("Query for all dates" is * ticked). If the user removes the tick the time range is from today - 3 * days to today. Currently, the input model is empty. * @@ -49,7 +52,8 @@ public class JobController extends BasicController { } /** - * form a query page for a job. The servlet should no be visible to users at all. + * form a query page for a job. The servlet should no be visible to users at + * all. * * @param model * MVC model @@ -58,10 +62,18 @@ public class JobController extends BasicController { @RequestMapping(value = "/job/query", method = RequestMethod.GET) public String initFindForm(Map model) { model.put("username", getPrincipalName()); - model.put("value", "jp_NzBOJKo"); + CassandraRequester cr = new CassandraRequester(); + model.put("value", cr.getExample("jobid")); return "query/JobLog"; } + /** + * form a report page for a job execution time statistics. + * + * @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 model) { @@ -79,18 +91,43 @@ public class JobController extends BasicController { model.put("option", option); List 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 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)); return "/reportTimeExecution"; } + /** + * form a query page for a job. The servlet should no be visible to users at + * all. + * + * @param model + * MVC model + * @return link to the JSP query page + */ @RequestMapping(value = "/job/results", method = RequestMethod.GET) public String findJob(@RequestParam("IdJob") String jobid, Map model) { model.put("username", getPrincipalName()); final long startTime = System.currentTimeMillis(); - CassandraRequester cr = new CassandraRequester(); - model.put("result", cr.readJobLog(jobid)); + JobReader reader = new JobReader(); + model.put("result", reader.readJobLog(jobid)); final long endTime = System.currentTimeMillis(); model.put("timeExecution", (endTime - startTime)); model.put("IdJob", jobid); @@ -99,13 +136,19 @@ public class JobController extends BasicController { try { model.put("jobarchive", aj.prepareJobArchiveToWeb()); } catch (IOException e) { - //TODO. what should we do if job is not available??? + log.error("JobController.prepareJobArchiveToWeb: IO exception with job archive file"); + log.error(e.getLocalizedMessage(), e.getCause()); } return "reportJobLog"; } - /* - * convert ??? + /** + * convert date from the standard long representation (milliseconds from 1 + * Jan 1970) to yyyy/mm/dd + * + * @param indate + * date in milliseconds from 1 Jan 1970 + * @return date in the form of yyyy/mm/dd */ private String DateFormatYYMMDD(long indate) { SimpleDateFormat datformat = new SimpleDateFormat("yyyy/MM/dd");