Minor Update
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-sdmx-export-widget@99291 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
1a6107ad76
commit
9ef7fac1d1
|
@ -0,0 +1,2 @@
|
|||
disabled=06target
|
||||
eclipse.preferences.version=1
|
8
pom.xml
8
pom.xml
|
@ -123,6 +123,14 @@
|
|||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- tabular-data-monitor-widget -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>tabular-data-monitor-widget</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- tabular-data-wizard-widget -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.portlets.user</groupId>
|
||||
|
|
|
@ -5,10 +5,12 @@ package org.gcube.portlets.user.td.sdmxexportwidget.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.sdmx.SDMXExportSession;
|
||||
import org.gcube.portlets.user.td.sdmxexportwidget.client.progress.SDMXExportProgressBarUpdater;
|
||||
import org.gcube.portlets.user.td.sdmxexportwidget.client.progress.SDMXExportProgressListener;
|
||||
import org.gcube.portlets.user.td.sdmxexportwidget.client.progress.SDMXExportProgressUpdater;
|
||||
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 SDMXOperationInProgressCard extends WizardCard implements
|
||||
SDMXExportProgressListener {
|
||||
MonitorUpdaterListener {
|
||||
|
||||
public static final int STATUS_POLLING_DELAY = 1000;
|
||||
protected SDMXOperationInProgressCard thisCard;
|
||||
protected SDMXExportSession exportSession;
|
||||
protected SDMXExportProgressUpdater progressUpdater;
|
||||
protected MonitorUpdater progressUpdater;
|
||||
protected ProgressBar progressBar;
|
||||
|
||||
public SDMXOperationInProgressCard(final SDMXExportSession exportSession) {
|
||||
super("Operation In Progress", "");
|
||||
|
@ -96,12 +99,7 @@ public class SDMXOperationInProgressCard extends WizardCard implements
|
|||
operationInProgressPanel.add(progressBar, new BoxLayoutData(
|
||||
new Margins(10, 5, 10, 5)));
|
||||
|
||||
progressUpdater = new SDMXExportProgressUpdater();
|
||||
progressUpdater.addListener(new SDMXExportProgressBarUpdater(
|
||||
progressBar));
|
||||
|
||||
progressUpdater.addListener(this);
|
||||
|
||||
|
||||
setContent(operationInProgressPanel);
|
||||
|
||||
}
|
||||
|
@ -110,10 +108,19 @@ public class SDMXOperationInProgressCard extends WizardCard implements
|
|||
|
||||
public void exportSDMX() {
|
||||
TDGWTServiceAsync.INSTANCE.startSDMXExport(exportSession,
|
||||
new AsyncCallback<Void>() {
|
||||
new AsyncCallback<String>() {
|
||||
|
||||
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) {
|
||||
|
@ -145,24 +152,25 @@ public class SDMXOperationInProgressCard extends WizardCard implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public void operationInitializing() {
|
||||
public void monitorInitializing(OperationMonitor operationMonitor) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void operationUpdate(float elaborated) {
|
||||
public void monitorUpdate(OperationMonitor operationMonitor) {
|
||||
|
||||
}
|
||||
|
||||
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");
|
||||
getWizardWindow().fireCompleted(null);
|
||||
Log.info("fire Complete: " + trId);
|
||||
|
||||
getWizardWindow().fireCompleted(trId);
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.error("fire Complete :" + e.getLocalizedMessage());
|
||||
|
@ -176,7 +184,8 @@ public class SDMXOperationInProgressCard 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()
|
||||
|
@ -184,27 +193,27 @@ public class SDMXOperationInProgressCard extends WizardCard implements
|
|||
new SessionExpiredEvent(
|
||||
SessionExpiredType.EXPIREDONSERVER));
|
||||
} else {
|
||||
AlertMessageBox d = new AlertMessageBox("Error in SDMX Export",
|
||||
reason);
|
||||
AlertMessageBox d = new AlertMessageBox(
|
||||
"Error in Codelist Mapping Import", reason);
|
||||
d.addHideHandler(new HideHandler() {
|
||||
public void onHide(HideEvent event) {
|
||||
}
|
||||
|
||||
});
|
||||
d.show();
|
||||
}
|
||||
}
|
||||
|
||||
@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");
|
||||
getWizardWindow().fireCompleted(null);
|
||||
Log.info("fire Complete: tabular resource " + trId.getId());
|
||||
Log.info("fire Complete: tableId " + trId.getTableId());
|
||||
|
||||
getWizardWindow().fireCompleted(trId);
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.error("fire Complete :" + e.getLocalizedMessage());
|
||||
|
@ -220,13 +229,27 @@ public class SDMXOperationInProgressCard 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
|
||||
|
||||
}
|
||||
|
|
|
@ -1,99 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.td.sdmxexportwidget.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 SDMXExportProgressListener} events.
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class SDMXExportProgressBarUpdater implements SDMXExportProgressListener {
|
||||
|
||||
protected ProgressBar progressBar;
|
||||
//protected FramedPanel operationResult;
|
||||
//protected WizardWindow wizardWindow;
|
||||
/**
|
||||
* Creates a new {@link ProgressBar} updater.
|
||||
* @param progressBar the {@link ProgressBar} to update.
|
||||
*/
|
||||
public SDMXExportProgressBarUpdater(ProgressBar progressBar) {
|
||||
this.progressBar = progressBar;
|
||||
this.progressBar.updateProgress(0, "Please Wait...");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void operationComplete() {
|
||||
Log.info("Export completed");
|
||||
progressBar.updateProgress(1, "Export completed.");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void operationFailed(Throwable caught, String reason, String failureDetails) {
|
||||
Log.info("Export failed");
|
||||
progressBar.updateText("Export failed");
|
||||
}
|
||||
|
||||
@Override
|
||||
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...");
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.td.sdmxexportwidget.client.progress;
|
||||
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Defines a listener for operation progress.
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public interface SDMXExportProgressListener {
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
}
|
|
@ -1,191 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.td.sdmxexportwidget.client.progress;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXExportMonitor;
|
||||
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"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
|
||||
public class SDMXExportProgressUpdater extends Timer {
|
||||
|
||||
protected ArrayList<SDMXExportProgressListener> listeners = new ArrayList<SDMXExportProgressListener>();
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
Log.debug("requesting operation progress");
|
||||
TDGWTServiceAsync.INSTANCE
|
||||
.getSDMXExportMonitor(new AsyncCallback<SDMXExportMonitor>() {
|
||||
|
||||
|
||||
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(SDMXExportMonitor result) {
|
||||
Log.info("retrieved SDMXImportMonitor: "
|
||||
+ result.getStatus());
|
||||
switch (result.getStatus()) {
|
||||
case INITIALIZING:
|
||||
Log.info("SDMX Export Initializing...");
|
||||
fireOperationInitializing();
|
||||
break;
|
||||
case ABORTED:
|
||||
cancel();
|
||||
Log.info("SDMX 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");
|
||||
fireOperationComplete();
|
||||
break;
|
||||
|
||||
default:
|
||||
Log.info("Unknow State");
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
protected void errorMessage(SDMXExportMonitor result) {
|
||||
Log.info("SDMX 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(SDMXExportMonitor result) {
|
||||
Log.info("SDMX Export Stopped");
|
||||
String failure = null;
|
||||
String details = null;
|
||||
if (result.getError() != null) {
|
||||
failure = "Stopped";
|
||||
details = result.getError().getLocalizedMessage();
|
||||
} else {
|
||||
failure = "Stopped";
|
||||
details = "Stopped export SDMX";
|
||||
}
|
||||
|
||||
fireOperationStopped(result.getTrId(),failure, details);
|
||||
}
|
||||
|
||||
protected String getStack(Throwable e) {
|
||||
String message = e.getLocalizedMessage() + " -> <br>";
|
||||
Throwable c = e.getCause();
|
||||
if (c != null)
|
||||
message += getStack(c);
|
||||
return message;
|
||||
}
|
||||
|
||||
protected void fireOperationInitializing() {
|
||||
for (SDMXExportProgressListener listener : listeners)
|
||||
listener.operationInitializing();
|
||||
}
|
||||
|
||||
protected void fireOperationGeneratingView() {
|
||||
for (SDMXExportProgressListener listener : listeners)
|
||||
listener.operationGeneratingView();
|
||||
}
|
||||
|
||||
|
||||
protected void fireOperationUpdate(float elaborated) {
|
||||
for (SDMXExportProgressListener listener : listeners)
|
||||
listener.operationUpdate(elaborated);
|
||||
}
|
||||
|
||||
protected void fireOperationValidate(float elaborated) {
|
||||
for (SDMXExportProgressListener listener : listeners)
|
||||
listener.operationValidate(elaborated);
|
||||
}
|
||||
|
||||
protected void fireOperationComplete() {
|
||||
for (SDMXExportProgressListener listener : listeners)
|
||||
listener.operationComplete();
|
||||
}
|
||||
|
||||
protected void fireOperationFailed(Throwable caught, String failure,
|
||||
String failureDetails) {
|
||||
for (SDMXExportProgressListener listener : listeners)
|
||||
listener.operationFailed(caught, failure, failureDetails);
|
||||
}
|
||||
|
||||
protected void fireOperationStopped(TRId trId, String reason, String details) {
|
||||
for (SDMXExportProgressListener listener : listeners)
|
||||
listener.operationStopped(trId,reason, details);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new {@link SDMXExportProgressListener} to this
|
||||
* {@link SDMXExportProgressUpdater}.
|
||||
*
|
||||
* @param listener
|
||||
* the listener to add.
|
||||
*/
|
||||
public void addListener(SDMXExportProgressListener listener) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the specified {@link SDMXExportProgressListener} from this
|
||||
* {@link SDMXExportProgressUpdater}.
|
||||
*
|
||||
* @param listener
|
||||
* the listener to remove.
|
||||
*/
|
||||
public void removeListener(SDMXExportProgressListener listener) {
|
||||
listeners.remove(listener);
|
||||
}
|
||||
}
|
|
@ -19,6 +19,7 @@
|
|||
<inherits name="com.allen_sauer.gwt.log.gwt-log-TRACE" />
|
||||
<inherits name='org.gcube.portlets.user.td.gwtservice.TDGWTService' />
|
||||
<inherits name='org.gcube.portlets.user.td.wizardwidget.Wizard' />
|
||||
<inherits name='org.gcube.portlets.user.td.monitorwidget.MonitorWidgetTD' />
|
||||
|
||||
<!-- Specify the app entry point class. -->
|
||||
|
||||
|
|
Loading…
Reference in New Issue