diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/CommonMessages.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/CommonMessages.java new file mode 100644 index 0000000..7a70b4a --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/CommonMessages.java @@ -0,0 +1,24 @@ +package org.gcube.portlets.user.statisticalalgorithmsimporter.client; + +import com.google.gwt.i18n.client.Messages; + +/** + * + * @author giancarlo email: g.panichi@isti.cnr.it + * + */ +public interface CommonMessages extends Messages { + + // + @DefaultMessage("Attention") + String attention(); + + @DefaultMessage("Error") + String error(); + + @DefaultMessage("No Main Code set!") + String attentionNoMainCodeSet(); + + +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/StatAlgoImporterController.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/StatAlgoImporterController.java index 012caa4..e02bd58 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/StatAlgoImporterController.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/StatAlgoImporterController.java @@ -6,6 +6,7 @@ import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.Delete import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.InputReadyEvent; import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.InputRequestEvent; import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.MainCodeSetEvent; +import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.NewMainCodeEvent; import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.SessionExpiredEvent; import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.StatAlgoImporterRibbonEvent; import org.gcube.portlets.user.statisticalalgorithmsimporter.client.monitor.StatAlgoImporterMonitor; @@ -46,12 +47,11 @@ public class StatAlgoImporterController { private StatAlgoImporterMonitor monitor; private enum InputRequestType { - Save, - SoftwareCreate; + Save, SoftwareCreate; } + private InputRequestType inputRequestType; - - + public StatAlgoImporterController() { eventBus = new SimpleEventBus(); pm = new ProjectManager(eventBus); @@ -135,7 +135,7 @@ public class StatAlgoImporterController { String currentLocaleCookie = Cookies.getCookie(LocaleInfo .getLocaleCookieName()); - Log.debug(Constants.STATRUNNER_LANG_COOKIE + ":" + currentLocaleCookie); + Log.debug(Constants.STATISTICAL_ALGORITHMS_IMPORTER_COOKIE + ":" + currentLocaleCookie); LocaleInfo currentLocaleInfo = LocaleInfo.getCurrentLocale(); Log.debug("Current Locale:" + currentLocaleInfo.getLocaleName()); @@ -147,17 +147,23 @@ public class StatAlgoImporterController { long nowLong = now.getTime(); nowLong = nowLong + (1000 * 60 * 60 * 24 * 21); now.setTime(nowLong); - String cookieLang = Cookies.getCookie(Constants.STATRUNNER_LANG_COOKIE); + String cookieLang = Cookies.getCookie(Constants.STATISTICAL_ALGORITHMS_IMPORTER_COOKIE); if (cookieLang != null) { - Cookies.removeCookie(Constants.STATRUNNER_LANG_COOKIE); + Cookies.removeCookie(Constants.STATISTICAL_ALGORITHMS_IMPORTER_COOKIE); } - Cookies.setCookie(Constants.STATRUNNER_LANG_COOKIE, localeName, now); + Cookies.setCookie(Constants.STATISTICAL_ALGORITHMS_IMPORTER_COOKIE, localeName, now); com.google.gwt.user.client.Window.Location.reload(); } // public void restoreUISession() { checkLocale(); + + String value = com.google.gwt.user.client.Window.Location + .getParameter(Constants.STATISTICAL_ALGORITHMS_IMPORTER_ID); + + pm.startProjectManager(value); + } // Bind Controller to events on bus @@ -218,6 +224,19 @@ public class StatAlgoImporterController { } }); + + eventBus.addHandler(NewMainCodeEvent.TYPE, + new NewMainCodeEvent.NewMainCodeEventHandler() { + + @Override + public void onSet(NewMainCodeEvent event) { + Log.debug("Catch SaveNewMainCodeEvent"); + doSetNewMainCodeEvent(event); + + } + + + }); pm.startProjectManager(); @@ -255,38 +274,39 @@ public class StatAlgoImporterController { } private void doInputReadyCommand(InputReadyEvent event) { - switch(inputRequestType){ + switch (inputRequestType) { case Save: pm.saveProject(event.getInputData(), monitor); break; case SoftwareCreate: pm.createSofware(event.getInputData(), monitor); - break; + break; default: break; - + } - + } - + private void projectSaveRequest() { - monitor= new StatAlgoImporterMonitor(); - inputRequestType=InputRequestType.Save; + monitor = new StatAlgoImporterMonitor(); + inputRequestType = InputRequestType.Save; InputRequestEvent inputRequestEvent = new InputRequestEvent(); eventBus.fireEvent(inputRequestEvent); Log.debug("ProjectSaveRequest: " + inputRequestEvent); } - + private void softwareCreateRequest() { - monitor= new StatAlgoImporterMonitor(); - inputRequestType=InputRequestType.SoftwareCreate; + monitor = new StatAlgoImporterMonitor(); + inputRequestType = InputRequestType.SoftwareCreate; InputRequestEvent inputRequestEvent = new InputRequestEvent(); eventBus.fireEvent(inputRequestEvent); Log.debug("SoftwareCreateRequest: " + inputRequestEvent); - } - + + + private void showCreateProjectDialog() { pm.createProject(); @@ -300,9 +320,7 @@ public class StatAlgoImporterController { private void showAddResourceDialog() { pm.addResource(); } - - - + private void doMainCodeSetCommand(MainCodeSetEvent event) { ItemDescription itemDescription = event.getItemDescription(); if (itemDescription != null && itemDescription.getId() != null) { @@ -310,6 +328,14 @@ public class StatAlgoImporterController { } } + + private void doSetNewMainCodeEvent( + NewMainCodeEvent event) { + monitor = new StatAlgoImporterMonitor(); + pm.setNewMainCode(event,monitor); + + } + private void doDeleteItemCommand(DeleteItemEvent event) { ItemDescription itemDescription = event.getItemDescription(); @@ -319,9 +345,6 @@ public class StatAlgoImporterController { } - - - @SuppressWarnings("unused") private void showCodeUploadDialog() { CodeUploadDialog codeUploadDialog = new CodeUploadDialog(eventBus); diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/codeparser/CodeParser.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/codeparser/CodeParser.java index 3c5b567..9bba1c6 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/codeparser/CodeParser.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/codeparser/CodeParser.java @@ -2,7 +2,7 @@ package org.gcube.portlets.user.statisticalalgorithmsimporter.client.codeparser; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.DataType; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.IOType; -import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.SelectedRowsVariables; +import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.InputOutputVariables; import com.allen_sauer.gwt.log.client.Log; import com.google.gwt.regexp.shared.RegExp; @@ -24,8 +24,8 @@ public class CodeParser { } - public SelectedRowsVariables parse(String parameter, IOType ioType) { - SelectedRowsVariables selectedRowsVariables = null; + public InputOutputVariables parse(String parameter, IOType ioType) { + InputOutputVariables selectedRowsVariables = null; if (parameter == null) { return null; @@ -40,7 +40,7 @@ public class CodeParser { defaultValue = defaultValue.substring(0, defaultValue.length() - 1); - selectedRowsVariables = new SelectedRowsVariables( + selectedRowsVariables = new InputOutputVariables( varDescription[0].trim(), varDescription[0].trim(), defaultValue, checkDataType(varDescription[1].trim()), ioType, parameter); @@ -53,7 +53,7 @@ public class CodeParser { if (defaultValue.endsWith("\"")) defaultValue = defaultValue.substring(0, defaultValue.length() - 1); - selectedRowsVariables = new SelectedRowsVariables( + selectedRowsVariables = new InputOutputVariables( varDescription[0].trim(), varDescription[0].trim(), defaultValue, checkDataType(varDescription[1].trim()), ioType, parameter); diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/event/NewMainCodeEvent.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/event/NewMainCodeEvent.java new file mode 100644 index 0000000..3a40295 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/event/NewMainCodeEvent.java @@ -0,0 +1,73 @@ +package org.gcube.portlets.user.statisticalalgorithmsimporter.client.event; + +import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.workspace.ItemDescription; + +import com.google.gwt.event.shared.EventHandler; +import com.google.gwt.event.shared.GwtEvent; +import com.google.gwt.event.shared.HandlerRegistration; +import com.google.gwt.event.shared.HasHandlers; + +/** + * Main Code Set Event + * + * + * @author "Giancarlo Panichi" g.panichi@isti.cnr.it + * + */ +public class NewMainCodeEvent extends + GwtEvent { + + public static Type TYPE = new Type(); + private ItemDescription file; + private String code; + + public interface NewMainCodeEventHandler extends EventHandler { + void onSet(NewMainCodeEvent event); + } + + public interface HasSaveNewMainCodeEventHandler extends HasHandlers { + public HandlerRegistration addSaveNewMainCodeEventHandler( + NewMainCodeEventHandler handler); + } + + public NewMainCodeEvent(ItemDescription file, String code) { + this.file = file; + this.code = code; + } + + @Override + protected void dispatch(NewMainCodeEventHandler handler) { + handler.onSet(this); + } + + @Override + public Type getAssociatedType() { + return TYPE; + } + + public static Type getType() { + return TYPE; + } + + public static void fire(HasHandlers source, + NewMainCodeEvent saveNewMainCodeEvent) { + source.fireEvent(saveNewMainCodeEvent); + } + + public ItemDescription getFile() { + return file; + } + + public String getCode() { + return code; + } + + @Override + public String toString() { + return "NewMainCodeEvent [file=" + file + ", code=" + code + "]"; + } + + + +} diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/event/NewSelectedRowsVariableEvent.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/event/NewSelectedRowsVariableEvent.java index 961ae4a..d44c350 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/event/NewSelectedRowsVariableEvent.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/event/NewSelectedRowsVariableEvent.java @@ -1,6 +1,6 @@ package org.gcube.portlets.user.statisticalalgorithmsimporter.client.event; -import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.SelectedRowsVariables; +import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.InputOutputVariables; import com.google.gwt.event.shared.EventHandler; import com.google.gwt.event.shared.GwtEvent; @@ -20,7 +20,7 @@ public class NewSelectedRowsVariableEvent GwtEvent { public static Type TYPE = new Type(); - private SelectedRowsVariables selectedRowsVariable; + private InputOutputVariables selectedRowsVariable; public interface NewSelectedRowsVariableEventHandler extends EventHandler { void onNewVariable(NewSelectedRowsVariableEvent event); @@ -32,7 +32,7 @@ public class NewSelectedRowsVariableEvent } public NewSelectedRowsVariableEvent( - SelectedRowsVariables selectedRowsVariable) { + InputOutputVariables selectedRowsVariable) { this.selectedRowsVariable = selectedRowsVariable; } @@ -55,7 +55,7 @@ public class NewSelectedRowsVariableEvent source.fireEvent(newSelectedRowsVariableEvent); } - public SelectedRowsVariables getSelectedRowsVariable() { + public InputOutputVariables getSelectedRowsVariable() { return selectedRowsVariable; } diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/maindata/CodeEditMessages.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/maindata/CodeEditMessages.java new file mode 100644 index 0000000..512f456 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/maindata/CodeEditMessages.java @@ -0,0 +1,52 @@ +package org.gcube.portlets.user.statisticalalgorithmsimporter.client.maindata; + +import com.google.gwt.i18n.client.Messages; + +/** + * + * @author giancarlo email: g.panichi@isti.cnr.it + * + */ +public interface CodeEditMessages extends Messages { + + // + @DefaultMessage("Save") + String btnSaveText(); + + @DefaultMessage("Save") + String btnSaveToolTip(); + + @DefaultMessage("Input") + String btnAddInputText(); + + @DefaultMessage("Add input variable from code") + String btnAddInputToolTip(); + + @DefaultMessage("Output") + String btnAddOutputText(); + + @DefaultMessage("Add output variable from code") + String btnAddOutputToolTip(); + + @DefaultMessage("Code:") + String mainCodeFiledLabel(); + + @DefaultMessage("Select parameter in the code!") + String attentionSelectParameterInTheCode(); + + @DefaultMessage("No valid selected row, change selection and try again!") + String attentionNoValidSelectedRow(); + + @DefaultMessage("Code Saved") + String codeSavedHead(); + + @DefaultMessage("Code is saved!") + String codeSaved(); + + @DefaultMessage("Attention invalid file name for Main Code!") + String attentionInvalidFileNameForMainCode(); + + + +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/maindata/CodeEditPanel.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/maindata/CodeEditPanel.java index 3c8e22b..86454a8 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/maindata/CodeEditPanel.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/maindata/CodeEditPanel.java @@ -2,8 +2,10 @@ package org.gcube.portlets.user.statisticalalgorithmsimporter.client.maindata; import java.util.ArrayList; +import org.gcube.portlets.user.statisticalalgorithmsimporter.client.CommonMessages; import org.gcube.portlets.user.statisticalalgorithmsimporter.client.codeparser.CodeParser; import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.NewSelectedRowsVariableEvent; +import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.NewMainCodeEvent; import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.SessionExpiredEvent; import org.gcube.portlets.user.statisticalalgorithmsimporter.client.resource.StatAlgoImporterResources; import org.gcube.portlets.user.statisticalalgorithmsimporter.client.rpc.StatAlgoImporterServiceAsync; @@ -12,22 +14,31 @@ import org.gcube.portlets.user.statisticalalgorithmsimporter.client.utils.UtilsG import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.code.CodeData; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterSessionExpiredException; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.IOType; -import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.SelectedRowsVariables; +import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.InputOutputVariables; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Project; +import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.workspace.ItemDescription; import com.allen_sauer.gwt.log.client.Log; +import com.google.gwt.core.client.GWT; import com.google.gwt.event.shared.EventBus; import com.google.gwt.user.client.rpc.AsyncCallback; import com.sencha.gxt.cell.core.client.ButtonCell.ButtonScale; import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign; import com.sencha.gxt.core.client.util.Margins; import com.sencha.gxt.widget.core.client.ContentPanel; +import com.sencha.gxt.widget.core.client.Dialog.PredefinedButton; +import com.sencha.gxt.widget.core.client.box.PromptMessageBox; import com.sencha.gxt.widget.core.client.button.TextButton; import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutData; import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer; import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData; +import com.sencha.gxt.widget.core.client.event.DialogHideEvent; +import com.sencha.gxt.widget.core.client.event.DialogHideEvent.DialogHideHandler; import com.sencha.gxt.widget.core.client.event.SelectEvent; import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler; +import com.sencha.gxt.widget.core.client.form.TextField; +import com.sencha.gxt.widget.core.client.toolbar.LabelToolItem; +import com.sencha.gxt.widget.core.client.toolbar.SeparatorToolItem; import com.sencha.gxt.widget.core.client.toolbar.ToolBar; import edu.ycp.cs.dh.acegwt.client.ace.AceEditor; @@ -51,15 +62,20 @@ public class CodeEditPanel extends ContentPanel { private TextButton btnSave; private TextButton btnAddInput; private TextButton btnAddOutput; + private Project project; + private TextField mainCodeField; + private CodeEditMessages msgs; + private CommonMessages msgsCommon; public CodeEditPanel(Project project, EventBus eventBus) { super(); Log.debug("CodeEditPanel"); this.eventBus = eventBus; - - // msgs = GWT.create(ServiceCategoryMessages.class); + this.project = project; + this.msgs = GWT.create(CodeEditMessages.class); + this.msgsCommon = GWT.create(CommonMessages.class); init(); - create(project); + create(); } @@ -72,12 +88,12 @@ public class CodeEditPanel extends ContentPanel { } - private void create(Project project) { - btnSave = new TextButton("Save"); + private void create() { + btnSave = new TextButton(msgs.btnSaveText()); btnSave.setIcon(StatAlgoImporterResources.INSTANCE.save16()); btnSave.setScale(ButtonScale.SMALL); btnSave.setIconAlign(IconAlign.LEFT); - btnSave.setToolTip("Save"); + btnSave.setToolTip(msgs.btnSaveToolTip()); btnSave.addSelectHandler(new SelectHandler() { @Override @@ -87,11 +103,11 @@ public class CodeEditPanel extends ContentPanel { }); - btnAddInput = new TextButton("Input"); + btnAddInput = new TextButton(msgs.btnAddInputText()); btnAddInput.setIcon(StatAlgoImporterResources.INSTANCE.add16()); btnAddInput.setScale(ButtonScale.SMALL); btnAddInput.setIconAlign(IconAlign.LEFT); - btnAddInput.setToolTip("Add input variable from code"); + btnAddInput.setToolTip(msgs.btnAddInputToolTip()); btnAddInput.addSelectHandler(new SelectHandler() { @Override @@ -102,11 +118,11 @@ public class CodeEditPanel extends ContentPanel { }); btnAddInput.disable(); - btnAddOutput = new TextButton("Output"); + btnAddOutput = new TextButton(msgs.btnAddOutputText()); btnAddOutput.setIcon(StatAlgoImporterResources.INSTANCE.add16()); btnAddOutput.setScale(ButtonScale.SMALL); btnAddOutput.setIconAlign(IconAlign.LEFT); - btnAddOutput.setToolTip("Add output variable from code"); + btnAddOutput.setToolTip(msgs.btnAddOutputToolTip()); btnAddOutput.addSelectHandler(new SelectHandler() { @Override @@ -117,10 +133,17 @@ public class CodeEditPanel extends ContentPanel { }); btnAddOutput.disable(); + mainCodeField = new TextField(); + mainCodeField.setEmptyText(""); + mainCodeField.setReadOnly(true); + ToolBar toolBar = new ToolBar(); toolBar.add(btnSave, new BoxLayoutData(new Margins(0))); toolBar.add(btnAddInput, new BoxLayoutData(new Margins(0))); toolBar.add(btnAddOutput, new BoxLayoutData(new Margins(0))); + toolBar.add(new SeparatorToolItem()); + toolBar.add(new LabelToolItem(msgs.mainCodeFiledLabel())); + toolBar.add(mainCodeField, new BoxLayoutData(new Margins(0))); editor = new AceEditor(); @@ -132,7 +155,14 @@ public class CodeEditPanel extends ContentPanel { editor.startEditor(); editor.setShowPrintMargin(false); - if (project != null && project.getMainCode() != null) { + if (project != null && project.getMainCode() != null + && project.getMainCode().getItemDescription() != null) { + if (project.getMainCode().getItemDescription().getName() != null) { + mainCodeField.setValue(project.getMainCode() + .getItemDescription().getName()); + } else { + mainCodeField.setValue(""); + } loadCode(); } @@ -158,20 +188,22 @@ public class CodeEditPanel extends ContentPanel { Log.debug("Save Variable: " + ioType + ", " + parameter); if (parameter == null) { Log.debug("No text selected"); - UtilsGXT3.alert("Attention", "Select parameter in the code!"); + UtilsGXT3.alert(msgsCommon.attention(), + msgs.attentionSelectParameterInTheCode()); } else { - createSelectedRowVariable(parameter, ioType); + createInputOutputVariable(parameter, ioType); } } - private void createSelectedRowVariable(String parameter, IOType ioType) { + private void createInputOutputVariable(String parameter, IOType ioType) { CodeParser codeParser = new CodeParser(); - SelectedRowsVariables selectedRowsVariable = codeParser.parse( - parameter, ioType); + InputOutputVariables selectedRowsVariable = codeParser.parse(parameter, + ioType); if (selectedRowsVariable == null) { Log.debug("No valid selection, change selection and try again!"); - UtilsGXT3.alert("Attention", "No valid selected row, change selection and try again!"); + UtilsGXT3.alert(msgsCommon.attention(), + msgs.attentionNoValidSelectedRow()); } else { NewSelectedRowsVariableEvent newSelectedRowsVariableEvent = new NewSelectedRowsVariableEvent( selectedRowsVariable); @@ -181,33 +213,42 @@ public class CodeEditPanel extends ContentPanel { } protected void saveCode() { - String code = editor.getText(); - StatAlgoImporterServiceAsync.INSTANCE.saveCode(code, - new AsyncCallback() { + if (project != null && project.getMainCode() != null + && project.getMainCode().getItemDescription() != null) { + String code = editor.getText(); + StatAlgoImporterServiceAsync.INSTANCE.saveCode(code, + new AsyncCallback() { + + @Override + public void onFailure(Throwable caught) { + if (caught instanceof StatAlgoImporterSessionExpiredException) { + eventBus.fireEvent(new SessionExpiredEvent( + SessionExpiredType.EXPIREDONSERVER)); + } else { + Log.error("Error on save code: " + + caught.getLocalizedMessage()); + UtilsGXT3.alert(msgsCommon.error(), + caught.getLocalizedMessage()); + } + caught.printStackTrace(); - @Override - public void onFailure(Throwable caught) { - if (caught instanceof StatAlgoImporterSessionExpiredException) { - eventBus.fireEvent(new SessionExpiredEvent( - SessionExpiredType.EXPIREDONSERVER)); - } else { - Log.error("Error on save code: " - + caught.getLocalizedMessage()); - UtilsGXT3.alert("Error", - caught.getLocalizedMessage()); } - caught.printStackTrace(); - } + @Override + public void onSuccess(Void result) { + Log.debug("Code is saved!"); + UtilsGXT3.info(msgs.codeSavedHead(), + msgs.codeSaved()); + } - @Override - public void onSuccess(Void result) { - Log.debug("Code is saved!"); - UtilsGXT3.info("Code Saved", "Code is saved!"); - } - - }); + }); + } else { + saveNewMainCode(); + // Log.debug("Attention no Main Code Set!"); + // UtilsGXT3.alert(msgsCommon.attention(), + // msgsCommon.attentionNoMainCodeSet()); + } } private void loadCode() { @@ -221,7 +262,7 @@ public class CodeEditPanel extends ContentPanel { } else { Log.error("Error retrieving code: " + caught.getLocalizedMessage()); - UtilsGXT3.alert("Error", + UtilsGXT3.alert(msgsCommon.error(), caught.getLocalizedMessage()); } caught.printStackTrace(); @@ -254,8 +295,19 @@ public class CodeEditPanel extends ContentPanel { } public void codeUpdate(Project project) { - if (project != null && project.getMainCode() != null) { + this.project = project; + if (project != null && project.getMainCode() != null + && project.getMainCode().getItemDescription() != null) { + if (project.getMainCode().getItemDescription().getName() != null) { + mainCodeField.setValue(project.getMainCode() + .getItemDescription().getName()); + } else { + mainCodeField.setValue(""); + } loadCode(); + } else { + editor.setText(""); + mainCodeField.setValue(""); } } @@ -308,4 +360,48 @@ public class CodeEditPanel extends ContentPanel { return selectedText; } + private void saveNewMainCode() { + final PromptMessageBox messageBox = new PromptMessageBox("Main Code", + "File name:"); + // First option: Listening for the hide event and then figuring which + // button was pressed. + messageBox.addDialogHideHandler(new DialogHideHandler() { + @Override + public void onDialogHide(DialogHideEvent event) { + if (event.getHideButton() == PredefinedButton.OK) { + } else { + } + } + }); + + // Second option: Listen for a button click + messageBox.getButton(PredefinedButton.OK).addSelectHandler( + new SelectHandler() { + @Override + public void onSelect(SelectEvent event) { + String fileName = messageBox.getTextField() + .getCurrentValue(); + if (fileName != null && !fileName.isEmpty()) { + saveNewMainCodeOnServer(fileName); + } else { + Log.debug("Attention invalid file name for Main Code!"); + UtilsGXT3.alert(msgsCommon.attention(), + msgs.attentionInvalidFileNameForMainCode()); + } + + } + }); + messageBox.show(); + } + + private void saveNewMainCodeOnServer(String fileName){ + ItemDescription file=new ItemDescription(); + file.setName(fileName); + String code = editor.getText(); + NewMainCodeEvent saveNewMainCodeEvent=new NewMainCodeEvent(file, code); + eventBus.fireEvent(saveNewMainCodeEvent); + Log.debug("Fired: "+saveNewMainCodeEvent); + + } + } diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/project/ProjectManager.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/project/ProjectManager.java index 4929fbc..ee41550 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/project/ProjectManager.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/project/ProjectManager.java @@ -5,6 +5,7 @@ import java.util.Arrays; import java.util.List; import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.ProjectStatusEvent; +import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.NewMainCodeEvent; import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.SessionExpiredEvent; import org.gcube.portlets.user.statisticalalgorithmsimporter.client.monitor.StatAlgoImporterMonitor; import org.gcube.portlets.user.statisticalalgorithmsimporter.client.rpc.StatAlgoImporterServiceAsync; @@ -288,7 +289,8 @@ public class ProjectManager { }); } - public void saveProject(InputData inputData, final StatAlgoImporterMonitor monitor) { + public void saveProject(InputData inputData, + final StatAlgoImporterMonitor monitor) { Log.debug("Save Project: " + inputData); StatAlgoImporterServiceAsync.INSTANCE.saveProject(inputData, @@ -313,12 +315,13 @@ public class ProjectManager { caught.getLocalizedMessage()); } caught.printStackTrace(); - + } }); } - public void createSofware(InputData inputData, final StatAlgoImporterMonitor monitor) { + public void createSofware(InputData inputData, + final StatAlgoImporterMonitor monitor) { Log.debug("Create Software: " + inputData); StatAlgoImporterServiceAsync.INSTANCE.createSoftware(inputData, @@ -329,7 +332,7 @@ public class ProjectManager { monitor.hide(); fireProjectStatusSoftwareCreatedEvent(); UtilsGXT3.info("Create Software", "Software Created!"); - + } @Override @@ -414,7 +417,38 @@ public class ProjectManager { }); } + + public void setNewMainCode(NewMainCodeEvent newMainCodeEvent, final StatAlgoImporterMonitor monitor){ + StatAlgoImporterServiceAsync.INSTANCE.setNewMainCode(newMainCodeEvent.getFile(),newMainCodeEvent.getCode(), + new AsyncCallback() { + @Override + public void onFailure(Throwable caught) { + monitor.hide(); + if (caught instanceof StatAlgoImporterSessionExpiredException) { + eventBus.fireEvent(new SessionExpiredEvent( + SessionExpiredType.EXPIREDONSERVER)); + } else { + Log.error("Error on save new main code: " + + caught.getLocalizedMessage()); + UtilsGXT3.alert("Error", + caught.getLocalizedMessage()); + } + caught.printStackTrace(); + + } + + @Override + public void onSuccess(ItemDescription itemDescription) { + project.setMainCode(new MainCode(itemDescription)); + fireProjectStatusMainCodeSetEvent(); + monitor.hide(); + } + + }); + } + + public void deleteItem(ItemDescription itemDescription) { StatAlgoImporterServiceAsync.INSTANCE.deleteResourceOnProject( itemDescription, new AsyncCallback() { @@ -488,14 +522,13 @@ public class ProjectManager { eventBus.fireEvent(projectStatusEvent); Log.debug("ProjectStatusEvent fired! " + projectStatusEvent); } - + protected void fireProjectStatusSoftwareCreatedEvent() { ProjectStatusEvent projectStatusEvent = new ProjectStatusEvent( ProjectStatusEventType.SOFTWARE_CREATED, project); eventBus.fireEvent(projectStatusEvent); Log.debug("ProjectStatusEvent fired! " + projectStatusEvent); } - protected void fireProjectStatusStartEvent() { ProjectStatusEvent projectStatusEvent = new ProjectStatusEvent( @@ -504,4 +537,31 @@ public class ProjectManager { Log.debug("ProjectStatusEvent fired! " + projectStatusEvent); } + public void startProjectManager(String value) { + + StatAlgoImporterServiceAsync.INSTANCE.restoreUISession(value, + new AsyncCallback() { + + public void onFailure(Throwable caught) { + if (caught instanceof StatAlgoImporterSessionExpiredException) { + eventBus.fireEvent(new SessionExpiredEvent( + SessionExpiredType.EXPIREDONSERVER)); + } else { + UtilsGXT3.alert("Error", + caught.getLocalizedMessage()); + + } + } + + public void onSuccess(Project p) { + if (p != null) { + project = p; + fireProjectStatusOpenEvent(); + } + } + + }); + + } + } diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/properties/EnvironmentVariablesProperties.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/properties/GlobalVariablesProperties.java similarity index 55% rename from src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/properties/EnvironmentVariablesProperties.java rename to src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/properties/GlobalVariablesProperties.java index 3dff0d0..5e85312 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/properties/EnvironmentVariablesProperties.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/properties/GlobalVariablesProperties.java @@ -1,6 +1,6 @@ package org.gcube.portlets.user.statisticalalgorithmsimporter.client.properties; -import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.EnvironmentVariables; +import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.GlobalVariables; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.DataType; import com.sencha.gxt.core.client.ValueProvider; @@ -13,16 +13,16 @@ import com.sencha.gxt.data.shared.PropertyAccess; * href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it * */ -public interface EnvironmentVariablesProperties extends - PropertyAccess { +public interface GlobalVariablesProperties extends + PropertyAccess { - ModelKeyProvider id(); + ModelKeyProvider id(); - ValueProvider name(); + ValueProvider name(); - ValueProvider description(); + ValueProvider description(); - ValueProvider dataType(); + ValueProvider dataType(); - ValueProvider defaultValue(); + ValueProvider defaultValue(); } diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/properties/SelectedRowsVariablesProperties.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/properties/InputOutputVariablesProperties.java similarity index 52% rename from src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/properties/SelectedRowsVariablesProperties.java rename to src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/properties/InputOutputVariablesProperties.java index 0b30541..73c9740 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/properties/SelectedRowsVariablesProperties.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/properties/InputOutputVariablesProperties.java @@ -1,7 +1,7 @@ package org.gcube.portlets.user.statisticalalgorithmsimporter.client.properties; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.IOType; -import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.SelectedRowsVariables; +import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.InputOutputVariables; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.DataType; import com.sencha.gxt.core.client.ValueProvider; @@ -14,22 +14,22 @@ import com.sencha.gxt.data.shared.PropertyAccess; * href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it * */ -public interface SelectedRowsVariablesProperties extends - PropertyAccess { +public interface InputOutputVariablesProperties extends + PropertyAccess { - ModelKeyProvider id(); + ModelKeyProvider id(); - ValueProvider name(); + ValueProvider name(); - ValueProvider description(); + ValueProvider description(); - ValueProvider dataType(); + ValueProvider dataType(); - ValueProvider defaultValue(); + ValueProvider defaultValue(); - ValueProvider ioType(); + ValueProvider ioType(); - ValueProvider sourceSelection(); + ValueProvider sourceSelection(); } diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/properties/DeployableVREProperties.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/properties/RequestedVREProperties.java similarity index 63% rename from src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/properties/DeployableVREProperties.java rename to src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/properties/RequestedVREProperties.java index 623d498..602a296 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/properties/DeployableVREProperties.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/properties/RequestedVREProperties.java @@ -1,6 +1,6 @@ package org.gcube.portlets.user.statisticalalgorithmsimporter.client.properties; -import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.DeployableVRE; +import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.RequestedVRE; import com.sencha.gxt.core.client.ValueProvider; import com.sencha.gxt.data.shared.ModelKeyProvider; @@ -12,12 +12,12 @@ import com.sencha.gxt.data.shared.PropertyAccess; * href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it * */ -public interface DeployableVREProperties extends PropertyAccess { +public interface RequestedVREProperties extends PropertyAccess { - ModelKeyProvider id(); + ModelKeyProvider id(); - ValueProvider name(); + ValueProvider name(); - ValueProvider description(); + ValueProvider description(); } diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/rpc/StatAlgoImporterService.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/rpc/StatAlgoImporterService.java index 7f7e6c0..a6ae848 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/rpc/StatAlgoImporterService.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/rpc/StatAlgoImporterService.java @@ -64,8 +64,16 @@ public interface StatAlgoImporterService extends RemoteService { public void saveCode(String code) throws StatAlgoImporterServiceException; - public void createSoftware(InputData inputData) throws StatAlgoImporterServiceException; + public void createSoftware(InputData inputData) + throws StatAlgoImporterServiceException; - public String getUriFromResolver(ItemDescription itemDescription) throws StatAlgoImporterServiceException; + public String getPublicLink(ItemDescription itemDescription) + throws StatAlgoImporterServiceException; + + public Project restoreUISession(String value) + throws StatAlgoImporterServiceException; + + public ItemDescription setNewMainCode(ItemDescription itemDescription, String code) + throws StatAlgoImporterServiceException; } diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/rpc/StatAlgoImporterServiceAsync.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/rpc/StatAlgoImporterServiceAsync.java index bf0fc1c..4950453 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/rpc/StatAlgoImporterServiceAsync.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/rpc/StatAlgoImporterServiceAsync.java @@ -54,10 +54,14 @@ public interface StatAlgoImporterServiceAsync { AsyncCallback asyncCallback); void saveCode(String code, AsyncCallback asyncCallback); + + void setNewMainCode(ItemDescription itemDescription, String code, AsyncCallback asyncCallback); void createSoftware(InputData inputData, AsyncCallback callback); - void getUriFromResolver(ItemDescription itemDescription, + void getPublicLink(ItemDescription itemDescription, AsyncCallback asyncCallback); + void restoreUISession(String value, AsyncCallback asyncCallback); + } diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/explorer/ExplorerProjectPanel.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/explorer/ExplorerProjectPanel.java index e06bb6a..68aeb51 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/explorer/ExplorerProjectPanel.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/explorer/ExplorerProjectPanel.java @@ -119,9 +119,11 @@ public class ExplorerProjectPanel extends ContentPanel { create(event); break; case MAIN_CODE_SET: + reloadWSResourceExplorerPanel(); break; case SOFTWARE_CREATED: reloadWSResourceExplorerPanel(); + break; default: break; } @@ -354,8 +356,8 @@ public class ExplorerProjectPanel extends ContentPanel { selectedItem.getId(), selectedItem.getName(), selectedItem.getOwner(), selectedItem.getPath(), selectedItem.getType().name()); - - StatAlgoImporterServiceAsync.INSTANCE.getUriFromResolver( + + StatAlgoImporterServiceAsync.INSTANCE.getPublicLink( itemDescription, new AsyncCallback() { @Override diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/EnvironmentVariablesPanel.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/GlobalVariablesPanel.java similarity index 58% rename from src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/EnvironmentVariablesPanel.java rename to src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/GlobalVariablesPanel.java index 7f371e6..7b82961 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/EnvironmentVariablesPanel.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/GlobalVariablesPanel.java @@ -4,10 +4,10 @@ import java.util.ArrayList; import java.util.List; import org.gcube.portlets.user.statisticalalgorithmsimporter.client.properties.DataTypePropertiesCombo; -import org.gcube.portlets.user.statisticalalgorithmsimporter.client.properties.EnvironmentVariablesProperties; +import org.gcube.portlets.user.statisticalalgorithmsimporter.client.properties.GlobalVariablesProperties; import org.gcube.portlets.user.statisticalalgorithmsimporter.client.resource.StatAlgoImporterResources; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.DataType; -import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.EnvironmentVariables; +import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.GlobalVariables; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Project; import com.allen_sauer.gwt.log.client.Log; @@ -56,13 +56,13 @@ import com.sencha.gxt.widget.core.client.toolbar.ToolBar; * href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it * */ -public class EnvironmentVariablesPanel extends ContentPanel { +public class GlobalVariablesPanel extends ContentPanel { @SuppressWarnings("unused") private EventBus eventBus; - private ListStore storeEnvironmentVariable; - private Grid gridEnvironmentVariable; - private GridRowEditing gridEnvironmentVariableEditing; + private ListStore storeGlobalVariable; + private Grid gridGlobalVariable; + private GridRowEditing gridGlobalVariableEditing; private TextButton btnAdd; private boolean addStatus; private int seq = 0; @@ -75,9 +75,9 @@ public class EnvironmentVariablesPanel extends ContentPanel { SafeHtml format(String value); } - public EnvironmentVariablesPanel(Project project, EventBus eventBus) { + public GlobalVariablesPanel(Project project, EventBus eventBus) { super(); - Log.debug("EnvironmentVariablesPanel"); + Log.debug("GlobalVariablesPanel"); this.eventBus = eventBus; // msgs = GWT.create(ServiceCategoryMessages.class); @@ -99,18 +99,18 @@ public class EnvironmentVariablesPanel extends ContentPanel { private void create(Project project) { // Grid - EnvironmentVariablesProperties props = GWT - .create(EnvironmentVariablesProperties.class); + GlobalVariablesProperties props = GWT + .create(GlobalVariablesProperties.class); - ColumnConfig nameColumn = new ColumnConfig( + ColumnConfig nameColumn = new ColumnConfig( props.name(), 100, "Name"); // nameColumn.setMenuDisabled(true); - ColumnConfig descriptionColumn = new ColumnConfig( + ColumnConfig descriptionColumn = new ColumnConfig( props.description(), 100, "Description"); // descriptionColumn.setMenuDisabled(true); - ColumnConfig inputTypeColumn = new ColumnConfig( + ColumnConfig inputTypeColumn = new ColumnConfig( props.dataType(), 100, "Type"); // inputTypeColumn.setMenuDisabled(true); inputTypeColumn.setCell(new AbstractCell() { @@ -124,53 +124,53 @@ public class EnvironmentVariablesPanel extends ContentPanel { } }); - ColumnConfig defaultValueColumn = new ColumnConfig( + ColumnConfig defaultValueColumn = new ColumnConfig( props.defaultValue(), 100, "Default"); // defaColumn.setMenuDisabled(true); - ArrayList> l = new ArrayList>(); + ArrayList> l = new ArrayList>(); l.add(nameColumn); l.add(descriptionColumn); l.add(inputTypeColumn); l.add(defaultValueColumn); - ColumnModel columns = new ColumnModel(l); + ColumnModel columns = new ColumnModel(l); - storeEnvironmentVariable = new ListStore(props.id()); + storeGlobalVariable = new ListStore(props.id()); if (project != null && project.getInputData() != null - && project.getInputData().getListSelectedRows() != null) { - storeEnvironmentVariable.addAll(project.getInputData() - .getListEnvironmentVariables()); - seq = project.getInputData().getListEnvironmentVariables().size(); + && project.getInputData().getListGlobalVariables() != null) { + storeGlobalVariable.addAll(project.getInputData() + .getListGlobalVariables()); + seq = project.getInputData().getListGlobalVariables().size(); } - final GridSelectionModel sm = new GridSelectionModel(); + final GridSelectionModel sm = new GridSelectionModel(); sm.setSelectionMode(SelectionMode.SINGLE); - gridEnvironmentVariable = new Grid( - storeEnvironmentVariable, columns); - gridEnvironmentVariable.setSelectionModel(sm); - gridEnvironmentVariable.getView().setStripeRows(true); - gridEnvironmentVariable.getView().setColumnLines(true); - gridEnvironmentVariable.getView().setAutoExpandColumn(nameColumn); - gridEnvironmentVariable.getView().setAutoFill(true); - gridEnvironmentVariable.setBorders(false); - gridEnvironmentVariable.setColumnReordering(false); + gridGlobalVariable = new Grid( + storeGlobalVariable, columns); + gridGlobalVariable.setSelectionModel(sm); + gridGlobalVariable.getView().setStripeRows(true); + gridGlobalVariable.getView().setColumnLines(true); + gridGlobalVariable.getView().setAutoExpandColumn(nameColumn); + gridGlobalVariable.getView().setAutoFill(true); + gridGlobalVariable.setBorders(false); + gridGlobalVariable.setColumnReordering(false); /* - * GridDragSource ds = new - * GridDragSource( gridEnvironmentVariable); + * GridDragSource ds = new + * GridDragSource( gridGlobalVariable); * ds.addDragStartHandler(new DndDragStartHandler() { * * @Override public void onDragStart(DndDragStartEvent event) { * - * @SuppressWarnings("unchecked") ArrayList - * draggingSelection = (ArrayList) event + * @SuppressWarnings("unchecked") ArrayList + * draggingSelection = (ArrayList) event * .getData(); Log.debug("Start Drag: " + draggingSelection); * - * } }); GridDropTarget dt = new - * GridDropTarget( gridEnvironmentVariable); + * } }); GridDropTarget dt = new + * GridDropTarget( gridGlobalVariable); * dt.setFeedback(Feedback.BOTH); dt.setAllowSelfAsSource(true); */ @@ -191,26 +191,26 @@ public class EnvironmentVariablesPanel extends ContentPanel { comboInputType.setTriggerAction(TriggerAction.ALL); addHandlersForComboInputType(inputTypePropertiesCombo.label()); - gridEnvironmentVariableEditing = new GridRowEditing( - gridEnvironmentVariable); - gridEnvironmentVariableEditing.addEditor(nameColumn, new TextField()); - gridEnvironmentVariableEditing.addEditor(descriptionColumn, + gridGlobalVariableEditing = new GridRowEditing( + gridGlobalVariable); + gridGlobalVariableEditing.addEditor(nameColumn, new TextField()); + gridGlobalVariableEditing.addEditor(descriptionColumn, new TextField()); - gridEnvironmentVariableEditing.addEditor(inputTypeColumn, + gridGlobalVariableEditing.addEditor(inputTypeColumn, comboInputType); - gridEnvironmentVariableEditing.addEditor(defaultValueColumn, + gridGlobalVariableEditing.addEditor(defaultValueColumn, new TextField()); btnAdd = new TextButton("Add"); btnAdd.setIcon(StatAlgoImporterResources.INSTANCE.add16()); btnAdd.setScale(ButtonScale.SMALL); btnAdd.setIconAlign(IconAlign.LEFT); - btnAdd.setToolTip("Add Environment Variable"); + btnAdd.setToolTip("Add Global Variable"); btnAdd.addSelectHandler(new SelectHandler() { @Override public void onSelect(SelectEvent event) { - addEnvironmentVariable(event); + addGlobalVariable(event); } }); @@ -218,78 +218,78 @@ public class EnvironmentVariablesPanel extends ContentPanel { TextButton btnDelete = new TextButton("Delete"); btnDelete.addSelectHandler(new SelectEvent.SelectHandler() { public void onSelect(SelectEvent event) { - GridCell cell = gridEnvironmentVariableEditing.getActiveCell(); + GridCell cell = gridGlobalVariableEditing.getActiveCell(); int rowIndex = cell.getRow(); - gridEnvironmentVariableEditing.cancelEditing(); + gridGlobalVariableEditing.cancelEditing(); - storeEnvironmentVariable.remove(rowIndex); - storeEnvironmentVariable.commitChanges(); + storeGlobalVariable.remove(rowIndex); + storeGlobalVariable.commitChanges(); - gridEnvironmentVariableEditing.getCancelButton().setVisible( + gridGlobalVariableEditing.getCancelButton().setVisible( true); btnAdd.setEnabled(true); if (addStatus) { addStatus = false; } - List listSelected=storeEnvironmentVariable.getAll(); - List listNewSelected= new ArrayList(); + List listSelected=storeGlobalVariable.getAll(); + List listNewSelected= new ArrayList(); for(int i=0; i() { + gridGlobalVariableEditing + .addBeforeStartEditHandler(new BeforeStartEditHandler() { @Override public void onBeforeStartEdit( - BeforeStartEditEvent event) { + BeforeStartEditEvent event) { editingBeforeStart(event); } }); - gridEnvironmentVariableEditing - .addCancelEditHandler(new CancelEditHandler() { + gridGlobalVariableEditing + .addCancelEditHandler(new CancelEditHandler() { @Override public void onCancelEdit( - CancelEditEvent event) { - storeEnvironmentVariable.rejectChanges(); + CancelEditEvent event) { + storeGlobalVariable.rejectChanges(); btnAdd.setEnabled(true); } }); - gridEnvironmentVariableEditing - .addCompleteEditHandler(new CompleteEditHandler() { + gridGlobalVariableEditing + .addCompleteEditHandler(new CompleteEditHandler() { @Override public void onCompleteEdit( - CompleteEditEvent event) { + CompleteEditEvent event) { try { if (addStatus) { addStatus = false; } - storeEnvironmentVariable.commitChanges(); + storeGlobalVariable.commitChanges(); - gridEnvironmentVariableEditing.getCancelButton() + gridGlobalVariableEditing.getCancelButton() .setVisible(true); btnAdd.setEnabled(true); @@ -309,14 +309,14 @@ public class EnvironmentVariablesPanel extends ContentPanel { vlc.setScrollMode(ScrollMode.NONE); vlc.add(toolBar, new VerticalLayoutData(1, -1, new Margins(0))); - vlc.add(gridEnvironmentVariable, new VerticalLayoutData(1, 1, + vlc.add(gridGlobalVariable, new VerticalLayoutData(1, 1, new Margins(0))); add(vlc, new MarginData(new Margins(0))); } - private void editingBeforeStart(BeforeStartEditEvent event) { + private void editingBeforeStart(BeforeStartEditEvent event) { // TODO Auto-generated method stub } @@ -326,23 +326,23 @@ public class EnvironmentVariablesPanel extends ContentPanel { } - private void addEnvironmentVariable(SelectEvent event) { + private void addGlobalVariable(SelectEvent event) { try { seq++; - EnvironmentVariables newEnvironmentVariable = new EnvironmentVariables(seq, "", + GlobalVariables newGlobalVariable = new GlobalVariables(seq, "", "", "", DataType.STRING); - Log.debug("New Environment Variable: " + newEnvironmentVariable); - gridEnvironmentVariableEditing.cancelEditing(); + Log.debug("New Global Variable: " + newGlobalVariable); + gridGlobalVariableEditing.cancelEditing(); addStatus = true; - gridEnvironmentVariableEditing.getCancelButton().setVisible(false); - storeEnvironmentVariable.add(newEnvironmentVariable); - int row = storeEnvironmentVariable.indexOf(newEnvironmentVariable); + gridGlobalVariableEditing.getCancelButton().setVisible(false); + storeGlobalVariable.add(newGlobalVariable); + int row = storeGlobalVariable.indexOf(newGlobalVariable); storeComboInputType.clear(); storeComboInputType.addAll(DataType.asList()); storeComboInputType.commitChanges(); - gridEnvironmentVariableEditing.startEditing(new GridCell(row, 0)); + gridGlobalVariableEditing.startEditing(new GridCell(row, 0)); } catch (Throwable e) { e.printStackTrace(); } @@ -350,28 +350,28 @@ public class EnvironmentVariablesPanel extends ContentPanel { public void update(Project project) { if (project != null && project.getInputData() != null - && project.getInputData().getListSelectedRows() != null) { - storeEnvironmentVariable.clear(); - storeEnvironmentVariable.addAll(project.getInputData().getListEnvironmentVariables()); - storeEnvironmentVariable.commitChanges(); - seq = project.getInputData().getListEnvironmentVariables().size(); + && project.getInputData().getListGlobalVariables() != null) { + storeGlobalVariable.clear(); + storeGlobalVariable.addAll(project.getInputData().getListGlobalVariables()); + storeGlobalVariable.commitChanges(); + seq = project.getInputData().getListGlobalVariables().size(); } else { - storeEnvironmentVariable.clear(); - storeEnvironmentVariable.commitChanges(); + storeGlobalVariable.clear(); + storeGlobalVariable.commitChanges(); seq=0; } } - public ArrayList getEnvironmentVariables() { - ArrayList listEnviromentVarialbles = new ArrayList<>( - gridEnvironmentVariable.getStore().getAll()); - return listEnviromentVarialbles; + public ArrayList getGlobalVariables() { + ArrayList listGlobalVarialbles = new ArrayList<>( + gridGlobalVariable.getStore().getAll()); + return listGlobalVarialbles; } public void setMainCode(Project project) { - storeEnvironmentVariable.clear(); - storeEnvironmentVariable.commitChanges(); + storeGlobalVariable.clear(); + storeGlobalVariable.commitChanges(); seq = 0; forceLayout(); diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/SelectedRowsPanel.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/InputOutputVariablesPanel.java similarity index 59% rename from src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/SelectedRowsPanel.java rename to src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/InputOutputVariablesPanel.java index d875643..cacb267 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/SelectedRowsPanel.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/InputOutputVariablesPanel.java @@ -5,11 +5,11 @@ import java.util.List; import org.gcube.portlets.user.statisticalalgorithmsimporter.client.properties.DataTypePropertiesCombo; import org.gcube.portlets.user.statisticalalgorithmsimporter.client.properties.IOTypePropertiesCombo; -import org.gcube.portlets.user.statisticalalgorithmsimporter.client.properties.SelectedRowsVariablesProperties; +import org.gcube.portlets.user.statisticalalgorithmsimporter.client.properties.InputOutputVariablesProperties; import org.gcube.portlets.user.statisticalalgorithmsimporter.client.resource.StatAlgoImporterResources; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.DataType; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.IOType; -import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.SelectedRowsVariables; +import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.InputOutputVariables; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Project; import com.allen_sauer.gwt.log.client.Log; @@ -54,17 +54,17 @@ import com.sencha.gxt.widget.core.client.grid.editing.GridRowEditing; * href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it * */ -public class SelectedRowsPanel extends ContentPanel { +public class InputOutputVariablesPanel extends ContentPanel { @SuppressWarnings("unused") private EventBus eventBus; - private ListStore storeSelectedRows; - private Grid gridSelectedRows; + private ListStore storeInputOutputVariables; + private Grid gridInputOutputVariables; private ListStore storeComboDataType; private ComboBox comboDataType; private ListStore storeComboIOType; private ComboBox comboIOType; - private GridRowEditing gridSelectedRowsEditing; + private GridRowEditing gridInputOutputVariablesEditing; private TextButton btnAdd; private boolean addStatus; private int seq = 0; @@ -79,9 +79,9 @@ public class SelectedRowsPanel extends ContentPanel { SafeHtml format(String value); } - public SelectedRowsPanel(Project project, EventBus eventBus) { + public InputOutputVariablesPanel(Project project, EventBus eventBus) { super(); - Log.debug("SelectedRowsPanel"); + Log.debug("InputOutputVariablesPanel"); this.eventBus = eventBus; // msgs = GWT.create(ServiceCategoryMessages.class); @@ -103,25 +103,25 @@ public class SelectedRowsPanel extends ContentPanel { private void create(Project project) { if (project != null && project.getInputData() != null - && project.getInputData().getListSelectedRows() != null) { - seq = project.getInputData().getListSelectedRows().size(); + && project.getInputData().getListInputOutputVariables() != null) { + seq = project.getInputData().getListInputOutputVariables().size(); } else { seq = 0; } // Grid - SelectedRowsVariablesProperties props = GWT - .create(SelectedRowsVariablesProperties.class); + InputOutputVariablesProperties props = GWT + .create(InputOutputVariablesProperties.class); - ColumnConfig nameColumn = new ColumnConfig( + ColumnConfig nameColumn = new ColumnConfig( props.name(), 100, "Name"); // nameColumn.setMenuDisabled(true); - ColumnConfig descriptionColumn = new ColumnConfig( + ColumnConfig descriptionColumn = new ColumnConfig( props.description(), 100, "Description"); // descriptionColumn.setMenuDisabled(true); - ColumnConfig dataTypeColumn = new ColumnConfig( + ColumnConfig dataTypeColumn = new ColumnConfig( props.dataType(), 100, "Type"); // inputTypeColumn.setMenuDisabled(true); dataTypeColumn.setCell(new AbstractCell() { @@ -135,11 +135,11 @@ public class SelectedRowsPanel extends ContentPanel { } }); - ColumnConfig defaultValueColumn = new ColumnConfig( + ColumnConfig defaultValueColumn = new ColumnConfig( props.defaultValue(), 100, "Default"); // defaColumn.setMenuDisabled(true); - ColumnConfig ioTypeColumn = new ColumnConfig( + ColumnConfig ioTypeColumn = new ColumnConfig( props.ioType(), 100, "I/O"); // inputTypeColumn.setMenuDisabled(true); ioTypeColumn.setCell(new AbstractCell() { @@ -153,58 +153,58 @@ public class SelectedRowsPanel extends ContentPanel { } }); - ArrayList> l = new ArrayList>(); + ArrayList> l = new ArrayList>(); l.add(nameColumn); l.add(descriptionColumn); l.add(dataTypeColumn); l.add(defaultValueColumn); l.add(ioTypeColumn); - ColumnModel columns = new ColumnModel( + ColumnModel columns = new ColumnModel( l); - storeSelectedRows = new ListStore(props.id()); + storeInputOutputVariables = new ListStore(props.id()); /* - * ArrayList list = new ArrayList<>(); for (int i - * = 0; i < 10; i++) { list.add(new SelectedRowsVariables(i, "Test" + i, + * ArrayList list = new ArrayList<>(); for (int i + * = 0; i < 10; i++) { list.add(new InputOutputVariablesVariables(i, "Test" + i, * "Desc", "defaultValue", InputType.STRING)); } * * storeEnvironmentVariable.addAll(list); */ if (project != null && project.getInputData() != null - && project.getInputData().getListSelectedRows() != null) { - storeSelectedRows.addAll(project.getInputData() - .getListSelectedRows()); + && project.getInputData().getListInputOutputVariables() != null) { + storeInputOutputVariables.addAll(project.getInputData() + .getListInputOutputVariables()); } - final GridSelectionModel sm = new GridSelectionModel(); + final GridSelectionModel sm = new GridSelectionModel(); sm.setSelectionMode(SelectionMode.SINGLE); - gridSelectedRows = new Grid(storeSelectedRows, + gridInputOutputVariables = new Grid(storeInputOutputVariables, columns); - gridSelectedRows.setSelectionModel(sm); - gridSelectedRows.getView().setStripeRows(true); - gridSelectedRows.getView().setColumnLines(true); - gridSelectedRows.getView().setAutoExpandColumn(nameColumn); - gridSelectedRows.getView().setAutoFill(true); - gridSelectedRows.setBorders(false); - gridSelectedRows.setColumnReordering(false); + gridInputOutputVariables.setSelectionModel(sm); + gridInputOutputVariables.getView().setStripeRows(true); + gridInputOutputVariables.getView().setColumnLines(true); + gridInputOutputVariables.getView().setAutoExpandColumn(nameColumn); + gridInputOutputVariables.getView().setAutoFill(true); + gridInputOutputVariables.setBorders(false); + gridInputOutputVariables.setColumnReordering(false); /* - * GridDragSource ds = new - * GridDragSource( gridEnvironmentVariable); + * GridDragSource ds = new + * GridDragSource( gridEnvironmentVariable); * ds.addDragStartHandler(new DndDragStartHandler() { * * @Override public void onDragStart(DndDragStartEvent event) { * - * @SuppressWarnings("unchecked") ArrayList - * draggingSelection = (ArrayList) event + * @SuppressWarnings("unchecked") ArrayList + * draggingSelection = (ArrayList) event * .getData(); Log.debug("Start Drag: " + draggingSelection); * - * } }); GridDropTarget dt = new - * GridDropTarget( gridEnvironmentVariable); + * } }); GridDropTarget dt = new + * GridDropTarget( gridEnvironmentVariable); * dt.setFeedback(Feedback.BOTH); dt.setAllowSelfAsSource(true); */ @@ -249,24 +249,24 @@ public class SelectedRowsPanel extends ContentPanel { // - gridSelectedRowsEditing = new GridRowEditing( - gridSelectedRows); - gridSelectedRowsEditing.addEditor(nameColumn, new TextField()); - gridSelectedRowsEditing.addEditor(descriptionColumn, new TextField()); - gridSelectedRowsEditing.addEditor(dataTypeColumn, comboDataType); - gridSelectedRowsEditing.addEditor(defaultValueColumn, new TextField()); + gridInputOutputVariablesEditing = new GridRowEditing( + gridInputOutputVariables); + gridInputOutputVariablesEditing.addEditor(nameColumn, new TextField()); + gridInputOutputVariablesEditing.addEditor(descriptionColumn, new TextField()); + gridInputOutputVariablesEditing.addEditor(dataTypeColumn, comboDataType); + gridInputOutputVariablesEditing.addEditor(defaultValueColumn, new TextField()); - gridSelectedRowsEditing.addEditor(ioTypeColumn, comboIOType); + gridInputOutputVariablesEditing.addEditor(ioTypeColumn, comboIOType); btnAdd = new TextButton(); btnAdd.setIcon(StatAlgoImporterResources.INSTANCE.add16()); // btnAdd.setIconAlign(IconAlign.); - btnAdd.setToolTip("Add Environment Variable"); + btnAdd.setToolTip("Add Input/Output Variable"); btnAdd.addSelectHandler(new SelectHandler() { @Override public void onSelect(SelectEvent event) { - addSelectedRow(event); + addInputOutputVariable(event); } }); @@ -274,77 +274,77 @@ public class SelectedRowsPanel extends ContentPanel { TextButton btnDelete = new TextButton("Delete"); btnDelete.addSelectHandler(new SelectEvent.SelectHandler() { public void onSelect(SelectEvent event) { - GridCell cell = gridSelectedRowsEditing.getActiveCell(); + GridCell cell = gridInputOutputVariablesEditing.getActiveCell(); int rowIndex = cell.getRow(); - gridSelectedRowsEditing.cancelEditing(); + gridInputOutputVariablesEditing.cancelEditing(); - storeSelectedRows.remove(rowIndex); - storeSelectedRows.commitChanges(); + storeInputOutputVariables.remove(rowIndex); + storeInputOutputVariables.commitChanges(); - gridSelectedRowsEditing.getCancelButton().setVisible(true); + gridInputOutputVariablesEditing.getCancelButton().setVisible(true); btnAdd.setEnabled(true); if (addStatus) { addStatus = false; } - List listSelected=storeSelectedRows.getAll(); - List listNewSelected= new ArrayList(); - for(int i=0; i listIOVariables=storeInputOutputVariables.getAll(); + List listNewIOVariables= new ArrayList(); + for(int i=0; i() { + gridInputOutputVariablesEditing + .addBeforeStartEditHandler(new BeforeStartEditHandler() { @Override public void onBeforeStartEdit( - BeforeStartEditEvent event) { + BeforeStartEditEvent event) { editingBeforeStart(event); } }); - gridSelectedRowsEditing - .addCancelEditHandler(new CancelEditHandler() { + gridInputOutputVariablesEditing + .addCancelEditHandler(new CancelEditHandler() { @Override public void onCancelEdit( - CancelEditEvent event) { - storeSelectedRows.rejectChanges(); + CancelEditEvent event) { + storeInputOutputVariables.rejectChanges(); btnAdd.setEnabled(true); } }); - gridSelectedRowsEditing - .addCompleteEditHandler(new CompleteEditHandler() { + gridInputOutputVariablesEditing + .addCompleteEditHandler(new CompleteEditHandler() { @Override public void onCompleteEdit( - CompleteEditEvent event) { + CompleteEditEvent event) { try { if (addStatus) { addStatus = false; } - storeSelectedRows.commitChanges(); + storeInputOutputVariables.commitChanges(); - gridSelectedRowsEditing.getCancelButton() + gridInputOutputVariablesEditing.getCancelButton() .setVisible(true); btnAdd.setEnabled(true); @@ -364,14 +364,14 @@ public class SelectedRowsPanel extends ContentPanel { vlc.setScrollMode(ScrollMode.NONE); // vlc.add(toolBar, new VerticalLayoutData(1, -1, new Margins(0))); - vlc.add(gridSelectedRows, new VerticalLayoutData(1, 1, new Margins(0))); + vlc.add(gridInputOutputVariables, new VerticalLayoutData(1, 1, new Margins(0))); add(vlc, new MarginData(new Margins(0))); } private void editingBeforeStart( - BeforeStartEditEvent event) { + BeforeStartEditEvent event) { // TODO Auto-generated method stub } @@ -386,18 +386,18 @@ public class SelectedRowsPanel extends ContentPanel { } - public void addNewSelectedRowsVariable( - SelectedRowsVariables selectedRowsVariable) { + public void addNewInputOutputVariables( + InputOutputVariables inputOutputVariable) { try { Log.debug("Current Seq: " + seq); seq++; - selectedRowsVariable.setId(seq); - Log.debug("New Selected Rows Variable: " + selectedRowsVariable); - storeSelectedRows.add(selectedRowsVariable); - storeSelectedRows.commitChanges(); + inputOutputVariable.setId(seq); + Log.debug("New Input/Output Variable: " + inputOutputVariable); + storeInputOutputVariables.add(inputOutputVariable); + storeInputOutputVariables.commitChanges(); - if (gridSelectedRowsEditing.isEditing()) { - gridSelectedRowsEditing.cancelEditing(); + if (gridInputOutputVariablesEditing.isEditing()) { + gridInputOutputVariablesEditing.cancelEditing(); } forceLayout(); } catch (Throwable e) { @@ -406,18 +406,18 @@ public class SelectedRowsPanel extends ContentPanel { } } - private void addSelectedRow(SelectEvent event) { + private void addInputOutputVariable(SelectEvent event) { try { Log.debug("Current Seq: " + seq); seq++; - SelectedRowsVariables newSelectedRowsVariable = new SelectedRowsVariables( + InputOutputVariables newInputOutputVariablesVariable = new InputOutputVariables( seq, "", "", "", DataType.STRING, IOType.INPUT, ""); - Log.debug("New Selected Rows Variable: " + newSelectedRowsVariable); - gridSelectedRowsEditing.cancelEditing(); + Log.debug("New Input/Output Variable: " + newInputOutputVariablesVariable); + gridInputOutputVariablesEditing.cancelEditing(); addStatus = true; - gridSelectedRowsEditing.getCancelButton().setVisible(false); - storeSelectedRows.add(newSelectedRowsVariable); - int row = storeSelectedRows.indexOf(newSelectedRowsVariable); + gridInputOutputVariablesEditing.getCancelButton().setVisible(false); + storeInputOutputVariables.add(newInputOutputVariablesVariable); + int row = storeInputOutputVariables.indexOf(newInputOutputVariablesVariable); storeComboDataType.clear(); storeComboDataType.addAll(DataType.asList()); @@ -427,39 +427,39 @@ public class SelectedRowsPanel extends ContentPanel { storeComboIOType.addAll(IOType.asList()); storeComboIOType.commitChanges(); - gridSelectedRowsEditing.startEditing(new GridCell(row, 0)); + gridInputOutputVariablesEditing.startEditing(new GridCell(row, 0)); } catch (Throwable e) { e.printStackTrace(); } } public void update(Project project) { - Log.debug("Update Selected Rows: " + project); + Log.debug("Update Input/Output Variables: " + project); if (project != null && project.getInputData() != null - && project.getInputData().getListSelectedRows() != null) { - storeSelectedRows.clear(); - storeSelectedRows.addAll(project.getInputData() - .getListSelectedRows()); - storeSelectedRows.commitChanges(); - seq = project.getInputData().getListSelectedRows().size(); + && project.getInputData().getListInputOutputVariables() != null) { + storeInputOutputVariables.clear(); + storeInputOutputVariables.addAll(project.getInputData() + .getListInputOutputVariables()); + storeInputOutputVariables.commitChanges(); + seq = project.getInputData().getListInputOutputVariables().size(); } else { - storeSelectedRows.clear(); - storeSelectedRows.commitChanges(); + storeInputOutputVariables.clear(); + storeInputOutputVariables.commitChanges(); seq=0; } } - public ArrayList getSelectedRows() { - ArrayList listEnviromentVarialbles = new ArrayList<>( - gridSelectedRows.getStore().getAll()); - return listEnviromentVarialbles; + public ArrayList getInputOutputVariables() { + ArrayList listInputOutputVarialbles = new ArrayList<>( + gridInputOutputVariables.getStore().getAll()); + return listInputOutputVarialbles; } public void setMainCode(Project project) { - storeSelectedRows.clear(); - storeSelectedRows.commitChanges(); + storeInputOutputVariables.clear(); + storeInputOutputVariables.commitChanges(); seq = 0; forceLayout(); diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/InputVariableMessages.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/InputVariableMessages.java index 421098c..e6bc20b 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/InputVariableMessages.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/InputVariableMessages.java @@ -11,11 +11,11 @@ import com.google.gwt.i18n.client.Messages; public interface InputVariableMessages extends Messages { // - @DefaultMessage("Selected Rows") - String selectedRows(); + @DefaultMessage("Input/Output") + String inputOutputVariables(); - @DefaultMessage("Enviroment Variables") - String environmentVariables(); + @DefaultMessage("Global Variables") + String globalVariables(); @DefaultMessage("Interpreter") String interpreterInfo(); diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/InputVariablePanel.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/InputVariablePanel.java index 7e4f342..7ca3f46 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/InputVariablePanel.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/InputVariablePanel.java @@ -3,7 +3,7 @@ package org.gcube.portlets.user.statisticalalgorithmsimporter.client.tools.input import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.InputRequestEvent; import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.NewSelectedRowsVariableEvent; import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.ProjectStatusEvent; -import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.SelectedRowsVariables; +import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.InputOutputVariables; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Project; import com.allen_sauer.gwt.log.client.Log; @@ -97,7 +97,7 @@ public class InputVariablePanel extends ContentPanel { } protected void addNewSelectedRowsVariable( - SelectedRowsVariables selectedRowsVariable) { + InputOutputVariables selectedRowsVariable) { inputVariableTabPanel.addSelectedRowsVariable(selectedRowsVariable); } diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/InputVariableTabPanel.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/InputVariableTabPanel.java index 9624ea3..852e6fe 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/InputVariableTabPanel.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/InputVariableTabPanel.java @@ -1,7 +1,7 @@ package org.gcube.portlets.user.statisticalalgorithmsimporter.client.tools.input; import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.InputReadyEvent; -import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.SelectedRowsVariables; +import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.InputOutputVariables; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.InputData; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Project; @@ -22,8 +22,8 @@ import com.sencha.gxt.widget.core.client.TabPanel; public class InputVariableTabPanel extends TabPanel { private InputVariableMessages msgs; private EventBus eventBus; - private EnvironmentVariablesPanel enviromentVariablesPanel; - private SelectedRowsPanel selectedRowsPanel; + private GlobalVariablesPanel globalVariablesPanel; + private InputOutputVariablesPanel inputOutputVariablesPanel; private InterpreterInfoPanel interpreterInfoPanel; private ProjectInfoPanel projectInfoPanel; @@ -48,8 +48,8 @@ public class InputVariableTabPanel extends TabPanel { public void startTabs(Project project) { Log.debug("Start InputVariable Tabs"); - addEnvironmentVariablesPanel(project); - addSelectedRowsPanel(project); + addGlobalVariablesPanel(project); + addInputOutputVariablesPanel(project); addInterpreterInfoPanel(project); addProjectInfoPanel(project); setActiveWidget(getWidget(0)); @@ -77,8 +77,8 @@ public class InputVariableTabPanel extends TabPanel { // public void setMainCode(Project project) { try { - enviromentVariablesPanel.setMainCode(project); - selectedRowsPanel.setMainCode(project); + globalVariablesPanel.setMainCode(project); + inputOutputVariablesPanel.setMainCode(project); forceLayout(); } catch (Throwable e) { @@ -91,8 +91,8 @@ public class InputVariableTabPanel extends TabPanel { public void updateTabs(Project project) { try { - enviromentVariablesPanel.update(project); - selectedRowsPanel.update(project); + globalVariablesPanel.update(project); + inputOutputVariablesPanel.update(project); interpreterInfoPanel.update(project); projectInfoPanel.update(project); forceLayout(); @@ -105,14 +105,14 @@ public class InputVariableTabPanel extends TabPanel { public void requestInput() { InputData inputData = new InputData(); - if (enviromentVariablesPanel != null) { - inputData.setListEnvironmentVariables(enviromentVariablesPanel - .getEnvironmentVariables()); + if (globalVariablesPanel != null) { + inputData.setListGlobalVariables(globalVariablesPanel + .getGlobalVariables()); } - if (selectedRowsPanel != null) { - inputData.setListSelectedRows(selectedRowsPanel - .getSelectedRows()); + if (inputOutputVariablesPanel != null) { + inputData.setListInputOutputVariables(inputOutputVariablesPanel + .getInputOutputVariables()); } if (interpreterInfoPanel != null) { @@ -134,24 +134,24 @@ public class InputVariableTabPanel extends TabPanel { } // Add - private void addSelectedRowsPanel(Project project) { - TabItemConfig selectedRowsPanelItemConf = new TabItemConfig( - msgs.selectedRows(), false); + private void addInputOutputVariablesPanel(Project project) { + TabItemConfig inputOutputPanelItemConf = new TabItemConfig( + msgs.inputOutputVariables(), false); - selectedRowsPanel = new SelectedRowsPanel(project, eventBus); - selectedRowsPanel.setHeaderVisible(false); - add(selectedRowsPanel, selectedRowsPanelItemConf); + inputOutputVariablesPanel = new InputOutputVariablesPanel(project, eventBus); + inputOutputVariablesPanel.setHeaderVisible(false); + add(inputOutputVariablesPanel, inputOutputPanelItemConf); } - private void addEnvironmentVariablesPanel(Project project) { - TabItemConfig enviromentVariablePanelItemConf = new TabItemConfig( - msgs.environmentVariables(), false); + private void addGlobalVariablesPanel(Project project) { + TabItemConfig globalVariablePanelItemConf = new TabItemConfig( + msgs.globalVariables(), false); - enviromentVariablesPanel = new EnvironmentVariablesPanel(project, + globalVariablesPanel = new GlobalVariablesPanel(project, eventBus); - enviromentVariablesPanel.setHeaderVisible(false); - add(enviromentVariablesPanel, enviromentVariablePanelItemConf); + globalVariablesPanel.setHeaderVisible(false); + add(globalVariablesPanel, globalVariablePanelItemConf); } private void addInterpreterInfoPanel(Project project) { @@ -176,9 +176,9 @@ public class InputVariableTabPanel extends TabPanel { public void addSelectedRowsVariable( - SelectedRowsVariables selectedRowsVariable) { - setActiveWidget(selectedRowsPanel); - selectedRowsPanel.addNewSelectedRowsVariable(selectedRowsVariable); + InputOutputVariables inputOutputVariable) { + setActiveWidget(inputOutputVariablesPanel); + inputOutputVariablesPanel.addNewInputOutputVariables(inputOutputVariable); } diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/InterpreterInfoPanel.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/InterpreterInfoPanel.java index 3ed71ef..fe79744 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/InterpreterInfoPanel.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/InterpreterInfoPanel.java @@ -82,17 +82,7 @@ public class InterpreterInfoPanel extends ContentPanel { } private void create(Project project) { - if (project != null - && project.getInputData() != null - && project.getInputData().getInterpreterInfo() != null - && project.getInputData().getInterpreterInfo() - .getInterpreterPackagesInfo() != null) { - seq = project.getInputData().getInterpreterInfo() - .getInterpreterPackagesInfo().size(); - } else { - seq = 0; - } - + // Grid InterpreterPackageInfoProperties props = GWT .create(InterpreterPackageInfoProperties.class); @@ -130,6 +120,10 @@ public class InterpreterInfoPanel extends ContentPanel { .getInterpreterPackagesInfo() != null) { storeInterpreterPackageInfo.addAll(project.getInputData() .getInterpreterInfo().getInterpreterPackagesInfo()); + seq = project.getInputData().getInterpreterInfo() + .getInterpreterPackagesInfo().size(); + } else { + seq = 0; } final GridSelectionModel sm = new GridSelectionModel(); @@ -349,6 +343,8 @@ public class InterpreterInfoPanel extends ContentPanel { interpreterVersion.setValue(project.getInputData() .getInterpreterInfo().getVersion()); + } else { + interpreterVersion.clear(); } if (project.getInputData().getInterpreterInfo() @@ -358,7 +354,7 @@ public class InterpreterInfoPanel extends ContentPanel { storeInterpreterPackageInfo.addAll(project.getInputData() .getInterpreterInfo().getInterpreterPackagesInfo()); storeInterpreterPackageInfo.commitChanges(); - seq = project.getInputData().getListSelectedRows().size(); + seq = project.getInputData().getInterpreterInfo().getInterpreterPackagesInfo().size(); } else { seq = 0; } diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/ProjectInfoPanel.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/ProjectInfoPanel.java index 84e0fdb..5be7763 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/ProjectInfoPanel.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/ProjectInfoPanel.java @@ -3,9 +3,9 @@ package org.gcube.portlets.user.statisticalalgorithmsimporter.client.tools.input import java.util.ArrayList; import java.util.List; -import org.gcube.portlets.user.statisticalalgorithmsimporter.client.properties.DeployableVREProperties; +import org.gcube.portlets.user.statisticalalgorithmsimporter.client.properties.RequestedVREProperties; import org.gcube.portlets.user.statisticalalgorithmsimporter.client.resource.StatAlgoImporterResources; -import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.DeployableVRE; +import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.RequestedVRE; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.ProjectInfo; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Project; @@ -56,11 +56,11 @@ public class ProjectInfoPanel extends ContentPanel { @SuppressWarnings("unused") private EventBus eventBus; - private TextField packageName; - private TextField packageDescription; - private ListStore storeDeployableVRE; - private Grid gridDeployableVRE; - private GridRowEditing gridDeployableVREEditing; + private TextField algorithmName; + private TextField algorithmDescription; + private ListStore storeRequestedVRE; + private Grid gridRequestedVRE; + private GridRowEditing gridRequestedVREEditing; private TextButton btnAdd; private boolean addStatus; private int seq = 0; @@ -89,86 +89,87 @@ public class ProjectInfoPanel extends ContentPanel { private void create(Project project) { - packageName = new TextField(); - packageName.setAllowBlank(false); - packageName.addValidator(new RegExValidator("^[a-zA-Z0-9]*$", "Attention only characters a-z,A-Z,0-9 are allowed")); - packageName.setEmptyText("Enter name..."); - packageName.addChangeHandler(new ChangeHandler() { - + algorithmName = new TextField(); + algorithmName.setAllowBlank(false); + algorithmName.addValidator(new RegExValidator("^[a-zA-Z0-9_]*$", + "Attention only characters a-z,A-Z,0-9 are allowed")); + algorithmName.setEmptyText("Enter name..."); + algorithmName.addChangeHandler(new ChangeHandler() { + @Override public void onChange(ChangeEvent event) { - packageName.validate(); - + algorithmName.validate(); + } }); - - FieldLabel packageNameLabel = new FieldLabel(packageName, "Name"); - - packageDescription = new TextField(); - packageDescription.setAllowBlank(false); - packageDescription.setEmptyText("Enter description..."); - FieldLabel projectDescriptionLabel = new FieldLabel(packageDescription, - "Description"); - - if (project != null && project.getInputData() != null - && project.getInputData().getProjectInfo() != null) { - if (project.getInputData().getProjectInfo().getPackageName() != null) { - packageName.setValue(project.getInputData().getProjectInfo() - .getPackageName()); - } - if (project.getInputData().getProjectInfo().getPackageDescription() != null) { - packageDescription.setValue(project.getInputData() - .getProjectInfo().getPackageDescription()); - } + FieldLabel packageNameLabel = new FieldLabel(algorithmName, "Name"); - } + algorithmDescription = new TextField(); + algorithmDescription.setAllowBlank(false); + algorithmDescription.setEmptyText("Enter description..."); + FieldLabel projectDescriptionLabel = new FieldLabel( + algorithmDescription, "Description"); // Grid - DeployableVREProperties props = GWT - .create(DeployableVREProperties.class); + RequestedVREProperties props = GWT + .create(RequestedVREProperties.class); - ColumnConfig nameColumn = new ColumnConfig( + ColumnConfig nameColumn = new ColumnConfig( props.name(), 100, "Name"); // nameColumn.setMenuDisabled(true); - ColumnConfig descriptionColumn = new ColumnConfig( + ColumnConfig descriptionColumn = new ColumnConfig( props.description(), 100, "Description"); // descriptionColumn.setMenuDisabled(true); - ArrayList> l = new ArrayList>(); + ArrayList> l = new ArrayList>(); l.add(nameColumn); l.add(descriptionColumn); - ColumnModel columns = new ColumnModel(l); + ColumnModel columns = new ColumnModel(l); - storeDeployableVRE = new ListStore(props.id()); + storeRequestedVRE = new ListStore(props.id()); + + if (project != null && project.getInputData() != null + && project.getInputData().getProjectInfo() != null) { + + if (project.getInputData().getProjectInfo().getAlgorithmName() != null) { + algorithmName.setValue(project.getInputData().getProjectInfo() + .getAlgorithmName()); + } + if (project.getInputData().getProjectInfo() + .getAlgorithmDescription() != null) { + algorithmDescription.setValue(project.getInputData() + .getProjectInfo().getAlgorithmDescription()); + } + + if (project.getInputData().getProjectInfo().getListRequestedVRE() != null) { + storeRequestedVRE.addAll(project.getInputData() + .getProjectInfo().getListRequestedVRE()); + seq = project.getInputData().getProjectInfo() + .getListRequestedVRE().size(); + } - if (project != null && project.getInputData() != null && project.getInputData().getProjectInfo()!=null - && project.getInputData().getProjectInfo().getListDeployableVRE() != null) { - storeDeployableVRE.addAll(project.getInputData().getProjectInfo() - .getListDeployableVRE()); - seq = project.getInputData().getProjectInfo() - .getListDeployableVRE().size(); } - final GridSelectionModel sm = new GridSelectionModel(); + final GridSelectionModel sm = new GridSelectionModel(); sm.setSelectionMode(SelectionMode.SINGLE); - gridDeployableVRE = new Grid(storeDeployableVRE, columns); - gridDeployableVRE.setSelectionModel(sm); - gridDeployableVRE.getView().setStripeRows(true); - gridDeployableVRE.getView().setColumnLines(true); - gridDeployableVRE.getView().setAutoExpandColumn(nameColumn); - gridDeployableVRE.getView().setAutoFill(true); - gridDeployableVRE.setBorders(false); - gridDeployableVRE.setColumnReordering(false); + gridRequestedVRE = new Grid(storeRequestedVRE, columns); + gridRequestedVRE.setSelectionModel(sm); + gridRequestedVRE.getView().setStripeRows(true); + gridRequestedVRE.getView().setColumnLines(true); + gridRequestedVRE.getView().setAutoExpandColumn(nameColumn); + gridRequestedVRE.getView().setAutoFill(true); + gridRequestedVRE.setBorders(false); + gridRequestedVRE.setColumnReordering(false); // EDITING // - gridDeployableVREEditing = new GridRowEditing( - gridDeployableVRE); - gridDeployableVREEditing.addEditor(nameColumn, new TextField()); - gridDeployableVREEditing.addEditor(descriptionColumn, new TextField()); + gridRequestedVREEditing = new GridRowEditing( + gridRequestedVRE); + gridRequestedVREEditing.addEditor(nameColumn, new TextField()); + gridRequestedVREEditing.addEditor(descriptionColumn, new TextField()); btnAdd = new TextButton("Add"); btnAdd.setIcon(StatAlgoImporterResources.INSTANCE.add16()); @@ -179,7 +180,7 @@ public class ProjectInfoPanel extends ContentPanel { @Override public void onSelect(SelectEvent event) { - addDeployableVRE(event); + addRequestedVRE(event); } }); @@ -187,77 +188,77 @@ public class ProjectInfoPanel extends ContentPanel { TextButton btnDelete = new TextButton("Delete"); btnDelete.addSelectHandler(new SelectEvent.SelectHandler() { public void onSelect(SelectEvent event) { - GridCell cell = gridDeployableVREEditing.getActiveCell(); + GridCell cell = gridRequestedVREEditing.getActiveCell(); int rowIndex = cell.getRow(); - gridDeployableVREEditing.cancelEditing(); + gridRequestedVREEditing.cancelEditing(); - storeDeployableVRE.remove(rowIndex); - storeDeployableVRE.commitChanges(); + storeRequestedVRE.remove(rowIndex); + storeRequestedVRE.commitChanges(); - gridDeployableVREEditing.getCancelButton().setVisible(true); + gridRequestedVREEditing.getCancelButton().setVisible(true); btnAdd.setEnabled(true); if (addStatus) { addStatus = false; } - List listSelected = storeDeployableVRE.getAll(); - List listNewSelected = new ArrayList(); + List listSelected = storeRequestedVRE.getAll(); + List listNewSelected = new ArrayList(); for (int i = 0; i < listSelected.size(); i++) { - DeployableVRE var = listSelected.get(i); + RequestedVRE var = listSelected.get(i); var.setId(i); listNewSelected.add(var); } - storeDeployableVRE.clear(); - storeDeployableVRE.addAll(listNewSelected); - storeDeployableVRE.commitChanges(); + storeRequestedVRE.clear(); + storeRequestedVRE.addAll(listNewSelected); + storeRequestedVRE.commitChanges(); seq = listNewSelected.size(); Log.debug("Current Seq: " + seq); } }); - ButtonBar buttonBar = gridDeployableVREEditing.getButtonBar(); + ButtonBar buttonBar = gridRequestedVREEditing.getButtonBar(); buttonBar.add(btnDelete); - gridDeployableVREEditing - .addBeforeStartEditHandler(new BeforeStartEditHandler() { + gridRequestedVREEditing + .addBeforeStartEditHandler(new BeforeStartEditHandler() { @Override public void onBeforeStartEdit( - BeforeStartEditEvent event) { + BeforeStartEditEvent event) { editingBeforeStart(event); } }); - gridDeployableVREEditing - .addCancelEditHandler(new CancelEditHandler() { + gridRequestedVREEditing + .addCancelEditHandler(new CancelEditHandler() { @Override public void onCancelEdit( - CancelEditEvent event) { - storeDeployableVRE.rejectChanges(); + CancelEditEvent event) { + storeRequestedVRE.rejectChanges(); btnAdd.setEnabled(true); } }); - gridDeployableVREEditing - .addCompleteEditHandler(new CompleteEditHandler() { + gridRequestedVREEditing + .addCompleteEditHandler(new CompleteEditHandler() { @Override public void onCompleteEdit( - CompleteEditEvent event) { + CompleteEditEvent event) { try { if (addStatus) { addStatus = false; } - storeDeployableVRE.commitChanges(); + storeRequestedVRE.commitChanges(); - gridDeployableVREEditing.getCancelButton() + gridRequestedVREEditing.getCancelButton() .setVisible(true); btnAdd.setEnabled(true); @@ -269,7 +270,7 @@ public class ProjectInfoPanel extends ContentPanel { }); // / - FieldLabel deployableVRELabel = new FieldLabel(null, "Deployable VRE"); + FieldLabel requestedVRELabel = new FieldLabel(null, "Requested VREs"); ToolBar toolBar = new ToolBar(); toolBar.add(btnAdd, new BoxLayoutData(new Margins(0))); @@ -281,9 +282,10 @@ public class ProjectInfoPanel extends ContentPanel { vlc.add(packageNameLabel, new VerticalLayoutData(1, -1, new Margins(0))); vlc.add(projectDescriptionLabel, new VerticalLayoutData(1, -1, new Margins(0))); - vlc.add(deployableVRELabel, new VerticalLayoutData(1, -1, new Margins(0))); + vlc.add(requestedVRELabel, new VerticalLayoutData(1, -1, + new Margins(0))); vlc.add(toolBar, new VerticalLayoutData(1, -1, new Margins(0))); - vlc.add(gridDeployableVRE, new VerticalLayoutData(1, 1, new Margins(0))); + vlc.add(gridRequestedVRE, new VerticalLayoutData(1, 1, new Margins(0))); add(vlc, new MarginData(new Margins(0))); } @@ -293,72 +295,73 @@ public class ProjectInfoPanel extends ContentPanel { if (project != null && project.getInputData() != null && project.getInputData().getProjectInfo() != null) { - if (project.getInputData().getProjectInfo().getPackageName() != null) { - packageName.setValue(project.getInputData().getProjectInfo() - .getPackageName()); + if (project.getInputData().getProjectInfo().getAlgorithmName() != null) { + algorithmName.setValue(project.getInputData().getProjectInfo() + .getAlgorithmName()); } else { - packageName.clear(); + algorithmName.clear(); } - if (project.getInputData().getProjectInfo().getPackageDescription() != null) { - packageDescription.setValue(project.getInputData() - .getProjectInfo().getPackageDescription()); + if (project.getInputData().getProjectInfo() + .getAlgorithmDescription() != null) { + algorithmDescription.setValue(project.getInputData() + .getProjectInfo().getAlgorithmDescription()); } else { - packageDescription.clear(); + algorithmDescription.clear(); } - if (project.getInputData().getProjectInfo().getListDeployableVRE() != null) { - storeDeployableVRE.clear(); - storeDeployableVRE.addAll(project.getInputData() - .getProjectInfo().getListDeployableVRE()); - storeDeployableVRE.commitChanges(); + if (project.getInputData().getProjectInfo().getListRequestedVRE() != null) { + storeRequestedVRE.clear(); + storeRequestedVRE.addAll(project.getInputData() + .getProjectInfo().getListRequestedVRE()); + storeRequestedVRE.commitChanges(); seq = project.getInputData().getProjectInfo() - .getListDeployableVRE().size(); + .getListRequestedVRE().size(); } else { - storeDeployableVRE.clear(); - storeDeployableVRE.commitChanges(); + storeRequestedVRE.clear(); + storeRequestedVRE.commitChanges(); seq = 0; } } else { - packageName.clear(); - packageDescription.clear(); - storeDeployableVRE.clear(); - storeDeployableVRE.commitChanges(); + algorithmName.clear(); + algorithmDescription.clear(); + storeRequestedVRE.clear(); + storeRequestedVRE.commitChanges(); seq = 0; } } - private void editingBeforeStart(BeforeStartEditEvent event) { + private void editingBeforeStart(BeforeStartEditEvent event) { // TODO Auto-generated method stub } - private void addDeployableVRE(SelectEvent event) { + private void addRequestedVRE(SelectEvent event) { try { seq++; - DeployableVRE newEnvironmentVariable = new DeployableVRE(seq, "", + RequestedVRE newRequestedVRE = new RequestedVRE(seq, "", ""); - Log.debug("New DeployableVRE: " + newEnvironmentVariable); - gridDeployableVREEditing.cancelEditing(); + Log.debug("New RequestedVRE: " + newRequestedVRE); + gridRequestedVREEditing.cancelEditing(); addStatus = true; - gridDeployableVREEditing.getCancelButton().setVisible(false); - storeDeployableVRE.add(newEnvironmentVariable); - int row = storeDeployableVRE.indexOf(newEnvironmentVariable); + gridRequestedVREEditing.getCancelButton().setVisible(false); + storeRequestedVRE.add(newRequestedVRE); + int row = storeRequestedVRE.indexOf(newRequestedVRE); - gridDeployableVREEditing.startEditing(new GridCell(row, 0)); + gridRequestedVREEditing.startEditing(new GridCell(row, 0)); } catch (Throwable e) { e.printStackTrace(); } } public ProjectInfo getProjectInfo() { - String name = packageName.getCurrentValue(); - String description = packageDescription.getCurrentValue(); - ArrayList listDeployableVRE = new ArrayList<>( - gridDeployableVRE.getStore().getAll()); - return new ProjectInfo(name, description, listDeployableVRE); + String name = algorithmName.getCurrentValue(); + String description = algorithmDescription.getCurrentValue(); + ArrayList listRequestedVRE = new ArrayList<>( + gridRequestedVRE.getStore().getAll()); + return new ProjectInfo(name, description, listRequestedVRE); } } diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/StatAlgoImporterServiceImpl.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/StatAlgoImporterServiceImpl.java index 26a4288..4544bec 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/StatAlgoImporterServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/StatAlgoImporterServiceImpl.java @@ -10,8 +10,8 @@ import org.gcube.portlets.user.statisticalalgorithmsimporter.client.rpc.StatAlgo import org.gcube.portlets.user.statisticalalgorithmsimporter.server.file.CodeReader; import org.gcube.portlets.user.statisticalalgorithmsimporter.server.generator.ProjectBuilder; import org.gcube.portlets.user.statisticalalgorithmsimporter.server.storage.FilesStorage; +import org.gcube.portlets.user.statisticalalgorithmsimporter.server.storage.MainCodeSave; import org.gcube.portlets.user.statisticalalgorithmsimporter.server.storage.ProjectArchiver; -import org.gcube.portlets.user.statisticalalgorithmsimporter.server.uriresolver.UriResolverSMIClient; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.code.CodeData; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterServiceException; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.file.FileUploadMonitor; @@ -78,6 +78,27 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements } } + + @Override + public Project restoreUISession(String value) + throws StatAlgoImporterServiceException { + try { + HttpSession session = this.getThreadLocalRequest().getSession(); + SessionUtil.getAslSession(session); + logger.debug("restoreUISession(): "+value); + Project project = SessionUtil.getProjectSession(session); + return project; + } catch (StatAlgoImporterServiceException e) { + e.printStackTrace(); + throw e; + } catch (Throwable e) { + logger.error("getCode(): " + e.getLocalizedMessage(), e); + e.printStackTrace(); + throw new StatAlgoImporterServiceException(e.getLocalizedMessage()); + } + + } + /** * @@ -354,6 +375,39 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements } + @Override + public ItemDescription setNewMainCode(ItemDescription fileDescription, String code) + throws StatAlgoImporterServiceException { + try { + HttpSession session = this.getThreadLocalRequest().getSession(); + ASLSession aslSession = SessionUtil.getAslSession(session); + logger.debug("saveCode(): itemDescription" + fileDescription+", code:"+code); + Project project = SessionUtil.getProjectSession(session); + if (project != null && project.getProjectFolder()!=null&&project.getProjectFolder().getItemDescription()!=null) { + MainCodeSave mainCodeSave=new MainCodeSave(); + ItemDescription mainCodeItemDescription=mainCodeSave.save(aslSession, fileDescription, code,project); + MainCode mainCode=new MainCode(mainCodeItemDescription); + project.setMainCode(mainCode); + SessionUtil.setProjectSession(session, project); + return mainCodeItemDescription; + } else { + throw new StatAlgoImporterServiceException("No project open!"); + } + + + } catch (StatAlgoImporterServiceException e) { + e.printStackTrace(); + throw e; + } catch (Throwable e) { + logger.error("saveCode(): " + e.getLocalizedMessage(), e); + e.printStackTrace(); + throw new StatAlgoImporterServiceException(e.getLocalizedMessage()); + } + + + } + + @Override public void createSoftware(InputData inputData) throws StatAlgoImporterServiceException { @@ -384,24 +438,29 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements } @Override - public String getUriFromResolver(ItemDescription itemDescription) + public String getPublicLink(ItemDescription itemDescription) throws StatAlgoImporterServiceException { try { HttpSession session = this.getThreadLocalRequest().getSession(); ASLSession aslSession = SessionUtil.getAslSession(session); - logger.debug("GetUriFromResolver(): "+itemDescription); - UriResolverSMIClient resolver=new UriResolverSMIClient(); - String link=resolver.resolve(itemDescription, aslSession); + logger.debug("GetPublicLink(): "+itemDescription); + FilesStorage filesStorage=new FilesStorage(); + String link=filesStorage.getPublicLink(aslSession.getUsername(),itemDescription.getId()); + return link; } catch (StatAlgoImporterServiceException e) { e.printStackTrace(); throw e; } catch (Throwable e) { - logger.error("getUriFromResolver(): " + e.getLocalizedMessage(), e); + logger.error("getPublicLink(): " + e.getLocalizedMessage(), e); e.printStackTrace(); throw new StatAlgoImporterServiceException(e.getLocalizedMessage()); } } + + + + } diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/generator/AlgorithmGenerator.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/generator/AlgorithmGenerator.java index 2691219..b616596 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/generator/AlgorithmGenerator.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/generator/AlgorithmGenerator.java @@ -10,9 +10,9 @@ import java.util.Arrays; import java.util.List; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterServiceException; -import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.EnvironmentVariables; +import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.GlobalVariables; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.IOType; -import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.SelectedRowsVariables; +import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.InputOutputVariables; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Project; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -45,7 +45,7 @@ public class AlgorithmGenerator { try { Path tempFile = Files.createTempFile(project.getInputData() - .getProjectInfo().getPackageName(), EXTENTION_JAVA); + .getProjectInfo().getAlgorithmNameToClassName(), EXTENTION_JAVA); List lines = createJavaCode(); Files.write(tempFile, lines, Charset.defaultCharset(), @@ -80,7 +80,7 @@ public class AlgorithmGenerator { "import org.gcube.dataanalysis.executor.rscripts.generic.GenericRScript;", "", "public class " + project.getInputData().getProjectInfo() - .getPackageName() + .getAlgorithmNameToClassName() + " extends GenericRScript {", "", " public static enum operators {", @@ -88,20 +88,20 @@ public class AlgorithmGenerator { " };", "", " @Override", " public String getDescription() {", " return \"" + project.getInputData().getProjectInfo() - .getPackageDescription() + "\";", " }", "", + .getAlgorithmDescription() + "\";", " }", "", " protected void initVariables(){", " mainScriptName=\"" + mainScriptRelativePath + "\";", " packageURL=\"" + packageUrl + "\";", " environmentalvariables = new ArrayList();")); - for (EnvironmentVariables envVariable : project.getInputData() - .getListEnvironmentVariables()) { + for (GlobalVariables envVariable : project.getInputData() + .getListGlobalVariables()) { code.add(" environmentalvariables.add(\"" + envVariable.getName() + "\");"); } - for (SelectedRowsVariables selVariable : project.getInputData() - .getListSelectedRows()) { + for (InputOutputVariables selVariable : project.getInputData() + .getListInputOutputVariables()) { switch (selVariable.getIoType()) { case INPUT: code.add(" inputvariables.add(\"" + selVariable.getName() @@ -137,8 +137,8 @@ public class AlgorithmGenerator { private void createInputParameters(ArrayList code) { - for (SelectedRowsVariables selVariable : project.getInputData() - .getListSelectedRows()) { + for (InputOutputVariables selVariable : project.getInputData() + .getListInputOutputVariables()) { if (selVariable.getIoType().compareTo(IOType.INPUT) == 0) { switch (selVariable.getDataType()) { case BOOLEAN: @@ -208,8 +208,8 @@ public class AlgorithmGenerator { */ private void createOutputParameters(ArrayList code) { - for (SelectedRowsVariables selVariable : project.getInputData() - .getListSelectedRows()) { + for (InputOutputVariables selVariable : project.getInputData() + .getListInputOutputVariables()) { if (selVariable.getIoType().compareTo(IOType.OUTPUT) == 0) { switch (selVariable.getDataType()) { case BOOLEAN: diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/generator/InfoGenerator.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/generator/InfoGenerator.java index a0170d7..c1fc153 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/generator/InfoGenerator.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/generator/InfoGenerator.java @@ -9,7 +9,7 @@ import java.util.ArrayList; import java.util.List; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterServiceException; -import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.DeployableVRE; +import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.RequestedVRE; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.InterpreterPackageInfo; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Project; import org.slf4j.Logger; @@ -22,7 +22,8 @@ import org.slf4j.LoggerFactory; * */ public class InfoGenerator { - private static final String EXTENTION_TXT = ".txt"; + private static final String INFO_NAME = "Info"; + private static final String INFO_EXTENTION = ".txt"; public static final Logger logger = LoggerFactory .getLogger(InfoGenerator.class); @@ -38,13 +39,12 @@ public class InfoGenerator { return "IntegrationInfoGenerator [project=" + project + "]"; } - public Path createIntegrationInfo() throws StatAlgoImporterServiceException { + public Path createInfo() throws StatAlgoImporterServiceException { try { - Path tempFile = Files.createTempFile(project.getInputData() - .getProjectInfo().getPackageName(), EXTENTION_TXT); + Path tempFile = Files.createTempFile(INFO_NAME, INFO_EXTENTION); - List lines = createInfo(); + List lines = createInfoData(); Files.write(tempFile, lines, Charset.defaultCharset(), StandardOpenOption.WRITE); logger.debug(tempFile.toString()); @@ -59,35 +59,39 @@ public class InfoGenerator { } - private List createInfo() { + private List createInfoData() { ArrayList infos = new ArrayList(); if (project.getInputData() != null) { if (project.getInputData().getProjectInfo() != null) { - if (project.getInputData().getProjectInfo().getPackageName() != null) { - infos.add("Package Name: " + if (project.getInputData().getProjectInfo().getAlgorithmName() != null) { + infos.add("Algorithm Name: " + project.getInputData().getProjectInfo() - .getPackageName()); + .getAlgorithmNameToUpper()); + infos.add("Class Name: org.gcube.dataanalysis.executor.rscripts."+ project.getInputData().getProjectInfo() + .getAlgorithmNameToUpper()); + } else { - infos.add("Package Name: "); + infos.add("Algorithm Name: "); + infos.add("Class Name: "); } infos.add(""); - if (project.getInputData().getProjectInfo().getPackageDescription() != null) { - infos.add("Package Description: " + if (project.getInputData().getProjectInfo().getAlgorithmDescription() != null) { + infos.add("Algorithm Description: " + project.getInputData().getProjectInfo() - .getPackageDescription()); + .getAlgorithmDescription()); } else { - infos.add("Package Description: "); + infos.add("Algorithm Description: "); } infos.add(""); if (project.getInputData().getProjectInfo() - .getListDeployableVRE() != null + .getListRequestedVRE() != null && project.getInputData().getProjectInfo() - .getListDeployableVRE().size() > 0) { + .getListRequestedVRE().size() > 0) { infos.add("Deployable VRE:"); - for (DeployableVRE deployableVRE : project.getInputData() - .getProjectInfo().getListDeployableVRE()) { - infos.add("" + deployableVRE.getName() + ", " + deployableVRE.getDescription()); + for (RequestedVRE deployableVRE : project.getInputData() + .getProjectInfo().getListRequestedVRE()) { + infos.add("" + deployableVRE.getName() + " " + deployableVRE.getDescription()); } infos.add(""); } diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/generator/ProjectBuilder.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/generator/ProjectBuilder.java index 6c1c057..20ad6f5 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/generator/ProjectBuilder.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/generator/ProjectBuilder.java @@ -94,9 +94,9 @@ public class ProjectBuilder { "Attention No Project Information Set!"); } - if (project.getInputData().getProjectInfo().getPackageName() == null) { + if (project.getInputData().getProjectInfo().getAlgorithmName() == null) { throw new StatAlgoImporterServiceException( - "Attention No Project Class Name Set!"); + "Attention No Algorithm Name Set!"); } if (project.getMainCode() == null) { @@ -133,7 +133,7 @@ public class ProjectBuilder { algorithmItem = filesStorage.createItemOnWorkspace(aslSession .getUsername(), Files.newInputStream(algorithmJava, StandardOpenOption.READ), project.getInputData() - .getProjectInfo().getPackageName() + .getProjectInfo().getAlgorithmNameToClassName() + ALGORITHM_EXTENTION, ALGORITHM_DESCRIPTION, ALGORITHM_MIMETYPE, project.getProjectTarget() .getTargetFolder().getId()); @@ -207,7 +207,7 @@ public class ProjectBuilder { try { projectPackageItem = filesStorage.createItemOnWorkspace( aslSession.getUsername(), inputStream, project - .getInputData().getProjectInfo().getPackageName() + .getInputData().getProjectInfo().getAlgorithmNameToClassName() + PROJECT_PACKAGE_EXTENTION, PROJECT_PACKAGE_DESCRIPTION, PROJECT_PACKAGE_MIMETYPE, targetFolder.getId()); @@ -242,7 +242,7 @@ public class ProjectBuilder { throws StatAlgoImporterServiceException { InfoGenerator integrationInfoGenerator = new InfoGenerator( project); - infoTXT = integrationInfoGenerator.createIntegrationInfo(); + infoTXT = integrationInfoGenerator.createInfo(); FilesStorage filesStorage = new FilesStorage(); WorkspaceItem infoItem; @@ -297,7 +297,7 @@ public class ProjectBuilder { storage.downloadInputFile(ECOLOGICAL_ENGINE_SMART_EXECUTOR_JAR_URL, ecologicalEngineSmartExecutorJar); Path algorithmTempFile = new File(tempDirectory.toFile(), project - .getInputData().getProjectInfo().getPackageName() + .getInputData().getProjectInfo().getAlgorithmNameToClassName() + ALGORITHM_EXTENTION).toPath(); Files.copy(algorithmJava, algorithmTempFile); Path infoTempFile = new File(tempDirectory.toFile(), @@ -322,7 +322,7 @@ public class ProjectBuilder { } private void copyJarOnWorkspace(Path tempDirectory) throws StatAlgoImporterServiceException { - Path codeJar=Paths.get(tempDirectory.toString(),project.getInputData().getProjectInfo().getPackageName() + Path codeJar=Paths.get(tempDirectory.toString(),project.getInputData().getProjectInfo().getAlgorithmNameToClassName() + JAR_EXTENTION); FilesStorage filesStorage = new FilesStorage(); @@ -331,7 +331,7 @@ public class ProjectBuilder { try { codeJarItem = filesStorage.createItemOnWorkspace(aslSession .getUsername(), Files.newInputStream(codeJar, - StandardOpenOption.READ), project.getInputData().getProjectInfo().getPackageName() + StandardOpenOption.READ), project.getInputData().getProjectInfo().getAlgorithmNameToClassName() + JAR_EXTENTION, CODE_JAR_DESCRIPTION, CODE_JAR_MIMETYPE, project.getProjectTarget() .getTargetFolder().getId()); @@ -369,7 +369,7 @@ public class ProjectBuilder { ProcessBuilder pb = new ProcessBuilder("javac", "-cp", tempDirectory.toAbsolutePath().toString() + "/*", project - .getInputData().getProjectInfo().getPackageName() + .getInputData().getProjectInfo().getAlgorithmNameToClassName() + ALGORITHM_EXTENTION); pb.directory(tempDirectory.toFile()); Path logTXT = new File(tempDirectory.toFile(), LOG_TXT).toPath(); @@ -398,7 +398,7 @@ public class ProjectBuilder { List commands = new ArrayList<>(); commands.add("jar"); commands.add("-cvf"); - commands.add(project.getInputData().getProjectInfo().getPackageName() + commands.add(project.getInputData().getProjectInfo().getAlgorithmNameToClassName() + JAR_EXTENTION); DirectoryStream directoryStream = Files diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/social/AlgorithmNotification.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/social/AlgorithmNotification.java new file mode 100644 index 0000000..1b428de --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/social/AlgorithmNotification.java @@ -0,0 +1,80 @@ +package org.gcube.portlets.user.statisticalalgorithmsimporter.server.social; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.gcube.application.framework.core.session.ASLSession; +import org.gcube.applicationsupportlayer.social.ApplicationNotificationsManager; +import org.gcube.applicationsupportlayer.social.NotificationsManager; +import org.gcube.common.homelibrary.util.WorkspaceUtil; +import org.gcube.portal.databook.shared.NotificationType; +import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.Constants; +import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Project; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * TDMNotification notification sharing TR, templates or rules + * + * @author giancarlo email: g.panichi@isti.cnr.it + * + */ +public class AlgorithmNotification extends Thread { + private static Logger logger = LoggerFactory + .getLogger(AlgorithmNotification.class); + private ASLSession aslSession; + private NotificationType notificationType; + private Project project; + + public AlgorithmNotification(ASLSession aslSession, Project project) { + this.aslSession = aslSession; + this.project = project; + //this.notificationType = NotificationType.SAI_ALGORITHM_PUBLICATION; + + } + + public void run() { + algorithmPublicationNotify(); + + } + + private void algorithmPublicationNotify() { + NotificationsManager nm = new ApplicationNotificationsManager( + aslSession, Constants.APPLICATION_ID); + /* + List members = Arrays.asList("gianpaolo.coro", + "giancarlo.panichi", "roberto.cirillo"); + for (String member : members) { + try { + nm.notifyAlgorithmPublicationRequest( + member, + project.getInputData().getProjectInfo() + .getAlgorithmName(), + new String( + Constants.STATISTICAL_ALGORITHMS_IMPORTER_JAR_PUBLIC_LINK + + "=" + + project.getProjectTarget() + .getCodeJar().getPublicLink())); + + } catch (Exception e) { + logger.error("Error in the notification(Type: " + + notificationType + + " - " + + aslSession.getUsername() + + " =" + + "Algorithm [AlgorithmName=" + + project.getInputData().getProjectInfo() + .getAlgorithmName() + + ", JarPublicLink=" + + project.getProjectTarget().getCodeJar() + .getPublicLink() + "] to " + member + "): " + + e.getLocalizedMessage()); + e.printStackTrace(); + } + }*/ + + } + +} diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/storage/FilesStorage.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/storage/FilesStorage.java index 1d55b88..c105d1d 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/storage/FilesStorage.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/storage/FilesStorage.java @@ -22,6 +22,7 @@ import org.gcube.common.homelibrary.home.workspace.exceptions.ItemNotFoundExcept import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException; import org.gcube.common.homelibrary.home.workspace.exceptions.WrongDestinationException; import org.gcube.common.homelibrary.home.workspace.exceptions.WrongItemTypeException; +import org.gcube.common.homelibrary.home.workspace.folder.FolderItem; import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalFile; import org.gcube.common.homelibrary.util.zip.ZipUtil; import org.gcube.contentmanager.storageclient.model.protocol.smp.SMPUrl; @@ -46,6 +47,52 @@ public class FilesStorage { public static final Logger logger = LoggerFactory .getLogger(FilesStorage.class); + /** + * + * @param user + * User + * @param itemId + * Item id + * @return Public link + * @throws StatAlgoImporterServiceException + */ + public String getPublicLink(String user, String itemId) + throws StatAlgoImporterServiceException { + Workspace ws; + try { + ws = HomeLibrary.getUserWorkspace(user); + + WorkspaceItem workSpaceItem = ws.getItem(itemId); + if (workSpaceItem.isFolder()) { + throw new StatAlgoImporterServiceException( + "Attention this is a folder!"); + } + + if (workSpaceItem instanceof FolderItem) { + return workSpaceItem.getPublicLink(true); + } else { + throw new StatAlgoImporterServiceException( + "Attention no public link for this item!"); + } + + } catch (WorkspaceFolderNotFoundException | InternalErrorException + | HomeNotFoundException | ItemNotFoundException e) { + e.printStackTrace(); + throw new StatAlgoImporterServiceException(e.getLocalizedMessage()); + + } + } + + /** + * + * @param user + * User + * @param itemId + * Item id + * @param folderId + * Folder id + * @throws StatAlgoImporterServiceException + */ public void copyItemOnFolder(String user, String itemId, String folderId) throws StatAlgoImporterServiceException { Workspace ws; @@ -71,6 +118,14 @@ public class FilesStorage { } } + /** + * + * @param user + * User + * @param itemId + * Item id + * @throws StatAlgoImporterServiceException + */ public void deleteItemOnFolder(String user, String itemId) throws StatAlgoImporterServiceException { Workspace ws; @@ -90,6 +145,14 @@ public class FilesStorage { } + /** + * + * @param user + * User + * @param folderId + * Foler id + * @throws StatAlgoImporterServiceException + */ public void deleteTargetFolder(String user, String folderId) throws StatAlgoImporterServiceException { Workspace ws; @@ -120,6 +183,15 @@ public class FilesStorage { } + /** + * + * @param user + * User + * @param folderId + * Destination folder id + * @return Folder + * @throws StatAlgoImporterServiceException + */ public WorkspaceFolder createTargetFolder(String user, String folderId) throws StatAlgoImporterServiceException { Workspace ws; @@ -147,6 +219,16 @@ public class FilesStorage { } + /** + * + * @param user + * user + * @param inputStream + * input stream + * @param folderId + * destination folder + * @throws StatAlgoImporterServiceException + */ public void saveStatisticalAlgorithmProject(String user, InputStream inputStream, String folderId) throws StatAlgoImporterServiceException { @@ -183,6 +265,22 @@ public class FilesStorage { } } + /** + * + * @param user + * user + * @param inputStream + * input stream + * @param name + * item name + * @param description + * item description + * @param mimeType + * item mimetype + * @param folderId + * destination folder + * @throws StatAlgoImporterServiceException + */ public void saveItemOnWorkspace(String user, InputStream inputStream, String name, String description, String mimeType, String folderId) throws StatAlgoImporterServiceException { @@ -216,6 +314,23 @@ public class FilesStorage { } } + /** + * + * @param user + * User + * @param inputStream + * Input stream + * @param name + * Item name + * @param description + * Item description + * @param mimeType + * Item mimetype + * @param folderId + * Destination folder + * @return Workspace item + * @throws StatAlgoImporterServiceException + */ public WorkspaceItem createItemOnWorkspace(String user, InputStream inputStream, String name, String description, String mimeType, String folderId) @@ -246,6 +361,12 @@ public class FilesStorage { /** * + * @param user + * User + * @param folderId + * Folder id + * @return Input stream + * @throws StatAlgoImporterServiceException */ public InputStream retrieveProjectItemOnWorkspace(String user, String folderId) throws StatAlgoImporterServiceException { @@ -279,6 +400,12 @@ public class FilesStorage { /** * + * @param user + * User + * @param itemId + * Item id + * @return Input stream + * @throws StatAlgoImporterServiceException */ public InputStream retrieveItemOnWorkspace(String user, String itemId) throws StatAlgoImporterServiceException { @@ -307,7 +434,7 @@ public class FilesStorage { * User * @param remotePath * File path on storage - * @return InputStream back to read the file + * @return Input stream back to read the file * @throws StatAlgoImporterServiceException */ public InputStream retrieveImputStream(String user, WorkspaceItem wi) diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/storage/MainCodeSave.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/storage/MainCodeSave.java new file mode 100644 index 0000000..7e5351e --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/storage/MainCodeSave.java @@ -0,0 +1,106 @@ +package org.gcube.portlets.user.statisticalalgorithmsimporter.server.storage; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.StandardOpenOption; + +import org.gcube.application.framework.core.session.ASLSession; +import org.gcube.common.homelibrary.home.exceptions.InternalErrorException; +import org.gcube.common.homelibrary.home.workspace.WorkspaceItem; +import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterServiceException; +import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Project; +import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.workspace.ItemDescription; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * @author Giancarlo Panichi + * email: g.panichi@isti.cnr.it + * + */ +public class MainCodeSave { + private static final String ALGORITHM_DESCRIPTION = "Algorithm"; + private static final String ALGORITHM_MIMETYPE = "text/plain"; + + public static final Logger logger = LoggerFactory + .getLogger(MainCodeSave.class); + + public MainCodeSave() { + + } + + /** + * + * @param aslSession + * @param file description of destination file + * @param code code to insert in the file + * @param project + * @return + * @throws StatAlgoImporterServiceException + */ + public ItemDescription save(ASLSession aslSession, ItemDescription file, + String code, Project project) + throws StatAlgoImporterServiceException { + Path tempFile = createTempFile(file, code); + ItemDescription mainCode = saveInWorkspace(tempFile, aslSession, file, + project); + return mainCode; + } + + private Path createTempFile(ItemDescription file, String code) + throws StatAlgoImporterServiceException { + try { + Path tempFile = Files.createTempFile(file.getName(), ""); + + Files.write(tempFile, code.getBytes(), StandardOpenOption.WRITE); + logger.debug(tempFile.toString()); + + return tempFile; + + } catch (IOException e) { + logger.error(e.getLocalizedMessage()); + e.printStackTrace(); + throw new StatAlgoImporterServiceException(e.getLocalizedMessage(), + e); + } + } + + private ItemDescription saveInWorkspace(Path tempFile, + ASLSession aslSession, ItemDescription file, Project project) + throws StatAlgoImporterServiceException { + FilesStorage filesStorage = new FilesStorage(); + WorkspaceItem mainCodeItem; + + try { + mainCodeItem = filesStorage.createItemOnWorkspace( + aslSession.getUsername(), + Files.newInputStream(tempFile, StandardOpenOption.READ), + file.getName(), ALGORITHM_DESCRIPTION, ALGORITHM_MIMETYPE, + project.getProjectFolder().getItemDescription().getId()); + } catch (IOException e) { + logger.error(e.getLocalizedMessage()); + e.printStackTrace(); + throw new StatAlgoImporterServiceException(e.getLocalizedMessage(), + e); + } + + ItemDescription mainCode; + try { + mainCode = new ItemDescription(mainCodeItem.getId(), + mainCodeItem.getName(), mainCodeItem.getOwner() + .getPortalLogin(), mainCodeItem.getPath(), + mainCodeItem.getType().name()); + } catch (InternalErrorException e) { + logger.error(e.getLocalizedMessage()); + e.printStackTrace(); + throw new StatAlgoImporterServiceException(e.getLocalizedMessage()); + + } + + return mainCode; + + } + +} diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/shared/Constants.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/shared/Constants.java index d25c69b..7aa8cfe 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/shared/Constants.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/shared/Constants.java @@ -9,15 +9,16 @@ package org.gcube.portlets.user.statisticalalgorithmsimporter.shared; public class Constants { public static final String APPLICATION_ID = "org.gcube.portlets.user.statisticalalgorithmsimporter.server.portlet.StatAlgoImporterPortlet"; - public static final String STATRUNNER_ID = "StatRunnerId"; - public static final String STATRUNNER_LANG_COOKIE = "StatRunnerLangCookie"; - public static final String STATRUNNER_LANG = "StatRunnerLang"; + public static final String STATISTICAL_ALGORITHMS_IMPORTER_ID = "SAIId"; + public static final String STATISTICAL_ALGORITHMS_IMPORTER_COOKIE = "SAILangCookie"; + public static final String STATISTICAL_ALGORITHMS_IMPORTER_LANG = "SAILang"; public final static String DEFAULT_USER = "giancarlo.panichi"; //public final static String DEFAULT_SCOPE = "/gcube/devNext"; public final static String DEFAULT_SCOPE = "/gcube/devsec/devVRE"; + public static final String FILE_UPLOADED_FIELD = "FileUploadedField"; + public static final String STATISTICAL_ALGORITHMS_IMPORTER_JAR_PUBLIC_LINK = "JarPublicLink"; + + - - public static final String FILE_UPLOADED_FIELD = "fileUploadedField"; - } diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/shared/input/EnvironmentVariables.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/shared/input/GlobalVariables.java similarity index 87% rename from src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/shared/input/EnvironmentVariables.java rename to src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/shared/input/GlobalVariables.java index 5837279..99a7e78 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/shared/input/EnvironmentVariables.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/shared/input/GlobalVariables.java @@ -8,7 +8,7 @@ import java.io.Serializable; * href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it * */ -public class EnvironmentVariables implements Serializable { +public class GlobalVariables implements Serializable { private static final long serialVersionUID = -2519686355634242523L; private int id; @@ -17,7 +17,7 @@ public class EnvironmentVariables implements Serializable { private String defaultValue; private DataType dataType; - public EnvironmentVariables() { + public GlobalVariables() { super(); } @@ -29,7 +29,7 @@ public class EnvironmentVariables implements Serializable { * @param defaultValue * @param dataType */ - public EnvironmentVariables(int id, String name, String description, + public GlobalVariables(int id, String name, String description, String defaultValue, DataType dataType) { super(); this.id = id; @@ -81,10 +81,12 @@ public class EnvironmentVariables implements Serializable { @Override public String toString() { - return "EnvironmentVariables [id=" + id + ", name=" + name + return "GlobalVariables [id=" + id + ", name=" + name + ", description=" + description + ", defaultValue=" + defaultValue + ", dataType=" + dataType + "]"; } + + } diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/shared/input/SelectedRowsVariables.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/shared/input/InputOutputVariables.java similarity index 88% rename from src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/shared/input/SelectedRowsVariables.java rename to src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/shared/input/InputOutputVariables.java index bb93a72..bacabe7 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/shared/input/SelectedRowsVariables.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/shared/input/InputOutputVariables.java @@ -8,7 +8,7 @@ import java.io.Serializable; * href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it * */ -public class SelectedRowsVariables implements Serializable { +public class InputOutputVariables implements Serializable { private static final long serialVersionUID = -2519686355634242523L; private int id; @@ -19,11 +19,11 @@ public class SelectedRowsVariables implements Serializable { private IOType ioType; private String sourceSelection; - public SelectedRowsVariables() { + public InputOutputVariables() { super(); } - public SelectedRowsVariables(String name, String description, + public InputOutputVariables(String name, String description, String defaultValue, DataType dataType, IOType ioType, String sourceSelection){ super(); @@ -36,7 +36,7 @@ public class SelectedRowsVariables implements Serializable { } - public SelectedRowsVariables(int id, String name, String description, + public InputOutputVariables(int id, String name, String description, String defaultValue, DataType dataType, IOType ioType, String sourceSelection) { super(); @@ -107,7 +107,7 @@ public class SelectedRowsVariables implements Serializable { @Override public String toString() { - return "SelectedRowsVariables [id=" + id + ", name=" + name + return "InputOutputVariables [id=" + id + ", name=" + name + ", description=" + description + ", defaultValue=" + defaultValue + ", dataType=" + dataType + ", ioType=" + ioType + ", sourceSelection=" + sourceSelection + "]"; @@ -115,4 +115,5 @@ public class SelectedRowsVariables implements Serializable { + } diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/shared/input/ProjectInfo.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/shared/input/ProjectInfo.java index b185fd4..80b1326 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/shared/input/ProjectInfo.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/shared/input/ProjectInfo.java @@ -12,51 +12,61 @@ import java.util.ArrayList; public class ProjectInfo implements Serializable { private static final long serialVersionUID = 7304965177776383842L; - private String packageName; - private String packageDescription; - private ArrayList listDeployableVRE; + private String algorithmName; + private String algorithmDescription; + private ArrayList listRequestedVRE; public ProjectInfo() { super(); } - public ProjectInfo(String packageName, String pacakgeDescription, - ArrayList listDeployableVRE) { + public ProjectInfo(String algorithmName, String algorithmDescription, + ArrayList listRequestedVRE) { super(); - this.packageName = packageName; - this.packageDescription = pacakgeDescription; - this.listDeployableVRE = listDeployableVRE; + this.algorithmName = algorithmName; + this.algorithmDescription = algorithmDescription; + this.listRequestedVRE = listRequestedVRE; } - public String getPackageName() { - return packageName; + public String getAlgorithmName() { + return algorithmName; } - public void setPackageName(String packageName) { - this.packageName = packageName; + public String getAlgorithmNameToUpper() { + return algorithmName.toUpperCase(); } - public String getPackageDescription() { - return packageDescription; + public String getAlgorithmNameToClassName() { + return algorithmName.replaceAll("_", ""); } - public void setPackageDescription(String packageDescription) { - this.packageDescription = packageDescription; + public void setAlgorithmName(String algorithmName) { + this.algorithmName = algorithmName; } - public ArrayList getListDeployableVRE() { - return listDeployableVRE; + public String getAlgorithmDescription() { + return algorithmDescription; } - public void setListDeployableVRE(ArrayList listDeployableVRE) { - this.listDeployableVRE = listDeployableVRE; + public void setAlgorithmDescription(String algorithmDescription) { + this.algorithmDescription = algorithmDescription; + } + + public ArrayList getListRequestedVRE() { + return listRequestedVRE; + } + + public void setListRequestedVRE(ArrayList listRequestedVRE) { + this.listRequestedVRE = listRequestedVRE; } @Override public String toString() { - return "ProjectInfo [packageName=" + packageName - + ", packageDescription=" + packageDescription - + ", listDeployableVRE=" + listDeployableVRE + "]"; + return "ProjectInfo [algorithmName=" + algorithmName + + ", algorithmDescription=" + algorithmDescription + + ", listRequestedVRE=" + listRequestedVRE + "]"; } + + } diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/shared/input/DeployableVRE.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/shared/input/RequestedVRE.java similarity index 80% rename from src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/shared/input/DeployableVRE.java rename to src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/shared/input/RequestedVRE.java index 30ce5e3..027e125 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/shared/input/DeployableVRE.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/shared/input/RequestedVRE.java @@ -8,18 +8,18 @@ import java.io.Serializable; * href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it * */ -public class DeployableVRE implements Serializable { +public class RequestedVRE implements Serializable { private static final long serialVersionUID = -7548059008384829524L; private int id; private String name; private String description; - public DeployableVRE() { + public RequestedVRE() { super(); } - public DeployableVRE(int id, String name, String description) { + public RequestedVRE(int id, String name, String description) { super(); this.id = id; this.name = name; @@ -52,10 +52,11 @@ public class DeployableVRE implements Serializable { @Override public String toString() { - return "DeployableVRE [id=" + id + ", name=" + name + ", description=" + return "RequestedVRE [id=" + id + ", name=" + name + ", description=" + description + "]"; } + } diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/shared/project/InputData.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/shared/project/InputData.java index a7686ee..cef4515 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/shared/project/InputData.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/shared/project/InputData.java @@ -3,10 +3,10 @@ package org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project; import java.io.Serializable; import java.util.ArrayList; -import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.EnvironmentVariables; +import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.GlobalVariables; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.InterpreterInfo; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.ProjectInfo; -import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.SelectedRowsVariables; +import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.InputOutputVariables; /** * @@ -19,40 +19,29 @@ public class InputData implements Serializable { private static final long serialVersionUID = -2405068429998054485L; private ProjectInfo projectInfo; private InterpreterInfo interpreterInfo; - private ArrayList listEnvironmentVariables; - private ArrayList listSelectedRows; - - + private ArrayList listGlobalVariables; + private ArrayList listInputOutputVariables; + public InputData() { super(); } - public InputData(ArrayList listEnvironmentVariables, - ArrayList listSelectedRows, - InterpreterInfo interpreterInfo, ProjectInfo projectInfo) { + public InputData(ProjectInfo projectInfo, InterpreterInfo interpreterInfo, + ArrayList listGlobalVariables, + ArrayList listInputOutputVariables) { super(); - this.listEnvironmentVariables = listEnvironmentVariables; - this.listSelectedRows = listSelectedRows; - this.interpreterInfo = interpreterInfo; this.projectInfo = projectInfo; + this.interpreterInfo = interpreterInfo; + this.listGlobalVariables = listGlobalVariables; + this.listInputOutputVariables = listInputOutputVariables; } - public ArrayList getListEnvironmentVariables() { - return listEnvironmentVariables; + public ProjectInfo getProjectInfo() { + return projectInfo; } - public void setListEnvironmentVariables( - ArrayList listEnvironmentVariables) { - this.listEnvironmentVariables = listEnvironmentVariables; - } - - public ArrayList getListSelectedRows() { - return listSelectedRows; - } - - public void setListSelectedRows( - ArrayList listSelectedRows) { - this.listSelectedRows = listSelectedRows; + public void setProjectInfo(ProjectInfo projectInfo) { + this.projectInfo = projectInfo; } public InterpreterInfo getInterpreterInfo() { @@ -62,23 +51,31 @@ public class InputData implements Serializable { public void setInterpreterInfo(InterpreterInfo interpreterInfo) { this.interpreterInfo = interpreterInfo; } - - public ProjectInfo getProjectInfo() { - return projectInfo; + + public ArrayList getListGlobalVariables() { + return listGlobalVariables; } - public void setProjectInfo(ProjectInfo projectInfo) { - this.projectInfo = projectInfo; + public void setListGlobalVariables( + ArrayList listGlobalVariables) { + this.listGlobalVariables = listGlobalVariables; + } + + public ArrayList getListInputOutputVariables() { + return listInputOutputVariables; + } + + public void setListInputOutputVariables( + ArrayList listInputOutputVariables) { + this.listInputOutputVariables = listInputOutputVariables; } @Override public String toString() { return "InputData [projectInfo=" + projectInfo + ", interpreterInfo=" - + interpreterInfo + ", listEnvironmentVariables=" - + listEnvironmentVariables + ", listSelectedRows=" - + listSelectedRows + "]"; + + interpreterInfo + ", listGlobalVariables=" + + listGlobalVariables + ", listInputOutputVariables=" + + listInputOutputVariables + "]"; } - - }