create DateBean, UserBean, TotalBean
authorNatasha Sherstneva <n.shertneva@gmail.com>
Tue, 3 Dec 2013 17:45:52 +0000 (17:45 +0000)
committerNatasha Sherstneva <n.shertneva@gmail.com>
Tue, 3 Dec 2013 17:45:52 +0000 (17:45 +0000)
23 files changed:
datadb/compbio/cassandra/CassandraReader.java
datadb/compbio/cassandra/DataBase.java
datadb/compbio/cassandra/DateBean.java [new file with mode: 0644]
datadb/compbio/cassandra/JobBean.java [moved from datadb/compbio/cassandra/StructureJobLog.java with 51% similarity]
datadb/compbio/cassandra/ProteinBean.java
datadb/compbio/cassandra/Total.java [new file with mode: 0644]
datadb/compbio/cassandra/TotalByCounterBean.java [new file with mode: 0644]
datadb/compbio/cassandra/TotalJobsStatisticBean.java [new file with mode: 0644]
datadb/compbio/cassandra/UserBean.java [new file with mode: 0644]
server/compbio/controllers/DailyStatisticsController.java
server/compbio/controllers/IPDataController.java
server/compbio/controllers/SequenceController.java
server/compbio/listeners/ServletIp.java
server/compbio/listeners/ServletJobsByDate.java
server/compbio/listeners/ServletJobsByIp.java
server/compbio/listeners/ServletSequenceProtein.java
server/compbio/statistic/CassandraRequester.java
webapp/view/reportIP.jsp
webapp/view/reportIPstatistics.jsp
webapp/view/reportJobLog.jsp
webapp/view/reportJobStatistics.jsp
webapp/view/reportJobStatisticsOneDay.jsp
webapp/view/reportProteinSequencesCounter.jsp

index 9ac0a3b..69f7c08 100644 (file)
@@ -53,7 +53,7 @@ public class CassandraReader {
        /*
         * getting data from the db
         */
-       public List<Pair<String, String>> ReadProteinData(long day) {
+       public DateBean ReadProteinData(long day, String date) {
                final long startTime = System.currentTimeMillis();
                String com = "SELECT JobID, Protein FROM ProteinData WHERE jobtime = " + day + ";";
                System.out.println("Command: " + com);
@@ -63,11 +63,10 @@ public class CassandraReader {
                final long queryTime = System.currentTimeMillis();
                List<Row> rows = results.all();
                System.out.println("Query time is " + (queryTime - startTime) + " msec");
-               List<Pair<String, String>> res = new ArrayList<Pair<String, String>>();
+               DateBean res = new DateBean(date);
                int c = 0;
                for (Row r : rows) {
-                       Pair<String, String> pair = new Pair<String, String>(r.getString("JobID"), r.getString("Protein"));
-                       res.add(pair);
+                       res.setJobidAndSeq(r.getString("JobID"), r.getString("Protein"));
                        ++c;
                }
                final long endTime = System.currentTimeMillis();
@@ -77,17 +76,13 @@ public class CassandraReader {
        /*
         * getting data from the db JobDateInfo
         */
-       public List<Long> ReadDateTable(long queryDate) {
+       public Total ReadDateTable(long queryDate) {
                ResultSet results = session.execute("SELECT * FROM JobDateInfo WHERE jobday = " + queryDate + ";");
                if (results.isExhausted())
                        return null;
                Row therow = results.one();
-               List<Long> res = new ArrayList<Long>();
-               res.add(therow.getLong("Total"));
-               res.add(therow.getLong("TotalOK"));
-               res.add(therow.getLong("TotalStopped"));
-               res.add(therow.getLong("TotalError"));
-               res.add(therow.getLong("TotalTimeOut"));
+               Total res = new Total(therow.getLong("Total"), therow.getLong("TotalOK"), therow.getLong("TotalStopped"), 
+                               therow.getLong("TotalError"), therow.getLong("TotalTimeOut"));
                if (!results.isExhausted()) {
                        Date date = new Date (queryDate);
                        log.warn("CassandraReader.ReadDateTable: date row for " + date.toString () + " ("+ queryDate + ") duplicated ");
@@ -129,25 +124,23 @@ public class CassandraReader {
        /*
         * getting jobs by ip
         */
-       public List<Pair<String, String>> ReadIpWithJobs(String ip) {
+       public Map<String, String[]> ReadIpWithJobs(String ip) {
                final long startTime = System.currentTimeMillis();
-               String com = "SELECT JobID, Protein, FinalStatus FROM ProteinLog WHERE ip = '" + ip + "';";
+               String com = "SELECT JobID, Protein, FinalStatus, DataBegin FROM ProteinLog WHERE ip = '" + ip + "';";
                System.out.println("Command: " + com);
                ResultSet results = session.execute(com);
                if (results.isExhausted())
                        return null;
                final long queryTime = System.currentTimeMillis();
                List<Row> rows = results.all();
-               List<Pair<String, String>> res = new ArrayList<Pair<String, String>>();
+               Map<String, String[]> res = new HashMap<String, String[]>();
                System.out.println("Query time is " + (queryTime - startTime) + " msec");
                System.out.println(" rows analysed,  " + rows.size());
                int c = 0;
                for (Row r : rows) {
                        if (r.getString("FinalStatus").equals("OK")) { 
-                               Pair<String, String> pair = new Pair<String, String>(r.getString("JobID"), r.getString("Protein"));
-                               System.out.println(pair.getElement0());
-                               System.out.println(pair.getElement1());
-                               res.add(pair);
+                               String date = r.getString("DataBegin");
+                               res.put(r.getString("JobID"), new String[] {date.substring(0, date.indexOf(":")), r.getString("Protein")});
                                ++c;
                        }
                }
@@ -232,12 +225,12 @@ public class CassandraReader {
                Map<String, Integer> res = new HashMap<String, Integer>();
                int c = 0;
                for (Row r : rows) {
-                       String protein = r.getString("ip");
+                       String ip = r.getString("ip");
                        String id = r.getString("JobID");
-                       if (res.containsKey(protein))
-                               res.put(protein, res.get(protein) + 1);
+                       if (res.containsKey(ip))
+                               res.put(ip, res.get(ip) + 1);
                        else
-                               res.put(protein, 1);
+                               res.put(ip, 1);
                }
                final long endTime = System.currentTimeMillis();
                System.out.println(c + " rows analysed, execution time is " + (endTime - startTime) + " msec");
@@ -247,7 +240,7 @@ public class CassandraReader {
        /*
         * getting log info for jobid
         */
-       public StructureJobLog ReadJobLog(String jobid) {
+       public JobBean ReadJobLog(String jobid) {
                final long startTime = System.currentTimeMillis();
                String com = "SELECT * FROM ProteinLog WHERE JobID = '" + jobid + "';";
                System.out.println("Command: " + com);
@@ -262,7 +255,7 @@ public class CassandraReader {
                if (results1.isExhausted())
                        return null;
                Row row1 = results1.one();
-               StructureJobLog res = new StructureJobLog(row.getString("Protein"), row.getString("JobID"), row.getString("DataBegin"),
+               JobBean res = new JobBean(row.getString("Protein"), row.getString("JobID"), row.getString("DataBegin"),
                                row.getString("DataEnd"), row.getString("ip"), row1.getMap("Predictions", String.class, String.class));
                System.out.println("Query time is " + (queryTime - startTime) + " msec");
                final long endTime = System.currentTimeMillis();
index ab21e43..57063ec 100644 (file)
@@ -19,7 +19,7 @@ public class DataBase {
        private String jpred;
        private List<Integer> timeRez;
        private List<Integer> timeTotalExec;
-       private StructureJobLog logInfo;
+       private JobBean logInfo;
        private ProteinBean predictions;
 
        public DataBase() {
@@ -144,11 +144,11 @@ public class DataBase {
                return timeTotalExec;
        }
        
-       public void setLogInfo(StructureJobLog logInfo){
+       public void setLogInfo(JobBean logInfo){
                this.logInfo = logInfo;
        }
        
-       public StructureJobLog getLogInfo() {
+       public JobBean getLogInfo() {
                return logInfo;
        }
        
diff --git a/datadb/compbio/cassandra/DateBean.java b/datadb/compbio/cassandra/DateBean.java
new file mode 100644 (file)
index 0000000..6f4b06a
--- /dev/null
@@ -0,0 +1,38 @@
+package compbio.cassandra;
+
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+public class DateBean {
+       private String date;
+       private Map<String, String> jobidAndSeq;                                // Map for jobid and sequence
+       
+       public DateBean() {
+               this.jobidAndSeq = new HashMap<String, String>();
+       }
+       
+       public DateBean(String date) {
+               this.date = date;
+               this.jobidAndSeq = new HashMap<String, String>();
+       }
+       
+       public void setJobidAndSeq(String jobid, String seq) {
+               if (jobidAndSeq == null)
+                       jobidAndSeq = new HashMap<String, String>();
+               jobidAndSeq.put(jobid, seq);
+       }
+
+       
+       public Map<String, String> getJobidAndSeq() {
+               return jobidAndSeq;
+       }
+       
+       public void setDate(String date) {
+               this.date = date;
+       }
+
+       public String setDate() {
+               return date;
+       }
+}
similarity index 51%
rename from datadb/compbio/cassandra/StructureJobLog.java
rename to datadb/compbio/cassandra/JobBean.java
index b2d0400..0bfeb2c 100644 (file)
@@ -1,24 +1,33 @@
 package compbio.cassandra;
 
+import java.util.LinkedHashMap;
 import java.util.Map;
 
-public class StructureJobLog {
+public class JobBean implements PredictionIndex {
        private String jobid;
        private String dateStart;
        private String dateEnd;
        private String sequence;
        private String ip;      
-       private Map<String,String> prediction;
+       private LinkedHashMap<String,String> predictions;
        
-       public StructureJobLog (String seq, String id, String  dateStart, String  dateEnd, String ip, Map<String,String> pred) {
+       public JobBean (String seq, String id, String  dateStart, String  dateEnd, String ip, Map<String,String> pred) {
                this.sequence = seq;
                this.jobid = id;
                this.dateStart = dateStart;
                this.dateEnd = dateEnd;
                this.ip = ip;
-               this.prediction = pred;
+               this.predictions = new LinkedHashMap<String,String>();  
+               setPredictions(pred);
        }
        
+       public void setPredictions(Map<String,String> pred) {
+               if (predictions == null)
+                       predictions = new LinkedHashMap<String,String>();       
+               for (String index : predIndex) {
+                       this.predictions.put(index, pred.get(index));
+               }       
+       }
        public String getSequence () {
                return sequence;
        }
@@ -40,6 +49,6 @@ public class StructureJobLog {
        }
        
        public Map<String,String> getPrediction () {
-               return prediction;
+               return predictions;
        }
 }
index d2b7cb7..80f111b 100644 (file)
@@ -20,6 +20,8 @@ public class ProteinBean implements PredictionIndex{
        }
        
        public void setPredictions(Map<String,String> pred) {
+               if (predictions == null)
+                       predictions = new LinkedHashMap<String,String>();       
                for (String index : predIndex) {
                        this.predictions.put(index, pred.get(index));
                }       
diff --git a/datadb/compbio/cassandra/Total.java b/datadb/compbio/cassandra/Total.java
new file mode 100644 (file)
index 0000000..75cef1f
--- /dev/null
@@ -0,0 +1,59 @@
+package compbio.cassandra;
+
+public class Total {
+       private long total;                                     // total number of jobs
+       private long totalOK;                           // number of jobs with execution status OK
+       private long totalStopped;                       // number of jobs with execution status STOPPED
+       private long totalError;                                // number of jobs with execution status Jpred ERROR
+       private long totalTimeOut;                      // number of jobs with execution status TIMEOUT
+       
+       public Total() {}
+       
+       public Total(long total, long totalOK, long totalStopped, long totalError, long totalTimeOut) {
+               this.total = total;
+               this.totalOK = totalOK;
+               this.totalStopped = totalStopped;
+               this.totalError = totalError;
+               this.totalTimeOut = totalTimeOut;
+       }
+       
+       public void setTotal(long tot) {
+               this.total = tot;
+       }
+
+       public long getTotal() {
+               return total;
+       }
+
+       public void setTotalOK(long tot) {
+               this.totalOK = tot;
+       }
+
+       public long getTotalOK() {
+               return totalOK;
+       }
+
+       public void setTotalStopped(long tot) {
+               this.totalStopped = tot;
+       }
+
+       public long getTotalStopped() {
+               return totalStopped;
+       }
+
+       public void setTotalError(long tot) {
+               this.totalError = tot;
+       }
+
+       public long getTotalError() {
+               return totalError;
+       }
+
+       public void setTotalTimeOut(long tot) {
+               this.totalTimeOut = tot;
+       }
+
+       public long getTotalTimeOut() {
+               return totalTimeOut;
+       }
+}
diff --git a/datadb/compbio/cassandra/TotalByCounterBean.java b/datadb/compbio/cassandra/TotalByCounterBean.java
new file mode 100644 (file)
index 0000000..5c8f329
--- /dev/null
@@ -0,0 +1,22 @@
+package compbio.cassandra;
+
+public class TotalByCounterBean {
+       private int totaljobs;                          // total jobs for current condition
+       private String name;                                    // name for counter condition (ip or sequence)
+       
+       public void setTotaljobs(int tot) {
+               this.totaljobs = tot;
+       }
+
+       public int getTotaljobs() {
+               return totaljobs;
+       }
+       
+       public void setName(String name) {
+               this.name = name;
+       }
+
+       public String getName() {
+               return name;
+       }
+}
diff --git a/datadb/compbio/cassandra/TotalJobsStatisticBean.java b/datadb/compbio/cassandra/TotalJobsStatisticBean.java
new file mode 100644 (file)
index 0000000..1df13fd
--- /dev/null
@@ -0,0 +1,33 @@
+package compbio.cassandra;
+
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+public class TotalJobsStatisticBean extends Total {
+       private Map<String, Total> dateTotal;
+       private Total wholeTotal;
+       
+       public TotalJobsStatisticBean() {
+               super();
+               this.dateTotal = new LinkedHashMap<String, Total>();
+       }
+       
+       public void setDateTotal(String dat, Total tot) {
+               if (this.dateTotal == null)
+                       dateTotal = new LinkedHashMap<String, Total>();
+               dateTotal.put(dat, tot);
+       }
+
+       public Map<String, Total> getDateTotal() {
+               return dateTotal;
+       }
+       
+       public void setWholeTotal(Total tot) {
+               this.wholeTotal = tot;
+       }
+       
+       public Total getWholeTotal() {
+               return wholeTotal;
+       }
+}
diff --git a/datadb/compbio/cassandra/UserBean.java b/datadb/compbio/cassandra/UserBean.java
new file mode 100644 (file)
index 0000000..39cfd21
--- /dev/null
@@ -0,0 +1,38 @@
+package compbio.cassandra;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+
+public class UserBean {
+       private String ip;
+       private Map<String,String[]> mainInfo;                  // store jobid, date start and sequence
+       
+       public UserBean(String ip) {
+               this.ip = ip;
+               mainInfo = new HashMap<String,String[]>();
+       }
+
+       public String getIp() {
+               return ip;
+       }
+       
+       public void setMainInfo(String jobid, String date, String sequence) {
+               if (mainInfo == null)
+                       mainInfo = new HashMap<String,String[]>();
+               mainInfo.put(jobid, new String[] {date, sequence});
+       }
+       
+       public void setMainInfo( Map<String,String[]> info) {
+               if (mainInfo == null)
+                       mainInfo = new HashMap<String,String[]>();
+               mainInfo = info;
+       }
+       
+       public Map<String,String[]> getMainInfo() {
+               return mainInfo;
+       }
+
+}
index edfe876..b735107 100644 (file)
@@ -12,8 +12,9 @@ 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.cassandra.DateBean;
+import compbio.cassandra.TotalJobsStatisticBean;
 import compbio.statistic.CassandraRequester;
 import compbio.statistic.StatisticsProt;
 
@@ -50,7 +51,7 @@ public class DailyStatisticsController {
                }
                model.put("date1", date1);
                model.put("date2", date2);
-               List<DataBase> res = cr.countJobs(date1, date2);
+               TotalJobsStatisticBean res = cr.countJobs(date1, date2);
                model.put("result", res);
                final long endTime = System.currentTimeMillis();
                model.put("timeExecution", (endTime - startTime));
@@ -78,9 +79,10 @@ public class DailyStatisticsController {
 
                CassandraRequester cr = new CassandraRequester();
                // IMPORTANT: input should be suppied in the format: DD/MM/YYYY
-               List<DataBase> r = cr.readJobByDay(realdate);
+               DateBean r = cr.readJobByDay(realdate);
                model.put("results", r);
-               model.put("njobs", r.size());
+               if (r != null)
+                       model.put("njobs", r.getJobidAndSeq().size());
                model.put("date", realdate);
                final long endTime = System.currentTimeMillis();
                model.put("timeExecution", (endTime - startTime));
index 7a7e298..424a742 100644 (file)
@@ -9,6 +9,8 @@ import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RequestParam;
 
 import compbio.cassandra.DataBase;
+import compbio.cassandra.TotalByCounterBean;
+import compbio.cassandra.UserBean;
 import compbio.statistic.CassandraRequester;
 
 /**
@@ -56,7 +58,7 @@ public class IPDataController {
 
                final long startTime = System.currentTimeMillis();
                CassandraRequester cr = new CassandraRequester();
-               List<DataBase> r = cr.readIpByCounter(realcounter);
+               List<TotalByCounterBean> r = cr.readIpByCounter(realcounter);
                model.put("results", r);
                model.put("njobs", 0);
                if (null != r) {
@@ -72,11 +74,11 @@ public class IPDataController {
        public String findIP(@RequestParam("ip") String ip, Map<String, Object> model) {
                final long startTime = System.currentTimeMillis();
                CassandraRequester cr = new CassandraRequester();
-               List<DataBase> r = cr.readIp(ip);
+               UserBean r = cr.readIp(ip);
                model.put("results", r);
                model.put("njobs", 0);
                if (null != r) {
-                       model.put("njobs", r.size());
+                       model.put("njobs", r.getMainInfo().size());
                }
                final long endTime = System.currentTimeMillis();
                model.put("timeExecution", (endTime - startTime));
index 2986312..2008a06 100644 (file)
@@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.RequestParam;
 
 import compbio.cassandra.ProteinBean;
 import compbio.cassandra.DataBase;
+import compbio.cassandra.TotalByCounterBean;
 import compbio.statistic.CassandraRequester;
 
 /**
@@ -82,7 +83,7 @@ public class SequenceController {
                }
 
                CassandraRequester cr = new CassandraRequester();
-               List<DataBase> r = cr.readProteinByCounter(realcounter);
+               List<TotalByCounterBean> r = cr.readProteinByCounter(realcounter);
                model.put("results", r);
                model.put("njobs", 0);
                if (null != r) {
index 9fb5383..e229176 100644 (file)
@@ -25,8 +25,8 @@ public class ServletIp extends HttpServlet {
                final long startTime = System.currentTimeMillis();
                String ip = request.getParameter("ip");
                CassandraRequester cr = new CassandraRequester();
-               List<DataBase> r = cr.readIp(ip);
-               request.setAttribute("results", r);
+       //      List<DataBase> r = cr.readIp(ip);
+       //      request.setAttribute("results", r);
                final long endTime = System.currentTimeMillis();
                request.setAttribute("timeExecution", (endTime - startTime));
                request.setAttribute("ip", ip);
index 39fdf16..8ae389f 100644 (file)
@@ -35,8 +35,8 @@ public class ServletJobsByDate extends HttpServlet {
                }
                request.setAttribute("data1", date1);
                request.setAttribute("data2", date2);
-               List<DataBase> res = cr.countJobs(date1, date2);
-               request.setAttribute("result", res);
+//             List<DataBase> res = cr.countJobs(date1, date2);
+//             request.setAttribute("result", res);
                final long endTime = System.currentTimeMillis();
                request.setAttribute("timeExecution", (endTime - startTime));
 //             System.out.println ("QueryServlet.doGet: total number of dates = " + res.size());
index f8d92b9..bff4a5c 100644 (file)
@@ -26,8 +26,8 @@ public class ServletJobsByIp extends HttpServlet {
                final long startTime = System.currentTimeMillis();
                int counter = Integer.parseInt(request.getParameter("counterIp"));
                CassandraRequester cr = new CassandraRequester();
-               List<DataBase> r = cr.readIpByCounter(counter);
-               request.setAttribute("results", r);
+       //      List<DataBase> r = cr.readIpByCounter(counter);
+//             request.setAttribute("results", r);
                final long endTime = System.currentTimeMillis();
                request.setAttribute("timeExecution", (endTime - startTime));
                request.setAttribute("counter", counter);
index 5515566..6d1316d 100644 (file)
@@ -33,8 +33,8 @@ public class ServletSequenceProtein extends HttpServlet {
                int counter = Integer.parseInt(request.getParameter("counterJob"));
                CassandraRequester cr = new CassandraRequester();
                if (search.equals("Search counter")) {
-                       List<DataBase> r = cr.readProteinByCounter(counter);
-                       request.setAttribute("results", r);
+       //              List<DataBase> r = cr.readProteinByCounter(counter);
+//                     request.setAttribute("results", r);
        //              System.out.println ("Search counter: " + r.size() + " proteins found");
                } else {
                //      List<DataBase> r = cr.readProteins(prot, flag);
index d82543a..c150d9d 100755 (executable)
@@ -9,12 +9,17 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
+import compbio.cassandra.DateBean;
 import compbio.cassandra.ProteinBean;
 import compbio.cassandra.CassandraNativeConnector;
 import compbio.cassandra.CassandraReader;
 import compbio.cassandra.DataBase;
 import compbio.cassandra.Pair;
-import compbio.cassandra.StructureJobLog;
+import compbio.cassandra.JobBean;
+import compbio.cassandra.Total;
+import compbio.cassandra.TotalByCounterBean;
+import compbio.cassandra.TotalJobsStatisticBean;
+import compbio.cassandra.UserBean;
 
 public class CassandraRequester {
        private CassandraReader db = new CassandraReader();
@@ -115,7 +120,7 @@ public class CassandraRequester {
        /*
         * query: total number of jobs  for the period from date1 till date2
         */
-       public List<DataBase> countJobs(String date1, String date2) {
+       public TotalJobsStatisticBean countJobs(String date1, String date2) {
                if (null == date1) {
                        date1 = "1970/1/1";
                }
@@ -140,30 +145,27 @@ public class CassandraRequester {
                start.setTime(new Date(dateStart));
                Calendar end = Calendar.getInstance();
                end.setTime(new Date(dateEnd));
-               query = new ArrayList<DataBase>();
+               TotalJobsStatisticBean query = new TotalJobsStatisticBean();
+               Total wholeTotal = new Total(0,0,0,0,0);
                for (Date date = start.getTime(); !start.after(end); start.add(Calendar.DATE, 1), date = start.getTime()) {
-                       List<Long> res = db.ReadDateTable(date.getTime());
+                       Total res = db.ReadDateTable(date.getTime());
                        if (res == null)
                                continue;
-                       DataBase bean = new DataBase();
-                       bean.setTotal((int)(long)res.get(0));
-                       bean.setTotalOK((int)(long)res.get(1));
-                       bean.setTotalStopped((int)(long)res.get(2));
-                       bean.setTotalError((int)(long)res.get(3));
-                       bean.setTotalTimeOut((int)(long)res.get(4));
-                       bean.setDate(DateFormat(date.getTime()));
-                       query.add(bean);
+                       query.setDateTotal(DateFormat(date.getTime()), res);
+                       wholeTotal.setTotal(res.getTotal() + wholeTotal.getTotal());
+                       wholeTotal.setTotalOK(res.getTotalOK() + wholeTotal.getTotalOK());
+                       wholeTotal.setTotalStopped(res.getTotalStopped() + wholeTotal.getTotalStopped());
+                       wholeTotal.setTotalError(res.getTotalError() + wholeTotal.getTotalError());
+                       wholeTotal.setTotalTimeOut(res.getTotalTimeOut() + wholeTotal.getTotalTimeOut());
                }
+               query.setWholeTotal(wholeTotal);
                return query;
        }
 
        /*
         * query: jobs and sequence at date
         */
-       public List<DataBase> readJobByDay (String date) {
-               if (null == date) {
-                       return null;
-               }
+       public DateBean readJobByDay (String date) {
                if (!isThisDateValid(date, formatDDMMYY)) {
                        System.out.println("CassandraRequester.readJobByDay: Wrong date format for " + date);
                        return null;
@@ -172,24 +174,13 @@ public class CassandraRequester {
                long day = DateParsing(date, formatDDMMYY);
                if (day < earlestDate || day > currentDate)
                        return null;    
-               List<Pair<String, String>>      res = db.ReadProteinData(day);
-               if (res == null)
-                       return null;
-               query = new ArrayList<DataBase>();
-               for (Pair<String, String> entry : res) {                
-                       DataBase bean = new DataBase();
-                       bean.setDate(date);
-                       bean.setId(entry.getElement0());
-                       bean.setProt(entry.getElement1());
-                       query.add(bean);
-               }
-               return query;
+               return db.ReadProteinData(day, date);
        }
 
 
        /* 
         * query: protein sequence
-        * */
+        **/
        public List<ProteinBean> readProteins(String protIn, String flag) {
                List<ProteinBean> result;
                if (flag.equals("whole")) 
@@ -211,14 +202,16 @@ public class CassandraRequester {
        /* 
         * query protein sequences with number of jobs
         */
-       public List<DataBase> readProteinByCounter(int minimalcounter) {
-               query = new ArrayList<DataBase>();
+       public List<TotalByCounterBean> readProteinByCounter(int minimalcounter) {              
+               List<TotalByCounterBean> query = new ArrayList<TotalByCounterBean>();
                Map<String, Integer> map = db.ReadProteinSequenceByCounter();
+               if (map == null)
+                       return null;
                for (Map.Entry<String, Integer> entry : map.entrySet()) {
-                       if (entry.getValue() > minimalcounter && entry.getKey().length() > 0) {
-                               DataBase bean = new DataBase();
-                               bean.setTotalId(entry.getValue());
-                               bean.setProt(entry.getKey());
+                       if (entry.getValue() > minimalcounter) {
+                               TotalByCounterBean bean = new TotalByCounterBean();
+                               bean.setTotaljobs(entry.getValue());
+                               bean.setName(entry.getKey());
                                query.add(bean);
                        }
                }
@@ -228,8 +221,8 @@ public class CassandraRequester {
        /* 
         * query ip with number of jobs
         */
-       public List<DataBase> readIpByCounter(Integer minimalcounter) {
-               query = new ArrayList<DataBase>();
+       public List<TotalByCounterBean> readIpByCounter(Integer minimalcounter) {
+               List<TotalByCounterBean> query = new ArrayList<TotalByCounterBean>();
                Map<String, Integer> map = db.ReadIpByCounter();
                if (minimalcounter == null)
                        minimalcounter = 0;
@@ -237,9 +230,9 @@ public class CassandraRequester {
                        return null;
                for (Map.Entry<String, Integer> entry : map.entrySet()) {
                        if (entry.getValue() > minimalcounter) {
-                               DataBase bean = new DataBase();
-                               bean.setTotalId(entry.getValue());
-                               bean.setIp(entry.getKey());
+                               TotalByCounterBean bean = new TotalByCounterBean();
+                               bean.setTotaljobs(entry.getValue());
+                               bean.setName(entry.getKey());
                                query.add(bean);
                        }
                }
@@ -248,35 +241,24 @@ public class CassandraRequester {
        /*
         * query jobs log info
         */
-       public DataBase readJobLog(String jobid) {
+       public JobBean readJobLog(String jobid) {
                if (jobid == null)
                        return null;
-               StructureJobLog res = db.ReadJobLog(jobid);
-               if (res == null)
-                       return null;
-               DataBase query = new DataBase();
-               query.setLogInfo(res);
-               return query;
+               return db.ReadJobLog(jobid);
        }
        
        
        /*
         * query jobs by ipStructureJobLog
         */
-       public List<DataBase> readIp(String ip) {
+       public UserBean readIp(String ip) {
                if (ip == null)
                        return null;
-               List<Pair<String, String>> res = db.ReadIpWithJobs(ip);
+               Map<String, String[]> res = db.ReadIpWithJobs(ip);
                if (res == null) 
                        return null;
-               query = new ArrayList<DataBase>();
-               for (Pair<String, String> entry : res) {
-                       DataBase bean = new DataBase();
-                       bean.setIp(ip);
-                       bean.setId(entry.getElement0());
-                       bean.setProt(entry.getElement1());
-                       query.add(bean);
-               }
+               UserBean query = new UserBean(ip);
+               query.setMainInfo(res);
                return query;
        }
        
index e224de5..dce9db8 100644 (file)
                                                        </tr>
                                                </thead>
                                                <tbody>
-                                                       <c:forEach items="${results}" var="res" varStatus="status">
+                                                       <c:forEach items="${results.mainInfo}" var="res" varStatus="status">
                                                                <tr>
-                                                                       <td><a href="${jobqueryservlet}?IdJob=${res.id}&Search=Search">${res.id}</a></td>
-                                                                       <!-- <td style="text-align: left; border-buttom: dotted; font-family: monospace">${res.logInfo.dateStart}</td>-->
-                                                                       <td style="text-align: left; border-buttom: dotted; font-family: monospace">${res.date}</td>
-
-                                                                       <c:choose>
-                                                                       <c:when test="${res.prot==''}">
-                                                                               <td style="text-align: left; border-buttom: dotted; font-family: monospace">Alignment job</td>
-                                                                       </c:when>
-                                                                       <c:otherwise>
-                                                                               <td style="text-align: left; border-buttom: dotted; font-family: monospace">${res.prot}</td>
-                                                                       </c:otherwise>
-                                                                       </c:choose>
+                                                                       <td><a href="${jobqueryservlet}?IdJob=${res.key}&Search=Search">${res.key}</a></td>
+                                                                       
+                                                                       <c:forEach items="${res.value}" var="info" varStatus="status">
+                                                                               <c:if test="${status.first}">
+                                                                                       <td style="text-align: left; border-buttom: dotted; font-family: monospace">${info}</td>
+                                                                               </c:if>
+                                                                                <c:if test="${!status.first}">
+                                                                                       <c:choose>
+                                                                                       <c:when test="${info==''}">
+                                                                                               <td style="text-align: left; border-buttom: dotted; font-family: monospace">Alignment job</td>
+                                                                                       </c:when>
+                                                                                       <c:otherwise>
+                                                                                               <td style="text-align: left; border-buttom: dotted; font-family: monospace">${info}</td>
+                                                                                       </c:otherwise>
+                                                                                       </c:choose>
+                                                                               </c:if>
+                                                                       </c:forEach>
                                                                </tr>
                                                        </c:forEach>
                                                </tbody>
index dec24be..8c9a153 100644 (file)
@@ -36,8 +36,8 @@
                        <tbody>
                                <c:forEach items="${results}" var="res">
                                        <tr>
-                                               <td>${res.totalId}</td>
-                                               <td><a title="Click to view other jobs" href="${ipquery}?ip=${res.ip}&Search=Search">${res.ip}</a></td>
+                                               <td>${res.totaljobs}</td>
+                                               <td><a title="Click to view other jobs" href="${ipquery}?ip=${res.name}&Search=Search">${res.name}</a></td>
                                        </tr>
                                </c:forEach>
                        </tbody>
index b886aa9..91b7b8f 100644 (file)
                        <p style="font-weight:bold;">Information for the job ${IdJob}</p>
                </div>
                <div class="panel-body">
-                       <p>Start timestamp : ${result.logInfo.dateStart}</p>
-                       <p>End timestamp : ${result.logInfo.dateEnd}</p>
-                       <p>IP: <a title="Click to view other jobs" href="${ipquery}?ip=${result.logInfo.ip}&Search=Search">${result.logInfo.ip}</a></p>
+                       <p>Start timestamp : ${result.dateStart}</p>
+                       <p>End timestamp : ${result.dateEnd}</p>
+                       <p>IP: <a title="Click to view other jobs" href="${ipquery}?ip=${result.ip}&Search=Search">${result.ip}</a></p>
 
                        <table class="table table-striped table-hover table-bordered">
                        <tbody>
                                <tr>
                                        <td>Sequence</td>
                                        <td style="text-align: left; border-buttom: dotted; font-family: monospace">
-                                               <a title="Click to view other jobs" href="${searchquery}?sequence=${result.logInfo.sequence}&protein=whole&Search=Search">${result.logInfo.sequence}</a>
+                                               <a title="Click to view other jobs" href="${searchquery}?sequence=${result.sequence}&protein=whole&Search=Search">${result.sequence}</a>
                                        </td>
                                </tr>
-                               <c:forEach items="${result.logInfo.prediction}" var="pred">
+                               <c:forEach items="${result.prediction}" var="pred">
                                        <tr>
                                                <td>${pred.key}</td>
                                                <td
index 5c707b7..7b7a515 100644 (file)
                                <p>No jobs for this period</p>
                        </c:when>
                        <c:otherwise>
-                               <c:set var="sum" value="0" />
-                               <c:set var="sumOK" value="0" />
-                               <c:set var="sumStopped" value="0" />
-                               <c:set var="sumError" value="0" />
-                               <c:set var="sumTimeOut" value="0" />
-                               <c:forEach items="${result}" var="res">
-                                       <c:set var="tot" value="${res.total}" />
-                                       <c:set var="sum" value="${sum + tot}" />
-                                       <c:set var="totOK" value="${res.totalOK}" />
-                                       <c:set var="sumOK" value="${sumOK + totOK}" />
-                                       <c:set var="totStopped" value="${res.totalStopped}" />
-                                       <c:set var="sumStopped" value="${sumStopped + totStopped}" />
-                                       <c:set var="totError" value="${res.totalError}" />
-                                       <c:set var="sumError" value="${sumError + totError}" />
-                                       <c:set var="totTimeOut" value="${res.totalTimeOut}" />
-                                       <c:set var="sumTimeOut" value="${sumTimeOut + totTimeOut}" />
-                               </c:forEach>
                                <div class="table-responsive">
                                <table class="table table-striped table-hover table-bordered">
                                        <thead>
                                        <tbody>
                                                <tr style="font-weight: bolder;">
                                                        <td style="text-align: center">Total:</td>
-                                                       <td style="text-align: right">${sum}</td>
-                                                       <td style="text-align: right">${sumOK}</td>
-                                                       <td style="text-align: right">${sumStopped}</td>
-                                                       <td style="text-align: right">${sumError}</td>
-                                                       <td style="text-align: right">${sumTimeOut}</td>
+                                                       <c:set var="total" value="${result.wholeTotal}"/>
+                                                       <td style="text-align: right">${total.total}</td>
+                                                       <td style="text-align: right">${total.totalOK}</td>
+                                                       <td style="text-align: right">${total.totalStopped}</td>
+                                                       <td style="text-align: right">${total.totalError}</td>
+                                                       <td style="text-align: right">${total.totalTimeOut}</td>
                                                </tr>
-                                               <c:forEach items="${result}" var="res">
+                                               <c:forEach items="${result.dateTotal}" var="res">
                                                        <tr>
-                                                               <td style="text-align: center">${res.date}</td>
-                                                               <td style="text-align: right">${res.total}</td>
-                                                               <td style="text-align: right"><a href="${onedayquery}?date=${res.date}">${res.totalOK}</a></td>
-                                                               <td style="text-align: right">${res.totalStopped}</td>
-                                                               <td style="text-align: right">${res.totalError}</td>
-                                                               <td style="text-align: right">${res.totalTimeOut}</td>
+                                                               <td style="text-align: center">${res.key}</td>
+                                                               <c:set var="value" value="${res.value}"/>
+                                                               <td style="text-align: right">${value.total}</td>
+                                                               <td style="text-align: right"><a href="${onedayquery}?date=${res.key}">${value.totalOK}</a></td>
+                                                               <td style="text-align: right">${value.totalStopped}</td>
+                                                               <td style="text-align: right">${value.totalError}</td>
+                                                               <td style="text-align: right">${value.totalTimeOut}</td>
                                                        </tr>
                                                </c:forEach>
                                        </tbody>
index 719ace8..1194596 100644 (file)
                        </tr>
                </thead>
                <tbody>
-                       <c:forEach items="${results}" var="res" varStatus="status">
+                       <c:forEach items="${results.jobidAndSeq}" var="res" varStatus="status">
                                <tr>
-                                       <td><a href="${jobquery}?IdJob=${res.id}">${res.id}</a></td>
+                                       <td><a href="${jobquery}?IdJob=${res.key}">${res.key}</a></td>
                                        <c:choose>
-                                       <c:when test="${res.prot == ''}">
+                                       <c:when test="${res.value == ''}">
                                                        <td>Job with alignment</td>
                                        </c:when>
                                        <c:otherwise>
-                                               <td style="text-align: left; border-buttom: dotted; font-family: monospace">${res.prot}</td>
+                                               <td style="text-align: left; border-buttom: dotted; font-family: monospace">${res.value}</td>
                                        </c:otherwise>
                                        </c:choose>
                                        
index 4f38666..7944451 100644 (file)
@@ -39,9 +39,9 @@
                        <tbody>
                                <c:forEach items="${results}" var="res">
                                        <tr>
-                                               <td>${res.totalId}</td>
+                                               <td>${res.totaljobs}</td>
                                                <td style="text-align: left; border-buttom: dotted; font-family: monospace">
-                                                       <a title="Click to view all jobs" href="${searchquery}?sequence=${res.prot}&protein=whole&Search=Search">${res.prot}</a>
+                                                       <a title="Click to view all jobs" href="${searchquery}?sequence=${res.name}&protein=whole&Search=Search">${res.name}</a>
                                                </td>
                                        </tr>
                                </c:forEach>