public BpmTask assignTaskFromQueue(final ProcessQueue pq, BpmTask pi, ProcessToolContext ctx) {
Collection<ProcessQueue> configs = getUserQueuesFromConfig(ctx);
final List<String> names = keyFilter("name", configs);
final String taskId = pi != null ? pi.getInternalTaskId() : null;
if (!names.contains(pq.getName())) throw new ProcessToolSecurityException("queue.no.rights", pq.getName());
TaskService ts = getProcessEngine().getTaskService();
Task task;
if (taskId == null) {
task = ts.createTaskQuery()