1452: Implement a GUI for StatMan Algorithms Importer
Task-Url: https://support.d4science.org/issues/1452 Fixed enumerated Input/Output parameters git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/statistical-algorithms-importer@122680 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
b289d6718f
commit
cdb0ea5424
|
@ -323,7 +323,7 @@ public class StatAlgoImporterController {
|
|||
pm.saveProject(event.getInputData(), monitor);
|
||||
break;
|
||||
case SoftwareCreate:
|
||||
pm.createSofware(event.getInputData(), monitor);
|
||||
pm.softwareCreate(event.getInputData(), monitor);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -17,8 +17,8 @@ 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|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() {
|
||||
|
||||
|
@ -111,6 +111,7 @@ public class CodeParser {
|
|||
return DataType.FILE;
|
||||
}
|
||||
|
||||
/*
|
||||
RegExp regExpEnum1 = RegExp.compile(ENUM1_PATTERN);
|
||||
if (regExpEnum1.test(data)) {
|
||||
return DataType.ENUMERATED;
|
||||
|
@ -119,7 +120,7 @@ public class CodeParser {
|
|||
RegExp regExpEnum2 = RegExp.compile(ENUM2_PATTERN);
|
||||
if (regExpEnum2.test(data)) {
|
||||
return DataType.ENUMERATED;
|
||||
}
|
||||
}*/
|
||||
|
||||
try {
|
||||
Integer.parseInt(data);
|
||||
|
|
|
@ -73,6 +73,7 @@ public class MainDataPanel extends SimpleContainer {
|
|||
case SOFTWARE_REPACKAGE:
|
||||
case ADD_RESOURCE:
|
||||
case DELETE_RESOURCE:
|
||||
case EXPLORER_REFRESH:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -194,7 +194,7 @@ public class ProjectManager {
|
|||
}
|
||||
|
||||
private void addResourceToProject(Item item) {
|
||||
final StatAlgoImporterMonitor monitor=new StatAlgoImporterMonitor();
|
||||
final StatAlgoImporterMonitor monitor = new StatAlgoImporterMonitor();
|
||||
Log.debug("Add Resource To Project Item selected: " + item);
|
||||
ItemDescription itemDescription = new ItemDescription(item.getId(),
|
||||
item.getName(), item.getOwner(), item.getPath(), item.getType()
|
||||
|
@ -228,7 +228,7 @@ public class ProjectManager {
|
|||
}
|
||||
|
||||
private void createProjectOnServer(Item item) {
|
||||
final StatAlgoImporterMonitor monitor=new StatAlgoImporterMonitor();
|
||||
final StatAlgoImporterMonitor monitor = new StatAlgoImporterMonitor();
|
||||
Log.debug("Create Project Item selected: " + item);
|
||||
final ItemDescription newProjectFolder = new ItemDescription(
|
||||
item.getId(), item.getName(), item.getOwner(), item.getPath(),
|
||||
|
@ -263,8 +263,8 @@ public class ProjectManager {
|
|||
}
|
||||
|
||||
protected void openProjectOnServer(Item item) {
|
||||
final StatAlgoImporterMonitor monitor=new StatAlgoImporterMonitor();
|
||||
|
||||
final StatAlgoImporterMonitor monitor = new StatAlgoImporterMonitor();
|
||||
|
||||
Log.debug("Open Project Item selected: " + item);
|
||||
final ItemDescription newProjectFolder = new ItemDescription(
|
||||
item.getId(), item.getName(), item.getOwner(), item.getPath(),
|
||||
|
@ -330,7 +330,7 @@ public class ProjectManager {
|
|||
});
|
||||
}
|
||||
|
||||
public void createSofware(final InputData inputData,
|
||||
public void softwareCreate(final InputData inputData,
|
||||
final StatAlgoImporterMonitor monitor) {
|
||||
|
||||
StatAlgoImporterServiceAsync.INSTANCE.createSoftware(inputData,
|
||||
|
@ -355,6 +355,8 @@ public class ProjectManager {
|
|||
+ caught.getLocalizedMessage());
|
||||
UtilsGXT3.alert("Error",
|
||||
caught.getLocalizedMessage());
|
||||
fireProjectStatusExplorerRefreshEvent();
|
||||
|
||||
}
|
||||
caught.printStackTrace();
|
||||
|
||||
|
@ -548,7 +550,6 @@ public class ProjectManager {
|
|||
|
||||
}
|
||||
|
||||
|
||||
public void startProjectManager(String value) {
|
||||
|
||||
StatAlgoImporterServiceAsync.INSTANCE.restoreUISession(value,
|
||||
|
@ -575,7 +576,7 @@ public class ProjectManager {
|
|||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void softwareRepackage() {
|
||||
if (project != null) {
|
||||
final ConfirmMessageBox mb = new ConfirmMessageBox(
|
||||
|
@ -605,9 +606,8 @@ public class ProjectManager {
|
|||
UtilsGXT3.alert("Error", "Project not open!");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void softwareRepackageOnServer() {
|
||||
final StatAlgoImporterMonitor monitor = new StatAlgoImporterMonitor();
|
||||
StatAlgoImporterServiceAsync.INSTANCE
|
||||
|
@ -621,7 +621,7 @@ public class ProjectManager {
|
|||
} else {
|
||||
UtilsGXT3.alert("Error",
|
||||
caught.getLocalizedMessage());
|
||||
|
||||
fireProjectStatusExplorerRefreshEvent();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -634,8 +634,6 @@ public class ProjectManager {
|
|||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void softwarePublish() {
|
||||
if (project != null) {
|
||||
|
@ -681,6 +679,7 @@ public class ProjectManager {
|
|||
} else {
|
||||
UtilsGXT3.alert("Error",
|
||||
caught.getLocalizedMessage());
|
||||
fireProjectStatusExplorerRefreshEvent();
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -707,7 +706,6 @@ public class ProjectManager {
|
|||
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private void fireProjectStatusSaveProjectEvent() {
|
||||
ProjectStatusEvent projectStatusEvent = new ProjectStatusEvent(
|
||||
|
@ -745,6 +743,13 @@ public class ProjectManager {
|
|||
Log.debug("ProjectStatusEvent fired! " + projectStatusEvent);
|
||||
}
|
||||
|
||||
private void fireProjectStatusExplorerRefreshEvent() {
|
||||
ProjectStatusEvent projectStatusEvent = new ProjectStatusEvent(
|
||||
ProjectStatusEventType.EXPLORER_REFRESH, project);
|
||||
eventBus.fireEvent(projectStatusEvent);
|
||||
Log.debug("ProjectStatusEvent fired! " + projectStatusEvent);
|
||||
}
|
||||
|
||||
private void fireProjectStatusMainCodeSetEvent() {
|
||||
ProjectStatusEvent projectStatusEvent = new ProjectStatusEvent(
|
||||
ProjectStatusEventType.MAIN_CODE_SET, project);
|
||||
|
@ -758,22 +763,20 @@ public class ProjectManager {
|
|||
eventBus.fireEvent(projectStatusEvent);
|
||||
Log.debug("ProjectStatusEvent fired! " + projectStatusEvent);
|
||||
}
|
||||
|
||||
|
||||
private void fireProjectStatusSoftwarePublishEvent() {
|
||||
ProjectStatusEvent projectStatusEvent = new ProjectStatusEvent(
|
||||
ProjectStatusEventType.SOFTWARE_PUBLISH, project);
|
||||
eventBus.fireEvent(projectStatusEvent);
|
||||
Log.debug("ProjectStatusEvent fired! " + projectStatusEvent);
|
||||
}
|
||||
|
||||
|
||||
private void fireProjectStatusSoftwareRepackageEvent() {
|
||||
ProjectStatusEvent projectStatusEvent = new ProjectStatusEvent(
|
||||
ProjectStatusEventType.SOFTWARE_REPACKAGE, project);
|
||||
eventBus.fireEvent(projectStatusEvent);
|
||||
Log.debug("ProjectStatusEvent fired! " + projectStatusEvent);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void fireProjectStatusStartEvent() {
|
||||
ProjectStatusEvent projectStatusEvent = new ProjectStatusEvent(
|
||||
|
@ -782,5 +785,4 @@ public class ProjectManager {
|
|||
Log.debug("ProjectStatusEvent fired! " + projectStatusEvent);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -119,7 +119,8 @@ public class ExplorerProjectPanel extends ContentPanel {
|
|||
case MAIN_CODE_SET:
|
||||
case SOFTWARE_CREATED:
|
||||
case SOFTWARE_PUBLISH:
|
||||
case SOFTWARE_REPACKAGE:
|
||||
case SOFTWARE_REPACKAGE:
|
||||
case EXPLORER_REFRESH:
|
||||
reloadWSResourceExplorerPanel();
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -397,7 +397,8 @@ public class GlobalVariablesPanel extends ContentPanel {
|
|||
int row = storeGlobalVariable.indexOf(newGlobalVariable);
|
||||
|
||||
storeComboInputType.clear();
|
||||
storeComboInputType.addAll(DataType.asList());
|
||||
|
||||
storeComboInputType.addAll(DataType.asListForGlobalVariables());
|
||||
storeComboInputType.commitChanges();
|
||||
|
||||
gridGlobalVariableEditing.startEditing(new GridCell(row, 0));
|
||||
|
|
|
@ -115,6 +115,7 @@ public class InputVariablePanel extends ContentPanel {
|
|||
case START:
|
||||
case ADD_RESOURCE:
|
||||
case DELETE_RESOURCE:
|
||||
case EXPLORER_REFRESH:
|
||||
break;
|
||||
case OPEN:
|
||||
create(event.getProject());
|
||||
|
|
|
@ -17,6 +17,7 @@ public enum ProjectStatusEventType {
|
|||
SOFTWARE_CREATED,
|
||||
SOFTWARE_PUBLISH,
|
||||
SOFTWARE_REPACKAGE,
|
||||
EXPLORER_REFRESH,
|
||||
SAVE;
|
||||
|
||||
|
||||
|
|
|
@ -7,9 +7,12 @@ import java.nio.file.Path;
|
|||
import java.nio.file.StandardOpenOption;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterServiceException;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.DataType;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.GlobalVariables;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.IOType;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.InputOutputVariables;
|
||||
|
@ -30,6 +33,7 @@ public class AlgorithmGenerator {
|
|||
.getLogger(AlgorithmGenerator.class);
|
||||
|
||||
private Project project;
|
||||
private HashMap<String, String> enumUUID;
|
||||
|
||||
public AlgorithmGenerator(Project project) {
|
||||
super();
|
||||
|
@ -42,10 +46,10 @@ public class AlgorithmGenerator {
|
|||
}
|
||||
|
||||
public Path createAlgorithm() throws StatAlgoImporterServiceException {
|
||||
|
||||
try {
|
||||
Path tempFile = Files.createTempFile(project.getInputData()
|
||||
.getProjectInfo().getAlgorithmNameToClassName(), EXTENTION_JAVA);
|
||||
.getProjectInfo().getAlgorithmNameToClassName(),
|
||||
EXTENTION_JAVA);
|
||||
|
||||
List<String> lines = createJavaCode();
|
||||
Files.write(tempFile, lines, Charset.defaultCharset(),
|
||||
|
@ -65,8 +69,8 @@ public class AlgorithmGenerator {
|
|||
private List<String> createJavaCode() {
|
||||
String mainScriptRelativePath = retrieveMainScriptRelativePath();
|
||||
String packageUrl = retrievePackageUrl();
|
||||
|
||||
ArrayList<String> code = new ArrayList<String>();
|
||||
enumUUID = new HashMap<>();
|
||||
ArrayList<String> code = new ArrayList<>();
|
||||
|
||||
code.addAll(Arrays
|
||||
.asList("package org.gcube.dataanalysis.executor.rscripts;",
|
||||
|
@ -78,26 +82,177 @@ public class AlgorithmGenerator {
|
|||
"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 "
|
||||
"import org.gcube.dataanalysis.ecoengine.utils.DynamicEnum;",
|
||||
"import java.lang.reflect.Field;", "", "public class "
|
||||
+ project.getInputData().getProjectInfo()
|
||||
.getAlgorithmNameToClassName()
|
||||
+ " extends GenericRScript {", "",
|
||||
+ " extends GenericRScript {"));
|
||||
|
||||
" public static enum operators {",
|
||||
" EQUAL, NOT_EQUAL, CONTAINS, BEGINS_WITH, ENDS_WITH",
|
||||
" };", "", " @Override",
|
||||
" public String getDescription() {", " return \""
|
||||
+ project.getInputData().getProjectInfo()
|
||||
.getAlgorithmDescription() + "\";", " }", "",
|
||||
" protected void initVariables(){",
|
||||
" mainScriptName=\"" + mainScriptRelativePath + "\";",
|
||||
" packageURL=\"" + packageUrl + "\";",
|
||||
" environmentalvariables = new ArrayList<String>();"));
|
||||
|
||||
for (GlobalVariables envVariable : project.getInputData()
|
||||
for (GlobalVariables globalVariable : project.getInputData()
|
||||
.getListGlobalVariables()) {
|
||||
code.add(" environmentalvariables.add(\"" + envVariable.getName()
|
||||
+ "\");");
|
||||
if (globalVariable.getDataType().compareTo(DataType.ENUMERATED) == 0) {
|
||||
if (globalVariable.getDefaultValue() == null
|
||||
|| globalVariable.getDefaultValue().isEmpty()) {
|
||||
|
||||
} else {
|
||||
String uuid = "" + UUID.randomUUID();
|
||||
uuid = uuid.replaceAll("-", "");
|
||||
String nameEnum = "opGV" + globalVariable.getId() + uuid;
|
||||
enumUUID.put("opGV" + globalVariable.getId(), nameEnum);
|
||||
|
||||
code.add("");
|
||||
code.add(" static class " + nameEnum
|
||||
+ " extends DynamicEnum {");
|
||||
code.add(" public enum E" + nameEnum + " {};");
|
||||
code.add(" public Field[] getFields() {");
|
||||
code.add(" Field[] fields = E" + nameEnum
|
||||
+ ".class.getDeclaredFields();");
|
||||
code.add(" return fields;");
|
||||
code.add(" }");
|
||||
code.add(" }");
|
||||
|
||||
/*
|
||||
* code.add(" String[] "+ nameEnum + " = {"); String[]
|
||||
* values = globalVariable.getDefaultValue().split( "\\|");
|
||||
* if (values.length < 1) {
|
||||
*
|
||||
* } else { for (int i = 0; i < values.length; i++) { if (i
|
||||
* == values.length - 1) { code.add(" \"" + values[i] +
|
||||
* "\""); } else { code.add(" \"" + values[i] + "\","); } }
|
||||
* } code.add(" };");
|
||||
*/
|
||||
/*
|
||||
* code.add(" public static enum opGV" +
|
||||
* globalVariable.getId() + " {"); String[] values =
|
||||
* globalVariable.getDefaultValue().split( "\\|"); if
|
||||
* (values.length < 1) {
|
||||
*
|
||||
* } else { for (int i = 0; i < values.length; i++) { String
|
||||
* identifier = values[i].trim();
|
||||
* identifier=identifier.replaceAll("\\s+","");
|
||||
*
|
||||
* if (i == values.length - 1) { code.add(" " + identifier
|
||||
* + "(\"" + values[i] + "\");"); } else { code.add(" " +
|
||||
* identifier + "(\"" + values[i] + "\"),"); } } }
|
||||
*
|
||||
* code.add(" "); code.add(" private final String id;");
|
||||
* code.add(" "); code.add(" private opGV" +
|
||||
* globalVariable.getId() + "(final String id) {");
|
||||
* code.add(" this.id = id;"); code.add(" }");
|
||||
* code.add(" "); code.add(" @Override");
|
||||
* code.add(" public String toString() {");
|
||||
* code.add(" return id;"); code.add(" }");
|
||||
* code.add(" "); code.add(" public String getId() {");
|
||||
* code.add(" return id;"); code.add(" }");
|
||||
* code.add(" ");
|
||||
*
|
||||
* code.add(" public opIO" + globalVariable.getId() +
|
||||
* " getIdentifier(String identifier){");
|
||||
* code.add(" if(identifier==null|| identifier.isEmpty()){"
|
||||
* ); code.add(" return null;"); code.add(" }");
|
||||
* code.add(" "); code.add(" for(opIO" +
|
||||
* globalVariable.getId() + " value:opIO" +
|
||||
* globalVariable.getId() + ".values()){");
|
||||
* code.add(" if(value.id.compareTo(identifier)==0){");
|
||||
* code.add(" return value;"); code.add(" }");
|
||||
* code.add(" }"); code.add(" return null;");
|
||||
* code.add(" }"); code.add(" "); code.add(" }");
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (InputOutputVariables inputOutputVariable : project.getInputData()
|
||||
.getListInputOutputVariables()) {
|
||||
if (inputOutputVariable.getDataType()
|
||||
.compareTo(DataType.ENUMERATED) == 0) {
|
||||
if (inputOutputVariable.getDefaultValue() == null
|
||||
|| inputOutputVariable.getDefaultValue().isEmpty()) {
|
||||
|
||||
} else {
|
||||
String uuid = "" + UUID.randomUUID();
|
||||
uuid = uuid.replaceAll("-", "");
|
||||
String nameEnum = "opIO" + inputOutputVariable.getId()
|
||||
+ uuid;
|
||||
enumUUID.put("opIO" + inputOutputVariable.getId(), nameEnum);
|
||||
|
||||
code.add("");
|
||||
code.add(" static class " + nameEnum
|
||||
+ " extends DynamicEnum {");
|
||||
code.add(" public enum E" + nameEnum + " {};");
|
||||
code.add(" public Field[] getFields() {");
|
||||
code.add(" Field[] fields = E" + nameEnum
|
||||
+ ".class.getDeclaredFields();");
|
||||
code.add(" return fields;");
|
||||
code.add(" }");
|
||||
code.add(" }");
|
||||
|
||||
/*
|
||||
* code.add(" String[] opIO" + inputOutputVariable.getId() +
|
||||
* " = {"); String[] values =
|
||||
* inputOutputVariable.getDefaultValue() .split("\\|"); if
|
||||
* (values.length < 1) {
|
||||
*
|
||||
* } else { for (int i = 0; i < values.length; i++) { if (i
|
||||
* == values.length - 1) { code.add(" \"" + values[i] +
|
||||
* "\""); } else { code.add(" \"" + values[i] + "\","); } }
|
||||
* } code.add(" };");
|
||||
*/
|
||||
|
||||
/*
|
||||
* code.add(" public static enum opIO"
|
||||
*
|
||||
* + inputOutputVariable.getId() + " {"); String[] values =
|
||||
* inputOutputVariable.getDefaultValue() .split("\\|"); if
|
||||
* (values.length < 1) {
|
||||
*
|
||||
* } else { for (int i = 0; i < values.length; i++) { String
|
||||
* identifier = values[i].trim(); identifier =
|
||||
* identifier.replaceAll("\\s+", ""); if (i == values.length
|
||||
* - 1) { code.add(" " + identifier + "(\"" + values[i] +
|
||||
* "\");"); } else { code.add(" " + identifier + "(\"" +
|
||||
* values[i] + "\"),"); } } } code.add(" ");
|
||||
* code.add(" private final String id;"); code.add(" ");
|
||||
* code.add(" private opIO" + inputOutputVariable.getId() +
|
||||
* "(final String id) {"); code.add(" this.id = id;");
|
||||
* code.add(" }"); code.add(" "); code.add(" @Override");
|
||||
* code.add(" public String toString() {");
|
||||
* code.add(" return id;"); code.add(" }");
|
||||
* code.add(" "); code.add(" public String getId() {");
|
||||
* code.add(" return id;"); code.add(" }");
|
||||
* code.add(" "); code.add(" public opIO" +
|
||||
* inputOutputVariable.getId() +
|
||||
* " getIdentifier(String identifier){");
|
||||
* code.add(" if(identifier==null|| identifier.isEmpty()){"
|
||||
* ); code.add(" return null;"); code.add(" }");
|
||||
* code.add(" "); code.add(" for(opIO" +
|
||||
* inputOutputVariable.getId() + " value:opIO" +
|
||||
* inputOutputVariable.getId() + ".values()){");
|
||||
* code.add(" if(value.id.compareTo(identifier)==0){");
|
||||
* code.add(" return value;"); code.add(" }");
|
||||
* code.add(" }"); code.add(" return null;");
|
||||
* code.add(" }"); code.add(" "); code.add(" }");
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
code.addAll(Arrays.asList("", " @Override",
|
||||
" public String getDescription() {", " return \""
|
||||
+ project.getInputData().getProjectInfo()
|
||||
.getAlgorithmDescription() + "\";", " }", "",
|
||||
" protected void initVariables(){", " mainScriptName=\""
|
||||
+ mainScriptRelativePath + "\";", " packageURL=\""
|
||||
+ packageUrl + "\";",
|
||||
" environmentalvariables = new ArrayList<String>();"));
|
||||
|
||||
for (GlobalVariables globalVariable : project.getInputData()
|
||||
.getListGlobalVariables()) {
|
||||
code.add(" environmentalvariables.add(\""
|
||||
+ globalVariable.getName() + "\");");
|
||||
}
|
||||
|
||||
for (InputOutputVariables selVariable : project.getInputData()
|
||||
|
@ -158,12 +313,60 @@ public class AlgorithmGenerator {
|
|||
+ selVariable.getDefaultValue() + "\"));");
|
||||
break;
|
||||
case ENUMERATED:
|
||||
code.add(" inputs.add(new PrimitiveType(Enum.class.getName(), operators.values(),PrimitiveTypes.ENUMERATED, \""
|
||||
+ selVariable.getName()
|
||||
+ "\", \""
|
||||
+ selVariable.getDescription()
|
||||
+ "\", \""
|
||||
+ selVariable.getDefaultValue() + "\"));");
|
||||
String[] values = selVariable.getDefaultValue()
|
||||
.split("\\|");
|
||||
if (values.length > 0) {
|
||||
|
||||
// TODO
|
||||
String nameEnum = enumUUID.get("opIO"
|
||||
+ selVariable.getId());
|
||||
|
||||
code.add(" if (org.gcube.dataanalysis.executor.rscripts."
|
||||
+ project.getInputData().getProjectInfo()
|
||||
.getAlgorithmNameToClassName()
|
||||
+ "."
|
||||
+ nameEnum
|
||||
+ ".E"
|
||||
+ nameEnum
|
||||
+ ".values().length==0){");
|
||||
code.add(" " + nameEnum + " en = new " + nameEnum
|
||||
+ "();");
|
||||
|
||||
for (String val : values) {
|
||||
code.add(" en.addEnum(org.gcube.dataanalysis.executor.rscripts."
|
||||
+ project.getInputData().getProjectInfo()
|
||||
.getAlgorithmNameToClassName()
|
||||
+ "."
|
||||
+ nameEnum
|
||||
+ ".E"
|
||||
+ nameEnum
|
||||
+ ".class, \"" + val + "\");");
|
||||
}
|
||||
code.add(" }");
|
||||
code.add("");
|
||||
code.add(" addEnumerateInput(org.gcube.dataanalysis.executor.rscripts."
|
||||
+ project.getInputData().getProjectInfo()
|
||||
.getAlgorithmNameToClassName()
|
||||
+ "."
|
||||
+ nameEnum
|
||||
+ ".E"
|
||||
+ nameEnum
|
||||
+ ".values(), \""
|
||||
+ selVariable.getName()
|
||||
+ "\", \""
|
||||
+ selVariable.getDescription()
|
||||
+ "\", \""
|
||||
+ values[0] + "\");");
|
||||
/*
|
||||
* code.add(
|
||||
* " inputs.add(new PrimitiveType(Enum.class.getName(), opIO"
|
||||
* + selVariable.getId() +
|
||||
* ".values(),PrimitiveTypes.ENUMERATED, \"" +
|
||||
* selVariable.getName() + "\", \"" +
|
||||
* selVariable.getDescription() + "\", \"" + values[0] +
|
||||
* "\"));");
|
||||
*/
|
||||
}
|
||||
break;
|
||||
case FILE:
|
||||
code.add(" inputs.add(new PrimitiveType(File.class.getName(), null,PrimitiveTypes.FILE, \""
|
||||
|
@ -271,13 +474,11 @@ public class AlgorithmGenerator {
|
|||
}
|
||||
|
||||
private String retrieveMainScriptRelativePath() {
|
||||
String projectPath = project.getProjectFolder().getFolder()
|
||||
.getPath();
|
||||
String projectPath = project.getProjectFolder().getFolder().getPath();
|
||||
String mainCodePath = project.getMainCode().getItemDescription()
|
||||
.getPath();
|
||||
|
||||
String relativePath = project.getProjectFolder().getFolder()
|
||||
.getName()
|
||||
String relativePath = project.getProjectFolder().getFolder().getName()
|
||||
+ mainCodePath.substring(projectPath.length());
|
||||
return relativePath;
|
||||
|
||||
|
@ -285,12 +486,14 @@ public class AlgorithmGenerator {
|
|||
|
||||
private String retrievePackageUrl() {
|
||||
String packageUrl = "";
|
||||
if (project.getProjectTarget()!=null&&
|
||||
project.getProjectTarget().getProjectDeploy() != null
|
||||
&& project.getProjectTarget().getProjectDeploy().getPackageProject() != null) {
|
||||
if (project.getProjectTarget().getProjectDeploy().getPackageProject().getPublicLink() != null) {
|
||||
packageUrl = project.getProjectTarget().getProjectDeploy().getPackageProject()
|
||||
.getPublicLink();
|
||||
if (project.getProjectTarget() != null
|
||||
&& project.getProjectTarget().getProjectDeploy() != null
|
||||
&& project.getProjectTarget().getProjectDeploy()
|
||||
.getPackageProject() != null) {
|
||||
if (project.getProjectTarget().getProjectDeploy()
|
||||
.getPackageProject().getPublicLink() != null) {
|
||||
packageUrl = project.getProjectTarget().getProjectDeploy()
|
||||
.getPackageProject().getPublicLink();
|
||||
}
|
||||
}
|
||||
return packageUrl;
|
||||
|
|
|
@ -5,33 +5,27 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
* @author "Giancarlo Panichi" <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public enum DataType {
|
||||
STRING("String"),
|
||||
INTEGER("Integer"),
|
||||
DOUBLE("Double"),
|
||||
ENUMERATED("Enumerated"),
|
||||
FILE("File"),
|
||||
BOOLEAN("Boolean");
|
||||
|
||||
|
||||
//private static InputTypeMessages msgs=GWT.create(InputTypeMessages.class);
|
||||
private String id;
|
||||
|
||||
//private static List<String> inputTypeI18NList;
|
||||
STRING("String"), INTEGER("Integer"), DOUBLE("Double"), ENUMERATED(
|
||||
"Enumerated"), FILE("File"), BOOLEAN("Boolean");
|
||||
|
||||
/*static {
|
||||
inputTypeI18NList = new ArrayList<String>();
|
||||
for (InputType itype : values()) {
|
||||
inputTypeI18NList.add(msgs.inputType(itype));
|
||||
}
|
||||
}*/
|
||||
// private static InputTypeMessages
|
||||
// msgs=GWT.create(InputTypeMessages.class);
|
||||
private String id;
|
||||
|
||||
// private static List<String> inputTypeI18NList;
|
||||
|
||||
/*
|
||||
* static { inputTypeI18NList = new ArrayList<String>(); for (InputType
|
||||
* itype : values()) { inputTypeI18NList.add(msgs.inputType(itype)); } }
|
||||
*/
|
||||
|
||||
private DataType(String id) {
|
||||
this.id = id;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
|
@ -41,21 +35,27 @@ public enum DataType {
|
|||
public String toString() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getLabel(){
|
||||
//return msgs.inputType(this);
|
||||
|
||||
public String getLabel() {
|
||||
// return msgs.inputType(this);
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static List<DataType> asList() {
|
||||
List<DataType> list = Arrays.asList(values());
|
||||
return list;
|
||||
}
|
||||
|
||||
/*public static List<String> asI18NList() {
|
||||
return inputTypeI18NList;
|
||||
public static List<DataType> asListForGlobalVariables() {
|
||||
List<DataType> list = Arrays.asList(DataType.STRING, DataType.INTEGER,
|
||||
DataType.DOUBLE, DataType.FILE, DataType.BOOLEAN);
|
||||
return list;
|
||||
}
|
||||
|
||||
/*
|
||||
* public static List<String> asI18NList() { return inputTypeI18NList;
|
||||
*
|
||||
* }
|
||||
*/
|
||||
|
||||
}*/
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue