First patch for * JAL-493
[jalview.git] / src / jalview / ws / AWsJob.java
diff --git a/src/jalview/ws/AWsJob.java b/src/jalview/ws/AWsJob.java
new file mode 100644 (file)
index 0000000..2f036bf
--- /dev/null
@@ -0,0 +1,200 @@
+package jalview.ws;
+
+/**
+ * Generic properties for an individual job within a Web Service Client thread.
+ * Derived from jalview web services version 1 statuses, and revised for Jws2.
+ */
+
+public abstract class AWsJob
+{
+  protected int jobnum = 0;
+
+  protected String jobId;
+
+  /**
+   * @param jobId the jobId to set
+   */
+  public void setJobId(String jobId)
+  {
+    this.jobId = jobId;
+  }
+
+  /**
+   * has job been cancelled
+   */
+  protected boolean cancelled = false;
+
+  /**
+   * number of exceptions left before job dies
+   */
+  int allowedServerExceptions = 3;
+
+  /**
+   * @param allowedServerExceptions the allowedServerExceptions to set
+   */
+  public void setAllowedServerExceptions(int allowedServerExceptions)
+  {
+    this.allowedServerExceptions = allowedServerExceptions;
+  }
+
+  /**
+   * has job been submitted to server ? if false, then no state info is
+   * available.
+   */
+  protected boolean submitted = false;
+
+  /**
+   * @param jobnum the jobnum to set
+   */
+  public void setJobnum(int jobnum)
+  {
+    this.jobnum = jobnum;
+  }
+
+  /**
+   * @param submitted the submitted to set
+   */
+  public void setSubmitted(boolean submitted)
+  {
+    this.submitted = submitted;
+  }
+
+  /**
+   * @param subjobComplete the subjobComplete to set
+   */
+  public void setSubjobComplete(boolean subjobComplete)
+  {
+    this.subjobComplete = subjobComplete;
+  }
+
+  /**
+   * @return the jobnum
+   */
+  public int getJobnum()
+  {
+    return jobnum;
+  }
+
+  /**
+   * @return the jobId
+   */
+  public String getJobId()
+  {
+    return jobId;
+  }
+
+  /**
+   * @return the cancelled
+   */
+  public boolean isCancelled()
+  {
+    return cancelled;
+  }
+
+  /**
+   * @return the allowedServerExceptions
+   */
+  public int getAllowedServerExceptions()
+  {
+    return allowedServerExceptions;
+  }
+
+  /**
+   * @return the submitted
+   */
+  public boolean isSubmitted()
+  {
+    return submitted;
+  }
+
+  /**
+   * @return the subjobComplete
+   */
+  public boolean isSubjobComplete()
+  {
+    return subjobComplete;
+  }
+
+  /**
+   * are all sub-jobs complete
+   */
+  protected boolean subjobComplete = false;
+
+  public AWsJob()
+  {
+  }
+
+  /**
+   * 
+   * @return true if job has completed and valid results are available
+   */
+  abstract public boolean hasResults();
+
+  /**
+   * 
+   * @return boolean true if job can be submitted.
+   */
+  public abstract boolean hasValidInput();
+
+  /**
+   * 
+   * @return true if job is running
+   */
+  abstract public boolean isRunning();
+
+  /**
+   * 
+   * @return true if job is queued
+   */
+  abstract public boolean isQueued();
+
+  /**
+   * 
+   * @return true if job has finished
+   */
+  abstract public boolean isFinished();
+
+  /**
+   * 
+   * @return true if the job failed due to some problem with the input data or
+   *         parameters.
+   */
+  abstract public boolean isFailed();
+
+  /**
+   * 
+   * @return true if job failed due to an unhandled technical issue
+   */
+  abstract public boolean isBroken();
+
+  /**
+   * 
+   * @return true if there was a problem contacting the server.
+   */
+  abstract public boolean isServerError();
+
+  /**
+   * 
+   * @return true if the job has status text.
+   */
+  abstract public boolean hasStatus();
+
+  /**
+   * 
+   * @return status text for job to be displayed to user.
+   */
+  abstract public String getStatus();
+
+  abstract public boolean hasResponse();
+  abstract public void clearResponse();
+  abstract public String getState();
+  /**
+   * generates response using the abstract service flags.
+   * @return a standard state response 
+   */
+  protected String _defaultState() {
+    
+    String state = "";
+    return state;
+  }
+}
\ No newline at end of file