Added SelectableOperator

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/widgets/ws-task-executor-widget@169055 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2018-06-12 13:38:05 +00:00
parent aa39419270
commit 2677d45c0f
9 changed files with 380 additions and 551 deletions

View File

@ -30,6 +30,7 @@ import org.gcube.portlets.widgets.wstaskexecutor.client.rpc.WsTaskExecutorWidget
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.SelectableOperator;
import org.gcube.portlets.widgets.wstaskexecutor.shared.WSItem;
import com.github.gwtbootstrap.client.ui.Alert;
@ -73,6 +74,8 @@ public class WsTaskExecutorWidget {
private final List<TaskCompletedNotificationListner> taskEventsListeners = new ArrayList<TaskCompletedNotificationListner>();
private SelectableOperator selectableOperators = null;
/**
* Instantiates a new ws task executor widget.
*/
@ -146,7 +149,7 @@ public class WsTaskExecutorWidget {
if(showListOfTaskConfigurationsEvent.getWsItem()!=null)
try {
showTaskConfigurations(showListOfTaskConfigurationsEvent.getWsItem());
showTaskConfigurations(showListOfTaskConfigurationsEvent.getWsItem(), selectableOperators);
}
catch (Exception e) {
Window.alert(e.getMessage());
@ -180,7 +183,7 @@ public class WsTaskExecutorWidget {
String msg = "Task configuration for Algorithm: "+dcEvent.getTaskConf().getTaskName() +"<br/><br/>removed correctly";
new DialogResult(null, "Delete performed!",msg).center();
}
showTaskConfigurations(dcEvent.getWsItem());
showTaskConfigurations(dcEvent.getWsItem(), selectableOperators);
}
catch (Exception e) {
Window.alert(e.getMessage());
@ -201,9 +204,9 @@ public class WsTaskExecutorWidget {
if(event.getWsItem()!=null){
if(event.getOperation().equals(Operation.CREATE_NEW)){
viewManager.showCreateTaskConfigurationForFolder(event.getWsItem(), null);
viewManager.showCreateTaskConfigurationForFolder(event.getWsItem(), null, selectableOperators);
}else {
viewManager.showCreateTaskConfigurationForFolder(event.getWsItem(), event.getTaskConfiguration());
viewManager.showCreateTaskConfigurationForFolder(event.getWsItem(), event.getTaskConfiguration(), selectableOperators);
}
}
}
@ -233,7 +236,7 @@ public class WsTaskExecutorWidget {
public void onSuccess(Boolean result) {
try {
showTaskConfigurations(createTCE.getWsItem());
showTaskConfigurations(createTCE.getWsItem(), selectableOperators);
}
catch (Exception e) {
// TODO Auto-generated catch block
@ -355,10 +358,47 @@ public class WsTaskExecutorWidget {
* @param wsItem the ws item
* @throws Exception the exception
*/
public void showTaskConfigurations(final WSItem wsItem) throws Exception {
public void showTaskConfigurations(final WSItem wsItem, SelectableOperator selectableOperators) throws Exception {
this.selectableOperators = selectableOperators;
if(wsItem==null || wsItem.getItemId()==null)
throw new Exception("Invalid parameter workpace item or its id is null");
throw new Exception("Invalid input parameter "+WSItem.class.getSimpleName()+". Its id or itself is null");
final Modal box = new Modal(true);
box.setTitle("Checking item configurations...");
String suffix = wsItem.getItemName()!=null || !wsItem.getItemName().isEmpty()?wsItem.getItemName():wsItem.getItemId();
LoaderIcon loader = new LoaderIcon("Checking task configurations for item: "+suffix);
box.add(loader);
WsTaskExecutorWidget.wsTaskService.loadItem(wsItem.getItemId(), new AsyncCallback<WSItem>() {
@Override
public void onFailure(Throwable caught) {
box.hide();
Window.alert(caught.getMessage());
}
@Override
public void onSuccess(WSItem result) {
//no hide monitor
handleShowMonitor(result,box);
}
});
box.show();
}
/**
* Handle show monitor.
*
* @param wsItem the ws item
*/
private void handleShowMonitor(final WSItem wsItem, final Modal box){
MonitorFolderTaskExecutionStatusView monitor = viewManager.getMonitor(wsItem);
@ -369,12 +409,12 @@ public class WsTaskExecutorWidget {
return;
}
final Modal box = new Modal(true);
box.setTitle("Checking configurations...");
String suffix = wsItem.getItemName()!=null || !wsItem.getItemName().isEmpty()?wsItem.getItemName():wsItem.getItemId();
LoaderIcon loader = new LoaderIcon("Checking task configurations for item: "+suffix);
box.add(loader);
// box.clear();
// box.setTitle("Checking configurations...");
//
// String suffix = wsItem.getItemName()!=null || !wsItem.getItemName().isEmpty()?wsItem.getItemName():wsItem.getItemId();
// LoaderIcon loader = new LoaderIcon("Checking task configurations for item: "+suffix);
// box.add(loader);
GWT.log("Performing checkItemTaskConfigurations: "+wsItem.getItemId());
@ -393,7 +433,7 @@ public class WsTaskExecutorWidget {
if(caught instanceof ItemNotConfiguredException){
box.hide();
viewManager.showCreateTaskConfigurationForFolder(wsItem, null);
viewManager.showCreateTaskConfigurationForFolder(wsItem, null, selectableOperators);
}else if(caught instanceof WorkspaceFolderLocked){
VerticalPanel v = new VerticalPanel();
@ -418,7 +458,6 @@ public class WsTaskExecutorWidget {
}
});
box.show();
//box.show();
}
}

View File

@ -13,6 +13,8 @@ import org.gcube.common.workspacetaskexecutor.shared.exception.ItemNotExecutable
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 org.gcube.portlets.widgets.wstaskexecutor.shared.SelectableOperator;
import org.gcube.portlets.widgets.wstaskexecutor.shared.WSItem;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
@ -116,14 +118,17 @@ public interface WsTaskExecutorWidgetService extends RemoteService {
throws ItemNotExecutableException, TaskNotExecutableException,
Exception;
/**
* Gets the list operators per scope.
*
* @param scope the scope
* @param selectableOperators the selectable operators
* @return the list operators per scope
* @throws Exception the exception
*/
List<TaskOperator> getListOperatorsPerScope(String scope) throws Exception;
List<TaskOperator> getListOperatorsPerScope(String scope, SelectableOperator selectableOperators) throws Exception;
/**
@ -138,4 +143,14 @@ public interface WsTaskExecutorWidgetService extends RemoteService {
TaskOutput getOutput(
TaskConfiguration taskConfiguration, TaskComputation taskComputation)
throws TaskErrorException, Exception;
/**
* Load item.
*
* @param itemId the item id
* @return the WS item
* @throws Exception the exception
*/
WSItem loadItem(String itemId) throws Exception;
}

View File

@ -12,6 +12,8 @@ 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 org.gcube.portlets.widgets.wstaskexecutor.shared.SelectableOperator;
import org.gcube.portlets.widgets.wstaskexecutor.shared.WSItem;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
@ -138,14 +140,16 @@ public interface WsTaskExecutorWidgetServiceAsync {
void executeTheTask(TaskConfiguration taskConfiguration, AsyncCallback<TaskExecutionStatus> asyncCallback);
/**
* Gets the list operators per scope.
*
* @param scope the scope
* @param selectableOperators the selectable operators
* @param asyncCallback the async callback
* @return the list operators per scope
*/
void getListOperatorsPerScope(String scope, AsyncCallback<List<TaskOperator>> asyncCallback);
void getListOperatorsPerScope(String scope, SelectableOperator selectableOperators, AsyncCallback<List<TaskOperator>> asyncCallback);
/**
@ -160,4 +164,13 @@ public interface WsTaskExecutorWidgetServiceAsync {
TaskConfiguration taskConfiguration, TaskComputation taskComputation, AsyncCallback<TaskOutput> asyncCallback);
/**
* Load item.
*
* @param itemId the item id
* @param asyncCallback the async callback
*/
void loadItem(String itemId, AsyncCallback<WSItem> asyncCallback);
}

View File

@ -17,6 +17,7 @@ import org.gcube.portlets.widgets.wstaskexecutor.client.view.binder.AbstractView
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.client.view.binder.ShowTaskConfigurationsView;
import org.gcube.portlets.widgets.wstaskexecutor.shared.SelectableOperator;
import org.gcube.portlets.widgets.wstaskexecutor.shared.WSItem;
import com.github.gwtbootstrap.client.ui.Modal;
@ -316,7 +317,7 @@ public class WsTaskExecutorWidgetViewManager {
* @param wsItem the ws item
* @param conf the conf
*/
public void showCreateTaskConfigurationForFolder(final WSItem wsItem, TaskConfiguration conf){
public void showCreateTaskConfigurationForFolder(final WSItem wsItem, TaskConfiguration conf, SelectableOperator selectableOperator){
final Modal box = new Modal(true);
//box.setWidth(AbstractViewDialogBox.DEFAULT_WIDTH+20+"px");
@ -346,7 +347,7 @@ public class WsTaskExecutorWidgetViewManager {
}
};
CreateTaskConfigurationView createTaskConfiguration = new CreateTaskConfigurationView(wsItem, conf) {
CreateTaskConfigurationView createTaskConfiguration = new CreateTaskConfigurationView(wsItem, conf, selectableOperator) {
@Override
public void submitHandler() {

View File

@ -1,515 +0,0 @@
package org.gcube.portlets.widgets.wstaskexecutor.client.view.binder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.gcube.common.workspacetaskexecutor.shared.TaskOperator;
import org.gcube.common.workspacetaskexecutor.shared.TaskParameter;
import org.gcube.common.workspacetaskexecutor.shared.TaskParameterType;
import org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskConfiguration;
import org.gcube.portlets.widgets.wstaskexecutor.client.WsTaskExecutorWidget;
import org.gcube.portlets.widgets.wstaskexecutor.client.dialog.DialogResult;
import org.gcube.portlets.widgets.wstaskexecutor.client.event.DeleteCustomFieldEvent;
import org.gcube.portlets.widgets.wstaskexecutor.client.event.DeleteCustomFieldEventHandler;
import org.gcube.portlets.widgets.wstaskexecutor.client.event.ShowListOfTaskConfigurationsEvent;
import org.gcube.portlets.widgets.wstaskexecutor.client.view.LoaderIcon;
import org.gcube.portlets.widgets.wstaskexecutor.shared.GcubeScope;
import org.gcube.portlets.widgets.wstaskexecutor.shared.WSItem;
import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.ControlGroup;
import com.github.gwtbootstrap.client.ui.Controls;
import com.github.gwtbootstrap.client.ui.Fieldset;
import com.github.gwtbootstrap.client.ui.ListBox;
import com.github.gwtbootstrap.client.ui.Pager;
import com.github.gwtbootstrap.client.ui.TextArea;
import com.github.gwtbootstrap.client.ui.constants.ControlGroupType;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Document;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.DomEvent;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTMLPanel;
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 CopyOfCreateTaskConfigurationView extends Composite {
/** The ui binder. */
private static CreateTaskConfigurationViewUiBinder uiBinder = GWT.create(CreateTaskConfigurationViewUiBinder.class);
/**
* The Interface CreateTaskConfigurationViewUiBinder.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* May 4, 2018
*/
interface CreateTaskConfigurationViewUiBinder
extends UiBinder<Widget, CopyOfCreateTaskConfigurationView> {
}
/** The pager. */
@UiField
Pager pager;
@UiField
ListBox field_select_scope;
@UiField
ListBox field_select_task_id;
@UiField
ControlGroup cg_select_vre;
@UiField
ControlGroup cg_select_task_id;
@UiField
ControlGroup cg_parameters_control;
@UiField
Fieldset form_unit_fields;
@UiField
Controls task_parameters_control;
@UiField
Button addCustomFieldButton;
@UiField
HTMLPanel html_panel_field;
@UiField
TextArea field_task_description;
/** The map VR es. */
private Map<String, GcubeScope> mapScopes = new HashMap<String, GcubeScope>();
private Map<String, List<TaskOperator>> mapOperators = new HashMap<String, List<TaskOperator>>();
private String currentScope;
public final static HandlerManager eventBus = new HandlerManager(null);
// added custom field entries (by the user)
private List<CustomFieldEntry> customFieldEntriesList = new ArrayList<CustomFieldEntry>();
private WSItem wsItem;
private boolean isEditConfiguration;
private TaskConfiguration editConfiguration;
/**
* 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 wsItem the folder
* @param conf the conf
*/
public CopyOfCreateTaskConfigurationView(final WSItem wsItem, TaskConfiguration conf) {
this.wsItem = wsItem;
if(conf!=null)
this.isEditConfiguration = true;
this.editConfiguration = conf;
initWidget(uiBinder.createAndBindUi(this));
bindEvents();
WsTaskExecutorWidget.wsTaskService.getListOfScopesForLoggedUser(new AsyncCallback<List<GcubeScope>>() {
@Override
public void onSuccess(List<GcubeScope> result) {
for (GcubeScope gcubeScope : result) {
String toValue = gcubeScope.getScopeTitle();
mapScopes.put(gcubeScope.getScopeName(), gcubeScope);
field_select_scope.addItem(toValue, gcubeScope.getScopeName());
}
if(result.size()>0){
if(isEditConfiguration){
//String vreName = FormatUtil.toVREName(editConfiguration.getScope());
field_select_scope.setSelectedValue(editConfiguration.getScope());
}
else
field_select_scope.setSelectedValue(result.get(0).getScopeName());
//field_select_vre.setSelectedIndex(0);
//field_select_vre.fireEvent(DomEvent.fireNativeEvent(nativeEvent, handlerSource););
DomEvent.fireNativeEvent(Document.get().createChangeEvent(), field_select_scope);
}
}
@Override
public void onFailure(Throwable caught) {
// TODO Auto-generated method stub
}
});
if(isEditConfiguration){
//field_task_id.setValue(editConfiguration.getTaskId());
field_task_description.setValue(editConfiguration.getTaskDescription());
List<TaskParameter> params = editConfiguration.getListParameters();
for (TaskParameter taskParameter : params) {
appendCustomField(taskParameter.getKey(), taskParameter.getValue(), taskParameter.getType().getType(), false);
}
pager.getRight().setText("Update Configuration");
}
else
addEmptyCustomFieldEvent(null);
}
/**
* Adds the empty custom field event.
*
* @param e the e
*/
@UiHandler("addCustomFieldButton")
void addEmptyCustomFieldEvent(ClickEvent e){
appendCustomField(null, null, null, true);
}
/**
* Append custom field.
*
* @param key the key
* @param value the value
* @param parameterType the parameter type
* @param removable the removable
*/
private void appendCustomField(String key, String value, String parameterType, boolean removable){
CustomFieldEntry toAdd = new CustomFieldEntry(eventBus, key, value, parameterType, removable);
customFieldEntriesList.add(toAdd);
cg_parameters_control.add(toAdd);
}
/**
* @param taskOperator
*/
private void fillParametersToOperator(TaskOperator taskOperator) {
customFieldEntriesList.clear();
cg_parameters_control.clear();
for (TaskParameter operator : taskOperator.getInputOperators()) {
appendCustomField(operator.getKey(), operator.getValue(), operator.getType().getType(), false);
}
}
private void loadAlgorithmsForSelectedScope(){
final GcubeScope selScope = getSelectedScope();
if(selScope==null)
return;
List<TaskOperator> operators = mapOperators.get(selScope.getScopeName());
if(operators!=null){
fillSelectOperator(operators);
return;
}
LoaderIcon loader = new LoaderIcon("Please wait, loading Algorithms...");
final DialogResult loaderBox = new DialogResult(null, "Please wait", loader, false);
loaderBox.getElement().getStyle().setZIndex(Integer.MAX_VALUE-5000);
pager.getRight().setVisible(false);
WsTaskExecutorWidget.wsTaskService.getListOperatorsPerScope(selScope.getScopeName(), new AsyncCallback<List<TaskOperator>>() {
@Override
public void onFailure(Throwable caught) {
loaderBox.hide();
field_select_task_id.setEnabled(false);
Window.alert("Error: "+caught.getMessage());
pager.getRight().setVisible(false);
}
@Override
public void onSuccess(List<TaskOperator> result) {
loaderBox.hide();
field_select_task_id.setEnabled(true);
if(result==null || result.size()==0){
new DialogResult(null, "Warning", "No operator available in the scope: "+selScope.getScopeName()).center();
return;
}
pager.getRight().setVisible(true);
mapOperators.put(selScope.getScopeName(), result);
fillSelectOperator(result);
}
});
loaderBox.center();
}
private void fillSelectOperator(List<TaskOperator> operators){
field_select_task_id.clear();
for (TaskOperator taskOperator : operators) {
field_select_task_id.addItem(taskOperator.getName(), taskOperator.getId());
}
if(isEditConfiguration){
//String vreName = FormatUtil.toVREName(editConfiguration.getScope());
field_select_task_id.setSelectedValue(editConfiguration.getTaskId());
}
DomEvent.fireNativeEvent(Document.get().createChangeEvent(), field_select_task_id);
}
/**
* Bind events.
*/
private void bindEvents() {
// when a custom field is removed, remove it from the list
eventBus.addHandler(DeleteCustomFieldEvent.TYPE, new DeleteCustomFieldEventHandler() {
@Override
public void onRemoveEntry(DeleteCustomFieldEvent event) {
customFieldEntriesList.remove(event.getRemovedEntry());
cg_parameters_control.remove(event.getRemovedEntry());
}
});
pager.getLeft().addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
WsTaskExecutorWidget.eventBus.fireEvent(new ShowListOfTaskConfigurationsEvent(wsItem));
}
});
pager.getRight().addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
setError(false, "");
boolean isValid = validateSubmit();
if(isValid)
submitHandler();
}
});
field_select_scope.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
loadAlgorithmsForSelectedScope();
}
});
field_select_task_id.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
setValueDescription("");
String taskId = getTaskId();
GWT.log("Task Id: "+taskId);
GcubeScope selScope = getSelectedScope();
List<TaskOperator> operators = mapOperators.get(selScope.getScopeName());
GWT.log("Operatos for scope '"+selScope.getScopeName() +"' are: "+operators);
for (TaskOperator taskOperator : operators) {
if(taskId.compareTo(taskOperator.getId())==0){
setValueDescription(taskOperator.getDescription());
fillParametersToOperator(taskOperator);
}
}
}
});
}
/**
*
*/
private void setValueDescription(String value) {
field_task_description.setValue(value);
}
/**
* Validate submit.
*
* @return true, if successful
*/
protected boolean validateSubmit() {
cg_select_task_id.setType(ControlGroupType.NONE);
//cg_parameters_control.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_select_scope.getSelectedItemText() == null || field_select_scope.getSelectedItemText().isEmpty()){
cg_select_task_id.setType(ControlGroupType.ERROR);
setError(true, "You must select an Algorithm!");
return false;
}
for (CustomFieldEntry cFE : customFieldEntriesList) {
cFE.getControlGroup().setType(ControlGroupType.NONE);
if(cFE.getKey()==null || cFE.getKey().isEmpty()){
cFE.getControlGroup().setType(ControlGroupType.ERROR);
//cg_parameters_control.setType(ControlGroupType.ERROR);
setError(true, "You must type a valid key parameter!");
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);
}
/**
* Gets the task id.
*
* @return the task id
*/
public String getTaskId(){
String taskId = field_select_task_id.getSelectedValue();
GWT.log("Selected task Id: "+taskId);
return taskId;
}
/**
* Gets the parameters.
*
* @return the parameters
*/
public List<TaskParameter> getParameters(){
List<TaskParameter> listParameters = new ArrayList<TaskParameter>();
for (CustomFieldEntry cFE : customFieldEntriesList) {
TaskParameter tp = new TaskParameter(cFE.getKey(), cFE.getValue(), null, new TaskParameterType(cFE.getType()));
listParameters.add(tp);
}
return listParameters;
}
/**
* Gets the description.
*
* @return the description
*/
public String getDescription(){
return field_task_description.getValue();
}
/**
* @return the isEditConfiguration
*/
public boolean isEditConfiguration() {
return isEditConfiguration;
}
/**
* @return the editConfiguration
*/
public TaskConfiguration getEditConfiguration() {
return editConfiguration;
}
}

View File

@ -6,6 +6,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.gcube.common.workspacetaskexecutor.shared.FilterOperator;
import org.gcube.common.workspacetaskexecutor.shared.TaskOperator;
import org.gcube.common.workspacetaskexecutor.shared.TaskParameter;
import org.gcube.common.workspacetaskexecutor.shared.TaskParameterType;
@ -17,6 +18,7 @@ import org.gcube.portlets.widgets.wstaskexecutor.client.event.DeleteCustomFieldE
import org.gcube.portlets.widgets.wstaskexecutor.client.event.ShowListOfTaskConfigurationsEvent;
import org.gcube.portlets.widgets.wstaskexecutor.client.view.LoaderIcon;
import org.gcube.portlets.widgets.wstaskexecutor.shared.GcubeScope;
import org.gcube.portlets.widgets.wstaskexecutor.shared.SelectableOperator;
import org.gcube.portlets.widgets.wstaskexecutor.shared.WSItem;
import com.github.gwtbootstrap.client.ui.Button;
@ -124,6 +126,9 @@ public abstract class CreateTaskConfigurationView extends Composite {
private TaskConfiguration editConfiguration;
private SelectableOperator selectableOperators;
/**
* Submit handler.
*/
@ -162,8 +167,9 @@ public abstract class CreateTaskConfigurationView extends Composite {
* @param wsItem the folder
* @param conf the conf
*/
public CreateTaskConfigurationView(final WSItem wsItem, TaskConfiguration conf) {
public CreateTaskConfigurationView(final WSItem wsItem, TaskConfiguration conf, SelectableOperator selectableOperators) {
this.wsItem = wsItem;
this.selectableOperators = selectableOperators;
if(conf!=null)
this.isEditConfiguration = true;
@ -293,7 +299,20 @@ public abstract class CreateTaskConfigurationView extends Composite {
loaderBox.getElement().getStyle().setZIndex(Integer.MAX_VALUE-5000);
pager.getRight().setVisible(false);
WsTaskExecutorWidget.wsTaskService.getListOperatorsPerScope(selScope.getScopeName(), new AsyncCallback<List<TaskOperator>>() {
String[] filterForParameterNames = null;
FilterOperator filterOperator = null;
// if(!wsItem.isFolder()){
// //is file gets only algorithm having FILE as parameter
// filterForParameterNames = new String[2];
// filterForParameterNames[0] = "FILE";
// }
// filterForParameterNames = new String[2];
// filterForParameterNames[0] = "FILE";
// filterForParameterNames[1] = "TABULAR";
WsTaskExecutorWidget.wsTaskService.getListOperatorsPerScope(selScope.getScopeName(), selectableOperators, new AsyncCallback<List<TaskOperator>>() {
@Override
public void onFailure(Throwable caught) {

View File

@ -8,10 +8,11 @@ import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
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.FilterOperator;
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.WSItemObject;
import org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskComputation;
import org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskConfiguration;
import org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskExecutionStatus;
@ -25,6 +26,8 @@ import org.gcube.portlets.widgets.wstaskexecutor.client.rpc.WsTaskExecutorWidget
import org.gcube.portlets.widgets.wstaskexecutor.server.util.PortalContextUtil;
import org.gcube.portlets.widgets.wstaskexecutor.shared.GcubeScope;
import org.gcube.portlets.widgets.wstaskexecutor.shared.GcubeScopeType;
import org.gcube.portlets.widgets.wstaskexecutor.shared.SelectableOperator;
import org.gcube.portlets.widgets.wstaskexecutor.shared.WSItem;
import org.gcube.vomanagement.usermanagement.GroupManager;
import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault;
import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException;
@ -170,6 +173,7 @@ public class WsTaskExecutorWidgetServiceImpl extends RemoteServiceServlet implem
return listOfScopes;
}
/**
* Check item task configurations.
*
@ -322,15 +326,17 @@ public class WsTaskExecutorWidgetServiceImpl extends RemoteServiceServlet implem
/**
* Gets the list operators per scope.
*
* @param scope the scope
* @param selectableOperators the selectable operators
* @return the list operators per scope
* @throws Exception the exception
*/
@Override
public List<TaskOperator> getListOperatorsPerScope(String scope) throws Exception{
public List<TaskOperator> getListOperatorsPerScope(String scope, SelectableOperator selectableOperators) throws Exception{
if(scope==null || scope.isEmpty())
throw new Exception("Invalid scope null");
@ -339,23 +345,34 @@ public class WsTaskExecutorWidgetServiceImpl extends RemoteServiceServlet implem
String originalScope = ScopeProvider.instance.get();
String originalToken = SecurityTokenProvider.instance.get();
String[] filterForParameterTypes = null;
FilterOperator filterOperator = null;
if(selectableOperators!=null){
filterForParameterTypes = selectableOperators.getFilterForParameterTypes();
filterOperator = selectableOperators.getFilterOperator();
}
try{
GCubeUser user = PortalContextUtil.getUserLogged(this.getThreadLocalRequest());
String token = PortalContextUtil.getTokenFor(scope, user.getUsername());
ScopeProvider.instance.set(scope);
SecurityTokenProvider.instance.set(token);
List<TaskOperator> operators = exec.getListOperators();
List<TaskOperator> operators = exec.getListOperators(filterForParameterTypes, filterOperator);
if(logger.isDebugEnabled()){
//JUST A DEBUG LOG
/*if(logger.isDebugEnabled()){
//APPLYING FILTERS ON PARAMETER NAME/TYPE
for (TaskOperator taskOperator : operators) {
logger.trace("***Algor: "+taskOperator.getName());
List<TaskParameter> io = taskOperator.getInputOperators();
for (TaskParameter taskParameter : io) {
logger.trace("key: "+taskParameter.getKey() + ", value: "+taskParameter.getValue() +", defaultValue: "+taskParameter.getDefaultValue());
}
}
}
}*/
logger.info("Returning "+operators.size()+ " operator/s for the scope: "+scope);
return operators;
@ -371,4 +388,26 @@ public class WsTaskExecutorWidgetServiceImpl extends RemoteServiceServlet implem
}
}
/**
* Load item.
*
* @param itemId the item id
* @return the WS item
* @throws Exception the exception
*/
@Override
public WSItem loadItem(String itemId) throws Exception{
WorkspaceDataMinerTaskExecutor exec = getTaskExecutor();
try{
WSItemObject wsIO = exec.loadItem(itemId);
return new WSItem(wsIO.getItemId(), wsIO.getItemName(), wsIO.getOwner(), wsIO.getPublicLink(), wsIO.isFolder());
}catch(Exception e){
throw new Exception(e);
}
}
}

View File

@ -0,0 +1,116 @@
/**
*
*/
package org.gcube.portlets.widgets.wstaskexecutor.shared;
import java.io.Serializable;
import java.util.Arrays;
import org.gcube.common.workspacetaskexecutor.shared.FilterOperator;
import org.gcube.common.workspacetaskexecutor.shared.TaskOperator;
/**
* The Class SelectableOperator.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Jun 12, 2018
*/
public class SelectableOperator implements Serializable{
/**
*
*/
private static final long serialVersionUID = -736347344123058207L;
private String[] filterForParameterTypes;
private FilterOperator filterOperator;
/**
* Instantiates a new selectable operator.
*/
public SelectableOperator() {
}
/**
* Instantiates a new selectable operator.
*
* @param filterForParameterTypes the filter for parameter types. It returns only {@link TaskOperator} matching the input filters
* @param filterOperator the filter operator
*/
public SelectableOperator(
String[] filterForParameterTypes, FilterOperator filterOperator) {
super();
this.filterForParameterTypes = filterForParameterTypes;
this.filterOperator = filterOperator;
}
/**
* Gets the filter for parameter types.
*
* @return the filterForParameterTypes
*/
public String[] getFilterForParameterTypes() {
return filterForParameterTypes;
}
/**
* Gets the filter operator.
*
* @return the filterOperator
*/
public FilterOperator getFilterOperator() {
return filterOperator;
}
/**
* Sets the filter for parameter types.
*
* @param filterForParameterTypes the filterForParameterTypes to set
*/
public void setFilterForParameterTypes(String[] filterForParameterTypes) {
this.filterForParameterTypes = filterForParameterTypes;
}
/**
* Sets the filter operator.
*
* @param filterOperator the filterOperator to set
*/
public void setFilterOperator(FilterOperator filterOperator) {
this.filterOperator = filterOperator;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("SelectableOperator [filterForParameterTypes=");
builder.append(Arrays.toString(filterForParameterTypes));
builder.append(", filterOperator=");
builder.append(filterOperator);
builder.append("]");
return builder.toString();
}
}

View File

@ -5,21 +5,27 @@ import java.io.Serializable;
import com.google.gwt.user.client.rpc.IsSerializable;
/**
* The Class WSItem.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* May 9, 2018
* Jun 12, 2018
*/
public class WSItem implements Serializable, IsSerializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 5993446472545533536L;
private String itemId;
private String itemName;
private String owner;
private String publicLink;
private boolean isFolder;
/**
* Instantiates a new ws folder.
*/
@ -41,6 +47,28 @@ public class WSItem implements Serializable, IsSerializable {
this.itemName = itemName;
}
/**
* Instantiates a new WS item.
*
* @param itemId the item id
* @param itemName the item name
* @param owner the owner
* @param publicLink the public link
* @param isFolder the is folder
*/
public WSItem(
String itemId, String itemName, String owner, String publicLink,
boolean isFolder) {
super();
this.itemId = itemId;
this.itemName = itemName;
this.owner = owner;
this.publicLink = publicLink;
this.isFolder = isFolder;
}
/**
* Gets the item id.
*
@ -51,6 +79,7 @@ public class WSItem implements Serializable, IsSerializable {
return itemId;
}
/**
* Gets the item name.
*
@ -61,41 +90,114 @@ public class WSItem implements Serializable, IsSerializable {
return itemName;
}
/**
* Gets the owner.
*
* @return the owner
*/
public String getOwner() {
return owner;
}
/**
* Gets the public link.
*
* @return the publicLink
*/
public String getPublicLink() {
return publicLink;
}
/**
* Checks if is folder.
*
* @return the isFolder
*/
public boolean isFolder() {
return isFolder;
}
/**
* Sets the item id.
*
* @param itemId
* the itemId to set
* @param itemId the itemId to set
*/
public void setItemId(String itemId) {
this.itemId = itemId;
}
/**
* Sets the item name.
*
* @param itemName
* the itemName to set
* @param itemName the itemName to set
*/
public void setItemName(String itemName) {
this.itemName = itemName;
}
/*
* (non-Javadoc)
/**
* Sets the owner.
*
* @param owner the owner to set
*/
public void setOwner(String owner) {
this.owner = owner;
}
/**
* Sets the public link.
*
* @param publicLink the publicLink to set
*/
public void setPublicLink(String publicLink) {
this.publicLink = publicLink;
}
/**
* Sets the folder.
*
* @param isFolder the isFolder to set
*/
public void setFolder(boolean isFolder) {
this.isFolder = isFolder;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("WorkspaceFile [itemId=");
builder.append("WSItem [itemId=");
builder.append(itemId);
builder.append(", itemName=");
builder.append(itemName);
builder.append(", owner=");
builder.append(owner);
builder.append(", publicLink=");
builder.append(publicLink);
builder.append(", isFolder=");
builder.append(isFolder);
builder.append("]");
return builder.toString();
}
}