Minor Update

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-extractcodelist-widget@99286 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-08-26 14:19:54 +00:00
parent 3549b5c2a7
commit d7da7f3cb9
7 changed files with 84 additions and 406 deletions

View File

@ -0,0 +1,2 @@
disabled=06target
eclipse.preferences.version=1

11
pom.xml
View File

@ -121,7 +121,16 @@
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
<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>

View File

@ -3,12 +3,14 @@
*/
package org.gcube.portlets.user.td.extractcodelistwidget.client;
import org.gcube.portlets.user.td.extractcodelistwidget.client.progress.ExtractCodelistProgressBarUpdater;
import org.gcube.portlets.user.td.extractcodelistwidget.client.progress.ExtractCodelistProgressListener;
import org.gcube.portlets.user.td.extractcodelistwidget.client.progress.ExtractCodelistProgressUpdater;
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.extract.ExtractCodelistSession;
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;
@ -34,67 +36,70 @@ import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler;
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class ExtractCodelistOperationInProgressCard extends WizardCard implements
ExtractCodelistProgressListener {
public class ExtractCodelistOperationInProgressCard extends WizardCard
implements MonitorUpdaterListener {
public static final int STATUS_POLLING_DELAY = 1000;
protected ExtractCodelistOperationInProgressCard thisCard;
protected ExtractCodelistSession extractCodelistSession;
protected ExtractCodelistProgressUpdater progressUpdater;
protected MonitorUpdater progressUpdater;
protected ProgressBar progressBar;
protected final FlexTable description;
protected final FramedPanel summary;
protected final ProgressBar progressBar;
public ExtractCodelistOperationInProgressCard(final ExtractCodelistSession extractCodelistSession) {
public ExtractCodelistOperationInProgressCard(
final ExtractCodelistSession extractCodelistSession) {
super("Operation In Progress", "");
this.extractCodelistSession = extractCodelistSession;
this.extractCodelistSession = extractCodelistSession;
thisCard = this;
VBoxLayoutContainer operationInProgressPanel = new VBoxLayoutContainer();
operationInProgressPanel.setVBoxLayoutAlign(VBoxLayoutAlign.CENTER);
progressBar = new ProgressBar();
operationInProgressPanel.add(progressBar, new BoxLayoutData(
new Margins(10, 30, 10, 5)));
progressUpdater = new ExtractCodelistProgressUpdater();
progressUpdater
.addListener(new ExtractCodelistProgressBarUpdater(progressBar));
progressUpdater.addListener(this);
description = new FlexTable();
description.setCellSpacing(10);
description.setCellPadding(4);
description.setBorderWidth(0);
description.setHTML(0, 0,
"The Codelists is available in the list of yours tabular resources");
description
.setHTML(0, 0,
"The Codelists is available in the list of yours tabular resources");
summary = new FramedPanel();
summary.setHeadingText("Operation Completed");
summary.setWidth(400);
summary.add(description);
operationInProgressPanel.add(summary, new BoxLayoutData(new Margins(20,5, 10, 5)));
operationInProgressPanel.add(summary, new BoxLayoutData(new Margins(20,
5, 10, 5)));
setContent(operationInProgressPanel);
summary.setVisible(false);
}
public void extractCodelist() {
TDGWTServiceAsync.INSTANCE.startExtractCodelist(extractCodelistSession,
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) {
@ -104,8 +109,7 @@ public class ExtractCodelistOperationInProgressCard extends WizardCard implement
new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
showErrorAndHide(
"Error in extract codelist",
showErrorAndHide("Error in extract codelist",
"An error occured in extract codelist: "
+ caught.getLocalizedMessage(),
caught.getStackTrace().toString(), caught);
@ -124,25 +128,28 @@ public class ExtractCodelistOperationInProgressCard extends WizardCard implement
extractCodelist();
}
public void operationInitializing() {
}
public void operationUpdate(float elaborated) {
}
@Override
public void operationComplete(final TRId trId) {
public void monitorInitializing(OperationMonitor operationMonitor) {
}
@Override
public void monitorUpdate(OperationMonitor operationMonitor) {
}
@Override
public void monitorComplete(final TRId trId) {
summary.setVisible(true);
progressBar.setVisible(false);
forceLayout();
Command sayComplete = new Command() {
public void execute() {
try {
getWizardWindow().close(false);
Log.info("fire Complete: tableId");
Log.info("fire Complete: " + trId);
getWizardWindow().fireCompleted(trId);
} catch (Exception e) {
@ -157,7 +164,8 @@ public class ExtractCodelistOperationInProgressCard extends WizardCard implement
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()
@ -165,9 +173,8 @@ public class ExtractCodelistOperationInProgressCard extends WizardCard implement
new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
AlertMessageBox d = new AlertMessageBox("Error in Extract Codelist",
reason);
AlertMessageBox d = new AlertMessageBox(
"Error in Codelist Mapping Import", reason);
d.addHideHandler(new HideHandler() {
public void onHide(HideEvent event) {
}
@ -177,16 +184,16 @@ public class ExtractCodelistOperationInProgressCard extends WizardCard implement
}
@Override
public void operationStopped(TRId trId, String reason, String details) {
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());
@ -202,13 +209,25 @@ public class ExtractCodelistOperationInProgressCard extends WizardCard implement
}
@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
}

View File

@ -1,98 +0,0 @@
/**
*
*/
package org.gcube.portlets.user.td.extractcodelistwidget.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 ExtractCodelistProgressListener} events.
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class ExtractCodelistProgressBarUpdater implements ExtractCodelistProgressListener {
protected ProgressBar progressBar;
//protected FramedPanel operationResult;
//protected WizardWindow wizardWindow;
/**
* Creates a new {@link ProgressBar} updater.
* @param progressBar the {@link ProgressBar} to update.
*/
public ExtractCodelistProgressBarUpdater(ProgressBar progressBar) {
this.progressBar = progressBar;
this.progressBar.updateProgress(0, "Please Wait...");
}
/**
* {@inheritDoc}
*/
@Override
public void operationComplete(TRId trId) {
Log.info("Completed "+trId.toString());
progressBar.updateProgress(1, "Completed.");
}
/**
* {@inheritDoc}
*/
public void operationFailed(Throwable caught, String reason, String failureDetails) {
Log.info("Failed");
progressBar.updateText("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+"% 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...");
}
}

View File

@ -1,63 +0,0 @@
/**
*
*/
package org.gcube.portlets.user.td.extractcodelistwidget.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 ExtractCodelistProgressListener {
/**
* 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();
}

View File

@ -1,192 +0,0 @@
/**
*
*/
package org.gcube.portlets.user.td.extractcodelistwidget.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.ExtractCodelistMonitor;
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 ExtractCodelistProgressUpdater extends Timer {
protected ArrayList<ExtractCodelistProgressListener> listeners = new ArrayList<ExtractCodelistProgressListener>();
/**
* {@inheritDoc}
*/
@Override
public void run() {
Log.debug("requesting operation progress");
TDGWTServiceAsync.INSTANCE
.getExtractCodelistMonitor(new AsyncCallback<ExtractCodelistMonitor>() {
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(ExtractCodelistMonitor 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 FAILED:
cancel();
errorMessage(result);
break;
case STOPPED:
cancel();
stopMessage(result);
break;
case SUCCEDED:
cancel();
Log.info("Finish:"
+ result.toString());
fireOperationComplete(result.getTrId());
break;
default:
Log.info("Unknow State");
break;
}
}
});
}
protected void errorMessage(ExtractCodelistMonitor result) {
Log.info("Extract Codelist Failed");
Throwable th = null;
String failure = null;
String details = null;
if (result.getError() != null) {
th = result.getError();
failure = "Failed Client Library Extract Codelist";
details = result.getError().getLocalizedMessage();
} else {
th = new Throwable("Failed");
failure = "Failed Client Library Extract Codelist";
details = "Error in export";
}
fireOperationFailed(th, failure, details);
}
protected void stopMessage(ExtractCodelistMonitor result) {
Log.info("Extract Codelist Stopped");
String failure = null;
String details = null;
if (result.getError() != null) {
failure = "Stopped extract codelist";
details = result.getError().getLocalizedMessage();
} else {
failure = "Stopped extract codelist";
details = "Stopped extract codelist";
}
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 (ExtractCodelistProgressListener listener : listeners)
listener.operationInitializing();
}
protected void fireOperationGeneratingView() {
for (ExtractCodelistProgressListener listener : listeners)
listener.operationGeneratingView();
}
protected void fireOperationUpdate(float elaborated) {
for (ExtractCodelistProgressListener listener : listeners)
listener.operationUpdate(elaborated);
}
protected void fireOperationValidate(float elaborated) {
for (ExtractCodelistProgressListener listener : listeners)
listener.operationValidate(elaborated);
}
protected void fireOperationComplete(TRId trId) {
for (ExtractCodelistProgressListener listener : listeners)
listener.operationComplete(trId);
}
protected void fireOperationFailed(Throwable caught, String failure,
String failureDetails) {
for (ExtractCodelistProgressListener listener : listeners)
listener.operationFailed(caught, failure, failureDetails);
}
protected void fireOperationStopped(TRId trId, String reason, String details) {
for (ExtractCodelistProgressListener listener : listeners)
listener.operationStopped(trId,reason, details);
}
/**
* Add a new {@link ExtractCodelistProgressListener} to this
* {@link ExtractCodelistProgressUpdater}.
*
* @param listener
* the listener to add.
*/
public void addListener(ExtractCodelistProgressListener listener) {
listeners.add(listener);
}
/**
* Removes the specified {@link ExtractCodelistProgressListener} from this
* {@link ExtractCodelistProgressUpdater}.
*
* @param listener
* the listener to remove.
*/
public void removeListener(ExtractCodelistProgressListener listener) {
listeners.remove(listener);
}
}

View File

@ -20,7 +20,8 @@
<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.columnwidget.ColumnWidget' />
<inherits name='org.gcube.portlets.user.td.monitorwidget.MonitorWidgetTD' />
<!-- Specify the app entry point class. -->
<!-- <entry-point class='org.gcube.portlets.user.SDMXImportWizardTD.client.SDMXImportWizardTDEntry' /> -->