From 93cf8baeea8bf6cd233ce6b673bcdcf451c0c6d6 Mon Sep 17 00:00:00 2001 From: Mateusz Warowny Date: Tue, 5 Apr 2022 14:10:56 +0200 Subject: [PATCH] JAL-3878 Add uid to WS Tasks --- src/jalview/ws2/actions/AbstractPollableTask.java | 8 ++++++++ src/jalview/ws2/actions/api/TaskI.java | 9 +++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/jalview/ws2/actions/AbstractPollableTask.java b/src/jalview/ws2/actions/AbstractPollableTask.java index 999411f..6ff5749 100644 --- a/src/jalview/ws2/actions/AbstractPollableTask.java +++ b/src/jalview/ws2/actions/AbstractPollableTask.java @@ -11,6 +11,7 @@ import java.util.concurrent.TimeUnit; import jalview.bin.Cache; import jalview.util.ArrayUtils; +import jalview.util.MathUtils; import jalview.ws.params.ArgumentI; import jalview.ws2.actions.api.TaskEventListener; import jalview.ws2.actions.api.TaskI; @@ -37,6 +38,8 @@ import static java.lang.String.format; */ public abstract class AbstractPollableTask implements TaskI { + private final long uid = MathUtils.getUID(); + protected final WebServiceClientI client; protected final List args; @@ -62,6 +65,11 @@ public abstract class AbstractPollableTask implements Task this.eventHandler = new TaskEventSupport(this, eventListener); } + public long getUid() + { + return uid; + } + /** * Start the task using provided scheduled executor service. It creates a * polling loop running at set intervals. diff --git a/src/jalview/ws2/actions/api/TaskI.java b/src/jalview/ws2/actions/api/TaskI.java index 874f5a6..cb84944 100644 --- a/src/jalview/ws2/actions/api/TaskI.java +++ b/src/jalview/ws2/actions/api/TaskI.java @@ -2,9 +2,7 @@ package jalview.ws2.actions.api; import java.util.List; -import jalview.viewmodel.AlignmentViewport; import jalview.ws2.api.JobStatus; -import jalview.ws2.api.WebServiceJobHandle; /** * {@code TaskI} objects represent running services. Tasks are created by @@ -19,6 +17,13 @@ import jalview.ws2.api.WebServiceJobHandle; public interface TaskI { /** + * Get the universal identifier of this task. + * + * @return identifier + */ + long getUid(); + + /** * Get the current status of the task. The resultant status should be a * combination of individual sub-job statuses. * -- 1.7.10.2