return null;
}
Task task = taskList.get(0);
Execution exec = processEngine.getExecutionService().findExecutionById(task.getExecutionId());
String internalId = exec.getProcessInstance().getId();
ProcessInstance pi = getProcessData(internalId, ctx);
if (pi == null) {
loger.warning("Process instance not found for instance id: " + internalId);
return null;
}
Calendar snapshotDate = Calendar.getInstance();
processEngine.getTaskService().assignTask(task.getId(), user.getLogin());
task = processEngine.getTaskService().getTask(task.getId());
if (!user.getLogin().equals(task.getAssignee())) {
loger.warning("Task: + " + bpmTask.getExecutionId() + " not assigned to requesting user: " + user.getLogin());
return null;
}
ProcessInstanceLog log = new ProcessInstanceLog();
log.setLogType(ProcessInstanceLog.LOG_TYPE_CLAIM_PROCESS);
ctx.getProcessInstanceDAO().saveProcessInstance(pi);
bpmTask = collectTask(task, pi, ctx);
log.setState(ctx.getProcessDefinitionDAO().getProcessStateConfiguration(bpmTask));
log.setEntryDate(snapshotDate);
log.setEventI18NKey("process.log.process-assigned");
log.setLogValue(pq.getName());
log.setUser(findOrCreateUser(user, ctx));
log.setAdditionalInfo(pq.getDescription());
log.setExecutionId(task.getExecutionId());
log.setOwnProcessInstance(pi);
pi.getRootProcessInstance().addProcessLog(log);
if (!ProcessStatus.RUNNING.equals(pi.getStatus())) {
pi.setStatus(ProcessStatus.RUNNING);
}
/* Inform queue manager about task assigne */
ctx.getUserProcessQueueManager().onTaskAssigne(bpmTask);