Updated OperationMonitor
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-codelistmapping-import-widget@99255 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
c9dc83c485
commit
71a69038ff
12
pom.xml
12
pom.xml
|
@ -44,7 +44,7 @@
|
||||||
|
|
||||||
<!-- Convenience property to set the GWT version -->
|
<!-- Convenience property to set the GWT version -->
|
||||||
<gwtVersion>2.5.1</gwtVersion>
|
<gwtVersion>2.5.1</gwtVersion>
|
||||||
|
|
||||||
<KEYS>${env.KEYS}</KEYS>
|
<KEYS>${env.KEYS}</KEYS>
|
||||||
<!-- GWT needs at least java 1.5 -->
|
<!-- GWT needs at least java 1.5 -->
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
@ -107,7 +107,7 @@
|
||||||
<version>3.0.1</version>
|
<version>3.0.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- tabular-data-gwt-service -->
|
<!-- tabular-data-gwt-service -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -125,6 +125,14 @@
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</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 -->
|
<!-- tabular-data-wizard-widget -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -3,12 +3,14 @@
|
||||||
*/
|
*/
|
||||||
package org.gcube.portlets.user.td.codelistmappingimportwidget.client;
|
package org.gcube.portlets.user.td.codelistmappingimportwidget.client;
|
||||||
|
|
||||||
import org.gcube.portlets.user.td.codelistmappingimportwidget.client.progress.CodelistMappingImportProgressBarUpdater;
|
|
||||||
import org.gcube.portlets.user.td.codelistmappingimportwidget.client.progress.CodelistMappingImportProgressListener;
|
|
||||||
import org.gcube.portlets.user.td.codelistmappingimportwidget.client.progress.CodelistMappingImportProgressUpdater;
|
|
||||||
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.codelisthelper.CodelistMappingSession;
|
import org.gcube.portlets.user.td.gwtservice.shared.codelisthelper.CodelistMappingSession;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
|
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.MonitorUpdaterListener;
|
||||||
|
import org.gcube.portlets.user.td.monitorwidget.client.MonitorUpdater;
|
||||||
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
|
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.client.type.SessionExpiredType;
|
||||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||||
|
@ -37,12 +39,12 @@ import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class CodelistMappingOperationInProgressCard extends WizardCard implements
|
public class CodelistMappingOperationInProgressCard extends WizardCard implements
|
||||||
CodelistMappingImportProgressListener {
|
MonitorUpdaterListener {
|
||||||
|
|
||||||
public static final int STATUS_POLLING_DELAY = 1000;
|
public static final int STATUS_POLLING_DELAY = 1000;
|
||||||
protected CodelistMappingOperationInProgressCard thisCard;
|
protected CodelistMappingOperationInProgressCard thisCard;
|
||||||
protected CodelistMappingSession codelistMappingSession;
|
protected CodelistMappingSession codelistMappingSession;
|
||||||
protected CodelistMappingImportProgressUpdater progressUpdater;
|
protected MonitorUpdater progressUpdater;
|
||||||
|
|
||||||
public CodelistMappingOperationInProgressCard(final CodelistMappingSession codelistMappingSession) {
|
public CodelistMappingOperationInProgressCard(final CodelistMappingSession codelistMappingSession) {
|
||||||
super("Operation In Progress", "");
|
super("Operation In Progress", "");
|
||||||
|
@ -79,10 +81,12 @@ public class CodelistMappingOperationInProgressCard extends WizardCard implement
|
||||||
ProgressBar progressBar = new ProgressBar();
|
ProgressBar progressBar = new ProgressBar();
|
||||||
operationInProgressPanel.add(progressBar, new BoxLayoutData(
|
operationInProgressPanel.add(progressBar, new BoxLayoutData(
|
||||||
new Margins(10, 5, 10, 5)));
|
new Margins(10, 5, 10, 5)));
|
||||||
|
|
||||||
progressUpdater = new CodelistMappingImportProgressUpdater();
|
|
||||||
|
OperationMonitorSession operationMonitorSession=new OperationMonitorSession();
|
||||||
|
progressUpdater = new MonitorUpdater(operationMonitorSession);
|
||||||
progressUpdater
|
progressUpdater
|
||||||
.addListener(new CodelistMappingImportProgressBarUpdater(progressBar));
|
.addListener(new MonitorBarUpdater(progressBar));
|
||||||
|
|
||||||
progressUpdater.addListener(this);
|
progressUpdater.addListener(this);
|
||||||
|
|
||||||
|
@ -93,9 +97,9 @@ public class CodelistMappingOperationInProgressCard extends WizardCard implement
|
||||||
|
|
||||||
public void importCodelistMapping() {
|
public void importCodelistMapping() {
|
||||||
TDGWTServiceAsync.INSTANCE.startCodelistMappingImport(codelistMappingSession,
|
TDGWTServiceAsync.INSTANCE.startCodelistMappingImport(codelistMappingSession,
|
||||||
new AsyncCallback<Void>() {
|
new AsyncCallback<String>() {
|
||||||
|
|
||||||
public void onSuccess(Void result) {
|
public void onSuccess(String result) {
|
||||||
progressUpdater.scheduleRepeating(STATUS_POLLING_DELAY);
|
progressUpdater.scheduleRepeating(STATUS_POLLING_DELAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,16 +129,19 @@ public class CodelistMappingOperationInProgressCard extends WizardCard implement
|
||||||
getWizardWindow().setNextButtonToFinish();
|
getWizardWindow().setNextButtonToFinish();
|
||||||
importCodelistMapping();
|
importCodelistMapping();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void operationInitializing() {
|
@Override
|
||||||
|
public void monitorInitializing() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void operationUpdate(float elaborated) {
|
@Override
|
||||||
|
public void monitorUpdate(float elaborated) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void operationComplete(final TRId trId) {
|
@Override
|
||||||
|
public void monitorComplete(final TRId trId) {
|
||||||
|
|
||||||
Command sayComplete = new Command() {
|
Command sayComplete = new Command() {
|
||||||
public void execute() {
|
public void execute() {
|
||||||
|
@ -155,8 +162,9 @@ public class CodelistMappingOperationInProgressCard extends WizardCard implement
|
||||||
setNextButtonVisible(true);
|
setNextButtonVisible(true);
|
||||||
getWizardWindow().setEnableNextButton(true);
|
getWizardWindow().setEnableNextButton(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void operationFailed(Throwable caught, String reason,
|
@Override
|
||||||
|
public void monitorFailed(Throwable caught, String reason,
|
||||||
String failureDetails) {
|
String failureDetails) {
|
||||||
if (caught instanceof TDGWTSessionExpiredException) {
|
if (caught instanceof TDGWTSessionExpiredException) {
|
||||||
getEventBus()
|
getEventBus()
|
||||||
|
@ -175,7 +183,7 @@ public class CodelistMappingOperationInProgressCard extends WizardCard implement
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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() {
|
Command sayComplete = new Command() {
|
||||||
public void execute() {
|
public void execute() {
|
||||||
|
@ -200,15 +208,36 @@ public class CodelistMappingOperationInProgressCard extends WizardCard implement
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void operationGeneratingView() {
|
public void monitorGeneratingView() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void operationValidate(float elaborated) {
|
public void monitorValidate(float elaborated) {
|
||||||
// TODO Auto-generated method stub
|
// 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
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,12 +3,20 @@
|
||||||
*/
|
*/
|
||||||
package org.gcube.portlets.user.td.codelistmappingimportwidget.client;
|
package org.gcube.portlets.user.td.codelistmappingimportwidget.client;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.codelisthelper.CodelistMappingSession;
|
import org.gcube.portlets.user.td.gwtservice.shared.codelisthelper.CodelistMappingSession;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.resource.ResourceTD;
|
import org.gcube.portlets.user.td.gwtservice.shared.resource.ResourceTD;
|
||||||
|
import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialog;
|
||||||
|
import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialogListener;
|
||||||
|
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;
|
||||||
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
|
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
|
||||||
|
|
||||||
import com.allen_sauer.gwt.log.client.Log;
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
import com.google.gwt.user.client.Command;
|
import com.google.gwt.user.client.Command;
|
||||||
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
import com.sencha.gxt.widget.core.client.FramedPanel;
|
import com.sencha.gxt.widget.core.client.FramedPanel;
|
||||||
import com.sencha.gxt.widget.core.client.box.AlertMessageBox;
|
import com.sencha.gxt.widget.core.client.box.AlertMessageBox;
|
||||||
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
|
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
|
||||||
|
@ -25,7 +33,8 @@ import com.sencha.gxt.widget.core.client.form.TextField;
|
||||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class CodelistMappingTableDetailCard extends WizardCard {
|
public class CodelistMappingTableDetailCard extends WizardCard
|
||||||
|
implements MonitorDialogListener {
|
||||||
|
|
||||||
protected CodelistMappingSession codelistMappingSession;
|
protected CodelistMappingSession codelistMappingSession;
|
||||||
protected CodelistMappingTableDetailCard thisCard;
|
protected CodelistMappingTableDetailCard thisCard;
|
||||||
|
@ -141,14 +150,87 @@ public class CodelistMappingTableDetailCard extends WizardCard {
|
||||||
|
|
||||||
codelistMappingSession.setResourceTD(resourceDetails);
|
codelistMappingSession.setResourceTD(resourceDetails);
|
||||||
|
|
||||||
CodelistMappingOperationInProgressCard codelistMappingOperationInProgressCard = new CodelistMappingOperationInProgressCard(
|
/*CodelistMappingOperationInProgressCard codelistMappingOperationInProgressCard = new CodelistMappingOperationInProgressCard(
|
||||||
codelistMappingSession);
|
codelistMappingSession);
|
||||||
getWizardWindow().addCard(codelistMappingOperationInProgressCard);
|
getWizardWindow().addCard(codelistMappingOperationInProgressCard);
|
||||||
Log.info("NextCard CodelistMappingOperationInProgressCard");
|
Log.info("NextCard CodelistMappingOperationInProgressCard");
|
||||||
getWizardWindow().nextCard();
|
getWizardWindow().nextCard();*/
|
||||||
|
importCodelistMapping();
|
||||||
|
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
Log.error("sayNextCard :" + e.getLocalizedMessage());
|
Log.error("sayNextCard :" + e.getLocalizedMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected void importCodelistMapping() {
|
||||||
|
TDGWTServiceAsync.INSTANCE.startCodelistMappingImport(codelistMappingSession,
|
||||||
|
new AsyncCallback<String>() {
|
||||||
|
|
||||||
|
public void onSuccess(String taskId) {
|
||||||
|
openMonitorDialog(taskId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
if (caught instanceof TDGWTSessionExpiredException) {
|
||||||
|
getEventBus()
|
||||||
|
.fireEvent(
|
||||||
|
new SessionExpiredEvent(
|
||||||
|
SessionExpiredType.EXPIREDONSERVER));
|
||||||
|
} else {
|
||||||
|
showErrorAndHide(
|
||||||
|
"Error in import codelist mapping",
|
||||||
|
"An error occured in import codelist mapping: "
|
||||||
|
+ caught.getLocalizedMessage(),
|
||||||
|
caught.getStackTrace().toString(), caught);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void openMonitorDialog(String taskId){
|
||||||
|
MonitorDialog monitorDialog=new MonitorDialog(taskId,getEventBus());
|
||||||
|
monitorDialog.add(thisCard);
|
||||||
|
monitorDialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void operationComplete(TRId trId) {
|
||||||
|
getWizardWindow().fireCompleted(trId);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void operationFailed(Throwable caught, String reason, String details) {
|
||||||
|
if (caught instanceof TDGWTSessionExpiredException) {
|
||||||
|
getEventBus()
|
||||||
|
.fireEvent(
|
||||||
|
new SessionExpiredEvent(
|
||||||
|
SessionExpiredType.EXPIREDONSERVER));
|
||||||
|
} else {
|
||||||
|
getWizardWindow().fireFailed(caught, "Error in Codelist Mapping Import", details);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void operationStopped(TRId trId, String reason, String details) {
|
||||||
|
getWizardWindow().fireCompleted(trId);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void operationAborted() {
|
||||||
|
getWizardWindow().fireAborted();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void operationPutInBackground() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,99 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package org.gcube.portlets.user.td.codelistmappingimportwidget.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 CodelistMappingImportProgressListener} events.
|
|
||||||
*
|
|
||||||
* @author "Giancarlo Panichi"
|
|
||||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class CodelistMappingImportProgressBarUpdater implements CodelistMappingImportProgressListener {
|
|
||||||
|
|
||||||
protected ProgressBar progressBar;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new {@link ProgressBar} updater.
|
|
||||||
* @param progressBar the {@link ProgressBar} to update.
|
|
||||||
*/
|
|
||||||
public CodelistMappingImportProgressBarUpdater(ProgressBar progressBar) {
|
|
||||||
this.progressBar = progressBar;
|
|
||||||
this.progressBar.updateProgress(0, "Please Wait...");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void operationComplete(TRId trId) {
|
|
||||||
Log.info("Import completed");
|
|
||||||
progressBar.updateProgress(1, "Import completed.");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void operationFailed(Throwable caught, String reason, String failureDetails) {
|
|
||||||
Log.info("Import failed");
|
|
||||||
progressBar.updateText("Import failed");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void operationInitializing() {
|
|
||||||
Log.info("Inport 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+"% Importing...");
|
|
||||||
}
|
|
||||||
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.codelistmappingimportwidget.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 CodelistMappingImportProgressListener {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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.codelistmappingimportwidget.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.CodelistMappingMonitor;
|
|
||||||
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 CodelistMappingImportProgressListener}.
|
|
||||||
*
|
|
||||||
* @author "Giancarlo Panichi" <a
|
|
||||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class CodelistMappingImportProgressUpdater extends Timer {
|
|
||||||
|
|
||||||
protected ArrayList<CodelistMappingImportProgressListener> listeners = new ArrayList<CodelistMappingImportProgressListener>();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
Log.debug("requesting operation progress");
|
|
||||||
TDGWTServiceAsync.INSTANCE
|
|
||||||
.getCodelistMappingMonitor(new AsyncCallback<CodelistMappingMonitor>() {
|
|
||||||
|
|
||||||
|
|
||||||
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(CodelistMappingMonitor result) {
|
|
||||||
Log.info("retrieved CSVImportMonitor: "
|
|
||||||
+ result.getStatus());
|
|
||||||
switch (result.getStatus()) {
|
|
||||||
case INITIALIZING:
|
|
||||||
Log.info("CSV Import Initializing...");
|
|
||||||
fireOperationInitializing();
|
|
||||||
break;
|
|
||||||
case ABORTED:
|
|
||||||
cancel();
|
|
||||||
Log.info("CSV Import 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("Import fisnish:"
|
|
||||||
+ result.getTrId());
|
|
||||||
fireOperationComplete(result.getTrId());
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
Log.info("Unknow State");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void errorMessage(CodelistMappingMonitor result) {
|
|
||||||
Log.info("Codelist Mapping Import Failed");
|
|
||||||
Throwable th = null;
|
|
||||||
String failure = null;
|
|
||||||
String details = null;
|
|
||||||
if (result.getError() != null) {
|
|
||||||
th = result.getError();
|
|
||||||
failure = "Failed Client Library Codelist Mapping Import";
|
|
||||||
details = result.getError().getLocalizedMessage();
|
|
||||||
} else {
|
|
||||||
th = new Throwable("Failed");
|
|
||||||
failure = "Failed Client Library Codelist Mapping Import";
|
|
||||||
details = "Error in codelist mapping import";
|
|
||||||
}
|
|
||||||
fireOperationFailed(th, failure, details);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void stopMessage(CodelistMappingMonitor result) {
|
|
||||||
Log.info("Codelist Mapping Import Stopped");
|
|
||||||
String failure = null;
|
|
||||||
String details = null;
|
|
||||||
if (result.getError() != null) {
|
|
||||||
failure = "Stopped";
|
|
||||||
details = result.getError().getLocalizedMessage();
|
|
||||||
} else {
|
|
||||||
failure = "Stopped";
|
|
||||||
details = "Stopped codelist mapping import";
|
|
||||||
}
|
|
||||||
|
|
||||||
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 (CodelistMappingImportProgressListener listener : listeners)
|
|
||||||
listener.operationInitializing();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void fireOperationGeneratingView() {
|
|
||||||
for (CodelistMappingImportProgressListener listener : listeners)
|
|
||||||
listener.operationGeneratingView();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void fireOperationUpdate(float elaborated) {
|
|
||||||
for (CodelistMappingImportProgressListener listener : listeners)
|
|
||||||
listener.operationUpdate(elaborated);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void fireOperationValidate(float elaborated) {
|
|
||||||
for (CodelistMappingImportProgressListener listener : listeners)
|
|
||||||
listener.operationValidate(elaborated);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void fireOperationComplete(TRId trId) {
|
|
||||||
for (CodelistMappingImportProgressListener listener : listeners)
|
|
||||||
listener.operationComplete(trId);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void fireOperationFailed(Throwable caught, String failure,
|
|
||||||
String failureDetails) {
|
|
||||||
for (CodelistMappingImportProgressListener listener : listeners)
|
|
||||||
listener.operationFailed(caught, failure, failureDetails);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void fireOperationStopped(TRId trId, String reason, String details) {
|
|
||||||
for (CodelistMappingImportProgressListener listener : listeners)
|
|
||||||
listener.operationStopped(trId,reason, details);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a new {@link CodelistMappingImportProgressListener} to this
|
|
||||||
* {@link CodelistMappingImportProgressUpdater}.
|
|
||||||
*
|
|
||||||
* @param listener
|
|
||||||
* the listener to add.
|
|
||||||
*/
|
|
||||||
public void addListener(CodelistMappingImportProgressListener listener) {
|
|
||||||
listeners.add(listener);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes the specified {@link CodelistMappingImportProgressListener} from this
|
|
||||||
* {@link CodelistMappingImportProgressUpdater}.
|
|
||||||
*
|
|
||||||
* @param listener
|
|
||||||
* the listener to remove.
|
|
||||||
*/
|
|
||||||
public void removeListener(CodelistMappingImportProgressListener listener) {
|
|
||||||
listeners.remove(listener);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -19,7 +19,7 @@
|
||||||
<inherits name="com.allen_sauer.gwt.log.gwt-log-TRACE" />
|
<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.gwtservice.TDGWTService' />
|
||||||
<inherits name='org.gcube.portlets.user.td.wizardwidget.Wizard' />
|
<inherits name='org.gcube.portlets.user.td.wizardwidget.Wizard' />
|
||||||
|
<inherits name='org.gcube.portlets.user.td.monitorwidget.MonitorWidgetTD' />
|
||||||
|
|
||||||
<inherits name='org.gcube.portlets.widgets.lighttree.WorkspacePortletLightTree' />
|
<inherits name='org.gcube.portlets.widgets.lighttree.WorkspacePortletLightTree' />
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue