--- /dev/null
+package jalview.ws;
+
+import jalview.gui.WebserviceInfo;
+
+/**
+ * bookkeeper class for the WebServiceInfo GUI, maintaining records of web
+ * service jobs handled by the window and reflecting any status updates.
+ *
+ * @author JimP
+ *
+ */
+public class JobStateSummary
+{
+ /**
+ * number of jobs running
+ */
+ int running = 0;
+
+ /**
+ * number of jobs queued
+ */
+ int queuing = 0;
+
+ /**
+ * number of jobs finished
+ */
+ int finished = 0;
+
+ /**
+ * number of jobs failed
+ */
+ int error = 0;
+
+ /**
+ * number of jobs stopped due to server error
+ */
+ int serror = 0;
+
+ /**
+ * number of jobs cancelled
+ */
+ int cancelled = 0;
+
+ /**
+ * number of jobs finished with results
+ */
+ int results = 0;
+
+ /**
+ * processes an AWSJob's status and updates job status counters and WebService
+ * status displays
+ *
+ * @param wsInfo
+ * @param OutputHeader
+ * @param j
+ */
+ public void updateJobPanelState(WebserviceInfo wsInfo, String OutputHeader,
+ AWsJob j)
+ {
+ if (j.submitted)
+ {
+ String progheader = "";
+ // Parse state of job[j]
+ if (j.isRunning())
+ {
+ running++;
+ wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_RUNNING);
+ }
+ else if (j.isQueued())
+ {
+ queuing++;
+ wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_QUEUING);
+ }
+ else if (j.isFinished())
+ {
+ finished++;
+ j.subjobComplete = true;
+ if (j.hasResults())
+ {
+ results++;
+ }
+ wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_STOPPED_OK);
+ }
+ else if (j.isFailed())
+ {
+ progheader += "Job failed.\n";
+ j.subjobComplete = true;
+ wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_STOPPED_ERROR);
+ error++;
+ }
+ else if (j.isServerError())
+ {
+ serror++;
+ j.subjobComplete = true;
+ wsInfo
+ .setStatus(j.jobnum,
+ WebserviceInfo.STATE_STOPPED_SERVERERROR);
+ }
+ else if (j.isBroken())
+ {
+ progheader += "Job was broken.\n";
+ error++;
+ j.subjobComplete = true;
+ wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_STOPPED_ERROR);
+ }
+ // and pass on any sub-job messages to the user
+ wsInfo.setProgressText(j.jobnum, OutputHeader);
+ wsInfo.appendProgressText(j.jobnum, progheader);
+ if (j.hasStatus())
+ {
+ wsInfo.appendProgressText(j.jobnum, j.getStatus());
+ }
+ }
+ else
+ {
+ if (j.submitted && j.subjobComplete)
+ {
+ if (j.allowedServerExceptions == 0)
+ {
+ serror++;
+ }
+ else if (!j.hasResults())
+ {
+ error++;
+ }
+ }
+ }
+ }
+}