Giancarlo Panichi 2017-02-21 18:28:44 +00:00
parent d4b9954bb7
commit c5d0bda36c
3 changed files with 169 additions and 41 deletions

View File

@ -1,6 +1,8 @@
<ReleaseNotes>
<Changeset component="${groupId}.${artifactId}.1-5-0" date="2017-02-15">
<Change>Updated PortalContext support[ticket #6279]</Change>
<Change>Added support only for file data type in output
parameter[ticket #7120]</Change>
</Changeset>
<Changeset component="${groupId}.${artifactId}.1-4-0" date="2016-12-01">
<Change>Updated Storage support</Change>

View File

@ -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<def.length;i++){
defaultValue=defaultValue+"\\\""+def[i];
String[] def = defaultValue.split("\"");
if (def.length > 2) {
defaultValue = def[0];
for (int i = 1; i < def.length; i++) {
defaultValue = defaultValue + "\\\"" + def[i];
}
}
if (ioType.compareTo(IOType.OUTPUT) == 0) {
selectedRowsVariables = new InputOutputVariables(
varDescription[0].trim(), varDescription[0].trim(),
defaultValue, checkDataType(checkDataTypeValue), ioType,
parameter);
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<def.length;i++){
defaultValue=defaultValue+"\\\""+def[i];
String[] def = defaultValue.split("\"");
if (def.length > 2) {
defaultValue = def[0];
for (int i = 1; i < def.length; i++) {
defaultValue = defaultValue + "\\\"" + def[i];
}
}
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);

View File

@ -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<InputOutputVariables>(
gridInputOutputVariables);
gridInputOutputVariablesEditing
@ -400,18 +406,112 @@ public class InputOutputVariablesPanel extends ContentPanel {
private void editingBeforeStart(
BeforeStartEditEvent<InputOutputVariables> 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<DataType> labelProvider) {
comboDataType.addValueChangeHandler(new ValueChangeHandler<DataType>() {
@Override
public void onValueChange(ValueChangeEvent<DataType> event) {
}
});
comboDataType.addSelectionHandler(new SelectionHandler<DataType>() {
@Override
public void onSelection(SelectionEvent<DataType> event) {
}
});
}
private void addHandlersForComboDataType(LabelProvider<DataType> idI18N) {
// TODO Auto-generated method stub
private void addHandlersForComboIOType(LabelProvider<IOType> labelProvider) {
comboIOType.addValueChangeHandler(new ValueChangeHandler<IOType>() {
@Override
public void onValueChange(ValueChangeEvent<IOType> event) {
IOType ioType = event.getValue();
switch (ioType) {
case INPUT:
setComboForInputParameter();
break;
case OUTPUT:
setComboForOutputParamert();
break;
default:
setComboForInputParameter();
break;
}
}
private void addHandlersForComboIOType(LabelProvider<IOType> idI18N) {
// TODO Auto-generated method stub
});
comboIOType.addSelectionHandler(new SelectionHandler<IOType>() {
@Override
public void onSelection(SelectionEvent<IOType> event) {
IOType ioType = event.getSelectedItem();
switch (ioType) {
case INPUT:
setComboForInputParameter();
break;
case OUTPUT:
setComboForOutputParamert();
break;
default:
setComboForInputParameter();
break;
}
}
});
}
private void setComboForOutputParamert() {
storeComboDataType.clear();
storeComboDataType.add(DataType.FILE);
storeComboDataType.commitChanges();
comboDataType.clear();
comboDataType.setValue(DataType.FILE,true,true);
}
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<InputOutputVariables> 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<InputOutputVariables> getInputOutputVariables() {
ArrayList<InputOutputVariables> listInputOutputVarialbles = new ArrayList<>(
gridInputOutputVariables.getStore().getAll());