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:
parent
89bb818699
commit
d5fe4657c5
|
@ -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.IOType;
|
||||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.SelectedRowsVariables;
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.SelectedRowsVariables;
|
||||||
|
|
||||||
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
import com.google.gwt.regexp.shared.RegExp;
|
import com.google.gwt.regexp.shared.RegExp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32,24 +33,37 @@ public class CodeParser {
|
||||||
|
|
||||||
if (parameter.contains("<-")) {
|
if (parameter.contains("<-")) {
|
||||||
String[] varDescription = parameter.split("<-");
|
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(
|
selectedRowsVariables = new SelectedRowsVariables(
|
||||||
varDescription[0].trim(), varDescription[0].trim(),
|
varDescription[0].trim(), varDescription[0].trim(),
|
||||||
varDescription[1].trim(),
|
defaultValue, checkDataType(varDescription[1].trim()),
|
||||||
checkDataType(varDescription[1].trim()), ioType, parameter);
|
ioType, parameter);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (parameter.contains("=")) {
|
if (parameter.contains("=")) {
|
||||||
String[] varDescription = parameter.split("=");
|
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(
|
selectedRowsVariables = new SelectedRowsVariables(
|
||||||
varDescription[0].trim(), varDescription[0].trim(),
|
varDescription[0].trim(), varDescription[0].trim(),
|
||||||
varDescription[1].trim(),
|
defaultValue, checkDataType(varDescription[1].trim()),
|
||||||
checkDataType(varDescription[1].trim()), ioType,
|
ioType, parameter);
|
||||||
parameter);
|
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Log.debug("CodeParser: " + selectedRowsVariables);
|
||||||
return selectedRowsVariables;
|
return selectedRowsVariables;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -106,7 +106,7 @@ public class EnvironmentVariablesPanel extends ContentPanel {
|
||||||
// nameColumn.setMenuDisabled(true);
|
// nameColumn.setMenuDisabled(true);
|
||||||
|
|
||||||
ColumnConfig<EnvironmentVariables, String> descriptionColumn = new ColumnConfig<EnvironmentVariables, String>(
|
ColumnConfig<EnvironmentVariables, String> descriptionColumn = new ColumnConfig<EnvironmentVariables, String>(
|
||||||
props.name(), 100, "Description");
|
props.description(), 100, "Description");
|
||||||
// descriptionColumn.setMenuDisabled(true);
|
// descriptionColumn.setMenuDisabled(true);
|
||||||
|
|
||||||
ColumnConfig<EnvironmentVariables, DataType> inputTypeColumn = new ColumnConfig<EnvironmentVariables, DataType>(
|
ColumnConfig<EnvironmentVariables, DataType> inputTypeColumn = new ColumnConfig<EnvironmentVariables, DataType>(
|
||||||
|
|
|
@ -118,7 +118,7 @@ public class SelectedRowsPanel extends ContentPanel {
|
||||||
// nameColumn.setMenuDisabled(true);
|
// nameColumn.setMenuDisabled(true);
|
||||||
|
|
||||||
ColumnConfig<SelectedRowsVariables, String> descriptionColumn = new ColumnConfig<SelectedRowsVariables, String>(
|
ColumnConfig<SelectedRowsVariables, String> descriptionColumn = new ColumnConfig<SelectedRowsVariables, String>(
|
||||||
props.name(), 100, "Description");
|
props.description(), 100, "Description");
|
||||||
// descriptionColumn.setMenuDisabled(true);
|
// descriptionColumn.setMenuDisabled(true);
|
||||||
|
|
||||||
ColumnConfig<SelectedRowsVariables, DataType> dataTypeColumn = new ColumnConfig<SelectedRowsVariables, DataType>(
|
ColumnConfig<SelectedRowsVariables, DataType> dataTypeColumn = new ColumnConfig<SelectedRowsVariables, DataType>(
|
||||||
|
|
|
@ -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());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -10,8 +10,12 @@ import java.io.Serializable;
|
||||||
*/
|
*/
|
||||||
public class Project implements Serializable {
|
public class Project implements Serializable {
|
||||||
|
|
||||||
|
|
||||||
private static final long serialVersionUID = -7906477664944910362L;
|
private static final long serialVersionUID = -7906477664944910362L;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private String description;
|
||||||
|
private String className;
|
||||||
private ProjectFolder projectFolder;
|
private ProjectFolder projectFolder;
|
||||||
private MainCode mainCode;
|
private MainCode mainCode;
|
||||||
private InputData inputData;
|
private InputData inputData;
|
||||||
|
@ -26,6 +30,30 @@ public class Project implements Serializable {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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() {
|
public MainCode getMainCode() {
|
||||||
return mainCode;
|
return mainCode;
|
||||||
}
|
}
|
||||||
|
@ -52,12 +80,11 @@ public class Project implements Serializable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Project [projectFolder=" + projectFolder + ", mainCode="
|
return "Project [name=" + name + ", description=" + description
|
||||||
+ mainCode + ", inputData=" + inputData + "]";
|
+ ", className=" + className + ", projectFolder="
|
||||||
|
+ projectFolder + ", mainCode=" + mainCode + ", inputData="
|
||||||
|
+ inputData + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,17 +51,17 @@
|
||||||
name="locale" values="es" /> <set-property name="locale" value="en, it, es"
|
name="locale" values="es" /> <set-property name="locale" value="en, it, es"
|
||||||
/> <set-property-fallback name="locale" value="en" /> -->
|
/> <set-property-fallback name="locale" value="en" /> -->
|
||||||
|
|
||||||
<set-property name="log_ConsoleLogger" value="ENABLED" />
|
<!-- <set-property name="log_ConsoleLogger" value="ENABLED" /> <set-property
|
||||||
<set-property name="log_DivLogger" value="ENABLED" />
|
name="log_DivLogger" value="ENABLED" /> <set-property name="log_GWTLogger"
|
||||||
<set-property name="log_GWTLogger" value="ENABLED" />
|
value="ENABLED" /> <set-property name="log_SystemLogger" value="ENABLED"
|
||||||
<set-property name="log_SystemLogger" value="ENABLED" />
|
/> -->
|
||||||
<!-- Not in GWT 2.6 <set-property name="log_FirebugLogger" value="ENABLED"
|
<!-- Not in GWT 2.6 <set-property name="log_FirebugLogger" value="ENABLED"
|
||||||
/> -->
|
/> -->
|
||||||
|
|
||||||
<!-- <set-property name="log_ConsoleLogger" value="DISABLED" /> <set-property
|
<set-property name="log_ConsoleLogger" value="DISABLED" />
|
||||||
name="log_DivLogger" value="DISABLED" /> <set-property name="log_GWTLogger"
|
<set-property name="log_DivLogger" value="DISABLED" />
|
||||||
value="DISABLED" /> <set-property name="log_SystemLogger" 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"
|
<!-- Not in GWT 2.6 <set-property name="log_FirebugLogger" value="DISABLED"
|
||||||
/> -->
|
/> -->
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue