diff --git a/pom.xml b/pom.xml
index a2ae5f7..7042978 100644
--- a/pom.xml
+++ b/pom.xml
@@ -119,6 +119,14 @@
[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)
provided
+
+
+
+ org.gcube.portlets.user
+ tabular-data-monitor-widget
+ [1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)
+ provided
+
diff --git a/src/main/java/org/gcube/portlets/user/td/csvexportwidget/client/CSVOperationInProgressCard.java b/src/main/java/org/gcube/portlets/user/td/csvexportwidget/client/CSVOperationInProgressCard.java
index 2410493..d63f1f0 100644
--- a/src/main/java/org/gcube/portlets/user/td/csvexportwidget/client/CSVOperationInProgressCard.java
+++ b/src/main/java/org/gcube/portlets/user/td/csvexportwidget/client/CSVOperationInProgressCard.java
@@ -3,12 +3,14 @@
*/
package org.gcube.portlets.user.td.csvexportwidget.client;
-import org.gcube.portlets.user.td.csvexportwidget.client.progress.CSVExportProgressBarUpdater;
-import org.gcube.portlets.user.td.csvexportwidget.client.progress.CSVExportProgressListener;
-import org.gcube.portlets.user.td.csvexportwidget.client.progress.CSVExportProgressUpdater;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVExportSession;
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.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;
@@ -35,12 +37,13 @@ import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler;
*
*/
public class CSVOperationInProgressCard extends WizardCard implements
- CSVExportProgressListener {
+ MonitorUpdaterListener {
public static final int STATUS_POLLING_DELAY = 1000;
protected CSVOperationInProgressCard thisCard;
protected CSVExportSession exportSession;
- protected CSVExportProgressUpdater progressUpdater;
+ protected MonitorUpdater progressUpdater;
+ protected ProgressBar progressBar;
public CSVOperationInProgressCard(final CSVExportSession exportSession) {
super("Operation In Progress", "");
@@ -79,13 +82,9 @@ public class CSVOperationInProgressCard extends WizardCard implements
ProgressBar progressBar = new ProgressBar();
operationInProgressPanel.add(progressBar, new BoxLayoutData(
new Margins(10, 5, 10, 5)));
+
- progressUpdater = new CSVExportProgressUpdater();
- progressUpdater
- .addListener(new CSVExportProgressBarUpdater(progressBar));
-
- progressUpdater.addListener(this);
-
+
setContent(operationInProgressPanel);
}
@@ -94,10 +93,17 @@ public class CSVOperationInProgressCard extends WizardCard implements
public void exportCSV() {
TDGWTServiceAsync.INSTANCE.startCSVExport(exportSession,
- 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) {
@@ -127,24 +133,27 @@ public class CSVOperationInProgressCard extends WizardCard implements
exportCSV();
}
- public void operationInitializing() {
+
+ @Override
+ public void monitorInitializing() {
}
-
- public void operationUpdate(float elaborated) {
+
+ @Override
+ public void monitorUpdate(float elaborated) {
}
-
- public void operationComplete() {
- // final String tableId,final String tableResourceId) {
-
+
+ @Override
+ public void monitorComplete(final TRId trId) {
+
Command sayComplete = new Command() {
public void execute() {
try {
getWizardWindow().close(false);
- Log.info("fire Complete: tableId");
-
- getWizardWindow().fireCompleted(null);
+ Log.info("fire Complete: "+ trId);
+
+ getWizardWindow().fireCompleted(trId);
} catch (Exception e) {
Log.error("fire Complete :" + e.getLocalizedMessage());
@@ -157,8 +166,9 @@ public class CSVOperationInProgressCard extends WizardCard implements
setNextButtonVisible(true);
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()
@@ -166,8 +176,7 @@ public class CSVOperationInProgressCard extends WizardCard implements
new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
-
- AlertMessageBox d = new AlertMessageBox("Error in CSV Export",
+ AlertMessageBox d = new AlertMessageBox("Error in Codelist Mapping Import",
reason);
d.addHideHandler(new HideHandler() {
public void onHide(HideEvent event) {
@@ -178,16 +187,16 @@ public class CSVOperationInProgressCard extends WizardCard implements
}
@Override
- public void operationStopped(TRId trId, String reason, String details) {
- // final String tableId,final String tableResourceId) {
-
+ public void monitorStopped(final TRId trId, String reason, String details) {
+
Command sayComplete = new Command() {
public void execute() {
try {
getWizardWindow().close(false);
- Log.info("fire Complete: tableId");
+ Log.info("fire Complete: tabular resource " + trId.getId());
+ Log.info("fire Complete: tableId " + trId.getTableId());
- getWizardWindow().fireCompleted(null);
+ getWizardWindow().fireCompleted(trId);
} catch (Exception e) {
Log.error("fire Complete :" + e.getLocalizedMessage());
@@ -203,15 +212,37 @@ public class CSVOperationInProgressCard extends WizardCard implements
}
@Override
- public void operationGeneratingView() {
+ public void monitorGeneratingView() {
// TODO Auto-generated method stub
}
@Override
- public void operationValidate(float elaborated) {
+ public void monitorValidate(float elaborated) {
// TODO Auto-generated method stub
}
+
+ @Override
+ public void monitorChanged(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/csvexportwidget/client/progress/CSVExportProgressBarUpdater.java b/src/main/java/org/gcube/portlets/user/td/csvexportwidget/client/progress/CSVExportProgressBarUpdater.java
deleted file mode 100644
index 6e3f06a..0000000
--- a/src/main/java/org/gcube/portlets/user/td/csvexportwidget/client/progress/CSVExportProgressBarUpdater.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/**
- *
- */
-package org.gcube.portlets.user.td.csvexportwidget.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 CSVExportProgressListener} events.
- *
- * @author "Giancarlo Panichi"
- * g.panichi@isti.cnr.it
- *
- */
-public class CSVExportProgressBarUpdater implements CSVExportProgressListener {
-
- protected ProgressBar progressBar;
- //protected FramedPanel operationResult;
- //protected WizardWindow wizardWindow;
- /**
- * Creates a new {@link ProgressBar} updater.
- * @param progressBar the {@link ProgressBar} to update.
- */
- public CSVExportProgressBarUpdater(ProgressBar progressBar) {
- this.progressBar = progressBar;
- this.progressBar.updateProgress(0, "Please Wait...");
- }
-
-
- /**
- * {@inheritDoc}
- */
- public void operationComplete() {
- Log.info("Export completed");
- progressBar.updateProgress(1, "Export completed.");
-
- }
-
- /**
- * {@inheritDoc}
- */
- public void operationFailed(Throwable caught, String reason, String failureDetails) {
- Log.info("Export failed");
- progressBar.updateText("Export failed");
- }
-
- public void operationInitializing() {
- Log.info("Export 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+"% Exporting...");
- }
- 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/csvexportwidget/client/progress/CSVExportProgressListener.java b/src/main/java/org/gcube/portlets/user/td/csvexportwidget/client/progress/CSVExportProgressListener.java
deleted file mode 100644
index 95f5621..0000000
--- a/src/main/java/org/gcube/portlets/user/td/csvexportwidget/client/progress/CSVExportProgressListener.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/**
- *
- */
-package org.gcube.portlets.user.td.csvexportwidget.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 CSVExportProgressListener {
-
- /**
- * 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();
-
- /**
- * 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/csvexportwidget/client/progress/CSVExportProgressUpdater.java b/src/main/java/org/gcube/portlets/user/td/csvexportwidget/client/progress/CSVExportProgressUpdater.java
deleted file mode 100644
index daa80cf..0000000
--- a/src/main/java/org/gcube/portlets/user/td/csvexportwidget/client/progress/CSVExportProgressUpdater.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/**
- *
- */
-package org.gcube.portlets.user.td.csvexportwidget.client.progress;
-
-import java.util.ArrayList;
-
-import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
-import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVExportMonitor;
-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;
-
-/**
- *
- * @author "Giancarlo Panichi"
- * g.panichi@isti.cnr.it
- *
- */
-
-public class CSVExportProgressUpdater extends Timer {
-
- protected ArrayList listeners = new ArrayList();
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void run() {
- Log.debug("requesting operation progress");
- TDGWTServiceAsync.INSTANCE
- .getCSVExportMonitor(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(CSVExportMonitor result) {
- Log.info("retrieved CSVImportMonitor: "
- + result.getStatus());
- switch (result.getStatus()) {
- case INITIALIZING:
- Log.info("CSV Export Initializing...");
- fireOperationInitializing();
- break;
- case ABORTED:
- cancel();
- Log.info("CSV Export 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 FAILED:
- cancel();
- errorMessage(result);
- break;
- case STOPPED:
- cancel();
- stopMessage(result);
- break;
- case SUCCEDED:
- cancel();
- Log.info("Export fisnish ExportMetadata:"
- + result.getTrExportMetadata());
- fireOperationComplete();
- break;
- default:
- Log.info("Unknow State");
- break;
- }
-
- }
-
- });
-
- }
-
- protected void errorMessage(CSVExportMonitor result) {
- Log.info("CSV Export Failed");
- Throwable th = null;
- String failure = null;
- String details = null;
- if (result.getError() != null) {
- th = result.getError();
- failure = "Failed Client Library Export";
- details = result.getError().getLocalizedMessage();
- } else {
- th = new Throwable("Failed");
- failure = "Failed Client Library Export";
- details = "Error in export";
- }
-
- fireOperationFailed(th, failure, details);
- }
-
-
- protected void stopMessage(CSVExportMonitor result) {
- Log.info("CSV Export Stopped");
- String failure = null;
- String details = null;
- if (result.getError() != null) {
- failure = "Stopped export csv";
- details = result.getError().getLocalizedMessage();
- } else {
- failure = "Stopped export csv";
- details = "Stopped export csv";
- }
-
- 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 (CSVExportProgressListener listener : listeners)
- listener.operationInitializing();
- }
-
- protected void fireOperationGeneratingView() {
- for (CSVExportProgressListener listener : listeners)
- listener.operationGeneratingView();
- }
-
- protected void fireOperationUpdate(float elaborated) {
- for (CSVExportProgressListener listener : listeners)
- listener.operationUpdate(elaborated);
- }
-
- protected void fireOperationValidate(float elaborated) {
- for (CSVExportProgressListener listener : listeners)
- listener.operationValidate(elaborated);
- }
-
- protected void fireOperationComplete() {
- for (CSVExportProgressListener listener : listeners)
- listener.operationComplete();
- }
-
- protected void fireOperationFailed(Throwable caught, String failure,
- String failureDetails) {
- for (CSVExportProgressListener listener : listeners)
- listener.operationFailed(caught, failure, failureDetails);
- }
-
- protected void fireOperationStopped(TRId trId, String reason, String details) {
- for (CSVExportProgressListener listener : listeners)
- listener.operationStopped(trId,reason, details);
- }
-
- /**
- * Add a new {@link CSVExportProgressListener} to this
- * {@link CSVExportProgressUpdater}.
- *
- * @param listener
- * the listener to add.
- */
- public void addListener(CSVExportProgressListener listener) {
- listeners.add(listener);
- }
-
- /**
- * Removes the specified {@link CSVExportProgressListener} from this
- * {@link CSVExportProgressUpdater}.
- *
- * @param listener
- * the listener to remove.
- */
- public void removeListener(CSVExportProgressListener listener) {
- listeners.remove(listener);
- }
-}
diff --git a/src/main/resources/org/gcube/portlets/user/td/csvexportwidget/CSVExportWizardTD.gwt.xml b/src/main/resources/org/gcube/portlets/user/td/csvexportwidget/CSVExportWizardTD.gwt.xml
index e076f7e..5db8a54 100644
--- a/src/main/resources/org/gcube/portlets/user/td/csvexportwidget/CSVExportWizardTD.gwt.xml
+++ b/src/main/resources/org/gcube/portlets/user/td/csvexportwidget/CSVExportWizardTD.gwt.xml
@@ -19,6 +19,7 @@
+