Merge branch 'DAO' of https://source.jalview.org/git/proteocache into DAO
authorNatasha Sherstneva <n.shertneva@gmail.com>
Fri, 31 Jan 2014 10:37:32 +0000 (10:37 +0000)
committerNatasha Sherstneva <n.shertneva@gmail.com>
Fri, 31 Jan 2014 10:37:32 +0000 (10:37 +0000)
Conflicts:
datadb/compbio/cassandra/CassandraReaderOld.java
server/compbio/statistic/CassandraRequester.java

35 files changed:
conf/Proteocache.properties
datadb/compbio/beans/DateBean.java
datadb/compbio/beans/JobBean.java
datadb/compbio/beans/ProteinBean.java
datadb/compbio/cassandra/CassandraNativeConnector.java
datadb/compbio/cassandra/CassandraNewTableWriter.java
datadb/compbio/cassandra/CassandraRemover.java
datadb/compbio/cassandra/DataBase.java
datadb/compbio/cassandra/JpredParserLocalFile.java
datadb/compbio/cassandra/readers/CassandraReader.java
datadb/compbio/cassandra/readers/CassandraReaderExecutionTime.java
datadb/compbio/cassandra/readers/ExecutionTimeReader.java
datadb/compbio/cassandra/readers/JobReader.java
datadb/compbio/cassandra/readers/SequenceReader.java
engine/compbio/engine/ExecutionInterval.java
engine/compbio/engine/JpredJob.java
engine/compbio/engine/Pair.java [moved from datadb/compbio/cassandra/Pair.java with 93% similarity]
server/compbio/controllers/BasicController.java
server/compbio/controllers/DailyStatisticsController.java
server/compbio/controllers/DatabaseController.java
server/compbio/controllers/JobController.java
server/compbio/controllers/MainController.java
server/compbio/controllers/SSFeaturesController.java
server/compbio/controllers/SequenceController.java
server/compbio/listeners/ContextListener.java
webapp/view/home.jsp
webapp/view/public.jsp
webapp/view/query/Sequence.jsp
webapp/view/reports/IPstatistics.jsp
webapp/view/reports/Job.jsp
webapp/view/reports/JobStatisticsOneDay.jsp
webapp/view/reports/RemoveJobs.jsp
webapp/view/reports/SSFeatures.jsp
webapp/view/reports/Sequences.jsp
webapp/view/reports/SequencesStatistics.jsp

index 24307b7..2b2a2fd 100644 (file)
@@ -1,7 +1,8 @@
 #################################################################################
 # Cassandra host or IP
 # test server is 10.0.115.190
-cassandra.host=localhost
+#cassandra.host=localhost
+cassandra.host=Main-laptop2.dyn.lifesci.dundee.ac.uk
 #cassandra.host=gjb-www-1.cluster.lifesci.dundee.ac.uk
 #cassandra.host=c6100-1.cluster.lifesci.dundee.ac.uk
 
@@ -14,6 +15,7 @@ cassandra.version.update=false
 cassandra.jpred.web.update=true
 cassandra.jpred.web.inidelay=0
 cassandra.jpred.web.updaterate=30
+#cassandra.jpred.web.prefix=http://gjb-www-1.cluster.lifesci.dundee.ac.uk:3209/results
 
 # update time period (in days)
 # by defauls for 100 past days
index 7c593d3..b00e1d6 100644 (file)
@@ -1,7 +1,6 @@
 package compbio.beans;
 
 import java.util.HashMap;
-import java.util.LinkedHashMap;
 import java.util.Map;
 
 public class DateBean {
index ec1f030..5a499c2 100644 (file)
@@ -13,16 +13,18 @@ public class JobBean implements PredictionIndex {
        private String ip;
        private String ProgramName;
        private String ProgramVersion;
+       private String ProgramLink;
        private LinkedHashMap<String, String> predictions;
 
-       public JobBean(String seq, String id, String dateStart, String dateEnd, String ip, Map<String, String> pred, String program, String version) {
+       public JobBean(String seq, String id, String dateStart, String dateEnd, String ip, Map<String, String> pred) {
                this.sequence = seq;
-               this.ProgramName = program;
-               this.ProgramVersion = version;
+               this.ProgramName = "";
+               this.ProgramVersion = "";
                this.jobid = id;
                this.dateStart = dateStart;
                this.dateEnd = dateEnd;
                this.ip = ip;
+               this.ProgramLink = "";
                this.predictions = new LinkedHashMap<String, String>();
                setPredictions(pred);
        }
@@ -63,6 +65,22 @@ public class JobBean implements PredictionIndex {
                return ProgramVersion;
        }
 
+       public String getProgramLink() {
+               return ProgramLink;
+       }
+
+       public void setProgramName(String name) {
+               ProgramName = name;
+       }
+       
+       public void setProgramVersion(String version) {
+               ProgramVersion = version;
+       }
+       
+       public void setProgramLink(String link) {
+               ProgramLink = link;
+       }
+       
        public Map<String, String> getPrediction() {
                return predictions;
        }
index c649320..958eab5 100644 (file)
@@ -21,6 +21,7 @@ public class ProteinBean implements PredictionIndex {
                this.predictions = new LinkedHashMap<String, String>();
                this.jobid = new ArrayList<String>();
                setPredictions(pred);
+               setJnetpred(pred);
        }
 
        public void setSequence(String seq) {
index bb807c1..f02000c 100644 (file)
@@ -88,8 +88,11 @@ public class CassandraNativeConnector {
                session.execute("CREATE TABLE IF NOT EXISTS JobDateInfo "
                                + "(jobday bigint, Total bigint,  TotalOK bigint, TotalStopped bigint, TotalError bigint, TotalTimeOut bigint, Program varchar, Version varchar, PRIMARY KEY(jobday));");
 
-               String com = "CREATE TABLE IF NOT EXISTS Users "
-                               + "(name varchar, id bigint, email varchar, password varchar, organisation varchar, position varchar, signedtolist boolean, registrationdate bigint, PRIMARY KEY(id));";
+               session.execute("CREATE TABLE IF NOT EXISTS Programs "
+                               + "(Program varchar, Version varchar, Description varchar, weblink varchar, PRIMARY KEY(Program,Version));");
+
+               session.execute("CREATE TABLE IF NOT EXISTS Users "
+                               + "(name varchar, id bigint, email varchar, password varchar, organisation varchar, position varchar, signedtolist boolean, registrationdate bigint, PRIMARY KEY(id));");
 
                // session.execute("ALTER TABLE ProteinLog ADD ProgramName ascii;");
                // session.execute("ALTER TABLE ProteinLog ADD ProgramVersion ascii;");
index b4e9746..3b6c741 100644 (file)
@@ -9,11 +9,8 @@ import org.apache.log4j.Logger;
 import com.datastax.driver.core.Row;
 import com.datastax.driver.core.Session;
 import com.datastax.driver.core.ResultSet;
-import com.datastax.driver.core.PreparedStatement;
-import com.datastax.driver.core.BoundStatement;
 import com.datastax.driver.core.exceptions.QueryExecutionException;
 
-import compbio.engine.ProteoCachePropertyHelperManager;
 import compbio.cassandra.CassandraNativeConnector;
 
 public class CassandraNewTableWriter {
@@ -59,7 +56,7 @@ public class CassandraNewTableWriter {
                Calendar endcal = Calendar.getInstance();
                long endTime = endcal.getTime().getTime();
                for (Date date = runnicCal.getTime(); date.getTime() < endTime; runnicCal.add(Calendar.DATE, 1), date = runnicCal.getTime()) {
-                       try {                           
+                       try {
                                String com = "SELECT JobID, Protein FROM ProteinData WHERE jobtime = " + date.getTime() + ";";
                                System.out.println(com);
                                ResultSet results = session.execute(com);
@@ -67,12 +64,11 @@ public class CassandraNewTableWriter {
                                        continue;
                                List<Row> rows = results.all();
                                System.out.println(rows.size());
-                               int k=0;
                                for (Row r : rows) {
                                        session.execute("UPDATE  ProteinLog SET ProgramName = 'Jpred', ProgramVersion = '3.0.1' WHERE JobID = '"
                                                        + r.getString("JobID") + "';");
                                        session.execute("UPDATE  JpredArchive SET ProgramName = 'Jpred', ProgramVersion = '3.0.1' WHERE JobID = '"
-                                                       + r.getString("JobID") + "';");                         
+                                                       + r.getString("JobID") + "';");
                                }
                        } catch (QueryExecutionException e) {
                                e.printStackTrace();
index 76cc787..d7aeafb 100644 (file)
@@ -6,58 +6,75 @@ import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
 
-import org.apache.log4j.Logger;
-
 import com.datastax.driver.core.ResultSet;
 import com.datastax.driver.core.Row;
-import com.datastax.driver.core.Session;
-import com.datastax.driver.core.exceptions.QueryExecutionException;
-import com.datastax.driver.core.exceptions.QueryValidationException;
+import compbio.cassandra.readers.CassandraReader;
 
-public class CassandraRemover {
-       private Session session;
+/**
+ * The class removes jobs from the cassandra database. 4 different strategies
+ * are possiable: 1. remove 1 job with given job ID 2. remove jobs launched from
+ * an IP 3. remove jobs with particular protein sequence 4. remove jobs launched
+ * within a time range (date1, data2)
+ * 
+ * @author Alexander Sherstnev
+ * @author Natasha Sherstneva
+ * @version 1.0
+ * @since Nov 2013
+ */
+public class CassandraRemover extends CassandraReader {
        static SimpleDateFormat dateformatter = new SimpleDateFormat("yyyy/MM/dd");
-       private static Logger log = Logger.getLogger(CassandraNativeConnector.class);
 
-       public CassandraRemover() {
-               Session inis = CassandraNativeConnector.getSession();
-               setSession(inis);
-       }
+       /**
+        * private method for real deleting one job
+        * 
+        * @param jobid
+        *            job ID
+        * @param date
+        *            job execution date
+        * 
+        * @return nothing
+        */
+       private int RemoveJob(String jobid, long date) {
 
-       public void setSession(Session s) {
-               assert s != null;
-               session = s;
-       }
+               if (date < 0L) {
+                       log.error("CassandraRemover error: job " + jobid + " with date " + date
+                                       + " can not be deleted in JobDateInfo. Daily statistics is inconsistent");
+                       return 0;
+               }
 
-       /*
-        * delete a record from CF for current jobId
-        */
-       private void RemoveJob(String jobid, long date) {
                String status = FindStatus(jobid);
-               String com0 = "DELETE FROM ProteinLog WHERE JobID = '" + jobid + "';";
-               System.out.println("Command: " + com0);
-               session.execute(com0);
-               String com3 = "UPDATE jpredarchive SET finalstatus = 'DELETED'  WHERE JobID = '" + jobid + "' ;";
+               String com1 = "DELETE FROM ProteinLog WHERE JobID = '" + jobid + "';";
+               System.out.println("Command: " + com1);
+               CassandraQuery(com1);
+
+               String com2 = "UPDATE jpredarchive SET finalstatus = 'DELETED'  WHERE JobID = '" + jobid + "' ;";
+               System.out.println("Command: " + com2);
+               CassandraQuery(com2);
+
+               String com3 = "SELECT * FROM JobDateInfo WHERE jobday = " + date + ";";
                System.out.println("Command: " + com3);
-               session.execute(com3);
-               String com = "SELECT * FROM JobDateInfo WHERE jobday = " + date + ";";
-               System.out.println("Command: " + com);
-               ResultSet results = session.execute(com);
+               ResultSet results = CassandraQuery(com3);
+               if (results.isExhausted()) {
+                       log.error("CassandraRemover error: job " + jobid + " with date " + date
+                                       + " can not be deleted in JobDateInfo. Daily statistics is inconsistent");
+                       return 0;
+               }
                Row row = results.one();
                long njobs = row.getLong("Total") - 1;
                if (status.equals("OK")) {
                        long njobsOK = row.getLong("TotalOK") - 1;
-                       String com1 = "DELETE FROM ProteinRow WHERE JobID = '" + jobid + "';";
-                       System.out.println("Command: " + com1);
-                       session.execute(com1);
-                       String com2 = "DELETE FROM ProteinData WHERE JobID = '" + jobid + "' AND jobtime = " + date + ";";
-                       System.out.println("Command: " + com2);
-                       session.execute(com2);
+                       String com4 = "DELETE FROM ProteinRow WHERE JobID = '" + jobid + "';";
+                       System.out.println("Command: " + com4);
+                       CassandraQuery(com4);
+
+                       String com5 = "DELETE FROM ProteinData WHERE JobID = '" + jobid + "' AND jobtime = " + date + ";";
+                       System.out.println("Command: " + com5);
+                       CassandraQuery(com5);
                        UpdateJobDateInfo(date, "TotalOK", njobsOK, njobs);
                } else {
                        String com6 = "DELETE FROM FailLog WHERE JobID = '" + jobid + "' AND jobtime = " + date + ";";
                        System.out.println("Command: " + com6);
-                       session.execute(com6);
+                       CassandraQuery(com6);
                        if (status.equals("STOPPED")) {
                                long njobsStopped = row.getLong("TotalStopped") - 1;
                                UpdateJobDateInfo(date, "TotalStopped", njobsStopped, njobs);
@@ -69,132 +86,166 @@ public class CassandraRemover {
                                UpdateJobDateInfo(date, "TotalTimeOut", njobsTimeOut, njobs);
                        }
                }
-               System.out.println("Remove jobs: " + jobid);
+               System.out.println("Job " + jobid + " removed...");
+               return 1;
        }
 
+       /**
+        * update a pariticular column in the JobDateInfo table
+        * 
+        * @param jobid
+        *            job ID
+        * 
+        * @return nothing
+        * 
+        */
        private void UpdateJobDateInfo(long date, String ColumnName, long totalcol, long total) {
-               String com4 = "UPDATE JobDateInfo SET " + ColumnName + " = " + totalcol + ", Total = " + total + " WHERE jobday = " + date + ";";
-               System.out.println("Command: " + com4);
-               session.execute(com4);
+               String com = "UPDATE JobDateInfo SET " + ColumnName + " = " + totalcol + ", Total = " + total + " WHERE jobday = " + date + ";";
+               System.out.println("Command: " + com);
+               CassandraQuery(com);
        }
 
+       /**
+        * external method for deleting job with given job ID (strategy 1)
+        * 
+        * @param jobid
+        *            job ID
+        * 
+        * @return a number of deleted jobs
+        * 
+        */
        public int RemoveJobById(String jobid) {
                if (jobid == null)
                        return 0;
-               Long date = FindDate(jobid);
-               RemoveJob(jobid, date);
-               return 1;
+               long date = FindJobDate(jobid);
+               return RemoveJob(jobid, date);
        }
 
+       /**
+        * external method for deleting jobs within a time range (strategy 4)
+        * 
+        * @param date1
+        *            starting date
+        * 
+        * @param date2
+        *            ending date
+        * 
+        * @return a number of deleted jobs
+        * 
+        */
        public int RemoveJobByDate(String date1, String date2) {
-               int numremover = 0;
                if (date1 == null || date2 == null)
                        return 0;
+
+               int njobs = 0;
                Long dateBegin = convertDate(date1);
                Long dateEnd = convertDate(date2);
                Calendar start = Calendar.getInstance();
                start.setTime(new Date(dateBegin));
                Calendar end = Calendar.getInstance();
                end.setTime(new Date(dateEnd));
+
                for (Date date = start.getTime(); !start.after(end); start.add(Calendar.DATE, 1), date = start.getTime()) {
-                       System.out.println("--------------------------------------------------------------------: ");
-                       String com = "SELECT JobID FROM ProteinData WHERE jobtime = " + date.getTime() + ";";
-                       System.out.println("Command: " + com);
-                       ResultSet results = session.execute(com);
+                       String com1 = "SELECT JobID FROM ProteinData WHERE jobtime = " + date.getTime() + ";";
+                       System.out.println("Command: " + com1);
+                       ResultSet results = CassandraQuery(com1);
                        if (!results.isExhausted()) {
                                List<Row> rows = results.all();
                                for (Row r : rows) {
                                        String jobid = r.getString("JobID");
                                        if (jobid != null) {
-                                               RemoveJob(jobid, date.getTime());
-                                               numremover++;
+                                               njobs += RemoveJob(jobid, date.getTime());
                                        }
                                }
                        }
-                       String comm = "SELECT JobID FROM FailLog WHERE jobtime = " + date.getTime() + ";";
-                       ResultSet resultsfail = session.execute(comm);
+
+                       String com2 = "SELECT JobID FROM FailLog WHERE jobtime = " + date.getTime() + ";";
+                       ResultSet resultsfail = CassandraQuery(com2);
                        if (!resultsfail.isExhausted()) {
                                List<Row> rows = resultsfail.all();
                                for (Row r : rows) {
                                        String jobid = r.getString("JobID");
                                        if (jobid != null) {
-                                               RemoveJob(jobid, date.getTime());
-                                               numremover++;
+                                               njobs += RemoveJob(jobid, date.getTime());
                                        }
                                }
                        }
                }
-               return numremover;
+               return njobs;
        }
 
+       /**
+        * external method for deleting jobs launched from a particular IP (strategy
+        * 2)
+        * 
+        * @param ip
+        *            the IP
+        * 
+        * @return a number of deleted jobs
+        * 
+        */
        public int RemoveJobByIp(String ip) {
-               int numremover = 0;
+               int njobs = 0;
                if (ip == null)
                        return 0;
                String com = "SELECT databegin, JobID FROM ProteinLog WHERE ip = '" + ip + "';";
-               ResultSet results = session.execute(com);
+               ResultSet results = CassandraQuery(com);
                if (!results.isExhausted()) {
                        List<Row> rows = results.all();
                        for (Row r : rows) {
                                Long date = convertDate(r.getString("databegin"));
                                String jobid = r.getString("JobID");
-                               if (date == null || jobid == null)
-                                       continue;
-                               RemoveJob(jobid, date);
-                               numremover++;
+                               if (date != null || jobid != null) {
+                                       njobs += RemoveJob(jobid, date);
+                               }
                        }
                }
-               return numremover;
+               return njobs;
        }
 
-       public int RemoveJobBySequence(String seq) {
-               int numremover = 0;
-               if (seq == null)
+       /**
+        * external method for deleting jobs with a protein sequence (strategy 3)
+        * 
+        * @param sequence
+        *            the sequence
+        * 
+        * @return a number of deleted jobs
+        * 
+        */
+       public int RemoveJobBySequence(String sequence) {
+               int njobs = 0;
+               if (sequence == null)
                        return 0;
-               String com = "SELECT JobID FROM ProteinRow WHERE Protein = '" + seq + "';";
-               ResultSet results = session.execute(com);
+               String com = "SELECT JobID FROM ProteinRow WHERE Protein = '" + sequence + "';";
+               ResultSet results = CassandraQuery(com);
                if (!results.isExhausted()) {
                        List<Row> rows = results.all();
                        for (Row r : rows) {
                                String jobid = r.getString("JobID");
-                               Long date = FindDate(jobid);
-                               RemoveJob(jobid, date);
-                               numremover++;
+                               long date = FindJobDate(jobid);
+                               njobs += RemoveJob(jobid, date);
                        }
                }
-               return numremover;
+               return njobs;
        }
 
-       private Long FindDate(String jobid) {
+       private long FindJobDate(String jobid) {
                String com = "SELECT databegin FROM ProteinLog WHERE JobID = '" + jobid + "';";
-               ResultSet results = session.execute(com);
-               Long date = convertDate(results.one().getString("databegin"));
-               return date;
+               ResultSet results = CassandraQuery(com);
+               if (!results.isExhausted()) {
+                       return convertDate(results.one().getString("databegin"));
+               }
+               return -1L;
        }
 
        private String FindStatus(String jobid) {
-               String status = "UNKNOWN";
-               String command = "SELECT FinalStatus FROM ProteinLog WHERE JobID = '" + jobid + "';";
-               try {
-                       System.out.println("Command: " + command);
-                       ResultSet results = session.execute(command);
-                       Row raw = results.one();
-                       if (null != raw) {
-                               status = raw.getString("FinalStatus");
-                       }
-               } catch (QueryExecutionException e) {
-                       String mess = "CassandraRemover: query execution exception...";
-                       System.out.println(mess);
-                       log.error(mess);
-                       log.error(e.getLocalizedMessage(), e.getCause());
-               } catch (QueryValidationException e) {
-                       String mess = "CassandraRemover: query validation exception... Command: " + command;
-                       System.out.println(mess);
-                       log.error(mess);
-                       log.error(e.getLocalizedMessage(), e.getCause());
+               String com = "SELECT FinalStatus FROM ProteinLog WHERE JobID = '" + jobid + "';";
+               System.out.println("Command: " + com);
+               ResultSet results = CassandraQuery(com);
+               if (!results.isExhausted()) {
+                       return results.one().getString("FinalStatus");
                }
-               System.out.println("*****status: " + status);
-               return status;
+               return "UNKNOWN";
        }
 
        protected long convertDate(String d) {
index e741b39..6ced180 100644 (file)
@@ -1,8 +1,6 @@
 package compbio.cassandra;
 
 import java.util.List;
-import java.util.ArrayList;
-import java.util.Collections;
 
 import compbio.beans.JobBean;
 import compbio.beans.ProteinBean;
index e2e5dc9..c89fe59 100644 (file)
@@ -2,11 +2,8 @@ package compbio.cassandra;
 
 import java.io.BufferedReader;
 import java.io.File;
-import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStreamReader;
-import java.net.HttpURLConnection;
-import java.net.MalformedURLException;
 import java.io.FileInputStream;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
@@ -19,7 +16,6 @@ import compbio.data.sequence.FastaReader;
 import compbio.data.sequence.FastaSequence;
 
 public class JpredParserLocalFile implements JpredParser {
-       private CassandraWriter cw = new CassandraWriter();
        private String dirprefix;
 
        public void setSource(String newsourceprefix) {
@@ -75,8 +71,6 @@ public class JpredParserLocalFile implements JpredParser {
                        if (in.matches(date + ":(.*)jp_[^\\s]+")) {
                                String[] table = in.split("\\s+");
                                String starttime = table[0];
-                               String finishtime = table[1];
-                               String ip = table[2];
                                String id = table[table.length - 1];
                                totalcount++;
                                String confilename = dirprefix + "/" + id + "/" + id + ".concise";
@@ -99,10 +93,8 @@ public class JpredParserLocalFile implements JpredParser {
                                                } else {
                                                        SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd");
                                                        String dateInString1 = starttime.substring(0, starttime.indexOf(":"));
-                                                       long insertdate = 0;
                                                        try {
                                                                Date dat = formatter.parse(dateInString1);
-                                                               insertdate = dat.getTime();
                                                        } catch (ParseException e) {
                                                                e.printStackTrace();
                                                        }
index b0d71d4..f970659 100644 (file)
@@ -10,8 +10,8 @@ import com.datastax.driver.core.exceptions.QueryValidationException;
 import compbio.cassandra.CassandraNativeConnector;
 
 public class CassandraReader {
-       private static long earlestDate = 0;
-       private Session session;
+       protected static long earlestDate = 0;
+       protected Session session;
        protected static Logger log = Logger.getLogger(CassandraNativeConnector.class);
 
        public CassandraReader() {
@@ -29,13 +29,13 @@ public class CassandraReader {
                        ResultSet results = session.execute(command);
                        return results;
                } catch (QueryExecutionException e) {
-                       String mess = "CassandraUserManagerImpl.findAllUsers: query execution exception...";
+                       String mess = "ProteoCache Cassandra DB interface: query execution exception...\n   Command: " + command;
                        System.out.println(mess);
                        log.error(mess);
                        log.error(e.getLocalizedMessage(), e.getCause());
                        return null;
                } catch (QueryValidationException e) {
-                       String mess = "CassandraUserManagerImpl.findAllUsers: query validation exception... Command: " + command;
+                       String mess = "CProteoCache Cassandra DB interface: query validation exception...\n   Command: " + command;
                        System.out.println(mess);
                        log.error(mess);
                        log.error(e.getLocalizedMessage(), e.getCause());
index 134a139..32bea66 100644 (file)
@@ -8,7 +8,7 @@ import com.datastax.driver.core.Row;
 import com.datastax.driver.core.Session;
 import com.datastax.driver.core.ResultSet;
 
-import compbio.cassandra.Pair;
+import compbio.engine.Pair;
 
 public class CassandraReaderExecutionTime {
        private Session session;
@@ -22,10 +22,6 @@ public class CassandraReaderExecutionTime {
                session = s;
        }
 
-       private void setConditions() {
-
-       }
-
        public boolean JobisNotInsterted(String jobid) {
                ResultSet results1 = session.execute("SELECT * FROM ProteinLog WHERE JobID = '" + jobid + "';");
                if (results1.isExhausted()) {
index bca4666..d019c35 100644 (file)
@@ -11,7 +11,7 @@ import compbio.beans.DateBean;
 import compbio.beans.ExecutionTimeBean;
 import compbio.beans.TotalExecutionTime;
 import compbio.cassandra.DateFormatter;
-import compbio.cassandra.Pair;
+import compbio.engine.Pair;
 
 public class ExecutionTimeReader extends CassandraReader {
 
index a525a56..26a40e6 100644 (file)
@@ -23,14 +23,30 @@ public class JobReader extends CassandraReader {
                ResultSet results = CassandraQuery("SELECT * FROM ProteinLog WHERE JobID = '" + jobid + "';");
                if (results.isExhausted())
                        return null;
-               Row row = results.one();
+               Row row1 = results.one();
                ResultSet results1 = CassandraQuery("SELECT * FROM ProteinRow WHERE JobID = '" + jobid + "' ALLOW FILTERING;");
                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), row.getString("ProgramName"),
-                               row.getString("ProgramVersion"));
+               Row row2 = results1.one();
+               String program = row1.getString("ProgramName");
+               String version = row1.getString("ProgramVersion");
+               JobBean res = new JobBean(row1.getString("Protein"), row1.getString("JobID"), row1.getString("DataBegin"),
+                               row1.getString("DataEnd"), row1.getString("ip"), row2.getMap("Predictions", String.class, String.class));
+
+               if (null != program && null != version) {
+                       res.setProgramName(program);
+                       res.setProgramVersion(version);
+                       ResultSet results3 = CassandraQuery("SELECT * FROM Programs WHERE Program = '" + program + "' and Version = '" + version
+                                       + "' ALLOW FILTERING;");
+                       if (results3.isExhausted())
+                               return null;
+                       Row row3 = results3.one();
+                       String link = row3.getString("weblink");
+                       if (null != link) {
+                               res.setProgramLink(link);
+                       }
+               }
+
                return res;
        }
 }
index 0aedbb2..7e77126 100644 (file)
@@ -8,6 +8,16 @@ import com.datastax.driver.core.Row;
 
 import compbio.beans.ProteinBean;
 
+/**
+ * Reader class for making requests on protein sequences to cassandra.
+ * 
+ * @author Alexander Sherstnev
+ * @author Natasha Sherstneva
+ * 
+ * @since 0.5
+ * @version 1.0 
+ * @since December 2013
+ */
 public class SequenceReader extends CassandraReader {
 
        public SequenceReader() {
@@ -17,7 +27,7 @@ public class SequenceReader extends CassandraReader {
        /**
         * query: protein sequence
         * 
-        * @param protIn
+        * @param sequence
         *            protein sequence or partial of protein sequence
         * @param searchtype
         *            "whole" or "partial" of protein sequence
@@ -25,35 +35,35 @@ public class SequenceReader extends CassandraReader {
         * @return List<ProteinBean> to the controller SequenceController
         * 
         **/
-       public List<ProteinBean> readProteins(String protIn, String searchtype) {
+       public List<ProteinBean> readProteins(String sequence, String searchtype) {
                List<ProteinBean> query = new ArrayList<ProteinBean>();
                if (searchtype.equals("whole")) {
-                       ResultSet results = CassandraQuery("SELECT  JobID, Predictions FROM ProteinRow WHERE Protein = '" + protIn + "';");
+                       ResultSet results = CassandraQuery("SELECT JobID, Predictions FROM ProteinRow WHERE Protein = '" + sequence + "';");
                        if (results.isExhausted())
                                return null;
                        List<Row> rows = results.all();
-                       ProteinBean structure = new ProteinBean(protIn, rows.get(0).getMap("Predictions", String.class, String.class));
+                       ProteinBean structure = new ProteinBean(sequence, rows.get(0).getMap("Predictions", String.class, String.class));
                        for (Row r : rows) {
                                structure.setJobid(r.getString("JobID"));
                        }
                        query.add(structure);
                } else {
-                       ResultSet results = CassandraQuery("SELECT  * FROM ProteinRow;");
+                       ResultSet results = CassandraQuery("SELECT * FROM ProteinRow;");
                        if (results.isExhausted())
                                return null;
                        List<Row> rows = results.all();
                        for (Row r : rows) {
-                               String prot = r.getString("Protein");
-                               if (prot.matches("(.*)" + protIn + "(.*)")) {
-                                       ProteinBean structure = new ProteinBean(prot, r.getMap("Predictions", String.class, String.class));
-                                       structure.setJobid(r.getString("JobID"));
-                                       query.add(structure);
+                               String protein = r.getString("Protein");
+                               if (protein.matches("(.*)" + sequence + "(.*)")) {
+                                       ProteinBean foundsequence = new ProteinBean(protein, r.getMap("Predictions", String.class, String.class));
+                                       foundsequence.setJobid(r.getString("JobID"));
+                                       query.add(foundsequence);
                                }
                        }
                }
                if (searchtype.equals("partial")) {
                        for (ProteinBean entry : query) {
-                               entry.setSubProt(CreateSubprotein(entry.getSequence(), protIn));
+                               entry.setSubProt(CreateSubprotein(entry.getSequence(), sequence));
                        }
                }
                return query;
index 522ad9f..99981e4 100644 (file)
@@ -17,7 +17,6 @@ public class JpredJob extends Job {
 
        public JpredJob(String jobid, String date1, String date2) {
                super(jobid, date1, date2);
-               this.protein = protein;
                predictions = new ArrayList<FastaSequence>();
                alignment = new ArrayList<FastaSequence>();
                log = "";
@@ -25,7 +24,6 @@ public class JpredJob extends Job {
 
        public JpredJob(String jobid, String date1, String date2, List<FastaSequence> alignment, List<FastaSequence> predictions) {
                super(jobid, date1, date2);
-               this.protein = protein;
                this.alignment = alignment;
                this.predictions = predictions;
        }
similarity index 93%
rename from datadb/compbio/cassandra/Pair.java
rename to engine/compbio/engine/Pair.java
index d942fea..efd24c7 100644 (file)
@@ -1,4 +1,4 @@
-package compbio.cassandra;
+package compbio.engine;
 
 public class Pair<K, V> {
 
index 2612360..5c20236 100644 (file)
@@ -12,7 +12,9 @@ import compbio.cassandra.DateFormatter;
 import compbio.cassandra.readers.CassandraReader;
 
 /**
- * 
+ * ProteoCache Basic controller. All other controllers should inherit this
+ * controller. Currently BasicController provides user role checks and some
+ * global dates for the system (current and the earliest date of executing job)
  * 
  * @author Alexander Sherstnev
  * @version 1.0
@@ -21,10 +23,13 @@ import compbio.cassandra.readers.CassandraReader;
 public class BasicController {
        final protected SimpleDateFormat formaterDDMMYY = DateFormatter.getFormatDDMMYY();
        final protected SimpleDateFormat formaterYYMMDD = DateFormatter.getFormatYYMMDD();
-       protected Calendar cal = Calendar.getInstance();
-       protected String theEaerlistDate = DateFormatter.DateLongToString(CassandraReader.earliestDate(), formaterYYMMDD);
-       protected String theCurrentDate = cal.get(Calendar.YEAR) + "/" + (cal.get(Calendar.MONTH) + 1) + "/" + cal.get(Calendar.DAY_OF_MONTH);
 
+       /**
+        * give the user (principal) name
+        * 
+        * @return the user name. If the user uses LDAP credentials LDAP prefix is
+        *         set
+        */
        protected String getPrincipalName() {
                Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
                if (principal instanceof UserDetails) {
@@ -42,6 +47,12 @@ public class BasicController {
                return principal.toString();
        }
 
+       /**
+        * check whether the current user has standard user permissions (ROLE_USER
+        * or ROLE_LDAP_USER)
+        * 
+        * @return true if this is a ROLE_USER/ROLE_LDAP_USER user, false otherwise
+        */
        protected boolean isUserRole() {
                Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
                if (principal instanceof UserDetails) {
@@ -57,6 +68,11 @@ public class BasicController {
                return false;
        }
 
+       /**
+        * check whether the current user has administrator permissions (ROLE_ADMIN)
+        * 
+        * @return true if this is a ROLE_ADMIN user, false otherwise
+        */
        protected boolean isAdminRole() {
                Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
                if (principal instanceof UserDetails) {
@@ -72,20 +88,57 @@ public class BasicController {
                return false;
        }
 
-       protected String DateChecking(String trimmeddate1, String trimmeddate2, long longDate1, long longDate2) {
+       /**
+        * check whether provided dates are ordered properly and within permitted
+        * time range
+        * 
+        * @param date1
+        *            early limit of the time range)
+        * 
+        *            * @param date2 late limit of the time range)
+        * 
+        *            * @param longDate1 date 1 in the numerical represenation (in
+        *            milliseconds)
+        * 
+        *            * @param longDate2 date 2 in the numerical represenation (in
+        *            milliseconds)
+        * 
+        * @return true if these dates are correct, false otherwise
+        */
+       protected String checkDates(String date1, String date2, long longDate1, long longDate2) {
                Calendar cal2 = Calendar.getInstance();
-               if (trimmeddate1.equalsIgnoreCase("") || trimmeddate2.equalsIgnoreCase(""))
-                       return "The date cann't be empty";
-               else if (!DateFormatter.isThisDateValid(trimmeddate1, formaterYYMMDD)
-                               || !DateFormatter.isThisDateValid(trimmeddate2, formaterYYMMDD))
-                       return "The date format in invalid. Try format yyyy/mm/dd";
+               if (date1.equalsIgnoreCase("") || date2.equalsIgnoreCase(""))
+                       return "The date can not be empty strinfs";
+               else if (!DateFormatter.isThisDateValid(date1, formaterYYMMDD) || !DateFormatter.isThisDateValid(date2, formaterYYMMDD))
+                       return "The date format in invalid. The format yyyy/mm/dd should be used";
                else if (longDate2 < CassandraReader.earliestDate())
-                       return "The date2 is after the earlestDate " + theEaerlistDate;
+                       return "The date2 is earlier than the earliest date in the system " + getEarliestDate();
                else if (longDate1 > cal2.getTimeInMillis())
-                       return "The date1 is before the current date " + theCurrentDate;
+                       return "The date1 is later than the current date " + getCurrentDate();
                else if (longDate1 > longDate2)
-                       return "Wrong date's diaposon. The date1 is more than date2.";
-               else
-                       return null;
+                       return "Wrong date range. The date1 is later than date2.";
+
+               return null;
+       }
+
+       /**
+        * gives the current date in the form of string (yyyy/mm/dd)
+        * 
+        * @return the current date
+        */
+       protected String getCurrentDate() {
+               Calendar cal = Calendar.getInstance();
+               String date = cal.get(Calendar.YEAR) + "/" + (cal.get(Calendar.MONTH) + 1) + "/" + cal.get(Calendar.DAY_OF_MONTH);
+               return date;
+       }
+
+       /**
+        * gives the earliest date in the system (through a direct call of a
+        * Cassandra related class) in the form of string (yyyy/mm/dd)
+        * 
+        * @return the current date
+        */
+       protected String getEarliestDate() {
+               return DateFormatter.DateLongToString(CassandraReader.earliestDate(), formaterYYMMDD);
        }
 }
index 5d183f9..1453523 100644 (file)
@@ -20,9 +20,13 @@ import compbio.cassandra.readers.CassandraReader;
 import compbio.cassandra.readers.DailyStatisticsReader;
 
 /**
+ * MVC controller for collecting and showing job statistics
+ * 
  * @author Alexander Sherstnev
  * @author Natasha Sherstneva
- * @version 1.0 Dec 2013
+ * 
+ * @version 1.0
+ * @since Dec 2013
  */
 @Controller
 public class DailyStatisticsController extends BasicController {
@@ -76,8 +80,8 @@ public class DailyStatisticsController extends BasicController {
                final long startTime = System.currentTimeMillis();
                DailyStatisticsReader reader = new DailyStatisticsReader();
                if (option.equals("AllDates,off")) {
-                       date1 = theEaerlistDate;
-                       date2 = theCurrentDate;
+                       date1 = getEarliestDate();
+                       date2 = getCurrentDate();
                }
 
                // dates in string format
@@ -86,7 +90,7 @@ public class DailyStatisticsController extends BasicController {
                // dates in long format
                long longDate1 = DateFormatter.DateParsing(date1, formaterYYMMDD);
                long longDate2 = DateFormatter.DateParsing(date2, formaterYYMMDD);
-               String error = DateChecking(trimmeddate1, trimmeddate2, longDate1, longDate2);
+               String error = checkDates(trimmeddate1, trimmeddate2, longDate1, longDate2);
                if (error != null) {
                        model.put("error", error);
                        model.put("date1", date1);
@@ -151,10 +155,9 @@ public class DailyStatisticsController extends BasicController {
                        thetime = formaterDDMMYY.parse(realdate).getTime();
                }
 
-               if (null == JobStatus.getJobStatus(status)) 
+               if (null == JobStatus.getJobStatus(status))
                        return "support/Notimplemented";
 
-
                DailyStatisticsReader reader = new DailyStatisticsReader();
                // IMPORTANT: input should be suppied in the format: DD/MM/YYYY
                DateBean r = reader.readJobByDay(thetime, realdate, JobStatus.getJobStatus(status));
index e720a2c..c7d6155 100644 (file)
@@ -12,8 +12,13 @@ import compbio.cassandra.CassandraRemover;
 import compbio.cassandra.DateFormatter;
 
 /**
+ * MVC controller for direct interaction with the internal DB
+ * 
  * @author Alexander Sherstnev
  * @author Natasha Sherstneva
+ * 
+ * @version 1.0
+ * @since Nov 2013
  */
 @Controller
 public class DatabaseController extends BasicController {
@@ -63,21 +68,27 @@ public class DatabaseController extends BasicController {
                model.put("seq", sequence);
 
                CassandraRemover cr = new CassandraRemover();
-               int njobs = 0;
+               int njobs1 = 0;
+               int njobs2 = 0;
+               int njobs3 = 0;
+               int njobs4 = 0;
                if (byId.equals("on,off"))
-                       njobs = cr.RemoveJobById(jobid);
+                       njobs1 = cr.RemoveJobById(jobid);
                if (byDate.equals("on,off")) {
                        long longDate1 = DateFormatter.DateParsing(date1, formaterYYMMDD) / 1000;
                        long longDate2 = DateFormatter.DateParsing(date2, formaterYYMMDD) / 1000;
                        int timerange = (int)(longDate2 - longDate1) /24 / 3600 + 1;
                        model.put("ndays", timerange);
-                       njobs = cr.RemoveJobByDate(date1, date2);
+                       njobs2 = cr.RemoveJobByDate(date1, date2);
                }
                if (byIp.equals("on,off"))
-                       njobs = cr.RemoveJobByIp(ip);
+                       njobs3 = cr.RemoveJobByIp(ip);
                if (bySequence.equals("on,off"))
-                       njobs = cr.RemoveJobBySequence(sequence);
-               model.put("njobs", njobs);
+                       njobs4 = cr.RemoveJobBySequence(sequence);
+               model.put("njobs", njobs1 + njobs2 + njobs3 + njobs4);
+               model.put("njobsbyDate", njobs2);
+               model.put("njobsbyIP", njobs3);
+               model.put("njobsbySeq", njobs4);
 
                return "reports/RemoveJobs";
        }
index 732d07d..f05234e 100644 (file)
@@ -4,10 +4,8 @@ import java.io.IOException;
 import java.net.HttpURLConnection;
 import java.net.URL;
 import java.text.ParseException;
-import java.text.SimpleDateFormat;
 import java.util.Calendar;
 import java.util.Date;
-import java.util.List;
 import java.util.Map;
 
 import org.apache.log4j.Logger;
@@ -18,23 +16,23 @@ import org.springframework.web.bind.annotation.RequestParam;
 
 import compbio.beans.DateBean;
 import compbio.beans.ExecutionTimeBean;
-import compbio.beans.Total;
+import compbio.beans.JobBean;
 import compbio.beans.TotalExecutionTime;
-import compbio.beans.TotalJobsStatisticBean;
-import compbio.cassandra.DataBase;
 import compbio.cassandra.DateFormatter;
 import compbio.cassandra.readers.CassandraReader;
-import compbio.cassandra.readers.DailyStatisticsReader;
 import compbio.cassandra.readers.ExecutionTimeReader;
 import compbio.cassandra.readers.JobReader;
 import compbio.engine.ExecutionInterval;
-import compbio.engine.JobStatus;
 import compbio.engine.archive.ArchivedJob;
 
 /**
+ * Spring controller for supporting job queries. This version works in the
+ * servlet style.
+ * 
  * @author Alexander Sherstnev
  * @author Natasha Sherstneva
- * @version 1.0 Dec 2013
+ * @version 1.0
+ * @since Dec 2013
  */
 @Controller
 public class JobController extends BasicController {
@@ -83,36 +81,42 @@ public class JobController extends BasicController {
        /**
         * form a report page for a job execution time statistics.
         * 
+        * @param date1
+        *            initial date for requested statistics
+        * @param date2
+        *            final date for requested statistics
+        * @param alldates
+        *            All available jobs are analyzed if alldates="AllDates,off"
         * @param model
         *            MVC model
         * @return link to the JSP query page
         */
        @RequestMapping(value = "/stat/exectime/results", method = RequestMethod.GET)
        public String findExecTimeData(@RequestParam("date1") String date1, @RequestParam("date2") String date2,
-                       @RequestParam(value = "option", required = false) String option, Map<String, Object> model) {
+                       @RequestParam(value = "option", required = false) String alldates, Map<String, Object> model) {
                model.put("username", getPrincipalName());
                final long startTime = System.currentTimeMillis();
                Calendar loccal = Calendar.getInstance();
                ExecutionTimeReader reader = new ExecutionTimeReader();
-               if (option.equals("AllDates,off")) {
-                       date1 = theEaerlistDate;
-                       date2 = theCurrentDate;
+               if (alldates.equals("AllDates,off")) {
+                       date1 = getEarliestDate();
+                       date2 = getCurrentDate();
                }
-               
+
                // dates in string format
                String trimmeddate1 = date1.replaceAll("\\s", "");
                String trimmeddate2 = date2.replaceAll("\\s", "");
                // dates in long format
                long longDate1 = DateFormatter.DateParsing(date1, formaterYYMMDD);
                long longDate2 = DateFormatter.DateParsing(date2, formaterYYMMDD);
-               String error = DateChecking(trimmeddate1, trimmeddate2, longDate1, longDate2);
+               String error = checkDates(trimmeddate1, trimmeddate2, longDate1, longDate2);
                if (error != null) {
                        model.put("error", error);
                        model.put("date1", date1);
                        model.put("date2", date2);
                        return "query/JobTimeExecution";
                }
-               
+
                if (longDate1 < CassandraReader.earliestDate())
                        longDate1 = CassandraReader.earliestDate();
                if (longDate2 > loccal.getTimeInMillis())
@@ -122,20 +126,21 @@ public class JobController extends BasicController {
                date2 = DateFormatter.DateLongToString(longDate2, formaterYYMMDD);
                model.put("date1", date1);
                model.put("date2", date2);
-               model.put("option", option);
-               ExecutionTimeBean res = reader.query(longDate1, longDate2);;
+               model.put("option", alldates);
+               ExecutionTimeBean res = reader.query(longDate1, longDate2);
+               ;
                model.put("result", res);
                Map<String, TotalExecutionTime> results = res.getDateTotal();
-               String csvline = "";
+               StringBuilder csvline = new StringBuilder("");
                if (0 < res.getDateTotal().size()) {
-                       csvline = "\'Date\',\'Total\',\'0-30 sec\',\'30-60 sec\',\'1-2 min\',\'2-10 min\',\'more 10 min\'%0A";
+                       csvline.append("\'Date\',\'Total\',\'0-30 sec\',\'30-60 sec\',\'1-2 min\',\'2-10 min\',\'more 10 min\'%0A");
                        for (Map.Entry<String, TotalExecutionTime> entry : results.entrySet()) {
-                               csvline += "\'" + entry.getKey() + "\',\'" + entry.getValue().getTotal() + "\',\'" + entry.getValue().getTotal0_30s() + "\',\'"
-                                               + entry.getValue().getTotal30_60s() + "\',\'" + entry.getValue().getTotal1_2m() + "\',\'"
-                                               + entry.getValue().getTotal2_10m() + "\',\'" + entry.getValue().getTotal10m() + "\'%0A";
+                               csvline.append("\'" + entry.getKey() + "\',\'" + entry.getValue().getTotal() + "\',\'" + entry.getValue().getTotal0_30s()
+                                               + "\',\'" + entry.getValue().getTotal30_60s() + "\',\'" + entry.getValue().getTotal1_2m() + "\',\'"
+                                               + entry.getValue().getTotal2_10m() + "\',\'" + entry.getValue().getTotal10m() + "\'%0A");
                        }
                }
-               model.put("csvfile", csvline);
+               model.put("csvfile", csvline.toString());
                model.put("ndays", res.getDateTotal().size() - 1);
                final long endTime = System.currentTimeMillis();
                model.put("timeExecution", (endTime - startTime));
@@ -176,7 +181,6 @@ public class JobController extends BasicController {
                if (null == ExecutionInterval.getExecutionInterval(interval)) 
                        return "support/Notimplemented";
 
-
                ExecutionTimeReader reader = new ExecutionTimeReader();
                // IMPORTANT: input should be suppied in the format: DD/MM/YYYY
                DateBean r = reader.readJobByDay(thetime, realdate, ExecutionInterval.getBoundsInterval(interval));
@@ -191,11 +195,13 @@ public class JobController extends BasicController {
        }
 
        /**
-        * form a query page for a job. The servlet should no be visible to users at
-        * all.
+        * form result page for one job with a given job ID.
         * 
+        * @param jobid
+        *            job ID
         * @param model
         *            MVC model
+        * 
         * @return link to the JSP query page
         * @throws IOException
         */
@@ -204,11 +210,17 @@ public class JobController extends BasicController {
                model.put("username", getPrincipalName());
                final long startTime = System.currentTimeMillis();
                JobReader reader = new JobReader();
-               model.put("result", reader.readJobLog(jobid));
+               JobBean job = reader.readJobLog(jobid);
+               if (null == job) {
+                       model.put("jobnotfound", "yes");
+               } else {
+                       model.put("result", job);
+               }
                final long endTime = System.currentTimeMillis();
                model.put("timeExecution", (endTime - startTime));
                model.put("IdJob", jobid);
 
+               // prepare archive file for the job for downloading
                ArchivedJob aj = new ArchivedJob(jobid);
                try {
                        model.put("jobarchive", aj.prepareJobArchiveToWeb());
@@ -216,6 +228,7 @@ public class JobController extends BasicController {
                        log.error("JobController.prepareJobArchiveToWeb: IO exception with job archive file");
                        log.error(e.getLocalizedMessage(), e.getCause());
                }
+
                // add a direct link to the job
                String remotelink = "http://www.compbio.dundee.ac.uk/www-jpred/results/" + jobid + "/" + jobid + ".results.html";
                URL remotelinkurl = new URL(remotelink);
@@ -226,18 +239,4 @@ public class JobController extends BasicController {
                return "reports/Job";
        }
 
-       /**
-        * convert date from the standard long representation (milliseconds from 1
-        * Jan 1970) to yyyy/mm/dd
-        * 
-        * @param indate
-        *            date in milliseconds from 1 Jan 1970
-        * @return date in the form of yyyy/mm/dd
-        */
-       private String DateFormatYYMMDD(long indate) {
-               SimpleDateFormat datformat = new SimpleDateFormat("yyyy/MM/dd");
-               String dateString = datformat.format(new Date(indate));
-               return dateString;
-       }
-
 }
index d555d36..d9e0cf0 100644 (file)
 package compbio.controllers;
 
+import java.util.Calendar;
+
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.ModelMap;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 
+import compbio.beans.Total;
+import compbio.beans.TotalJobsStatisticBean;
+import compbio.cassandra.DateFormatter;
+import compbio.cassandra.readers.DailyStatisticsReader;
+
+/**
+ * The main system controller with most general functionality (home page, login
+ * and logout pages)
+ * 
+ * @author Alexander Sherstnev
+ * @author Natasha Sherstneva
+ * 
+ * @version 1.0
+ * @since Dec 2013
+ */
 @Controller
 public class MainController extends BasicController {
 
+       /**
+        * Form the project home page
+        * 
+        * @param model
+        *            MVC model object
+        * 
+        * @return JSP template for the page
+        */
        @RequestMapping(value = "/index", method = RequestMethod.GET)
        public String printPublicHome(ModelMap model) {
                model.addAttribute("username", getPrincipalName());
+               model = getStatistics(model);
                if (isUserRole())
                        return "home";
                return "public";
        }
 
+       /**
+        * Form login page
+        * 
+        * @param model
+        *            MVC model object
+        * 
+        * @return JSP template for the page
+        */
        @RequestMapping(value = "/login", method = RequestMethod.GET)
        public String login(ModelMap model) {
                return "login";
        }
 
+       /**
+        * Form a page with failed login
+        * 
+        * @param model
+        *            MVC model object
+        * 
+        * @return JSP template for the page
+        */
        @RequestMapping(value = "/loginfailed", method = RequestMethod.GET)
        public String loginerror(ModelMap model) {
                model.addAttribute("error", "Wrong user name or password");
                return "login";
        }
 
+       /**
+        * Form a page after log out
+        * 
+        * @param model
+        *            MVC model object
+        * 
+        * @return JSP template for the page
+        */
        @RequestMapping(value = "/logout", method = RequestMethod.GET)
        public String logout(ModelMap model) {
+               model = getStatistics(model);
                return "public";
        }
 
+       /**
+        * Form a page with denial of service
+        * 
+        * @param model
+        *            MVC model object
+        * 
+        * @return JSP template for the page
+        */
        @RequestMapping(value = "/denied", method = RequestMethod.GET)
        public String denied(ModelMap model) {
                model.put("username", getPrincipalName());
                return "support/Denied";
        }
 
+       /**
+        * Form the project home page
+        * 
+        * @param model
+        *            MVC model object
+        * 
+        * @return JSP template for the page
+        */
        @RequestMapping(value = "/home", method = RequestMethod.GET)
        public String printHome(ModelMap model) {
                model.addAttribute("username", getPrincipalName());
+               model = getStatistics(model);
                return "home";
        }
 
+       /**
+        * collect job execution statiustics for the last 7 days.
+        * 
+        * @param model
+        *            MVC model object
+        * 
+        * @return the the same model, but with additional parameters with the job
+        *         statistics
+        */
+       private ModelMap getStatistics(ModelMap model) {
+               int ndays = 7;
+               model.addAttribute("ndays", ndays);
+
+               Calendar cal = Calendar.getInstance();
+               String date2 = cal.get(Calendar.YEAR) + "/" + (cal.get(Calendar.MONTH) + 1) + "/" + cal.get(Calendar.DAY_OF_MONTH);
+               long longDate2 = DateFormatter.DateParsing(date2, formaterYYMMDD);
+               cal.add(Calendar.DATE, -ndays);
+               String date1 = cal.get(Calendar.YEAR) + "/" + (cal.get(Calendar.MONTH) + 1) + "/" + cal.get(Calendar.DAY_OF_MONTH);
+               long longDate1 = DateFormatter.DateParsing(date1, formaterYYMMDD);
+
+               DailyStatisticsReader reader = new DailyStatisticsReader();
+               TotalJobsStatisticBean res = reader.query(longDate1, longDate2);
+               Total total = res.getWholeTotal();
+               model.addAttribute("total", total.getTotal());
+               model.addAttribute("totalOK", total.getTotalOK());
+               model.addAttribute("totalTimeout", total.getTotalOK());
+               model.addAttribute("totalError", total.getTotalError());
+               model.addAttribute("totalStopped", total.getTotalStopped());
+               return model;
+       }
+
 }
index 6398eef..a961efe 100644 (file)
@@ -10,8 +10,8 @@ import org.springframework.web.bind.annotation.RequestParam;
 import compbio.cassandra.readers.FeaturesReader;
 
 /**
- * Spring controller for sequence queries. This version works in the servlet
- * style.
+ * Spring controller for protein secondary structure features. This version
+ * works in the servlet style.
  * 
  * @author Alexander Sherstnev
  * @author Natasha Sherstneva
@@ -23,6 +23,15 @@ import compbio.cassandra.readers.FeaturesReader;
 @RequestMapping("/features")
 public class SSFeaturesController extends BasicController {
 
+       /**
+        * form a query page for protein secondary structure feaatures: Proteins
+        * with given fraction of H/E (helix/beta sheets)
+        * 
+        * @param model
+        *            MVC model object
+        * 
+        * @return link to the report JSP page
+        */
        @RequestMapping(value = "query", method = RequestMethod.GET)
        public String formCounterQuery(Map<String, Object> model) {
                model.put("username", getPrincipalName());
@@ -31,6 +40,21 @@ public class SSFeaturesController extends BasicController {
                return "query/SSFeatures";
        }
 
+       /**
+        * form a results page for protein secondary structure features: Proteins
+        * with given fraction of H/E (helix/beta sheets) All proteins with E/H
+        * higher than a given percent of the length are returned
+        * 
+        * @param model
+        *            MVC model object
+        * @param typeFeature
+        *            type of SS: H/E (helix/beta sheets)
+        * @param percent
+        *            fraction of the protein length predicted as H/E (helix/beta
+        *            sheets)
+        * 
+        * @return link to the report JSP page
+        */
        @RequestMapping(value = "results", method = RequestMethod.GET)
        public String countSequences(@RequestParam("TypeFeatures") String typeFeature, @RequestParam("Percent") String percent,
                        Map<String, Object> model) {
@@ -69,19 +93,19 @@ public class SSFeaturesController extends BasicController {
                Map<String, String> r = reader.readProteinsPrediction(typeFeature, realpercent);
                model.put("results", r);
                model.put("njobs", 0);
-               String csvline = "";
+               StringBuilder csvline = new StringBuilder("");
                if (null != r) {
                        model.put("njobs", r.size());
-                       csvline = "\'Prediction%20number\',\'Protein%20Sequence\', \'Secondary%20Structure%20Prediction\'%0A";
-               }
+                       csvline.append("\'Prediction%20number\',\'Protein%20Sequence\', \'Secondary%20Structure%20Prediction\'%0A");
 
-               // form line for CSV file
-               int counter = 1;
-               for (Map.Entry<String, String> entry : r.entrySet()) {
-                       csvline += "\'" + counter + "\',\'" + entry.getKey() + "\',\'" + entry.getValue() + "\'%0A";
-                       ++counter;
+                       // form line for CSV file
+                       int counter = 1;
+                       for (Map.Entry<String, String> entry : r.entrySet()) {
+                               csvline.append("\'" + counter + "\',\'" + entry.getKey() + "\',\'" + entry.getValue() + "\'%0A");
+                               ++counter;
+                       }
                }
-               model.put("csvfile", csvline);
+               model.put("csvfile", csvline.toString());
 
                final long endTime = System.currentTimeMillis();
                model.put("timeExecution", (endTime - startTime));
index 9e92273..76b5e20 100644 (file)
@@ -16,8 +16,8 @@ import compbio.cassandra.readers.ReaderByCounter;
 import compbio.cassandra.readers.SequenceReader;
 
 /**
- * Spring controller for sequence queries. This version works in the servlet
- * style.
+ * Spring controller for supporting sequence queries. This version works in the
+ * servlet style.
  * 
  * @author Alexander Sherstnev
  * @author Natasha Sherstneva
@@ -76,7 +76,7 @@ public class SequenceController extends BasicController {
         *            be searched
         * @return link to the report JSP page
         */
-       @RequestMapping(value = "sequence/results", method = RequestMethod.GET)
+       @RequestMapping(value = "results", method = RequestMethod.GET)
        public String findSequence(@RequestParam("sequence") String sequence, @RequestParam("searchtype") String searchtype,
                        Map<String, Object> model) {
                model.put("username", getPrincipalName());
@@ -98,32 +98,37 @@ public class SequenceController extends BasicController {
                model.put("njobs", 0);
                model.put("prot", trimmedsequence);
                model.put("searchtype", searchtype);
-               String csvline = "";
+               StringBuilder csvline = new StringBuilder("");
                if (0 < trimmedsequence.length()) {
                        SequenceReader reader = new SequenceReader();
                        List<ProteinBean> result = reader.readProteins(trimmedsequence, searchtype);
                        model.put("results", result);
                        if (null != result) {
-                               if (searchtype.equals("whole"))
+                               if (searchtype.equals("whole")) {
                                        model.put("njobs", result.get(0).getJobid().size());
-                               else
+                               } else {
                                        model.put("njobs", result.size());
-                               csvline = "\'Job\',\'Annotation\',\'Sequence\'%0A";
-                               // form CSV file string
+                               }
+                               csvline.append("\'Job\',\'Annotation\',\'Sequence\'%0A");
                                for (ProteinBean entry : result) {
                                        List<String> jobs = entry.getJobid();
                                        String protein = entry.getSequence();
                                        LinkedHashMap<String, String> predictions = entry.getPredictions();
+                                       StringBuilder jobline = new StringBuilder();
+                                       for (Map.Entry<String, String> pr : predictions.entrySet()) {
+                                               jobline.append("\'\',\'" + pr.getKey() + "\',\'" + pr.getValue() + "\'%0A");
+                                       }
                                        for (String job : jobs) {
-                                               csvline += "\'" + job + "\',\'Sequence\',\'" + protein + "\',\'%0A";
-                                               for (Map.Entry<String, String> pr : predictions.entrySet()) {
-                                                       csvline += "\'\',\'" + pr.getKey() + "\',\'" + pr.getValue() + "\'%0A";
-                                               }
+                                               csvline.append("\'" + job + "\',\'Sequence\',\'" + protein + "\',\'%0A" + jobline.toString());
                                        }
                                }
                        }
+               } else {
+                       model.put("error", "The sequence after trimming is empty");
+                       model.put("value", sequence);
+                       return "query/Sequence";
                }
-               model.put("csvfile", csvline);
+               model.put("csvfile", csvline.toString());
 
                final long endTime = System.currentTimeMillis();
                model.put("timeExecution", (endTime - startTime));
@@ -169,24 +174,23 @@ public class SequenceController extends BasicController {
                List<TotalByCounterBean> r = reader.readProteinByCounter(realcounter);
                model.put("results", r);
                model.put("njobs", 0);
-               String csvline = "";
+               StringBuilder csvline = new StringBuilder("");
                if (null != r) {
                        model.put("njobs", r.size());
-                       csvline = "\'Job%20 count\', \'Protein%20Sequence\'%0A";
-               }
-               // form line for CSV file
-
-               for (TotalByCounterBean b : r) {
-                       if (b.getName().equals("")) {
-                               csvline += "\'" + b.getTotaljobs() + "\',\'Alignment%20job\'%0A";
-                               // fix problem with records without protein sequence (alignment
-                               // jobs)
-                               b.setName("Alignment job");
-                       } else {
-                               csvline += "\'" + b.getTotaljobs() + "\',\'" + b.getName() + "\'%0A";
+                       // form line for CSV file
+                       csvline.append("\'Job%20 count\', \'Protein%20Sequence\'%0A");
+                       for (TotalByCounterBean b : r) {
+                               if (b.getName().equals("")) {
+                                       // fix problem with records without protein sequence
+                                       // (alignment jobs)
+                                       csvline.append("\'" + b.getTotaljobs() + "\',\'Alignment%20job\'%0A");
+                                       b.setName("Alignment job");
+                               } else {
+                                       csvline.append("\'" + b.getTotaljobs() + "\',\'" + b.getName() + "\'%0A");
+                               }
                        }
                }
-               model.put("csvfile", csvline);
+               model.put("csvfile", csvline.toString());
 
                model.put("results", r);
                final long endTime = System.currentTimeMillis();
index f673e30..f862a2f 100644 (file)
@@ -91,8 +91,13 @@ public class ContextListener implements ServletContextListener {
 
                if (READ_WEB_JPRED) {
                        // get data from real Jpred production server
-                       final String datasrc = "http://www.compbio.dundee.ac.uk/www-jpred/results/usage-new/alljobs.dat";
-                       final String prefix = "http://www.compbio.dundee.ac.uk/www-jpred/results";
+                       String theprefix = ph.getProperty("cassandra.jpred.web.prefix");
+                       if (null == theprefix) {
+                               theprefix = "http://www.compbio.dundee.ac.uk/www-jpred/results";
+                       }
+                       
+                       final String datasrc = theprefix + "/usage-new/alljobs.dat";
+                       final String prefix = theprefix;
                        final JpredParserHTTP parser = new JpredParserHTTP(prefix);
 
                        int initialdelay = 300;
index db9857c..3c40ea7 100644 (file)
                        <div class="panel panel-default">
                        <div class="panel-heading">Execution statistics for the last days</div>
                        <div class="panel-body">
-                               Statistics plot
+                               <p style="font-weight:bold;">${total} jobs have been calculated with Jped over the last ${ndays} days:</p>
+                               <ul>
+                                       <li>${totalOK} jobs have been done without problems  (status: OK)</li>
+                                       <li>${totalStopped} jobs have been stopped (status: Stopped)</li>
+                                       <li>${totalTimeout} jobs haven't had enough time to complete (status: Time Out)</li>
+                                       <li>${totalError} jobs have been failed (status: Internal Error)</li>
+                               </ul>
                        </div>
                        </div>
                </div>
@@ -21,9 +27,9 @@
                        <div class="panel panel-default">
                        <div class="panel-heading">Overview</div>
                        <div class="panel-body">
-                               ProteoCache is as a repository of the result of running all tools in the Dundee Resource on
-                               complete proteomes.  The data are updated on a regular basis as tools are improved and genomes newly
-                               sequenced or updated.
+                               ProteoCache is as a repository and a caching system for Jpred and other tools of the Dundee Resource. 
+                               ProteoCache deals with both single proteins and complete proteomes.  The internal data are updated 
+                               on a regular basis as the tools are improved and proteomes are published and updated.
                        </div>
                        </div>
                </div>
index 4017906..2c63a3c 100644 (file)
                        <div class="panel panel-default">
                        <div class="panel-heading">Execution statistics for the last days</div>
                        <div class="panel-body">
-                               bla-bla
+                               <p style="font-weight:bold;">${total} jobs have been calculated with Jped over the last ${ndays} days:</p>
+                               <ul>
+                                       <li>${totalOK} jobs have been done without problems  (status: OK)</li>
+                                       <li>${totalStopped} jobs have been stopped (status: Stopped)</li>
+                                       <li>${totalTimeout} jobs haven't had enough time to complete (status: Time Out)</li>
+                                       <li>${totalError} jobs have been failed (status: Internal Error)</li>
+                               </ul>
                        </div>
                        </div>
                </div>
@@ -21,9 +27,9 @@
                        <div class="panel panel-default">
                        <div class="panel-heading">Overview</div>
                        <div class="panel-body">
-                               ProteoCache is as a repository of the result of running all tools in the Dundee Resource on
-                               complete proteomes.  The data are updated on a regular basis as tools are improved and genomes newly
-                               sequenced or updated.
+                               ProteoCache is as a repository and a caching system for Jpred and other tools of the Dundee Resource. 
+                               ProteoCache deals with both single proteins and complete proteomes.  The internal data are updated 
+                               on a regular basis as the tools are improved and proteomes are published and updated.
                        </div>
                        </div>
                </div>
index e9cff65..18d50a7 100644 (file)
@@ -11,7 +11,7 @@
 <body>
        <div class="container">
        <jsp:include page="../fragments/mainmenu.jsp" />
-       <spring:url value="/sequence/sequence/results" var="query"/>
+       <spring:url value="/sequence/results" var="query"/>
 
        <div class="panel panel-default">
                <div class="panel-heading">
index d0f90f4..b1d06cd 100644 (file)
@@ -4,7 +4,7 @@
 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
-<%@page import="java.util.ArrayList"%>
+<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>
 
 <html>
 <jsp:include page="../fragments/header.jsp" />
                <p style="font-weight:bold;">IP Statistics</p>
        </div>
        <div class="panel-body">
-
+<sec:authorize access="hasRole('ROLE_ADMIN')">
+               <p>Servlet execution time: ${timeExecution} milliseconds</p>
+</sec:authorize>
                <c:choose>
                <c:when test="${njobs == 0}">
                        <p>No IP with at least ${counter} jobs ever launched found</p>
                </c:when>
                <c:otherwise>
-                       <p>${njobs} IP with at least ${counter} jobs ever launched</p>
+                       <p>${njobs} IPs with at least ${counter} jobs ever launched</p>
                        <div class="table-responsive">
                        <table class="table table-striped table-hover table-bordered" id="counts">
                        <thead>
index 2dd4e82..e042564 100644 (file)
 <body>
        <div class="container">
                <jsp:include page="../fragments/mainmenu.jsp" />
-               <spring:url value="/sequence/sequence/results" var="sequence_query" />
+               <spring:url value="/sequence/results" var="sequence_query" />
                <spring:url value="/admin/ip/results" var="ip_query" />
+               <spring:url value="/job/results?IdJob=${IdJob}" var="the_query" />
+               <spring:url value="/database/remove/go?byId=on&id=${IdJob}&byId=off&date1=&date2=&byDate=off&ip=&byIp=off&seq=&bySequence=off" var="remove_query" />
+
+               <!-- reload and CSV buttons  -->
+               <ul class="nav navbar-nav navbar-right">
+                       <li>
+                       <a href="${the_query}" class="btn btn-default active">Reload</a>
+                       </li>
+<sec:authorize access="hasRole('ROLE_ADMIN')">
+                       <li>
+                       <a href="${remove_query}" class="btn btn-default active">Delete</a>
+                       </li>
+</sec:authorize>
+               </ul>
 
                <div class="panel panel-default">
                <div class="panel-heading">
                        <p style="font-weight:bold;">Information for the job ${IdJob}</p>
                </div>
                <div class="panel-body">
+                       <c:choose><c:when test="${jobnotfound == 'yes'}">
+                               <p>The job not found</p>
+                       </c:when><c:otherwise>
                        <p>Start timestamp : ${result.dateStart}</p>
                        <p>End timestamp : ${result.dateEnd}</p>
-                       <c:if test='${jobarchive != null}'>
-                               <p>Program name : ${result.programName}</p>
-                               <p>Program version : ${result.programVersion}</p>
+                       <c:if test='${result.programName != null}'>
+                               <c:choose>
+                               <c:when test="${result.programLink != ''}">
+                                       <p style="font-weight:bold;">
+                                       Program: <a href="${result.programLink}">${result.programName}</a> (version : ${result.programVersion})
+                                       </p>
+                               </c:when>
+                               <c:otherwise>
+                                       <p style="font-weight:bold;">Program : ${result.programName} (version : ${result.programVersion})</p>
+                               </c:otherwise>
+                               </c:choose>
                        </c:if>
 <sec:authorize access="hasRole('ROLE_ADMIN')">
                        <p>IP: <a title="Click to view other jobs" href="${ip_query}?ip=${result.ip}">${result.ip}</a></p>
                        </tbody>
                        </table>
                        </div>
+                       </c:otherwise></c:choose>
                </div>
                </div>
 
                <jsp:include page="../fragments/footer.jsp" />
        </div>
 </body>
-</html>
\ No newline at end of file
+</html>
index b47977c..f19cdf7 100644 (file)
@@ -12,7 +12,7 @@
                <jsp:include page="../fragments/mainmenu.jsp" />
                <spring:url value="/job/results" var="job_query" />
                <spring:url value="/stat/jobsoneday/results?date=${date}&status=${status}" var="the_query" />
-               <spring:url value="/sequence/sequence/results" var="sequence_query" />
+               <spring:url value="/sequence/results" var="sequence_query" />
 
        <ul class="nav navbar-nav navbar-right">
                <li>
@@ -73,4 +73,4 @@
        <jsp:include page="../fragments/footer.jsp" />
        </div>
 </body>
-</html>
\ No newline at end of file
+</html>
index b1d62fa..4a63761 100644 (file)
 <body>
        <div class="container">
                <jsp:include page="../fragments/mainmenu.jsp" />
-               <spring:url value="/sequence/sequence/results" var="sequence_query" />
+               <spring:url value="/sequence/results" var="sequence_query" />
                <spring:url value="/admin/ip/results" var="ip_query" />
 
                <div class="panel panel-default">
-               <div class="panel-heading">
-                       <p style="font-weight:bold;">Information for removed jobs</p>
-               </div>
-               <div class="panel-body">
-                       <!-- <div class="grid-wrapper-div">-->
-                       <c:if test="${byDate != 'off'}">
-                               <p>${njobs} jobs have been removed for time period: <c:out value="${date1}" /> to <c:out value="${date2}"/> (${ndays} days)</p>
-                       </c:if>
-                       <c:if test="${byId != 'off'}">
-                               <p>Job ${id} has been removed.</p>
-                       </c:if>
-                       <c:if test="${byIp != 'off'}">
-                               <p>Jobs launched from ${ip} have been removed. ${njobs} jobs have been removed.</p>
-                       </c:if>
-                       <c:if test="${bySequence != 'off'}">
-                               <p>Jobs launched with sequence ${seq} have been removed. ${njobs} jobs have been removed.</p>
-                       </c:if>
-                       <!-- </div>-->
-               </div>
+                       <div class="panel-heading">
+                               <p style="font-weight:bold;">Information on removed jobs</p>
+                       </div>
+                       <div class="panel-body">
+                       <c:choose>
+                       <c:when test="${njobs > 0}">
+                               <c:if test="${byDate != 'off'}">
+                                       <p>${njobsbyDate} jobs have been removed for the time period: ${date1} to ${date2} (${ndays} days)</p>
+                               </c:if>
+                               <c:if test="${byId != 'off'}">
+                                       <p>Job ${id} has been removed.</p>
+                               </c:if>
+                               <c:if test="${byIp != 'off'}">
+                                       <p>Jobs launched from ${ip} have been removed. ${njobsbyIp} jobs have been removed.</p>
+                               </c:if>
+                               <c:if test="${bySequence != 'off'}">
+                                       <p>Jobs launched with sequence ${seq} have been removed. ${njobsbySeq} jobs have been removed.</p>
+                               </c:if>
+                       </c:when>
+                       <c:otherwise>
+                               <p>No jobs has been removed.</p>
+                       </c:otherwise>
+                       </c:choose>
+                       </div>
                </div>
 
                <jsp:include page="../fragments/footer.jsp" />
        </div>
 </body>
-</html>
\ No newline at end of file
+</html>
index 4e2e773..1156494 100644 (file)
@@ -6,14 +6,14 @@
 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
-<%@page import="java.util.ArrayList"%>
+<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>
 
 <html>
 <jsp:include page="../fragments/header.jsp" />
 <body>
        <div class="container">
                <jsp:include page="../fragments/mainmenu.jsp" />
-               <spring:url value="/sequence/sequence/results" var="sequence_query" />
+               <spring:url value="/sequence/results" var="sequence_query" />
                <spring:url value="/features/results" var="the_query"/>
                <spring:url value="/features/results?TypeFeatures=${feature}&Percent=${percent}" var="the_query" />
 
@@ -35,6 +35,9 @@
        </div>
 
        <div class="panel-body">
+<sec:authorize access="hasRole('ROLE_ADMIN')">
+                       <p>Servlet execution time: ${timeExecution} milliseconds</p>
+</sec:authorize>
                <c:choose>
                <c:when test="${njobs == 0}">
                        <p>No proteins with feature ${feature} more then ${percent}% of the protein sequence found</p>
@@ -81,4 +84,4 @@
        <jsp:include page="../fragments/footer.jsp" />
        </div>
 </body>
-</html>
\ No newline at end of file
+</html>
index 0bb4b7a..3ba5d10 100644 (file)
@@ -4,7 +4,7 @@
 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
-<%@page import="java.util.ArrayList"%>
+<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>
 
 <html>
 <jsp:include page="../fragments/header.jsp" />
@@ -12,7 +12,7 @@
        <div class="container">
                <jsp:include page="../fragments/mainmenu.jsp" />
                <spring:url value="/job/results" var="job_query" />
-               <spring:url value="/sequence/sequence/results?sequence=${prot}&searchtype=${searchtype}" var="the_query"/>
+               <spring:url value="/sequence/results?sequence=${prot}&searchtype=${searchtype}" var="the_query"/>
                <c:set var="shortensequencelength" value="108"/>
 
                <!-- reload and CSV buttons  -->
@@ -46,6 +46,9 @@
        </div>
 
        <div class="panel-body">
+<sec:authorize access="hasRole('ROLE_ADMIN')">
+                       <p>Servlet execution time: ${timeExecution} milliseconds</p>
+</sec:authorize>
                <c:choose>
                        <c:when test="${njobs == 0}">
                                <p>No jobs found</p>
                                                        <c:forEach items="${results}" var="res" varStatus="status">
                                                                <c:forEach items="${res.jobid}" var="id" varStatus="status">
                                                                <tr>
-                                                                       <th rowspan="${res.size + 2}"><a
+                                                                       <th rowspan="3"><a
                                                                                title="Click to view the job log"
                                                                                href="${job_query}?IdJob=${id}">${id}</a></th>
                                                                </tr>
                                                                <tr>
                                                                        <td style="text-align: center; font-weight: bold; font-family: monospace">Sequence</td>
                                                                        <c:if test="${searchtype == 'whole'}">
-                                                                               <td
-                                                                                       style="text-align: left; border-buttom: dotted; font-family: monospace"><c:out
-                                                                                               value="${res.sequence}" /></td>
+                                                                               <td style="text-align: left; font-family: monospace">
+                                                                                               ${res.sequence}</td>
                                                                        </c:if>
                                                                        <c:if test="${searchtype == 'partial'}">
-                                                                               <td
-                                                                                       style="text-align: left; border-buttom: dotted; font-family: monospace">
+                                                                               <td style="text-align: left; border-buttom: dotted; font-family: monospace">
                                                                                        <c:forEach items="${res.subProt}" var="seq">
                                                                                                <c:choose>
-                                                       <c:when test="${fn:contains(seq, prot)}">
-                                                       <span style="background-color: blue">${seq}</span></c:when>
-                                                       <c:otherwise>${seq}</c:otherwise>
+                                                                                               <c:when test="${fn:contains(seq, prot)}">
+                                                                                               <span style="background-color: blue">${seq}</span></c:when>
+                                                                                               <c:otherwise>${seq}</c:otherwise>
                                                                                                </c:choose>
                                                                                        </c:forEach>
                                                                                </td>
                                                                        </c:if>
                                                                </tr>
-                                                               <c:forEach items="${res.predictions}" var="seq"
-                                                                       varStatus="status">
-                                                                       <tr>
-                                                                               <td
-                                                                                       style="text-align: center; font-weight: bold; font-family: monospace"><c:out
-                                                                                               value="${seq.key}" /></td>
-                                                                               <td
-                                                                                       style="text-align: left; border-buttom: dotted; font-family: monospace"><c:out
-                                                                                               value="${seq.value}" /></td>
-                                                                       </tr>
-                                                               </c:forEach>
+                                                               <tr>
+                                                                       <td style="text-align: center; font-weight: bold; font-family: monospace">
+                                                                               Jnetpred
+                                                                       </td>
+                                                                       <td style="text-align: left; border-buttom: dotted; font-family: monospace">
+                                                                               ${res.jnetpred}
+                                                                       </td>
+                                                               </tr>
                                                        </c:forEach>
                                                        </c:forEach>
                                                </tbody>
                <jsp:include page="../fragments/footer.jsp" />
        </div>
 </body>
-</html>
\ No newline at end of file
+</html>
index 894d113..175f5f4 100644 (file)
@@ -5,6 +5,7 @@
 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
+<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>
 
 <html>
 <jsp:include page="../fragments/header.jsp" />
@@ -12,7 +13,7 @@
 <body>
        <div class="container">
                <jsp:include page="../fragments/mainmenu.jsp" />
-               <spring:url value="/sequence/sequence/results" var="sequence_query" />
+               <spring:url value="/sequence/results" var="sequence_query" />
                <spring:url value="/sequence/counts/results?counterJob=${counter}" var="the_query" />
                <c:set var="shortensequencelength" value="108"/>
 
@@ -34,6 +35,9 @@
        </div>
 
        <div class="panel-body">
+<sec:authorize access="hasRole('ROLE_ADMIN')">
+               <p>Servlet execution time: ${timeExecution} milliseconds</p>
+</sec:authorize>
                <c:choose>
                <c:when test="${njobs == 0}">
                        <p>No proteins with at least ${counter} jobs found</p>
@@ -73,4 +77,4 @@
        <jsp:include page="../fragments/footer.jsp" />
        </div>
 </body>
-</html>
\ No newline at end of file
+</html>