пятница, 29 апреля 2011 г.

Process workflow with alfresco and actitviti

Alfresco release new version of their ECM - 3.4.e. Major feature of this release is integration with activiti BPM platform. That's a good news, because JBPM 3 is obsolete. Of course, I try to use it and have some problems ;) In our projects we use WorkflowService to control business processes. To move workflow from one task to another we have to end current task and specify the transition name(more details you can find here:
    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);

Most popular

Authors