From 5521e2b5b17013a7f5544835c68005cee471ddf0 Mon Sep 17 00:00:00 2001 From: Mateusz Warowny Date: Tue, 5 Apr 2022 14:12:03 +0200 Subject: [PATCH] JAL-3878 Move status precedence list to JobStatus class --- src/jalview/ws2/actions/AbstractPollableTask.java | 23 ++------------------- src/jalview/ws2/api/JobStatus.java | 19 +++++++++++++++++ 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/jalview/ws2/actions/AbstractPollableTask.java b/src/jalview/ws2/actions/AbstractPollableTask.java index 6ff5749..bf58b13 100644 --- a/src/jalview/ws2/actions/AbstractPollableTask.java +++ b/src/jalview/ws2/actions/AbstractPollableTask.java @@ -219,35 +219,16 @@ public abstract class AbstractPollableTask implements Task for (BaseJob job : jobs) { JobStatus status = job.getStatus(); - int jobPrecedence = ArrayUtils.indexOf(statusPrecedence, status); + int jobPrecedence = ArrayUtils.indexOf(JobStatus.statusPrecedence, status); if (precedence < jobPrecedence) precedence = jobPrecedence; } if (precedence >= 0) { - setStatus(statusPrecedence[precedence]); + setStatus(JobStatus.statusPrecedence[precedence]); } } - /** - * A precedence order of job statuses used to compute the overall task status. - */ - private static JobStatus[] statusPrecedence = { - JobStatus.INVALID, // all must be invalid for task to be invalid - JobStatus.COMPLETED, // all but invalid must be completed for task to be - // completed - JobStatus.UNKNOWN, // unknown prevents successful completion but not - // running or failure - JobStatus.READY, - JobStatus.SUBMITTED, - JobStatus.QUEUED, - JobStatus.RUNNING, - JobStatus.CANCELLED, // if any is terminated unsuccessfully, the task is - // failed - JobStatus.FAILED, - JobStatus.SERVER_ERROR - }; - @Override public void cancel() { diff --git a/src/jalview/ws2/api/JobStatus.java b/src/jalview/ws2/api/JobStatus.java index 0334737..3341a69 100644 --- a/src/jalview/ws2/api/JobStatus.java +++ b/src/jalview/ws2/api/JobStatus.java @@ -49,4 +49,23 @@ public enum JobStatus throw new AssertionError("non-exhaustive switch statement"); } } + + /** + * A precedence order of job statuses used to compute the overall task status. + */ + public static final JobStatus[] statusPrecedence = { + JobStatus.INVALID, // all must be invalid for task to be invalid + JobStatus.COMPLETED, // all but invalid must be completed for task to be + // completed + JobStatus.UNKNOWN, // unknown prevents successful completion but not + // running or failure + JobStatus.READY, + JobStatus.SUBMITTED, + JobStatus.QUEUED, + JobStatus.RUNNING, + JobStatus.CANCELLED, // if any is terminated unsuccessfully, the task is + // failed + JobStatus.FAILED, + JobStatus.SERVER_ERROR + }; } -- 1.7.10.2