Fix bug for inserting job without known predictions
authorSasha Sherstnev <a.sherstnev@dundee.ac.uk>
Tue, 12 Nov 2013 15:22:07 +0000 (15:22 +0000)
committerSasha Sherstnev <a.sherstnev@dundee.ac.uk>
Tue, 12 Nov 2013 15:22:07 +0000 (15:22 +0000)
datadb/compbio/cassandra/CassandraWriter.java

index 6ee62fd..c478d68 100644 (file)
@@ -67,7 +67,7 @@ public class CassandraWriter {
                                allpredictions += "'" + predictionname + "':'" + prediction + "',";
                        }
                        String final_prediction = "";
-                       if (null != allpredictions) {
+                       if (!allpredictions.equals("")) {
                                final_prediction = allpredictions.substring(0, allpredictions.length() - 1);
                        }
 
@@ -79,7 +79,7 @@ public class CassandraWriter {
                                session.execute(com3);
                        }
 
-                       // update some internal tables 
+                       // update some internal query tables
                        String check3 = "SELECT * FROM MainParameters WHERE Name = 'EarliestJobDate';";
                        ResultSet results3 = session.execute(check3);
                        boolean updateparameter = true;
@@ -93,15 +93,15 @@ public class CassandraWriter {
                                                + "');";
                                session.execute(com);
                        }
-                       String check4 = "SELECT * FROM MainParameters WHERE Name = 'TotalNumberOfJobs';";
+                       String check4 = "SELECT * FROM JobDateInfo WHERE jobday = " + jobtime + ";";
                        ResultSet results4 = session.execute(check4);
                        updateparameter = true;
                        int njobs = 1;
                        if (!results4.isExhausted()) {
                                Row r = results4.one();
-                               njobs += Integer.parseInt(r.getString("Value"));
+                               njobs += r.getLong("Total");
                        }
-                       String com = "INSERT INTO MainParameters " + "(Name, Value)" + " VALUES ('TotalNumberOfJobs','" + String.valueOf(njobs) + "');";
+                       String com = "INSERT INTO JobDateInfo " + "(jobday, Total)" + " VALUES (" + jobtime + "," + njobs + ");";
                        session.execute(com);
 
                        return 1;