String description = task.getDescription();
workItem.setParameter("signalling", task.isSignalling());
workItem.setParameter("blocking", task.isBlocking());
if ((description != null) && (description.indexOf("#{") != -1)) {
Object result = JbpmExpressionEvaluator.evaluate(
description, nodeInstance.new JpdlExecutionContext());
if (result != null) {
description = result.toString();
}
}
workItem.setParameter("Description", description);
initializeVariables(workItem, task, nodeInstance);
if (task.getDueDate() != null) {
BusinessCalendar businessCalendar = new BusinessCalendar();
workItem.setParameter("dueDate",
businessCalendar.add(new Date(), new Duration(task.getDueDate())));
}
if (task.getSwimlane() != null) {
String swimlaneName = task.getSwimlane().getName();
SwimlaneContextInstance swimlaneContextInstance = (SwimlaneContextInstance)
nodeInstance.resolveContextInstance(SwimlaneContext.SWIMLANE_SCOPE, swimlaneName);
String actorId = swimlaneContextInstance.getActorId(swimlaneName);
if (actorId == null) {
actorId = assignTask(task, nodeInstance);
}
workItem.setParameter("ActorId", actorId);
}
Event event = task.getEvent(Event.EVENTTYPE_TASK_CREATE);
if (event != null) {
// TODO this doesn't take event handlers of task itself
// into account
JpdlExecutionContext context = nodeInstance.new JpdlExecutionContext();
context.setTask(task);
nodeInstance.executeActions(event.getActions(), context);
}
return workItem;
}