enhancement

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/widgets/ws-task-executor-widget@167541 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2018-05-16 15:52:14 +00:00
parent e2bdfdc458
commit 0c69fa392d
9 changed files with 190 additions and 79 deletions

View File

@ -4,10 +4,13 @@ package org.gcube.portlets.widgets.wstaskexecutor.client;
import java.util.ArrayList;
import java.util.List;
import org.gcube.common.workspacetaskexecutor.shared.TaskParameter;
import org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskConfiguration;
import org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskExecutionStatus;
import org.gcube.common.workspacetaskexecutor.shared.exception.ItemNotConfiguredException;
import org.gcube.common.workspacetaskexecutor.shared.exception.WorkspaceFolderLocked;
import org.gcube.portlets.widgets.wstaskexecutor.client.TaskCompletedNotification.TaskCompletedNotificationListner;
import org.gcube.portlets.widgets.wstaskexecutor.client.dialog.DialogConfirm;
import org.gcube.portlets.widgets.wstaskexecutor.client.dialog.DialogResult;
import org.gcube.portlets.widgets.wstaskexecutor.client.event.CreatedTaskConfigurationEvent;
import org.gcube.portlets.widgets.wstaskexecutor.client.event.CreatedTaskConfigurationEventHandler;
@ -83,10 +86,49 @@ public class WsTaskExecutorWidget {
eventBus.addHandler(PerformRunTaskEvent.TYPE, new PerformRunTaskEventHandler() {
@Override
public void onPerformRunTask(PerformRunTaskEvent perforRunTaskEvent) {
public void onPerformRunTask(final PerformRunTaskEvent perforRunTaskEvent) {
try {
performRunTask(perforRunTaskEvent.getFolder(), perforRunTaskEvent.getConf());
if(perforRunTaskEvent.getWsItem()!=null && perforRunTaskEvent.getConfiguration()!=null){
String msg = "<div style='font-size:14px; font-weight:bold;'>Executing the task with configuration:</div>";
msg+="<br/>";
msg+="Operator Id: "+perforRunTaskEvent.getConfiguration().getTaskId();
int cParam = perforRunTaskEvent.getConfiguration().getListParameters().size();
msg+="<br/><br/>";
if(cParam>0){
msg+="With Input ";
msg+=cParam>1?"Parameters:":"Parameter:";
msg+="<br/>";
int i = 0;
for (TaskParameter param : perforRunTaskEvent.getConfiguration().getListParameters()) {
msg+=++i+". Type: "+param.getType().getType() +" having "+param.getKey()+" = " +param.getValue();
msg+="<br/>";
}
}
msg+="<br/>";
msg+="<br/>";
msg+="<div style='font-size:14px; font-weight:bold;'>Confirm?</div>";
final DialogConfirm confirm = new DialogConfirm(null, "Run the task?", msg);
confirm.getYesButton().addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
try {
performRunTask(perforRunTaskEvent.getWsItem(), perforRunTaskEvent.getConfiguration());
confirm.hide();
}
catch (Exception e) {
Window.alert(e.getMessage());
}
}
});
confirm.center();
}
}
catch (Exception e) {
Window.alert(e.getMessage());
@ -104,8 +146,7 @@ public class WsTaskExecutorWidget {
showTaskConfigurations(showListOfTaskConfigurationsEvent.getWsItem());
}
catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
Window.alert(e.getMessage());
}
}
});
@ -139,8 +180,7 @@ public class WsTaskExecutorWidget {
showTaskConfigurations(dcEvent.getWsItem());
}
catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
Window.alert(e.getMessage());
}
}
@ -213,7 +253,7 @@ public class WsTaskExecutorWidget {
* @param conf the conf
* @throws Exception the exception
*/
public void performRunTask(WSItem wsItem, TaskConfiguration conf) throws Exception {
public void performRunTask(final WSItem wsItem, final TaskConfiguration conf) throws Exception {
if(wsItem==null || wsItem.getItemId()==null)
throw new Exception("Invalid parameter workpace item or its id is null");
@ -221,8 +261,29 @@ public class WsTaskExecutorWidget {
if(conf==null)
throw new Exception("Invalid parameter the configuration is null");
final Modal box = new Modal(true);
box.setTitle("Executing task configuration...");
//WsTaskExecutorWidget.wsTaskService.runTask()
LoaderIcon loader = new LoaderIcon("Executing task configuration for: <br/>"+conf.getTaskId());
box.add(loader);
WsTaskExecutorWidget.wsTaskService.executeTheTask(conf, new AsyncCallback<TaskExecutionStatus>() {
@Override
public void onFailure(Throwable caught) {
box.hide();
new DialogResult(null, "Error on show Task Status for algorithm id:"+conf.getTaskId(), caught.getMessage()).center();
viewManager.cancelMonitor(wsItem);
}
@Override
public void onSuccess(TaskExecutionStatus result) {
box.hide();
viewManager.showMonitorTaskStatusFor(wsItem, result.getTaskConfiguration(), result.getTaskComputation(), taskEventsListeners);
}
});
box.show();
}
@ -266,10 +327,10 @@ public class WsTaskExecutorWidget {
@Override
public void onFailure(Throwable caught) {
box.hide();
if(caught instanceof ItemNotConfiguredException){
box.hide();
viewManager.showCreateTaskConfigurationForFolder(wsItem, null);
}else if(caught instanceof WorkspaceFolderLocked){

View File

@ -20,17 +20,17 @@ public class PerformRunTaskEvent extends GwtEvent<PerformRunTaskEventHandler> {
/** The type. */
public static Type<PerformRunTaskEventHandler> TYPE = new Type<PerformRunTaskEventHandler>();
private TaskConfiguration conf;
private WSItem folder;
private WSItem wsItem;
/**
* Instantiates a new perform do sync event.
* Instantiates a new perform run task event.
*
* @param folder the folder
* @param wsItem the ws item
* @param conf the conf
*/
public PerformRunTaskEvent(WSItem folder, TaskConfiguration conf) {
this.folder = folder;
public PerformRunTaskEvent(WSItem wsItem, TaskConfiguration conf) {
this.wsItem = wsItem;
this.conf = conf;
}
@ -52,23 +52,25 @@ public class PerformRunTaskEvent extends GwtEvent<PerformRunTaskEventHandler> {
}
/**
* Gets the conf.
* Gets the configuration.
*
* @return the conf
* @return the configuration
*/
public TaskConfiguration getConf() {
public TaskConfiguration getConfiguration() {
return conf;
}
/**
* Gets the folder.
* Gets the ws item.
*
* @return the folder
* @return the ws item
*/
public WSItem getFolder() {
return folder;
public WSItem getWsItem() {
return wsItem;
}
}

View File

@ -8,17 +8,20 @@ import org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskConfiguration
import org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskExecutionStatus;
import org.gcube.common.workspacetaskexecutor.shared.exception.ItemNotConfiguredException;
import org.gcube.common.workspacetaskexecutor.shared.exception.ItemNotExecutableException;
import org.gcube.common.workspacetaskexecutor.shared.exception.TaskErrorException;
import org.gcube.common.workspacetaskexecutor.shared.exception.TaskNotExecutableException;
import org.gcube.portlets.widgets.wstaskexecutor.shared.GcubeScope;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
/**
* The Interface GreetingService.
* The Interface WsTaskExecutorWidgetService.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* May 4, 2018
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* May 16, 2018
*/
@RemoteServiceRelativePath("workspacetaskexecutor")
public interface WsTaskExecutorWidgetService extends RemoteService {
@ -37,10 +40,11 @@ public interface WsTaskExecutorWidgetService extends RemoteService {
* @param configuration the configuration
* @param taskComputation the task computation
* @return the task execution status
* @throws TaskErrorException the task error exception
* @throws Exception the exception
*/
TaskExecutionStatus monitorTaskExecutionStatus(
TaskConfiguration configuration, TaskComputation taskComputation) throws Exception;
TaskConfiguration configuration, TaskComputation taskComputation) throws TaskErrorException, Exception;
/**
@ -63,30 +67,50 @@ public interface WsTaskExecutorWidgetService extends RemoteService {
List<TaskParameterType> getAvailableParameterTypes() throws Exception;
/**
* @param itemId
* @param taskConfiguration
* @param isUpdate
* @return
* @throws Exception
* Creates the task configuration.
*
* @param itemId the item id
* @param taskConfiguration the task configuration
* @param isUpdate the is update
* @return the boolean
* @throws Exception the exception
*/
Boolean createTaskConfiguration(
String itemId, TaskConfiguration taskConfiguration, boolean isUpdate)
throws Exception;
/**
* @param itemId
* @return
* @throws Exception
* Gets the item task configurations.
*
* @param itemId the item id
* @return the item task configurations
* @throws Exception the exception
*/
List<TaskConfiguration> getItemTaskConfigurations(String itemId)
throws Exception;
/**
* @param taskConfiguration
* @return
* @throws ItemNotExecutableException
* @throws Exception
* Removes the task configuration.
*
* @param taskConfiguration the task configuration
* @return the boolean
* @throws ItemNotExecutableException the item not executable exception
* @throws Exception the exception
*/
Boolean removeTaskConfiguration(TaskConfiguration taskConfiguration)
throws ItemNotExecutableException, Exception;
/**
* Execute the task.
*
* @param taskConfiguration the task configuration
* @return the task execution status
* @throws ItemNotExecutableException the item not executable exception
* @throws TaskNotExecutableException the task not executable exception
* @throws Exception the exception
*/
TaskExecutionStatus executeTheTask(TaskConfiguration taskConfiguration)
throws ItemNotExecutableException, TaskNotExecutableException,
Exception;
}

View File

@ -126,4 +126,14 @@ public interface WsTaskExecutorWidgetServiceAsync {
*/
void removeTaskConfiguration(TaskConfiguration taskConfiguration, AsyncCallback<Boolean> asyncCallback);
/**
* Execute the task.
*
* @param taskConfiguration the task configuration
* @param asyncCallback the async callback
*/
void executeTheTask(TaskConfiguration taskConfiguration, AsyncCallback<TaskExecutionStatus> asyncCallback);
}

View File

@ -48,7 +48,7 @@ public class WsTaskExecutorWidgetViewManager {
MonitorFolderTaskExecutionStatusView monitor = getMonitor(wsItem);
if(monitor.getSchedulerTime()!=null) {
GWT.log("Cancelling scheduler time on folder: "+wsItem.getItemId());
GWT.log("Cancelling scheduler time on item: "+wsItem.getItemId());
monitor.getSchedulerTime().cancel();
}
@ -66,7 +66,7 @@ public class WsTaskExecutorWidgetViewManager {
try {
MonitorFolderTaskExecutionStatusView monitor = cancelScheduler(wsItem);
if(monitor!=null) {
GWT.log("Removed monitor for folder: "+wsItem.getItemId());
GWT.log("Removed monitor for item: "+wsItem.getItemId());
mapMonitor.remove(wsItem.getItemId());
}
}catch (Exception e) {
@ -116,11 +116,11 @@ public class WsTaskExecutorWidgetViewManager {
final WSItem folder,
final TaskConfiguration configuration, final TaskComputation taskComputation, final List<TaskCompletedNotificationListner> taskEventsListeners) {
GWT.log("showMonitorSyncToFolder for folder: "+folder.getItemId());
GWT.log("Show Monitor TaskStatus for itemId: "+folder.getItemId());
final Modal box = new Modal(true);
box.addStyleName("ws-thredds-modal-body");
box.setTitle("Monitor transferring of: "+FormatUtil.getFolderTitle(folder.getItemName(), 20));
box.setTitle("Monitor Task Execution on: "+FormatUtil.getFolderTitle(folder.getItemName(), 20));
box.setWidth(800);
box.hide(false);

View File

@ -45,7 +45,7 @@ public abstract class MonitorFolderTaskExecutionStatusView extends Composite {
*/
public static final String PROCESSING_STATE = "Processing state: ";
private static final String UNKNOWN = "UNKNOWN";
private static final String EMPTY = "EMPTY";
/** The ui binder. */
private static MonitorFolderTaskExecutionStatusViewUiBinder uiBinder =
@ -78,8 +78,8 @@ public abstract class MonitorFolderTaskExecutionStatusView extends Composite {
// @UiField
// TextBox field_transferred_items;
@UiField
TextBox field_number_error;
// @UiField
// TextBox field_number_error;
@UiField
TextArea field_history_messages;
@ -179,11 +179,11 @@ public abstract class MonitorFolderTaskExecutionStatusView extends Composite {
field_loader.add(loader);
this.folder = folder;
this.field_current_message.setValue(UNKNOWN);
setFieldValue(this.field_number_error, UNKNOWN);
this.field_current_message.setValue(EMPTY);
//setFieldValue(this.field_number_error, UNKNOWN);
// setFieldValue(this.field_queued_items, UNKNOWN);
// setFieldValue(this.field_transferred_items, UNKNOWN);
this.field_history_messages.setValue(UNKNOWN);
this.field_history_messages.setValue(EMPTY);
if(folder==null || taskExecutionStatus==null || taskExecutionStatus.getStatus()==null) {
//setError(true, "Sync status error: either folder does not exist or the status is null");
@ -206,7 +206,6 @@ public abstract class MonitorFolderTaskExecutionStatusView extends Composite {
field_loader.clear();
field_loader.add(new LoaderIcon(PROCESSING_STATE+TaskStatus.INITIALIZING.toString()));
break;
case ONGOING:
field_loader.clear();
field_loader.add(new LoaderIcon(PROCESSING_STATE+TaskStatus.ONGOING.toString()));
@ -222,7 +221,6 @@ public abstract class MonitorFolderTaskExecutionStatusView extends Composite {
alert.setType(AlertType.SUCCESS);
field_loader.add(alert);
break;
case CANCELLED:
field_loader.clear();
Alert alert1 = new Alert("Transferring " +TaskStatus.CANCELLED.toString());
@ -247,8 +245,8 @@ public abstract class MonitorFolderTaskExecutionStatusView extends Composite {
if(taskExecutionStatus.getCurrentMessage()!=null)
this.field_current_message.setValue(taskExecutionStatus.getCurrentMessage());
if(taskExecutionStatus.getErrorCount()!=null)
this.field_number_error.setValue(taskExecutionStatus.getErrorCount().toString());
// if(taskExecutionStatus.getErrorCount()!=null)
// this.field_number_error.setValue(taskExecutionStatus.getErrorCount().toString());
if(taskExecutionStatus.getLog()!=null)
this.field_history_messages.setValue(taskExecutionStatus.getLog());

View File

@ -11,7 +11,6 @@
}
.myFormWidth {
width: 750px;
}
</ui:style>
<g:VerticalPanel>
@ -20,7 +19,7 @@
</g:HTMLPanel>
<b:ProgressBar type="DEFAULT" color="INFO" percent="0"
ui:field="progress_percentage" />
<g:HorizontalPanel addStyleNames="myMarginLeft">
<!-- <g:HorizontalPanel addStyleNames="myMarginLeft"> -->
<!-- <b:ControlGroup ui:field="cg_queued_items" addStyleNames="myLittleMarginLeft"> -->
<!-- <b:ControlLabel for="cl_queued_items">Items in queue</b:ControlLabel> -->
<!-- <b:Controls> -->
@ -36,14 +35,14 @@
<!-- </b:TextBox> -->
<!-- </b:Controls> -->
<!-- </b:ControlGroup> -->
<b:ControlGroup ui:field="cg_number_error" addStyleNames="myLittleMarginLeft">
<b:ControlLabel for="cl_number_error">Number of Errors</b:ControlLabel>
<b:Controls>
<b:TextBox b:id="field_number_error" ui:field="field_number_error"
readOnly="true" addStyleNames="myLittleWidth"></b:TextBox>
</b:Controls>
</b:ControlGroup>
</g:HorizontalPanel>
<!-- <b:ControlGroup ui:field="cg_number_error" addStyleNames="myLittleMarginLeft"> -->
<!-- <b:ControlLabel for="cl_number_error">Number of Errors</b:ControlLabel> -->
<!-- <b:Controls> -->
<!-- <b:TextBox b:id="field_number_error" ui:field="field_number_error" -->
<!-- readOnly="true" addStyleNames="myLittleWidth"></b:TextBox> -->
<!-- </b:Controls> -->
<!-- </b:ControlGroup> -->
<!-- </g:HorizontalPanel> -->
<b:Form type="HORIZONTAL" addStyleNames="myFormWidth"
ui:field="field_form">
<b:Fieldset styleName="{style.noBorder}">

View File

@ -7,6 +7,7 @@ import java.util.List;
import org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskConfiguration;
import org.gcube.portlets.widgets.wstaskexecutor.client.WsTaskExecutorWidget;
import org.gcube.portlets.widgets.wstaskexecutor.client.event.PerformRunTaskEvent;
import org.gcube.portlets.widgets.wstaskexecutor.client.event.ShowCreateTaskConfigurationDialogEvent;
import org.gcube.portlets.widgets.wstaskexecutor.client.event.ShowCreateTaskConfigurationDialogEvent.Operation;
import org.gcube.portlets.widgets.wstaskexecutor.shared.WSItem;
@ -97,9 +98,9 @@ public abstract class ShowTaskConfigurationsView extends Composite {
HTML h2 = new HTML("<b>VRE<b>");
flex_table_configurations.setWidget(0, 2, h2);
flex_table_configurations.setWidget(0, 3, new HTML("<b>Owner<b>"));
flex_table_configurations.setWidget(0, 4, new HTML("<b>Oper.<b>"));
flex_table_configurations.setWidget(0, 5, new HTML("<b>Oper.<b>"));
flex_table_configurations.setWidget(0, 6, new HTML("<b>Oper.<b>"));
flex_table_configurations.setWidget(0, 4, new HTML("<b>Run<b>"));
flex_table_configurations.setWidget(0, 5, new HTML("<b>Edit<b>"));
flex_table_configurations.setWidget(0, 6, new HTML("<b>Del.<b>"));
//flex_table_configurations.getColumnFormatter().setWidth(0, "10%");
flex_table_configurations.getColumnFormatter().setWidth(0, "31%");
flex_table_configurations.getColumnFormatter().setWidth(1, "6%");
@ -116,7 +117,12 @@ public abstract class ShowTaskConfigurationsView extends Composite {
//flex_table_configurations.setWidget(i+1, 0, new HTML(taskConfiguration.getConfigurationKey()));
String operatorID = taskConfiguration.getTaskId();
if(operatorID.length()>MAX_LENGHT_TEXT){
operatorID = "..."+operatorID.substring(operatorID.length()-MAX_LENGHT_TEXT, operatorID.length());
int algNameIndexStart = operatorID.lastIndexOf(".")+1;
String algName = operatorID.substring(algNameIndexStart, operatorID.length());
if(algName.length()>MAX_LENGHT_TEXT)
operatorID = "..."+operatorID.substring(operatorID.length()-MAX_LENGHT_TEXT, operatorID.length());
else
operatorID = algName;
}
HTML aId=new HTML(operatorID);
aId.setTitle(taskConfiguration.getTaskId());
@ -138,7 +144,7 @@ public abstract class ShowTaskConfigurationsView extends Composite {
@Override
public void onClick(ClickEvent event) {
WsTaskExecutorWidget.eventBus.fireEvent(new PerformRunTaskEvent(wsItem,taskConfiguration));
}
});

View File

@ -13,6 +13,8 @@ import org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskConfiguration
import org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskExecutionStatus;
import org.gcube.common.workspacetaskexecutor.shared.exception.ItemNotConfiguredException;
import org.gcube.common.workspacetaskexecutor.shared.exception.ItemNotExecutableException;
import org.gcube.common.workspacetaskexecutor.shared.exception.TaskErrorException;
import org.gcube.common.workspacetaskexecutor.shared.exception.TaskNotExecutableException;
import org.gcube.common.workspacetaskexecutor.shared.exception.WorkspaceFolderLocked;
import org.gcube.common.workspacetaskexecutor.util.EncrypterUtil;
import org.gcube.portlets.widgets.wstaskexecutor.client.rpc.WsTaskExecutorWidgetService;
@ -209,18 +211,6 @@ public class WsTaskExecutorWidgetServiceImpl extends RemoteServiceServlet implem
return exec.getParameterTypes();
}
/* (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 TaskExecutionStatus monitorTaskExecutionStatus(
TaskConfiguration configuration, TaskComputation taskComputation)
throws Exception {
// TODO Auto-generated method stub
return null;
}
/**
* Creates the task configuration.
@ -293,4 +283,25 @@ public class WsTaskExecutorWidgetServiceImpl extends RemoteServiceServlet implem
return confs;
}
/* (non-Javadoc)
* @see org.gcube.portlets.widgets.wstaskexecutor.client.rpc.WsTaskExecutorWidgetService#executeTheTask(org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskConfiguration)
*/
@Override
public TaskExecutionStatus executeTheTask(TaskConfiguration taskConfiguration) throws ItemNotExecutableException, TaskNotExecutableException, Exception {
WorkspaceDataMinerTaskExecutor exec = getTaskExecutor();
return exec.executeRun(taskConfiguration);
}
/* (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 TaskExecutionStatus monitorTaskExecutionStatus(
TaskConfiguration configuration, TaskComputation taskComputation)
throws TaskErrorException, Exception{
WorkspaceDataMinerTaskExecutor exec = getTaskExecutor();
return exec.monitorRunStatus(configuration, taskComputation);
}
}