org.jbpm.graph.def.ProcessDefinition.parseXmlResource(name);
return loadJpdlProcess(processDefinition);
}
public JpdlProcess loadJpdlProcess(org.jbpm.graph.def.ProcessDefinition processDefinition) {
JpdlProcess process = new JpdlProcess();
process.setId(processDefinition.getName());
process.setName(processDefinition.getName());
process.setPackageName("org.drools");
SwimlaneContext swimlaneContext = (SwimlaneContext) process.getDefaultContext(SwimlaneContext.SWIMLANE_SCOPE);
process.setDefaultContext(swimlaneContext);
org.jbpm.graph.def.Node startState = processDefinition.getStartState();
String startStateName = startState == null ? null : startState.getName();
List<org.jbpm.graph.def.Node> nodes = processDefinition.getNodes();
Map<org.jbpm.graph.def.Node, Node> mapping = new HashMap<org.jbpm.graph.def.Node, Node>();
for (org.jbpm.graph.def.Node jPDLnode : nodes) {
JpdlNode node = classifyNode(processDefinition, jPDLnode, swimlaneContext);
//@TODO: see how to include this following code into the classifyNode method
if (node == null) {
throw new IllegalArgumentException(
"Unknown node type: " + jPDLnode.getClass().getName() + " " + jPDLnode);
}
setDefaultNodeProperties(jPDLnode, (JpdlNode) node);
node.setId(++nodeId);
mapping.put(jPDLnode, node);
process.addNode(node);
if (startStateName != null && startStateName.equals(node.getName())) {
process.setStartState(node);
}
}
generateConnections(mapping);