enhancement

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/widgets/ws-task-executor-widget@167380 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2018-05-09 10:36:54 +00:00
parent 52678a65b9
commit a04c1dfd0d
12 changed files with 350 additions and 81 deletions

View File

@ -8,6 +8,8 @@ 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.event.CreateTaskConfigurationEvent;
import org.gcube.portlets.widgets.wstaskexecutor.client.event.CreateTaskConfigurationEventHandler;
import org.gcube.portlets.widgets.wstaskexecutor.client.event.PerformRunTaskEvent;
import org.gcube.portlets.widgets.wstaskexecutor.client.event.PerformRunTaskEventHandler;
import org.gcube.portlets.widgets.wstaskexecutor.client.rpc.WsTaskExecutorWidgetServiceAsync;
@ -84,6 +86,39 @@ public class WsTaskExecutorWidget {
}
});
eventBus.addHandler(CreateTaskConfigurationEvent.TYPE, new CreateTaskConfigurationEventHandler() {
@Override
public void onCreateConfiguration(
final CreateTaskConfigurationEvent createTCE) {
if(createTCE.getFolder()!=null && createTCE.getConf()!=null){
WsTaskExecutorWidget.wsTaskService.createTaskConfiguration(createTCE.getFolder().getFolderId(), createTCE.getConf(), createTCE.isUpdate(), new AsyncCallback<Boolean>() {
@Override
public void onFailure(Throwable caught) {
Window.alert(caught.getMessage());
}
@Override
public void onSuccess(Boolean result) {
try {
showTaskConfigurationsForFolder(createTCE.getFolder());
}
catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
}
}
});
}

View File

@ -0,0 +1,86 @@
/*
*
*/
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;
/**
* The Class CreateTaskConfigurationEvent.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* May 9, 2018
*/
public class CreateTaskConfigurationEvent extends GwtEvent<CreateTaskConfigurationEventHandler> {
/** The type. */
public static Type<CreateTaskConfigurationEventHandler> TYPE = new Type<CreateTaskConfigurationEventHandler>();
private TaskConfiguration conf;
private WsFolder folder;
private boolean isUpdate;
/**
* Instantiates a new creates the task configuration event.
*
* @param folder the folder
* @param conf the conf
* @param isUpdate the is update
*/
public CreateTaskConfigurationEvent(WsFolder folder, TaskConfiguration conf, boolean isUpdate) {
this.folder = folder;
this.conf = conf;
this.isUpdate = isUpdate;
}
/* (non-Javadoc)
* @see com.google.gwt.event.shared.GwtEvent#getAssociatedType()
*/
@Override
public Type<CreateTaskConfigurationEventHandler> getAssociatedType() {
return TYPE;
}
/* (non-Javadoc)
* @see com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared.EventHandler)
*/
@Override
protected void dispatch(CreateTaskConfigurationEventHandler handler) {
handler.onCreateConfiguration(this);
}
/**
* @return the isUpdate
*/
public boolean isUpdate() {
return isUpdate;
}
/**
* Gets the conf.
*
* @return the conf
*/
public TaskConfiguration getConf() {
return conf;
}
/**
* Gets the folder.
*
* @return the folder
*/
public WsFolder getFolder() {
return folder;
}
}

View File

@ -0,0 +1,19 @@
package org.gcube.portlets.widgets.wstaskexecutor.client.event;
import com.google.gwt.event.shared.EventHandler;
/**
* The Interface CreateTaskConfigurationEventHandler.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* May 9, 2018
*/
public interface CreateTaskConfigurationEventHandler extends EventHandler {
/**
* @param createTaskConfigurationEvent
*/
void onCreateConfiguration(
CreateTaskConfigurationEvent createTaskConfigurationEvent);
}

View File

@ -60,4 +60,23 @@ public interface WsTaskExecutorWidgetService extends RemoteService {
* @throws Exception the exception
*/
List<TaskParameterType> getAvailableParameterTypes() throws Exception;
/**
* @param itemId
* @param taskConfiguration
* @param isUpdate
* @return
* @throws Exception
*/
Boolean createTaskConfiguration(
String itemId, TaskConfiguration taskConfiguration, boolean isUpdate)
throws Exception;
/**
* @param itemId
* @return
* @throws Exception
*/
List<TaskConfiguration> getItemTaskConfigurations(String itemId)
throws Exception;
}

View File

@ -95,4 +95,25 @@ public interface WsTaskExecutorWidgetServiceAsync {
* @return the available parameter types
*/
void getAvailableParameterTypes(AsyncCallback<List<TaskParameterType>> asyncCallback);
/**
* Creates the task configuration.
*
* @param itemId the item id
* @param taskConfiguration the task configuration
* @param isUpdate the is update
* @param asyncCallback the async callback
*/
void createTaskConfiguration(
String itemId, TaskConfiguration taskConfiguration, boolean isUpdate, AsyncCallback<Boolean> asyncCallback);
/**
* Gets the item task configurations.
*
* @param itemId the item id
* @param asyncCallback the async callback
* @return the item task configurations
*/
void getItemTaskConfigurations(String itemId, AsyncCallback<List<TaskConfiguration>> asyncCallback);
}

View File

@ -244,8 +244,10 @@ public class WsTaskExecutorWidgetViewManager {
public void showCreateTaskConfigurationForFolder(final WsFolder folder, TaskConfiguration conf){
final Modal box = new Modal(true);
box.setWidth(AbstractViewDialogBox.DEFAULT_WIDTH+20+"px");
//box.setWidth(AbstractViewDialogBox.DEFAULT_WIDTH+20+"px");
box.setTitle("Create Task Configuration for: "+FormatUtil.getFolderTitle(folder.getFoderName(), 20));
box.addStyleName("ws-task-modal-body");
box.setWidth(AbstractViewDialogBox.DEFAULT_WIDTH+50);
//box.getElement().getStyle().setZIndex(10000);
final AbstractViewDialogBox panelView = new AbstractViewDialogBox() {

View File

@ -34,6 +34,7 @@ import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
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;
@ -88,6 +89,9 @@ public abstract class CreateTaskConfigurationView extends Composite {
@UiField
Button addCustomFieldButton;
@UiField
HTMLPanel html_panel_field;
/** The map VR es. */
private Map<String, GcubeScope> mapScopes = new HashMap<String, GcubeScope>();
@ -193,7 +197,7 @@ public abstract class CreateTaskConfigurationView extends Composite {
if(folder.getPublicLink()!=null){
customFieldEntry = new CustomFieldEntry(eventBus, "publicLink", folder.getPublicLink(), "FILE");
customFieldEntriesList.add(customFieldEntry);
task_parameters_control.add(customFieldEntry);
cg_parameters_control.add(customFieldEntry);
}else
addCustomFieldEvent(null);
@ -209,7 +213,7 @@ public abstract class CreateTaskConfigurationView extends Composite {
CustomFieldEntry toAdd = new CustomFieldEntry(eventBus, null, null, null);
customFieldEntriesList.add(toAdd);
task_parameters_control.add(toAdd);
cg_parameters_control.add(toAdd);
}
@ -224,7 +228,7 @@ public abstract class CreateTaskConfigurationView extends Composite {
@Override
public void onRemoveEntry(DeleteCustomFieldEvent event) {
customFieldEntriesList.remove(event.getRemovedEntry());
task_parameters_control.remove(event.getRemovedEntry());
cg_parameters_control.remove(event.getRemovedEntry());
}
});
@ -238,7 +242,7 @@ public abstract class CreateTaskConfigurationView extends Composite {
*/
protected boolean validateSubmit() {
cg_input_task_id.setType(ControlGroupType.NONE);
cg_parameters_control.setType(ControlGroupType.NONE);
//cg_parameters_control.setType(ControlGroupType.NONE);
//cg_remote_path.setType(ControlGroupType.NONE);
if(field_select_scope.getSelectedItemText()==null){
@ -254,9 +258,11 @@ public abstract class CreateTaskConfigurationView extends Composite {
}
for (CustomFieldEntry cFE : customFieldEntriesList) {
cFE.getControlGroup().setType(ControlGroupType.NONE);
if(cFE.getKey()==null || cFE.getKey().isEmpty()){
cg_parameters_control.setType(ControlGroupType.ERROR);
setError(true, "You must type a valid key paramter!");
cFE.getControlGroup().setType(ControlGroupType.ERROR);
//cg_parameters_control.setType(ControlGroupType.ERROR);
setError(true, "You must type a valid key parameter!");
return false;
}
}

View File

@ -7,7 +7,7 @@
}
</ui:style>
<g:HTMLPanel>
<g:HTMLPanel>
<g:HTMLPanel ui:field="html_panel_field">
<b:Form type="HORIZONTAL">
<b:Fieldset styleName="{style.noBorder}" ui:field="form_unit_fields">
@ -15,7 +15,7 @@
<b:ControlLabel for="cl_select_vre">Execute in the Scope</b:ControlLabel>
<b:Controls>
<b:ListBox name="Select a VRE..." b:id="field_select_scope"
ui:field="field_select_scope">
ui:field="field_select_scope" addStyleNames="my-external-select-width">
</b:ListBox>
</b:Controls>
</b:ControlGroup>
@ -25,7 +25,7 @@
<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"></b:TextBox>
ui:field="field_task_id" addStyleNames="my-external-input-width"></b:TextBox>
</b:Controls>
</b:ControlGroup>
<b:ControlGroup ui:field="cg_parameters_control">
@ -40,7 +40,7 @@
</b:Fieldset>
</b:Form>
</g:HTMLPanel>
<b:Pager left="Older" right="Create Configuration and Do Sync"
<b:Pager left="Older" right="Create Configuration"
aligned="true" ui:field="pager" />
</g:HTMLPanel>
</ui:UiBinder>

View File

@ -7,15 +7,18 @@ import org.gcube.portlets.widgets.wstaskexecutor.client.WsTaskExecutorWidget;
import org.gcube.portlets.widgets.wstaskexecutor.client.event.DeleteCustomFieldEvent;
import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.ControlGroup;
import com.github.gwtbootstrap.client.ui.InputAddOn;
import com.github.gwtbootstrap.client.ui.ListBox;
import com.github.gwtbootstrap.client.ui.TextBox;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.ClickEvent;
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.Random;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Composite;
@ -47,6 +50,7 @@ public class CustomFieldEntry extends Composite {
@UiField InputAddOn valueFieldPrepend;
@UiField Button removeCustomField;
@UiField ListBox field_select_parameter;
@UiField ControlGroup cg_parameter;
private List<TaskParameterType> parameterTypes;
@ -59,6 +63,7 @@ public class CustomFieldEntry extends Composite {
private HandlerManager eventBus;
private String parameterType;
/**
* Instantiates a new custom field entry.
*
@ -69,6 +74,9 @@ public class CustomFieldEntry extends Composite {
*/
public CustomFieldEntry(HandlerManager eventBus, String key, String value, final String parameterType) {
initWidget(uiBinder.createAndBindUi(this));
this.getElement().getStyle().setMarginTop(10, Unit.PX);
this.getElement().getStyle().setMarginBottom(20, Unit.PX);
cg_parameter.getElement().setId(Random.nextInt()+Random.nextInt()+"");
keyFieldPrepend.setTitle("This is the key of the parameter");
valueFieldPrepend.setTitle("This is the value of the parameter");
@ -130,6 +138,14 @@ public class CustomFieldEntry extends Composite {
}
/**
* @return the cg_parameter
*/
public ControlGroup getControlGroup() {
return cg_parameter;
}
/**
* Retrieve the key value.
*

View File

@ -1,23 +1,32 @@
<!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">
<b:ControlGroup>
<b:ControlLabel>Parameter</b:ControlLabel>
<b:Controls>
<b:InputAddOn prependText="Type:">
<b:ListBox name="Select the Type of Parameter..." b:id="field_select_parameter"
ui:field="field_select_parameter">
</b:ListBox>
</b:InputAddOn>
</b:Controls>
<b:Controls>
<b:InputAddOn prependText="Key:" ui:field="keyFieldPrepend">
<b:TextBox />
</b:InputAddOn>
<b:InputAddOn prependText="Value:" ui:field="valueFieldPrepend">
<b:TextBox />
</b:InputAddOn>
<b:Button icon="REMOVE_SIGN" title="Remove field" ui:field="removeCustomField"></b:Button>
</b:Controls>
</b:ControlGroup>
<g:HTMLPanel>
<b:ControlGroup ui:field="cg_parameter">
<b:ControlLabel>Parameter</b:ControlLabel>
<b:Controls>
<b:InputAddOn prependText="Type:" addStyleNames="my-prepend-width">
<b:ListBox name="Select the Type of Parameter..." b:id="field_select_parameter"
ui:field="field_select_parameter" addStyleNames="my-select-width">
</b:ListBox>
</b:InputAddOn>
</b:Controls>
<b:Controls>
<b:InputAddOn prependText="Key:" ui:field="keyFieldPrepend"
addStyleNames="my-prepend-width">
<b:TextBox addStyleNames="my-input-width" />
</b:InputAddOn>
</b:Controls>
<b:Controls>
<b:InputAddOn addStyleNames="my-prepend-width"
prependText="Value:" ui:field="valueFieldPrepend">
<b:TextBox addStyleNames="my-input-width" />
</b:InputAddOn>
</b:Controls>
<b:Controls>
<b:Button icon="REMOVE_SIGN" title="Remove Parameter" text="Remove Parameter"
ui:field="removeCustomField"></b:Button>
</b:Controls>
</b:ControlGroup>
</g:HTMLPanel>
</ui:UiBinder>

View File

@ -1,9 +1,11 @@
/** Add css rules here for your application. */
.ws-thredds-modal-body div.modal-body {
.ws-task-modal-body div.modal-body {
position: relative;
max-height: 600px !important;
max-height: 650px !important;
padding: 15px;
overflow-y: auto;
width: 800px;
margin: 0 auto;
}
.textAreaWidth {
@ -23,8 +25,27 @@
width: 750px !important;
}
.myLittleMarginLeft{
.myLittleMarginLeft {
margin-left: 25px !important;
}
.my-input-width {
width: 300px !important;
}
.my-prepend-width .add-on {
width: 50px !important;
margin-bottom: 5px !important;
}
.my-select-width {
width: 312px !important;
}
.my-external-select-width {
width: 370px !important;
}
.my-external-input-width {
width: 360px !important;
}

View File

@ -59,6 +59,27 @@ public class WsTaskExecutorWidgetServiceImpl extends RemoteServiceServlet implem
}
}
/**
* Sets the masked token.
*
* @param taskConfiguration the task configuration
* @return the task configuration
* @throws Exception the exception
*/
private TaskConfiguration setMaskedToken(TaskConfiguration taskConfiguration) throws Exception{
String scope = taskConfiguration.getScope();
if(scope==null)
throw new Exception("Missing scope in the input configuration. Set it and try again");
GCubeUser user = PortalContextUtil.getUserLogged(this.getThreadLocalRequest());
String token = PortalContextUtil.getTokenFor(scope, user.getUsername());
taskConfiguration.setMaskedToken(EncrypterUtil.encryptString(token));
return taskConfiguration;
}
/**
* Gets the task executor.
*
@ -96,9 +117,9 @@ public class WsTaskExecutorWidgetServiceImpl extends RemoteServiceServlet implem
if (!isWithinPortal()){
listOfScopes.add(new GcubeScope("devVRE", "/gcube/devsec/devVRE", GcubeScopeType.VRE));
listOfScopes.add(new GcubeScope("NextNext", "/gcube/devNext/NextNext", GcubeScopeType.VRE));
listOfScopes.add(new GcubeScope("devNext", "/gcube/devNext", GcubeScopeType.VO));
listOfScopes.add(new GcubeScope("devsec", "/gcube/devsec", GcubeScopeType.VO));
listOfScopes.add(new GcubeScope("gcube", "/gcube", GcubeScopeType.ROOT));
// listOfScopes.add(new GcubeScope("devNext", "/gcube/devNext", GcubeScopeType.VO));
// listOfScopes.add(new GcubeScope("devsec", "/gcube/devsec", GcubeScopeType.VO));
// listOfScopes.add(new GcubeScope("gcube", "/gcube", GcubeScopeType.ROOT));
Collections.sort(listOfScopes);
return listOfScopes;
}
@ -142,33 +163,12 @@ public class WsTaskExecutorWidgetServiceImpl extends RemoteServiceServlet implem
return listOfScopes;
}
/**
* Creates the task configuration.
*
* @param workspaceItemId the workspace item id
* @param taskConfiguration the task configuration
* @return the task configuration
* @throws Exception the exception
*/
public TaskConfiguration createTaskConfiguration(String workspaceItemId, TaskConfiguration taskConfiguration) throws Exception{
WorkspaceDataMinerTaskExecutor exec = getTaskExecutor();
taskConfiguration = setMaskedToken(taskConfiguration);
exec.setTaskConfiguration(taskConfiguration);
return taskConfiguration;
}
/**
* Check item task configurations.
*
* @param itemId the item id
* @return the list
* @throws Exception
* @throws Exception the exception
*/
@Override
public List<TaskConfiguration> checkItemTaskConfigurations(String itemId) throws Exception {
@ -197,27 +197,6 @@ public class WsTaskExecutorWidgetServiceImpl extends RemoteServiceServlet implem
}
/**
* Sets the masked token.
*
* @param taskConfiguration the task configuration
* @return the task configuration
* @throws Exception the exception
*/
private TaskConfiguration setMaskedToken(TaskConfiguration taskConfiguration) throws Exception{
String scope = taskConfiguration.getScope();
if(scope==null)
throw new Exception("Missing scope in the input configuration. Set it and try again");
GCubeUser user = PortalContextUtil.getUserLogged(this.getThreadLocalRequest());
String token = PortalContextUtil.getTokenFor(scope, user.getUsername());
taskConfiguration.setMaskedToken(EncrypterUtil.encryptString(token));
return taskConfiguration;
}
/* (non-Javadoc)
* @see org.gcube.portlets.widgets.wstaskexecutor.client.rpc.WsTaskExecutorWidgetService#getAvailablesParameterTypes()
*/
@ -241,4 +220,60 @@ public class WsTaskExecutorWidgetServiceImpl extends RemoteServiceServlet implem
return null;
}
/**
* Creates the task configuration.
*
* @param itemId the item id
* @param taskConfiguration the task configuration
* @param isUpdate the is update
* @return true, if successful
* @throws Exception the exception
*/
@Override
public Boolean createTaskConfiguration(String itemId, TaskConfiguration taskConfiguration, boolean isUpdate) throws Exception{
WorkspaceDataMinerTaskExecutor exec = getTaskExecutor();
try {
GCubeUser user = PortalContextUtil.getUserLogged(this.getThreadLocalRequest());
taskConfiguration.setOwner(user.getUsername());
taskConfiguration = setMaskedToken(taskConfiguration);
exec.setTaskConfiguration(taskConfiguration);
return true;
}
catch (Exception e) {
logger.error("Error on creating the TaskConfiguration for itemId: "+itemId,e);
throw new Exception("Sorry, an rrror occurred during creating the configuration for itemId: "+itemId+ ". Refresh and try again later");
}
}
/* (non-Javadoc)
* @see org.gcube.portlets.widgets.wstaskexecutor.client.rpc.WsTaskExecutorWidgetService#getItemTaskConfigurations(java.lang.String)
*/
@Override
public List<TaskConfiguration> getItemTaskConfigurations(String itemId) throws Exception{
logger.debug("Getting Task Configurations for item: "+itemId);
WorkspaceDataMinerTaskExecutor exec = getTaskExecutor();
List<TaskConfiguration> confs = null;
try {
confs = exec.getListOfTaskConfigurations(itemId);
}
catch (ItemNotConfiguredException e){
String msg = "No TaskConfiguration found for itemId: "+itemId+", retuning null";
logger.info(msg);
throw e;
}catch (WorkspaceFolderLocked e) {
logger.info(e.getMessage());
throw e;
}catch (Exception e) {
logger.error("Error on getting TaskConfigurations for itemId: "+itemId,e);
throw new Exception("Error occurred during loading Task Configurations for id: "+itemId+ ". Refresh and try again later");
}
logger.debug("Returning configurations: "+confs);
return confs;
}
}