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 { 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)\"))"; 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 ENUM1_PATTERN = "(c\\([^\\)]*\\))";
private static final String ENUM2_PATTERN = "(\\{[^\\}]*\\})"; private static final String ENUM2_PATTERN = "(\\{[^\\}]*\\})";
@ -49,8 +49,8 @@ public class CodeParser {
selectedRowsVariables = new InputOutputVariables( selectedRowsVariables = new InputOutputVariables(
varDescription[0].trim(), varDescription[0].trim(), varDescription[0].trim(), varDescription[0].trim(),
defaultValue, checkDataType(checkDataTypeValue), defaultValue, checkDataType(checkDataTypeValue), ioType,
ioType, parameter); parameter);
} else { } else {
if (parameter.contains("=")) { if (parameter.contains("=")) {
String[] varDescription = parameter.split("="); String[] varDescription = parameter.split("=");

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.event.SelectEvent.SelectHandler;
import com.sencha.gxt.widget.core.client.form.ComboBox; 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.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.ColumnConfig;
import com.sencha.gxt.widget.core.client.grid.ColumnModel; import com.sencha.gxt.widget.core.client.grid.ColumnModel;
import com.sencha.gxt.widget.core.client.grid.Grid; import com.sencha.gxt.widget.core.client.grid.Grid;
@ -191,15 +192,26 @@ public class GlobalVariablesPanel extends ContentPanel {
comboInputType.setTriggerAction(TriggerAction.ALL); comboInputType.setTriggerAction(TriggerAction.ALL);
addHandlersForComboInputType(inputTypePropertiesCombo.label()); 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>( gridGlobalVariableEditing = new GridRowEditing<GlobalVariables>(
gridGlobalVariable); gridGlobalVariable);
gridGlobalVariableEditing.addEditor(nameColumn, new TextField()); gridGlobalVariableEditing.addEditor(nameColumn, nameColumnEditing);
gridGlobalVariableEditing.addEditor(descriptionColumn, gridGlobalVariableEditing.addEditor(descriptionColumn,
new TextField()); descriptionColumnEditing);
gridGlobalVariableEditing.addEditor(inputTypeColumn, gridGlobalVariableEditing.addEditor(inputTypeColumn,
comboInputType); comboInputType);
gridGlobalVariableEditing.addEditor(defaultValueColumn, gridGlobalVariableEditing.addEditor(defaultValueColumn,
new TextField()); defaultValueColumnEditing);
btnAdd = new TextButton("Add"); btnAdd = new TextButton("Add");
btnAdd.setIcon(StatAlgoImporterResources.INSTANCE.add16()); 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.event.SelectEvent.SelectHandler;
import com.sencha.gxt.widget.core.client.form.ComboBox; 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.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.ColumnConfig;
import com.sencha.gxt.widget.core.client.grid.ColumnModel; import com.sencha.gxt.widget.core.client.grid.ColumnModel;
import com.sencha.gxt.widget.core.client.grid.Grid; import com.sencha.gxt.widget.core.client.grid.Grid;
@ -163,12 +164,14 @@ public class InputOutputVariablesPanel extends ContentPanel {
ColumnModel<InputOutputVariables> columns = new ColumnModel<InputOutputVariables>( ColumnModel<InputOutputVariables> columns = new ColumnModel<InputOutputVariables>(
l); l);
storeInputOutputVariables = new ListStore<InputOutputVariables>(props.id()); storeInputOutputVariables = new ListStore<InputOutputVariables>(
props.id());
/* /*
* ArrayList<InputOutputVariablesVariables> list = new ArrayList<>(); for (int i * ArrayList<InputOutputVariablesVariables> list = new ArrayList<>();
* = 0; i < 10; i++) { list.add(new InputOutputVariablesVariables(i, "Test" + i, * for (int i = 0; i < 10; i++) { list.add(new
* "Desc", "defaultValue", InputType.STRING)); } * InputOutputVariablesVariables(i, "Test" + i, "Desc", "defaultValue",
* InputType.STRING)); }
* *
* storeEnvironmentVariable.addAll(list); * storeEnvironmentVariable.addAll(list);
*/ */
@ -182,8 +185,8 @@ public class InputOutputVariablesPanel extends ContentPanel {
final GridSelectionModel<InputOutputVariables> sm = new GridSelectionModel<InputOutputVariables>(); final GridSelectionModel<InputOutputVariables> sm = new GridSelectionModel<InputOutputVariables>();
sm.setSelectionMode(SelectionMode.SINGLE); sm.setSelectionMode(SelectionMode.SINGLE);
gridInputOutputVariables = new Grid<InputOutputVariables>(storeInputOutputVariables, gridInputOutputVariables = new Grid<InputOutputVariables>(
columns); storeInputOutputVariables, columns);
gridInputOutputVariables.setSelectionModel(sm); gridInputOutputVariables.setSelectionModel(sm);
gridInputOutputVariables.getView().setStripeRows(true); gridInputOutputVariables.getView().setStripeRows(true);
gridInputOutputVariables.getView().setColumnLines(true); gridInputOutputVariables.getView().setColumnLines(true);
@ -194,18 +197,21 @@ public class InputOutputVariablesPanel extends ContentPanel {
/* /*
* GridDragSource<InputOutputVariablesVariables> ds = new * GridDragSource<InputOutputVariablesVariables> ds = new
* GridDragSource<InputOutputVariablesVariables>( gridEnvironmentVariable); * GridDragSource<InputOutputVariablesVariables>(
* ds.addDragStartHandler(new DndDragStartHandler() { * gridEnvironmentVariable); ds.addDragStartHandler(new
* DndDragStartHandler() {
* *
* @Override public void onDragStart(DndDragStartEvent event) { * @Override public void onDragStart(DndDragStartEvent event) {
* *
* @SuppressWarnings("unchecked") ArrayList<InputOutputVariablesVariables> * @SuppressWarnings("unchecked")
* draggingSelection = (ArrayList<InputOutputVariablesVariables>) event * ArrayList<InputOutputVariablesVariables> draggingSelection =
* .getData(); Log.debug("Start Drag: " + draggingSelection); * (ArrayList<InputOutputVariablesVariables>) event .getData();
* Log.debug("Start Drag: " + draggingSelection);
* *
* } }); GridDropTarget<InputOutputVariablesVariables> dt = new * } }); GridDropTarget<InputOutputVariablesVariables> dt = new
* GridDropTarget<InputOutputVariablesVariables>( gridEnvironmentVariable); * GridDropTarget<InputOutputVariablesVariables>(
* dt.setFeedback(Feedback.BOTH); dt.setAllowSelfAsSource(true); * gridEnvironmentVariable); dt.setFeedback(Feedback.BOTH);
* dt.setAllowSelfAsSource(true);
*/ */
// EDITING // // EDITING //
@ -248,14 +254,26 @@ public class InputOutputVariablesPanel extends ContentPanel {
storeComboIOType.commitChanges(); 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>( gridInputOutputVariablesEditing = new GridRowEditing<InputOutputVariables>(
gridInputOutputVariables); gridInputOutputVariables);
gridInputOutputVariablesEditing.addEditor(nameColumn, new TextField()); gridInputOutputVariablesEditing
gridInputOutputVariablesEditing.addEditor(descriptionColumn, new TextField()); .addEditor(nameColumn, nameColumnEditing);
gridInputOutputVariablesEditing.addEditor(dataTypeColumn, comboDataType); gridInputOutputVariablesEditing.addEditor(descriptionColumn,
gridInputOutputVariablesEditing.addEditor(defaultValueColumn, new TextField()); descriptionColumnEditing);
gridInputOutputVariablesEditing
.addEditor(dataTypeColumn, comboDataType);
gridInputOutputVariablesEditing.addEditor(defaultValueColumn,
defaultValueColumnEditing);
gridInputOutputVariablesEditing.addEditor(ioTypeColumn, comboIOType); gridInputOutputVariablesEditing.addEditor(ioTypeColumn, comboIOType);
btnAdd = new TextButton(); btnAdd = new TextButton();
@ -282,13 +300,15 @@ public class InputOutputVariablesPanel extends ContentPanel {
storeInputOutputVariables.remove(rowIndex); storeInputOutputVariables.remove(rowIndex);
storeInputOutputVariables.commitChanges(); storeInputOutputVariables.commitChanges();
gridInputOutputVariablesEditing.getCancelButton().setVisible(true); gridInputOutputVariablesEditing.getCancelButton().setVisible(
true);
btnAdd.setEnabled(true); btnAdd.setEnabled(true);
if (addStatus) { if (addStatus) {
addStatus = false; addStatus = false;
} }
List<InputOutputVariables> listIOVariables=storeInputOutputVariables.getAll(); List<InputOutputVariables> listIOVariables = storeInputOutputVariables
.getAll();
List<InputOutputVariables> listNewIOVariables = new ArrayList<InputOutputVariables>(); List<InputOutputVariables> listNewIOVariables = new ArrayList<InputOutputVariables>();
for (int i = 0; i < listIOVariables.size(); i++) { for (int i = 0; i < listIOVariables.size(); i++) {
InputOutputVariables var = listIOVariables.get(i); InputOutputVariables var = listIOVariables.get(i);
@ -349,8 +369,7 @@ public class InputOutputVariablesPanel extends ContentPanel {
btnAdd.setEnabled(true); btnAdd.setEnabled(true);
} catch (Throwable e) { } catch (Throwable e) {
Log.error("Error: " Log.error("Error: " + e.getLocalizedMessage());
+ e.getLocalizedMessage());
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -364,7 +383,8 @@ public class InputOutputVariablesPanel extends ContentPanel {
vlc.setScrollMode(ScrollMode.NONE); vlc.setScrollMode(ScrollMode.NONE);
// vlc.add(toolBar, new VerticalLayoutData(1, -1, new Margins(0))); // 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))); add(vlc, new MarginData(new Margins(0)));
@ -393,6 +413,7 @@ public class InputOutputVariablesPanel extends ContentPanel {
seq++; seq++;
inputOutputVariable.setId(seq); inputOutputVariable.setId(seq);
Log.debug("New Input/Output Variable: " + inputOutputVariable); Log.debug("New Input/Output Variable: " + inputOutputVariable);
storeInputOutputVariables.add(inputOutputVariable); storeInputOutputVariables.add(inputOutputVariable);
storeInputOutputVariables.commitChanges(); storeInputOutputVariables.commitChanges();
@ -412,12 +433,14 @@ public class InputOutputVariablesPanel extends ContentPanel {
seq++; seq++;
InputOutputVariables newInputOutputVariablesVariable = new InputOutputVariables( InputOutputVariables newInputOutputVariablesVariable = new InputOutputVariables(
seq, "", "", "", DataType.STRING, IOType.INPUT, ""); seq, "", "", "", DataType.STRING, IOType.INPUT, "");
Log.debug("New Input/Output Variable: " + newInputOutputVariablesVariable); Log.debug("New Input/Output Variable: "
+ newInputOutputVariablesVariable);
gridInputOutputVariablesEditing.cancelEditing(); gridInputOutputVariablesEditing.cancelEditing();
addStatus = true; addStatus = true;
gridInputOutputVariablesEditing.getCancelButton().setVisible(false); gridInputOutputVariablesEditing.getCancelButton().setVisible(false);
storeInputOutputVariables.add(newInputOutputVariablesVariable); storeInputOutputVariables.add(newInputOutputVariablesVariable);
int row = storeInputOutputVariables.indexOf(newInputOutputVariablesVariable); int row = storeInputOutputVariables
.indexOf(newInputOutputVariablesVariable);
storeComboDataType.clear(); storeComboDataType.clear();
storeComboDataType.addAll(DataType.asList()); storeComboDataType.addAll(DataType.asList());

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

View File

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

View File

@ -4,6 +4,7 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.lang.ProcessBuilder.Redirect; import java.lang.ProcessBuilder.Redirect;
import java.nio.file.DirectoryStream;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
@ -383,6 +384,7 @@ public class ProjectBuilder {
throw new StatAlgoImporterServiceException(e.getLocalizedMessage(), throw new StatAlgoImporterServiceException(e.getLocalizedMessage(),
e); e);
} }
return; return;
} }
@ -457,6 +459,21 @@ public class ProjectBuilder {
int exitValue = process.waitFor(); int exitValue = process.waitFor();
logger.debug("Create Algo Class: Exit Value is " + exitValue); 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) { } catch (IOException | InterruptedException e) {
logger.error(e.getLocalizedMessage()); logger.error(e.getLocalizedMessage());
e.printStackTrace(); e.printStackTrace();