Fix problem due to new internal java beans
authorSasha Sherstnev <a.sherstnev@dundee.ac.uk>
Thu, 5 Dec 2013 09:44:49 +0000 (09:44 +0000)
committerSasha Sherstnev <a.sherstnev@dundee.ac.uk>
Thu, 5 Dec 2013 09:44:49 +0000 (09:44 +0000)
server/compbio/controllers/DailyStatisticsController.java
server/compbio/controllers/HelpController.java
server/compbio/controllers/SequenceController.java
server/compbio/statistic/CassandraRequester.java

index 5731b96..0fdd4b8 100644 (file)
@@ -34,7 +34,7 @@ public class DailyStatisticsController {
 
                model.put("date1", date1);
                model.put("date2", date2);
-               
+
                return "queryJobStatistics";
        }
 
@@ -53,13 +53,13 @@ public class DailyStatisticsController {
                model.put("date2", date2);
                TotalJobsStatisticBean res = cr.countJobs(date1, date2);
                model.put("result", res);
-               model.put("ndays", res.size());
+               model.put("ndays", res.getDateTotal().size());
                final long endTime = System.currentTimeMillis();
                model.put("timeExecution", (endTime - startTime));
                model.put("option", option);
                return "/reportJobStatistics";
        }
-       
+
        @RequestMapping(value = "/stat/oneday", method = RequestMethod.GET)
        public String findJobsInOneDay(@RequestParam("date") String date, Map<String, Object> model) throws ParseException {
                final long startTime = System.currentTimeMillis();
index cd16fff..e0345b1 100644 (file)
@@ -5,6 +5,7 @@ import java.util.Map;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
+
 //import org.springframework.web.bind.annotation.RequestParam;
 
 /**
@@ -24,12 +25,10 @@ public class HelpController {
                return "support/Notimplemented";
        }
 
-
        @RequestMapping(value = "/help/doc", method = RequestMethod.GET)
        public String formDocPage(Map<String, Object> model) {
                return "support/Notimplemented";
        }
-       
 
        @RequestMapping(value = "/help/javadoc", method = RequestMethod.GET)
        public String formJavadoc(Map<String, Object> model) {
index 62ec81e..4bb9271 100644 (file)
@@ -16,7 +16,8 @@ import compbio.cassandra.TotalByCounterBean;
 import compbio.statistic.CassandraRequester;
 
 /**
- * Spring controller for sequence search. This version works in the servlet style.
+ * Spring controller for sequence search. This version works in the servlet
+ * style.
  * 
  * @author Alexander Sherstnev
  * @author Natasha Sherstneva
@@ -26,9 +27,9 @@ import compbio.statistic.CassandraRequester;
  */
 @Controller
 public class SequenceController {
-       
+
        /**
-        * pattern for NON-protein alphabet  symbols
+        * pattern for NON-protein alphabet symbols
         */
        private final Pattern NONPROTEIN = Pattern.compile("[^ARNDCQEGHILKMFPSTWYV]+", Pattern.CASE_INSENSITIVE);
 
@@ -43,7 +44,7 @@ public class SequenceController {
                model.put("value", 5);
                return "queryProteinSequenceCounter";
        }
-       
+
        @RequestMapping(value = "/sequence/querysequence", method = RequestMethod.GET)
        public String findSequence(@RequestParam("sequence") String sequence, @RequestParam("protein") String flag, Map<String, Object> model) {
                final long startTime = System.currentTimeMillis();
@@ -71,7 +72,7 @@ public class SequenceController {
                        model.put("results", r);
                        if (null != r) {
                                if (flag.equals("whole"))
-                                       model.put("njobs",r.get(0).getJobid().size());
+                                       model.put("njobs", r.get(0).getJobid().size());
                                else
                                        model.put("njobs", r.size());
                        }
index c150d9d..5ed9398 100755 (executable)
@@ -39,7 +39,7 @@ public class CassandraRequester {
                if (null == date2) {
                        date1 = "2100/1/1";
                }
-               if (!isThisDateValid(date1,formatYYMMDD) || !isThisDateValid(date2,formatYYMMDD)) {
+               if (!isThisDateValid(date1, formatYYMMDD) || !isThisDateValid(date2, formatYYMMDD)) {
                        System.out.println("CassandraRequester.extractExecutionTime: wrong format for date1 " + date1 + "or date2 " + date2);
                        return null;
                }
@@ -116,9 +116,9 @@ public class CassandraRequester {
                query.add(db);
                return query;
        }
-       
+
        /*
-        * query: total number of jobs  for the period from date1 till date2
+        * query: total number of jobs for the period from date1 till date2
         */
        public TotalJobsStatisticBean countJobs(String date1, String date2) {
                if (null == date1) {
@@ -146,7 +146,7 @@ public class CassandraRequester {
                Calendar end = Calendar.getInstance();
                end.setTime(new Date(dateEnd));
                TotalJobsStatisticBean query = new TotalJobsStatisticBean();
-               Total wholeTotal = new Total(0,0,0,0,0);
+               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()) {
                        Total res = db.ReadDateTable(date.getTime());
                        if (res == null)
@@ -165,7 +165,7 @@ public class CassandraRequester {
        /*
         * query: jobs and sequence at date
         */
-       public DateBean readJobByDay (String date) {
+       public DateBean readJobByDay(String date) {
                if (!isThisDateValid(date, formatDDMMYY)) {
                        System.out.println("CassandraRequester.readJobByDay: Wrong date format for " + date);
                        return null;
@@ -173,36 +173,34 @@ public class CassandraRequester {
                SetDateRange();
                long day = DateParsing(date, formatDDMMYY);
                if (day < earlestDate || day > currentDate)
-                       return null;    
+                       return null;
                return db.ReadProteinData(day, date);
        }
 
-
-       /* 
+       /*
         * query: protein sequence
-        **/
+        */
        public List<ProteinBean> readProteins(String protIn, String flag) {
                List<ProteinBean> result;
-               if (flag.equals("whole")) 
+               if (flag.equals("whole"))
                        result = db.ReadWholeSequence(protIn);
-                else 
-                        result = db.ReadPartOfSequence(protIn);
+               else
+                       result = db.ReadPartOfSequence(protIn);
                if (result == null)
                        return null;
-               
+
                if (flag.equals("part")) {
                        for (ProteinBean entry : result) {
                                entry.setSubProt(CreateSubprot(entry.getSequence(), protIn));
                        }
-               }                                       
+               }
                return result;
        }
-       
 
-       /* 
+       /*
         * query protein sequences with number of jobs
         */
-       public List<TotalByCounterBean> readProteinByCounter(int minimalcounter) {              
+       public List<TotalByCounterBean> readProteinByCounter(int minimalcounter) {
                List<TotalByCounterBean> query = new ArrayList<TotalByCounterBean>();
                Map<String, Integer> map = db.ReadProteinSequenceByCounter();
                if (map == null)
@@ -217,8 +215,8 @@ public class CassandraRequester {
                }
                return query;
        }
-       
-       /* 
+
+       /*
         * query ip with number of jobs
         */
        public List<TotalByCounterBean> readIpByCounter(Integer minimalcounter) {
@@ -238,6 +236,7 @@ public class CassandraRequester {
                }
                return query;
        }
+
        /*
         * query jobs log info
         */
@@ -246,8 +245,7 @@ public class CassandraRequester {
                        return null;
                return db.ReadJobLog(jobid);
        }
-       
-       
+
        /*
         * query jobs by ipStructureJobLog
         */
@@ -255,17 +253,17 @@ public class CassandraRequester {
                if (ip == null)
                        return null;
                Map<String, String[]> res = db.ReadIpWithJobs(ip);
-               if (res == null) 
+               if (res == null)
                        return null;
                UserBean query = new UserBean(ip);
                query.setMainInfo(res);
                return query;
        }
-       
+
        /*
         * create list of parts of protein sequence;
         */
-       private static List<String> CreateSubprot (String protein, String subprot) {
+       private static List<String> CreateSubprot(String protein, String subprot) {
                List<String> sub = new ArrayList<String>();
                String subStr = protein;
                while (subStr.length() > 0 && subStr.contains(subprot)) {
@@ -279,6 +277,7 @@ public class CassandraRequester {
                        sub.add(subStr);
                return sub;
        }
+
        /*
         * convert String date into long date (miliseconds since the epoch start)
         */
@@ -287,7 +286,7 @@ public class CassandraRequester {
                        return 0;
                }
                long dateWorkSt = 0;
-               
+
                try {
                        dateWorkSt = formatter.parse(datInput).getTime();
                } catch (ParseException e) {
@@ -308,7 +307,8 @@ public class CassandraRequester {
         */
        private static void SetDateRange() {
                Calendar cal = Calendar.getInstance();
-               currentDate = DateParsing(cal.get(Calendar.YEAR) + "/" + (cal.get(Calendar.MONTH) + 1) + "/" + cal.get(Calendar.DAY_OF_MONTH), formatYYMMDD);
+               currentDate = DateParsing(cal.get(Calendar.YEAR) + "/" + (cal.get(Calendar.MONTH) + 1) + "/" + cal.get(Calendar.DAY_OF_MONTH),
+                               formatYYMMDD);
                if (0 == earlestDate) {
                        CassandraRequester cr = new CassandraRequester();
                        earlestDate = cr.earliestDate();
@@ -337,5 +337,5 @@ public class CassandraRequester {
                earlestDate = CassandraNativeConnector.getEarliestDateInDB();
                return earlestDate;
        }
-       
+
 }