diff --git a/src/main/java/org/gcube/common/workspacetaskexecutor/dataminer/DMConverter.java b/src/main/java/org/gcube/common/workspacetaskexecutor/dataminer/DMConverter.java index 8cf7f44..a139ae2 100644 --- a/src/main/java/org/gcube/common/workspacetaskexecutor/dataminer/DMConverter.java +++ b/src/main/java/org/gcube/common/workspacetaskexecutor/dataminer/DMConverter.java @@ -78,24 +78,48 @@ public class DMConverter { * To task operator. * * @param op the op + * @param inputParameters the input parameters + * @param outputParameters the output parameters * @return the task operator */ - public static TaskOperator toTaskOperator(Operator op){ + public static TaskOperator toTaskOperator(Operator op, List inputParameters, List outputParameters){ if(op==null) return null; - List listOperator = null; - if(op.getOperatorParameters()!=null){ - listOperator = new ArrayList(op.getOperatorParameters().size()); - for (Parameter param : op.getOperatorParameters()) { +// List listOperator = null; +// if(op.getOperatorParameters()!=null){ +// listOperator = new ArrayList(op.getOperatorParameters().size()); +// for (Parameter param : op.getOperatorParameters()) { +// TaskParameter tp = toTaskParameter(param); +// if(tp!=null) +// listOperator.add(tp); +// } +// } + + //Converting input parameters + List listInOperator = null; + if(inputParameters!=null){ + listInOperator = new ArrayList(inputParameters.size()); + for (Parameter param :inputParameters) { TaskParameter tp = toTaskParameter(param); if(tp!=null) - listOperator.add(tp); + listInOperator.add(tp); } } - return new TaskOperator(op.getId(), op.getName(), op.getBriefDescription(), op.getDescription(), listOperator,op.hasImage()); + //Converting output parameters + List listOutOperator = null; + if(outputParameters!=null){ + listOutOperator = new ArrayList(inputParameters.size()); + for (Parameter param : outputParameters) { + TaskParameter tp = toTaskParameter(param); + if(tp!=null) + listOutOperator.add(tp); + } + } + + return new TaskOperator(op.getId(), op.getName(), op.getBriefDescription(), op.getDescription(), listInOperator, listOutOperator, op.hasImage()); } diff --git a/src/main/java/org/gcube/common/workspacetaskexecutor/dataminer/DataMinerAccessPoint.java b/src/main/java/org/gcube/common/workspacetaskexecutor/dataminer/DataMinerAccessPoint.java index 74b9113..db15df4 100644 --- a/src/main/java/org/gcube/common/workspacetaskexecutor/dataminer/DataMinerAccessPoint.java +++ b/src/main/java/org/gcube/common/workspacetaskexecutor/dataminer/DataMinerAccessPoint.java @@ -397,12 +397,14 @@ public class DataMinerAccessPoint { if(firstCategory.getOperators()!=null&& !firstCategory.getOperators().isEmpty()){ for (Operator operator : firstCategory.getOperators()) { - TaskOperator to = DMConverter.toTaskOperator(operator); + List inputParameters=sClient.getInputParameters(operator); + List outputParameters=sClient.getOutputParameters(operator); + TaskOperator to = DMConverter.toTaskOperator(operator, inputParameters, outputParameters); if(to!=null) listOperator.add(to); } - //firstCategory.getOperators(); // RETURNS THE LIST OF ALGORITHMS +// firstCategory.getOperators(); // RETURNS THE LIST OF ALGORITHMS // Operator operator=firstCategory.getOperators().get(0); // logger.debug("First Operator: "+operator); // List inputParameters=sClient.getInputParameters(operator); diff --git a/src/main/java/org/gcube/common/workspacetaskexecutor/shared/TaskOperator.java b/src/main/java/org/gcube/common/workspacetaskexecutor/shared/TaskOperator.java index 0e30290..cbbb0c0 100644 --- a/src/main/java/org/gcube/common/workspacetaskexecutor/shared/TaskOperator.java +++ b/src/main/java/org/gcube/common/workspacetaskexecutor/shared/TaskOperator.java @@ -11,8 +11,8 @@ import java.util.List; /** * The Class TaskOperator. * - * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it - * May 17, 2018 + * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) + * May 18, 2018 */ public class TaskOperator implements Serializable{ @@ -24,8 +24,9 @@ public class TaskOperator implements Serializable{ private String name; private String briefDescription; private String description; - private List operatorParameters = new ArrayList(); + private List inputOperators = new ArrayList(); private boolean hasImage = false; + private List outputOperators; /** * Instantiates a new task operator. @@ -42,18 +43,20 @@ public class TaskOperator implements Serializable{ * @param name the name * @param briefDescription the brief description * @param description the description - * @param operatorParameters the operator parameters + * @param inputOperatorParameters the input operator parameters + * @param outputOeratorParameters the output oerator parameters * @param hasImage the has image */ public TaskOperator( String id, String name, String briefDescription, String description, - List operatorParameters, boolean hasImage) { + List inputOperatorParameters, List outputOeratorParameters, boolean hasImage) { this.id = id; this.name = name; this.briefDescription = briefDescription; this.description = description; - this.operatorParameters = operatorParameters; + this.inputOperators = inputOperatorParameters; + this.outputOperators = outputOeratorParameters; this.hasImage = hasImage; } @@ -103,13 +106,13 @@ public class TaskOperator implements Serializable{ /** - * Gets the operator parameters. + * Gets the input operators. * - * @return the operatorParameters + * @return the inputOperators */ - public List getOperatorParameters() { + public List getInputOperators() { - return operatorParameters; + return inputOperators; } @@ -124,6 +127,17 @@ public class TaskOperator implements Serializable{ } + /** + * Gets the output operators. + * + * @return the outputOperators + */ + public List getOutputOperators() { + + return outputOperators; + } + + /** * Sets the id. * @@ -169,13 +183,13 @@ public class TaskOperator implements Serializable{ /** - * Sets the operator parameters. + * Sets the input operators. * - * @param operatorParameters the operatorParameters to set + * @param inputOperators the inputOperators to set */ - public void setOperatorParameters(List operatorParameters) { + public void setInputOperators(List inputOperators) { - this.operatorParameters = operatorParameters; + this.inputOperators = inputOperators; } @@ -189,6 +203,17 @@ public class TaskOperator implements Serializable{ this.hasImage = hasImage; } + + /** + * Sets the output operators. + * + * @param outputOperators the outputOperators to set + */ + public void setOutputOperators(List outputOperators) { + + this.outputOperators = outputOperators; + } + /* (non-Javadoc) * @see java.lang.Object#toString() */ @@ -204,14 +229,17 @@ public class TaskOperator implements Serializable{ builder.append(briefDescription); builder.append(", description="); builder.append(description); - builder.append(", operatorParameters="); - builder.append(operatorParameters); + builder.append(", inputOperators="); + builder.append(inputOperators); builder.append(", hasImage="); builder.append(hasImage); + builder.append(", outputOperators="); + builder.append(outputOperators); builder.append("]"); return builder.toString(); } + }