Allow less full jobs (with failed status) to be reported
authorSasha Sherstnev <a.sherstnev@dundee.ac.uk>
Mon, 3 Feb 2014 14:03:51 +0000 (14:03 +0000)
committerSasha Sherstnev <a.sherstnev@dundee.ac.uk>
Mon, 3 Feb 2014 14:03:51 +0000 (14:03 +0000)
datadb/compbio/cassandra/readers/JobReader.java

index 26a40e6..94f8536 100644 (file)
@@ -1,5 +1,8 @@
 package compbio.cassandra.readers;
 
+import java.util.HashMap;
+import java.util.Map;
+
 import com.datastax.driver.core.ResultSet;
 import com.datastax.driver.core.Row;
 
@@ -25,25 +28,28 @@ public class JobReader extends CassandraReader {
                        return null;
                Row row1 = results.one();
                ResultSet results1 = CassandraQuery("SELECT * FROM ProteinRow WHERE JobID = '" + jobid + "' ALLOW FILTERING;");
-               if (results1.isExhausted())
-                       return null;
-               Row row2 = results1.one();
-               String program = row1.getString("ProgramName");
-               String version = row1.getString("ProgramVersion");
+               Map<String, String> predictions = new HashMap<String, String>();
+               if (!results1.isExhausted()) {
+                       Row row2 = results1.one();
+                       predictions = row2.getMap("Predictions", String.class, String.class);
+               }
+
                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));
+                               row1.getString("DataEnd"), row1.getString("ip"), predictions);
 
-               if (null != program && null != version) {
-                       res.setProgramName(program);
-                       res.setProgramVersion(version);
-                       ResultSet results3 = CassandraQuery("SELECT * FROM Programs WHERE Program = '" + program + "' and Version = '" + version
+               String programname = row1.getString("ProgramName");
+               String programversion = row1.getString("ProgramVersion");
+               if (null != programname && null != programversion) {
+                       res.setProgramName(programname);
+                       res.setProgramVersion(programversion);
+                       ResultSet results3 = CassandraQuery("SELECT * FROM Programs WHERE Program = '" + programname + "' and Version = '" + programversion
                                        + "' ALLOW FILTERING;");
-                       if (results3.isExhausted())
-                               return null;
-                       Row row3 = results3.one();
-                       String link = row3.getString("weblink");
-                       if (null != link) {
-                               res.setProgramLink(link);
+                       if (!results3.isExhausted()) {
+                               Row row3 = results3.one();
+                               String link = row3.getString("weblink");
+                               if (null != link) {
+                                       res.setProgramLink(link);
+                               }
                        }
                }