- workflowService.endTask(task.getId(), "transitionName");
But when we migrate simple workflow from jbpm to activiti, we got exception :(
I start to discover alfresco sources and found interesting method in activiti workflow component:
- private WorkflowTask endNormalTask(String taskId, String localTaskId, String transition)
- {
- // Retrieve task
- Task task = taskService.createTaskQuery().taskId(localTaskId).singleResult();
- if(task == null)
- {
- String msg = messageService.getMessage(ERR_END_UNEXISTING_TASK, taskId);
- throw new WorkflowException(msg);
- }
- // Signal the transition on the task
- if (transition != null &&
- ActivitiConstants.DEFAULT_TRANSITION_NAME.equals(transition)==false)
- {
- // Only 'Next' is supported as transition.
- String msg = messageService.getMessage(ERR_END_TASK_INVALID_TRANSITION, transition, taskId, ActivitiConstants.DEFAULT_TRANSITION_NAME);
- throw new WorkflowException(msg);
- }
- setOutcome(task);
- taskService.complete(localTaskId);
- // The task should have a historicTaskInstance
- HistoricTaskInstance historicTask = historyService.createHistoricTaskInstanceQuery().taskId(task.getId()).singleResult();
- return typeConverter.convert(historicTask);
- }
YOOHOO! Now, you can use only "Next" keyword to move activiti workflow and code to end task should looks like this:
- workflowService.endTask(task.getId(),ActivitiConstants.DEFAULT_TRANSITION_NAME);