public class CassandraRemover {
private Session session;
- static SimpleDateFormat dateformatter = new SimpleDateFormat("yyyy/MM/dd");
+ static SimpleDateFormat dateformatter = new SimpleDateFormat("yyyy/MM/dd");
private static Logger log = Logger.getLogger(CassandraNativeConnector.class);
public CassandraRemover() {
Session inis = CassandraNativeConnector.getSession();
- setSession (inis);
+ setSession(inis);
}
public void setSession(Session s) {
assert s != null;
session = s;
}
-
+
/*
* delete a record from CF for current jobId
*/
System.out.println("Command: " + com);
ResultSet results = session.execute(com);
Row row = results.one();
- long njobs = row.getLong("Total") -1 ;
+ 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("Remove jobs: " + jobid);
}
-
+
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);
}
-
- public int RemoveJobById (String jobid) {
- if (jobid == null)
+
+ public int RemoveJobById(String jobid) {
+ if (jobid == null)
return 0;
Long date = FindDate(jobid);
RemoveJob(jobid, date);
return 1;
}
-
- public int RemoveJobByDate (String date1, String date2) {
+
+ public int RemoveJobByDate(String date1, String date2) {
int numremover = 0;
- if (date1 == null || date2 == null)
+ if (date1 == null || date2 == null)
return 0;
Long dateBegin = convertDate(date1);
Long dateEnd = convertDate(date2);
}
return numremover;
}
-
-
- public int RemoveJobByIp (String ip) {
+
+ public int RemoveJobByIp(String ip) {
int numremover = 0;
- if (ip == null)
+ if (ip == null)
return 0;
String com = "SELECT databegin, JobID FROM ProteinLog WHERE ip = '" + ip + "';";
ResultSet results = session.execute(com);
}
return numremover;
}
-
- public int RemoveJobBySequence (String seq) {
+
+ public int RemoveJobBySequence(String seq) {
int numremover = 0;
- if (seq == null)
+ if (seq == null)
return 0;
String com = "SELECT JobID FROM ProteinRow WHERE Protein = '" + seq + "';";
ResultSet results = session.execute(com);
}
return numremover;
}
-
+
private Long FindDate(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;
}
-
+
private String FindStatus(String jobid) {
String com = "SELECT FinalStatus FROM ProteinLog WHERE JobID = '" + jobid + "';";
System.out.println("Command: " + com);
System.out.println("*****status: " + status);
return status;
}
-
- protected long convertDate (String d) {
+
+ protected long convertDate(String d) {
try {
if (null != d) {
Date startdate = dateformatter.parse(d);