X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws%2FJobStateSummary.java;fp=src%2Fjalview%2Fws%2FJobStateSummary.java;h=0983dc078be52da844bc5b1ded1835d6e438e505;hb=39c0b5e5d2ff4352d36bb6705121dc5ed14ba81b;hp=0000000000000000000000000000000000000000;hpb=fe66b18b34201857669c2b5b44435a397af202d8;p=jalview.git diff --git a/src/jalview/ws/JobStateSummary.java b/src/jalview/ws/JobStateSummary.java new file mode 100644 index 0000000..0983dc0 --- /dev/null +++ b/src/jalview/ws/JobStateSummary.java @@ -0,0 +1,129 @@ +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++; + } + } + } + } +}