예제 #1
0
        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);
                }
            }
        }