1452: Implement a GUI for StatMan Algorithms Importer

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

Updated UI behavior

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/statistical-algorithms-importer@122173 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2016-01-08 16:03:44 +00:00
parent 89bb818699
commit d5fe4657c5
7 changed files with 165 additions and 26 deletions
src
main
java/org/gcube/portlets/user/statisticalalgorithmsimporter
resources/org/gcube/portlets/user/statisticalalgorithmsimporter
test/resources/org/gcube/portlets/user/statisticalalgorithmsimporter/example

View File

@ -4,6 +4,7 @@ import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.DataTy
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.IOType;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.SelectedRowsVariables;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.regexp.shared.RegExp;
/**
@ -32,24 +33,37 @@ public class CodeParser {
if (parameter.contains("<-")) {
String[] varDescription = parameter.split("<-");
String defaultValue = varDescription[1].trim();
if (defaultValue.startsWith("\""))
defaultValue = defaultValue.substring(1);
if (defaultValue.endsWith("\""))
defaultValue = defaultValue.substring(0,
defaultValue.length() - 1);
selectedRowsVariables = new SelectedRowsVariables(
varDescription[0].trim(), varDescription[0].trim(),
varDescription[1].trim(),
checkDataType(varDescription[1].trim()), ioType, parameter);
defaultValue, checkDataType(varDescription[1].trim()),
ioType, parameter);
} else {
if (parameter.contains("=")) {
String[] varDescription = parameter.split("=");
String defaultValue = varDescription[1].trim();
if (defaultValue.startsWith("\""))
defaultValue = defaultValue.substring(1);
if (defaultValue.endsWith("\""))
defaultValue = defaultValue.substring(0,
defaultValue.length() - 1);
selectedRowsVariables = new SelectedRowsVariables(
varDescription[0].trim(), varDescription[0].trim(),
varDescription[1].trim(),
checkDataType(varDescription[1].trim()), ioType,
parameter);
defaultValue, checkDataType(varDescription[1].trim()),
ioType, parameter);
} else {
return null;
}
}
Log.debug("CodeParser: " + selectedRowsVariables);
return selectedRowsVariables;
}

View File

@ -106,7 +106,7 @@ public class EnvironmentVariablesPanel extends ContentPanel {
// nameColumn.setMenuDisabled(true);
ColumnConfig<EnvironmentVariables, String> descriptionColumn = new ColumnConfig<EnvironmentVariables, String>(
props.name(), 100, "Description");
props.description(), 100, "Description");
// descriptionColumn.setMenuDisabled(true);
ColumnConfig<EnvironmentVariables, DataType> inputTypeColumn = new ColumnConfig<EnvironmentVariables, DataType>(

View File

@ -118,7 +118,7 @@ public class SelectedRowsPanel extends ContentPanel {
// nameColumn.setMenuDisabled(true);
ColumnConfig<SelectedRowsVariables, String> descriptionColumn = new ColumnConfig<SelectedRowsVariables, String>(
props.name(), 100, "Description");
props.description(), 100, "Description");
// descriptionColumn.setMenuDisabled(true);
ColumnConfig<SelectedRowsVariables, DataType> dataTypeColumn = new ColumnConfig<SelectedRowsVariables, DataType>(

View File

@ -0,0 +1,55 @@
package org.gcube.portlets.user.statisticalalgorithmsimporter.server.generator;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
import org.apache.commons.io.IOUtils;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterServiceException;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Project;
/**
*
* @author Giancarlo Panichi email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class AlgorithmGenerator {
private static final String EXTENTION_JAVA = ".java";
private Project project;
public AlgorithmGenerator(Project project) {
super();
this.project = project;
}
@Override
public String toString() {
return "AlgorithmGenerator [project=" + project + "]";
}
public File createAlgorithm() throws StatAlgoImporterServiceException {
try {
File fileTmp = File.createTempFile(project.getClassName(),
EXTENTION_JAVA);
fileTmp.deleteOnExit();
/*
List<String> lines = Arrays.asList("The first line", "The second line");
Path file = Paths.g;
Files.write(file, lines, Charset.forName("UTF-8"));
*/
return fileTmp;
} catch (IOException e) {
e.printStackTrace();
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
}
}
}

View File

@ -10,22 +10,50 @@ import java.io.Serializable;
*/
public class Project implements Serializable {
private static final long serialVersionUID = -7906477664944910362L;
private String name;
private String description;
private String className;
private ProjectFolder projectFolder;
private MainCode mainCode;
private InputData inputData;
public Project(){
public Project() {
super();
}
public Project(ProjectFolder projectFolder) {
super();
this.projectFolder=projectFolder;
this.projectFolder = projectFolder;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getClassName() {
return className;
}
public void setClassName(String className) {
this.className = className;
}
public MainCode getMainCode() {
return mainCode;
}
@ -52,12 +80,11 @@ public class Project implements Serializable {
@Override
public String toString() {
return "Project [projectFolder=" + projectFolder + ", mainCode="
+ mainCode + ", inputData=" + inputData + "]";
return "Project [name=" + name + ", description=" + description
+ ", className=" + className + ", projectFolder="
+ projectFolder + ", mainCode=" + mainCode + ", inputData="
+ inputData + "]";
}
}

View File

@ -51,17 +51,17 @@
name="locale" values="es" /> <set-property name="locale" value="en, it, es"
/> <set-property-fallback name="locale" value="en" /> -->
<set-property name="log_ConsoleLogger" value="ENABLED" />
<set-property name="log_DivLogger" value="ENABLED" />
<set-property name="log_GWTLogger" value="ENABLED" />
<set-property name="log_SystemLogger" value="ENABLED" />
<!-- <set-property name="log_ConsoleLogger" value="ENABLED" /> <set-property
name="log_DivLogger" value="ENABLED" /> <set-property name="log_GWTLogger"
value="ENABLED" /> <set-property name="log_SystemLogger" value="ENABLED"
/> -->
<!-- Not in GWT 2.6 <set-property name="log_FirebugLogger" value="ENABLED"
/> -->
<!-- <set-property name="log_ConsoleLogger" value="DISABLED" /> <set-property
name="log_DivLogger" value="DISABLED" /> <set-property name="log_GWTLogger"
value="DISABLED" /> <set-property name="log_SystemLogger" value="DISABLED"
/> -->
<set-property name="log_ConsoleLogger" value="DISABLED" />
<set-property name="log_DivLogger" value="DISABLED" />
<set-property name="log_GWTLogger" value="DISABLED" />
<set-property name="log_SystemLogger" value="DISABLED" />
<!-- Not in GWT 2.6 <set-property name="log_FirebugLogger" value="DISABLED"
/> -->

View File

@ -0,0 +1,43 @@
package org.gcube.dataanalysis.executor.rscripts;
import java.io.File;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import org.gcube.dataanalysis.ecoengine.datatypes.PrimitiveType;
import org.gcube.dataanalysis.ecoengine.datatypes.StatisticalType;
import org.gcube.dataanalysis.ecoengine.datatypes.enumtypes.PrimitiveTypes;
import org.gcube.dataanalysis.executor.rscripts.generic.GenericRScript;
public class KnitrCompiler extends GenericRScript {
@Override
public String getDescription() {
return "An algorithm to compile Knitr documents. Developed by IRD (reference Julien Bard, julien.barde@ird.fr)";
}
protected void initVariables(){
mainScriptName="IRDTunaAtlas-master/report/knitr/compileKnitR_CNR.R";
packageURL="http://goo.gl/T7V8LV";
environmentalvariables = new ArrayList<String>();
inputvariables.add("zipfile");
inputvariables.add("file.inout");
outputvariables.add("pdfresult");
}
@Override
protected void setInputParameters() {
inputs.add(new PrimitiveType(File.class.getName(), null, PrimitiveTypes.FILE, "zipfile", "The file containing R and the markdown (Rnw) files to compile","knitr_wfs.zip"));
inputs.add(new PrimitiveType(String.class.getName(), null, PrimitiveTypes.STRING, "file.inout", "The name of the R file in the zip package", "main.r"));
}
@Override
public StatisticalType getOutput() {
output.put("pdfresult",new PrimitiveType(File.class.getName(), new File(outputValues.get("pdfresult")), PrimitiveTypes.FILE, "pdfresult", "The compiled PDF file"));
PrimitiveType o = new PrimitiveType(LinkedHashMap.class.getName(), output, PrimitiveTypes.MAP, "Output", "");
return o;
}
}