Merge branch 'DAO'
authorSasha Sherstnev <a.sherstnev@dundee.ac.uk>
Fri, 31 Jan 2014 16:34:26 +0000 (16:34 +0000)
committerSasha Sherstnev <a.sherstnev@dundee.ac.uk>
Fri, 31 Jan 2014 16:34:26 +0000 (16:34 +0000)
Conflicts:
datadb/compbio/cassandra/CassandraReaderOld.java

12 files changed:
datadb/compbio/cassandra/CassandraReaderOld.java [deleted file]
datadb/compbio/cassandra/readers/CassandraReader.java
datadb/compbio/cassandra/readers/FeaturesReader.java [new file with mode: 0644]
server/compbio/controllers/IPDataController.java
server/compbio/controllers/JobController.java
server/compbio/controllers/ProteomeController.java
server/compbio/controllers/SSFeaturesController.java
server/compbio/statistic/CassandraRequester.java [deleted file]
server/compbio/ws/jpred/jaxws/FindJobForSequence.java [new file with mode: 0644]
server/compbio/ws/jpred/jaxws/FindJobForSequenceResponse.java [new file with mode: 0644]
server/compbio/ws/jpred/jaxws/GetArchive.java [new file with mode: 0644]
server/compbio/ws/jpred/jaxws/GetArchiveResponse.java [new file with mode: 0644]

diff --git a/datadb/compbio/cassandra/CassandraReaderOld.java b/datadb/compbio/cassandra/CassandraReaderOld.java
deleted file mode 100644 (file)
index f483dc1..0000000
+++ /dev/null
@@ -1,325 +0,0 @@
-package compbio.cassandra;
-
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Map;
-
-import org.apache.log4j.Logger;
-
-import com.datastax.driver.core.Row;
-import com.datastax.driver.core.Session;
-import com.datastax.driver.core.ResultSet;
-
-import compbio.beans.DateBean;
-import compbio.beans.JobBean;
-import compbio.beans.ProteinBean;
-import compbio.beans.Total;
-import compbio.engine.JobStatus;
-import compbio.engine.Pair;
-
-public class CassandraReaderOld {
-       private Session session;
-       private static Logger log = Logger.getLogger(CassandraNativeConnector.class);
-
-       public CassandraReaderOld() {
-               Session inis = CassandraNativeConnector.getSession();
-               setSession(inis);
-       }
-
-       public void setSession(Session s) {
-               assert s != null;
-               session = s;
-       }
-
-       /*
-        * getting data from the db
-        */
-       public List<Pair<String, String>> ReadProteinDataTable() {
-               final long startTime = System.currentTimeMillis();
-               String com = "SELECT DataBegin,DataEnd FROM ProteinLog;";
-               System.out.println("Command: " + com);
-               ResultSet results = session.execute(com);
-               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>>();
-               int c = 0;
-               for (Row r : rows) {
-                       Pair<String, String> pair = new Pair<String, String>(r.getString("DataBegin"), r.getString("DataEnd"));
-                       res.add(pair);
-                       ++c;
-               }
-               final long endTime = System.currentTimeMillis();
-               System.out.println(c + " rows analysed, execution time is " + (endTime - startTime) + " msec");
-               return res;
-       }
-
-       /*
-        * getting data from the db
-        */
-       public DateBean ReadProteinData(long day, String date) {
-               String com = "SELECT JobID, Protein FROM ProteinData WHERE jobtime = " + day + ";";
-               System.out.println("Command: " + com);
-               ResultSet results = session.execute(com);
-               if (results.isExhausted())
-                       return null;
-               List<Row> rows = results.all();
-               DateBean res = new DateBean(date);
-               for (Row r : rows) {
-                       res.setJobidAndSeq(r.getString("JobID"), r.getString("Protein"));
-               }
-               return res;
-       }
-
-       /**
-        * getting data from the db
-        */
-       public DateBean ReadFailedJobs(long day, String date, JobStatus status) {
-               // FailLog (jobtime, JobID, ExecTime, ip, FinalStatus)
-               String com = "SELECT JobID FROM FailLog WHERE jobtime = " + day + " and FinalStatus = '" + status.name() + "';";
-               ResultSet results = session.execute(com);
-               if (results.isExhausted())
-                       return null;
-               List<Row> rows = results.all();
-               DateBean res = new DateBean(date);
-               for (Row r : rows) {
-                       String jobid = r.getString("JobID");
-                       String com1 = "SELECT Protein FROM ProteinLog WHERE JobID = '" + jobid + "';";
-                       System.out.println("Command: " + com1);
-                       ResultSet results2 = session.execute(com1);
-                       List<Row> jrows = results2.all();
-                       if (1 == jrows.size()) {
-                               String protein = jrows.get(0).getString("Protein");
-                               res.setJobidAndSeq(jobid, protein);
-                       }
-               }
-               return res;
-       }
-
-       /*
-        * getting data from the db JobDateInfo
-        */
-       public Total ReadDateTable(long queryDate) {
-               ResultSet results = session.execute("SELECT * FROM JobDateInfo WHERE jobday = " + queryDate + ";");
-               if (results.isExhausted())
-                       return null;
-               Row therow = results.one();
-               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 ");
-               }
-               return res;
-       }
-
-       /*
-        * getting whole protein sequence from the db ProteinRow
-        */
-       public List<ProteinBean> ReadWholeSequence(String queryProtein) {
-               final long startTime = System.currentTimeMillis();
-               String com = "SELECT JobID, Predictions FROM ProteinRow WHERE Protein = '" + queryProtein + "';";
-               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();
-               System.out.println("first size : " + rows.size());
-               System.out.println("Query time is " + (queryTime - startTime) + " msec");
-               System.out.println(" rows analysed,  " + rows.size());
-               List<ProteinBean> res = new ArrayList<ProteinBean>();
-               ProteinBean structure = new ProteinBean(queryProtein, rows.get(0).getMap("Predictions", String.class, String.class));
-               System.out.println("second size : " + rows.size());
-               int c = 0;
-               for (Row r : rows) {
-                       structure.setJobid(r.getString("JobID"));
-                       ++c;
-               }
-               res.add(structure);
-               final long endTime = System.currentTimeMillis();
-               System.out.println(c + " rows analysed, execution time is " + (endTime - startTime) + " msec");
-               return res;
-       }
-
-       /*
-        * getting jobs by ip
-        */
-       public Map<String, String[]> ReadIpWithJobs(String ip) {
-               final long startTime = System.currentTimeMillis();
-               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();
-               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")) {
-                               String date = r.getString("DataBegin");
-                               res.put(r.getString("JobID"), new String[] { date.substring(0, date.indexOf(":")), r.getString("Protein") });
-                               ++c;
-                       }
-               }
-               final long endTime = System.currentTimeMillis();
-               System.out.println(c + " rows analysed, execution time is " + (endTime - startTime) + " msec");
-               return res;
-       }
-
-       /*
-        * getting part of protein sequence from the db ProteinRow
-        */
-       public List<ProteinBean> ReadPartOfSequence(String queryProtein) {
-               final long startTime = System.currentTimeMillis();
-               String com = "SELECT * FROM ProteinRow;";
-               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();
-               System.out.println("Query time is " + (queryTime - startTime) + " msec");
-               System.out.println(" rows analysed,  " + rows.size());
-               List<ProteinBean> res = new ArrayList<ProteinBean>();
-               int c = 0;
-               for (Row r : rows) {
-                       String prot = r.getString("Protein");
-                       if (prot.matches("(.*)" + queryProtein + "(.*)")) {
-                               ProteinBean structure = new ProteinBean(prot, r.getMap("Predictions", String.class, String.class));
-                               structure.setJobid(r.getString("JobID"));
-                               res.add(structure);
-                               ++c;
-                       }
-               }
-               final long endTime = System.currentTimeMillis();
-               System.out.println(c + " rows analysed, execution time is " + (endTime - startTime) + " msec");
-               return res;
-       }
-
-       /*
-        * getting protein sequence from the db ProteinRow
-        */
-       public Map<String, String> ReadProtein() {
-               //final long startTime = System.currentTimeMillis();
-               String com = "SELECT * FROM ProteinRow;";
-               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();
-               Map<String, String> output = new HashMap<String, String>();
-               for (Row r : rows) {
-                       String protein = r.getString("Protein");
-                       String prediction = findJnetpred(r.getMap("Predictions", String.class, String.class));
-                       if (protein != null && prediction != null) {
-                               output.put(protein, prediction);
-                       }
-               }
-               //final long endTime = System.currentTimeMillis();
-               return output;
-       }
-
-       private String findJnetpred(Map<String, String> pred) {
-               if (pred != null) {
-                       if (pred.containsKey("jnetpred"))
-                               return pred.get("jnetpred");
-               }
-               return null;
-       }
-
-       /*
-        * getting protein sequences by counter
-        */
-       public Map<String, Integer> ReadProteinSequenceByCounter() {
-               final long startTime = System.currentTimeMillis();
-               String com = "SELECT Protein, JobID FROM ProteinRow;";
-               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();
-               System.out.println("Query time is " + (queryTime - startTime) + " msec");
-               System.out.println(" rows analysed,  " + rows.size());
-               Map<String, Integer> res = new HashMap<String, Integer>();
-               int c = 0;
-               for (Row r : rows) {
-                       String protein = r.getString("Protein");
-                       if (res.containsKey(protein))
-                               res.put(protein, res.get(protein) + 1);
-                       else
-                               res.put(protein, 1);
-               }
-               final long endTime = System.currentTimeMillis();
-               System.out.println(c + " rows analysed, execution time is " + (endTime - startTime) + " msec");
-               return res;
-       }
-
-       /*
-        * getting ip by counter
-        */
-       public Map<String, Integer> ReadIpByCounter() {
-               final long startTime = System.currentTimeMillis();
-               String com = "SELECT JobID, ip FROM ProteinLog;";
-               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();
-               System.out.println("Query time is " + (queryTime - startTime) + " msec");
-               System.out.println(" rows analysed,  " + rows.size());
-               Map<String, Integer> res = new HashMap<String, Integer>();
-               int c = 0;
-               for (Row r : rows) {
-                       String ip = r.getString("ip");
-                       if (res.containsKey(ip))
-                               res.put(ip, res.get(ip) + 1);
-                       else
-                               res.put(ip, 1);
-               }
-               final long endTime = System.currentTimeMillis();
-               System.out.println(c + " rows analysed, execution time is " + (endTime - startTime) + " msec");
-               return res;
-       }
-
-       /*
-        * getting log info for jobid
-        */
-       public JobBean ReadJobLog(String jobid) {
-               final long startTime = System.currentTimeMillis();
-               String com = "SELECT * FROM ProteinLog WHERE JobID = '" + jobid + "';";
-               System.out.println("Command: " + com);
-               ResultSet results = session.execute(com);
-               if (results.isExhausted())
-                       return null;
-               final long queryTime = System.currentTimeMillis();
-               Row row = results.one();
-               String com1 = "SELECT * FROM ProteinRow WHERE JobID = '" + jobid + "' ALLOW FILTERING;";
-               System.out.println("Command: " + com1);
-               ResultSet results1 = session.execute(com1);
-               if (results1.isExhausted())
-                       return null;
-               Row row1 = results1.one();
-               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));
-               String program = row.getString("ProgramName");
-               String version = row.getString("ProgramVersion");
-               if (null != program && null != version) {
-                       res.setProgramName(program);
-                       res.setProgramVersion(version);
-               }
-               System.out.println("Query time is " + (queryTime - startTime) + " msec");
-               final long endTime = System.currentTimeMillis();
-               System.out.println(" rows analysed, execution time is " + (endTime - startTime) + " msec");
-               return res;
-       }
-}
index 01dc122..f970659 100644 (file)
@@ -6,6 +6,7 @@ import com.datastax.driver.core.ResultSet;
 import com.datastax.driver.core.Session;
 import com.datastax.driver.core.exceptions.QueryExecutionException;
 import com.datastax.driver.core.exceptions.QueryValidationException;
+
 import compbio.cassandra.CassandraNativeConnector;
 
 public class CassandraReader {
@@ -50,5 +51,23 @@ public class CassandraReader {
                earlestDate = CassandraNativeConnector.getEarliestDateInDB();
                return earlestDate;
        }
+       
+       /**
+        * prepares an example of either job id or IP for the DB
+        * 
+        * @param exampletype
+        *            defines which example you need (an existing job from the DB -
+        *            jobid, an IP - "ip")
+        * @return a string representation of the requested example, if the example
+        *         type is not known empty string is returned
+        */
+       public String getExample(String exampletype) {
+               if (exampletype.equals("jobid")) {
+                       return "jp_NzBOJKo";
+               } else if (exampletype.equals("ip")) {
+                       return "127.0.0.1";
+               }
+               return "";
+       }
 
 }
diff --git a/datadb/compbio/cassandra/readers/FeaturesReader.java b/datadb/compbio/cassandra/readers/FeaturesReader.java
new file mode 100644 (file)
index 0000000..0ced6c8
--- /dev/null
@@ -0,0 +1,57 @@
+package compbio.cassandra.readers;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.Row;
+
+
+public class FeaturesReader extends CassandraReader {
+
+       public FeaturesReader() {
+               super();
+       }
+
+       /**
+        * query protein feature
+        * 
+        * @param feature
+        *                      protein SS feature
+        * 
+        * @param percent
+        *                      percent SS feature in protein sequence
+        * 
+        * @return UserBean to the controller SSFeaturesController
+        **/
+        
+        public Map<String, String> readProteinsPrediction(String feature, int percent) {
+                ResultSet results = CassandraQuery("SELECT * FROM ProteinRow;");
+                if (results.isExhausted())
+                               return null;
+               List<Row> rows = results.all();
+               Map<String, String> query = new HashMap<String, String>();
+               for (Row r : rows) {
+                       String prot = r.getString("Protein");
+                       String prediction = findJnetpred(r.getMap("Predictions", String.class, String.class));
+                       if (prot != null && prediction != null && (!prot.equals(""))) {
+                               if (prediction.replaceAll("[^" + feature + "]", "").length() > prediction.length() * percent / 100 ) {
+                                       query.put(prot, prediction);
+                               }
+                       }
+               }
+               return query;
+       }
+
+        
+       private String findJnetpred(Map<String, String> pred) {
+               if (pred != null) {
+                       if (pred.containsKey("jnetpred"))
+                               return pred.get("jnetpred");
+               }
+               return null;
+       }
+
+
+}
index 248389a..2b06e39 100644 (file)
@@ -10,9 +10,9 @@ import org.springframework.web.bind.annotation.RequestParam;
 
 import compbio.beans.TotalByCounterBean;
 import compbio.beans.UserBean;
+import compbio.cassandra.readers.CassandraReader;
 import compbio.cassandra.readers.IpReader;
 import compbio.cassandra.readers.ReaderByCounter;
-import compbio.statistic.CassandraRequester;
 
 /**
  * @author Alexander Sherstnev
@@ -31,7 +31,7 @@ public class IPDataController extends BasicController {
        @RequestMapping(value = "/admin/ip/query", method = RequestMethod.GET)
        public String initOneIPForm(Map<String, Object> model) {
                model.put("username", getPrincipalName());
-               CassandraRequester cr = new CassandraRequester();
+               CassandraReader cr = new CassandraReader();
                model.put("value", cr.getExample("ip"));
                return "query/IP";
        }
index 0a00d9b..f05234e 100644 (file)
@@ -14,7 +14,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RequestParam;
 
-import compbio.statistic.CassandraRequester;
 import compbio.beans.DateBean;
 import compbio.beans.ExecutionTimeBean;
 import compbio.beans.JobBean;
@@ -74,7 +73,7 @@ public class JobController extends BasicController {
        @RequestMapping(value = "/job/query", method = RequestMethod.GET)
        public String initFindForm(Map<String, Object> model) {
                model.put("username", getPrincipalName());
-               CassandraRequester cr = new CassandraRequester();
+               CassandraReader cr = new CassandraReader();
                model.put("value", cr.getExample("jobid"));
                return "query/JobLog";
        }
index d5a8c85..3ee0609 100644 (file)
@@ -7,7 +7,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RequestParam;
 
-import compbio.statistic.CassandraRequester;
+import compbio.cassandra.readers.FeaturesReader;
+
 
 /**
  * Spring controller for dealing with proteomes. This version works in the
@@ -75,8 +76,8 @@ public class ProteomeController extends BasicController {
                        return "query/SSFeatures";
                }
 
-               CassandraRequester cr = new CassandraRequester();
-               Map<String, String> r = cr.readProteinsPrediction(typeFeature, realpercent);
+               FeaturesReader reader = new FeaturesReader();
+               Map<String, String> r = reader.readProteinsPrediction(typeFeature, realpercent);
                model.put("results", r);
                model.put("njobs", 0);
                if (null != r) {
index 3c66361..a961efe 100644 (file)
@@ -7,7 +7,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RequestParam;
 
-import compbio.statistic.CassandraRequester;
+import compbio.cassandra.readers.FeaturesReader;
 
 /**
  * Spring controller for protein secondary structure features. This version
@@ -89,8 +89,8 @@ public class SSFeaturesController extends BasicController {
                        return "query/SSFeatures";
                }
 
-               CassandraRequester cr = new CassandraRequester();
-               Map<String, String> r = cr.readProteinsPrediction(typeFeature, realpercent);
+               FeaturesReader reader = new FeaturesReader();
+               Map<String, String> r = reader.readProteinsPrediction(typeFeature, realpercent);
                model.put("results", r);
                model.put("njobs", 0);
                StringBuilder csvline = new StringBuilder("");
diff --git a/server/compbio/statistic/CassandraRequester.java b/server/compbio/statistic/CassandraRequester.java
deleted file mode 100755 (executable)
index 1e2d00b..0000000
+++ /dev/null
@@ -1,379 +0,0 @@
-package compbio.statistic;
-
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import compbio.beans.DateBean;
-import compbio.beans.JobBean;
-import compbio.beans.ProteinBean;
-import compbio.beans.Total;
-import compbio.beans.TotalByCounterBean;
-import compbio.beans.TotalJobsStatisticBean;
-import compbio.beans.UserBean;
-import compbio.cassandra.CassandraNativeConnector;
-import compbio.cassandra.CassandraReaderOld;
-import compbio.cassandra.DataBase;
-import compbio.engine.JobStatus;
-import compbio.engine.Pair;
-
-public class CassandraRequester {
-       private CassandraReaderOld db = new CassandraReaderOld();
-       private ArrayList<DataBase> query;
-       private static long currentDate = 0;
-       private static long earlestDate = 0;
-       private final static SimpleDateFormat formatYYMMDD = new SimpleDateFormat("yyyy/MM/dd");
-       private final static SimpleDateFormat formatDDMMYY = new SimpleDateFormat("dd/MM/yyyy");
-
-       /*
-        * query: execution time for the period from date1 till date2
-        */
-       public List<DataBase> extractExecutionTime(String date1, String date2) {
-               if (null == date1) {
-                       date1 = "1970/1/1";
-               }
-               if (null == date2) {
-                       date1 = "2100/1/1";
-               }
-               if (!isThisDateValid(date1, formatYYMMDD) || !isThisDateValid(date2, formatYYMMDD)) {
-                       System.out.println("CassandraRequester.extractExecutionTime: wrong format for date1 " + date1 + "or date2 " + date2);
-                       return null;
-               }
-               SetDateRange();
-               int nbins = 5;
-               long dateStart = DateParsing(date1, formatYYMMDD);
-               long dateEnd = DateParsing(date2, formatYYMMDD);
-               if (dateEnd < earlestDate || dateStart > currentDate || dateStart > dateEnd)
-                       return null;
-               if (dateStart < earlestDate)
-                       dateStart = earlestDate;
-               if (dateEnd > currentDate)
-                       dateStart = currentDate;
-
-               Calendar start = Calendar.getInstance();
-               start.setTime(new Date(dateStart));
-               Calendar end = Calendar.getInstance();
-               end.setTime(new Date(dateEnd));
-               query = new ArrayList<DataBase>();
-               List<Integer> totalTime = new ArrayList<Integer>();
-               for (int i = 0; i < nbins; i++)
-                       totalTime.add(i, 0);
-               List<Pair<String, String>> res = db.ReadProteinDataTable();
-               List<Pair<Date, Long>> numres = new ArrayList<Pair<Date, Long>>();
-
-               for (Pair<String, String> entry : res) {
-                       SimpleDateFormat dateformatter = new SimpleDateFormat("yyyy/MM/dd");
-                       try {
-                               Date jobstartdate = dateformatter.parse(entry.getElement0());
-                               long date = jobstartdate.getTime();
-                               if (dateStart <= date && date <= dateEnd) {
-                                       SimpleDateFormat datetimeformatter = new SimpleDateFormat("yyyy/MM/dd:H:m:s");
-                                       Date jobstarttime = datetimeformatter.parse(entry.getElement0());
-                                       Date jobendtime = datetimeformatter.parse(entry.getElement1());
-                                       long diff = (jobendtime.getTime() - jobstarttime.getTime()) / 1000;
-                                       Pair<Date, Long> pair = new Pair<Date, Long>(jobstartdate, Long.valueOf(diff));
-                                       numres.add(pair);
-                               }
-                       } catch (ParseException e) {
-                               e.printStackTrace();
-                       }
-               }
-
-               for (Date date = start.getTime(); !start.after(end); start.add(Calendar.DATE, 1), date = start.getTime()) {
-                       List<Integer> timeResult = new ArrayList<Integer>();
-                       for (int i = 0; i < nbins; i++)
-                               timeResult.add(i, 0);
-                       for (Pair<Date, Long> p : numres) {
-                               if (date.equals(p.getElement0())) {
-                                       long lenResult = p.getElement1().longValue();
-                                       if (lenResult <= 30)
-                                               timeResult.set(0, timeResult.get(0) + 1);
-                                       else if (lenResult > 30 && lenResult <= 60)
-                                               timeResult.set(1, timeResult.get(1) + 1);
-                                       else if (lenResult > 60 && lenResult <= 120)
-                                               timeResult.set(2, timeResult.get(2) + 1);
-                                       else if (lenResult > 120 && lenResult <= 600)
-                                               timeResult.set(3, timeResult.get(3) + 1);
-                                       else {
-                                               timeResult.set(4, timeResult.get(4) + 1);
-                                       }
-                               }
-                       }
-                       for (int i = 0; i < nbins; i++)
-                               totalTime.set(i, totalTime.get(i) + timeResult.get(i));
-                       DataBase db = new DataBase();
-                       db.setTimeRez(timeResult);
-                       db.setDate(DateFormat(date.getTime()));
-                       query.add(db);
-               }
-
-               /*
-                * ???? Very strange code... DataBase db = new DataBase();
-                * db.setTimeTotalExec(totalTime); query.add(db);
-                */
-               return query;
-       }
-
-       /*
-        * query: total number of jobs for the period from date1 till date2
-        */
-       public TotalJobsStatisticBean countJobs(String date1, String date2) {
-               /*
-                * if (null == date1) { date1 = "1970/1/1"; } if (null == date2) { date1
-                * = "2100/1/1"; } 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) return null; if (dateStart < earlestDate) dateStart =
-                * earlestDate; if (dateEnd > currentDate) dateStart = currentDate;
-                */
-               Calendar start = Calendar.getInstance();
-               start.setTime(new Date(dateStart));
-               Calendar end = Calendar.getInstance();
-               end.setTime(new Date(dateEnd));
-               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()) {
-                       Total res = db.ReadDateTable(date.getTime());
-                       if (res == null)
-                               continue;
-                       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 DateBean readJobByDay(String date, JobStatus status) {
-               if (!isThisDateValid(date, formatDDMMYY)) {
-                       System.out.println("CassandraRequester.readJobByDay: Wrong date format for " + date);
-                       return null;
-               }
-               SetDateRange();
-               long day = DateParsing(date, formatDDMMYY);
-               if (day < earlestDate || day > currentDate)
-                       return null;
-
-               if (status == JobStatus.OK) {
-                       return db.ReadProteinData(day, date);
-               }
-               return db.ReadFailedJobs(day, date, status);
-       }
-
-       /*
-        * query: protein sequence
-        */
-       public List<ProteinBean> readProteins(String protIn, String searchtype) {
-               List<ProteinBean> result;
-               if (searchtype.equals("whole"))
-                       result = db.ReadWholeSequence(protIn);
-               else
-                       result = db.ReadPartOfSequence(protIn);
-               if (result == null)
-                       return null;
-
-               if (searchtype.equals("partial")) {
-                       for (ProteinBean entry : result) {
-                               entry.setSubProt(CreateSubprot(entry.getSequence(), protIn));
-                       }
-               }
-               return result;
-       }
-
-       /*
-        * query: protein feature
-        */
-
-       public Map<String, String> readProteinsPrediction(String feature, int percent) {
-               Map<String, String> results = db.ReadProtein();
-               if (results == null)
-                       return null;
-               Map<String, String> query = new HashMap<String, String>();
-               for (Map.Entry<String, String> entry : results.entrySet()) {
-                       String prediction = entry.getValue();
-                       String protein = entry.getKey();
-                       if (prediction.replaceAll("[^" + feature + "]", "").length() > prediction.length() * percent / 100 && !protein.equals("")) {
-                               query.put(protein, prediction);
-                       }
-               }
-               return query;
-       }
-
-       /*
-        * query protein sequences with number of jobs
-        */
-       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) {
-                               TotalByCounterBean bean = new TotalByCounterBean();
-                               bean.setTotaljobs(entry.getValue());
-                               bean.setName(entry.getKey());
-                               query.add(bean);
-                       }
-               }
-               return query;
-       }
-
-       /*
-        * query ip with number of jobs
-        */
-       public List<TotalByCounterBean> readIpByCounter(Integer minimalcounter) {
-               List<TotalByCounterBean> query = new ArrayList<TotalByCounterBean>();
-               Map<String, Integer> map = db.ReadIpByCounter();
-               if (minimalcounter == null)
-                       minimalcounter = 0;
-               if (map == null)
-                       return null;
-               for (Map.Entry<String, Integer> entry : map.entrySet()) {
-                       if (entry.getValue() > minimalcounter) {
-                               TotalByCounterBean bean = new TotalByCounterBean();
-                               bean.setTotaljobs(entry.getValue());
-                               bean.setName(entry.getKey());
-                               query.add(bean);
-                       }
-               }
-               return query;
-       }
-
-       /*
-        * query jobs log info
-        */
-       public JobBean readJobLog(String jobid) {
-               if (jobid == null)
-                       return null;
-               return db.ReadJobLog(jobid);
-       }
-
-       /*
-        * query jobs by ipStructureJobLog
-        */
-       public UserBean readIp(String ip) {
-               if (ip == null)
-                       return null;
-               Map<String, String[]> res = db.ReadIpWithJobs(ip);
-               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) {
-               List<String> sub = new ArrayList<String>();
-               String subStr = protein;
-               while (subStr.length() > 0 && subStr.contains(subprot)) {
-                       String first = subStr.substring(0, subStr.indexOf(subprot));
-                       if (first.length() > 0)
-                               sub.add(first);
-                       sub.add(subprot);
-                       subStr = subStr.substring(subStr.indexOf(subprot) + subprot.length(), subStr.length());
-               }
-               if (subStr.length() > 0)
-                       sub.add(subStr);
-               return sub;
-       }
-
-       /*
-        * convert String date into long date (miliseconds since the epoch start)
-        */
-       private static long DateParsing(String datInput, SimpleDateFormat formatter) {
-               if (datInput == null) {
-                       return 0;
-               }
-               long dateWorkSt = 0;
-
-               try {
-                       dateWorkSt = formatter.parse(datInput).getTime();
-               } catch (ParseException e) {
-                       e.printStackTrace();
-               }
-               return dateWorkSt;
-       }
-
-       // convert long to date in string format
-       private static String DateFormat(long inDate) {
-               SimpleDateFormat datformat = new SimpleDateFormat("dd/MM/yyyy");
-               return datformat.format(new Date(inDate));
-       }
-
-       /*
-        * set earlest date and current dates. earlestDate is static and should be
-        * set at the 1st call currentDate should be re-calculated every time
-        */
-       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);
-               if (0 == earlestDate) {
-                       CassandraRequester cr = new CassandraRequester();
-                       earlestDate = cr.earliestDate();
-               }
-       }
-
-       public boolean isThisDateValid(String dateToValidate, SimpleDateFormat sdf) {
-               if (dateToValidate == null || dateToValidate.equals("")) {
-                       return false;
-               }
-               try {
-                       // if not valid, this will throw ParseException
-                       sdf.setLenient(false);
-                       Date date = sdf.parse(dateToValidate);
-               } catch (ParseException e) {
-                       e.printStackTrace();
-                       return false;
-               }
-               return true;
-       }
-
-       /*
-        * find the earliest date in the database
-        */
-       public long earliestDate() {
-               earlestDate = CassandraNativeConnector.getEarliestDateInDB();
-               return earlestDate;
-       }
-
-       /**
-        * prepares an example of either job id or IP for the DB
-        * 
-        * @param exampletype
-        *            defines which example you need (an existing job from the DB -
-        *            jobid, an IP - "ip")
-        * @return a string representation of the requested example, if the example
-        *         type is not known empty string is returned
-        */
-       public String getExample(String exampletype) {
-               if (exampletype.equals("jobid")) {
-                       return "jp_NzBOJKo";
-               } else if (exampletype.equals("ip")) {
-                       return "127.0.0.1";
-               }
-               return "";
-       }
-
-}
diff --git a/server/compbio/ws/jpred/jaxws/FindJobForSequence.java b/server/compbio/ws/jpred/jaxws/FindJobForSequence.java
new file mode 100644 (file)
index 0000000..6142ff7
--- /dev/null
@@ -0,0 +1,80 @@
+
+package compbio.ws.jpred.jaxws;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlRootElement(name = "findJobForSequence", namespace = "http://server.proteocache.ws")
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "findJobForSequence", namespace = "http://server.proteocache.ws", propOrder = {
+    "sequence",
+    "program",
+    "version"
+})
+public class FindJobForSequence {
+
+    @XmlElement(name = "sequence", namespace = "")
+    private String sequence;
+    @XmlElement(name = "program", namespace = "")
+    private String program;
+    @XmlElement(name = "version", namespace = "")
+    private String version;
+
+    /**
+     * 
+     * @return
+     *     returns String
+     */
+    public String getSequence() {
+        return this.sequence;
+    }
+
+    /**
+     * 
+     * @param sequence
+     *     the value for the sequence property
+     */
+    public void setSequence(String sequence) {
+        this.sequence = sequence;
+    }
+
+    /**
+     * 
+     * @return
+     *     returns String
+     */
+    public String getProgram() {
+        return this.program;
+    }
+
+    /**
+     * 
+     * @param program
+     *     the value for the program property
+     */
+    public void setProgram(String program) {
+        this.program = program;
+    }
+
+    /**
+     * 
+     * @return
+     *     returns String
+     */
+    public String getVersion() {
+        return this.version;
+    }
+
+    /**
+     * 
+     * @param version
+     *     the value for the version property
+     */
+    public void setVersion(String version) {
+        this.version = version;
+    }
+
+}
diff --git a/server/compbio/ws/jpred/jaxws/FindJobForSequenceResponse.java b/server/compbio/ws/jpred/jaxws/FindJobForSequenceResponse.java
new file mode 100644 (file)
index 0000000..d367d02
--- /dev/null
@@ -0,0 +1,36 @@
+
+package compbio.ws.jpred.jaxws;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlRootElement(name = "findJobForSequenceResponse", namespace = "http://server.proteocache.ws")
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "findJobForSequenceResponse", namespace = "http://server.proteocache.ws")
+public class FindJobForSequenceResponse {
+
+    @XmlElement(name = "return", namespace = "")
+    private String _return;
+
+    /**
+     * 
+     * @return
+     *     returns String
+     */
+    public String getReturn() {
+        return this._return;
+    }
+
+    /**
+     * 
+     * @param _return
+     *     the value for the _return property
+     */
+    public void setReturn(String _return) {
+        this._return = _return;
+    }
+
+}
diff --git a/server/compbio/ws/jpred/jaxws/GetArchive.java b/server/compbio/ws/jpred/jaxws/GetArchive.java
new file mode 100644 (file)
index 0000000..2fab038
--- /dev/null
@@ -0,0 +1,36 @@
+
+package compbio.ws.jpred.jaxws;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlRootElement(name = "getArchive", namespace = "http://server.proteocache.ws")
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "getArchive", namespace = "http://server.proteocache.ws")
+public class GetArchive {
+
+    @XmlElement(name = "job", namespace = "")
+    private String job;
+
+    /**
+     * 
+     * @return
+     *     returns String
+     */
+    public String getJob() {
+        return this.job;
+    }
+
+    /**
+     * 
+     * @param job
+     *     the value for the job property
+     */
+    public void setJob(String job) {
+        this.job = job;
+    }
+
+}
diff --git a/server/compbio/ws/jpred/jaxws/GetArchiveResponse.java b/server/compbio/ws/jpred/jaxws/GetArchiveResponse.java
new file mode 100644 (file)
index 0000000..ac6b0db
--- /dev/null
@@ -0,0 +1,36 @@
+
+package compbio.ws.jpred.jaxws;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlRootElement(name = "getArchiveResponse", namespace = "http://server.proteocache.ws")
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "getArchiveResponse", namespace = "http://server.proteocache.ws")
+public class GetArchiveResponse {
+
+    @XmlElement(name = "return", namespace = "")
+    private String _return;
+
+    /**
+     * 
+     * @return
+     *     returns String
+     */
+    public String getReturn() {
+        return this._return;
+    }
+
+    /**
+     * 
+     * @param _return
+     *     the value for the _return property
+     */
+    public void setReturn(String _return) {
+        this._return = _return;
+    }
+
+}