X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=server%2Fcompbio%2Fcontrollers%2FJobController.java;h=a2b952cd92be0ea0a3c040631e7ff7e90a5b8d66;hb=daa7e16fa1815c285bf465b69c8aa1a4ae36c0b9;hp=94045f96e130737bd5769928b7d3e57bdc2a6436;hpb=025c55d49c191f24d0e06c5cbb69a9894c50af22;p=proteocache.git diff --git a/server/compbio/controllers/JobController.java b/server/compbio/controllers/JobController.java index 94045f9..a2b952c 100644 --- a/server/compbio/controllers/JobController.java +++ b/server/compbio/controllers/JobController.java @@ -1,7 +1,9 @@ package compbio.controllers; -import java.security.Principal; +import java.io.IOException; +import java.text.SimpleDateFormat; import java.util.Calendar; +import java.util.Date; import java.util.List; import java.util.Map; @@ -12,15 +14,27 @@ import org.springframework.web.bind.annotation.RequestParam; import compbio.statistic.CassandraRequester; import compbio.cassandra.DataBase; -import compbio.statistic.StatisticsProt; +import compbio.engine.archive.ArchivedJob; /** * @author Alexander Sherstnev * @author Natasha Sherstneva + * @version 1.0 Dec 2013 */ @Controller public class JobController extends BasicController { + /** + * 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. + * + * @param model + * MVC model + * @return link to the JSP query page + */ @RequestMapping(value = "/stat/exectime/query", method = RequestMethod.GET) public String initFormExecTime(Map model) { model.put("username", getPrincipalName()); @@ -34,6 +48,13 @@ public class JobController extends BasicController { return "query/JobTimeExecution"; } + /** + * 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/query", method = RequestMethod.GET) public String initFindForm(Map model) { model.put("username", getPrincipalName()); @@ -50,7 +71,7 @@ public class JobController extends BasicController { CassandraRequester sp = new CassandraRequester(); if (option.equals("AllDates,off")) { Calendar cal = Calendar.getInstance(); - date1 = StatisticsProt.DateFormatYYMMDD(sp.earliestDate()); + date1 = DateFormatYYMMDD(sp.earliestDate()); date2 = cal.get(Calendar.YEAR) + "/" + (cal.get(Calendar.MONTH) + 1) + "/" + cal.get(Calendar.DAY_OF_MONTH); } model.put("date1", date1); @@ -73,7 +94,23 @@ public class JobController extends BasicController { final long endTime = System.currentTimeMillis(); model.put("timeExecution", (endTime - startTime)); model.put("IdJob", jobid); + + ArchivedJob aj = new ArchivedJob(jobid); + try { + model.put("jobarchive", aj.prepareJobArchiveToWeb()); + } catch (IOException e) { + //TODO. what should we do if job is not available??? + } return "reportJobLog"; } - + + /* + * convert ??? + */ + private String DateFormatYYMMDD(long indate) { + SimpleDateFormat datformat = new SimpleDateFormat("yyyy/MM/dd"); + String dateString = datformat.format(new Date(indate)); + return dateString; + } + }