From ada58be75fc7cd59e09bf79568233430a86db8f1 Mon Sep 17 00:00:00 2001 From: Sasha Sherstnev Date: Tue, 12 Nov 2013 18:31:30 +0000 Subject: [PATCH] Code for Jpred Job java Bean --- engine/compbio/engine/Job.java | 167 +++++++++++++++++++++++++++++++++++ engine/compbio/engine/JpredJob.java | 64 ++++++++++++++ 2 files changed, 231 insertions(+) create mode 100644 engine/compbio/engine/Job.java create mode 100644 engine/compbio/engine/JpredJob.java diff --git a/engine/compbio/engine/Job.java b/engine/compbio/engine/Job.java new file mode 100644 index 0000000..309e0e9 --- /dev/null +++ b/engine/compbio/engine/Job.java @@ -0,0 +1,167 @@ +package compbio.engine; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; + +public class Job { + private String jobid; + private String ExecutionStatus; + private String FinalStatus; + private String IP; + private String Email; + + private String StartingDateStr; + private long StartingDate; + private String EndTimeStr; + private long EndTime; + private String StartingTimeStr; + private long StartingTime; + private long ExecutionTime; + + static SimpleDateFormat dateformatter = new SimpleDateFormat("yyyy/MM/dd");; + static SimpleDateFormat timeformatter = new SimpleDateFormat("yyyy/MM/dd:H:m:s"); + + public Job() { + ExecutionStatus = "OK"; + FinalStatus = "OK"; + jobid = ""; + + StartingDateStr = "1970/1/1"; + StartingTimeStr = "1970/1/1:0:0:0"; + EndTimeStr = "1970/1/1:0:0:0"; + StartingDate = 0L; + StartingTime = 0L; + EndTime = 0L; + ExecutionTime = 0L; + } + + public Job(String id, String date1, String date2) { + jobid = id; + ExecutionStatus = "OK"; + FinalStatus = "OK"; + setDates(date1, date2); + } + + protected void setDates (String d1, String d2) { + StartingTimeStr = d1; + StartingDateStr = d1.substring(0, d1.indexOf(":")); + StartingTime = convertTime(StartingTimeStr); + StartingDate = convertDate(StartingDateStr); + + EndTimeStr = d2; + EndTime = convertTime(d2); + ExecutionTime = EndTime - StartingTime; + } + + + protected long convertDate (String d) { + try { + if (null != d) { + Date startdate = dateformatter.parse(d); + return startdate.getTime(); + } + } catch (ParseException e) { + e.printStackTrace(); + } + return 0L; + } + + protected long convertTime (String d) { + try { + if (null != d) { + Date startdate = timeformatter.parse(d); + return startdate.getTime(); + } + } catch (ParseException e) { + e.printStackTrace(); + } + return 0L; + } + + + public void setStartingDate(String date) { + this.StartingDateStr = date; + StartingDate = convertDate(date); + StartingTime = convertTime(date); + if (0 < EndTime) { + ExecutionTime = EndTime - StartingTime; + } + } + + public void setEndTime(String date) { + this.EndTimeStr = date; + EndTime = convertTime(date); + if (0 < StartingTime) { + ExecutionTime = EndTime - StartingTime; + } + } + + public String getStartingDateStr() { + return StartingDateStr; + } + public String getStartingTimeStr() { + return StartingTimeStr; + } + public long getStartingDate() { + return StartingDate; + } + public long getStartingTime() { + return StartingTime; + } + + public String getEndTimeStr() { + return EndTimeStr; + } + public long getEndTime() { + return EndTime; + } + + public void setExecutionStatus(String status) { + ExecutionStatus = status; + } + + public void setFinalStatus(String status) { + FinalStatus = status; + } + + public String getExecutionStatus() { + return ExecutionStatus; + } + + public String getFinalStatus() { + return FinalStatus; + } + + public long getExecutionTime() { + return ExecutionTime; + } + + public void setIP(String IP) { + this.IP = IP; + } + + public String getIP() { + if (null != IP) + return IP; + return "127.0.0.1"; + } + + public void setEmail(String email) { + this.Email = email; + } + + public String getEmail() { + if (null != Email) + return Email; + return "user@localhost"; + } + + public void setJobId(String id) { + this.jobid = id; + } + + public String getJobID() { + return jobid; + } +} diff --git a/engine/compbio/engine/JpredJob.java b/engine/compbio/engine/JpredJob.java new file mode 100644 index 0000000..a606746 --- /dev/null +++ b/engine/compbio/engine/JpredJob.java @@ -0,0 +1,64 @@ +package compbio.engine; + +import java.util.ArrayList; +import java.util.List; + +import compbio.cassandra.FastaSequence; + +public class JpredJob extends Job { + private String protein; + private String log; + private List predictions; + private List alignment; + + public JpredJob() { + super(); + } + + public JpredJob(String jobid, String date1, String date2) { + super(jobid, date1, date2); + this.protein = protein; + predictions = new ArrayList(); + alignment = new ArrayList(); + log = ""; + } + + public JpredJob(String jobid, String date1, String date2, List alignment, List predictions) { + super(jobid, date1, date2); + this.protein = protein; + this.alignment = alignment; + this.predictions = predictions; + } + + public void setProtein(String protein) { + this.protein = protein; + } + + public String getProtein() { + return protein; + } + + public void setLog(String log) { + this.log = log; + } + + public String getLog() { + return log; + } + + public void setAlignment(List al) { + this.alignment = al; + } + + public List getAlignment() { + return alignment; + } + + public void setPredictions(List pr) { + this.predictions = pr; + } + + public List getPredictions() { + return predictions; + } +} -- 1.7.10.2