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