From c5d0bda36c1a389f4b6dc4bb23f405b1d58e0289 Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Tue, 21 Feb 2017 18:28:44 +0000 Subject: [PATCH] ref 7120:Manage SAI output https://support.d4science.org/issues/7120 git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/statistical-algorithms-importer@144027 82a268e6-3cf1-43bd-a215-b396298e98cf --- distro/changelog.xml | 2 + .../client/codeparser/CodeParser.java | 70 +++++---- .../input/InputOutputVariablesPanel.java | 138 ++++++++++++++++-- 3 files changed, 169 insertions(+), 41 deletions(-) diff --git a/distro/changelog.xml b/distro/changelog.xml index 86410e2..c4cf32b 100644 --- a/distro/changelog.xml +++ b/distro/changelog.xml @@ -1,6 +1,8 @@ Updated PortalContext support[ticket #6279] + Added support only for file data type in output + parameter[ticket #7120] Updated Storage support 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 773d94b..07316be 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 @@ -17,8 +17,9 @@ public class CodeParser { private static final String IMAGE_PATTERN = "([^\\s]+(\\.(jpg|png|gif|bmp)\"))"; private static final String FILE_PATTERN = "([^\\s]+(\\.(txt|csv|pdf|doc|zip|bin|dat|mat|java|m|exe|sh|tar|gz|r)\"))"; - //private static final String ENUM1_PATTERN = "(c\\([^\\)]*\\))"; - //private static final String ENUM2_PATTERN = "(\\{[^\\}]*\\})"; + + // private static final String ENUM1_PATTERN = "(c\\([^\\)]*\\))"; + // private static final String ENUM2_PATTERN = "(\\{[^\\}]*\\})"; public CodeParser() { @@ -46,18 +47,23 @@ public class CodeParser { if (defaultValue.endsWith("\"")) defaultValue = defaultValue.substring(0, defaultValue.length() - 1); - String[] def=defaultValue.split("\""); - if(def.length>2){ - defaultValue=def[0]; - for(int i=1; i 2) { + defaultValue = def[0]; + for (int i = 1; i < def.length; i++) { + defaultValue = defaultValue + "\\\"" + def[i]; } } - - selectedRowsVariables = new InputOutputVariables( - varDescription[0].trim(), varDescription[0].trim(), - defaultValue, checkDataType(checkDataTypeValue), ioType, - parameter); + if (ioType.compareTo(IOType.OUTPUT) == 0) { + selectedRowsVariables = new InputOutputVariables( + varDescription[0].trim(), varDescription[0].trim(), + defaultValue, DataType.FILE, ioType, parameter); + } else { + selectedRowsVariables = new InputOutputVariables( + varDescription[0].trim(), varDescription[0].trim(), + defaultValue, checkDataType(checkDataTypeValue), + ioType, parameter); + } } else { if (parameter.contains("=")) { String[] varDescription = parameter.split("="); @@ -74,17 +80,24 @@ public class CodeParser { if (defaultValue.endsWith("\"")) defaultValue = defaultValue.substring(0, defaultValue.length() - 1); - String[] def=defaultValue.split("\""); - if(def.length>2){ - defaultValue=def[0]; - for(int i=1; i 2) { + defaultValue = def[0]; + for (int i = 1; i < def.length; i++) { + defaultValue = defaultValue + "\\\"" + def[i]; } } - selectedRowsVariables = new InputOutputVariables( - varDescription[0].trim(), varDescription[0].trim(), - defaultValue, checkDataType(checkDataTypeValue), - ioType, parameter); + + if (ioType.compareTo(IOType.OUTPUT) == 0) { + selectedRowsVariables = new InputOutputVariables( + varDescription[0].trim(), varDescription[0].trim(), + defaultValue, DataType.FILE, ioType, parameter); + } else { + selectedRowsVariables = new InputOutputVariables( + varDescription[0].trim(), varDescription[0].trim(), + defaultValue, checkDataType(checkDataTypeValue), + ioType, parameter); + } } else { return null; @@ -112,15 +125,12 @@ public class CodeParser { } /* - RegExp regExpEnum1 = RegExp.compile(ENUM1_PATTERN); - if (regExpEnum1.test(data)) { - return DataType.ENUMERATED; - } - - RegExp regExpEnum2 = RegExp.compile(ENUM2_PATTERN); - if (regExpEnum2.test(data)) { - return DataType.ENUMERATED; - }*/ + * RegExp regExpEnum1 = RegExp.compile(ENUM1_PATTERN); if + * (regExpEnum1.test(data)) { return DataType.ENUMERATED; } + * + * RegExp regExpEnum2 = RegExp.compile(ENUM2_PATTERN); if + * (regExpEnum2.test(data)) { return DataType.ENUMERATED; } + */ try { Integer.parseInt(data); diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/InputOutputVariablesPanel.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/InputOutputVariablesPanel.java index 93b758e..8b75c7c 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/InputOutputVariablesPanel.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/InputOutputVariablesPanel.java @@ -15,6 +15,10 @@ import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Proj import com.allen_sauer.gwt.log.client.Log; import com.google.gwt.cell.client.AbstractCell; import com.google.gwt.core.client.GWT; +import com.google.gwt.event.logical.shared.SelectionEvent; +import com.google.gwt.event.logical.shared.SelectionHandler; +import com.google.gwt.event.logical.shared.ValueChangeEvent; +import com.google.gwt.event.logical.shared.ValueChangeHandler; import com.google.gwt.event.shared.EventBus; import com.google.gwt.safehtml.shared.SafeHtml; import com.google.gwt.safehtml.shared.SafeHtmlBuilder; @@ -182,6 +186,9 @@ public class InputOutputVariablesPanel extends ContentPanel { if (project != null && project.getInputData() != null && project.getInputData().getListInputOutputVariables() != null) { + checkOutputParameterOnlyFileTypeIsSupported(project.getInputData() + .getListInputOutputVariables()); + storeInputOutputVariables.addAll(project.getInputData() .getListInputOutputVariables()); } @@ -267,11 +274,10 @@ public class InputOutputVariablesPanel extends ContentPanel { "Attention character \" is not allowed")); TextField defaultValueColumnEditing = new TextField(); defaultValueColumnEditing.setAllowBlank(false); - defaultValueColumnEditing.addValidator(new RegExValidator("^[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*$", + defaultValueColumnEditing.addValidator(new RegExValidator( + "^[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*$", "Attention character \" is not allowed")); - - - + gridInputOutputVariablesEditing = new GridRowEditing( gridInputOutputVariables); gridInputOutputVariablesEditing @@ -400,18 +406,112 @@ public class InputOutputVariablesPanel extends ContentPanel { private void editingBeforeStart( BeforeStartEditEvent event) { - // TODO Auto-generated method stub + if (storeInputOutputVariables != null + && storeInputOutputVariables.size() > 0) { + + int rowIndex = event.getEditCell().getRow(); + + InputOutputVariables currentInputOutputVariable = storeInputOutputVariables + .get(rowIndex); + if (currentInputOutputVariable != null + && currentInputOutputVariable.getIoType() != null + && currentInputOutputVariable.getIoType().compareTo( + IOType.OUTPUT) == 0) { + storeComboDataType.clear(); + storeComboDataType.add(DataType.FILE); + storeComboDataType.commitChanges(); + } else { + storeComboDataType.clear(); + storeComboDataType.addAll(DataType.asList()); + storeComboDataType.commitChanges(); + } + } else { + storeComboDataType.clear(); + storeComboDataType.addAll(DataType.asList()); + storeComboDataType.commitChanges(); + } + } + + private void addHandlersForComboDataType( + LabelProvider labelProvider) { + comboDataType.addValueChangeHandler(new ValueChangeHandler() { + + @Override + public void onValueChange(ValueChangeEvent event) { + + + } + }); + + comboDataType.addSelectionHandler(new SelectionHandler() { + + @Override + public void onSelection(SelectionEvent event) { + + } + }); + + + } + + private void addHandlersForComboIOType(LabelProvider labelProvider) { + comboIOType.addValueChangeHandler(new ValueChangeHandler() { + + @Override + public void onValueChange(ValueChangeEvent event) { + IOType ioType = event.getValue(); + switch (ioType) { + case INPUT: + setComboForInputParameter(); + break; + case OUTPUT: + setComboForOutputParamert(); + break; + default: + setComboForInputParameter(); + break; + } + + } + + }); + + comboIOType.addSelectionHandler(new SelectionHandler() { + + @Override + public void onSelection(SelectionEvent event) { + + IOType ioType = event.getSelectedItem(); + switch (ioType) { + case INPUT: + setComboForInputParameter(); + break; + case OUTPUT: + setComboForOutputParamert(); + break; + default: + setComboForInputParameter(); + break; + } + + } + + }); } - private void addHandlersForComboDataType(LabelProvider idI18N) { - // TODO Auto-generated method stub - + private void setComboForOutputParamert() { + storeComboDataType.clear(); + storeComboDataType.add(DataType.FILE); + storeComboDataType.commitChanges(); + comboDataType.clear(); + comboDataType.setValue(DataType.FILE,true,true); } - private void addHandlersForComboIOType(LabelProvider idI18N) { - // TODO Auto-generated method stub - + private void setComboForInputParameter() { + storeComboDataType.clear(); + storeComboDataType.addAll(DataType.asList()); + storeComboDataType.commitChanges(); } public void addNewInputOutputVariables( @@ -468,6 +568,9 @@ public class InputOutputVariablesPanel extends ContentPanel { Log.debug("Update Input/Output Variables: " + project); if (project != null && project.getInputData() != null && project.getInputData().getListInputOutputVariables() != null) { + checkOutputParameterOnlyFileTypeIsSupported(project.getInputData() + .getListInputOutputVariables()); + storeInputOutputVariables.clear(); storeInputOutputVariables.addAll(project.getInputData() .getListInputOutputVariables()); @@ -482,6 +585,19 @@ public class InputOutputVariablesPanel extends ContentPanel { } + private void checkOutputParameterOnlyFileTypeIsSupported( + ArrayList inputOutputVarialbles) { + for (InputOutputVariables ioVariable : inputOutputVarialbles) { + if (ioVariable.getIoType() != null + && ioVariable.getIoType().compareTo(IOType.OUTPUT) == 0) { + if (ioVariable.getDataType() == null + || ioVariable.getDataType().compareTo(DataType.FILE) != 0) { + ioVariable.setDataType(DataType.FILE); + } + } + } + } + public ArrayList getInputOutputVariables() { ArrayList listInputOutputVarialbles = new ArrayList<>( gridInputOutputVariables.getStore().getAll());