Element workflowRoot = (Element) node;
String id = workflowRoot.getAttribute("id");
String name = workflowRoot.getAttribute("name");
Workflow workflow = new Workflow();
workflow.setName(name);
workflow.setId(id);
Element taskElem = getFirstElement("tasks", workflowRoot);
NodeList taskList = taskElem.getElementsByTagName("task");
if (taskList != null && taskList.getLength() > 0) {
List workflowTasks = new Vector(taskList.getLength());
for (int i = 0; i < taskList.getLength(); i++) {
Element taskElement = (Element) taskList.item(i);
WorkflowTask t = (WorkflowTask) tasks.get(taskElement
.getAttribute("id"));
if (t != null) {
WorkflowTask workflowTask = new WorkflowTask();
workflowTask.setTaskInstanceClassName(t
.getTaskInstanceClassName());
workflowTask.setConditions(t.getConditions());
workflowTask.setTaskId(t.getTaskId());
workflowTask.setTaskConfig(t.getTaskConfig());
workflowTask.setTaskName(t.getTaskName());
workflowTask.setOrder(i + 1);
workflowTask.setRequiredMetFields(t.getRequiredMetFields());
workflowTasks.add(workflowTask);
}
}
workflow.setTasks(workflowTasks);
}
return workflow;
}