execute((ExecutionImpl)execution);
}
public void execute(ExecutionImpl execution) {
DbSession dbSession = Environment.getFromCurrent(DbSession.class);
TaskImpl task = (TaskImpl) dbSession.createTask();
task.setTaskDefinition(taskDefinition);
task.setExecution(execution);
task.setProcessInstance(execution.getProcessInstance());
task.setSignalling(true);
// initialize the name
if (taskDefinition.getName()!=null) {
task.setName(taskDefinition.getName());
} else {
task.setName(execution.getActivityName());
}
task.setDescription(taskDefinition.getDescription());
task.setPriority(taskDefinition.getPriority());
task.setFormResourceName(taskDefinition.getFormResourceName());
// save task so that TaskDbSession.findTaskByExecution works for assign event listeners
dbSession.save(task);
SwimlaneDefinitionImpl swimlaneDefinition = taskDefinition.getSwimlaneDefinition();
if (swimlaneDefinition!=null) {
SwimlaneImpl swimlane = execution.getInitializedSwimlane(swimlaneDefinition);
task.setSwimlane(swimlane);
// copy the swimlane assignments to the task
task.setAssignee(swimlane.getAssignee());
for (ParticipationImpl participant: swimlane.getParticipations()) {
task.addParticipation(participant.getUserId(), participant.getGroupId(), participant.getType());
}
}
execution.initializeAssignments(taskDefinition, task);