public virtual void ConvertToBpmnModel(XMLStreamReader xtr, BpmnModel model, Process activeProcess, IList <SubProcess> activeSubProcessList) { string elementId = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_ID); string elementName = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_NAME); bool async = ParseAsync(xtr); bool notExclusive = ParseNotExclusive(xtr); string defaultFlow = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_DEFAULT); bool isForCompensation = ParseForCompensation(xtr); BaseElement parsedElement = ConvertXMLToElement(xtr, model); if (parsedElement is Artifact currentArtifact) { currentArtifact.Id = elementId; if (activeSubProcessList.Count > 0) { activeSubProcessList[activeSubProcessList.Count - 1].AddArtifact(currentArtifact); } else { activeProcess.AddArtifact(currentArtifact); } } if (parsedElement is FlowElement currentFlowElement) { currentFlowElement.Id = elementId; currentFlowElement.Name = elementName; if (currentFlowElement is FlowNode flowNode) { flowNode.Asynchronous = async; flowNode.NotExclusive = notExclusive; if (currentFlowElement is Activity activity) { activity.ForCompensation = isForCompensation; if (!string.IsNullOrWhiteSpace(defaultFlow)) { activity.DefaultFlow = defaultFlow; } } if (currentFlowElement is Gateway gateway) { if (!string.IsNullOrWhiteSpace(defaultFlow)) { gateway.DefaultFlow = defaultFlow; } } } if (currentFlowElement is DataObject) { if (activeSubProcessList.Count > 0) { SubProcess subProcess = activeSubProcessList[activeSubProcessList.Count - 1]; subProcess.DataObjects.Add((ValuedDataObject)parsedElement); } else { activeProcess.DataObjects.Add((ValuedDataObject)parsedElement); } } if (activeSubProcessList.Count > 0) { SubProcess subProcess = activeSubProcessList[activeSubProcessList.Count - 1]; subProcess.AddFlowElement(currentFlowElement); } else { activeProcess.AddFlowElement(currentFlowElement); } } }
public virtual void Parse(XMLStreamReader xtr, IList <SubProcess> activeSubProcessList, Process activeProcess) { SubProcess subProcess; if (BpmnXMLConstants.ELEMENT_TRANSACTION.Equals(xtr.LocalName, StringComparison.CurrentCultureIgnoreCase)) { subProcess = new Transaction(); } else if (BpmnXMLConstants.ELEMENT_ADHOC_SUBPROCESS.Equals(xtr.LocalName, StringComparison.CurrentCultureIgnoreCase)) { AdhocSubProcess adhocSubProcess = new AdhocSubProcess(); string orderingAttributeValue = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_ORDERING); if (!string.IsNullOrWhiteSpace(orderingAttributeValue)) { adhocSubProcess.Ordering = orderingAttributeValue; } if (BpmnXMLConstants.ATTRIBUTE_VALUE_FALSE.Equals(xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_CANCEL_REMAINING_INSTANCES), StringComparison.CurrentCultureIgnoreCase)) { adhocSubProcess.CancelRemainingInstances = false; } subProcess = adhocSubProcess; } else if (BpmnXMLConstants.ATTRIBUTE_VALUE_TRUE.Equals(xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_TRIGGERED_BY), StringComparison.CurrentCultureIgnoreCase)) { subProcess = new EventSubProcess(); } else { subProcess = new SubProcess(); } BpmnXMLUtil.AddXMLLocation(subProcess, xtr); activeSubProcessList.Add(subProcess); subProcess.Id = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_ID); subProcess.Name = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_NAME); bool async = false; string asyncString = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_ACTIVITY_ASYNCHRONOUS); if (BpmnXMLConstants.ATTRIBUTE_VALUE_TRUE.Equals(asyncString, StringComparison.CurrentCultureIgnoreCase)) { async = true; } bool notExclusive = false; string exclusiveString = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_ACTIVITY_EXCLUSIVE); if (BpmnXMLConstants.ATTRIBUTE_VALUE_FALSE.Equals(exclusiveString, StringComparison.CurrentCultureIgnoreCase)) { notExclusive = true; } bool forCompensation = false; string compensationString = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_ACTIVITY_ISFORCOMPENSATION); if (BpmnXMLConstants.ATTRIBUTE_VALUE_TRUE.Equals(compensationString, StringComparison.CurrentCultureIgnoreCase)) { forCompensation = true; } subProcess.Asynchronous = async; subProcess.NotExclusive = notExclusive; subProcess.ForCompensation = forCompensation; if (!string.IsNullOrWhiteSpace(xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_DEFAULT))) { subProcess.DefaultFlow = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_DEFAULT); } if (activeSubProcessList.Count > 1) { SubProcess parentSubProcess = activeSubProcessList[activeSubProcessList.Count - 2]; parentSubProcess.AddFlowElement(subProcess); } else { activeProcess.AddFlowElement(subProcess); } }