Introduce new table for programs and necessary infrastructure for the table
[proteocache.git] / datadb / compbio / cassandra / readers / JobReader.java
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;
        }
 }