1452: Implement a GUI for StatMan Algorithms Importer

Task-Url: https://support.d4science.org/issues/1452

Fixed parser on input files

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/statistical-algorithms-importer@122461 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2016-01-22 14:47:04 +00:00
parent 4bc1ed3a69
commit e4b4e45961
6 changed files with 122 additions and 49 deletions

View File

@ -16,7 +16,7 @@ import com.google.gwt.regexp.shared.RegExp;
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)\"))";
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 = "(\\{[^\\}]*\\})";
@ -33,7 +33,7 @@ public class CodeParser {
if (parameter.contains("<-")) {
String[] varDescription = parameter.split("<-");
String checkDataTypeValue=varDescription[1].trim();
String checkDataTypeValue = varDescription[1].trim();
if (checkDataTypeValue.endsWith(";"))
checkDataTypeValue = checkDataTypeValue.substring(0,
checkDataTypeValue.length() - 1);
@ -49,12 +49,12 @@ public class CodeParser {
selectedRowsVariables = new InputOutputVariables(
varDescription[0].trim(), varDescription[0].trim(),
defaultValue, checkDataType(checkDataTypeValue),
ioType, parameter);
defaultValue, checkDataType(checkDataTypeValue), ioType,
parameter);
} else {
if (parameter.contains("=")) {
String[] varDescription = parameter.split("=");
String checkDataTypeValue=varDescription[1].trim();
String checkDataTypeValue = varDescription[1].trim();
if (checkDataTypeValue.endsWith(";"))
checkDataTypeValue = checkDataTypeValue.substring(0,
checkDataTypeValue.length() - 1);

View File

@ -42,6 +42,7 @@ 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.ComboBox;
import com.sencha.gxt.widget.core.client.form.TextField;
import com.sencha.gxt.widget.core.client.form.validator.RegExValidator;
import com.sencha.gxt.widget.core.client.grid.ColumnConfig;
import com.sencha.gxt.widget.core.client.grid.ColumnModel;
import com.sencha.gxt.widget.core.client.grid.Grid;
@ -190,16 +191,27 @@ public class GlobalVariablesPanel extends ContentPanel {
comboInputType.setTriggerAction(TriggerAction.ALL);
addHandlersForComboInputType(inputTypePropertiesCombo.label());
//
TextField nameColumnEditing = new TextField();
nameColumnEditing.addValidator(new RegExValidator("^[^\"]*$",
"Attention character \" is not allowed"));
TextField descriptionColumnEditing = new TextField();
descriptionColumnEditing.addValidator(new RegExValidator("^[^\"]*$",
"Attention character \" is not allowed"));
TextField defaultValueColumnEditing = new TextField();
defaultValueColumnEditing.addValidator(new RegExValidator("^[^\"]*$",
"Attention character \" is not allowed"));
gridGlobalVariableEditing = new GridRowEditing<GlobalVariables>(
gridGlobalVariable);
gridGlobalVariableEditing.addEditor(nameColumn, new TextField());
gridGlobalVariableEditing.addEditor(nameColumn, nameColumnEditing);
gridGlobalVariableEditing.addEditor(descriptionColumn,
new TextField());
descriptionColumnEditing);
gridGlobalVariableEditing.addEditor(inputTypeColumn,
comboInputType);
gridGlobalVariableEditing.addEditor(defaultValueColumn,
new TextField());
defaultValueColumnEditing);
btnAdd = new TextButton("Add");
btnAdd.setIcon(StatAlgoImporterResources.INSTANCE.add16());

View File

@ -41,6 +41,7 @@ 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.ComboBox;
import com.sencha.gxt.widget.core.client.form.TextField;
import com.sencha.gxt.widget.core.client.form.validator.RegExValidator;
import com.sencha.gxt.widget.core.client.grid.ColumnConfig;
import com.sencha.gxt.widget.core.client.grid.ColumnModel;
import com.sencha.gxt.widget.core.client.grid.Grid;
@ -163,12 +164,14 @@ public class InputOutputVariablesPanel extends ContentPanel {
ColumnModel<InputOutputVariables> columns = new ColumnModel<InputOutputVariables>(
l);
storeInputOutputVariables = new ListStore<InputOutputVariables>(props.id());
storeInputOutputVariables = new ListStore<InputOutputVariables>(
props.id());
/*
* ArrayList<InputOutputVariablesVariables> list = new ArrayList<>(); for (int i
* = 0; i < 10; i++) { list.add(new InputOutputVariablesVariables(i, "Test" + i,
* "Desc", "defaultValue", InputType.STRING)); }
* ArrayList<InputOutputVariablesVariables> list = new ArrayList<>();
* for (int i = 0; i < 10; i++) { list.add(new
* InputOutputVariablesVariables(i, "Test" + i, "Desc", "defaultValue",
* InputType.STRING)); }
*
* storeEnvironmentVariable.addAll(list);
*/
@ -182,8 +185,8 @@ public class InputOutputVariablesPanel extends ContentPanel {
final GridSelectionModel<InputOutputVariables> sm = new GridSelectionModel<InputOutputVariables>();
sm.setSelectionMode(SelectionMode.SINGLE);
gridInputOutputVariables = new Grid<InputOutputVariables>(storeInputOutputVariables,
columns);
gridInputOutputVariables = new Grid<InputOutputVariables>(
storeInputOutputVariables, columns);
gridInputOutputVariables.setSelectionModel(sm);
gridInputOutputVariables.getView().setStripeRows(true);
gridInputOutputVariables.getView().setColumnLines(true);
@ -194,18 +197,21 @@ public class InputOutputVariablesPanel extends ContentPanel {
/*
* GridDragSource<InputOutputVariablesVariables> ds = new
* GridDragSource<InputOutputVariablesVariables>( gridEnvironmentVariable);
* ds.addDragStartHandler(new DndDragStartHandler() {
* GridDragSource<InputOutputVariablesVariables>(
* gridEnvironmentVariable); ds.addDragStartHandler(new
* DndDragStartHandler() {
*
* @Override public void onDragStart(DndDragStartEvent event) {
*
* @SuppressWarnings("unchecked") ArrayList<InputOutputVariablesVariables>
* draggingSelection = (ArrayList<InputOutputVariablesVariables>) event
* .getData(); Log.debug("Start Drag: " + draggingSelection);
* @SuppressWarnings("unchecked")
* ArrayList<InputOutputVariablesVariables> draggingSelection =
* (ArrayList<InputOutputVariablesVariables>) event .getData();
* Log.debug("Start Drag: " + draggingSelection);
*
* } }); GridDropTarget<InputOutputVariablesVariables> dt = new
* GridDropTarget<InputOutputVariablesVariables>( gridEnvironmentVariable);
* dt.setFeedback(Feedback.BOTH); dt.setAllowSelfAsSource(true);
* GridDropTarget<InputOutputVariablesVariables>(
* gridEnvironmentVariable); dt.setFeedback(Feedback.BOTH);
* dt.setAllowSelfAsSource(true);
*/
// EDITING //
@ -248,14 +254,26 @@ public class InputOutputVariablesPanel extends ContentPanel {
storeComboIOType.commitChanges();
//
TextField nameColumnEditing = new TextField();
nameColumnEditing.addValidator(new RegExValidator("^[^\"]*$",
"Attention character \" is not allowed"));
TextField descriptionColumnEditing = new TextField();
descriptionColumnEditing.addValidator(new RegExValidator("^[^\"]*$",
"Attention character \" is not allowed"));
TextField defaultValueColumnEditing = new TextField();
defaultValueColumnEditing.addValidator(new RegExValidator("^[^\"]*$",
"Attention character \" is not allowed"));
gridInputOutputVariablesEditing = new GridRowEditing<InputOutputVariables>(
gridInputOutputVariables);
gridInputOutputVariablesEditing.addEditor(nameColumn, new TextField());
gridInputOutputVariablesEditing.addEditor(descriptionColumn, new TextField());
gridInputOutputVariablesEditing.addEditor(dataTypeColumn, comboDataType);
gridInputOutputVariablesEditing.addEditor(defaultValueColumn, new TextField());
gridInputOutputVariablesEditing
.addEditor(nameColumn, nameColumnEditing);
gridInputOutputVariablesEditing.addEditor(descriptionColumn,
descriptionColumnEditing);
gridInputOutputVariablesEditing
.addEditor(dataTypeColumn, comboDataType);
gridInputOutputVariablesEditing.addEditor(defaultValueColumn,
defaultValueColumnEditing);
gridInputOutputVariablesEditing.addEditor(ioTypeColumn, comboIOType);
btnAdd = new TextButton();
@ -282,27 +300,29 @@ public class InputOutputVariablesPanel extends ContentPanel {
storeInputOutputVariables.remove(rowIndex);
storeInputOutputVariables.commitChanges();
gridInputOutputVariablesEditing.getCancelButton().setVisible(true);
gridInputOutputVariablesEditing.getCancelButton().setVisible(
true);
btnAdd.setEnabled(true);
if (addStatus) {
addStatus = false;
}
List<InputOutputVariables> listIOVariables=storeInputOutputVariables.getAll();
List<InputOutputVariables> listNewIOVariables= new ArrayList<InputOutputVariables>();
for(int i=0; i<listIOVariables.size(); i++){
InputOutputVariables var=listIOVariables.get(i);
List<InputOutputVariables> listIOVariables = storeInputOutputVariables
.getAll();
List<InputOutputVariables> listNewIOVariables = new ArrayList<InputOutputVariables>();
for (int i = 0; i < listIOVariables.size(); i++) {
InputOutputVariables var = listIOVariables.get(i);
var.setId(i);
listNewIOVariables.add(var);
}
storeInputOutputVariables.clear();
storeInputOutputVariables.addAll(listNewIOVariables);
storeInputOutputVariables.commitChanges();
seq=listNewIOVariables.size();
Log.debug("Current Seq: "+seq);
seq = listNewIOVariables.size();
Log.debug("Current Seq: " + seq);
}
});
ButtonBar buttonBar = gridInputOutputVariablesEditing.getButtonBar();
@ -349,8 +369,7 @@ public class InputOutputVariablesPanel extends ContentPanel {
btnAdd.setEnabled(true);
} catch (Throwable e) {
Log.error("Error: "
+ e.getLocalizedMessage());
Log.error("Error: " + e.getLocalizedMessage());
e.printStackTrace();
}
}
@ -364,7 +383,8 @@ public class InputOutputVariablesPanel extends ContentPanel {
vlc.setScrollMode(ScrollMode.NONE);
// vlc.add(toolBar, new VerticalLayoutData(1, -1, new Margins(0)));
vlc.add(gridInputOutputVariables, new VerticalLayoutData(1, 1, new Margins(0)));
vlc.add(gridInputOutputVariables, new VerticalLayoutData(1, 1,
new Margins(0)));
add(vlc, new MarginData(new Margins(0)));
@ -393,6 +413,7 @@ public class InputOutputVariablesPanel extends ContentPanel {
seq++;
inputOutputVariable.setId(seq);
Log.debug("New Input/Output Variable: " + inputOutputVariable);
storeInputOutputVariables.add(inputOutputVariable);
storeInputOutputVariables.commitChanges();
@ -412,12 +433,14 @@ public class InputOutputVariablesPanel extends ContentPanel {
seq++;
InputOutputVariables newInputOutputVariablesVariable = new InputOutputVariables(
seq, "", "", "", DataType.STRING, IOType.INPUT, "");
Log.debug("New Input/Output Variable: " + newInputOutputVariablesVariable);
Log.debug("New Input/Output Variable: "
+ newInputOutputVariablesVariable);
gridInputOutputVariablesEditing.cancelEditing();
addStatus = true;
gridInputOutputVariablesEditing.getCancelButton().setVisible(false);
storeInputOutputVariables.add(newInputOutputVariablesVariable);
int row = storeInputOutputVariables.indexOf(newInputOutputVariablesVariable);
int row = storeInputOutputVariables
.indexOf(newInputOutputVariablesVariable);
storeComboDataType.clear();
storeComboDataType.addAll(DataType.asList());
@ -446,7 +469,7 @@ public class InputOutputVariablesPanel extends ContentPanel {
} else {
storeInputOutputVariables.clear();
storeInputOutputVariables.commitChanges();
seq=0;
seq = 0;
}
}
@ -462,7 +485,7 @@ public class InputOutputVariablesPanel extends ContentPanel {
storeInputOutputVariables.commitChanges();
seq = 0;
forceLayout();
}
}

View File

@ -33,6 +33,7 @@ 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.FieldLabel;
import com.sencha.gxt.widget.core.client.form.TextField;
import com.sencha.gxt.widget.core.client.form.validator.RegExValidator;
import com.sencha.gxt.widget.core.client.grid.ColumnConfig;
import com.sencha.gxt.widget.core.client.grid.ColumnModel;
import com.sencha.gxt.widget.core.client.grid.Grid;
@ -140,12 +141,19 @@ public class InterpreterInfoPanel extends ContentPanel {
gridInterpreterPackageInfo.setColumnReordering(false);
// EDITING //
TextField nameColumnEditing=new TextField();
nameColumnEditing.addValidator(new RegExValidator("^[^\"]*$",
"Attention character \" is not allowed"));
TextField versionColumnEditing=new TextField();
versionColumnEditing.addValidator(new RegExValidator("^[^\"]*$",
"Attention character \" is not allowed"));
gridInterpreterPackageInfoEditing = new GridRowEditing<InterpreterPackageInfo>(
gridInterpreterPackageInfo);
gridInterpreterPackageInfoEditing
.addEditor(nameColumn, new TextField());
.addEditor(nameColumn, nameColumnEditing);
gridInterpreterPackageInfoEditing.addEditor(versionColumn,
new TextField());
versionColumnEditing);
btnAdd = new TextButton("Add");
btnAdd.setIcon(StatAlgoImporterResources.INSTANCE.add16());
@ -250,6 +258,8 @@ public class InterpreterInfoPanel extends ContentPanel {
interpreterVersion = new TextField();
interpreterVersion.setAllowBlank(false);
interpreterVersion.setEmptyText("Enter version...");
interpreterVersion.addValidator(new RegExValidator("^[^\"]*$",
"Attention character \" is not allowed"));
FieldLabel interpreterVersionLabel = new FieldLabel(interpreterVersion,
"Version");

View File

@ -110,6 +110,8 @@ public class ProjectInfoPanel extends ContentPanel {
algorithmDescription = new TextField();
algorithmDescription.setAllowBlank(false);
algorithmDescription.setEmptyText("Enter description...");
algorithmDescription.addValidator(new RegExValidator("^[^\"]*$",
"Attention character \" is not allowed"));
FieldLabel descriptionLabel = new FieldLabel(
algorithmDescription, "Description");
descriptionLabel.setLabelWidth(LABAEL_WIDTH);
@ -121,6 +123,7 @@ public class ProjectInfoPanel extends ContentPanel {
ColumnConfig<RequestedVRE, String> nameColumn = new ColumnConfig<RequestedVRE, String>(
props.name(), 100, "Name");
// nameColumn.setMenuDisabled(true);
ColumnConfig<RequestedVRE, String> descriptionColumn = new ColumnConfig<RequestedVRE, String>(
props.description(), 100, "Description");
@ -169,10 +172,18 @@ public class ProjectInfoPanel extends ContentPanel {
gridRequestedVRE.setColumnReordering(false);
// EDITING //
TextField nameColumnEditing=new TextField();
nameColumnEditing.addValidator(new RegExValidator("^[^\"]*$",
"Attention character \" is not allowed"));
TextField descriptionColumnEditing=new TextField();
descriptionColumnEditing.addValidator(new RegExValidator("^[^\"]*$",
"Attention character \" is not allowed"));
gridRequestedVREEditing = new GridRowEditing<RequestedVRE>(
gridRequestedVRE);
gridRequestedVREEditing.addEditor(nameColumn, new TextField());
gridRequestedVREEditing.addEditor(descriptionColumn, new TextField());
gridRequestedVREEditing.addEditor(nameColumn, nameColumnEditing);
gridRequestedVREEditing.addEditor(descriptionColumn, descriptionColumnEditing);
btnAdd = new TextButton("Add");
btnAdd.setIcon(StatAlgoImporterResources.INSTANCE.add16());

View File

@ -4,6 +4,7 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.lang.ProcessBuilder.Redirect;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@ -383,6 +384,7 @@ public class ProjectBuilder {
throw new StatAlgoImporterServiceException(e.getLocalizedMessage(),
e);
}
return;
}
@ -457,6 +459,21 @@ public class ProjectBuilder {
int exitValue = process.waitFor();
logger.debug("Create Algo Class: Exit Value is " + exitValue);
DirectoryStream<Path> packageHomeStream = Files
.newDirectoryStream(packageHome);
boolean createdFilesClass = false;
for (Path path : packageHomeStream) {
if (path.toString().endsWith(".class")) {
createdFilesClass = true;
break;
}
}
if (!createdFilesClass) {
throw new StatAlgoImporterServiceException(
"Error in the creation of the class files!");
}
} catch (IOException | InterruptedException e) {
logger.error(e.getLocalizedMessage());
e.printStackTrace();