Enhancement on Task #10070
Added Parameters as a List git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/Common/workspace-task-executor-library@167360 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
3e6a514b97
commit
cce789d2a6
|
@ -26,7 +26,6 @@ import org.gcube.data.analysis.dataminermanagercl.shared.data.computations.Compu
|
|||
import org.gcube.data.analysis.dataminermanagercl.shared.data.output.MapResource;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.data.output.Resource;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.Parameter;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.ParameterType;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.process.ComputationStatus;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.process.ComputationStatus.Status;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.process.Operator;
|
||||
|
@ -150,7 +149,7 @@ public class DataMinerAccessPoint {
|
|||
}
|
||||
|
||||
try {
|
||||
addParametersToOperator(operator, taskConfiguration.getMapParameters());
|
||||
addParametersToOperator(operator, taskConfiguration.getListParameters());
|
||||
logger.debug("Start Computation");
|
||||
ComputationId computationId = sClient.startComputation(operator);
|
||||
logger.debug("Started ComputationId: " + computationId);
|
||||
|
@ -385,14 +384,11 @@ public class DataMinerAccessPoint {
|
|||
* @param parameters the parameters
|
||||
* @return the operator
|
||||
*/
|
||||
private Operator addParametersToOperator(Operator operator, Map<String, TaskParameter> parameters) {
|
||||
private Operator addParametersToOperator(Operator operator, List<TaskParameter> parameters) {
|
||||
logger.debug("Adding parameters to operator");
|
||||
|
||||
List<Parameter> listParameters = new ArrayList<Parameter>();
|
||||
for (String key : parameters.keySet()) {
|
||||
|
||||
TaskParameter taskParameter = parameters.get(key);
|
||||
ParameterType toParameterType = null;
|
||||
for (TaskParameter taskParameter : parameters) {
|
||||
|
||||
if(taskParameter.getType()==null)
|
||||
continue;
|
||||
|
|
|
@ -166,9 +166,9 @@ public class WorkspaceDataMinerTaskExecutor implements ExecutableTask<TaskConfig
|
|||
TypeReference<List<TaskConfiguration>> mapType = new TypeReference<List<TaskConfiguration>>() {};
|
||||
conf = jsonUtil.readList(arrayConf, mapType);
|
||||
}catch(Exception e){
|
||||
logger.warn("The item id "+workspaceItemId+" has a wrong "+TaskConfiguration.class.getSimpleName()+" saved");
|
||||
logger.error("Error on serializing configuration: "+arrayConf, e);
|
||||
logger.info("The item id "+workspaceItemId+" has a wrong "+TaskConfiguration.class.getSimpleName()+" saved. Deleting them..");
|
||||
eraseAllTaskConfigurations(workspaceItemId);
|
||||
//eraseAllTaskConfigurations(workspaceItemId);
|
||||
}
|
||||
|
||||
logger.debug("Found configuration/s: "+conf);
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
*/
|
||||
package org.gcube.common.workspacetaskexecutor.shared;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
@ -38,11 +39,11 @@ public interface BaseTaskConfiguration {
|
|||
|
||||
|
||||
/**
|
||||
* Gets the map parameters.
|
||||
* Gets the list parameters.
|
||||
*
|
||||
* @return the map parameters
|
||||
* @return the list parameters
|
||||
*/
|
||||
Map<String, TaskParameter> getMapParameters();
|
||||
List<TaskParameter> getListParameters();
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
package org.gcube.common.workspacetaskexecutor.shared.dataminer;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import org.gcube.common.workspacetaskexecutor.shared.BaseTaskConfiguration;
|
||||
|
@ -40,7 +40,7 @@ public class TaskConfiguration implements BaseTaskConfiguration, Serializable {
|
|||
private String maskedToken;
|
||||
private String workspaceItemId;
|
||||
@JsonIgnoreProperties
|
||||
private Map<String, TaskParameter> mapParameters; // optional
|
||||
private List<TaskParameter> listParameters; // optional
|
||||
private String configurationKey;
|
||||
|
||||
/**
|
||||
|
@ -59,12 +59,12 @@ public class TaskConfiguration implements BaseTaskConfiguration, Serializable {
|
|||
* @param scope the scope
|
||||
* @param maskedToken the token
|
||||
* @param workspaceItemId the workspace item id
|
||||
* @param mapParameters the map parameters
|
||||
* @param listParameters the map parameters
|
||||
*/
|
||||
public TaskConfiguration(
|
||||
String configurationKey, String taskId, String taskDescription, String scope,
|
||||
String maskedToken, String workspaceItemId,
|
||||
Map<String, TaskParameter> mapParameters) {
|
||||
List<TaskParameter> listParameters) {
|
||||
|
||||
setConfigurationKey(configurationKey);
|
||||
this.taskId = taskId;
|
||||
|
@ -72,7 +72,7 @@ public class TaskConfiguration implements BaseTaskConfiguration, Serializable {
|
|||
this.scope = scope;
|
||||
this.maskedToken = maskedToken;
|
||||
this.workspaceItemId = workspaceItemId;
|
||||
this.mapParameters = mapParameters;
|
||||
this.listParameters = listParameters;
|
||||
}
|
||||
|
||||
|
||||
|
@ -149,20 +149,20 @@ public class TaskConfiguration implements BaseTaskConfiguration, Serializable {
|
|||
|
||||
|
||||
/**
|
||||
* @return the mapParameters
|
||||
* @return the listParameters
|
||||
*/
|
||||
public Map<String, TaskParameter> getMapParameters() {
|
||||
public List<TaskParameter> getListParameters() {
|
||||
|
||||
return mapParameters;
|
||||
return listParameters;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param mapParameters the mapParameters to set
|
||||
* @param listParameters the listParameters to set
|
||||
*/
|
||||
public void setMapParameters(Map<String, TaskParameter> mapParameters) {
|
||||
public void setListParameters(List<TaskParameter> listParameters) {
|
||||
|
||||
this.mapParameters = mapParameters;
|
||||
this.listParameters = listParameters;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -234,8 +234,6 @@ public class TaskConfiguration implements BaseTaskConfiguration, Serializable {
|
|||
this.maskedToken = maskedToken;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
|
@ -253,8 +251,8 @@ public class TaskConfiguration implements BaseTaskConfiguration, Serializable {
|
|||
builder.append(maskedToken);
|
||||
builder.append(", workspaceItemId=");
|
||||
builder.append(workspaceItemId);
|
||||
builder.append(", mapParameters=");
|
||||
builder.append(mapParameters);
|
||||
builder.append(", listParameters=");
|
||||
builder.append(listParameters);
|
||||
builder.append(", configurationKey=");
|
||||
builder.append(configurationKey);
|
||||
builder.append("]");
|
||||
|
|
|
@ -5,9 +5,7 @@ package org.gcube.common.workspacetaskexecutor;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -101,7 +99,7 @@ public class TestDataMinerTaskExecutor {
|
|||
//jsonCheck();
|
||||
|
||||
//ERASE ALL CONFIGURATIONS
|
||||
eraseAllTaskConfigurations(exec);
|
||||
//eraseAllTaskConfigurations(exec);
|
||||
|
||||
//GET LIST CONFIGURATIONS
|
||||
//getConfigurations(exec);
|
||||
|
@ -235,22 +233,22 @@ public class TestDataMinerTaskExecutor {
|
|||
// System.out.println(availableType);
|
||||
// }
|
||||
|
||||
Map<String, TaskParameter> mapParameters = new HashMap<String, TaskParameter>();
|
||||
List<TaskParameter> listParameters = new ArrayList<TaskParameter>();
|
||||
|
||||
TaskParameter tp = new TaskParameter();
|
||||
tp.setKey("publiclink");
|
||||
tp.setValue("this is the public link "+index);
|
||||
tp.setType(new TaskParameterType(ParameterType.FILE.toString()));
|
||||
|
||||
mapParameters.put("publiclink", tp);
|
||||
listParameters.add(tp);
|
||||
|
||||
TaskParameter tp2 = new TaskParameter();
|
||||
tp2.setKey("key"+index);
|
||||
tp2.setValue("value "+index);
|
||||
tp2.setType(types.get(new Random().nextInt(types.size())));
|
||||
mapParameters.put("publiclink", tp2);
|
||||
listParameters.add(tp2);
|
||||
|
||||
return new TaskConfiguration(index+"", UUID.randomUUID().toString(), null, SCOPE, "my token", WORKSPACE_FOLDER_ID, mapParameters);
|
||||
return new TaskConfiguration(index+"", UUID.randomUUID().toString(), null, SCOPE, "my token", WORKSPACE_FOLDER_ID, listParameters);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue