Minor Update
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-unionwizard-widget@99292 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
c88dba4915
commit
c5f29defb0
10
pom.xml
10
pom.xml
|
@ -125,7 +125,15 @@
|
|||
<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.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" <a
|
||||
|
@ -37,12 +37,13 @@ import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler;
|
|||
*
|
||||
*/
|
||||
public class UnionOperationInProgressCard extends WizardCard implements
|
||||
UnionProgressListener {
|
||||
MonitorUpdaterListener {
|
||||
|
||||
public static final int STATUS_POLLING_DELAY = 1000;
|
||||
protected UnionOperationInProgressCard thisCard;
|
||||
protected UnionSession unionSession;
|
||||
protected UnionProgressUpdater progressUpdater;
|
||||
protected MonitorUpdater progressUpdater;
|
||||
protected ProgressBar progressBar;
|
||||
|
||||
public UnionOperationInProgressCard(final UnionSession unionSession) {
|
||||
super("Operation In Progress", "");
|
||||
|
@ -60,14 +61,17 @@ public class UnionOperationInProgressCard extends WizardCard implements
|
|||
|
||||
description.setHTML(0, 0,
|
||||
"<span style=\"font-weight:bold;\";>Union with: </span>");
|
||||
description.setText(0, 1, unionSession.getUnionTabularResource().getName());
|
||||
description.setText(0, 1, unionSession.getUnionTabularResource()
|
||||
.getName());
|
||||
description.setHTML(1, 0,
|
||||
"<span style=\"font-weight:bold;\";>Type: </span>");
|
||||
description.setText(1, 1, unionSession.getUnionTabularResource().getTabularResourceType());
|
||||
description.setText(1, 1, unionSession.getUnionTabularResource()
|
||||
.getTabularResourceType());
|
||||
|
||||
description.setHTML(2, 0,
|
||||
"<span style=\"font-weight:bold;\";>Owner: </span>");
|
||||
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<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) {
|
||||
|
@ -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
|
||||
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
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...");
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -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"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
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();
|
||||
|
||||
}
|
|
@ -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" <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class UnionProgressUpdater extends Timer {
|
||||
|
||||
protected ArrayList<UnionProgressListener> listeners = new ArrayList<UnionProgressListener>();
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
Log.debug("requesting operation progress");
|
||||
TDGWTServiceAsync.INSTANCE
|
||||
.getUnionMonitor(new AsyncCallback<UnionMonitor>() {
|
||||
|
||||
|
||||
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() + " -> <br>";
|
||||
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);
|
||||
}
|
||||
}
|
|
@ -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