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<String, Object> 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<String, Object> 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);
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<DataBase> query;
private static long currentDate = 0;
private static long earlestDate = 0;
private final static SimpleDateFormat formatYYMMDD = new SimpleDateFormat("yyyy/MM/dd");