// 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);