+++ /dev/null
-package compbio.cassandra;
-
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Collections;
-
-public class DataBase {
- private String date;
- private int total; // total number of jobs
- private int totalOK; // number of jobs with execution status OK
- private int totalStopped; // number of jobs with execution status STOPPED
- private int totalError; // number of jobs with execution status Jpred ERROR
- private int totalTimeOut; // number of jobs with execution status TIMEOUT
- private int totalJobs;
- private int totalId; // total jobs for current protein sequence
- private String id;
- private String ip;
- private String prot; // protein sequence
- private String jpred;
- private List<Integer> timeRez;
- private List<Integer> timeTotalExec;
- private JobBean logInfo;
- private ProteinBean predictions;
-
- public DataBase() {
- }
-
- public DataBase(String dat, int total) {
- this.date = dat;
- this.total = total;
- }
-
- public void setDate(String dat) {
- this.date = dat;
- }
-
- public String getDate() {
- if (null == date)
- return "1/1/1970";
- return date;
- }
-
- public void setTotal(int tot) {
- this.total = tot;
- }
-
- public int getTotal() {
- return total;
- }
-
- public void setTotalOK(int tot) {
- this.totalOK = tot;
- }
-
- public int getTotalOK() {
- return totalOK;
- }
-
- public void setTotalStopped(int tot) {
- this.totalStopped = tot;
- }
-
- public int getTotalStopped() {
- return totalStopped;
- }
-
- public void setTotalError(int tot) {
- this.totalError = tot;
- }
-
- public int getTotalError() {
- return totalError;
- }
-
- public void setTotalTimeOut(int tot) {
- this.totalTimeOut = tot;
- }
-
- public int getTotalTimeOut() {
- return totalTimeOut;
- }
-
- public void setTotalJobs(int totalJobs) {
- this.totalJobs = totalJobs;
- }
-
- public int getTotalJobs() {
- return totalJobs;
- }
-
- public void setTotalId(int totId) {
- this.totalId = totId;
- }
-
- public int getTotalId() {
- return totalId;
- }
-
- public void setProt(String prot) {
- this.prot = prot;
- }
-
- public String getProt() {
- return prot;
- }
-
- public void setJpred(String jpred) {
- this.jpred = jpred;
- }
-
- public String getJpred() {
- return jpred;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public String getId() {
- return id;
- }
-
- public void setIp(String ip) {
- this.ip = ip;
- }
-
- public String getIp() {
- return ip;
- }
-
- public void setTimeRez(List<Integer> timeRez) {
- this.timeRez = timeRez;
- }
-
- public List<Integer> getTimeRez() {
- return timeRez;
- }
-
- public void setTimeTotalExec(List<Integer> timeTotalExec) {
- this.timeTotalExec = timeTotalExec;
- }
-
- public List<Integer> getTimeTotalExec() {
- return timeTotalExec;
- }
-
- public void setLogInfo(JobBean logInfo){
- this.logInfo = logInfo;
- }
-
- public JobBean getLogInfo() {
- return logInfo;
- }
-
- public void setPredictions(ProteinBean predictions){
- this.predictions = predictions;
- }
-
- public ProteinBean getPredictions() {
- return predictions;
- }
-
-}
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
*/
@Controller
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/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 "query/JobStatistics";
}
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 = 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);
final long startTime = System.currentTimeMillis();
String realdate;
+ final SimpleDateFormat formaterDDMMYY = new SimpleDateFormat("dd/MM/yyyy");
+ final SimpleDateFormat formaterYYMMDD = new SimpleDateFormat("yyyy/MM/dd");
try {
long thetime = formaterYYMMDD.parse(date).getTime();
if (thetime < 0) {
model.put("timeExecution", (endTime - startTime));
return "/reportJobStatisticsOneDay";
}
-
- private String DateChecking(String trimmeddate1, String trimmeddate2, long longDate1, long longDate2) {
-
- if (trimmeddate1.equalsIgnoreCase("") || trimmeddate2.equalsIgnoreCase(""))
- return "The date cann't be empty";
- else if (!DateFormatter.isThisDateValid(trimmeddate1, formaterYYMMDD) || !DateFormatter.isThisDateValid(trimmeddate2, formaterYYMMDD))
- return "The date format in invalid. Try format yyyy/mm/dd";
- else if (longDate2 < CassandraReader.earliestDate())
- return "The date2 is after the earlestDate " + theEaerlistDate;
- else if (longDate1 > cal.getTimeInMillis())
- return "The date1 is before the current date " + theCurrentDate;
- else if (longDate1 > longDate2)
- return "Wrong date's diaposon. The date1 is more than date2.";
- else
- return null;
- }
}
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import compbio.cassandra.DataBase;
import compbio.statistic.CassandraRequester;
/**
package compbio.listeners;
import java.io.IOException;
-import java.text.SimpleDateFormat;
import java.util.Calendar;
-import java.util.Date;
import java.util.List;
import javax.servlet.RequestDispatcher;
import compbio.cassandra.DataBase;
import compbio.statistic.CassandraRequester;
+import compbio.statistic.StatisticsProt;
@WebServlet("/ServletJobsByDate")
public class ServletJobsByDate extends HttpServlet {
CassandraRequester cr = new CassandraRequester();
if (null != request.getParameter("option")) {
Calendar cal = Calendar.getInstance();
- 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);
doGet(request, response);
}
- private String DateFormatYYMMDD(long indate) {
- SimpleDateFormat datformat = new SimpleDateFormat("yyyy/MM/dd");
- String dateString = datformat.format(new Date(indate));
- return dateString;
- }
-
}
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import compbio.cassandra.DataBase;
import compbio.statistic.CassandraRequester;
/**
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import compbio.cassandra.DataBase;
import compbio.statistic.CassandraRequester;
/**
package compbio.listeners;
import java.io.IOException;
-import java.text.SimpleDateFormat;
import java.util.Calendar;
-import java.util.Date;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import compbio.statistic.StatisticsProt;
import compbio.statistic.CassandraRequester;
/**
CassandraRequester sp = new CassandraRequester();
if (null != request.getParameter("option")) {
Calendar cal = Calendar.getInstance();
- 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);
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request, response);
}
-
- private String DateFormatYYMMDD(long indate) {
- SimpleDateFormat datformat = new SimpleDateFormat("yyyy/MM/dd");
- String dateString = datformat.format(new Date(indate));
- return dateString;
- }
}
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.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;
* query: total number of jobs for the period from date1 till date2
*/
public TotalJobsStatisticBean countJobs(String date1, String date2) {
- /* if (null == date1) {
+ if (null == date1) {
date1 = "1970/1/1";
}
if (null == date2) {
if (!isThisDateValid(date1, formatYYMMDD) || !isThisDateValid(date2, formatYYMMDD)) {
System.out.println("CassandraRequester.countJobs: wrong format for date1 " + date1 + "or date2 " + date2);
return null;
- }*/
+ }
SetDateRange();
long dateStart = DateParsing(date1, formatYYMMDD);
long dateEnd = DateParsing(date2, formatYYMMDD);
-/* if (dateEnd < earlestDate || dateStart > currentDate || dateStart > dateEnd)
+ if (dateEnd < earlestDate || dateStart > currentDate || dateStart > dateEnd)
return null;
if (dateStart < earlestDate)
dateStart = earlestDate;
if (dateEnd > currentDate)
- dateStart = currentDate;*/
+ dateStart = currentDate;
+
Calendar start = Calendar.getInstance();
start.setTime(new Date(dateStart));
Calendar end = Calendar.getInstance();