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> <ReleaseNotes>
<Changeset component="${groupId}.${artifactId}.1-5-0" date="2017-02-15"> <Changeset component="${groupId}.${artifactId}.1-5-0" date="2017-02-15">
<Change>Updated PortalContext support[ticket #6279]</Change> <Change>Updated PortalContext support[ticket #6279]</Change>
<Change>Added support only for file data type in output
parameter[ticket #7120]</Change>
</Changeset> </Changeset>
<Changeset component="${groupId}.${artifactId}.1-4-0" date="2016-12-01"> <Changeset component="${groupId}.${artifactId}.1-4-0" date="2016-12-01">
<Change>Updated Storage support</Change> <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 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 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() { public CodeParser() {
@ -46,18 +47,23 @@ public class CodeParser {
if (defaultValue.endsWith("\"")) if (defaultValue.endsWith("\""))
defaultValue = defaultValue.substring(0, defaultValue = defaultValue.substring(0,
defaultValue.length() - 1); defaultValue.length() - 1);
String[] def=defaultValue.split("\""); String[] def = defaultValue.split("\"");
if(def.length>2){ if (def.length > 2) {
defaultValue=def[0]; defaultValue = def[0];
for(int i=1; i<def.length;i++){ for (int i = 1; i < def.length; i++) {
defaultValue=defaultValue+"\\\""+def[i]; defaultValue = defaultValue + "\\\"" + def[i];
} }
} }
if (ioType.compareTo(IOType.OUTPUT) == 0) {
selectedRowsVariables = new InputOutputVariables( selectedRowsVariables = new InputOutputVariables(
varDescription[0].trim(), varDescription[0].trim(), varDescription[0].trim(), varDescription[0].trim(),
defaultValue, checkDataType(checkDataTypeValue), ioType, defaultValue, DataType.FILE, ioType, parameter);
parameter); } else {
selectedRowsVariables = new InputOutputVariables(
varDescription[0].trim(), varDescription[0].trim(),
defaultValue, checkDataType(checkDataTypeValue),
ioType, parameter);
}
} else { } else {
if (parameter.contains("=")) { if (parameter.contains("=")) {
String[] varDescription = parameter.split("="); String[] varDescription = parameter.split("=");
@ -74,17 +80,24 @@ public class CodeParser {
if (defaultValue.endsWith("\"")) if (defaultValue.endsWith("\""))
defaultValue = defaultValue.substring(0, defaultValue = defaultValue.substring(0,
defaultValue.length() - 1); defaultValue.length() - 1);
String[] def=defaultValue.split("\""); String[] def = defaultValue.split("\"");
if(def.length>2){ if (def.length > 2) {
defaultValue=def[0]; defaultValue = def[0];
for(int i=1; i<def.length;i++){ for (int i = 1; i < def.length; i++) {
defaultValue=defaultValue+"\\\""+def[i]; defaultValue = defaultValue + "\\\"" + def[i];
} }
} }
selectedRowsVariables = new InputOutputVariables(
varDescription[0].trim(), varDescription[0].trim(), if (ioType.compareTo(IOType.OUTPUT) == 0) {
defaultValue, checkDataType(checkDataTypeValue), selectedRowsVariables = new InputOutputVariables(
ioType, parameter); 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 { } else {
return null; return null;
@ -112,15 +125,12 @@ public class CodeParser {
} }
/* /*
RegExp regExpEnum1 = RegExp.compile(ENUM1_PATTERN); * RegExp regExpEnum1 = RegExp.compile(ENUM1_PATTERN); if
if (regExpEnum1.test(data)) { * (regExpEnum1.test(data)) { return DataType.ENUMERATED; }
return DataType.ENUMERATED; *
} * RegExp regExpEnum2 = RegExp.compile(ENUM2_PATTERN); if
* (regExpEnum2.test(data)) { return DataType.ENUMERATED; }
RegExp regExpEnum2 = RegExp.compile(ENUM2_PATTERN); */
if (regExpEnum2.test(data)) {
return DataType.ENUMERATED;
}*/
try { try {
Integer.parseInt(data); 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.allen_sauer.gwt.log.client.Log;
import com.google.gwt.cell.client.AbstractCell; import com.google.gwt.cell.client.AbstractCell;
import com.google.gwt.core.client.GWT; 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.event.shared.EventBus;
import com.google.gwt.safehtml.shared.SafeHtml; import com.google.gwt.safehtml.shared.SafeHtml;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder; import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
@ -182,6 +186,9 @@ public class InputOutputVariablesPanel extends ContentPanel {
if (project != null && project.getInputData() != null if (project != null && project.getInputData() != null
&& project.getInputData().getListInputOutputVariables() != null) { && project.getInputData().getListInputOutputVariables() != null) {
checkOutputParameterOnlyFileTypeIsSupported(project.getInputData()
.getListInputOutputVariables());
storeInputOutputVariables.addAll(project.getInputData() storeInputOutputVariables.addAll(project.getInputData()
.getListInputOutputVariables()); .getListInputOutputVariables());
} }
@ -267,11 +274,10 @@ public class InputOutputVariablesPanel extends ContentPanel {
"Attention character \" is not allowed")); "Attention character \" is not allowed"));
TextField defaultValueColumnEditing = new TextField(); TextField defaultValueColumnEditing = new TextField();
defaultValueColumnEditing.setAllowBlank(false); defaultValueColumnEditing.setAllowBlank(false);
defaultValueColumnEditing.addValidator(new RegExValidator("^[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*$", defaultValueColumnEditing.addValidator(new RegExValidator(
"^[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*$",
"Attention character \" is not allowed")); "Attention character \" is not allowed"));
gridInputOutputVariablesEditing = new GridRowEditing<InputOutputVariables>( gridInputOutputVariablesEditing = new GridRowEditing<InputOutputVariables>(
gridInputOutputVariables); gridInputOutputVariables);
gridInputOutputVariablesEditing gridInputOutputVariablesEditing
@ -400,18 +406,112 @@ public class InputOutputVariablesPanel extends ContentPanel {
private void editingBeforeStart( private void editingBeforeStart(
BeforeStartEditEvent<InputOutputVariables> event) { 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 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;
}
}
});
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 addHandlersForComboDataType(LabelProvider<DataType> idI18N) { private void setComboForOutputParamert() {
// TODO Auto-generated method stub storeComboDataType.clear();
storeComboDataType.add(DataType.FILE);
storeComboDataType.commitChanges();
comboDataType.clear();
comboDataType.setValue(DataType.FILE,true,true);
} }
private void addHandlersForComboIOType(LabelProvider<IOType> idI18N) { private void setComboForInputParameter() {
// TODO Auto-generated method stub storeComboDataType.clear();
storeComboDataType.addAll(DataType.asList());
storeComboDataType.commitChanges();
} }
public void addNewInputOutputVariables( public void addNewInputOutputVariables(
@ -468,6 +568,9 @@ public class InputOutputVariablesPanel extends ContentPanel {
Log.debug("Update Input/Output Variables: " + project); Log.debug("Update Input/Output Variables: " + project);
if (project != null && project.getInputData() != null if (project != null && project.getInputData() != null
&& project.getInputData().getListInputOutputVariables() != null) { && project.getInputData().getListInputOutputVariables() != null) {
checkOutputParameterOnlyFileTypeIsSupported(project.getInputData()
.getListInputOutputVariables());
storeInputOutputVariables.clear(); storeInputOutputVariables.clear();
storeInputOutputVariables.addAll(project.getInputData() storeInputOutputVariables.addAll(project.getInputData()
.getListInputOutputVariables()); .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() { public ArrayList<InputOutputVariables> getInputOutputVariables() {
ArrayList<InputOutputVariables> listInputOutputVarialbles = new ArrayList<>( ArrayList<InputOutputVariables> listInputOutputVarialbles = new ArrayList<>(
gridInputOutputVariables.getStore().getAll()); gridInputOutputVariables.getStore().getAll());