git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/Common/workspace-task-executor-library@169324 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
cae510b7bd
commit
b4ce45fe73
7
pom.xml
7
pom.xml
|
@ -94,6 +94,13 @@
|
|||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- JSON PARSER -->
|
||||
<dependency>
|
||||
<groupId>org.json</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
<version>20090211</version>
|
||||
</dependency>
|
||||
|
||||
<!-- LOGGER -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
|
|
|
@ -23,8 +23,8 @@ public class TaskParameter implements Serializable{
|
|||
private static final long serialVersionUID = 3607328256110736864L;
|
||||
private String key;
|
||||
private String value;
|
||||
@JsonIgnoreProperties
|
||||
private List<String> defaultValues; //optional
|
||||
@JsonIgnoreProperties //optional
|
||||
private List<String> defaultValues;
|
||||
private TaskParameterType type;
|
||||
|
||||
/**
|
||||
|
|
|
@ -5,15 +5,12 @@ package org.gcube.common.workspacetaskexecutor;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException;
|
||||
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
||||
import org.gcube.common.homelibrary.home.workspace.exceptions.ItemNotFoundException;
|
||||
import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
|
||||
import org.gcube.common.workspacetaskexecutor.dataminer.WorkspaceDataMinerTaskExecutor;
|
||||
import org.gcube.common.workspacetaskexecutor.shared.TaskParameter;
|
||||
import org.gcube.common.workspacetaskexecutor.shared.TaskParameterType;
|
||||
|
@ -40,7 +37,7 @@ public class TestDataMinerTaskExecutor {
|
|||
public static String USERNAME = "francesco.mangiacrapa";
|
||||
public static String SCOPE = "/gcube/devsec";
|
||||
|
||||
public static String WORKSPACE_FOLDER_ID = "f5c2f5ab-5c35-4418-8e60-d48d173538ed";
|
||||
public static String WORKSPACE_FOLDER_ID = "682ff48e-0cc9-44df-884d-185fabe8909b";
|
||||
|
||||
private static JsonUtil jUtil = new JsonUtil();
|
||||
|
||||
|
@ -93,7 +90,9 @@ public class TestDataMinerTaskExecutor {
|
|||
|
||||
public static void main(String[] args) {
|
||||
|
||||
// ScopeProvider.instance.set(SCOPE);
|
||||
jsonCheck();
|
||||
|
||||
//ScopeProvider.instance.set(SCOPE);
|
||||
// listDummyConf = gelDummyListOfConfigurations(3);
|
||||
// WorkspaceDataMinerTaskExecutor exec = WorkspaceDataMinerTaskExecutor.getInstance();
|
||||
// exec.withOwner(USERNAME);
|
||||
|
@ -148,7 +147,7 @@ public class TestDataMinerTaskExecutor {
|
|||
// e.printStackTrace();
|
||||
// }
|
||||
|
||||
//checkGubeProperties(gelDummyListOfConfigurations());
|
||||
//checkGubeProperties(null);
|
||||
|
||||
|
||||
// try {
|
||||
|
@ -195,13 +194,15 @@ public class TestDataMinerTaskExecutor {
|
|||
try {
|
||||
WorkspaceItem workspaceItem = WsUtil.getItem(USERNAME, WORKSPACE_FOLDER_ID);
|
||||
|
||||
JSONArray jsonArray = jUtil.toJSONArray(listConfigurations);
|
||||
System.out.println("Json array to save: "+jsonArray);
|
||||
WsUtil.setPropertyValue(workspaceItem, WorkspaceDataMinerTaskExecutor.WS_DM_TASK_TASK_CONF, jsonArray.toString());
|
||||
/*if(listConfigurations!=null){
|
||||
JSONArray jsonArray = jUtil.toJSONArray(listConfigurations);
|
||||
System.out.println("Json array to save: "+jsonArray);
|
||||
WsUtil.setPropertyValue(workspaceItem, WorkspaceDataMinerTaskExecutor.WS_DM_TASK_TASK_CONF, jsonArray.toString());
|
||||
}
|
||||
|
||||
//GET
|
||||
String jsonArrayConf = WsUtil.getPropertyValue(workspaceItem, WorkspaceDataMinerTaskExecutor.WS_DM_TASK_TASK_CONF);
|
||||
System.out.println("Json array read from "+WorkspaceDataMinerTaskExecutor.WS_DM_TASK_TASK_CONF+": "+jsonArray);
|
||||
System.out.println("Json array read from "+WorkspaceDataMinerTaskExecutor.WS_DM_TASK_TASK_CONF+": "+jsonArrayConf);
|
||||
|
||||
|
||||
TypeReference<List<TaskConfiguration>> mapType = new TypeReference<List<TaskConfiguration>>() {};
|
||||
|
@ -209,15 +210,9 @@ public class TestDataMinerTaskExecutor {
|
|||
System.out.println("Json array to listUnM...");
|
||||
for (TaskConfiguration taskConfiguration : listUnM) {
|
||||
System.out.println(taskConfiguration);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
catch (WorkspaceFolderNotFoundException | ItemNotFoundException
|
||||
| InternalErrorException | HomeNotFoundException | JsonProcessingException | JSONException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
@ -242,19 +237,22 @@ public class TestDataMinerTaskExecutor {
|
|||
tp.setValue("this is the public link "+index);
|
||||
tp.setType(new TaskParameterType(ParameterType.FILE.toString()));
|
||||
|
||||
|
||||
listParameters.add(tp);
|
||||
|
||||
TaskParameter tp2 = new TaskParameter();
|
||||
tp2.setKey("key"+index);
|
||||
tp2.setValue("value "+index);
|
||||
tp2.setType(types.get(new Random().nextInt(types.size())));
|
||||
tp2.setDefaultValues(Arrays.asList("value 1", "value2"));
|
||||
listParameters.add(tp2);
|
||||
|
||||
|
||||
return new TaskConfiguration(index+"", UUID.randomUUID().toString(), index+"name", null, USERNAME, SCOPE, "my token", WORKSPACE_FOLDER_ID, listParameters);
|
||||
}
|
||||
|
||||
|
||||
public static List<TaskConfiguration> gelDummyListOfConfigurations(int total){
|
||||
public static List<TaskConfiguration> getDummyListOfConfigurations(int total){
|
||||
List<TaskConfiguration> listConfigurations = new ArrayList<>(total);
|
||||
for (int i=0; i<total; i++) {
|
||||
TaskConfiguration c = createDummyConfiguration(i);
|
||||
|
@ -266,10 +264,10 @@ public class TestDataMinerTaskExecutor {
|
|||
public static void jsonCheck(){
|
||||
|
||||
|
||||
List<TaskConfiguration> listConfigurations = gelDummyListOfConfigurations(3);
|
||||
List<TaskConfiguration> listConfigurations = getDummyListOfConfigurations(3);
|
||||
try {
|
||||
JSONArray jsonArray = jUtil.toJSONArray(listConfigurations);
|
||||
System.out.println("Json array: "+jsonArray);
|
||||
System.out.println("Json array: "+jsonArray.toString(4));
|
||||
TypeReference<List<TaskConfiguration>> mapType = new TypeReference<List<TaskConfiguration>>() {};
|
||||
List<TaskConfiguration> listUnM = jUtil.readList(jsonArray.toString(), mapType);
|
||||
System.out.println("Json array to listUnM...");
|
||||
|
|
Loading…
Reference in New Issue