package compbio.controllers; import java.util.Calendar; import java.util.Map; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import compbio.statistic.CassandraRequester; import compbio.statistic.StatisticsProt; /** * @author Alexander Sherstnev * @author Natasha Sherstneva */ @Controller public class JobExecutionTimeController { @RequestMapping(value = "/exectime", method = RequestMethod.GET) public String initFindForm(Map model) { Calendar cal = Calendar.getInstance(); String date2 = cal.get(Calendar.YEAR) + "/" + (cal.get(Calendar.MONTH) + 1) + "/" + cal.get(Calendar.DATE); cal.add(Calendar.DATE, -3); String date1 = cal.get(Calendar.YEAR) + "/" + (cal.get(Calendar.MONTH) + 1) + "/" + cal.get(Calendar.DATE); model.put("date1", date1); model.put("date2", date2); return "queryTimeExecution"; } @RequestMapping(value = "/exectime/query", method = RequestMethod.GET) public String findSequence(@RequestParam("date1") String date1, @RequestParam("date2") String date2, @RequestParam(value="option", required=false) String option, Map model) { final long startTime = System.currentTimeMillis(); CassandraRequester sp = new CassandraRequester(); if (option.equals("AllDates,off")) { Calendar cal = Calendar.getInstance(); date1 = StatisticsProt.DateFormatYYMMDD(sp.earliestDate()); date2 = cal.get(Calendar.YEAR) + "/" + (cal.get(Calendar.MONTH) + 1) + "/" + cal.get(Calendar.DAY_OF_MONTH); } model.put("date1", date1); model.put("date2", date2); model.put("option", option); model.put("result", sp.extractExecutionTime(date1, date2)); final long endTime = System.currentTimeMillis(); model.put("timeExecution", (endTime - startTime)); return "/reportTimeExecution"; } }