package compbio.controllers; import java.util.Calendar; import java.util.Map; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.validation.BindingResult; import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.annotation.InitBinder; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import compbio.cassandra.DataBase; 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) { return "QueryTimeExecution"; } @RequestMapping(value = "/exectime/query", method = RequestMethod.GET) public String findSequence(@RequestParam("data1") String date1, @RequestParam("data2") String date2, @RequestParam(value="option", required=false) String option, Map model) { final long startTime = System.currentTimeMillis(); CassandraRequester sp = new CassandraRequester(); if (option.equals("AllDates")) { 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("data1", date1); model.put("data2", date2); model.put("result", sp.extractExecutionTime(date1, date2)); model.put("flag", option); final long endTime = System.currentTimeMillis(); model.put("timeExecution", (endTime - startTime)); return "/ReportTimeExecution"; } }