Add direct links to Jpred jobs
[proteocache.git] / server / compbio / controllers / JobController.java
index 254fdc2..9987bd5 100644 (file)
@@ -1,6 +1,8 @@
 package compbio.controllers;
 
 import java.io.IOException;
+import java.net.HttpURLConnection;
+import java.net.URL;
 import java.text.SimpleDateFormat;
 import java.util.Calendar;
 import java.util.Date;
@@ -15,6 +17,7 @@ import org.springframework.web.bind.annotation.RequestParam;
 
 import compbio.statistic.CassandraRequester;
 import compbio.cassandra.DataBase;
+import compbio.cassandra.readers.JobReader;
 import compbio.engine.archive.ArchivedJob;
 
 /**
@@ -110,7 +113,7 @@ public class JobController extends BasicController {
                model.put("ndays", res.size() - 1);
                final long endTime = System.currentTimeMillis();
                model.put("timeExecution", (endTime - startTime));
-               return "/reportTimeExecution";
+               return "/reports/TimeExecution";
        }
 
        /**
@@ -120,13 +123,14 @@ public class JobController extends BasicController {
         * @param model
         *            MVC model
         * @return link to the JSP query page
+        * @throws IOException
         */
        @RequestMapping(value = "/job/results", method = RequestMethod.GET)
-       public String findJob(@RequestParam("IdJob") String jobid, Map<String, Object> model) {
+       public String findJob(@RequestParam("IdJob") String jobid, Map<String, Object> model) throws IOException {
                model.put("username", getPrincipalName());
                final long startTime = System.currentTimeMillis();
-               CassandraRequester cr = new CassandraRequester();
-               model.put("result", cr.readJobLog(jobid));
+               JobReader reader = new JobReader();
+               model.put("result", reader.readJobLog(jobid));
                final long endTime = System.currentTimeMillis();
                model.put("timeExecution", (endTime - startTime));
                model.put("IdJob", jobid);
@@ -138,7 +142,14 @@ public class JobController extends BasicController {
                        log.error("JobController.prepareJobArchiveToWeb: IO exception with job archive file");
                        log.error(e.getLocalizedMessage(), e.getCause());
                }
-               return "reportJobLog";
+               // 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);
+               HttpURLConnection httpConnection_remotelinkurl = (HttpURLConnection) remotelinkurl.openConnection();
+               if (199 < httpConnection_remotelinkurl.getResponseCode() && httpConnection_remotelinkurl.getResponseCode() < 300) {
+                       model.put("jobremotelink", remotelink);
+               }
+               return "reports/Job";
        }
 
        /**