diff --git a/pom.xml b/pom.xml
index 0a1ff55..eb91d24 100644
--- a/pom.xml
+++ b/pom.xml
@@ -125,7 +125,15 @@
provided
-
+
+
+ org.gcube.portlets.user
+ tabular-data-monitor-widget
+ [1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)
+ provided
+
+
+
org.gcube.portlets.user
diff --git a/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/UnionOperationInProgressCard.java b/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/UnionOperationInProgressCard.java
index 29fbb79..eb1fe9b 100644
--- a/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/UnionOperationInProgressCard.java
+++ b/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/UnionOperationInProgressCard.java
@@ -5,10 +5,12 @@ package org.gcube.portlets.user.td.unionwizardwidget.client;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
+import org.gcube.portlets.user.td.gwtservice.shared.monitor.OperationMonitor;
+import org.gcube.portlets.user.td.gwtservice.shared.monitor.OperationMonitorSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.union.UnionSession;
-import org.gcube.portlets.user.td.unionwizardwidget.client.progress.UnionProgressBarUpdater;
-import org.gcube.portlets.user.td.unionwizardwidget.client.progress.UnionProgressListener;
-import org.gcube.portlets.user.td.unionwizardwidget.client.progress.UnionProgressUpdater;
+import org.gcube.portlets.user.td.monitorwidget.client.MonitorBarUpdater;
+import org.gcube.portlets.user.td.monitorwidget.client.MonitorUpdater;
+import org.gcube.portlets.user.td.monitorwidget.client.MonitorUpdaterListener;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
@@ -28,8 +30,6 @@ import com.sencha.gxt.widget.core.client.container.VBoxLayoutContainer.VBoxLayou
import com.sencha.gxt.widget.core.client.event.HideEvent;
import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler;
-
-
/**
*
* @author "Giancarlo Panichi" Union with: ");
- description.setText(0, 1, unionSession.getUnionTabularResource().getName());
+ description.setText(0, 1, unionSession.getUnionTabularResource()
+ .getName());
description.setHTML(1, 0,
"Type: ");
- description.setText(1, 1, unionSession.getUnionTabularResource().getTabularResourceType());
+ description.setText(1, 1, unionSession.getUnionTabularResource()
+ .getTabularResourceType());
description.setHTML(2, 0,
"Owner: ");
- description.setText(2, 1, unionSession.getUnionTabularResource().getOwnerLogin());
+ description.setText(2, 1, unionSession.getUnionTabularResource()
+ .getOwnerLogin());
FramedPanel summary = new FramedPanel();
summary.setHeadingText("Union Summary");
@@ -80,12 +84,6 @@ public class UnionOperationInProgressCard extends WizardCard implements
operationInProgressPanel.add(progressBar, new BoxLayoutData(
new Margins(10, 5, 10, 5)));
- progressUpdater = new UnionProgressUpdater();
- progressUpdater
- .addListener(new UnionProgressBarUpdater(progressBar));
-
- progressUpdater.addListener(this);
-
setContent(operationInProgressPanel);
}
@@ -95,10 +93,19 @@ public class UnionOperationInProgressCard extends WizardCard implements
*/
public void startUnion() {
TDGWTServiceAsync.INSTANCE.startUnion(unionSession,
- new AsyncCallback() {
+ new AsyncCallback() {
- public void onSuccess(Void result) {
+ public void onSuccess(String taskId) {
+ OperationMonitorSession operationMonitorSession = new OperationMonitorSession(
+ taskId);
+ progressUpdater = new MonitorUpdater(
+ operationMonitorSession);
+ progressUpdater.addListener(new MonitorBarUpdater(
+ progressBar));
+
+ progressUpdater.addListener(thisCard);
progressUpdater.scheduleRepeating(STATUS_POLLING_DELAY);
+
}
public void onFailure(Throwable caught) {
@@ -116,7 +123,7 @@ public class UnionOperationInProgressCard extends WizardCard implements
}
}
});
-
+
}
@Override
@@ -129,22 +136,25 @@ public class UnionOperationInProgressCard extends WizardCard implements
startUnion();
}
- public void operationInitializing() {
+ @Override
+ public void monitorInitializing(OperationMonitor operationMonitor) {
}
- public void operationUpdate(float elaborated) {
+ @Override
+ public void monitorUpdate(OperationMonitor operationMonitor) {
}
- public void operationComplete(final TRId trId) {
-
+ @Override
+ public void monitorComplete(final TRId trId) {
+
Command sayComplete = new Command() {
public void execute() {
try {
getWizardWindow().close(false);
- Log.info("fire Complete: "+ trId);
-
+ Log.info("fire Complete: " + trId);
+
getWizardWindow().fireCompleted(trId);
} catch (Exception e) {
@@ -159,7 +169,8 @@ public class UnionOperationInProgressCard extends WizardCard implements
getWizardWindow().setEnableNextButton(true);
}
- public void operationFailed(Throwable caught, String reason,
+ @Override
+ public void monitorFailed(Throwable caught, String reason,
String failureDetails) {
if (caught instanceof TDGWTSessionExpiredException) {
getEventBus()
@@ -167,8 +178,8 @@ public class UnionOperationInProgressCard extends WizardCard implements
new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
- AlertMessageBox d = new AlertMessageBox("Error in Union",
- reason);
+ AlertMessageBox d = new AlertMessageBox(
+ "Error in Codelist Mapping Import", reason);
d.addHideHandler(new HideHandler() {
public void onHide(HideEvent event) {
}
@@ -178,8 +189,8 @@ public class UnionOperationInProgressCard extends WizardCard implements
}
@Override
- public void operationStopped(final TRId trId, String reason, String details) {
-
+ public void monitorStopped(final TRId trId, String reason, String details) {
+
Command sayComplete = new Command() {
public void execute() {
try {
@@ -203,13 +214,27 @@ public class UnionOperationInProgressCard extends WizardCard implements
}
@Override
- public void operationGeneratingView() {
+ public void monitorGeneratingView(OperationMonitor operationMonitor) {
// TODO Auto-generated method stub
}
@Override
- public void operationValidate(float elaborated) {
+ public void monitorValidate(OperationMonitor operationMonitor) {
+ // TODO Auto-generated method stub
+
+ }
+
+
+
+ @Override
+ public void monitorAborted() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void monitorPutInBackground() {
// TODO Auto-generated method stub
}
diff --git a/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/progress/UnionProgressBarUpdater.java b/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/progress/UnionProgressBarUpdater.java
deleted file mode 100644
index a745b80..0000000
--- a/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/progress/UnionProgressBarUpdater.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/**
- *
- */
-package org.gcube.portlets.user.td.unionwizardwidget.client.progress;
-
-
-
-
-import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
-
-import com.allen_sauer.gwt.log.client.Log;
-import com.sencha.gxt.widget.core.client.ProgressBar;
-
-/**
- * Updates a {@link ProgressBar} progress and text based on {@link UnionProgressListener} events.
- *
- * @author "Giancarlo Panichi"
- * g.panichi@isti.cnr.it
- *
- */
-public class UnionProgressBarUpdater implements UnionProgressListener {
-
- protected ProgressBar progressBar;
-
- /**
- * Creates a new {@link ProgressBar} updater.
- * @param progressBar the {@link ProgressBar} to update.
- */
- public UnionProgressBarUpdater(ProgressBar progressBar) {
- this.progressBar = progressBar;
- this.progressBar.updateProgress(0, "Please Wait...");
- }
-
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void operationComplete(TRId trId) {
- Log.info("Completed");
- progressBar.updateProgress(1, "Completed");
-
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void operationFailed(Throwable caught, String reason, String failureDetails) {
- Log.info("Failed");
- progressBar.updateText("Failed");
- }
-
- @Override
- public void operationInitializing() {
- Log.info("Inizializing");
- progressBar.updateProgress(0, "Initializing...");
- }
-
- @Override
- public void operationUpdate(float elaborated) {
- Log.info("Elaborated: "+elaborated);
- if (elaborated>=0 && elaborated<1) {
- Log.trace("progress "+elaborated);
- int elab=new Float(elaborated*100).intValue();
- progressBar.updateProgress(elaborated,elab+"% Progress...");
- }
- if (elaborated == 1) progressBar.updateProgress(1, "Completing...");
-
- }
-
- @Override
- public void operationValidate(float elaborated) {
- Log.info("Validation Elaborated: "+elaborated);
- if (elaborated == 0) progressBar.updateProgress(0, "Start Validation...");
- if (elaborated>0 && elaborated<1) {
- Log.trace("Validation progress "+elaborated);
- int elab=new Float(elaborated*100).intValue();
- progressBar.updateProgress(elaborated,elab+"% Validation Progress...");
- }
- if (elaborated == 1) progressBar.updateProgress(1, "Validation...");
- }
-
- @Override
- public void operationStopped(TRId trId,String reason, String details) {
- Log.debug("Operation Stopped: ["+trId.toString()+", "+reason+", "+details+"]");
- progressBar.updateText("Validations failed");
-
- }
-
-
- @Override
- public void operationGeneratingView() {
- Log.info("Generating View...");
- progressBar.updateText("Generating View...");
-
- }
-
-}
diff --git a/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/progress/UnionProgressListener.java b/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/progress/UnionProgressListener.java
deleted file mode 100644
index 8aee58d..0000000
--- a/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/progress/UnionProgressListener.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/**
- *
- */
-package org.gcube.portlets.user.td.unionwizardwidget.client.progress;
-
-import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
-
-
-
-/**
- * Defines a listener for operation progress.
- *
- * @author "Giancarlo Panichi"
- * g.panichi@isti.cnr.it
- *
- */
-public interface UnionProgressListener {
-
- /**
- * Called when the operation is starting.
- */
- public void operationInitializing();
-
- /**
- * Called when there is a progress for the operation.
- * @param elaborated the elaborated part.
- */
- public void operationUpdate(float elaborated);
-
- /**
- * Called when there is a validate for the operation.
- * @param elaborated the elaborated part.
- */
- public void operationValidate(float elaborated);
-
-
- /**
- * Called when the operation is complete.
- */
- public void operationComplete(TRId trId);
-
- /**
- * Called when the operation is failed.
- * @param caught the failure exception.
- * @param reason the failure reason.
- */
- public void operationFailed(Throwable caught, String reason, String failureDetails);
-
- /**
- * Called when the operation is stopped
- *
- * @param trId
- * @param reason
- * @param details
- */
- public void operationStopped(TRId trId, String reason, String details);
-
- /**
- * Called when the operation is generating the view
- */
- public void operationGeneratingView();
-
-}
diff --git a/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/progress/UnionProgressUpdater.java b/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/progress/UnionProgressUpdater.java
deleted file mode 100644
index e0914da..0000000
--- a/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/progress/UnionProgressUpdater.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/**
- *
- */
-package org.gcube.portlets.user.td.unionwizardwidget.client.progress;
-
-import java.util.ArrayList;
-
-import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
-import org.gcube.portlets.user.td.gwtservice.shared.monitor.UnionMonitor;
-import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
-
-import com.allen_sauer.gwt.log.client.Log;
-import com.google.gwt.user.client.Timer;
-import com.google.gwt.user.client.rpc.AsyncCallback;
-
-/**
- * This {@link Timer} retrieves {@link OperationProgress} from the specified
- * {@link OperationProgressSource} with the scheduled interval. The retrieved
- * information are spread to the subscribed {@link UnionProgressListener}.
- *
- * @author "Giancarlo Panichi" g.panichi@isti.cnr.it
- *
- */
-public class UnionProgressUpdater extends Timer {
-
- protected ArrayList listeners = new ArrayList();
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void run() {
- Log.debug("requesting operation progress");
- TDGWTServiceAsync.INSTANCE
- .getUnionMonitor(new AsyncCallback() {
-
-
- public void onFailure(Throwable caught) {
- cancel();
- Log.error("Error retrieving the operation state",
- caught);
- String message = getStack(caught);
- fireOperationFailed(caught,
- "Failed getting operation updates", message);
- }
-
- public void onSuccess(UnionMonitor result) {
- Log.info("retrieved Monitor: "
- + result.getStatus());
- switch (result.getStatus()) {
- case INITIALIZING:
- Log.info("Initializing...");
- fireOperationInitializing();
- break;
- case ABORTED:
- cancel();
- Log.info("Operation Aborted");
- break;
- case IN_PROGRESS:
- fireOperationUpdate(result.getProgress());
- break;
- case VALIDATING_RULES:
- fireOperationValidate(result.getProgress());
- break;
- case GENERATING_VIEW:
- Log.info("Generating View...");
- fireOperationGeneratingView();
- break;
- case STOPPED:
- cancel();
- stopMessage(result);
- break;
- case FAILED:
- cancel();
- errorMessage(result);
- break;
- case SUCCEDED:
- cancel();
- Log.info("Fisnish:"
- + result.getTrId());
- fireOperationComplete(result.getTrId());
- break;
- default:
- Log.info("Unknow State");
- break;
- }
-
- }
-
- });
-
- }
-
- protected void errorMessage(UnionMonitor result) {
- Log.info("Union Failed");
- Throwable th = null;
- String failure = null;
- String details = null;
- if (result.getError() != null) {
- th = result.getError();
- failure = "Failed Client Library on Union";
- details = result.getError().getLocalizedMessage();
- } else {
- th = new Throwable("Failed");
- failure = "Failed Client Library on Union";
- details = "Error in union";
- }
- fireOperationFailed(th, failure, details);
-
- }
-
- protected void stopMessage(UnionMonitor result) {
- Log.info("Union Stopped");
- String failure = null;
- String details = null;
- if (result.getError() != null) {
- failure = "Stopped";
- details = result.getError().getLocalizedMessage();
- } else {
- failure = "Stopped";
- details = "Stopped Union";
- }
-
- fireOperationStopped(result.getTrId(),failure, details);
- }
-
- protected String getStack(Throwable e) {
- String message = e.getLocalizedMessage() + " ->
";
- Throwable c = e.getCause();
- if (c != null)
- message += getStack(c);
- return message;
- }
-
- protected void fireOperationInitializing() {
- for (UnionProgressListener listener : listeners)
- listener.operationInitializing();
- }
-
- protected void fireOperationGeneratingView() {
- for (UnionProgressListener listener : listeners)
- listener.operationGeneratingView();
- }
-
- protected void fireOperationUpdate(float elaborated) {
- for (UnionProgressListener listener : listeners)
- listener.operationUpdate(elaborated);
- }
-
- protected void fireOperationValidate(float elaborated) {
- for (UnionProgressListener listener : listeners)
- listener.operationValidate(elaborated);
- }
-
- protected void fireOperationComplete(TRId trId) {
- for (UnionProgressListener listener : listeners)
- listener.operationComplete(trId);
- }
-
- protected void fireOperationFailed(Throwable caught, String failure,
- String failureDetails) {
- for (UnionProgressListener listener : listeners)
- listener.operationFailed(caught, failure, failureDetails);
- }
-
- protected void fireOperationStopped(TRId trId, String reason, String details) {
- for (UnionProgressListener listener : listeners)
- listener.operationStopped(trId,reason, details);
- }
-
- /**
- * Add a new {@link UnionProgressListener} to this
- * {@link UnionProgressUpdater}.
- *
- * @param listener
- * the listener to add.
- */
- public void addListener(UnionProgressListener listener) {
- listeners.add(listener);
- }
-
- /**
- * Removes the specified {@link UnionProgressListener} from this
- * {@link UnionProgressUpdater}.
- *
- * @param listener
- * the listener to remove.
- */
- public void removeListener(UnionProgressListener listener) {
- listeners.remove(listener);
- }
-}
diff --git a/src/main/resources/org/gcube/portlets/user/td/unionwizardwidget/UnionWizardTD.gwt.xml b/src/main/resources/org/gcube/portlets/user/td/unionwizardwidget/UnionWizardTD.gwt.xml
index 1fc13c1..7f2ef90 100644
--- a/src/main/resources/org/gcube/portlets/user/td/unionwizardwidget/UnionWizardTD.gwt.xml
+++ b/src/main/resources/org/gcube/portlets/user/td/unionwizardwidget/UnionWizardTD.gwt.xml
@@ -19,6 +19,7 @@
+