From a3acbd487c6b2ad3d7ae55f44a76dccbbaf51edc Mon Sep 17 00:00:00 2001 From: Francesco Mangiacrapa Date: Thu, 7 Jun 2018 13:30:37 +0000 Subject: [PATCH] Added show results git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/widgets/ws-task-executor-widget@168967 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../client/WsTaskExecutorWidget.java | 67 +++++++++++++- .../client/dialog/DialogResult.java | 6 +- .../event/TaskComputationFinishedEvent.java | 88 +++++++++++++++++++ .../TaskComputationFinishedEventHandler.java | 22 +++++ .../rpc/WsTaskExecutorWidgetService.java | 15 ++++ .../rpc/WsTaskExecutorWidgetServiceAsync.java | 14 ++- .../view/WsTaskExecutorWidgetViewManager.java | 55 ++++++------ .../MonitorFolderTaskExecutionStatusView.java | 1 - .../public/WsTaskExecutorWidget.css | 8 +- .../WsTaskExecutorWidgetServiceImpl.java | 13 +++ 10 files changed, 255 insertions(+), 34 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/event/TaskComputationFinishedEvent.java create mode 100644 src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/event/TaskComputationFinishedEventHandler.java diff --git a/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/WsTaskExecutorWidget.java b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/WsTaskExecutorWidget.java index 03095b6..4fb8333 100644 --- a/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/WsTaskExecutorWidget.java +++ b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/WsTaskExecutorWidget.java @@ -4,6 +4,7 @@ package org.gcube.portlets.widgets.wstaskexecutor.client; import java.util.ArrayList; import java.util.List; +import org.gcube.common.workspacetaskexecutor.shared.TaskOutput; import org.gcube.common.workspacetaskexecutor.shared.TaskParameter; import org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskConfiguration; import org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskExecutionStatus; @@ -23,6 +24,8 @@ import org.gcube.portlets.widgets.wstaskexecutor.client.event.ShowCreateTaskConf import org.gcube.portlets.widgets.wstaskexecutor.client.event.ShowCreateTaskConfigurationDialogEventHandler; import org.gcube.portlets.widgets.wstaskexecutor.client.event.ShowListOfTaskConfigurationsEvent; import org.gcube.portlets.widgets.wstaskexecutor.client.event.ShowListOfTaskConfigurationsEventHandler; +import org.gcube.portlets.widgets.wstaskexecutor.client.event.TaskComputationFinishedEvent; +import org.gcube.portlets.widgets.wstaskexecutor.client.event.TaskComputationFinishedEventHandler; import org.gcube.portlets.widgets.wstaskexecutor.client.rpc.WsTaskExecutorWidgetServiceAsync; import org.gcube.portlets.widgets.wstaskexecutor.client.view.LoaderIcon; import org.gcube.portlets.widgets.wstaskexecutor.client.view.WsTaskExecutorWidgetViewManager; @@ -243,6 +246,64 @@ public class WsTaskExecutorWidget { } }); + eventBus.addHandler(TaskComputationFinishedEvent.TYPE, new TaskComputationFinishedEventHandler() { + + @Override + public void onTaskFinished( + TaskComputationFinishedEvent taskComputationTerminatedEvent) { + + if(taskComputationTerminatedEvent.getWsItem()!=null){ + + GWT.log("Task finished with status "+taskComputationTerminatedEvent.getTaskExecutionStatus()+" cancelling the polling"); + viewManager.cancelMonitor(taskComputationTerminatedEvent.getWsItem()); + + if(taskComputationTerminatedEvent.getError()!=null){ + //Exception occurred server-side no output to displaying + Window.alert(taskComputationTerminatedEvent.getError().getMessage()); + return; + } + + + //CALLING METHOD ON SYNC COMPLETED TO THE LISTENERS + for (TaskCompletedNotificationListner listener : taskEventsListeners) { + listener.onTaskComputationCompleted(taskComputationTerminatedEvent.getWsItem()); + } + + //RETRIEVES A VALID STATUS IF THE OUTPUT IS COMPLETED BUT IT IS CALLED ON FAILED AND CANCELLED STATUS IN ORDER TO REMOVE SERVER SIDE CACHED COMPUATION + WsTaskExecutorWidget.wsTaskService.getOutput(taskComputationTerminatedEvent.getTaskExecutionStatus().getTaskConfiguration(), taskComputationTerminatedEvent.getTaskExecutionStatus().getTaskComputation(), new AsyncCallback() { + + @Override + public void onFailure(Throwable caught) { + + //Window.alert(caught.getMessage()); + + } + + @Override + public void onSuccess(TaskOutput result) { + + if(result==null) + return; + + List listMessages = result.getOutputMessages(); + + String outMsg = ""; + for (String msg : listMessages) { + outMsg+="
"+msg; + } + + + final DialogResult dResult = new DialogResult(null, "Output are:", outMsg); + dResult.center(); + + } + }); + + } + + } + }); + } @@ -262,7 +323,7 @@ public class WsTaskExecutorWidget { throw new Exception("Invalid parameter the configuration is null"); final Modal box = new Modal(true); - box.setTitle("Executing task configuration..."); + box.setTitle("Executing task..."); String algName = conf.getTaskId().substring(conf.getTaskId().lastIndexOf(".")+1, conf.getTaskId().length()); LoaderIcon loader = new LoaderIcon("Inizializing new run for: "+algName); @@ -280,7 +341,7 @@ public class WsTaskExecutorWidget { @Override public void onSuccess(TaskExecutionStatus result) { box.hide(); - viewManager.showMonitorTaskStatusFor(wsItem, result.getTaskConfiguration(), result.getTaskComputation(), taskEventsListeners); + viewManager.showMonitorTaskStatusFor(wsItem, result.getTaskConfiguration(), result.getTaskComputation()); } }); @@ -304,7 +365,7 @@ public class WsTaskExecutorWidget { //SHOWING CURRENT ACTIVE MONITOR if(monitor!=null) { GWT.log("Monitor for workpace item: "+wsItem.getItemId() +" exists showing it.."); - viewManager.showMonitorTaskStatusFor(wsItem, monitor.getTaskConfiguration(), monitor.getTaskComputation(), taskEventsListeners); + viewManager.showMonitorTaskStatusFor(wsItem, monitor.getTaskConfiguration(), monitor.getTaskComputation()); return; } diff --git a/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/dialog/DialogResult.java b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/dialog/DialogResult.java index d122860..15cbbb4 100644 --- a/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/dialog/DialogResult.java +++ b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/dialog/DialogResult.java @@ -40,7 +40,11 @@ public class DialogResult extends DialogBox implements ClickHandler { closeButton = new Button("Close", this); dock.setSpacing(4); dock.setWidth("100%"); - dock.add(new HTML(msg), DockPanel.CENTER); + //dock.getElement().getStyle().setProperty("overflowY", "scroll"); + //vp.getElement().getStyle().setProperty("overflowY", "scroll"); + HTML htmlMsg = new HTML(msg); + //htmlMsg.getElement().getStyle().setProperty("overflowY", "scroll"); + dock.add(htmlMsg, DockPanel.CENTER); dock.add(closeButton, DockPanel.SOUTH); if(img!=null) diff --git a/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/event/TaskComputationFinishedEvent.java b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/event/TaskComputationFinishedEvent.java new file mode 100644 index 0000000..6c8d1dd --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/event/TaskComputationFinishedEvent.java @@ -0,0 +1,88 @@ +/* + * + */ +package org.gcube.portlets.widgets.wstaskexecutor.client.event; + +import org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskExecutionStatus; +import org.gcube.portlets.widgets.wstaskexecutor.shared.WSItem; + +import com.google.gwt.event.shared.GwtEvent; + + + +/** + * The Class TaskComputationFinishedEvent. + * + * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) + * Jun 7, 2018 + */ +public class TaskComputationFinishedEvent extends GwtEvent { + + /** The type. */ + public static Type TYPE = new Type(); + private TaskExecutionStatus taskExecutionStatus; + private WSItem wsItem; + private Throwable error; + + + /** + * Instantiates a new perform run task event. + * + * @param wsItem the ws item + * @param taskExecutionStatus the task execution status + */ + public TaskComputationFinishedEvent(WSItem wsItem, TaskExecutionStatus taskExecutionStatus, Throwable exception) { + this.wsItem = wsItem; + this.taskExecutionStatus = taskExecutionStatus; + this.error = exception; + + } + + /* (non-Javadoc) + * @see com.google.gwt.event.shared.GwtEvent#getAssociatedType() + */ + @Override + public Type getAssociatedType() { + return TYPE; + } + + /* (non-Javadoc) + * @see com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared.EventHandler) + */ + @Override + protected void dispatch(TaskComputationFinishedEventHandler handler) { + handler.onTaskFinished(this); + } + + + + /** + * Gets the task execution status. + * + * @return the taskExecutionStatus + */ + public TaskExecutionStatus getTaskExecutionStatus() { + + return taskExecutionStatus; + } + + + /** + * Gets the ws item. + * + * @return the ws item + */ + public WSItem getWsItem() { + return wsItem; + } + + + /** + * @return the error + */ + public Throwable getError() { + + return error; + } + +} diff --git a/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/event/TaskComputationFinishedEventHandler.java b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/event/TaskComputationFinishedEventHandler.java new file mode 100644 index 0000000..6dec14b --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/event/TaskComputationFinishedEventHandler.java @@ -0,0 +1,22 @@ +package org.gcube.portlets.widgets.wstaskexecutor.client.event; + +import com.google.gwt.event.shared.EventHandler; + + + +/** + * The Interface TaskComputationFinishedEventHandler. + * + * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) + * Jun 7, 2018 + */ +public interface TaskComputationFinishedEventHandler extends EventHandler { + + /** + * On task finished. + * + * @param taskComputationTerminatedEvent the task computation terminated event + */ + void onTaskFinished( + TaskComputationFinishedEvent taskComputationTerminatedEvent); +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/rpc/WsTaskExecutorWidgetService.java b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/rpc/WsTaskExecutorWidgetService.java index 0ef3bdb..bd668b6 100644 --- a/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/rpc/WsTaskExecutorWidgetService.java +++ b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/rpc/WsTaskExecutorWidgetService.java @@ -3,6 +3,7 @@ package org.gcube.portlets.widgets.wstaskexecutor.client.rpc; import java.util.List; import org.gcube.common.workspacetaskexecutor.shared.TaskOperator; +import org.gcube.common.workspacetaskexecutor.shared.TaskOutput; import org.gcube.common.workspacetaskexecutor.shared.TaskParameterType; import org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskComputation; import org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskConfiguration; @@ -123,4 +124,18 @@ public interface WsTaskExecutorWidgetService extends RemoteService { * @throws Exception the exception */ List getListOperatorsPerScope(String scope) throws Exception; + + + /** + * Gets the output. + * + * @param taskConfiguration the task configuration + * @param taskComputation the task computation + * @return the output + * @throws TaskErrorException the task error exception + * @throws Exception the exception + */ + TaskOutput getOutput( + TaskConfiguration taskConfiguration, TaskComputation taskComputation) + throws TaskErrorException, Exception; } diff --git a/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/rpc/WsTaskExecutorWidgetServiceAsync.java b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/rpc/WsTaskExecutorWidgetServiceAsync.java index d036b44..fb24706 100644 --- a/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/rpc/WsTaskExecutorWidgetServiceAsync.java +++ b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/rpc/WsTaskExecutorWidgetServiceAsync.java @@ -6,6 +6,7 @@ package org.gcube.portlets.widgets.wstaskexecutor.client.rpc; import java.util.List; import org.gcube.common.workspacetaskexecutor.shared.TaskOperator; +import org.gcube.common.workspacetaskexecutor.shared.TaskOutput; import org.gcube.common.workspacetaskexecutor.shared.TaskParameterType; import org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskComputation; import org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskConfiguration; @@ -143,9 +144,20 @@ public interface WsTaskExecutorWidgetServiceAsync { * @param scope the scope * @param asyncCallback the async callback * @return the list operators per scope - * @throws Exception the exception */ void getListOperatorsPerScope(String scope, AsyncCallback> asyncCallback); + /** + * Gets the output. + * + * @param taskConfiguration the task configuration + * @param taskComputation the task computation + * @param asyncCallback the async callback + * @return the output + */ + void getOutput( + TaskConfiguration taskConfiguration, TaskComputation taskComputation, AsyncCallback asyncCallback); + + } diff --git a/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/view/WsTaskExecutorWidgetViewManager.java b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/view/WsTaskExecutorWidgetViewManager.java index 813acc8..cdcecff 100644 --- a/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/view/WsTaskExecutorWidgetViewManager.java +++ b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/view/WsTaskExecutorWidgetViewManager.java @@ -12,6 +12,7 @@ import org.gcube.portlets.widgets.wstaskexecutor.client.TaskCompletedNotificatio import org.gcube.portlets.widgets.wstaskexecutor.client.WsTaskExecutorWidget; import org.gcube.portlets.widgets.wstaskexecutor.client.event.CreatedTaskConfigurationEvent; import org.gcube.portlets.widgets.wstaskexecutor.client.event.DeleteConfigurationEvent; +import org.gcube.portlets.widgets.wstaskexecutor.client.event.TaskComputationFinishedEvent; import org.gcube.portlets.widgets.wstaskexecutor.client.view.binder.AbstractViewDialogBox; import org.gcube.portlets.widgets.wstaskexecutor.client.view.binder.CreateTaskConfigurationView; import org.gcube.portlets.widgets.wstaskexecutor.client.view.binder.MonitorFolderTaskExecutionStatusView; @@ -24,7 +25,6 @@ import com.github.gwtbootstrap.client.ui.event.HideHandler; import com.google.gwt.core.shared.GWT; import com.google.gwt.user.client.Command; import com.google.gwt.user.client.Timer; -import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; @@ -102,29 +102,26 @@ public class WsTaskExecutorWidgetViewManager { } - - /** * Show monitor task status for. * - * @param folder the folder + * @param wsItem the ws item * @param configuration the configuration * @param taskComputation the task computation - * @param taskEventsListeners the task events listeners */ public void showMonitorTaskStatusFor( - final WSItem folder, - final TaskConfiguration configuration, final TaskComputation taskComputation, final List taskEventsListeners) { + final WSItem wsItem, + final TaskConfiguration configuration, final TaskComputation taskComputation) { - GWT.log("Show Monitor TaskStatus for itemId: "+folder.getItemId()); + GWT.log("Show Monitor TaskStatus for itemId: "+wsItem.getItemId()); final Modal box = new Modal(true); box.addStyleName("ws-task-modal-body"); - box.setTitle("Monitor Task Execution on: "+FormatUtil.getFolderTitle(folder.getItemName(), 20)); + box.setTitle("Monitor Task Execution on: "+FormatUtil.getFolderTitle(wsItem.getItemName(), 20)); box.setWidth(800); box.hide(false); - MonitorFolderTaskExecutionStatusView monitorView = getMonitor(folder); + MonitorFolderTaskExecutionStatusView monitorView = getMonitor(wsItem); GWT.log("monitorView is: "+monitorView); final AbstractViewDialogBox panelView = new AbstractViewDialogBox() { @@ -179,13 +176,13 @@ public class WsTaskExecutorWidgetViewManager { @Override public void onFailure(Throwable caught) { - cancelMonitor(folder); - Window.alert(caught.getMessage()); + //cancelMonitor(wsItem); + WsTaskExecutorWidget.eventBus.fireEvent(new TaskComputationFinishedEvent(wsItem, null, caught)); - //CALLING METHOD ON SYNC ERROR TO THE LISTENERS - for (TaskCompletedNotificationListner listener : taskEventsListeners) { - listener.onTaskComputationError(folder); - } +// //CALLING METHOD ON SYNC ERROR TO THE LISTENERS +// for (TaskCompletedNotificationListner listener : taskEventsListeners) { +// listener.onTaskComputationError(wsItem); +// } } @Override @@ -193,21 +190,27 @@ public class WsTaskExecutorWidgetViewManager { GWT.log("monitorSyncStatus: "+status); if(status==null) { GWT.log("The status is null server-side, cancelling polling"); - cancelMonitor(folder); + cancelMonitor(wsItem); } - currentMonitor.updateStatusView(folder, status); + currentMonitor.updateStatusView(wsItem, status); if(status!=null) { - if(status.getStatus().equals(TaskStatus.COMPLETED)) { - GWT.log("Sync completed cancel the polling: "+status); - cancelMonitor(folder); + if(status.getStatus().equals(TaskStatus.CANCELLED) || + status.getStatus().equals(TaskStatus.COMPLETED) || + status.getStatus().equals(TaskStatus.FAILED)){ - //CALLING METHOD ON SYNC COMPLETED TO THE LISTENERS - for (TaskCompletedNotificationListner listener : taskEventsListeners) { - listener.onTaskComputationCompleted(folder); - } + WsTaskExecutorWidget.eventBus.fireEvent(new TaskComputationFinishedEvent(wsItem, status, null)); + + +// GWT.log("Sync completed cancel the polling: "+status); +// cancelMonitor(wsItem); +// +// //CALLING METHOD ON SYNC COMPLETED TO THE LISTENERS +// for (TaskCompletedNotificationListner listener : taskEventsListeners) { +// listener.onTaskComputationCompleted(wsItem); +// } } } @@ -218,7 +221,7 @@ public class WsTaskExecutorWidgetViewManager { schedulingTimer.scheduleRepeating(2000); currentMonitor.setScheduler(schedulingTimer); - saveMonitor(folder, currentMonitor); + saveMonitor(wsItem, currentMonitor); } diff --git a/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/view/binder/MonitorFolderTaskExecutionStatusView.java b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/view/binder/MonitorFolderTaskExecutionStatusView.java index dcd6639..c9c220d 100644 --- a/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/view/binder/MonitorFolderTaskExecutionStatusView.java +++ b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/view/binder/MonitorFolderTaskExecutionStatusView.java @@ -289,7 +289,6 @@ public abstract class MonitorFolderTaskExecutionStatusView extends Composite { msgHistory += storageUtil.getItem(KEY_LOCAL_STORAGE_COMP_MSG_HISTORY); //adding also history this.field_history_messages.setValue(msgHistory); storageUtil.setItem(KEY_LOCAL_STORAGE_COMP_MSG_HISTORY, msgHistory); - } diff --git a/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/public/WsTaskExecutorWidget.css b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/public/WsTaskExecutorWidget.css index 917325f..ef08b3b 100644 --- a/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/public/WsTaskExecutorWidget.css +++ b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/public/WsTaskExecutorWidget.css @@ -79,8 +79,10 @@ table.table-fixed td { box-shadow: none; /* line-height: 7px; */ opacity: 1; - z-index: 1500; + z-index: 10000; background-color: #FFFFFF; + max-height: 700px; + max-width: 1000px; } .gwt-DialogBoxNew .Caption { @@ -95,7 +97,9 @@ table.table-fixed td { } .gwt-DialogBoxNew .dialogContent { - + max-height: 650px; + overflow: hidden; + overflow-y: auto !important; } .gwt-DialogBoxNew .dialogMiddleCenter { diff --git a/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/server/WsTaskExecutorWidgetServiceImpl.java b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/server/WsTaskExecutorWidgetServiceImpl.java index 35bd05c..776a35e 100644 --- a/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/server/WsTaskExecutorWidgetServiceImpl.java +++ b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/server/WsTaskExecutorWidgetServiceImpl.java @@ -9,6 +9,7 @@ import org.gcube.common.portal.PortalContext; import org.gcube.common.scope.api.ScopeProvider; import org.gcube.common.workspacetaskexecutor.dataminer.WorkspaceDataMinerTaskExecutor; import org.gcube.common.workspacetaskexecutor.shared.TaskOperator; +import org.gcube.common.workspacetaskexecutor.shared.TaskOutput; import org.gcube.common.workspacetaskexecutor.shared.TaskParameter; import org.gcube.common.workspacetaskexecutor.shared.TaskParameterType; import org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskComputation; @@ -308,6 +309,18 @@ public class WsTaskExecutorWidgetServiceImpl extends RemoteServiceServlet implem } + /* (non-Javadoc) + * @see org.gcube.portlets.widgets.wstaskexecutor.client.rpc.WsTaskExecutorWidgetService#monitorTaskExecutionStatus(org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskConfiguration, org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskComputation) + */ + @Override + public TaskOutput getOutput( + TaskConfiguration taskConfiguration, TaskComputation taskComputation) + throws TaskErrorException, Exception{ + WorkspaceDataMinerTaskExecutor exec = getTaskExecutor(); + return exec.getTaskOutput(taskConfiguration, taskComputation); + } + + /** * Gets the list operators per scope.