Java Code Examples for org.activiti.engine.task.Task#getTaskLocalVariables()

The following examples show how to use org.activiti.engine.task.Task#getTaskLocalVariables() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TaskAndVariablesQueryTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void testQueryWithPagingAndVariables() {
  List<Task> tasks = taskService.createTaskQuery().includeProcessVariables().includeTaskLocalVariables().orderByTaskPriority().desc().listPage(0, 1);
  assertEquals(1, tasks.size());
  Task task = tasks.get(0);
  Map<String, Object> variableMap = task.getTaskLocalVariables();
  assertEquals(3, variableMap.size());
  assertEquals("someVariable", variableMap.get("testVar"));
  assertEquals(123, variableMap.get("testVar2"));
  assertEquals("This is a binary variable", new String((byte[]) variableMap.get("testVarBinary")));

  tasks = taskService.createTaskQuery().includeProcessVariables().includeTaskLocalVariables().orderByTaskPriority().asc().listPage(1, 2);
  assertEquals(2, tasks.size());
  task = tasks.get(1);
  variableMap = task.getTaskLocalVariables();
  assertEquals(3, variableMap.size());
  assertEquals("someVariable", variableMap.get("testVar"));
  assertEquals(123, variableMap.get("testVar2"));
  assertEquals("This is a binary variable", new String((byte[]) variableMap.get("testVarBinary")));

  tasks = taskService.createTaskQuery().includeProcessVariables().includeTaskLocalVariables().orderByTaskPriority().asc().listPage(2, 4);
  assertEquals(1, tasks.size());
  task = tasks.get(0);
  variableMap = task.getTaskLocalVariables();
  assertEquals(3, variableMap.size());
  assertEquals("someVariable", variableMap.get("testVar"));
  assertEquals(123, variableMap.get("testVar2"));
  assertEquals("This is a binary variable", new String((byte[]) variableMap.get("testVarBinary")));

  tasks = taskService.createTaskQuery().includeProcessVariables().includeTaskLocalVariables().orderByTaskPriority().asc().listPage(4, 2);
  assertEquals(0, tasks.size());
}
 
Example 2
Source File: TaskAndVariablesQueryTest.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
@Deployment
public void testQuery() {
  Task task = taskService.createTaskQuery().includeTaskLocalVariables().taskAssignee("gonzo").singleResult();
  Map<String, Object> variableMap = task.getTaskLocalVariables();
  assertEquals(3, variableMap.size());
  assertEquals(0, task.getProcessVariables().size());
  assertNotNull(variableMap.get("testVar"));
  assertEquals("someVariable", variableMap.get("testVar"));
  assertNotNull(variableMap.get("testVar2"));
  assertEquals(123, variableMap.get("testVar2"));
  assertNotNull(variableMap.get("testVarBinary"));
  assertEquals("This is a binary variable", new String((byte[]) variableMap.get("testVarBinary")));

  List<Task> tasks = taskService.createTaskQuery().list();
  assertEquals(3, tasks.size());

  task = taskService.createTaskQuery().includeProcessVariables().taskAssignee("gonzo").singleResult();
  assertEquals(0, task.getProcessVariables().size());
  assertEquals(0, task.getTaskLocalVariables().size());

  Map<String, Object> startMap = new HashMap<String, Object>();
  startMap.put("processVar", true);
  startMap.put("binaryVariable", "This is a binary process variable".getBytes());
  runtimeService.startProcessInstanceByKey("oneTaskProcess", startMap);

  task = taskService.createTaskQuery().includeProcessVariables().taskAssignee("kermit").singleResult();
  assertEquals(2, task.getProcessVariables().size());
  assertEquals(0, task.getTaskLocalVariables().size());
  assertTrue((Boolean) task.getProcessVariables().get("processVar"));
  assertEquals("This is a binary process variable", new String((byte[]) task.getProcessVariables().get("binaryVariable")));

  taskService.setVariable(task.getId(), "anotherProcessVar", 123);
  taskService.setVariableLocal(task.getId(), "localVar", "test");

  task = taskService.createTaskQuery().includeTaskLocalVariables().taskAssignee("kermit").singleResult();
  assertEquals(0, task.getProcessVariables().size());
  assertEquals(1, task.getTaskLocalVariables().size());
  assertEquals("test", task.getTaskLocalVariables().get("localVar"));

  task = taskService.createTaskQuery().includeProcessVariables().taskAssignee("kermit").singleResult();
  assertEquals(3, task.getProcessVariables().size());
  assertEquals(0, task.getTaskLocalVariables().size());
  assertEquals(true, task.getProcessVariables().get("processVar"));
  assertEquals(123, task.getProcessVariables().get("anotherProcessVar"));
  assertEquals("This is a binary process variable", new String((byte[]) task.getProcessVariables().get("binaryVariable")));

  tasks = taskService.createTaskQuery().includeTaskLocalVariables().taskCandidateUser("kermit").list();
  assertEquals(2, tasks.size());
  assertEquals(2, tasks.get(0).getTaskLocalVariables().size());
  assertEquals("test", tasks.get(0).getTaskLocalVariables().get("test"));
  assertEquals(0, tasks.get(0).getProcessVariables().size());

  tasks = taskService.createTaskQuery().includeProcessVariables().taskCandidateUser("kermit").list();
  assertEquals(2, tasks.size());
  assertEquals(0, tasks.get(0).getProcessVariables().size());
  assertEquals(0, tasks.get(0).getTaskLocalVariables().size());

  task = taskService.createTaskQuery().includeTaskLocalVariables().taskAssignee("kermit").taskVariableValueEquals("localVar", "test").singleResult();
  assertEquals(0, task.getProcessVariables().size());
  assertEquals(1, task.getTaskLocalVariables().size());
  assertEquals("test", task.getTaskLocalVariables().get("localVar"));

  task = taskService.createTaskQuery().includeProcessVariables().taskAssignee("kermit").taskVariableValueEquals("localVar", "test").singleResult();
  assertEquals(3, task.getProcessVariables().size());
  assertEquals(0, task.getTaskLocalVariables().size());
  assertEquals(true, task.getProcessVariables().get("processVar"));
  assertEquals(123, task.getProcessVariables().get("anotherProcessVar"));

  task = taskService.createTaskQuery().includeTaskLocalVariables().includeProcessVariables().taskAssignee("kermit").singleResult();
  assertEquals(3, task.getProcessVariables().size());
  assertEquals(1, task.getTaskLocalVariables().size());
  assertEquals("test", task.getTaskLocalVariables().get("localVar"));
  assertEquals(true, task.getProcessVariables().get("processVar"));
  assertEquals(123, task.getProcessVariables().get("anotherProcessVar"));
  assertEquals("This is a binary process variable", new String((byte[]) task.getProcessVariables().get("binaryVariable")));
}
 
Example 3
Source File: TaskAndVariablesQueryTest.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
@Deployment
public void testQuery() {
  Task task = taskService.createTaskQuery().includeTaskLocalVariables().taskAssignee("gonzo").singleResult();
  Map<String, Object> variableMap = task.getTaskLocalVariables();
  assertEquals(3, variableMap.size());
  assertEquals(0, task.getProcessVariables().size());
  assertNotNull(variableMap.get("testVar"));
  assertEquals("someVariable", variableMap.get("testVar"));
  assertNotNull(variableMap.get("testVar2"));
  assertEquals(123, variableMap.get("testVar2"));
  assertNotNull(variableMap.get("testVarBinary"));
  assertEquals("This is a binary variable", new String((byte[]) variableMap.get("testVarBinary")));
  
  List<Task> tasks = taskService.createTaskQuery().list();
  assertEquals(3, tasks.size());
  
  task = taskService.createTaskQuery().includeProcessVariables().taskAssignee("gonzo").singleResult();
  assertEquals(0, task.getProcessVariables().size());
  assertEquals(0, task.getTaskLocalVariables().size());
  
  Map<String, Object> startMap = new HashMap<String, Object>();
  startMap.put("processVar", true);
  startMap.put("binaryVariable", "This is a binary process variable".getBytes());
  runtimeService.startProcessInstanceByKey("oneTaskProcess", startMap);
  
  task = taskService.createTaskQuery().includeProcessVariables().taskAssignee("kermit").singleResult();
  assertEquals(2, task.getProcessVariables().size());
  assertEquals(0, task.getTaskLocalVariables().size());
  assertTrue((Boolean) task.getProcessVariables().get("processVar"));
  assertEquals("This is a binary process variable", new String((byte[]) task.getProcessVariables().get("binaryVariable")));
  
  taskService.setVariable(task.getId(), "anotherProcessVar", 123);
  taskService.setVariableLocal(task.getId(), "localVar", "test");
  
  task = taskService.createTaskQuery().includeTaskLocalVariables().taskAssignee("kermit").singleResult();
  assertEquals(0, task.getProcessVariables().size());
  assertEquals(1, task.getTaskLocalVariables().size());
  assertEquals("test", task.getTaskLocalVariables().get("localVar"));
  
  task =  taskService.createTaskQuery().includeProcessVariables().taskAssignee("kermit").singleResult();
  assertEquals(3, task.getProcessVariables().size());
  assertEquals(0, task.getTaskLocalVariables().size());
  assertEquals(true, task.getProcessVariables().get("processVar"));
  assertEquals(123, task.getProcessVariables().get("anotherProcessVar"));
  assertEquals("This is a binary process variable", new String((byte[]) task.getProcessVariables().get("binaryVariable")));
  
  tasks = taskService.createTaskQuery().includeTaskLocalVariables().taskCandidateUser("kermit").list();
  assertEquals(2, tasks.size());
  assertEquals(2, tasks.get(0).getTaskLocalVariables().size());
  assertEquals("test", tasks.get(0).getTaskLocalVariables().get("test"));
  assertEquals(0, tasks.get(0).getProcessVariables().size());
  
  tasks = taskService.createTaskQuery().includeProcessVariables().taskCandidateUser("kermit").list();
  assertEquals(2, tasks.size());
  assertEquals(0, tasks.get(0).getProcessVariables().size());
  assertEquals(0, tasks.get(0).getTaskLocalVariables().size());
  
  task = taskService.createTaskQuery().includeTaskLocalVariables().taskAssignee("kermit").taskVariableValueEquals("localVar", "test").singleResult();
  assertEquals(0, task.getProcessVariables().size());
  assertEquals(1, task.getTaskLocalVariables().size());
  assertEquals("test", task.getTaskLocalVariables().get("localVar"));
  
  task = taskService.createTaskQuery().includeProcessVariables().taskAssignee("kermit").taskVariableValueEquals("localVar", "test").singleResult();
  assertEquals(3, task.getProcessVariables().size());
  assertEquals(0, task.getTaskLocalVariables().size());
  assertEquals(true, task.getProcessVariables().get("processVar"));
  assertEquals(123, task.getProcessVariables().get("anotherProcessVar"));
  
  task = taskService.createTaskQuery().includeTaskLocalVariables().includeProcessVariables().taskAssignee("kermit").singleResult();
  assertEquals(3, task.getProcessVariables().size());
  assertEquals(1, task.getTaskLocalVariables().size());
  assertEquals("test", task.getTaskLocalVariables().get("localVar"));
  assertEquals(true, task.getProcessVariables().get("processVar"));
  assertEquals(123, task.getProcessVariables().get("anotherProcessVar"));
  assertEquals("This is a binary process variable", new String((byte[]) task.getProcessVariables().get("binaryVariable")));
}
 
Example 4
Source File: TaskAndVariablesQueryTest.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
public void testQueryWithPagingAndVariables() {
  List<Task> tasks = taskService.createTaskQuery()
      .includeProcessVariables()
      .includeTaskLocalVariables()
      .orderByTaskPriority()
      .desc()
      .listPage(0, 1);
  assertEquals(1, tasks.size());
  Task task = tasks.get(0);
  Map<String, Object> variableMap = task.getTaskLocalVariables();
  assertEquals(3, variableMap.size());
  assertEquals("someVariable", variableMap.get("testVar"));
  assertEquals(123, variableMap.get("testVar2"));
  assertEquals("This is a binary variable", new String((byte[]) variableMap.get("testVarBinary")));
  
  tasks = taskService.createTaskQuery()
      .includeProcessVariables()
      .includeTaskLocalVariables()
      .orderByTaskPriority()
      .asc()
      .listPage(1, 2);
  assertEquals(2, tasks.size());
  task = tasks.get(1);
  variableMap = task.getTaskLocalVariables();
  assertEquals(3, variableMap.size());
  assertEquals("someVariable", variableMap.get("testVar"));
  assertEquals(123, variableMap.get("testVar2"));
  assertEquals("This is a binary variable", new String((byte[]) variableMap.get("testVarBinary")));
  
  tasks = taskService.createTaskQuery()
      .includeProcessVariables()
      .includeTaskLocalVariables()
      .orderByTaskPriority()
      .asc()
      .listPage(2, 4);
  assertEquals(1, tasks.size());
  task = tasks.get(0);
  variableMap = task.getTaskLocalVariables();
  assertEquals(3, variableMap.size());
  assertEquals("someVariable", variableMap.get("testVar"));
  assertEquals(123, variableMap.get("testVar2"));
  assertEquals("This is a binary variable", new String((byte[]) variableMap.get("testVarBinary")));
  
  tasks = taskService.createTaskQuery()
      .includeProcessVariables()
      .includeTaskLocalVariables()
      .orderByTaskPriority()
      .asc()
      .listPage(4, 2);
  assertEquals(0, tasks.size());
}
 
Example 5
Source File: ActivitiResourceMapper.java    From crnk-framework with Apache License 2.0 4 votes vote down vote up
public void mapFromResource(TaskResource resource, Task task) {
	Map<String, Object> variables = task.getTaskLocalVariables();
	copyInternal(resource, null, variables, false, Optional.of(task));
}