Exemple #1
0
        protected internal virtual void InitializeIoSpecification(IOSpecification activityIoSpecification, IExecutionEntity execution, BpmnModel bpmnModel)
        {
            foreach (DataSpec dataSpec in activityIoSpecification.DataInputs)
            {
                Datas.ItemDefinition itemDefinition = itemDefinitionMap[dataSpec.ItemSubjectRef];
                execution.SetVariable(dataSpec.Id, itemDefinition.CreateInstance());
            }

            foreach (DataSpec dataSpec in activityIoSpecification.DataOutputs)
            {
                Datas.ItemDefinition itemDefinition = itemDefinitionMap[dataSpec.ItemSubjectRef];
                execution.SetVariable(dataSpec.Id, itemDefinition.CreateInstance());
            }
        }
        public override void ParseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model)
        {
            if (!(parentElement is Activity) && !(parentElement is Process))
            {
                return;
            }

            IOSpecification ioSpecification = new IOSpecification();

            BpmnXMLUtil.AddXMLLocation(ioSpecification, xtr);
            bool readyWithIOSpecification = false;

            try
            {
                while (!readyWithIOSpecification && xtr.HasNext())
                {
                    //xtr.next();

                    if (xtr.IsStartElement() && BpmnXMLConstants.ELEMENT_DATA_INPUT.Equals(xtr.LocalName, StringComparison.CurrentCultureIgnoreCase))
                    {
                        DataSpec dataSpec = new DataSpec();
                        BpmnXMLUtil.AddXMLLocation(dataSpec, xtr);
                        dataSpec.Id             = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_ID);
                        dataSpec.Name           = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_NAME);
                        dataSpec.ItemSubjectRef = ParseItemSubjectRef(xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_ITEM_SUBJECT_REF), model);
                        ioSpecification.DataInputs.Add(dataSpec);
                    }
                    else if (xtr.IsStartElement() && BpmnXMLConstants.ELEMENT_DATA_OUTPUT.Equals(xtr.LocalName, StringComparison.CurrentCultureIgnoreCase))
                    {
                        DataSpec dataSpec = new DataSpec();
                        BpmnXMLUtil.AddXMLLocation(dataSpec, xtr);
                        dataSpec.Id             = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_ID);
                        dataSpec.Name           = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_NAME);
                        dataSpec.ItemSubjectRef = ParseItemSubjectRef(xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_ITEM_SUBJECT_REF), model);
                        ioSpecification.DataOutputs.Add(dataSpec);
                    }
                    else if (xtr.IsStartElement() && BpmnXMLConstants.ELEMENT_DATA_INPUT_REFS.Equals(xtr.LocalName, StringComparison.CurrentCultureIgnoreCase))
                    {
                        string dataInputRefs = xtr.ElementText;
                        if (!string.IsNullOrWhiteSpace(dataInputRefs))
                        {
                            ioSpecification.DataInputRefs.Add(dataInputRefs.Trim());
                        }
                    }
                    else if (xtr.IsStartElement() && BpmnXMLConstants.ELEMENT_DATA_OUTPUT_REFS.Equals(xtr.LocalName, StringComparison.CurrentCultureIgnoreCase))
                    {
                        string dataOutputRefs = xtr.ElementText;
                        if (!string.IsNullOrWhiteSpace(dataOutputRefs))
                        {
                            ioSpecification.DataOutputRefs.Add(dataOutputRefs.Trim());
                        }
                    }
                    else if (xtr.EndElement && ElementName.Equals(xtr.LocalName, StringComparison.CurrentCultureIgnoreCase))
                    {
                        readyWithIOSpecification = true;
                    }

                    if (xtr.IsEmptyElement && ElementName.Equals(xtr.LocalName, StringComparison.OrdinalIgnoreCase))
                    {
                        readyWithIOSpecification = true;
                    }
                }
            }
            catch (Exception e)
            {
                log.LogWarning(e, "Error parsing ioSpecification child elements");
            }

            if (parentElement is Process)
            {
                ((Process)parentElement).IoSpecification = ioSpecification;
            }
            else
            {
                ((Activity)parentElement).IoSpecification = ioSpecification;
            }
        }