use of org.jbpm.services.task.audit.service.objects.Person in project jbpm by kiegroup.
the class PersonTaskVariablesIndexer method index.
@Override
public List<TaskVariable> index(String name, Object variable) {
Person person = (Person) variable;
List<TaskVariable> indexed = new ArrayList<TaskVariable>();
TaskVariableImpl personNameVar = new TaskVariableImpl();
personNameVar.setName("person.name");
personNameVar.setValue(person.getName());
indexed.add(personNameVar);
TaskVariableImpl personAgeVar = new TaskVariableImpl();
personAgeVar.setName("person.age");
personAgeVar.setValue(person.getAge() + "");
indexed.add(personAgeVar);
return indexed;
}
use of org.jbpm.services.task.audit.service.objects.Person in project jbpm by kiegroup.
the class TaskAuditBaseTest method testVariableIndexInputAndOutputWithCustomIdexer.
@Test
public void testVariableIndexInputAndOutputWithCustomIdexer() {
Task task = new TaskFluent().setName("This is my task name").addPotentialGroup("Knights Templer").setAdminUser("Administrator").getTask();
Map<String, Object> inputVariables = new HashMap<String, Object>();
inputVariables.put("firstVariable", "string content");
inputVariables.put("person", new Person("john", 25));
taskService.addTask(task, inputVariables);
long taskId = task.getId();
List<TaskSummary> allGroupAuditTasks = taskService.getTasksAssignedAsPotentialOwner("salaboy", null, null, null);
assertEquals(1, allGroupAuditTasks.size());
assertTrue(allGroupAuditTasks.get(0).getStatusId().equals("Ready"));
List<TaskVariable> inputVars = taskAuditService.taskVariableQuery().taskId(taskId).intersect().type(VariableType.INPUT).build().getResultList();
assertNotNull(inputVars);
assertEquals(3, inputVars.size());
Map<String, String> vars = collectVariableNameAndValue(inputVars);
assertTrue(vars.containsKey("firstVariable"));
assertTrue(vars.containsKey("person.name"));
assertTrue(vars.containsKey("person.age"));
assertEquals("string content", vars.get("firstVariable"));
assertEquals("john", vars.get("person.name"));
assertEquals("25", vars.get("person.age"));
taskService.claim(taskId, "Darth Vader");
allGroupAuditTasks = taskService.getTasksAssignedAsPotentialOwner("salaboy", null, null, null);
assertEquals(0, allGroupAuditTasks.size());
allGroupAuditTasks = taskService.getTasksAssignedAsPotentialOwner("Darth Vader", null, null, null);
assertEquals(1, allGroupAuditTasks.size());
assertTrue(allGroupAuditTasks.get(0).getStatusId().equals("Reserved"));
taskService.start(taskId, "Darth Vader");
Task task1 = taskService.getTaskById(taskId);
assertEquals(Status.InProgress, task1.getTaskData().getStatus());
assertEquals("Darth Vader", task1.getTaskData().getActualOwner().getId());
Map<String, Object> outputVariables = new HashMap<String, Object>();
outputVariables.put("reply", "updated content");
outputVariables.put("person", new Person("mary", 28));
// Check is Complete
taskService.complete(taskId, "Darth Vader", outputVariables);
List<TaskVariable> outputVars = taskAuditService.taskVariableQuery().taskId(taskId).intersect().type(VariableType.OUTPUT).build().getResultList();
assertNotNull(outputVars);
assertEquals(3, outputVars.size());
Map<String, String> outvars = collectVariableNameAndValue(outputVars);
assertTrue(outvars.containsKey("reply"));
assertTrue(vars.containsKey("person.name"));
assertTrue(vars.containsKey("person.age"));
assertEquals("updated content", outvars.get("reply"));
assertEquals("mary", outvars.get("person.name"));
assertEquals("28", outvars.get("person.age"));
}
Aggregations