2014-06-03 16:33:12 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
package org.gcube.portlets.user.td.codelistmappingimportwidget.client;
|
|
|
|
|
|
|
|
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
2014-06-04 15:11:21 +02:00
|
|
|
import org.gcube.portlets.user.td.gwtservice.shared.codelisthelper.CodelistMappingSession;
|
2014-09-26 16:38:15 +02:00
|
|
|
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsFinalException;
|
|
|
|
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsLockedException;
|
2014-06-03 16:33:12 +02:00
|
|
|
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
|
2014-08-29 19:31:26 +02:00
|
|
|
import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialog;
|
|
|
|
import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialogListener;
|
2014-09-26 16:38:15 +02:00
|
|
|
import org.gcube.portlets.user.td.monitorwidget.client.utils.UtilsGXT3;
|
2014-06-04 15:11:21 +02:00
|
|
|
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;
|
2014-06-03 16:33:12 +02:00
|
|
|
|
|
|
|
import com.allen_sauer.gwt.log.client.Log;
|
2014-08-29 19:31:26 +02:00
|
|
|
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
|
2014-06-03 16:33:12 +02:00
|
|
|
import com.google.gwt.user.client.Command;
|
|
|
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
|
|
|
import com.google.gwt.user.client.ui.FlexTable;
|
|
|
|
import com.sencha.gxt.core.client.util.Margins;
|
|
|
|
import com.sencha.gxt.widget.core.client.FramedPanel;
|
|
|
|
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutData;
|
2014-08-29 19:31:26 +02:00
|
|
|
import com.sencha.gxt.widget.core.client.container.HtmlLayoutContainer;
|
2014-06-03 16:33:12 +02:00
|
|
|
import com.sencha.gxt.widget.core.client.container.VBoxLayoutContainer;
|
|
|
|
import com.sencha.gxt.widget.core.client.container.VBoxLayoutContainer.VBoxLayoutAlign;
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @author "Giancarlo Panichi" <a
|
|
|
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
|
|
|
*
|
|
|
|
*/
|
2014-09-26 16:38:15 +02:00
|
|
|
public class CodelistMappingOperationInProgressCard extends WizardCard
|
|
|
|
implements MonitorDialogListener {
|
2014-06-03 16:33:12 +02:00
|
|
|
|
|
|
|
protected CodelistMappingOperationInProgressCard thisCard;
|
2014-06-04 15:11:21 +02:00
|
|
|
protected CodelistMappingSession codelistMappingSession;
|
2014-08-29 19:31:26 +02:00
|
|
|
protected TRId newTrId;
|
|
|
|
protected HtmlLayoutContainer resultField;
|
2014-06-03 16:33:12 +02:00
|
|
|
|
2014-09-26 16:38:15 +02:00
|
|
|
public CodelistMappingOperationInProgressCard(
|
|
|
|
final CodelistMappingSession codelistMappingSession) {
|
2014-06-03 16:33:12 +02:00
|
|
|
super("Operation In Progress", "");
|
|
|
|
|
2014-06-04 15:11:21 +02:00
|
|
|
this.codelistMappingSession = codelistMappingSession;
|
2014-06-03 16:33:12 +02:00
|
|
|
thisCard = this;
|
|
|
|
|
|
|
|
VBoxLayoutContainer operationInProgressPanel = new VBoxLayoutContainer();
|
|
|
|
operationInProgressPanel.setVBoxLayoutAlign(VBoxLayoutAlign.CENTER);
|
|
|
|
|
|
|
|
final FlexTable description = new FlexTable();
|
|
|
|
description.setCellSpacing(10);
|
|
|
|
description.setCellPadding(4);
|
|
|
|
description.setBorderWidth(0);
|
|
|
|
|
|
|
|
description.setHTML(0, 0,
|
|
|
|
"<span style=\"font-weight:bold;\";>Document: </span>");
|
2014-06-04 15:11:21 +02:00
|
|
|
description.setText(0, 1, "Codelist Mapping");
|
2014-06-03 16:33:12 +02:00
|
|
|
description.setHTML(1, 0,
|
|
|
|
"<span style=\"font-weight:bold;\";>Source: </span>");
|
2014-06-04 15:11:21 +02:00
|
|
|
description.setText(1, 1, codelistMappingSession.getSource().getName());
|
2014-06-03 16:33:12 +02:00
|
|
|
|
|
|
|
description.setHTML(2, 0,
|
2014-06-04 15:11:21 +02:00
|
|
|
"<span style=\"font-weight:bold;\";>Name: </span>");
|
2014-09-26 16:38:15 +02:00
|
|
|
description.setText(2, 1, codelistMappingSession.getResourceTD()
|
|
|
|
.getName());
|
2014-06-03 16:33:12 +02:00
|
|
|
|
|
|
|
FramedPanel summary = new FramedPanel();
|
|
|
|
summary.setHeadingText("Import Summary");
|
|
|
|
summary.setWidth(400);
|
|
|
|
summary.add(description);
|
|
|
|
operationInProgressPanel.add(summary, new BoxLayoutData(new Margins(20,
|
|
|
|
5, 10, 5)));
|
|
|
|
|
2014-08-29 19:31:26 +02:00
|
|
|
resultField = new HtmlLayoutContainer("<div></div>");
|
|
|
|
|
|
|
|
operationInProgressPanel.add(resultField, new BoxLayoutData(
|
2014-06-03 16:33:12 +02:00
|
|
|
new Margins(10, 5, 10, 5)));
|
|
|
|
|
|
|
|
setContent(operationInProgressPanel);
|
2014-08-29 19:31:26 +02:00
|
|
|
resultField.setVisible(false);
|
2014-06-03 16:33:12 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-06-04 15:11:21 +02:00
|
|
|
public void importCodelistMapping() {
|
2014-09-26 16:38:15 +02:00
|
|
|
TDGWTServiceAsync.INSTANCE.startCodelistMappingImport(
|
|
|
|
codelistMappingSession, new AsyncCallback<String>() {
|
2014-06-03 16:33:12 +02:00
|
|
|
|
2014-08-29 19:31:26 +02:00
|
|
|
public void onSuccess(String taskId) {
|
|
|
|
openMonitorDialog(taskId);
|
2014-06-03 16:33:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
if (caught instanceof TDGWTSessionExpiredException) {
|
|
|
|
getEventBus()
|
|
|
|
.fireEvent(
|
|
|
|
new SessionExpiredEvent(
|
|
|
|
SessionExpiredType.EXPIREDONSERVER));
|
|
|
|
} else {
|
2014-09-26 16:38:15 +02:00
|
|
|
if (caught instanceof TDGWTIsLockedException) {
|
|
|
|
Log.error(caught.getLocalizedMessage());
|
|
|
|
showErrorAndHide("Error Locked",
|
|
|
|
caught.getLocalizedMessage(), caught);
|
|
|
|
} else {
|
|
|
|
if (caught instanceof TDGWTIsFinalException) {
|
|
|
|
Log.error(caught.getLocalizedMessage());
|
|
|
|
showErrorAndHide("Error Final",
|
|
|
|
caught.getLocalizedMessage(),
|
|
|
|
caught);
|
|
|
|
} else {
|
|
|
|
showErrorAndHide(
|
|
|
|
"Error in import codelist mapping",
|
|
|
|
"An error occured in import codelist mapping: "
|
|
|
|
+ caught.getLocalizedMessage(),
|
|
|
|
caught);
|
|
|
|
}
|
|
|
|
}
|
2014-06-03 16:33:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setup() {
|
|
|
|
getWizardWindow().setEnableBackButton(false);
|
|
|
|
setBackButtonVisible(false);
|
|
|
|
setNextButtonVisible(false);
|
|
|
|
getWizardWindow().setEnableNextButton(false);
|
|
|
|
getWizardWindow().setNextButtonToFinish();
|
2014-06-04 15:11:21 +02:00
|
|
|
importCodelistMapping();
|
2014-06-03 16:33:12 +02:00
|
|
|
}
|
|
|
|
|
2014-08-29 19:31:26 +02:00
|
|
|
//
|
|
|
|
protected void openMonitorDialog(String taskId) {
|
|
|
|
MonitorDialog monitorDialog = new MonitorDialog(taskId, getEventBus());
|
|
|
|
monitorDialog.addProgressDialogListener(this);
|
|
|
|
monitorDialog.show();
|
|
|
|
}
|
|
|
|
|
2014-08-08 18:58:46 +02:00
|
|
|
@Override
|
2014-08-29 19:31:26 +02:00
|
|
|
public void operationComplete(TRId trId) {
|
|
|
|
newTrId = trId;
|
|
|
|
SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder();
|
|
|
|
safeHtmlBuilder
|
|
|
|
.appendHtmlConstant("<div style='text-align:center;font-size:large;font-weight:bold; color:#009900;'>Operation Completed</div>");
|
|
|
|
resultField.setHTML(safeHtmlBuilder.toSafeHtml());
|
|
|
|
resultField.setVisible(true);
|
|
|
|
|
2014-06-03 16:33:12 +02:00
|
|
|
Command sayComplete = new Command() {
|
|
|
|
public void execute() {
|
|
|
|
try {
|
|
|
|
getWizardWindow().close(false);
|
2014-08-29 19:31:26 +02:00
|
|
|
Log.info("fire Complete: " + newTrId);
|
|
|
|
|
|
|
|
getWizardWindow().fireCompleted(newTrId);
|
2014-06-03 16:33:12 +02:00
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
Log.error("fire Complete :" + e.getLocalizedMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
getWizardWindow().setNextButtonCommand(sayComplete);
|
|
|
|
|
|
|
|
setNextButtonVisible(true);
|
|
|
|
getWizardWindow().setEnableNextButton(true);
|
2014-08-29 19:31:26 +02:00
|
|
|
|
|
|
|
forceLayout();
|
|
|
|
|
2014-06-03 16:33:12 +02:00
|
|
|
}
|
2014-08-29 19:31:26 +02:00
|
|
|
|
2014-08-08 18:58:46 +02:00
|
|
|
@Override
|
2014-08-29 19:31:26 +02:00
|
|
|
public void operationFailed(Throwable caught, String reason, String details) {
|
|
|
|
SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder();
|
|
|
|
safeHtmlBuilder
|
|
|
|
.appendHtmlConstant("<div style='text-align:center;font-size:large;font-weight:bold;color:red;'>Operation Failed</div>");
|
|
|
|
resultField.setHTML(safeHtmlBuilder.toSafeHtml());
|
|
|
|
resultField.setVisible(true);
|
2014-06-03 16:33:12 +02:00
|
|
|
if (caught instanceof TDGWTSessionExpiredException) {
|
|
|
|
getEventBus()
|
|
|
|
.fireEvent(
|
|
|
|
new SessionExpiredEvent(
|
|
|
|
SessionExpiredType.EXPIREDONSERVER));
|
|
|
|
} else {
|
2014-09-26 16:38:15 +02:00
|
|
|
if (caught instanceof TDGWTIsLockedException) {
|
|
|
|
Log.error(caught.getLocalizedMessage());
|
|
|
|
showErrorAndHide("Error Locked", caught.getLocalizedMessage(),
|
|
|
|
caught);
|
|
|
|
} else {
|
|
|
|
if (caught instanceof TDGWTIsFinalException) {
|
|
|
|
Log.error(caught.getLocalizedMessage());
|
|
|
|
showErrorAndHide("Error Final",
|
|
|
|
caught.getLocalizedMessage(), caught);
|
|
|
|
} else {
|
|
|
|
UtilsGXT3.alert("Error in Codelist Mapping Import", reason);
|
2014-06-03 16:33:12 +02:00
|
|
|
}
|
2014-09-26 16:38:15 +02:00
|
|
|
}
|
2014-06-03 16:33:12 +02:00
|
|
|
}
|
2014-08-29 19:31:26 +02:00
|
|
|
|
|
|
|
forceLayout();
|
2014-06-03 16:33:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-08-29 19:31:26 +02:00
|
|
|
public void operationStopped(TRId trId, String reason, String details) {
|
|
|
|
newTrId = trId;
|
|
|
|
SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder();
|
|
|
|
safeHtmlBuilder
|
|
|
|
.appendHtmlConstant("<div style='text-align:center;font-size:large;font-weight:bold;color: #FF9900;'>Problems in the Operation</div>");
|
|
|
|
resultField.setHTML(safeHtmlBuilder.toSafeHtml());
|
|
|
|
resultField.setVisible(true);
|
|
|
|
|
2014-06-03 16:33:12 +02:00
|
|
|
Command sayComplete = new Command() {
|
|
|
|
public void execute() {
|
|
|
|
try {
|
|
|
|
getWizardWindow().close(false);
|
2014-08-29 19:31:26 +02:00
|
|
|
Log.info("fire Complete: tabular resource "
|
|
|
|
+ newTrId.getId());
|
|
|
|
Log.info("fire Complete: tableId " + newTrId.getTableId());
|
2014-06-03 16:33:12 +02:00
|
|
|
|
2014-08-29 19:31:26 +02:00
|
|
|
getWizardWindow().fireCompleted(newTrId);
|
2014-06-03 16:33:12 +02:00
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
Log.error("fire Complete :" + e.getLocalizedMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
getWizardWindow().setNextButtonCommand(sayComplete);
|
|
|
|
|
|
|
|
setNextButtonVisible(true);
|
|
|
|
getWizardWindow().setEnableNextButton(true);
|
|
|
|
|
2014-08-29 19:31:26 +02:00
|
|
|
forceLayout();
|
2014-06-03 16:33:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-08-29 19:31:26 +02:00
|
|
|
public void operationAborted() {
|
|
|
|
SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder();
|
|
|
|
safeHtmlBuilder
|
|
|
|
.appendHtmlConstant("<div style='text-align:center;font-size:large;font-weight:bold;color: #AA00AA;'>Operation Aborted</div>");
|
|
|
|
resultField.setHTML(safeHtmlBuilder.toSafeHtml());
|
|
|
|
resultField.setVisible(true);
|
|
|
|
|
|
|
|
Command sayComplete = new Command() {
|
|
|
|
public void execute() {
|
|
|
|
try {
|
|
|
|
getWizardWindow().close(false);
|
|
|
|
Log.info("fire Aborted");
|
|
|
|
|
|
|
|
getWizardWindow().fireAborted();
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
Log.error("fire Aborted :" + e.getLocalizedMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
getWizardWindow().setNextButtonCommand(sayComplete);
|
|
|
|
|
|
|
|
setNextButtonVisible(true);
|
|
|
|
getWizardWindow().setEnableNextButton(true);
|
|
|
|
forceLayout();
|
2014-08-08 18:58:46 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-08-29 19:31:26 +02:00
|
|
|
public void operationPutInBackground() {
|
|
|
|
SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder();
|
|
|
|
safeHtmlBuilder
|
|
|
|
.appendHtmlConstant("<div style='text-align:center;font-size:large;font-weight:bold;color: #00AAAA;'>Operation in Background</div>");
|
|
|
|
resultField.setHTML(safeHtmlBuilder.toSafeHtml());
|
|
|
|
resultField.setVisible(true);
|
2014-06-03 16:33:12 +02:00
|
|
|
|
2014-08-29 19:31:26 +02:00
|
|
|
Command sayComplete = new Command() {
|
|
|
|
public void execute() {
|
|
|
|
try {
|
|
|
|
getWizardWindow().close(false);
|
|
|
|
Log.info("fire Operation In Background");
|
2014-06-03 16:33:12 +02:00
|
|
|
|
2014-09-11 18:31:15 +02:00
|
|
|
getWizardWindow().firePutInBackground();
|
2014-08-08 18:58:46 +02:00
|
|
|
|
2014-08-29 19:31:26 +02:00
|
|
|
} catch (Exception e) {
|
|
|
|
Log.error("fire Operation In Background :"
|
|
|
|
+ e.getLocalizedMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2014-08-08 18:58:46 +02:00
|
|
|
|
2014-08-29 19:31:26 +02:00
|
|
|
getWizardWindow().setNextButtonCommand(sayComplete);
|
2014-06-03 16:33:12 +02:00
|
|
|
|
2014-08-29 19:31:26 +02:00
|
|
|
setNextButtonVisible(true);
|
|
|
|
getWizardWindow().setEnableNextButton(true);
|
|
|
|
forceLayout();
|
2014-08-08 18:58:46 +02:00
|
|
|
|
2014-06-03 16:33:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|