From 17798de7f9c2ed05a598f4df94c6dc029e4d96e9 Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Thu, 28 Aug 2014 18:12:50 +0000 Subject: [PATCH] Updated OperationMonitor git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@99338 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../user/td/gwtservice/shared/task/State.java | 31 +++++++++++---- .../gwtservice/shared/task/WorkerState.java | 28 +++++++++++-- .../shared/task/WorkerStateParser.java | 39 +++++++++++++++++++ 3 files changed, 86 insertions(+), 12 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/td/gwtservice/shared/task/WorkerStateParser.java diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/task/State.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/task/State.java index d67e25a..3899ffe 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/task/State.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/task/State.java @@ -11,13 +11,28 @@ import java.io.Serializable; * */ public enum State implements Serializable{ - INITIALIZING, - IN_PROGRESS, - VALIDATING_RULES, - GENERATING_VIEW, - STOPPED, - SUCCEDED, - ABORTED, - FAILED; + INITIALIZING("Initializing"), + IN_PROGRESS("In Progress"), + VALIDATING_RULES("Validating Rules"), + GENERATING_VIEW("Generating View"), + STOPPED("Stopped"), + SUCCEDED("Succeded"), + ABORTED("Aborted"), + FAILED("Failed"); + + /** + * @param text + */ + private State(final String id) { + this.id = id; + } + + private final String id; + + @Override + public String toString() { + return id; + } + } diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/task/WorkerState.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/task/WorkerState.java index 5b1b813..113374a 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/task/WorkerState.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/task/WorkerState.java @@ -2,11 +2,31 @@ package org.gcube.portlets.user.td.gwtservice.shared.task; /** * - * @author "Giancarlo Panichi" - * email: g.panichi@isti.cnr.it - * + * @author "Giancarlo Panichi" email: g.panichi@isti.cnr.it + * */ public enum WorkerState { - PENDING, INITIALIZING, VALIDATING_DATA, IN_PROGRESS, SUCCEDED, FAILED + PENDING("Pending"), + INITIALIZING("Initializing"), + VALIDATING_DATA("Validating Data"), + IN_PROGRESS("In Progress"), + SUCCEDED("Succeded"), + FAILED("Failed"); + + /** + * @param text + */ + private WorkerState(final String id) { + this.id = id; + } + + private final String id; + + @Override + public String toString() { + return id; + } + } diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/task/WorkerStateParser.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/task/WorkerStateParser.java new file mode 100644 index 0000000..5cd7b09 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/task/WorkerStateParser.java @@ -0,0 +1,39 @@ +package org.gcube.portlets.user.td.gwtservice.shared.task; + +/** + * + * @author giancarlo email: g.panichi@isti.cnr.it + * + */ +public class WorkerStateParser { + + public static WorkerState parse(String state) { + if (WorkerState.PENDING.toString().compareTo(state) == 0) { + return WorkerState.PENDING; + } else { + if (WorkerState.INITIALIZING.toString().compareTo(state) == 0) { + return WorkerState.INITIALIZING; + } else { + if (WorkerState.VALIDATING_DATA.toString().compareTo(state) == 0) { + return WorkerState.VALIDATING_DATA; + } else { + if (WorkerState.IN_PROGRESS.toString().compareTo(state) == 0) { + return WorkerState.IN_PROGRESS; + } else { + if (WorkerState.SUCCEDED.toString().compareTo(state) == 0) { + return WorkerState.SUCCEDED; + } else { + if (WorkerState.FAILED.toString().compareTo(state) == 0) { + return WorkerState.FAILED; + } else { + return null; + } + } + } + } + } + } + + } +}