ref 10705: Add user name to algorithms descriptions in SAI publication

https://support.d4science.org/issues/10705

Added

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/statistical-algorithms-importer@162274 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2018-01-17 16:04:56 +00:00
parent a615d34006
commit 8dc54356f0
2 changed files with 200 additions and 224 deletions

View File

@ -32,11 +32,9 @@ import org.slf4j.LoggerFactory;
public class AlgorithmGenerator { public class AlgorithmGenerator {
private static final String EXTENTION_JAVA = ".java"; private static final String EXTENTION_JAVA = ".java";
public static final Logger logger = LoggerFactory public static final Logger logger = LoggerFactory.getLogger(AlgorithmGenerator.class);
.getLogger(AlgorithmGenerator.class);
private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm"); private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm");
private Project project; private Project project;
private HashMap<String, String> enumUUID; private HashMap<String, String> enumUUID;
private ServiceCredentials serviceCredentials; private ServiceCredentials serviceCredentials;
@ -44,7 +42,7 @@ public class AlgorithmGenerator {
public AlgorithmGenerator(Project project, ServiceCredentials serviceCredentials) { public AlgorithmGenerator(Project project, ServiceCredentials serviceCredentials) {
super(); super();
this.project = project; this.project = project;
this.serviceCredentials=serviceCredentials; this.serviceCredentials = serviceCredentials;
} }
@Override @Override
@ -54,20 +52,17 @@ public class AlgorithmGenerator {
public Path createAlgorithm() throws StatAlgoImporterServiceException { public Path createAlgorithm() throws StatAlgoImporterServiceException {
try { try {
Path tempFile = Files.createTempFile(project.getInputData() Path tempFile = Files.createTempFile(project.getInputData().getProjectInfo().getAlgorithmNameToClassName(),
.getProjectInfo().getAlgorithmNameToClassName(),
EXTENTION_JAVA); EXTENTION_JAVA);
List<String> lines = createJavaCode(); List<String> lines = createJavaCode();
Files.write(tempFile, lines, Charset.defaultCharset(), Files.write(tempFile, lines, Charset.defaultCharset(), StandardOpenOption.WRITE);
StandardOpenOption.WRITE);
logger.debug(tempFile.toString()); logger.debug(tempFile.toString());
return tempFile; return tempFile;
} catch (IOException e) { } catch (IOException e) {
logger.error(e.getLocalizedMessage(),e); logger.error(e.getLocalizedMessage(), e);
throw new StatAlgoImporterServiceException(e.getLocalizedMessage(), throw new StatAlgoImporterServiceException(e.getLocalizedMessage(), e);
e);
} }
} }
@ -78,27 +73,19 @@ public class AlgorithmGenerator {
enumUUID = new HashMap<>(); enumUUID = new HashMap<>();
ArrayList<String> code = new ArrayList<>(); ArrayList<String> code = new ArrayList<>();
code.addAll(Arrays code.addAll(Arrays.asList("package org.gcube.dataanalysis.executor.rscripts;", "", "import java.io.File;",
.asList("package org.gcube.dataanalysis.executor.rscripts;", "import java.util.ArrayList;", "import java.util.LinkedHashMap;",
"",
"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.PrimitiveType;",
"import org.gcube.dataanalysis.ecoengine.datatypes.StatisticalType;", "import org.gcube.dataanalysis.ecoengine.datatypes.StatisticalType;",
"import org.gcube.dataanalysis.ecoengine.datatypes.enumtypes.PrimitiveTypes;", "import org.gcube.dataanalysis.ecoengine.datatypes.enumtypes.PrimitiveTypes;",
"import org.gcube.dataanalysis.executor.rscripts.generic.GenericRScript;", "import org.gcube.dataanalysis.executor.rscripts.generic.GenericRScript;",
"import org.gcube.dataanalysis.ecoengine.utils.DynamicEnum;", "import org.gcube.dataanalysis.ecoengine.utils.DynamicEnum;", "import java.lang.reflect.Field;", "",
"import java.lang.reflect.Field;", "", "public class " "public class " + project.getInputData().getProjectInfo().getAlgorithmNameToClassName()
+ project.getInputData().getProjectInfo()
.getAlgorithmNameToClassName()
+ " extends GenericRScript {")); + " extends GenericRScript {"));
for (GlobalVariables globalVariable : project.getInputData() for (GlobalVariables globalVariable : project.getInputData().getListGlobalVariables()) {
.getListGlobalVariables()) {
if (globalVariable.getDataType().compareTo(DataType.ENUMERATED) == 0) { if (globalVariable.getDataType().compareTo(DataType.ENUMERATED) == 0) {
if (globalVariable.getDefaultValue() == null if (globalVariable.getDefaultValue() == null || globalVariable.getDefaultValue().isEmpty()) {
|| globalVariable.getDefaultValue().isEmpty()) {
} else { } else {
String uuid = "" + UUID.randomUUID(); String uuid = "" + UUID.randomUUID();
@ -107,12 +94,10 @@ public class AlgorithmGenerator {
enumUUID.put("opGV" + globalVariable.getId(), nameEnum); enumUUID.put("opGV" + globalVariable.getId(), nameEnum);
code.add(""); code.add("");
code.add(" static class " + nameEnum code.add(" static class " + nameEnum + " extends DynamicEnum {");
+ " extends DynamicEnum {");
code.add(" public enum E" + nameEnum + " {};"); code.add(" public enum E" + nameEnum + " {};");
code.add(" public Field[] getFields() {"); code.add(" public Field[] getFields() {");
code.add(" Field[] fields = E" + nameEnum code.add(" Field[] fields = E" + nameEnum + ".class.getDeclaredFields();");
+ ".class.getDeclaredFields();");
code.add(" return fields;"); code.add(" return fields;");
code.add(" }"); code.add(" }");
code.add(" }"); code.add(" }");
@ -123,9 +108,9 @@ public class AlgorithmGenerator {
* if (values.length < 1) { * if (values.length < 1) {
* *
* } else { for (int i = 0; i < values.length; i++) { if (i * } else { for (int i = 0; i < values.length; i++) { if (i
* == values.length - 1) { code.add(" \"" + values[i] + * == values.length - 1) { code.add(" \"" + values[i]
* "\""); } else { code.add(" \"" + values[i] + "\","); } } * + "\""); } else { code.add(" \"" + values[i] +
* } code.add(" };"); * "\","); } } } code.add(" };");
*/ */
/* /*
* code.add(" public static enum opGV" + * code.add(" public static enum opGV" +
@ -137,32 +122,37 @@ public class AlgorithmGenerator {
* identifier = values[i].trim(); * identifier = values[i].trim();
* identifier=identifier.replaceAll("\\s+",""); * identifier=identifier.replaceAll("\\s+","");
* *
* if (i == values.length - 1) { code.add(" " + identifier * if (i == values.length - 1) { code.add(" " +
* + "(\"" + values[i] + "\");"); } else { code.add(" " + * identifier + "(\"" + values[i] + "\");"); } else {
* identifier + "(\"" + values[i] + "\"),"); } } } * code.add(" " + identifier + "(\"" + values[i] +
* "\"),"); } } }
* *
* code.add(" "); code.add(" private final String id;"); * code.add(" ");
* code.add(" private final String id;");
* code.add(" "); code.add(" private opGV" + * code.add(" "); code.add(" private opGV" +
* globalVariable.getId() + "(final String id) {"); * globalVariable.getId() + "(final String id) {");
* code.add(" this.id = id;"); code.add(" }"); * code.add(" this.id = id;"); code.add(" }");
* code.add(" "); code.add(" @Override"); * code.add(" "); code.add(" @Override");
* code.add(" public String toString() {"); * code.add(" public String toString() {");
* code.add(" return id;"); code.add(" }"); * code.add(" return id;"); code.add(" }");
* code.add(" "); code.add(" public String getId() {"); * code.add(" ");
* code.add(" public String getId() {");
* code.add(" return id;"); code.add(" }"); * code.add(" return id;"); code.add(" }");
* code.add(" "); * code.add(" ");
* *
* code.add(" public opIO" + globalVariable.getId() + * code.add(" public opIO" + globalVariable.getId() +
* " getIdentifier(String identifier){"); * " getIdentifier(String identifier){"); code.
* code.add(" if(identifier==null|| identifier.isEmpty()){" * add(" if(identifier==null|| identifier.isEmpty()){"
* ); code.add(" return null;"); code.add(" }"); * ); code.add(" return null;");
* code.add(" "); code.add(" for(opIO" + * code.add(" }"); code.add(" ");
* globalVariable.getId() + " value:opIO" + * code.add(" for(opIO" + globalVariable.getId() +
* globalVariable.getId() + ".values()){"); * " value:opIO" + globalVariable.getId() + ".values()){");
* code.add(" if(value.id.compareTo(identifier)==0){"); * code.
* code.add(" return value;"); code.add(" }"); * add(" if(value.id.compareTo(identifier)==0){"
* code.add(" }"); code.add(" return null;"); * ); code.add(" return value;");
* code.add(" }"); code.add(" "); code.add(" }"); * code.add(" }"); code.add(" }");
* code.add(" return null;"); code.add(" }");
* code.add(" "); code.add(" }");
*/ */
} }
@ -170,41 +160,35 @@ public class AlgorithmGenerator {
} }
for (InputOutputVariables inputOutputVariable : project.getInputData() for (InputOutputVariables inputOutputVariable : project.getInputData().getListInputOutputVariables()) {
.getListInputOutputVariables()) { if (inputOutputVariable.getDataType().compareTo(DataType.ENUMERATED) == 0) {
if (inputOutputVariable.getDataType() if (inputOutputVariable.getDefaultValue() == null || inputOutputVariable.getDefaultValue().isEmpty()) {
.compareTo(DataType.ENUMERATED) == 0) {
if (inputOutputVariable.getDefaultValue() == null
|| inputOutputVariable.getDefaultValue().isEmpty()) {
} else { } else {
String uuid = "" + UUID.randomUUID(); String uuid = "" + UUID.randomUUID();
uuid = uuid.replaceAll("-", ""); uuid = uuid.replaceAll("-", "");
String nameEnum = "opIO" + inputOutputVariable.getId() String nameEnum = "opIO" + inputOutputVariable.getId() + uuid;
+ uuid;
enumUUID.put("opIO" + inputOutputVariable.getId(), nameEnum); enumUUID.put("opIO" + inputOutputVariable.getId(), nameEnum);
code.add(""); code.add("");
code.add(" static class " + nameEnum code.add(" static class " + nameEnum + " extends DynamicEnum {");
+ " extends DynamicEnum {");
code.add(" public enum E" + nameEnum + " {};"); code.add(" public enum E" + nameEnum + " {};");
code.add(" public Field[] getFields() {"); code.add(" public Field[] getFields() {");
code.add(" Field[] fields = E" + nameEnum code.add(" Field[] fields = E" + nameEnum + ".class.getDeclaredFields();");
+ ".class.getDeclaredFields();");
code.add(" return fields;"); code.add(" return fields;");
code.add(" }"); code.add(" }");
code.add(" }"); code.add(" }");
/* /*
* code.add(" String[] opIO" + inputOutputVariable.getId() + * code.add(" String[] opIO" + inputOutputVariable.getId()
* " = {"); String[] values = * + " = {"); String[] values =
* inputOutputVariable.getDefaultValue() .split("\\|"); if * inputOutputVariable.getDefaultValue() .split("\\|"); if
* (values.length < 1) { * (values.length < 1) {
* *
* } else { for (int i = 0; i < values.length; i++) { if (i * } else { for (int i = 0; i < values.length; i++) { if (i
* == values.length - 1) { code.add(" \"" + values[i] + * == values.length - 1) { code.add(" \"" + values[i]
* "\""); } else { code.add(" \"" + values[i] + "\","); } } * + "\""); } else { code.add(" \"" + values[i] +
* } code.add(" };"); * "\","); } } } code.add(" };");
*/ */
/* /*
@ -217,62 +201,57 @@ public class AlgorithmGenerator {
* } else { for (int i = 0; i < values.length; i++) { String * } else { for (int i = 0; i < values.length; i++) { String
* identifier = values[i].trim(); identifier = * identifier = values[i].trim(); identifier =
* identifier.replaceAll("\\s+", ""); if (i == values.length * identifier.replaceAll("\\s+", ""); if (i == values.length
* - 1) { code.add(" " + identifier + "(\"" + values[i] + * - 1) { code.add(" " + identifier + "(\"" +
* "\");"); } else { code.add(" " + identifier + "(\"" + * values[i] + "\");"); } else { code.add(" " +
* values[i] + "\"),"); } } } code.add(" "); * identifier + "(\"" + values[i] + "\"),"); } } }
* code.add(" private final String id;"); code.add(" "); * code.add(" ");
* code.add(" private opIO" + inputOutputVariable.getId() + * code.add(" private final String id;");
* "(final String id) {"); code.add(" this.id = id;"); * code.add(" "); code.add(" private opIO" +
* code.add(" }"); code.add(" "); code.add(" @Override"); * inputOutputVariable.getId() + "(final String id) {");
* code.add(" this.id = id;"); code.add(" }");
* code.add(" "); code.add(" @Override");
* code.add(" public String toString() {"); * code.add(" public String toString() {");
* code.add(" return id;"); code.add(" }"); * code.add(" return id;"); code.add(" }");
* code.add(" "); code.add(" public String getId() {"); * code.add(" ");
* code.add(" public String getId() {");
* code.add(" return id;"); code.add(" }"); * code.add(" return id;"); code.add(" }");
* code.add(" "); code.add(" public opIO" + * code.add(" "); code.add(" public opIO" +
* inputOutputVariable.getId() + * inputOutputVariable.getId() +
* " getIdentifier(String identifier){"); * " getIdentifier(String identifier){"); code.
* code.add(" if(identifier==null|| identifier.isEmpty()){" * add(" if(identifier==null|| identifier.isEmpty()){"
* ); code.add(" return null;"); code.add(" }"); * ); code.add(" return null;");
* code.add(" "); code.add(" for(opIO" + * code.add(" }"); code.add(" ");
* code.add(" for(opIO" +
* inputOutputVariable.getId() + " value:opIO" + * inputOutputVariable.getId() + " value:opIO" +
* inputOutputVariable.getId() + ".values()){"); * inputOutputVariable.getId() + ".values()){"); code.
* code.add(" if(value.id.compareTo(identifier)==0){"); * add(" if(value.id.compareTo(identifier)==0){"
* code.add(" return value;"); code.add(" }"); * ); code.add(" return value;");
* code.add(" }"); code.add(" return null;"); * code.add(" }"); code.add(" }");
* code.add(" }"); code.add(" "); code.add(" }"); * code.add(" return null;"); code.add(" }");
* code.add(" "); code.add(" }");
*/ */
} }
} }
} }
code.addAll(Arrays.asList("", " @Override", " public String getDescription() {",
" return \"" + retrieveAlgorithmDescription() + "\";", " }", "",
" protected void initVariables(){", " mainScriptName=\"" + mainScriptRelativePath + "\";",
code.addAll(Arrays.asList("", " @Override", " packageURL=\"" + packageUrl + "\";",
" public String getDescription() {", " return \""
+ retrieveAlgorithmDescription() + "\";", " }", "",
" protected void initVariables(){", " mainScriptName=\""
+ mainScriptRelativePath + "\";", " packageURL=\""
+ packageUrl + "\";",
" environmentalvariables = new ArrayList<String>();")); " environmentalvariables = new ArrayList<String>();"));
for (GlobalVariables globalVariable : project.getInputData() for (GlobalVariables globalVariable : project.getInputData().getListGlobalVariables()) {
.getListGlobalVariables()) { code.add(" environmentalvariables.add(\"" + globalVariable.getName() + "\");");
code.add(" environmentalvariables.add(\""
+ globalVariable.getName() + "\");");
} }
for (InputOutputVariables selVariable : project.getInputData() for (InputOutputVariables selVariable : project.getInputData().getListInputOutputVariables()) {
.getListInputOutputVariables()) {
switch (selVariable.getIoType()) { switch (selVariable.getIoType()) {
case INPUT: case INPUT:
code.add(" inputvariables.add(\"" + selVariable.getName() code.add(" inputvariables.add(\"" + selVariable.getName() + "\");");
+ "\");");
break; break;
case OUTPUT: case OUTPUT:
code.add(" outputvariables.add(\"" + selVariable.getName() code.add(" outputvariables.add(\"" + selVariable.getName() + "\");");
+ "\");");
break; break;
default: default:
break; break;
@ -291,7 +270,8 @@ public class AlgorithmGenerator {
code.add(" @Override"); code.add(" @Override");
code.add(" public StatisticalType getOutput() {"); code.add(" public StatisticalType getOutput() {");
createOutputParameters(code); createOutputParameters(code);
code.add(" PrimitiveType o = new PrimitiveType(LinkedHashMap.class.getName(), output, PrimitiveTypes.MAP, \"Output\", \"\");"); code.add(
" PrimitiveType o = new PrimitiveType(LinkedHashMap.class.getName(), output, PrimitiveTypes.MAP, \"Output\", \"\");");
code.add(" return o;"); code.add(" return o;");
code.add(" }"); code.add(" }");
code.add("}"); code.add("}");
@ -299,107 +279,91 @@ public class AlgorithmGenerator {
} }
private String retrieveAlgorithmDescription() { private String retrieveAlgorithmDescription() {
String algorithmDescription=""; String algorithmDescription = "";
if (project.getInputData().getProjectInfo().getAlgorithmDescription() != null) { if (project.getInputData().getProjectInfo().getAlgorithmDescription() != null
&& !project.getInputData().getProjectInfo().getAlgorithmDescription().isEmpty()) {
if (serviceCredentials.getUserName() != null && !serviceCredentials.getUserName().isEmpty()) { if (serviceCredentials.getUserName() != null && !serviceCredentials.getUserName().isEmpty()) {
if (serviceCredentials.getFullName() != null && !serviceCredentials.getFullName().isEmpty()) { if (serviceCredentials.getFullName() != null && !serviceCredentials.getFullName().isEmpty()) {
algorithmDescription="Algorithm Description: " algorithmDescription = project.getInputData().getProjectInfo().getAlgorithmDescription()
+ project.getInputData().getProjectInfo().getAlgorithmDescription()
+ "[Published by " + serviceCredentials.getFullName() + "(" + "[Published by " + serviceCredentials.getFullName() + "("
+ serviceCredentials.getUserName() + ") on " + serviceCredentials.getUserName() + ") on " + sdf.format(Calendar.getInstance().getTime())
+ sdf.format(Calendar.getInstance().getTime()) + "]"; + "]";
} else { } else {
algorithmDescription="Algorithm Description: " algorithmDescription = project.getInputData().getProjectInfo().getAlgorithmDescription()
+ project.getInputData().getProjectInfo().getAlgorithmDescription()
+ "[Published on " + sdf.format(Calendar.getInstance().getTime()) + "]"; + "[Published on " + sdf.format(Calendar.getInstance().getTime()) + "]";
} }
} else { } else {
if (serviceCredentials.getFullName() != null && !serviceCredentials.getFullName().isEmpty()) { if (serviceCredentials.getFullName() != null && !serviceCredentials.getFullName().isEmpty()) {
algorithmDescription="Algorithm Description: " algorithmDescription = project.getInputData().getProjectInfo().getAlgorithmDescription()
+ project.getInputData().getProjectInfo().getAlgorithmDescription()
+ "[Published by " + serviceCredentials.getFullName() + " on " + "[Published by " + serviceCredentials.getFullName() + " on "
+ sdf.format(Calendar.getInstance().getTime()) + "]"; + sdf.format(Calendar.getInstance().getTime()) + "]";
} else { } else {
algorithmDescription="Algorithm Description: " algorithmDescription = project.getInputData().getProjectInfo().getAlgorithmDescription()
+ project.getInputData().getProjectInfo().getAlgorithmDescription()
+ "[Published on " + sdf.format(Calendar.getInstance().getTime()) + "]"; + "[Published on " + sdf.format(Calendar.getInstance().getTime()) + "]";
} }
} }
} else { } else {
if (serviceCredentials.getUserName() != null && !serviceCredentials.getUserName().isEmpty()) {
if (serviceCredentials.getFullName() != null && !serviceCredentials.getFullName().isEmpty()) {
algorithmDescription = "[Published by " + serviceCredentials.getFullName() + "("
+ serviceCredentials.getUserName() + ") on " + sdf.format(Calendar.getInstance().getTime())
+ "]";
} else {
algorithmDescription = "[Published on " + sdf.format(Calendar.getInstance().getTime()) + "]";
}
} else {
if (serviceCredentials.getFullName() != null && !serviceCredentials.getFullName().isEmpty()) {
algorithmDescription = "[Published by " + serviceCredentials.getFullName() + " on "
+ sdf.format(Calendar.getInstance().getTime()) + "]";
} else {
algorithmDescription = "[Published on " + sdf.format(Calendar.getInstance().getTime()) + "]";
}
}
} }
return algorithmDescription; return algorithmDescription;
} }
private void createInputParameters(ArrayList<String> code) { private void createInputParameters(ArrayList<String> code) {
for (InputOutputVariables selVariable : project.getInputData() for (InputOutputVariables selVariable : project.getInputData().getListInputOutputVariables()) {
.getListInputOutputVariables()) {
if (selVariable.getIoType().compareTo(IOType.INPUT) == 0) { if (selVariable.getIoType().compareTo(IOType.INPUT) == 0) {
switch (selVariable.getDataType()) { switch (selVariable.getDataType()) {
case BOOLEAN: case BOOLEAN:
code.add(" inputs.add(new PrimitiveType(Boolean.class.getName(), null,PrimitiveTypes.BOOLEAN, \"" code.add(
+ selVariable.getName() " inputs.add(new PrimitiveType(Boolean.class.getName(), null,PrimitiveTypes.BOOLEAN, \""
+ "\", \"" + selVariable.getName() + "\", \"" + selVariable.getDescription() + "\", \""
+ selVariable.getDescription()
+ "\", \""
+ selVariable.getDefaultValue() + "\"));"); + selVariable.getDefaultValue() + "\"));");
break; break;
case DOUBLE: case DOUBLE:
code.add(" inputs.add(new PrimitiveType(Double.class.getName(), null,PrimitiveTypes.NUMBER, \"" code.add(" inputs.add(new PrimitiveType(Double.class.getName(), null,PrimitiveTypes.NUMBER, \""
+ selVariable.getName() + selVariable.getName() + "\", \"" + selVariable.getDescription() + "\", \""
+ "\", \""
+ selVariable.getDescription()
+ "\", \""
+ selVariable.getDefaultValue() + "\"));"); + selVariable.getDefaultValue() + "\"));");
break; break;
case ENUMERATED: case ENUMERATED:
String[] values = selVariable.getDefaultValue() String[] values = selVariable.getDefaultValue().split("\\|");
.split("\\|");
if (values.length > 0) { if (values.length > 0) {
// TODO // TODO
String nameEnum = enumUUID.get("opIO" String nameEnum = enumUUID.get("opIO" + selVariable.getId());
+ selVariable.getId());
code.add(" if (org.gcube.dataanalysis.executor.rscripts." code.add(" if (org.gcube.dataanalysis.executor.rscripts."
+ project.getInputData().getProjectInfo() + project.getInputData().getProjectInfo().getAlgorithmNameToClassName() + "." + nameEnum
.getAlgorithmNameToClassName() + ".E" + nameEnum + ".values().length==0){");
+ "." code.add(" " + nameEnum + " en = new " + nameEnum + "();");
+ nameEnum
+ ".E"
+ nameEnum
+ ".values().length==0){");
code.add(" " + nameEnum + " en = new " + nameEnum
+ "();");
for (String val : values) { for (String val : values) {
code.add(" en.addEnum(org.gcube.dataanalysis.executor.rscripts." code.add(" en.addEnum(org.gcube.dataanalysis.executor.rscripts."
+ project.getInputData().getProjectInfo() + project.getInputData().getProjectInfo().getAlgorithmNameToClassName() + "."
.getAlgorithmNameToClassName() + nameEnum + ".E" + nameEnum + ".class, \"" + val + "\");");
+ "."
+ nameEnum
+ ".E"
+ nameEnum
+ ".class, \"" + val + "\");");
} }
code.add(" }"); code.add(" }");
code.add(""); code.add("");
code.add(" addEnumerateInput(org.gcube.dataanalysis.executor.rscripts." code.add(" addEnumerateInput(org.gcube.dataanalysis.executor.rscripts."
+ project.getInputData().getProjectInfo() + project.getInputData().getProjectInfo().getAlgorithmNameToClassName() + "." + nameEnum
.getAlgorithmNameToClassName() + ".E" + nameEnum + ".values(), \"" + selVariable.getName() + "\", \""
+ "." + selVariable.getDescription() + "\", \"" + values[0] + "\");");
+ nameEnum
+ ".E"
+ nameEnum
+ ".values(), \""
+ selVariable.getName()
+ "\", \""
+ selVariable.getDescription()
+ "\", \""
+ values[0] + "\");");
/* /*
* code.add( * code.add(
* " inputs.add(new PrimitiveType(Enum.class.getName(), opIO" * " inputs.add(new PrimitiveType(Enum.class.getName(), opIO"
@ -413,27 +377,19 @@ public class AlgorithmGenerator {
break; break;
case FILE: case FILE:
code.add(" inputs.add(new PrimitiveType(File.class.getName(), null,PrimitiveTypes.FILE, \"" code.add(" inputs.add(new PrimitiveType(File.class.getName(), null,PrimitiveTypes.FILE, \""
+ selVariable.getName() + selVariable.getName() + "\", \"" + selVariable.getDescription() + "\", \""
+ "\", \""
+ selVariable.getDescription()
+ "\", \""
+ selVariable.getDefaultValue() + "\"));"); + selVariable.getDefaultValue() + "\"));");
break; break;
case INTEGER: case INTEGER:
code.add(" inputs.add(new PrimitiveType(Integer.class.getName(), null,PrimitiveTypes.NUMBER, \"" code.add(
+ selVariable.getName() " inputs.add(new PrimitiveType(Integer.class.getName(), null,PrimitiveTypes.NUMBER, \""
+ "\", \"" + selVariable.getName() + "\", \"" + selVariable.getDescription() + "\", \""
+ selVariable.getDescription()
+ "\", \""
+ selVariable.getDefaultValue() + "\"));"); + selVariable.getDefaultValue() + "\"));");
break; break;
case STRING: case STRING:
code.add(" inputs.add(new PrimitiveType(String.class.getName(), null,PrimitiveTypes.STRING, \"" code.add(" inputs.add(new PrimitiveType(String.class.getName(), null,PrimitiveTypes.STRING, \""
+ selVariable.getName() + selVariable.getName() + "\", \"" + selVariable.getDescription() + "\", \""
+ "\", \""
+ selVariable.getDescription()
+ "\", \""
+ selVariable.getDefaultValue() + "\"));"); + selVariable.getDefaultValue() + "\"));");
break; break;
@ -454,57 +410,41 @@ public class AlgorithmGenerator {
*/ */
private void createOutputParameters(ArrayList<String> code) { private void createOutputParameters(ArrayList<String> code) {
for (InputOutputVariables selVariable : project.getInputData() for (InputOutputVariables selVariable : project.getInputData().getListInputOutputVariables()) {
.getListInputOutputVariables()) {
if (selVariable.getIoType().compareTo(IOType.OUTPUT) == 0) { if (selVariable.getIoType().compareTo(IOType.OUTPUT) == 0) {
switch (selVariable.getDataType()) { switch (selVariable.getDataType()) {
case BOOLEAN: case BOOLEAN:
code.add(" output.put(\"" code.add(" output.put(\"" + selVariable.getName()
+ selVariable.getName()
+ "\",new PrimitiveType(Boolean.class.getName(), new File(outputValues.get(\"" + "\",new PrimitiveType(Boolean.class.getName(), new File(outputValues.get(\""
+ selVariable.getName() + selVariable.getName() + "\")), PrimitiveTypes.BOOLEAN, \"" + selVariable.getName()
+ "\")), PrimitiveTypes.BOOLEAN, \"" + "\", \"" + selVariable.getName() + "\"));");
+ selVariable.getName() + "\", \""
+ selVariable.getName() + "\"));");
break; break;
case DOUBLE: case DOUBLE:
code.add(" output.put(\"" code.add(" output.put(\"" + selVariable.getName()
+ selVariable.getName()
+ "\",new PrimitiveType(Double.class.getName(), new File(outputValues.get(\"" + "\",new PrimitiveType(Double.class.getName(), new File(outputValues.get(\""
+ selVariable.getName() + selVariable.getName() + "\")), PrimitiveTypes.NUMBER, \"" + selVariable.getName()
+ "\")), PrimitiveTypes.NUMBER, \"" + "\", \"" + selVariable.getName() + "\"));");
+ selVariable.getName() + "\", \""
+ selVariable.getName() + "\"));");
break; break;
case ENUMERATED: case ENUMERATED:
break; break;
case FILE: case FILE:
code.add(" output.put(\"" code.add(" output.put(\"" + selVariable.getName()
+ selVariable.getName()
+ "\",new PrimitiveType(File.class.getName(), new File(outputValues.get(\"" + "\",new PrimitiveType(File.class.getName(), new File(outputValues.get(\""
+ selVariable.getName() + selVariable.getName() + "\")), PrimitiveTypes.FILE, \"" + selVariable.getName() + "\", \""
+ "\")), PrimitiveTypes.FILE, \""
+ selVariable.getName() + "\", \""
+ selVariable.getName() + "\"));"); + selVariable.getName() + "\"));");
break; break;
case INTEGER: case INTEGER:
code.add(" output.put(\"" code.add(" output.put(\"" + selVariable.getName()
+ selVariable.getName()
+ "\",new PrimitiveType(Integer.class.getName(), new File(outputValues.get(\"" + "\",new PrimitiveType(Integer.class.getName(), new File(outputValues.get(\""
+ selVariable.getName() + selVariable.getName() + "\")), PrimitiveTypes.NUMBER, \"" + selVariable.getName()
+ "\")), PrimitiveTypes.NUMBER, \"" + "\", \"" + selVariable.getName() + "\"));");
+ selVariable.getName() + "\", \""
+ selVariable.getName() + "\"));");
break; break;
case STRING: case STRING:
code.add(" output.put(\"" code.add(" output.put(\"" + selVariable.getName()
+ selVariable.getName()
+ "\",new PrimitiveType(String.class.getName(), new File(outputValues.get(\"" + "\",new PrimitiveType(String.class.getName(), new File(outputValues.get(\""
+ selVariable.getName() + selVariable.getName() + "\")), PrimitiveTypes.STRING, \"" + selVariable.getName()
+ "\")), PrimitiveTypes.STRING, \"" + "\", \"" + selVariable.getName() + "\"));");
+ selVariable.getName() + "\", \""
+ selVariable.getName() + "\"));");
break; break;
default: default:
@ -517,30 +457,25 @@ public class AlgorithmGenerator {
} }
private String retrieveMainScriptRelativePath() { private String retrieveMainScriptRelativePath() {
logger.debug("ProjectInfo: "+project); logger.debug("ProjectInfo: " + project);
String projectPath = project.getProjectFolder().getFolder().getPath(); String projectPath = project.getProjectFolder().getFolder().getPath();
String mainCodePath = project.getMainCode().getItemDescription() String mainCodePath = project.getMainCode().getItemDescription().getPath();
.getPath(); logger.debug("ProjectPath: " + projectPath);
logger.debug("ProjectPath: "+projectPath); logger.debug("MainCodePath: " + mainCodePath);
logger.debug("MainCodePath: "+mainCodePath);
String relativePath = project.getProjectFolder().getFolder().getName() String relativePath = project.getProjectFolder().getFolder().getName()
+ mainCodePath.substring(projectPath.length()); + mainCodePath.substring(projectPath.length());
logger.debug("RelativePath:"+relativePath); logger.debug("RelativePath:" + relativePath);
return relativePath; return relativePath;
} }
private String retrievePackageUrl() { private String retrievePackageUrl() {
String packageUrl = ""; String packageUrl = "";
if (project.getProjectTarget() != null if (project.getProjectTarget() != null && project.getProjectTarget().getProjectDeploy() != null
&& project.getProjectTarget().getProjectDeploy() != null && project.getProjectTarget().getProjectDeploy().getPackageProject() != null) {
&& project.getProjectTarget().getProjectDeploy() if (project.getProjectTarget().getProjectDeploy().getPackageProject().getPublicLink() != null) {
.getPackageProject() != null) { packageUrl = project.getProjectTarget().getProjectDeploy().getPackageProject().getPublicLink();
if (project.getProjectTarget().getProjectDeploy()
.getPackageProject().getPublicLink() != null) {
packageUrl = project.getProjectTarget().getProjectDeploy()
.getPackageProject().getPublicLink();
} }
} }
return packageUrl; return packageUrl;

View File

@ -910,3 +910,44 @@ return $entry0ValueAuth/..
2017-10-10 10:49:57 DEBUG InformationSystemUtils:118 - Resources: [GCoreEndpoint [id=a13cd300-a66e-4f9d-b2cc-a4229b148d8a, scopes=[/gcube/devNext, /gcube/devsec, /gcube], type=RunningInstance, version=0.4.x, profile=[description=, version=0.0.1, ghn=[id=96550b2e-09e9-4c4e-9bac-2f59ecaff1e7], service=[id=dataminer-pool-managerDataAnalysis0.0.1], serviceName=dataminer-pool-manager, serviceClass=DataAnalysis, runningInstanceInterfaces=[], platform=null, deploymentData=[instanceName=null, localPath=null, activationTime=10/9/17 5:55 PM, terminationTime=, status=ready, messageState=null, plugins=[]], functions=[], endpoints=[Endpoint [name=REST-API, uri=http://dm-pool-manager-dev.d4science.org:80/dataminer-pool-manager/api], Endpoint [name=dataminer-pool-manager-remote-management, uri=http://dm-pool-manager-dev.d4science.org:80/dataminer-pool-manager/gcube/resource]], specificData=[doc: null], accountings=[]]]] 2017-10-10 10:49:57 DEBUG InformationSystemUtils:118 - Resources: [GCoreEndpoint [id=a13cd300-a66e-4f9d-b2cc-a4229b148d8a, scopes=[/gcube/devNext, /gcube/devsec, /gcube], type=RunningInstance, version=0.4.x, profile=[description=, version=0.0.1, ghn=[id=96550b2e-09e9-4c4e-9bac-2f59ecaff1e7], service=[id=dataminer-pool-managerDataAnalysis0.0.1], serviceName=dataminer-pool-manager, serviceClass=DataAnalysis, runningInstanceInterfaces=[], platform=null, deploymentData=[instanceName=null, localPath=null, activationTime=10/9/17 5:55 PM, terminationTime=, status=ready, messageState=null, plugins=[]], functions=[], endpoints=[Endpoint [name=REST-API, uri=http://dm-pool-manager-dev.d4science.org:80/dataminer-pool-manager/api], Endpoint [name=dataminer-pool-manager-remote-management, uri=http://dm-pool-manager-dev.d4science.org:80/dataminer-pool-manager/gcube/resource]], specificData=[doc: null], accountings=[]]]]
2017-10-10 10:49:57 DEBUG InformationSystemUtils:162 - DataMiner PoolManager URI: null 2017-10-10 10:49:57 DEBUG InformationSystemUtils:162 - DataMiner PoolManager URI: null
2017-10-10 10:49:57 INFO ISResourceTest:109 - DataMinerPoolManager: null 2017-10-10 10:49:57 INFO ISResourceTest:109 - DataMinerPoolManager: null
2018-01-17 12:59:38 DEBUG InformationSystemUtils:101 - Retrieve dataminer-pool-manager
2018-01-17 12:59:38 INFO ScopeProviderScanner:50 - using scope provider org.gcube.common.scope.impl.DefaultScopeProvider@71c7db30
2018-01-17 12:59:38 DEBUG DefaultScopeProvider:38 - setting scope /d4science.research-infrastructures.eu/ParthenosVO/PARTHENOS_LAB in thread 1
2018-01-17 12:59:38 DEBUG InformationSystemUtils:106 - Retrieve DataMiner Pool Manager resource in scope: /d4science.research-infrastructures.eu/ParthenosVO/PARTHENOS_LAB
2018-01-17 12:59:39 INFO DefaultScanner:63 - matched 16 resources from 170 urls in 236 ms
2018-01-17 12:59:39 INFO ServiceMapScanner:52 - loading jar:file:/home/giancarlo/.m2/repository/org/gcube/core/common-scope-maps/1.0.7-SNAPSHOT/common-scope-maps-1.0.7-SNAPSHOT.jar!/socialisti.servicemap
2018-01-17 12:59:39 INFO ServiceMapScanner:52 - loading jar:file:/home/giancarlo/.m2/repository/org/gcube/core/common-scope-maps/1.0.7-SNAPSHOT/common-scope-maps-1.0.7-SNAPSHOT.jar!/devsec.servicemap
2018-01-17 12:59:39 INFO ServiceMapScanner:52 - loading jar:file:/home/giancarlo/.m2/repository/org/gcube/core/common-scope-maps/1.0.7-SNAPSHOT/common-scope-maps-1.0.7-SNAPSHOT.jar!/farm.servicemap
2018-01-17 12:59:39 INFO ServiceMapScanner:52 - loading jar:file:/home/giancarlo/.m2/repository/org/gcube/core/common-scope-maps/1.0.7-SNAPSHOT/common-scope-maps-1.0.7-SNAPSHOT.jar!/edison.servicemap
2018-01-17 12:59:39 INFO ServiceMapScanner:52 - loading jar:file:/home/giancarlo/.m2/repository/org/gcube/core/common-scope-maps/1.0.7-SNAPSHOT/common-scope-maps-1.0.7-SNAPSHOT.jar!/sobigdata.servicemap
2018-01-17 12:59:39 INFO ServiceMapScanner:52 - loading jar:file:/home/giancarlo/.m2/repository/org/gcube/core/common-scope-maps/1.0.7-SNAPSHOT/common-scope-maps-1.0.7-SNAPSHOT.jar!/gcube.servicemap
2018-01-17 12:59:39 INFO ServiceMapScanner:52 - loading jar:file:/home/giancarlo/.m2/repository/org/gcube/core/common-scope-maps/1.0.7-SNAPSHOT/common-scope-maps-1.0.7-SNAPSHOT.jar!/openaire.servicemap
2018-01-17 12:59:39 INFO ServiceMapScanner:52 - loading jar:file:/home/giancarlo/.m2/repository/org/gcube/core/common-scope-maps/1.0.7-SNAPSHOT/common-scope-maps-1.0.7-SNAPSHOT.jar!/smartarea.servicemap
2018-01-17 12:59:39 INFO ServiceMapScanner:52 - loading jar:file:/home/giancarlo/.m2/repository/org/gcube/core/common-scope-maps/1.0.7-SNAPSHOT/common-scope-maps-1.0.7-SNAPSHOT.jar!/d4science.servicemap
2018-01-17 12:59:39 INFO ServiceMapScanner:52 - loading jar:file:/home/giancarlo/.m2/repository/org/gcube/core/common-scope-maps/1.0.7-SNAPSHOT/common-scope-maps-1.0.7-SNAPSHOT.jar!/gcubeapps.servicemap
2018-01-17 12:59:39 INFO ServiceMapScanner:52 - loading jar:file:/home/giancarlo/.m2/repository/org/gcube/core/common-scope-maps/1.0.7-SNAPSHOT/common-scope-maps-1.0.7-SNAPSHOT.jar!/isti.servicemap
2018-01-17 12:59:39 INFO ServiceMapScanner:52 - loading jar:file:/home/giancarlo/.m2/repository/org/gcube/core/common-scope-maps/1.0.7-SNAPSHOT/common-scope-maps-1.0.7-SNAPSHOT.jar!/devnext.servicemap
2018-01-17 12:59:39 INFO ServiceMapScanner:52 - loading jar:file:/home/giancarlo/.m2/repository/org/gcube/core/common-scope-maps/1.0.7-SNAPSHOT/common-scope-maps-1.0.7-SNAPSHOT.jar!/parthenosvo.servicemap
2018-01-17 12:59:39 INFO ServiceMapScanner:52 - loading jar:file:/home/giancarlo/.m2/repository/org/gcube/core/common-scope-maps/1.0.7-SNAPSHOT/common-scope-maps-1.0.7-SNAPSHOT.jar!/cnr.servicemap
2018-01-17 12:59:39 INFO ServiceMapScanner:52 - loading jar:file:/home/giancarlo/.m2/repository/org/gcube/core/common-scope-maps/1.0.7-SNAPSHOT/common-scope-maps-1.0.7-SNAPSHOT.jar!/d4research.servicemap
2018-01-17 12:59:39 INFO ServiceMapScanner:62 - overwriting older map (v.1.0.7-SNAPSHOT) with newer map (v.1.0.7-SNAPSHOT) for /d4science.research-infrastructures.eu/D4Research
2018-01-17 12:59:39 INFO ServiceMapScanner:52 - loading jar:file:/home/giancarlo/.m2/repository/org/gcube/core/common-scope-maps/1.0.7-SNAPSHOT/common-scope-maps-1.0.7-SNAPSHOT.jar!/preprod.servicemap
2018-01-17 12:59:39 INFO ICClient:75 - connectinfg to http://collector-parthenosvo.d4science.org:8080/wsrf/services/gcube/informationsystem/collector/XQueryAccess
2018-01-17 12:59:39 INFO StubFactory:147 - fetching wsdl for XQueryAccessService at http://collector-parthenosvo.d4science.org:8080/wsrf/services/gcube/informationsystem/collector/XQueryAccess?wsdl
2018-01-17 12:59:39 INFO StubCache:63 - caching stub for interface org.gcube.resources.discovery.icclient.stubs.CollectorStub
2018-01-17 12:59:40 DEBUG MethodRetriever:18 - for interface org.gcube.resources.discovery.icclient.stubs.CollectorStub the proxy class is com.sun.proxy.$Proxy36
2018-01-17 12:59:40 INFO ICClient:57 - executing query declare namespace ic = 'http://gcube-system.org/namespaces/informationsystem/registry'; for $resource in collection('/db/Profiles/RunningInstance')//Document/Data/ic:Profile/Resource where ($resource/Profile/ServiceClass/text() eq 'DataAnalysis') and ($resource/Profile/ServiceName/text() eq 'dataminer-pool-manager') return $resource
2018-01-17 12:59:40 INFO Helper:200 - submitting filtered query: declare namespace ic = 'http://gcube-system.org/namespaces/informationsystem/registry'; declare namespace functx = "http://www.functx.com"; declare function functx:is-value-in-sequence ( $value as xs:anyAtomicType? , $seq as xs:anyAtomicType* ) as xs:boolean { $value = $seq } ;
for $entry0ValueAuth in collection('/db/Profiles/RunningInstance')//Document/Data/ic:Profile/Resource/Scopes
where (functx:is-value-in-sequence('/d4science.research-infrastructures.eu/ParthenosVO/PARTHENOS_LAB',$entry0ValueAuth/child::*[local-name()='Scope']/text()) or functx:is-value-in-sequence('/d4science.research-infrastructures.eu/ParthenosVO',$entry0ValueAuth/child::*[local-name()='Scope']/text())) and ( ($entry0ValueAuth/../Profile/ServiceClass/text() eq 'DataAnalysis') and ($entry0ValueAuth/../Profile/ServiceName/text() eq 'dataminer-pool-manager') )
return $entry0ValueAuth/..
2018-01-17 12:59:40 INFO HandlerRegistry:30 - loaded call handler org.gcube.common.clients.stubs.jaxws.handlers.ScopeHandler@140c9f39
2018-01-17 12:59:40 INFO HandlerRegistry:30 - loaded call handler org.gcube.common.clients.stubs.jaxws.handlers.AuthorizationHandler@7690781
2018-01-17 12:59:40 INFO HandlerRegistry:30 - loaded call handler org.gcube.common.clients.stubs.jaxws.handlers.TargetServiceHandler@2e222612
2018-01-17 12:59:40 INFO HandlerRegistry:30 - loaded call handler org.gcube.common.clients.stubs.jaxws.handlers.ClientInfoHandler@7671cb68
2018-01-17 12:59:40 INFO HandlerRegistry:30 - loaded call handler org.gcube.common.clients.stubs.jaxws.handlers.LegacyWSAddressingHandler@68c72235
2018-01-17 12:59:40 INFO ICClient:65 - executed query declare namespace ic = 'http://gcube-system.org/namespaces/informationsystem/registry'; for $resource in collection('/db/Profiles/RunningInstance')//Document/Data/ic:Profile/Resource where ($resource/Profile/ServiceClass/text() eq 'DataAnalysis') and ($resource/Profile/ServiceName/text() eq 'dataminer-pool-manager') return $resource in 251 ms
2018-01-17 12:59:40 DEBUG InformationSystemUtils:118 - Resources: [GCoreEndpoint [id=86981339-1a07-4eb3-9919-c42344e6dfc8, scopes=[/d4science.research-infrastructures.eu/ParthenosVO/ParthenosLab, /d4science.research-infrastructures.eu/SoBigData/SoBigDataLab, /d4science.research-infrastructures.eu/D4Research, /d4science.research-infrastructures.eu/gCubeApps/RPrototypingLab, /d4science.research-infrastructures.eu/SoBigData, /d4science.research-infrastructures.eu/gCubeApps/ICCAT_BFT-E, /d4science.research-infrastructures.eu/D4Research/FoodborneOutbreak, /d4science.research-infrastructures.eu/D4Research/AgroClimaticModelling, /d4science.research-infrastructures.eu/gCubeApps/ScalableDataMining, /d4science.research-infrastructures.eu/D4Research/RAKIP_portal, /d4science.research-infrastructures.eu/gCubeApps/FAO_TunaAtlas, /d4science.research-infrastructures.eu/ParthenosVO, /d4science.research-infrastructures.eu/gCubeApps/StockAssessment, /d4science.research-infrastructures.eu/gCubeApps, /d4science.research-infrastructures.eu/D4Research/Sinay, /d4science.research-infrastructures.eu/D4Research/StatnMap, /d4science.research-infrastructures.eu/D4Research/IOTC_SS3, /d4science.research-infrastructures.eu/D4Research/FoodSecurity, /d4science.research-infrastructures.eu/D4Research/TextCrowd], type=RunningInstance, version=0.4.x, profile=[description=, version=0.0.1, ghn=[id=5ddf1091-87d2-4c38-b288-7ac3ed19cdc3], service=[id=dataminer-pool-managerDataAnalysis0.0.1], serviceName=dataminer-pool-manager, serviceClass=DataAnalysis, runningInstanceInterfaces=[], platform=null, deploymentData=[instanceName=null, localPath=null, activationTime=12/19/17 3:08 PM, terminationTime=, status=ready, messageState=null, plugins=[]], functions=[], endpoints=[Endpoint [name=REST-API, uri=http://dm-pool-manager-proto.d4science.org:80/dataminer-pool-manager/api], Endpoint [name=dataminer-pool-manager-remote-management, uri=http://dm-pool-manager-proto.d4science.org:80/dataminer-pool-manager/gcube/resource]], specificData=[doc: null], accountings=[]]]]
2018-01-17 12:59:40 DEBUG InformationSystemUtils:162 - DataMiner PoolManager URI: null
2018-01-17 12:59:40 INFO ISResourceTest:109 - DataMinerPoolManager: null