Enhancement on Task #10070

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/widgets/ws-task-executor-widget@167328 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2018-05-04 15:32:34 +00:00
parent 60357cf4d6
commit d051be62b9
9 changed files with 721 additions and 447 deletions

View File

@ -6,7 +6,6 @@ import java.util.List;
import org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskConfiguration;
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.rpc.WsTaskExecutorWidgetServiceAsync;
import org.gcube.portlets.widgets.wstaskexecutor.client.view.LoaderIcon;
@ -39,7 +38,7 @@ public class WsTaskExecutorWidget {
* Create a remote service proxy to talk to the server-side Greeting
* service.
*/
public static final WsTaskExecutorWidgetServiceAsync greetingService = WsTaskExecutorWidgetServiceAsync.Util.getInstance();
public static final WsTaskExecutorWidgetServiceAsync wsTaskService = WsTaskExecutorWidgetServiceAsync.Util.getInstance();
/** The Constant eventBus. */
public final static HandlerManager eventBus = new HandlerManager(null);
@ -83,7 +82,7 @@ public class WsTaskExecutorWidget {
//SHOWING CURRENT ACTIVE MONITOR
if(monitor!=null) {
GWT.log("Monitor for folder: "+folder.getFolderId() +" exists showing it..");
viewManager.showMonitorTaskStatusForFolder(folder, taskEventsListeners);
viewManager.showMonitorTaskStatusFor(folder, monitor.getTaskConfiguration(), monitor.getTaskComputation(), taskEventsListeners);
return;
}
@ -94,52 +93,24 @@ public class WsTaskExecutorWidget {
GWT.log("Performing isItemSynched: "+folder.getFolderId());
WsTaskExecutorWidget.greetingService.checkItemTaskConfigurations(folder.getFolderId(), new AsyncCallback<List<TaskConfiguration>>() {
WsTaskExecutorWidget.wsTaskService.checkItemTaskConfigurations(folder.getFolderId(), new AsyncCallback<List<TaskConfiguration>>() {
@Override
public void onSuccess(List<TaskConfiguration> result) {
// TODO Auto-generated method stub
viewManager.showTaskConfigurationsFolderInfo(folder, result, taskEventsListeners);
}
@Override
public void onFailure(Throwable caught) {
if(caught instanceof ItemNotConfiguredException){
}else if(caught instanceof WorkspaceFolderLocked){
viewManager.showMonitorTaskStatusForFolder(folder,taskEventsListeners);
return;
viewManager.showCreateConfigurationFolder(folder, null);
}
}
});
// WsTaskExecutorWidget.greetingService.checkItemTaskConfigurations(folder.getFolderId(), new AsyncCallback<List<TaskConfiguration>>() {
//
// @Override
// public void onSuccess(List<TaskConfiguration> result) {
// box.hide();
// //GWT.log("WsThreddsSynchFolderDescriptor result: "+result);
// viewManager.showThreddsFolderInfo(folder, result);
//
// }
//
// @Override
// public void onFailure(Throwable caught) {
// box.hide();
//
// if(caught instanceof WorkspaceFolderLocked){
// viewManager.showMonitorSyncToFolder(folder,syncEventsListeners);
// return;
// }
//
// viewManager.cancelMonitor(folder);
// // TODO Auto-generated method stub
// Window.alert(caught.getMessage());
// }
// });
box.show();
}

View File

@ -0,0 +1,67 @@
package org.gcube.portlets.widgets.wstaskexecutor.client.event;
import org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskConfiguration;
import org.gcube.portlets.widgets.wstaskexecutor.shared.WsFolder;
import com.google.gwt.event.shared.GwtEvent;
// TODO: Auto-generated Javadoc
/**
* The Class PerformDoSyncEvent.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Feb 15, 2018
*/
public class PerformRunTaskEvent extends GwtEvent<PerformRunTaskEventHandler> {
/** The type. */
public static Type<PerformRunTaskEventHandler> TYPE = new Type<PerformRunTaskEventHandler>();
private TaskConfiguration conf;
private WsFolder folder;
/**
* Instantiates a new perform do sync event.
*
* @param folder the folder
* @param conf the conf
*/
public PerformRunTaskEvent(WsFolder folder, TaskConfiguration conf) {
this.folder = folder;
this.conf = conf;
}
/* (non-Javadoc)
* @see com.google.gwt.event.shared.GwtEvent#getAssociatedType()
*/
@Override
public Type<PerformRunTaskEventHandler> getAssociatedType() {
return TYPE;
}
/* (non-Javadoc)
* @see com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared.EventHandler)
*/
@Override
protected void dispatch(PerformRunTaskEventHandler handler) {
handler.onPerformRunTask(this);
}
/**
* Gets the conf.
*
* @return the conf
*/
public TaskConfiguration getConf() {
return conf;
}
public WsFolder getFolder() {
return folder;
}
}

View File

@ -0,0 +1,22 @@
package org.gcube.portlets.widgets.wstaskexecutor.client.event;
import com.google.gwt.event.shared.EventHandler;
// TODO: Auto-generated Javadoc
/**
* The Interface PerformDoSyncEventHandler.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Feb 15, 2018
*/
public interface PerformRunTaskEventHandler extends EventHandler {
/**
* On change status.
*
* @param courseChangeStatusEvent the course change status event
*/
void onPerformRunTask(PerformRunTaskEvent courseChangeStatusEvent);
}

View File

@ -5,7 +5,9 @@ package org.gcube.portlets.widgets.wstaskexecutor.client.rpc;
import java.util.List;
import org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskComputation;
import org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskConfiguration;
import org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskExecutionStatus;
import org.gcube.portlets.widgets.wstaskexecutor.shared.GcubeScope;
import com.google.gwt.core.client.GWT;
@ -70,4 +72,16 @@ public interface WsTaskExecutorWidgetServiceAsync {
* @param asyncCallback the async callback
*/
void checkItemTaskConfigurations(String folderId, AsyncCallback<List<TaskConfiguration>> asyncCallback);
/**
* Monitor task execution status.
*
* @param configuration the configuration
* @param taskComputation the task computation
* @param asyncCallback the async callback
*/
void monitorTaskExecutionStatus(
TaskConfiguration configuration, TaskComputation taskComputation,
AsyncCallback<TaskExecutionStatus> asyncCallback);
}

View File

@ -1,25 +1,38 @@
package org.gcube.portlets.widgets.wstaskexecutor.client.view;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.gcube.common.workspacetaskexecutor.shared.TaskStatus;
import org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskComputation;
import org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskConfiguration;
import org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskExecutionStatus;
import org.gcube.portlets.widgets.wstaskexecutor.client.TaskCompletedNotification.TaskCompletedNotificationListner;
import org.gcube.portlets.widgets.wstaskexecutor.client.WsTaskExecutorWidget;
import org.gcube.portlets.widgets.wstaskexecutor.client.event.PerformRunTaskEvent;
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;
import org.gcube.portlets.widgets.wstaskexecutor.shared.WsFolder;
import com.github.gwtbootstrap.client.ui.Modal;
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;
// TODO: Auto-generated Javadoc
/**
* The Class WsThreddsWidgetViewManager.
* The Class WsTaskExecutorWidgetViewManager.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Feb 19, 2018
* May 4, 2018
*/
public class WsTaskExecutorWidgetViewManager {
//private Map<String, MonitorFolderSyncStatusView> mapMonitor = new HashMap<String, MonitorFolderSyncStatusView>();
private Map<String, MonitorFolderTaskExecutionStatusView> mapMonitor = new HashMap<String, MonitorFolderTaskExecutionStatusView>();
/**
@ -29,420 +42,290 @@ public class WsTaskExecutorWidgetViewManager {
}
/**
* @param folder
* @return
* Cancel scheduler.
*
* @param folder the folder
* @return the monitor folder task execution status view
*/
public MonitorFolderTaskExecutionStatusView getMonitor(WsFolder folder) {
private MonitorFolderTaskExecutionStatusView cancelScheduler(final WsFolder folder) {
MonitorFolderTaskExecutionStatusView monitor = getMonitor(folder);
if(monitor.getSchedulerTime()!=null) {
GWT.log("Cancelling scheduler time on folder: "+folder.getFolderId());
monitor.getSchedulerTime().cancel();
}
return monitor;
// TODO Auto-generated method stub
return null;
}
/**
* @param folder
* @param taskEventsListeners
* Cancel monitor.
*
* @param folder the folder
*/
public void showMonitorTaskStatusForFolder(
WsFolder folder,
List<TaskCompletedNotificationListner> taskEventsListeners) {
public void cancelMonitor(WsFolder folder) {
try {
MonitorFolderTaskExecutionStatusView monitor = cancelScheduler(folder);
if(monitor!=null) {
GWT.log("Removed monitor for folder: "+folder.getFolderId());
mapMonitor.remove(folder.getFolderId());
}
}catch (Exception e) {
GWT.log("Error on removing map monitor for id: "+folder.getFolderId());
}
}
// TODO Auto-generated method stub
/**
* Gets the monitor.
*
* @param folder the folder
* @return the monitor
*/
public MonitorFolderTaskExecutionStatusView getMonitor(WsFolder folder){
if(folder==null)
return null;
return mapMonitor.get(folder.getFolderId());
}
/**
* Save monitor.
*
* @param folder the folder
* @param monitor the monitor
*/
private void saveMonitor(WsFolder folder, MonitorFolderTaskExecutionStatusView monitor) {
GWT.log("Saving monitor for folder: "+folder.getFolderId());
mapMonitor.put(folder.getFolderId(), monitor);
}
/**
* Show monitor task status for.
*
* @param folder the folder
* @param configuration the configuration
* @param taskComputation the task computation
* @param taskEventsListeners the task events listeners
*/
public void showMonitorTaskStatusFor(
WsFolder folder,
final TaskConfiguration configuration, TaskComputation taskComputation, List<TaskCompletedNotificationListner> taskEventsListeners) {
GWT.log("showMonitorSyncToFolder for folder: "+folder.getFolderId());
final Modal box = new Modal(true);
box.addStyleName("ws-thredds-modal-body");
box.setTitle("Monitor transferring of: "+FormatUtil.getFolderTitle(folder.getFoderName(), 20));
box.setWidth(800);
box.hide(false);
MonitorFolderTaskExecutionStatusView monitorView = getMonitor(folder);
GWT.log("monitorView is: "+monitorView);
final AbstractViewDialogBox panelView = new AbstractViewDialogBox() {
@Override
public void closeHandler() {
//cancelScheduler(folder);
box.hide();
}
@Override
public void confirmHanlder(CONFIRM_VALUE confirm, Command command) {
// TODO Auto-generated method stub
}
};
if(monitorView==null) {
monitorView = new MonitorFolderTaskExecutionStatusView(configuration, taskComputation) {
@Override
public void closetHandler() {
//TODO CLIENT SIDE?
//cancelMonitor(folder);
panelView.closeHandler();
}
@Override
public void setError(boolean visible, String error) {
panelView.setError(visible, error);
}
};
}
if(monitorView.getSchedulerTime()==null) {
//Removing old monitor
//cancelMonitor(folder);
//Creating new one
final MonitorFolderTaskExecutionStatusView currentMonitor = monitorView;
Timer schedulingTimer = new Timer() {
@Override
public void run() {
WsTaskExecutorWidget.wsTaskService.monitorTaskExecutionStatus(configuration, taskComputation, new AsyncCallback<TaskExecutionStatus>() {
@Override
public void onFailure(Throwable caught) {
cancelMonitor(folder);
Window.alert(caught.getMessage());
//CALLING METHOD ON SYNC ERROR TO THE LISTENERS
for (TaskCompletedNotificationListner listener : taskEventsListeners) {
listener.onTaskComputationError(folder);
}
}
@Override
public void onSuccess(TaskExecutionStatus status) {
GWT.log("monitorSyncStatus: "+status);
if(status==null) {
GWT.log("The status is null server-side, cancelling polling");
cancelMonitor(folder);
}
currentMonitor.updateStatusView(folder, status);
if(status!=null) {
if(status.getStatus().equals(TaskStatus.COMPLETED)) {
GWT.log("Sync completed cancel the polling: "+status);
cancelMonitor(folder);
//CALLING METHOD ON SYNC COMPLETED TO THE LISTENERS
for (TaskCompletedNotificationListner listener : taskEventsListeners) {
listener.onTaskComputationCompleted(folder);
}
}
}
}
});
}
};
schedulingTimer.scheduleRepeating(2000);
currentMonitor.setScheduler(schedulingTimer);
saveMonitor(folder, currentMonitor);
}
panelView.addViewAsWidget(monitorView);
box.add(panelView);
box.show();
}
/**
* Show task configurations folder info.
*
* @param folder the folder
* @param result the result
* @param taskEventsListeners the task events listeners
*/
public void showTaskConfigurationsFolderInfo(
WsFolder folder, final List<TaskConfiguration> result, final List<TaskCompletedNotificationListner> taskEventsListeners) {
}
/**
* Show create configuration folder.
*
* @param folder the folder
* @param conf the conf
*/
public void showCreateConfigurationFolder(final WsFolder folder, TaskConfiguration conf){
final Modal box = new Modal(true);
box.setTitle("Create Thredds Sync Configuration for: "+FormatUtil.getFolderTitle(folder.getFoderName(), 20));
//box.getElement().getStyle().setZIndex(10000);
final AbstractViewDialogBox panelView = new AbstractViewDialogBox() {
@Override
public void closeHandler() {
box.hide();
}
@Override
public void confirmHanlder(CONFIRM_VALUE confirm, Command command) {
if(confirm.equals(CONFIRM_VALUE.YES)){
box.hide();
}
if(command!=null)
command.execute();
}
};
CreateTaskConfigurationView createThreddsConfiguration = new CreateTaskConfigurationView(folder.getFolderId()) {
@Override
public void submitHandler() {
panelView.closeHandler();
TaskConfiguration conf = new TaskConfiguration();
conf.setScope(getSelectedScope().getScopeName());
conf.setTaskId(getTaskId());
conf.setTaskDescription("");
conf.setWorkspaceItemId(folder.getFolderId());
conf.setMapParameters(getParameters());
WsTaskExecutorWidget.eventBus.fireEvent(new PerformRunTaskEvent(folder, conf));
}
@Override
public void setError(boolean visible, String error) {
panelView.setError(visible, error);
}
@Override
public void setConfirm(boolean visible, String msg) {
Command yes = new Command() {
@Override
public void execute() {
submitHandler();
}
};
Command no = new Command() {
@Override
public void execute() {
panelView.setConfirm(false, "", null, null);
}
};
panelView.setConfirm(visible, msg, yes, no);
}
};
panelView.addViewAsWidget(createThreddsConfiguration);
box.add(panelView);
box.show();
}
// /**
// * Cancel monitor.
// *
// * @param folder the folder
// */
// public void cancelMonitor(WsFolder folder) {
// try {
// MonitorFolderSyncStatusView monitor = cancelScheduler(folder);
// if(monitor!=null) {
// GWT.log("Removed monitor for folder: "+folder.getFolderId());
// mapMonitor.remove(folder.getFolderId());
// }
// }catch (Exception e) {
// GWT.log("Error on removing map monitor for id: "+folder.getFolderId());
// }
// }
//
//
// /**
// * Gets the monitor.
// *
// * @param folder the folder
// * @return the monitor
// */
// public MonitorFolderSyncStatusView getMonitor(WsFolder folder){
//
// if(folder==null)
// return null;
//
// return mapMonitor.get(folder.getFolderId());
// }
//
//
// /**
// * Save monitor.
// *
// * @param folder the folder
// * @param monitor the monitor
// */
// private void saveMonitor(WsFolder folder, MonitorFolderSyncStatusView monitor) {
// GWT.log("Saving monitor for folder: "+folder.getFolderId());
// mapMonitor.put(folder.getFolderId(), monitor);
// }
//
//
// /**
// * Cancel scheduler.
// *
// * @param folder the folder
// * @return
// */
// private MonitorFolderSyncStatusView cancelScheduler(final WsFolder folder) {
//
// MonitorFolderSyncStatusView monitor = getMonitor(folder);
// if(monitor.getSchedulerTime()!=null) {
// GWT.log("Cancelling scheduler time on folder: "+folder.getFolderId());
// monitor.getSchedulerTime().cancel();
// }
//
// return monitor;
//
// }
//
// /**
// * Show monitor sync to folder.
// *
// * @param folder the folder
// * @param syncEventsListeners
// */
// public void showMonitorSyncToFolder(final WsFolder folder, final List<SyncCompletedNotificationListner> syncEventsListeners) {
// GWT.log("showMonitorSyncToFolder for folder: "+folder.getFolderId());
//
// final Modal box = new Modal(true);
// box.addStyleName("ws-thredds-modal-body");
// box.setTitle("Monitor transferring of: "+FormatUtil.getFolderTitle(folder.getFoderName(), 20));
// box.setWidth(800);
// box.hide(false);
//
// MonitorFolderSyncStatusView monitorView = getMonitor(folder);
// GWT.log("monitorView is: "+monitorView);
//
// final AbstractViewDialogBox panelView = new AbstractViewDialogBox() {
//
// @Override
// public void closeHandler() {
// //cancelScheduler(folder);
// box.hide();
//
// }
//
// @Override
// public void confirmHanlder(CONFIRM_VALUE confirm, Command command) {
//
// // TODO Auto-generated method stub
//
// }
// };
//
// if(monitorView==null) {
//
// monitorView = new MonitorFolderSyncStatusView() {
//
// @Override
// public void closetHandler() {
// //TODO CLIENT SIDE?
// //cancelMonitor(folder);
// panelView.closeHandler();
// }
//
// @Override
// public void setError(boolean visible, String error) {
// panelView.setError(visible, error);
// }
// };
//
// }
//
// if(monitorView.getSchedulerTime()==null) {
//
// //Removing old monitor
// //cancelMonitor(folder);
// //Creating new one
// final MonitorFolderSyncStatusView currentMonitor = monitorView;
//
// Timer schedulingTimer = new Timer() {
//
// @Override
// public void run() {
//
// WsThreddsWidget.wsThreddsSyncService.monitorSyncStatus(folder.getFolderId(), new AsyncCallback<ThSyncStatus>() {
//
// @Override
// public void onFailure(Throwable caught) {
// cancelMonitor(folder);
// Window.alert(caught.getMessage());
//
// //CALLING METHOD ON SYNC ERROR TO THE LISTENERS
// for (SyncCompletedNotificationListner listener : syncEventsListeners) {
// listener.onSyncError(folder);
// }
// }
//
// @Override
// public void onSuccess(ThSyncStatus status) {
// GWT.log("monitorSyncStatus: "+status);
// if(status==null) {
// GWT.log("The status is null server-side, cancelling polling");
// cancelMonitor(folder);
// }
//
// currentMonitor.updateStatusView(folder, status);
//
// if(status!=null && status.getProcessStatus()!=null) {
//
// if(status.getProcessStatus().getStatus().equals(Status.COMPLETED)) {
// GWT.log("Sync completed cancel the polling: "+status);
// cancelMonitor(folder);
//
// //CALLING METHOD ON SYNC COMPLETED TO THE LISTENERS
// for (SyncCompletedNotificationListner listener : syncEventsListeners) {
// listener.onSyncCompleted(folder);
// }
// }
//
// }
// }
// });
// }
// };
//
// schedulingTimer.scheduleRepeating(2000);
// currentMonitor.setScheduler(schedulingTimer);
// saveMonitor(folder, currentMonitor);
//
// }
//
// panelView.addViewAsWidget(monitorView);
// box.add(panelView);
// box.show();
//
// }
//
//
// /**
// * Show create configuration folder.
// *
// * @param folder the folder
// * @param conf the conf
// */
// public void showCreateConfigurationFolder(final WsFolder folder, WsThreddsSynchFolderDescriptor conf){
//
// final Modal box = new Modal(true);
// box.setTitle("Create Thredds Sync Configuration for: "+FormatUtil.getFolderTitle(folder.getFoderName(), 20));
// //box.getElement().getStyle().setZIndex(10000);
//
// final AbstractViewDialogBox panelView = new AbstractViewDialogBox() {
//
// @Override
// public void closeHandler() {
// box.hide();
//
// }
//
// @Override
// public void confirmHanlder(CONFIRM_VALUE confirm, Command command) {
//
// if(confirm.equals(CONFIRM_VALUE.YES)){
// box.hide();
// }
//
// if(command!=null)
// command.execute();
//
// }
// };
//
// CreateThreddsConfigurationView createThreddsConfiguration = new CreateThreddsConfigurationView(folder.getFolderId()) {
//
// @Override
// public void submitHandler() {
// panelView.closeHandler();
// WsThreddsSynchFolderConfiguration conf = new WsThreddsSynchFolderConfiguration();
// conf.setFilter(null);
//
// ThCatalogueBean catalogueSelected = getSelectedCatalogue();
// String remotePath = catalogueSelected.getPath()!=null?catalogueSelected.getPath():"";
// remotePath = remotePath.isEmpty()?getFolderName():remotePath+"/"+getFolderName();
// conf.setRemotePath(remotePath);
// conf.setCatalogName(catalogueSelected.getName());
// conf.setSelectedScope(getSelectedScope());
// conf.setRootFolderId(folder.getFolderId());
// WsThreddsWidget.eventBus.fireEvent(new PerformDoSyncEvent(folder, conf));
// }
//
// @Override
// public void setError(boolean visible, String error) {
// panelView.setError(visible, error);
//
// }
//
// @Override
// public void setConfirm(boolean visible, String msg) {
//
// Command yes = new Command() {
//
// @Override
// public void execute() {
//
// submitHandler();
// }
// };
//
// Command no = new Command() {
//
// @Override
// public void execute() {
//
// panelView.setConfirm(false, "", null, null);
// }
// };
//
// panelView.setConfirm(visible, msg, yes, no);
//
// }
// };
//
// panelView.addViewAsWidget(createThreddsConfiguration);
// box.add(panelView);
// box.show();
//
// }
//
//
// /**
// * Show thredds folder info.
// *
// * @param folder the folder
// * @param folderDescriptor the folder descriptor
// */
// public void showThreddsFolderInfo(final WsFolder folder, final WsThreddsSynchFolderDescriptor folderDescriptor){
// GWT.log("ShowThreddsFolderInfo folder: "+folder);
// //GWT.log("WsThreddsSynchFolderDescriptor is: "+folderDescriptor);
//
// final Modal box = new Modal(true);
// box.hide(false);
// //box.setWidth(WIDHT_DIALOG+"px");
// box.setTitle("Thredds Sync Information for: "+FormatUtil.getFolderTitle(folder.getFoderName(), 20));
// //box.getElement().getStyle().setZIndex(10000);
//
// final AbstractViewDialogBox panelView = new AbstractViewDialogBox() {
//
// @Override
// public void closeHandler() {
// box.hide();
// }
//
// @Override
// public void confirmHanlder(CONFIRM_VALUE confirm, Command command) {
//
// // TODO Auto-generated method stub
//
// }
// };
//
// boolean isCreateConfiguration = folderDescriptor==null?true:false;
//
//
// ShowThreddsFolderInfoView folderInfo = new ShowThreddsFolderInfoView(folder.getFolderId(), isCreateConfiguration) {
//
// @Override
// public void submitHandler(SUBMIT_ACTION action) {
// panelView.closeHandler();
//
// if(action==null)
// return;
//
// switch (action) {
//
// case CREATE_UPDATE_CONFIGURATION:
//
// if(folderDescriptor==null) {
// GWT.log("Performing a create configuration");
// //PERFORM A CREATE CONFIGURATION (AT FIRST TIME), THE CONFIGURATION DOES NOT EXITS
// showCreateConfigurationFolder(folder, null);
//
// }
//// else {
//// GWT.log("Performing an updated configuration");
//// //PERFORM AN UPDATE CONFIGURATION. THE CONFIGURATION EXIST
//// //BeanConverter.toWsThreddsFolderConfig(t, vre);
//// showCreateConfigurationFolder(folder, result);
//// }
////
//
// break;
//
// case DO_SYNC:
// GWT.log("Performing a do sync using server folder configuration");
// //PERFORM A DO SYNC BUT NOT AT FIRST TIME
// WsThreddsWidget.eventBus.fireEvent(new PerformDoSyncEvent(folder, null));
//
// break;
//
// default:
// break;
// }
//
// }
// @Override
// public void setError(boolean visible, String error) {
// //panelView.setError(visible, error);
// panelView.setInfo(visible, error);
// }
// };
//
// folderInfo.updateViewToResult(folder, folderDescriptor);
//
// if(isCreateConfiguration) {
// folderInfo.getMainPanel().setVisible(false);
// folderInfo.setError(true, "This Folder is not configured. Do you want create a configuration?");
// folderInfo.getPager().getLeft().setText("Create Configuration");
// }else {
// //USER CAN PERFORM DO SYNC
// //MOREOVER, HE/SHE COULD UPDATE THE CONFIGURATION BUT IT IS NOT SUPPORTED SERVER-SIDE
// folderInfo.getPager().getLeft().setVisible(false);
//
// if(folderDescriptor.getServerFolderDescriptor().isLocked()) {
// VerticalPanel v = new VerticalPanel();
// Alert alert = new Alert("Current Folder synchronization is locked by another proccess. Do you want see synchronization status?");
// alert.setClose(true);
// alert.setType(AlertType.INFO);
//
// Button butt = new Button("Show Status");
// butt.addClickHandler(new ClickHandler() {
//
// @Override
// public void onClick(ClickEvent event) {
// WsThreddsWidget.eventBus.fireEvent(new ShowMonitorSyncStatusEvent(folder));
// }
// });
//
// v.add(alert);
// v.add(butt);
// box.add(v);
// }
//
// }
//
// panelView.addViewAsWidget(folderInfo);
// box.add(panelView);
// box.show();
//
// }
}

View File

@ -148,7 +148,7 @@ public abstract class CreateTaskConfigurationView extends Composite {
});
WsTaskExecutorWidget.greetingService.getListOfScopesForLoggedUser(new AsyncCallback<List<GcubeScope>>() {
WsTaskExecutorWidget.wsTaskService.getListOfScopesForLoggedUser(new AsyncCallback<List<GcubeScope>>() {
@Override
public void onSuccess(List<GcubeScope> result) {
@ -241,6 +241,30 @@ public abstract class CreateTaskConfigurationView extends Composite {
}
/**
* Gets the task id.
*
* @return the task id
*/
public String getTaskId(){
return field_task_id.getValue();
}
/**
* Gets the parameters.
*
* @return the parameters
*/
public Map<String,String> getParameters(){
Map<String, String> map = new HashMap<String, String>(1);
map.put(field_key_param.getValue(), field_value_param.getValue());
return map;
}
}

View File

@ -2,6 +2,8 @@ package org.gcube.portlets.widgets.wstaskexecutor.client.view.binder;
import org.gcube.common.workspacetaskexecutor.shared.TaskStatus;
import org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskComputation;
import org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskConfiguration;
import org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskExecutionStatus;
import org.gcube.portlets.widgets.wstaskexecutor.client.view.LoaderIcon;
import org.gcube.portlets.widgets.wstaskexecutor.shared.WsFolder;
@ -97,6 +99,10 @@ public abstract class MonitorFolderTaskExecutionStatusView extends Composite {
/** The scheduler time. */
private Timer schedulerTime;
private TaskConfiguration taskConfiguration;
private TaskComputation taskComputation;
/**
* Submit handler.
@ -111,7 +117,6 @@ public abstract class MonitorFolderTaskExecutionStatusView extends Composite {
*/
public abstract void setError(boolean visible, String error);
/**
* Because this class has a default constructor, it can
* be used as a binder template. In other words, it can be used in other
@ -123,7 +128,9 @@ public abstract class MonitorFolderTaskExecutionStatusView extends Composite {
* Note that depending on the widget that is used, it may be necessary to
* implement HasHTML instead of HasText.
*/
public MonitorFolderTaskExecutionStatusView() {
public MonitorFolderTaskExecutionStatusView(TaskConfiguration conf, TaskComputation comp) {
this.taskConfiguration = conf;
this.taskComputation = comp;
initWidget(uiBinder.createAndBindUi(this));
@ -249,6 +256,25 @@ public abstract class MonitorFolderTaskExecutionStatusView extends Composite {
}
/**
* @return the taskConfiguration
*/
public TaskConfiguration getTaskConfiguration() {
return taskConfiguration;
}
/**
* @return the taskComputation
*/
public TaskComputation getTaskComputation() {
return taskComputation;
}
/**
* Sets the field value.
*

View File

@ -0,0 +1,210 @@
package org.gcube.portlets.widgets.wstaskexecutor.client.view.binder;
import java.util.HashMap;
import java.util.Map;
import org.gcube.portlets.widgets.wstaskexecutor.shared.GcubeScope;
import com.github.gwtbootstrap.client.ui.ControlGroup;
import com.github.gwtbootstrap.client.ui.ListBox;
import com.github.gwtbootstrap.client.ui.Pager;
import com.github.gwtbootstrap.client.ui.TextBox;
import com.github.gwtbootstrap.client.ui.constants.ControlGroupType;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;
/**
* The Class CreateTaskConfigurationView.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* May 4, 2018
*/
public abstract class ShowTaskConfigurationView extends Composite {
/** The ui binder. */
private static ShowTaskConfigurationViewUiBinder uiBinder =
GWT.create(ShowTaskConfigurationViewUiBinder.class);
/**
* The Interface CreateTaskConfigurationViewUiBinder.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* May 4, 2018
*/
interface ShowTaskConfigurationViewUiBinder
extends UiBinder<Widget, ShowTaskConfigurationView> {
}
/** The pager. */
@UiField
Pager pager;
@UiField
ListBox field_select_scope;
@UiField
TextBox field_key_param;
@UiField
TextBox field_value_param;
@UiField
ControlGroup cg_input_task_id;
@UiField
ControlGroup cg_select_vre;
@UiField
ControlGroup cg_input_key_param;
@UiField
ControlGroup cg_input_value_param;
@UiField
TextBox field_task_id;
/** The folder id. */
private String folderId;
/** The map VR es. */
private Map<String, GcubeScope> mapScopes = new HashMap<String, GcubeScope>();
private String currentScope;
/**
* Submit handler.
*/
public abstract void submitHandler();
/**
* Sets the error.
*
* @param visible the visible
* @param error the error
*/
public abstract void setError(boolean visible, String error);
/**
* Sets the confirm.
*
* @param visible the visible
* @param msg the msg
*/
public abstract void setConfirm(boolean visible, String msg);
/**
* Because this class has a default constructor, it can
* be used as a binder template. In other words, it can be used in other
* *.ui.xml files as follows:
* <ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
* xmlns:g="urn:import:**user's package**">
* <g:**UserClassName**>Hello!</g:**UserClassName>
* </ui:UiBinder>
* Note that depending on the widget that is used, it may be necessary to
* implement HasHTML instead of HasText.
*
* @param folderId the folder id
*/
public ShowTaskConfigurationView(String folderId) {
this.folderId = folderId;
initWidget(uiBinder.createAndBindUi(this));
pager.getLeft().setVisible(false);
pager.getRight().addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
setError(false, "");
boolean isValid = validateSubmit();
if(isValid)
submitHandler();
}
});
}
/**
* Inits the field catalogue name.
*/
private void initFields() {
field_task_id.setText("");
field_key_param.setText("");
field_value_param.setText("");
}
/**
* Validate submit.
*
* @return true, if successful
*/
protected boolean validateSubmit() {
cg_input_task_id.setType(ControlGroupType.NONE);
cg_input_key_param.setType(ControlGroupType.NONE);
cg_input_value_param.setType(ControlGroupType.NONE);
//cg_remote_path.setType(ControlGroupType.NONE);
if(field_select_scope.getSelectedItemText()==null){
cg_select_vre.setType(ControlGroupType.ERROR);
setError(true, "You must select a Scope!");
return false;
}
if(field_task_id.getValue() == null || field_task_id.getValue().isEmpty()){
cg_input_task_id.setType(ControlGroupType.ERROR);
setError(true, "You must type an Algorithm Identifier!");
return false;
}
if(field_key_param.getValue() == null || field_key_param.getValue().isEmpty()){
cg_input_key_param.setType(ControlGroupType.WARNING);
setConfirm(true, "The key of input parameter is empty. Do you want continue anyway?");
return false;
}
if(field_value_param.getValue() == null || field_value_param.getValue().isEmpty()){
cg_input_key_param.setType(ControlGroupType.WARNING);
setConfirm(true, "The value of input parameter is empty. Do you want continue anyway?");
return false;
}
return true;
}
/**
* Gets the selected scope.
*
* @return the selected scope
*/
public GcubeScope getSelectedScope(){
//String item = field_select_scope.getSelectedItemText();
String text = field_select_scope.getSelectedValue();
return mapScopes.get(text);
}
}

View File

@ -0,0 +1,57 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui" xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
<ui:style>
.noBorder {
border: 0px;
}
</ui:style>
<g:HTMLPanel>
<g:HTMLPanel ui:field="form_unit_fields">
<b:Form type="HORIZONTAL">
<b:Fieldset styleName="{style.noBorder}">
<b:ControlGroup ui:field="cg_select_vre">
<b:ControlLabel for="cl_select_vre">Executed in the Scope</b:ControlLabel>
<b:Controls>
<b:ListBox name="Select a VRE..." b:id="field_select_scope"
ui:field="field_select_scope" readOnly="true">
</b:ListBox>
</b:Controls>
</b:ControlGroup>
<b:ControlGroup ui:field="cg_input_task_id">
<b:ControlLabel for="cl_input_task_id">The Algorithm Id</b:ControlLabel>
<b:Controls>
<b:TextBox placeholder="Type the Algorithm Identifier..."
title="This is the Algorithm Identifier..." b:id="field_task_id"
ui:field="field_task_id" readOnly="true"></b:TextBox>
</b:Controls>
</b:ControlGroup>
<b:Label>With Parameter</b:Label>
<b:WellForm type="INLINE">
<b:ControlGroup ui:field="cg_input_key_param">
<b:ControlLabel for="cl_input_key_param">Parameter Key</b:ControlLabel>
<b:Controls>
<b:TextBox placeholder="Type the Key Entry..." title="This is the key of Parameter"
b:id="field_key_param" ui:field="field_key_param" readOnly="true"></b:TextBox>
</b:Controls>
</b:ControlGroup>
<b:ControlGroup ui:field="cg_input_value_param">
<b:ControlLabel for="cl_input_value_param">Parameter Value</b:ControlLabel>
<b:Controls>
<b:TextBox placeholder="Type the Value Entry..."
title="This is the value of parameter" b:id="field_value_param"
ui:field="field_value_param" readOnly="true"></b:TextBox>
</b:Controls>
</b:ControlGroup>
</b:WellForm>
</b:Fieldset>
</b:Form>
</g:HTMLPanel>
<b:Pager left="Older" right="Create Configuration and Do Sync"
aligned="true" ui:field="pager" />
</g:HTMLPanel>
</ui:UiBinder>