use of org.activiti.bpmn.model.IOSpecification in project Activiti by Activiti.
the class IOSpecificationParser method parseChildElement.
public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception {
if (parentElement instanceof Activity == false && parentElement instanceof Process == false)
return;
IOSpecification ioSpecification = new IOSpecification();
BpmnXMLUtil.addXMLLocation(ioSpecification, xtr);
boolean readyWithIOSpecification = false;
try {
while (readyWithIOSpecification == false && xtr.hasNext()) {
xtr.next();
if (xtr.isStartElement() && ELEMENT_DATA_INPUT.equalsIgnoreCase(xtr.getLocalName())) {
DataSpec dataSpec = new DataSpec();
BpmnXMLUtil.addXMLLocation(dataSpec, xtr);
dataSpec.setId(xtr.getAttributeValue(null, ATTRIBUTE_ID));
dataSpec.setName(xtr.getAttributeValue(null, ATTRIBUTE_NAME));
dataSpec.setItemSubjectRef(parseItemSubjectRef(xtr.getAttributeValue(null, ATTRIBUTE_ITEM_SUBJECT_REF), model));
ioSpecification.getDataInputs().add(dataSpec);
} else if (xtr.isStartElement() && ELEMENT_DATA_OUTPUT.equalsIgnoreCase(xtr.getLocalName())) {
DataSpec dataSpec = new DataSpec();
BpmnXMLUtil.addXMLLocation(dataSpec, xtr);
dataSpec.setId(xtr.getAttributeValue(null, ATTRIBUTE_ID));
dataSpec.setName(xtr.getAttributeValue(null, ATTRIBUTE_NAME));
dataSpec.setItemSubjectRef(parseItemSubjectRef(xtr.getAttributeValue(null, ATTRIBUTE_ITEM_SUBJECT_REF), model));
ioSpecification.getDataOutputs().add(dataSpec);
} else if (xtr.isStartElement() && ELEMENT_DATA_INPUT_REFS.equalsIgnoreCase(xtr.getLocalName())) {
String dataInputRefs = xtr.getElementText();
if (StringUtils.isNotEmpty(dataInputRefs)) {
ioSpecification.getDataInputRefs().add(dataInputRefs.trim());
}
} else if (xtr.isStartElement() && ELEMENT_DATA_OUTPUT_REFS.equalsIgnoreCase(xtr.getLocalName())) {
String dataOutputRefs = xtr.getElementText();
if (StringUtils.isNotEmpty(dataOutputRefs)) {
ioSpecification.getDataOutputRefs().add(dataOutputRefs.trim());
}
} else if (xtr.isEndElement() && getElementName().equalsIgnoreCase(xtr.getLocalName())) {
readyWithIOSpecification = true;
}
}
} catch (Exception e) {
LOGGER.warn("Error parsing ioSpecification child elements", e);
}
if (parentElement instanceof Process) {
((Process) parentElement).setIoSpecification(ioSpecification);
} else {
((Activity) parentElement).setIoSpecification(ioSpecification);
}
}
Aggregations