use of org.activiti.engine.task.Task in project Activiti by Activiti.
the class ReplayUserTaskCompleteEventHandler method handle.
@Override
public void handle(SimulationEvent event) {
String taskDefinitionKey = (String) event.getProperty(EventLogUserTaskCompleteTransformer.TASK_DEFINITION_KEY);
String processInstanceId = (String) event.getProperty(EventLogUserTaskCompleteTransformer.PROCESS_INSTANCE_ID);
String simulationRunId = SimulationRunContext.getSimulationRunId();
ProcessInstance processInstance = SimulationRunContext.getRuntimeService().createProcessInstanceQuery().variableValueEquals(StartReplayLogEventHandler.PROCESS_INSTANCE_ID, processInstanceId).variableValueEquals(StartReplayLogEventHandler.SIMULATION_RUN_ID, simulationRunId).singleResult();
Task task = SimulationRunContext.getTaskService().createTaskQuery().processInstanceId(processInstance.getId()).taskDefinitionKey(taskDefinitionKey).singleResult();
@SuppressWarnings("unchecked") Map<String, Object> variables = (Map<String, Object>) event.getProperty(EventLogUserTaskCompleteTransformer.TASK_VARIABLES);
if (variables != null) {
if (event.getProperty(EventLogUserTaskCompleteTransformer.VARIABLES_LOCAL_SCOPE) != null && ((Boolean) event.getProperty(EventLogUserTaskCompleteTransformer.VARIABLES_LOCAL_SCOPE)).booleanValue()) {
SimulationRunContext.getTaskService().complete(task.getId(), variables, true);
} else {
SimulationRunContext.getTaskService().complete(task.getId(), variables);
}
log.debug("completed {}, {}, {}", task, task.getName(), variables);
} else {
SimulationRunContext.getTaskService().complete(task.getId());
log.debug("completed {}, {}", task, task.getName());
}
}
use of org.activiti.engine.task.Task in project Activiti by Activiti.
the class CdiTaskServiceTest method testClaimTask.
@Test
public void testClaimTask() {
Task newTask = taskService.newTask();
taskService.saveTask(newTask);
taskService.claim(newTask.getId(), "kermit");
taskService.deleteTask(newTask.getId(), true);
}
use of org.activiti.engine.task.Task in project Activiti by Activiti.
the class UserTaskCompleteTransformer method apply.
@Override
public SimulationEvent apply(ActivitiEvent event) {
if (ActivitiEventType.TASK_COMPLETED.equals(event.getType())) {
Task task = (Task) ((ActivitiEntityEvent) event).getEntity();
Map<String, Object> properties = new HashMap<String, Object>();
properties.put("taskId", task.getId());
properties.put(TASK_DEFINITION_KEY, task.getTaskDefinitionKey());
properties.put(PROCESS_INSTANCE_ID, task.getProcessInstanceId());
properties.put(TASK_VARIABLES, task.getProcessVariables());
return new SimulationEvent.Builder(this.simulationEventType).simulationTime(Context.getProcessEngineConfiguration().getClock().getCurrentTime().getTime()).properties(properties).build();
}
return null;
}
use of org.activiti.engine.task.Task in project Activiti by Activiti.
the class BusinessProcessBeanTest method test.
/* General test asserting that the business process bean is functional */
@Test
@Deployment
public void test() throws Exception {
BusinessProcess businessProcess = getBeanInstance(BusinessProcess.class);
// start the process
businessProcess.startProcessByKey("businessProcessBeanTest").getId();
// ensure that the process is started:
assertNotNull(processEngine.getRuntimeService().createProcessInstanceQuery().singleResult());
// ensure that there is a single task waiting
Task task = processEngine.getTaskService().createTaskQuery().singleResult();
assertNotNull(task);
String value = "value";
businessProcess.setVariable("key", value);
assertEquals(value, businessProcess.getVariable("key"));
// complete the task
assertEquals(task.getId(), businessProcess.startTask(task.getId()).getId());
businessProcess.completeTask();
// assert the task is completed
assertNull(processEngine.getTaskService().createTaskQuery().singleResult());
// assert that the process is ended:
assertNull(processEngine.getRuntimeService().createProcessInstanceQuery().singleResult());
}
use of org.activiti.engine.task.Task in project Activiti by Activiti.
the class MultiInstanceTaskCompleteEventTest method testReceiveAll.
@Test
@Deployment(resources = { "org/activiti/cdi/test/impl/event/MultiInstanceTaskCompleteEventTest.process1.bpmn20.xml.bpmn" })
public void testReceiveAll() {
TestEventListener listenerBean = getBeanInstance(TestEventListener.class);
listenerBean.reset();
assertEquals(0, listenerBean.getCreateTask1());
assertEquals(0, listenerBean.getAssignTask1());
assertEquals(0, listenerBean.getCompleteTask1());
// start the process
runtimeService.startProcessInstanceByKey("process1");
Task task = taskService.createTaskQuery().singleResult();
taskService.claim(task.getId(), "auser");
taskService.complete(task.getId());
task = taskService.createTaskQuery().singleResult();
taskService.complete(task.getId());
// assert
assertEquals(2, listenerBean.getCreateTask1());
assertEquals(1, listenerBean.getAssignTask1());
assertEquals(2, listenerBean.getCompleteTask1());
}
Aggregations