added listInOperator and listOutOperator

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/Common/workspace-task-executor-library@167582 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2018-05-18 09:36:19 +00:00
parent a7b0d4cfa5
commit 07f7184e8e
3 changed files with 79 additions and 25 deletions

View File

@ -78,24 +78,48 @@ public class DMConverter {
* To task operator. * To task operator.
* *
* @param op the op * @param op the op
* @param inputParameters the input parameters
* @param outputParameters the output parameters
* @return the task operator * @return the task operator
*/ */
public static TaskOperator toTaskOperator(Operator op){ public static TaskOperator toTaskOperator(Operator op, List<Parameter> inputParameters, List<Parameter> outputParameters){
if(op==null) if(op==null)
return null; return null;
List<TaskParameter> listOperator = null; // List<TaskParameter> listOperator = null;
if(op.getOperatorParameters()!=null){ // if(op.getOperatorParameters()!=null){
listOperator = new ArrayList<TaskParameter>(op.getOperatorParameters().size()); // listOperator = new ArrayList<TaskParameter>(op.getOperatorParameters().size());
for (Parameter param : op.getOperatorParameters()) { // for (Parameter param : op.getOperatorParameters()) {
// TaskParameter tp = toTaskParameter(param);
// if(tp!=null)
// listOperator.add(tp);
// }
// }
//Converting input parameters
List<TaskParameter> listInOperator = null;
if(inputParameters!=null){
listInOperator = new ArrayList<TaskParameter>(inputParameters.size());
for (Parameter param :inputParameters) {
TaskParameter tp = toTaskParameter(param); TaskParameter tp = toTaskParameter(param);
if(tp!=null) 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<TaskParameter> listOutOperator = null;
if(outputParameters!=null){
listOutOperator = new ArrayList<TaskParameter>(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());
} }

View File

@ -397,12 +397,14 @@ public class DataMinerAccessPoint {
if(firstCategory.getOperators()!=null&& !firstCategory.getOperators().isEmpty()){ if(firstCategory.getOperators()!=null&& !firstCategory.getOperators().isEmpty()){
for (Operator operator : firstCategory.getOperators()) { for (Operator operator : firstCategory.getOperators()) {
TaskOperator to = DMConverter.toTaskOperator(operator); List<Parameter> inputParameters=sClient.getInputParameters(operator);
List<Parameter> outputParameters=sClient.getOutputParameters(operator);
TaskOperator to = DMConverter.toTaskOperator(operator, inputParameters, outputParameters);
if(to!=null) if(to!=null)
listOperator.add(to); listOperator.add(to);
} }
//firstCategory.getOperators(); // RETURNS THE LIST OF ALGORITHMS // firstCategory.getOperators(); // RETURNS THE LIST OF ALGORITHMS
// Operator operator=firstCategory.getOperators().get(0); // Operator operator=firstCategory.getOperators().get(0);
// logger.debug("First Operator: "+operator); // logger.debug("First Operator: "+operator);
// List<Parameter> inputParameters=sClient.getInputParameters(operator); // List<Parameter> inputParameters=sClient.getInputParameters(operator);

View File

@ -11,8 +11,8 @@ import java.util.List;
/** /**
* The Class TaskOperator. * The Class TaskOperator.
* *
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* May 17, 2018 * May 18, 2018
*/ */
public class TaskOperator implements Serializable{ public class TaskOperator implements Serializable{
@ -24,8 +24,9 @@ public class TaskOperator implements Serializable{
private String name; private String name;
private String briefDescription; private String briefDescription;
private String description; private String description;
private List<TaskParameter> operatorParameters = new ArrayList<TaskParameter>(); private List<TaskParameter> inputOperators = new ArrayList<TaskParameter>();
private boolean hasImage = false; private boolean hasImage = false;
private List<TaskParameter> outputOperators;
/** /**
* Instantiates a new task operator. * Instantiates a new task operator.
@ -42,18 +43,20 @@ public class TaskOperator implements Serializable{
* @param name the name * @param name the name
* @param briefDescription the brief description * @param briefDescription the brief description
* @param description the 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 * @param hasImage the has image
*/ */
public TaskOperator( public TaskOperator(
String id, String name, String briefDescription, String description, String id, String name, String briefDescription, String description,
List<TaskParameter> operatorParameters, boolean hasImage) { List<TaskParameter> inputOperatorParameters, List<TaskParameter> outputOeratorParameters, boolean hasImage) {
this.id = id; this.id = id;
this.name = name; this.name = name;
this.briefDescription = briefDescription; this.briefDescription = briefDescription;
this.description = description; this.description = description;
this.operatorParameters = operatorParameters; this.inputOperators = inputOperatorParameters;
this.outputOperators = outputOeratorParameters;
this.hasImage = hasImage; 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<TaskParameter> getOperatorParameters() { public List<TaskParameter> getInputOperators() {
return operatorParameters; return inputOperators;
} }
@ -124,6 +127,17 @@ public class TaskOperator implements Serializable{
} }
/**
* Gets the output operators.
*
* @return the outputOperators
*/
public List<TaskParameter> getOutputOperators() {
return outputOperators;
}
/** /**
* Sets the id. * 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<TaskParameter> operatorParameters) { public void setInputOperators(List<TaskParameter> inputOperators) {
this.operatorParameters = operatorParameters; this.inputOperators = inputOperators;
} }
@ -189,6 +203,17 @@ public class TaskOperator implements Serializable{
this.hasImage = hasImage; this.hasImage = hasImage;
} }
/**
* Sets the output operators.
*
* @param outputOperators the outputOperators to set
*/
public void setOutputOperators(List<TaskParameter> outputOperators) {
this.outputOperators = outputOperators;
}
/* (non-Javadoc) /* (non-Javadoc)
* @see java.lang.Object#toString() * @see java.lang.Object#toString()
*/ */
@ -204,14 +229,17 @@ public class TaskOperator implements Serializable{
builder.append(briefDescription); builder.append(briefDescription);
builder.append(", description="); builder.append(", description=");
builder.append(description); builder.append(description);
builder.append(", operatorParameters="); builder.append(", inputOperators=");
builder.append(operatorParameters); builder.append(inputOperators);
builder.append(", hasImage="); builder.append(", hasImage=");
builder.append(hasImage); builder.append(hasImage);
builder.append(", outputOperators=");
builder.append(outputOperators);
builder.append("]"); builder.append("]");
return builder.toString(); return builder.toString();
} }
} }