118 lines
3.6 KiB
Java
118 lines
3.6 KiB
Java
|
|
package org.gcube.portlets.widgets.wstaskexecutor.client;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
import org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskConfiguration;
|
|
import org.gcube.common.workspacetaskexecutor.shared.exception.ItemNotConfiguredException;
|
|
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;
|
|
import org.gcube.portlets.widgets.wstaskexecutor.client.view.WsTaskExecutorWidgetViewManager;
|
|
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.client.GWT;
|
|
import com.google.gwt.event.shared.HandlerManager;
|
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
|
|
|
|
|
/**
|
|
* Entry point classes define <code>onModuleLoad()</code>.
|
|
*
|
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
|
* May 4, 2018
|
|
*/
|
|
public class WsTaskExecutorWidget {
|
|
|
|
/**
|
|
* The message displayed to the user when the server cannot be reached or
|
|
* returns an error.
|
|
*/
|
|
private static final String SERVER_ERROR = "An error occurred while "
|
|
+ "attempting to contact the server. Please check your network "
|
|
+ "connection and try again.";
|
|
/**
|
|
* Create a remote service proxy to talk to the server-side Greeting
|
|
* service.
|
|
*/
|
|
public static final WsTaskExecutorWidgetServiceAsync wsTaskService = WsTaskExecutorWidgetServiceAsync.Util.getInstance();
|
|
|
|
/** The Constant eventBus. */
|
|
public final static HandlerManager eventBus = new HandlerManager(null);
|
|
|
|
private WsTaskExecutorWidgetViewManager viewManager = new WsTaskExecutorWidgetViewManager();
|
|
|
|
private final List<TaskCompletedNotificationListner> taskEventsListeners = new ArrayList<TaskCompletedNotificationListner>();
|
|
|
|
/**
|
|
* Instantiates a new ws task executor widget.
|
|
*/
|
|
public WsTaskExecutorWidget() {
|
|
bindEvents();
|
|
// TODO Auto-generated constructor stub
|
|
}
|
|
|
|
/**
|
|
* Bind events.
|
|
*/
|
|
private void bindEvents() {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
* Show task configurations folder info.
|
|
*
|
|
* @param folder the folder
|
|
* @throws Exception the exception
|
|
*/
|
|
public void showTaskConfigurationsFolderInfo(final WsFolder folder) throws Exception {
|
|
|
|
if(folder==null || folder.getFolderId()==null)
|
|
throw new Exception("Invalid parameter folder null");
|
|
|
|
|
|
MonitorFolderTaskExecutionStatusView monitor = viewManager.getMonitor(folder);
|
|
|
|
//SHOWING CURRENT ACTIVE MONITOR
|
|
if(monitor!=null) {
|
|
GWT.log("Monitor for folder: "+folder.getFolderId() +" exists showing it..");
|
|
viewManager.showMonitorTaskStatusFor(folder, monitor.getTaskConfiguration(), monitor.getTaskComputation(), taskEventsListeners);
|
|
return;
|
|
}
|
|
|
|
final Modal box = new Modal(true);
|
|
box.setTitle("Checking configurations...");
|
|
LoaderIcon loader = new LoaderIcon("Checking folder configurations...");
|
|
box.add(loader);
|
|
|
|
GWT.log("Performing isItemSynched: "+folder.getFolderId());
|
|
|
|
WsTaskExecutorWidget.wsTaskService.checkItemTaskConfigurations(folder.getFolderId(), new AsyncCallback<List<TaskConfiguration>>() {
|
|
|
|
@Override
|
|
public void onSuccess(List<TaskConfiguration> result) {
|
|
|
|
viewManager.showTaskConfigurationsFolderInfo(folder, result, taskEventsListeners);
|
|
}
|
|
|
|
@Override
|
|
public void onFailure(Throwable caught) {
|
|
|
|
if(caught instanceof ItemNotConfiguredException){
|
|
viewManager.showCreateConfigurationFolder(folder, null);
|
|
}
|
|
|
|
}
|
|
});
|
|
|
|
box.show();
|
|
|
|
}
|
|
}
|