From: Sasha Sherstnev Date: Thu, 19 Dec 2013 12:42:04 +0000 (+0000) Subject: Merge branch 'master' into servlets X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=5a44c7fd7f9802f255bf43489ff325af2df5eb94;p=proteocache.git Merge branch 'master' into servlets Conflicts: server/compbio/controllers/DailyStatisticsController.java server/compbio/controllers/JobExecutionTimeController.java server/compbio/controllers/SequenceController.java server/compbio/listeners/ServletJobsByDate.java server/compbio/listeners/ServletTimeExecution.java server/compbio/statistic/CassandraRequester.java --- 5a44c7fd7f9802f255bf43489ff325af2df5eb94 diff --cc server/compbio/controllers/DailyStatisticsController.java index b6d5bde,ef399f5..d6a0c1e --- a/server/compbio/controllers/DailyStatisticsController.java +++ b/server/compbio/controllers/DailyStatisticsController.java @@@ -12,41 -11,69 +11,45 @@@ import org.springframework.web.bind.ann import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; + import compbio.engine.JobStatus; -import compbio.cassandra.CassandraReader; import compbio.cassandra.DateBean; -import compbio.cassandra.DateFormatter; import compbio.cassandra.TotalJobsStatisticBean; import compbio.statistic.CassandraRequester; - ++import compbio.statistic.StatisticsProt; /** * @author Alexander Sherstnev * @author Natasha Sherstneva */ @Controller - public class DailyStatisticsController { + public class DailyStatisticsController extends BasicController { - Calendar cal = Calendar.getInstance(); - final SimpleDateFormat formaterDDMMYY = DateFormatter.getFormatDDMMYY(); - final SimpleDateFormat formaterYYMMDD = DateFormatter.getFormatYYMMDD(); - String theEaerlistDate = DateFormatter.DateLongToString(CassandraReader.earliestDate(), formaterYYMMDD); - String theCurrentDate = cal.get(Calendar.YEAR) + "/" + (cal.get(Calendar.MONTH) + 1) + "/" + cal.get(Calendar.DAY_OF_MONTH); - + - @RequestMapping(value = "/stat", method = RequestMethod.GET) + @RequestMapping(value = "/stat/jobs/query", method = RequestMethod.GET) public String initFindForm(Map model) { + model.put("username", getPrincipalName()); + 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 "queryJobStatistics"; + return "query/JobStatistics"; } - @RequestMapping(value = "/stat/query", method = RequestMethod.GET) + @RequestMapping(value = "/stat/jobsdaily/results", method = RequestMethod.GET) public String findJobsInPeriod(@RequestParam("date1") String date1, @RequestParam("date2") String date2, @RequestParam("option") String option, Map model) { + model.put("username", getPrincipalName()); - final long startTime = System.currentTimeMillis(); + final long startTime = System.currentTimeMillis(); + CassandraRequester cr = new CassandraRequester(); if (option.equals("AllDates,off")) { - date1 = theEaerlistDate; - date2 = theCurrentDate; - } - - // dates in string format - String trimmeddate1 = date1.replaceAll("\\s", ""); - String trimmeddate2 = date2.replaceAll("\\s", ""); - // dates in long format - long longDate1 = DateFormatter.DateParsing(date1,formaterYYMMDD); - long longDate2 = DateFormatter.DateParsing(date2, formaterYYMMDD); - String error = DateChecking(trimmeddate1, trimmeddate2, longDate1, longDate2); - if (error != null) { - model.put("error", error); - model.put("date1", date1); - model.put("date2", date2); - return "query/JobStatistics"; + Calendar cal = Calendar.getInstance(); - date1 = cr.earliestDateString(); ++ date1 = StatisticsProt.DateFormatYYMMDD(cr.earliestDate()); + date2 = cal.get(Calendar.YEAR) + "/" + (cal.get(Calendar.MONTH) + 1) + "/" + cal.get(Calendar.DAY_OF_MONTH); } - - if (longDate1 < CassandraReader.earliestDate()) - longDate1 = CassandraReader.earliestDate(); - if (longDate2 > cal.getTimeInMillis()) - longDate2 = cal.getTimeInMillis(); - - date1 = DateFormatter.DateLongToString(longDate1, formaterYYMMDD); - date2 = DateFormatter.DateLongToString(longDate2, formaterYYMMDD); model.put("date1", date1); model.put("date2", date2); TotalJobsStatisticBean res = cr.countJobs(date1, date2); diff --cc server/compbio/listeners/ServletJobsByDate.java index 83b2e4d,fe24750..8ae389f --- a/server/compbio/listeners/ServletJobsByDate.java +++ b/server/compbio/listeners/ServletJobsByDate.java @@@ -11,7 -13,8 +11,9 @@@ import javax.servlet.http.HttpServlet import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; + import compbio.cassandra.DataBase; import compbio.statistic.CassandraRequester; ++import compbio.statistic.StatisticsProt; @WebServlet("/ServletJobsByDate") public class ServletJobsByDate extends HttpServlet { @@@ -28,7 -31,7 +30,7 @@@ CassandraRequester cr = new CassandraRequester(); if (null != request.getParameter("option")) { Calendar cal = Calendar.getInstance(); - // date1 = StatisticsProt.DateFormatYYMMDD(cr.earliestDate()); - date1 = DateFormatYYMMDD(cr.earliestDate()); ++ date1 = StatisticsProt.DateFormatYYMMDD(cr.earliestDate()); date2 = cal.get(Calendar.YEAR) + "/" + (cal.get(Calendar.MONTH) + 1) + "/" + cal.get(Calendar.DAY_OF_MONTH); } request.setAttribute("data1", date1); diff --cc server/compbio/listeners/ServletTimeExecution.java index 563cf42,93b3faf..c380604 --- a/server/compbio/listeners/ServletTimeExecution.java +++ b/server/compbio/listeners/ServletTimeExecution.java @@@ -10,6 -12,6 +10,7 @@@ import javax.servlet.http.HttpServlet import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; ++import compbio.statistic.StatisticsProt; import compbio.statistic.CassandraRequester; /** @@@ -30,7 -32,7 +31,7 @@@ public class ServletTimeExecution exten CassandraRequester sp = new CassandraRequester(); if (null != request.getParameter("option")) { Calendar cal = Calendar.getInstance(); - // date1 = CassandraRequester.DateFormatYYMMDD(sp.earliestDate()); - date1 = DateFormatYYMMDD(sp.earliestDate()); ++ date1 = StatisticsProt.DateFormatYYMMDD(sp.earliestDate()); date2 = cal.get(Calendar.YEAR) + "/" + (cal.get(Calendar.MONTH) + 1) + "/" + cal.get(Calendar.DAY_OF_MONTH); } request.setAttribute("data1", date1); diff --cc server/compbio/statistic/CassandraRequester.java index 6a54800,3e5db8a..f2336e7 --- a/server/compbio/statistic/CassandraRequester.java +++ b/server/compbio/statistic/CassandraRequester.java @@@ -12,16 -12,19 +12,19 @@@ import java.util.Map import compbio.cassandra.DateBean; import compbio.cassandra.ProteinBean; import compbio.cassandra.CassandraNativeConnector; -import compbio.cassandra.CassandraReaderOld; +import compbio.cassandra.CassandraReader; + import compbio.cassandra.DataBase; import compbio.cassandra.Pair; import compbio.cassandra.JobBean; import compbio.cassandra.Total; import compbio.cassandra.TotalByCounterBean; import compbio.cassandra.TotalJobsStatisticBean; import compbio.cassandra.UserBean; + import compbio.engine.JobStatus; public class CassandraRequester { - private CassandraReaderOld db = new CassandraReaderOld(); + private CassandraReader db = new CassandraReader(); + private ArrayList query; private static long currentDate = 0; private static long earlestDate = 0; private final static SimpleDateFormat formatYYMMDD = new SimpleDateFormat("yyyy/MM/dd");