public BpmnModel convertToBpmnModel(XMLStreamReader xtr) {
BpmnModel model = new BpmnModel();
try {
boolean processExtensionAvailable = false;
Process activeProcess = null;
List<SubProcess> activeSubProcessList = new ArrayList<SubProcess>();
while (xtr.hasNext()) {
try {
xtr.next();
} catch(Exception e) {
LOGGER.log(Level.SEVERE, "Error reading XML document", e);
return model;
}
if (xtr.isEndElement() && ELEMENT_SUBPROCESS.equalsIgnoreCase(xtr.getLocalName())) {
activeSubProcessList.remove(activeSubProcessList.size() - 1);
}
if (xtr.isStartElement() == false)
continue;
if ("definitions".equalsIgnoreCase(xtr.getLocalName())) {
model.setTargetNamespace(xtr.getAttributeValue(null, TARGET_NAMESPACE_ATTRIBUTE));
} else if (ELEMENT_SIGNAL.equalsIgnoreCase(xtr.getLocalName())) {
if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_ID))) {
String signalId = xtr.getAttributeValue(null, ATTRIBUTE_ID);
String signalName = xtr.getAttributeValue(null, ATTRIBUTE_NAME);
model.addSignal(signalId, signalName);
}
} else if (ELEMENT_MESSAGE.equalsIgnoreCase(xtr.getLocalName())) {
if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_ID))) {
String messageId = xtr.getAttributeValue(null, ATTRIBUTE_ID);
String messageName = xtr.getAttributeValue(null, ATTRIBUTE_NAME);
model.addMessage(messageId, messageName);
}
} else if (ELEMENT_PARTICIPANT.equalsIgnoreCase(xtr.getLocalName())) {
if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_ID))) {
Pool pool = new Pool();
pool.setId(xtr.getAttributeValue(null, ATTRIBUTE_ID));
pool.setName(xtr.getAttributeValue(null, ATTRIBUTE_NAME));
pool.setProcessRef(xtr.getAttributeValue(null, ATTRIBUTE_PROCESS_REF));
model.getPools().add(pool);
}
} else if (ELEMENT_PROCESS.equalsIgnoreCase(xtr.getLocalName())) {
if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_ID))) {
String processId = xtr.getAttributeValue(null, ATTRIBUTE_ID);
processExtensionAvailable = true;
Process process = new Process();
process.setId(processId);
process.setName(xtr.getAttributeValue(null, ATTRIBUTE_NAME));
model.getProcesses().add(process);
activeProcess = process;
}
} else if ("lane".equalsIgnoreCase(xtr.getLocalName())) {