}
}
public Task readTask(Element taskElement, TaskMgmtDefinition taskMgmtDefinition, TaskNode taskNode)
{
Task task = new Task();
task.setProcessDefinition(processDefinition);
// get the task name
String name = taskElement.attributeValue("name");
if (name != null)
{
task.setName(name);
taskMgmtDefinition.addTask(task);
}
else if (taskNode != null)
{
task.setName(taskNode.getName());
taskMgmtDefinition.addTask(task);
}
// get the task description
String description = taskElement.elementTextTrim("description");
if (description != null)
{
task.setDescription(description);
}
else
{
task.setDescription(taskElement.attributeValue("description"));
}
// get the condition
String condition = taskElement.elementTextTrim("condition");
if (condition != null)
{
task.setCondition(condition);
}
else
{
task.setCondition(taskElement.attributeValue("condition"));
}
// parse common subelements
readTaskTimers(taskElement, task);
readEvents(taskElement, task);
readExceptionHandlers(taskElement, task);
// duedate and priority
String duedateText = taskElement.attributeValue("duedate");
if (duedateText == null)
{
duedateText = taskElement.attributeValue("dueDate");
}
task.setDueDate(duedateText);
String priorityText = taskElement.attributeValue("priority");
if (priorityText != null)
{
task.setPriority(Task.parsePriority(priorityText));
}
// if this task is in the context of a taskNode, associate them
if (taskNode != null)
{
taskNode.addTask(task);
}
// blocking
String blockingText = taskElement.attributeValue("blocking");
if (blockingText != null)
{
if (("true".equalsIgnoreCase(blockingText)) || ("yes".equalsIgnoreCase(blockingText)) || ("on".equalsIgnoreCase(blockingText)))
{
task.setBlocking(true);
}
}
// signalling
String signallingText = taskElement.attributeValue("signalling");
if (signallingText != null)
{
if (("false".equalsIgnoreCase(signallingText)) || ("no".equalsIgnoreCase(signallingText)) || ("off".equalsIgnoreCase(signallingText)))
{
task.setSignalling(false);
}
}
// assignment
String swimlaneName = taskElement.attributeValue("swimlane");
Element assignmentElement = taskElement.element("assignment");
// if there is a swimlane attribute specified
if (swimlaneName != null)
{
Swimlane swimlane = taskMgmtDefinition.getSwimlane(swimlaneName);
if (swimlane == null)
{
addWarning("task references unknown swimlane '" + swimlaneName + "':" + taskElement.asXML());
}
else
{
task.setSwimlane(swimlane);
}
// else if there is a direct assignment specified
}
else if (assignmentElement != null)
{
if ((assignmentElement.attribute("actor-id") != null) || (assignmentElement.attribute("pooled-actors") != null))
{
task.setActorIdExpression(assignmentElement.attributeValue("actor-id"));
task.setPooledActorsExpression(assignmentElement.attributeValue("pooled-actors"));
}
else
{
Delegation assignmentDelegation = readAssignmentDelegation(assignmentElement);
task.setAssignmentDelegation(assignmentDelegation);
}
// if no assignment or swimlane is specified
}
else
{
// the user has to manage assignment manually, so we better inform him/her.
log.info("process xml information: no swimlane or assignment specified for task '" + taskElement.asXML() + "'");
}
// notify
String notificationsText = taskElement.attributeValue("notify");
if (notificationsText != null
&& ("true".equalsIgnoreCase(notificationsText) || "on".equalsIgnoreCase(notificationsText) || "yes".equalsIgnoreCase(notificationsText)))
{
String notificationEvent = Event.EVENTTYPE_TASK_ASSIGN;
Event event = task.getEvent(notificationEvent);
if (event == null)
{
event = new Event(notificationEvent);
task.addEvent(event);
}
Delegation delegation = createMailDelegation(notificationEvent, null, null, null, null);
Action action = new Action(delegation);
action.setProcessDefinition(processDefinition);
action.setName(task.getName());
event.addAction(action);
}
// task controller
Element taskControllerElement = taskElement.element("controller");
if (taskControllerElement != null)
{
task.setTaskController(readTaskController(taskControllerElement));
}
return task;
}