public virtual void Parse(XMLStreamReader xtr, BpmnModel model)
        {
            string resourceId   = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_ID);
            string resourceName = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_NAME);

            Resource resource;

            if (model.ContainsResourceId(resourceId))
            {
                resource      = model.GetResource(resourceId);
                resource.Name = resourceName;
                foreach (Process process in model.Processes)
                {
                    foreach (FlowElement fe in process.FlowElements)
                    {
                        if (fe is UserTask && ((UserTask)fe).CandidateGroups.Contains(resourceId))
                        {
                            ((UserTask)fe).CandidateGroups.Remove(resourceId);
                            ((UserTask)fe).CandidateGroups.Add(resourceName);
                        }
                    }
                }
            }
            else
            {
                resource = new Resource(resourceId, resourceName);
                model.AddResource(resource);
            }

            BpmnXMLUtil.AddXMLLocation(resource, xtr);
        }
Exemple #2
0
        public virtual void Parse(XMLStreamReader xtr, BpmnModel model)
        {
            string id = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_ID);

            if (!string.IsNullOrWhiteSpace(id))
            {
                DataStore dataStore = new DataStore();
                dataStore.Id = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_ID);

                string name = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_NAME);
                if (!string.IsNullOrWhiteSpace(name))
                {
                    dataStore.Name = name;
                }

                string itemSubjectRef = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_ITEM_SUBJECT_REF);
                if (!string.IsNullOrWhiteSpace(itemSubjectRef))
                {
                    dataStore.ItemSubjectRef = itemSubjectRef;
                }

                BpmnXMLUtil.AddXMLLocation(dataStore, xtr);

                model.AddDataStore(dataStore.Id, dataStore);

                BpmnXMLUtil.ParseChildElements(BpmnXMLConstants.ELEMENT_DATA_STORE, dataStore, xtr, model);
            }
        }
Exemple #3
0
        public override void ParseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model)
        {
            if (!(parentElement is Activity))
            {
                return;
            }

            string errorCode       = xtr.GetAttributeValue(BpmnXMLConstants.MAP_EXCEPTION_ERRORCODE);
            string andChildren     = xtr.GetAttributeValue(BpmnXMLConstants.MAP_EXCEPTION_ANDCHILDREN);
            string exceptionClass  = xtr.ElementText;
            bool   hasChildrenBool = false;

            if (string.IsNullOrWhiteSpace(andChildren) || andChildren.ToLower().Equals("false"))
            {
                hasChildrenBool = false;
            }
            else if (andChildren.ToLower().Equals("true"))
            {
                hasChildrenBool = true;
            }
            else
            {
                throw new XMLException("'" + andChildren + "' is not valid boolean in mapException with errorCode=" + errorCode + " and class=" + exceptionClass);
            }

            if (string.IsNullOrWhiteSpace(errorCode) || string.IsNullOrWhiteSpace(errorCode.Trim()))
            {
                throw new XMLException("No errorCode defined mapException with errorCode=" + errorCode + " and class=" + exceptionClass);
            }

            ((Activity)parentElement).MapExceptions.Add(new MapExceptionEntry(errorCode, exceptionClass, hasChildrenBool));
        }
Exemple #4
0
        public virtual void Parse(XMLStreamReader xtr, BpmnModel model)
        {
            if (!string.IsNullOrWhiteSpace(xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_ID)))
            {
                string itemDefinitionId = model.TargetNamespace + ":" + xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_ID);
                string structureRef     = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_STRUCTURE_REF);
                if (!string.IsNullOrWhiteSpace(structureRef))
                {
                    ItemDefinition item = new ItemDefinition();
                    item.Id = itemDefinitionId;
                    BpmnXMLUtil.AddXMLLocation(item, xtr);

                    int indexOfP = structureRef.IndexOf(':');
                    if (indexOfP != -1)
                    {
                        string prefix            = structureRef.Substring(0, indexOfP);
                        string resolvedNamespace = model.GetNamespace(prefix);
                        structureRef = resolvedNamespace + ":" + structureRef.Substring(indexOfP + 1);
                    }
                    else
                    {
                        structureRef = model.TargetNamespace + ":" + structureRef;
                    }

                    item.StructureRef = structureRef;
                    item.ItemKind     = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_ITEM_KIND);
                    BpmnXMLUtil.ParseChildElements(BpmnXMLConstants.ELEMENT_ITEM_DEFINITION, item, xtr, model);
                    model.AddItemDefinition(itemDefinitionId, item);
                }
            }
        }
Exemple #5
0
        public virtual void Parse(XMLStreamReader xtr, BpmnModel model)
        {
            Import importObject = new Import();

            BpmnXMLUtil.AddXMLLocation(importObject, xtr);
            importObject.ImportType = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_IMPORT_TYPE);
            importObject.Namespace  = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_NAMESPACE);
            importObject.Location   = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_LOCATION);
            model.Imports.Add(importObject);
        }
Exemple #6
0
        public virtual void Parse(XMLStreamReader xtr, Process activeProcess, BpmnModel model)
        {
            Lane lane = new Lane();

            BpmnXMLUtil.AddXMLLocation(lane, xtr);
            lane.Id            = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_ID);
            lane.Name          = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_NAME);
            lane.ParentProcess = activeProcess;
            activeProcess.Lanes.Add(lane);
            BpmnXMLUtil.ParseChildElements(BpmnXMLConstants.ELEMENT_LANE, lane, xtr, model);
        }
Exemple #7
0
 public virtual void Parse(XMLStreamReader xtr, BpmnModel model)
 {
     if (!string.IsNullOrWhiteSpace(xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_ID)))
     {
         string  messageId   = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_ID);
         string  messageName = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_NAME);
         string  itemRef     = ParseItemRef(xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_ITEM_REF), model);
         Message message     = new Message(messageId, messageName, itemRef);
         BpmnXMLUtil.AddXMLLocation(message, xtr);
         BpmnXMLUtil.ParseChildElements(BpmnXMLConstants.ELEMENT_MESSAGE, message, xtr, model);
         model.AddMessage(message);
     }
 }
 public virtual void Parse(XMLStreamReader xtr, BpmnModel model)
 {
     if (!string.IsNullOrWhiteSpace(xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_ID)))
     {
         Pool pool = new Pool
         {
             Id         = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_ID),
             Name       = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_NAME),
             ProcessRef = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_PROCESS_REF)
         };
         BpmnXMLUtil.ParseChildElements(BpmnXMLConstants.ELEMENT_PARTICIPANT, pool, xtr, model);
         model.Pools.Add(pool);
     }
 }
Exemple #9
0
        public override void ParseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model)
        {
            if (!(parentElement is TimerEventDefinition))
            {
                return;
            }

            TimerEventDefinition eventDefinition = (TimerEventDefinition)parentElement;

            if (!string.IsNullOrWhiteSpace(xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_END_DATE)))
            {
                eventDefinition.EndDate = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_END_DATE);
            }
            eventDefinition.TimeCycle = xtr.ElementText;
        }
Exemple #10
0
        public virtual void Parse(XMLStreamReader xtr, BpmnModel model)
        {
            model.TargetNamespace = xtr.GetAttributeValue(BpmnXMLConstants.TARGET_NAMESPACE_ATTRIBUTE);
            for (int i = 0; i < xtr.NamespaceCount; i++)
            {
                string prefix = xtr.GetNamespacePrefix(i);
                if (!string.IsNullOrWhiteSpace(prefix))
                {
                    model.AddNamespace(prefix, xtr.GetNamespaceURI(i));
                }
            }

            for (int i = 0; i < xtr.AttributeCount; i++)
            {
                var attr = xtr.element.Attributes().ElementAt(i);
                ExtensionAttribute extensionAttribute = new ExtensionAttribute
                {
                    Name  = attr.Name.LocalName,
                    Value = attr.Value
                };
                if (!string.IsNullOrWhiteSpace(attr.Name.NamespaceName))
                {
                    extensionAttribute.Namespace = attr.Name.NamespaceName;
                }
                if (!string.IsNullOrWhiteSpace(xtr.element.GetPrefixOfNamespace(attr.Name.Namespace)))
                {
                    extensionAttribute.NamespacePrefix = xtr.element.GetPrefixOfNamespace(attr.Name.Namespace);
                }
                if (!BpmnXMLUtil.IsBlacklisted(extensionAttribute, defaultAttributes))
                {
                    model.AddDefinitionsAttribute(extensionAttribute);
                }
            }
        }
        protected internal virtual void ParseTerminateMultiInstanceAttribute(XMLStreamReader xtr, TerminateEventDefinition eventDefinition)
        {
            string terminateMiValue = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TERMINATE_MULTI_INSTANCE);

            if (!(terminateMiValue is null) && "true".Equals(terminateMiValue))
            {
                eventDefinition.TerminateMultiInstance = true;
            }
Exemple #12
0
        public override void ParseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model)
        {
            if (!(parentElement is Event))
            {
                return;
            }

            MessageEventDefinition eventDefinition = new MessageEventDefinition();

            BpmnXMLUtil.AddXMLLocation(eventDefinition, xtr);
            eventDefinition.MessageRef        = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_MESSAGE_REF);
            eventDefinition.MessageExpression = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_MESSAGE_EXPRESSION);

            if (!string.IsNullOrWhiteSpace(eventDefinition.MessageRef))
            {
                int indexOfP = eventDefinition.MessageRef.IndexOf(':');
                if (indexOfP != -1)
                {
                    string prefix            = eventDefinition.MessageRef.Substring(0, indexOfP);
                    string resolvedNamespace = model.GetNamespace(prefix);
                    string messageRef        = eventDefinition.MessageRef.Substring(indexOfP + 1);

                    if (resolvedNamespace is null)
                    {
                        // if it's an invalid prefix will consider this is not a namespace prefix so will be used as part of the stringReference
                        messageRef = prefix + ":" + messageRef;
                    }
                    else if (!resolvedNamespace.Equals(model.TargetNamespace, StringComparison.CurrentCultureIgnoreCase))
                    {
                        // if it's a valid namespace prefix but it's not the targetNamespace then we'll use it as a valid namespace
                        // (even out editor does not support defining namespaces it is still a valid xml file)
                        messageRef = resolvedNamespace + ":" + messageRef;
                    }
                    eventDefinition.MessageRef = messageRef;
                }
                else
                {
                    eventDefinition.MessageRef = eventDefinition.MessageRef;
                }
            }

            BpmnXMLUtil.ParseChildElements(BpmnXMLConstants.ELEMENT_EVENT_MESSAGEDEFINITION, eventDefinition, xtr, model);

            ((Event)parentElement).EventDefinitions.Add(eventDefinition);
        }
Exemple #13
0
        public virtual void Parse(XMLStreamReader xtr, BpmnModel model)
        {
            string signalId   = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_ID);
            string signalName = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_NAME);

            Signal signal = new Signal(signalId, signalName);

            string scope = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_SCOPE);

            if (!(scope is null))
            {
                signal.Scope = scope;
            }

            BpmnXMLUtil.AddXMLLocation(signal, xtr);
            BpmnXMLUtil.ParseChildElements(BpmnXMLConstants.ELEMENT_SIGNAL, signal, xtr, model);
            model.AddSignal(signal);
        }
        public virtual void Parse(XMLStreamReader xtr, BpmnModel model)
        {
            string id = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_DI_BPMNELEMENT);
            IList <GraphicInfo> wayPointList = new List <GraphicInfo>();

            while (xtr.HasNext())
            {
                //xtr.next();

                if (xtr.IsStartElement() && BpmnXMLConstants.ELEMENT_DI_LABEL.Equals(xtr.LocalName, StringComparison.CurrentCultureIgnoreCase))
                {
                    while (xtr.HasNext())
                    {
                        //xtr.next();

                        if (xtr.IsStartElement() && BpmnXMLConstants.ELEMENT_DI_BOUNDS.Equals(xtr.LocalName, StringComparison.CurrentCultureIgnoreCase))
                        {
                            GraphicInfo graphicInfo = new GraphicInfo();
                            BpmnXMLUtil.AddXMLLocation(graphicInfo, xtr);
                            graphicInfo.X      = Convert.ToDouble(xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_DI_X));
                            graphicInfo.Y      = Convert.ToDouble(xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_DI_Y));
                            graphicInfo.Width  = Convert.ToDouble(xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_DI_WIDTH));
                            graphicInfo.Height = Convert.ToDouble(xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_DI_HEIGHT));
                            model.AddLabelGraphicInfo(id, graphicInfo);
                            break;
                        }
                        else if (xtr.EndElement && BpmnXMLConstants.ELEMENT_DI_LABEL.Equals(xtr.LocalName, StringComparison.CurrentCultureIgnoreCase))
                        {
                            break;
                        }

                        if (xtr.IsEmptyElement && BpmnXMLConstants.ELEMENT_DI_LABEL.Equals(xtr.LocalName, StringComparison.CurrentCultureIgnoreCase))
                        {
                            break;
                        }
                    }
                }
                else if (xtr.IsStartElement() && BpmnXMLConstants.ELEMENT_DI_WAYPOINT.Equals(xtr.LocalName, StringComparison.CurrentCultureIgnoreCase))
                {
                    GraphicInfo graphicInfo = new GraphicInfo();
                    BpmnXMLUtil.AddXMLLocation(graphicInfo, xtr);
                    graphicInfo.X = Convert.ToDouble(xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_DI_X));
                    graphicInfo.Y = Convert.ToDouble(xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_DI_Y));
                    wayPointList.Add(graphicInfo);
                }
                else if (xtr.EndElement && BpmnXMLConstants.ELEMENT_DI_EDGE.Equals(xtr.LocalName, StringComparison.CurrentCultureIgnoreCase))
                {
                    break;
                }

                if (xtr.IsEmptyElement && BpmnXMLConstants.ELEMENT_DI_EDGE.Equals(xtr.LocalName, StringComparison.CurrentCultureIgnoreCase))
                {
                    break;
                }
            }
            model.AddFlowGraphicInfoList(id, wayPointList);
        }
        public override void ParseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model)
        {
            if (!(parentElement is Event))
            {
                return;
            }

            CompensateEventDefinition eventDefinition = new CompensateEventDefinition();

            BpmnXMLUtil.AddXMLLocation(eventDefinition, xtr);
            eventDefinition.ActivityRef = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_COMPENSATE_ACTIVITYREF);
            if (!string.IsNullOrWhiteSpace(xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_COMPENSATE_WAITFORCOMPLETION)))
            {
                eventDefinition.WaitForCompletion = bool.Parse(xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_COMPENSATE_WAITFORCOMPLETION));
            }

            BpmnXMLUtil.ParseChildElements(BpmnXMLConstants.ELEMENT_EVENT_COMPENSATEDEFINITION, eventDefinition, xtr, model);

            ((Event)parentElement).EventDefinitions.Add(eventDefinition);
        }
        public override void ParseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model)
        {
            if (!(parentElement is Event))
            {
                return;
            }

            SignalEventDefinition eventDefinition = new SignalEventDefinition();

            BpmnXMLUtil.AddXMLLocation(eventDefinition, xtr);
            eventDefinition.SignalRef        = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_SIGNAL_REF);
            eventDefinition.SignalExpression = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_SIGNAL_EXPRESSION);
            if (!string.IsNullOrWhiteSpace(xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_ACTIVITY_ASYNCHRONOUS)))
            {
                eventDefinition.Async = bool.Parse(xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_ACTIVITY_ASYNCHRONOUS));
            }

            BpmnXMLUtil.ParseChildElements(BpmnXMLConstants.ELEMENT_EVENT_SIGNALDEFINITION, eventDefinition, xtr, model);

            ((Event)parentElement).EventDefinitions.Add(eventDefinition);
        }
        protected internal virtual void parseTerminateAllAttribute(XMLStreamReader xtr, TerminateEventDefinition eventDefinition)
        {
            string terminateAllValue = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TERMINATE_ALL);

            if (!string.ReferenceEquals(terminateAllValue, null) && "true".Equals(terminateAllValue))
            {
                eventDefinition.TerminateAll = true;
            }
            else
            {
                eventDefinition.TerminateAll = false;
            }
        }
        public virtual void Parse(XMLStreamReader xtr, BpmnModel model)
        {
            string id = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_ID);

            if (!string.IsNullOrWhiteSpace(id))
            {
                MessageFlow messageFlow = new MessageFlow
                {
                    Id = id
                };

                string name = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_NAME);
                if (!string.IsNullOrWhiteSpace(name))
                {
                    messageFlow.Name = name;
                }

                string sourceRef = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_FLOW_SOURCE_REF);
                if (!string.IsNullOrWhiteSpace(sourceRef))
                {
                    messageFlow.SourceRef = sourceRef;
                }

                string targetRef = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_FLOW_TARGET_REF);
                if (!string.IsNullOrWhiteSpace(targetRef))
                {
                    messageFlow.TargetRef = targetRef;
                }

                string messageRef = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_MESSAGE_REF);
                if (!string.IsNullOrWhiteSpace(messageRef))
                {
                    messageFlow.MessageRef = messageRef;
                }

                model.AddMessageFlow(messageFlow);
            }
        }
        public override void ParseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model)
        {
            if (!(parentElement is Event))
            {
                return;
            }

            ErrorEventDefinition eventDefinition = new ErrorEventDefinition();

            BpmnXMLUtil.AddXMLLocation(eventDefinition, xtr);
            eventDefinition.ErrorCode = xtr.GetAttributeValue("errorRef");

            BpmnXMLUtil.ParseChildElements(BpmnXMLConstants.ELEMENT_EVENT_ERRORDEFINITION, eventDefinition, xtr, model);

            ((Event)parentElement).EventDefinitions.Add(eventDefinition);
        }
        public override void ParseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model)
        {
            if (!(parentElement is Event))
            {
                return;
            }
            TimerEventDefinition eventDefinition = new TimerEventDefinition();
            string calendarName = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_CALENDAR_NAME);

            if (!string.IsNullOrWhiteSpace(calendarName))
            {
                eventDefinition.CalendarName = calendarName;
            }
            BpmnXMLUtil.AddXMLLocation(eventDefinition, xtr);
            BpmnXMLUtil.ParseChildElements(BpmnXMLConstants.ELEMENT_EVENT_TIMERDEFINITION, eventDefinition, xtr, model);

            ((Event)parentElement).EventDefinitions.Add(eventDefinition);
        }
Exemple #21
0
        public virtual Process Parse(XMLStreamReader xtr, BpmnModel model)
        {
            Process process = null;

            if (!string.IsNullOrWhiteSpace(xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_ID)))
            {
                string processId = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_ID);
                process = new Process
                {
                    Id = processId
                };
                BpmnXMLUtil.AddXMLLocation(process, xtr);
                process.Name = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_NAME);
                if (!string.IsNullOrWhiteSpace(xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_PROCESS_EXECUTABLE)))
                {
                    process.Executable = bool.Parse(xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_PROCESS_EXECUTABLE));
                }
                string candidateUsersString = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_PROCESS_CANDIDATE_USERS);
                if (!string.IsNullOrWhiteSpace(candidateUsersString))
                {
                    IList <string> candidateUsers = BpmnXMLUtil.ParseDelimitedList(candidateUsersString);
                    process.CandidateStarterUsers = candidateUsers;
                }
                string candidateGroupsString = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_PROCESS_CANDIDATE_GROUPS);
                if (!string.IsNullOrWhiteSpace(candidateGroupsString))
                {
                    IList <string> candidateGroups = BpmnXMLUtil.ParseDelimitedList(candidateGroupsString);
                    process.CandidateStarterGroups = candidateGroups;
                }

                BpmnXMLUtil.AddCustomAttributes(xtr, process, ProcessExport.defaultProcessAttributes);

                model.Processes.Add(process);
            }
            return(process);
        }
Exemple #22
0
        public virtual void Parse(XMLStreamReader xtr, BpmnModel model)
        {
            string      id          = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_DI_BPMNELEMENT);
            GraphicInfo graphicInfo = new GraphicInfo();

            string strIsExpanded = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_DI_IS_EXPANDED);

            if ("true".Equals(strIsExpanded, StringComparison.CurrentCultureIgnoreCase))
            {
                graphicInfo.Expanded = true;
            }

            BpmnXMLUtil.AddXMLLocation(graphicInfo, xtr);
            while (xtr.HasNext())
            {
                //xtr.next();

                if (xtr.IsStartElement() && BpmnXMLConstants.ELEMENT_DI_BOUNDS.Equals(xtr.LocalName, StringComparison.CurrentCultureIgnoreCase))
                {
                    graphicInfo.X      = Convert.ToDouble(xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_DI_X));
                    graphicInfo.Y      = Convert.ToDouble(xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_DI_Y));
                    graphicInfo.Width  = Convert.ToDouble(xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_DI_WIDTH));
                    graphicInfo.Height = Convert.ToDouble(xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_DI_HEIGHT));

                    model.AddGraphicInfo(id, graphicInfo);
                    break;
                }
                else if (xtr.EndElement && BpmnXMLConstants.ELEMENT_DI_SHAPE.Equals(xtr.LocalName, StringComparison.CurrentCultureIgnoreCase))
                {
                    break;
                }

                if (xtr.IsEmptyElement && BpmnXMLConstants.ELEMENT_DI_SHAPE.Equals(xtr.LocalName, StringComparison.CurrentCultureIgnoreCase))
                {
                    break;
                }
            }
        }
Exemple #23
0
        public override void ParseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model)
        {
            if (!Accepts(parentElement))
            {
                return;
            }

            FieldExtension extension = new FieldExtension();

            BpmnXMLUtil.AddXMLLocation(extension, xtr);
            extension.FieldName = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_FIELD_NAME);

            if (!string.IsNullOrWhiteSpace(xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_FIELD_STRING)))
            {
                extension.StringValue = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_FIELD_STRING);
            }
            else if (!string.IsNullOrWhiteSpace(xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_FIELD_EXPRESSION)))
            {
                extension.Expression = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_FIELD_EXPRESSION);
            }
            else
            {
                bool readyWithFieldExtension = false;
                try
                {
                    while (readyWithFieldExtension == false && xtr.HasNext())
                    {
                        //xtr.next();

                        if (xtr.IsStartElement() && BpmnXMLConstants.ELEMENT_FIELD_STRING.Equals(xtr.LocalName, StringComparison.CurrentCultureIgnoreCase))
                        {
                            extension.StringValue = xtr.ElementText.Trim();
                        }
                        else if (xtr.IsStartElement() && BpmnXMLConstants.ATTRIBUTE_FIELD_EXPRESSION.Equals(xtr.LocalName, StringComparison.CurrentCultureIgnoreCase))
                        {
                            extension.Expression = xtr.ElementText.Trim();
                        }
                        else if (xtr.EndElement && ElementName.Equals(xtr.LocalName, StringComparison.CurrentCultureIgnoreCase))
                        {
                            readyWithFieldExtension = true;
                        }

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

            if (parentElement is ActivitiListener)
            {
                ((ActivitiListener)parentElement).FieldExtensions.Add(extension);
            }
            else if (parentElement is ServiceTask)
            {
                ((ServiceTask)parentElement).FieldExtensions.Add(extension);
            }
            else
            {
                ((SendTask)parentElement).FieldExtensions.Add(extension);
            }
        }
Exemple #24
0
        public static void parseDataAssociation(DataAssociation dataAssociation, string elementName, XMLStreamReader xtr)
        {
            bool       readyWithDataAssociation = false;
            Assignment assignment = null;

            try
            {
                dataAssociation.Id = xtr.GetAttributeValue("id");

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

                    if (xtr.IsStartElement() && BpmnXMLConstants.ELEMENT_SOURCE_REF.Equals(xtr.LocalName))
                    {
                        string sourceRef = xtr.ElementText;
                        if (!string.IsNullOrWhiteSpace(sourceRef))
                        {
                            dataAssociation.SourceRef = sourceRef.Trim();
                        }
                    }
                    else if (xtr.IsStartElement() && BpmnXMLConstants.ELEMENT_TARGET_REF.Equals(xtr.LocalName))
                    {
                        string targetRef = xtr.ElementText;
                        if (!string.IsNullOrWhiteSpace(targetRef))
                        {
                            dataAssociation.TargetRef = targetRef.Trim();
                        }
                    }
                    else if (xtr.IsStartElement() && BpmnXMLConstants.ELEMENT_TRANSFORMATION.Equals(xtr.LocalName))
                    {
                        string transformation = xtr.ElementText;
                        if (!string.IsNullOrWhiteSpace(transformation))
                        {
                            dataAssociation.Transformation = transformation.Trim();
                        }
                    }
                    else if (xtr.IsStartElement() && BpmnXMLConstants.ELEMENT_ASSIGNMENT.Equals(xtr.LocalName))
                    {
                        assignment = new Assignment();
                        BpmnXMLUtil.AddXMLLocation(assignment, xtr);
                    }
                    else if (xtr.IsStartElement() && BpmnXMLConstants.ELEMENT_FROM.Equals(xtr.LocalName))
                    {
                        string from = xtr.ElementText;
                        if (assignment != null && !string.IsNullOrWhiteSpace(from))
                        {
                            assignment.From = from.Trim();
                        }
                    }
                    else if (xtr.IsStartElement() && BpmnXMLConstants.ELEMENT_TO.Equals(xtr.LocalName))
                    {
                        string to = xtr.ElementText;
                        if (assignment != null && !string.IsNullOrWhiteSpace(to))
                        {
                            assignment.To = to.Trim();
                        }
                    }
                    else if (xtr.EndElement && BpmnXMLConstants.ELEMENT_ASSIGNMENT.Equals(xtr.LocalName))
                    {
                        if (!string.IsNullOrWhiteSpace(assignment.From) && !string.IsNullOrWhiteSpace(assignment.To))
                        {
                            dataAssociation.Assignments.Add(assignment);
                        }
                    }
                    else if (xtr.EndElement && elementName.Equals(xtr.LocalName))
                    {
                        readyWithDataAssociation = true;
                    }

                    if (xtr.IsEmptyElement && elementName.Equals(xtr.LocalName, StringComparison.OrdinalIgnoreCase))
                    {
                        readyWithDataAssociation = true;
                    }
                }
            }
            catch (Exception e)
            {
                log.LogWarning(e, "Error parsing data association child elements");
            }
        }
Exemple #25
0
        public override void ParseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model)
        {
            if (!Accepts(parentElement))
            {
                return;
            }
            FormProperty property = new FormProperty();

            BpmnXMLUtil.AddXMLLocation(property, xtr);
            property.Id                = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_FORM_ID);
            property.Name              = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_FORM_NAME);
            property.Type              = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_FORM_TYPE);
            property.Variable          = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_FORM_VARIABLE);
            property.Expression        = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_FORM_EXPRESSION);
            property.DefaultExpression = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_FORM_DEFAULT);
            property.DatePattern       = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_FORM_DATEPATTERN);
            if (!string.IsNullOrWhiteSpace(xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_FORM_REQUIRED)))
            {
                property.Required = Convert.ToBoolean(xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_FORM_REQUIRED));
            }
            if (!string.IsNullOrWhiteSpace(xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_FORM_READABLE)))
            {
                property.Readable = Convert.ToBoolean(xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_FORM_READABLE));
            }
            if (!string.IsNullOrWhiteSpace(xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_FORM_WRITABLE)))
            {
                property.Writeable = Convert.ToBoolean(xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_FORM_WRITABLE));
            }

            bool readyWithFormProperty = false;

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

                    if (xtr.IsStartElement() && BpmnXMLConstants.ELEMENT_VALUE.Equals(xtr.LocalName, StringComparison.CurrentCultureIgnoreCase))
                    {
                        FormValue value = new FormValue();
                        BpmnXMLUtil.AddXMLLocation(value, xtr);
                        value.Id   = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_ID);
                        value.Name = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_NAME);
                        property.FormValues.Add(value);
                    }
                    else if (xtr.EndElement && ElementName.Equals(xtr.LocalName, StringComparison.CurrentCultureIgnoreCase))
                    {
                        readyWithFormProperty = true;
                    }

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

            if (parentElement is UserTask)
            {
                ((UserTask)parentElement).FormProperties.Add(property);
            }
            else
            {
                ((StartEvent)parentElement).FormProperties.Add(property);
            }
        }
        public override void ParseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model)
        {
            EventListener listener = new EventListener();

            BpmnXMLUtil.AddXMLLocation(listener, xtr);
            if (!string.IsNullOrWhiteSpace(xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_LISTENER_CLASS)))
            {
                listener.Implementation     = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_LISTENER_CLASS);
                listener.ImplementationType = ImplementationType.IMPLEMENTATION_TYPE_CLASS;
            }
            else if (!string.IsNullOrWhiteSpace(xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_LISTENER_DELEGATEEXPRESSION)))
            {
                listener.Implementation     = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_LISTENER_DELEGATEEXPRESSION);
                listener.ImplementationType = ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION;
            }
            else if (!string.IsNullOrWhiteSpace(xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_LISTENER_THROW_EVENT_TYPE)))
            {
                string eventType = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_LISTENER_THROW_EVENT_TYPE);
                if (BpmnXMLConstants.ATTRIBUTE_LISTENER_THROW_EVENT_TYPE_SIGNAL.Equals(eventType))
                {
                    listener.ImplementationType = ImplementationType.IMPLEMENTATION_TYPE_THROW_SIGNAL_EVENT;
                    listener.Implementation     = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_LISTENER_THROW_SIGNAL_EVENT_NAME);
                }
                else if (BpmnXMLConstants.ATTRIBUTE_LISTENER_THROW_EVENT_TYPE_GLOBAL_SIGNAL.Equals(eventType))
                {
                    listener.ImplementationType = ImplementationType.IMPLEMENTATION_TYPE_THROW_GLOBAL_SIGNAL_EVENT;
                    listener.Implementation     = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_LISTENER_THROW_SIGNAL_EVENT_NAME);
                }
                else if (BpmnXMLConstants.ATTRIBUTE_LISTENER_THROW_EVENT_TYPE_MESSAGE.Equals(eventType))
                {
                    listener.ImplementationType = ImplementationType.IMPLEMENTATION_TYPE_THROW_MESSAGE_EVENT;
                    listener.Implementation     = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_LISTENER_THROW_MESSAGE_EVENT_NAME);
                }
                else if (BpmnXMLConstants.ATTRIBUTE_LISTENER_THROW_EVENT_TYPE_ERROR.Equals(eventType))
                {
                    listener.ImplementationType = ImplementationType.IMPLEMENTATION_TYPE_THROW_ERROR_EVENT;
                    listener.Implementation     = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_LISTENER_THROW_ERROR_EVENT_CODE);
                }
                else
                {
                    listener.ImplementationType = ImplementationType.IMPLEMENTATION_TYPE_INVALID_THROW_EVENT;
                }
            }
            listener.Events     = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_LISTENER_EVENTS);
            listener.EntityType = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_LISTENER_ENTITY_TYPE);

            Process parentProcess = (Process)parentElement;

            parentProcess.EventListeners.Add(listener);
        }
Exemple #27
0
        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);
            }
        }
        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;
            }
        }
Exemple #29
0
        public virtual void Parse(XMLStreamReader xtr, BpmnModel model)
        {
            Interface interfaceObject = new Interface();

            BpmnXMLUtil.AddXMLLocation(interfaceObject, xtr);
            interfaceObject.Id   = model.TargetNamespace + ":" + xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_ID);
            interfaceObject.Name = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_NAME);
            interfaceObject.ImplementationRef = ParseMessageRef(xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_IMPLEMENTATION_REF), model);

            bool      readyWithInterface = false;
            Operation operation          = null;

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

                    if (xtr.IsStartElement() && BpmnXMLConstants.ELEMENT_OPERATION.Equals(xtr.LocalName))
                    {
                        operation = new Operation();
                        BpmnXMLUtil.AddXMLLocation(operation, xtr);
                        operation.Id   = model.TargetNamespace + ":" + xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_ID);
                        operation.Name = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_NAME);
                        operation.ImplementationRef = ParseMessageRef(xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_IMPLEMENTATION_REF), model);
                    }
                    else if (xtr.IsStartElement() && BpmnXMLConstants.ELEMENT_IN_MESSAGE.Equals(xtr.LocalName))
                    {
                        string inMessageRef = xtr.ElementText;
                        if (operation != null && !string.IsNullOrWhiteSpace(inMessageRef))
                        {
                            operation.InMessageRef = ParseMessageRef(inMessageRef.Trim(), model);
                        }
                    }
                    else if (xtr.IsStartElement() && BpmnXMLConstants.ELEMENT_OUT_MESSAGE.Equals(xtr.LocalName))
                    {
                        string outMessageRef = xtr.ElementText;
                        if (operation != null && !string.IsNullOrWhiteSpace(outMessageRef))
                        {
                            operation.OutMessageRef = ParseMessageRef(outMessageRef.Trim(), model);
                        }
                    }
                    else if (xtr.EndElement && BpmnXMLConstants.ELEMENT_OPERATION.Equals(xtr.LocalName, StringComparison.CurrentCultureIgnoreCase))
                    {
                        if (operation != null && !string.IsNullOrWhiteSpace(operation.ImplementationRef))
                        {
                            interfaceObject.Operations.Add(operation);
                        }
                    }
                    else if (xtr.EndElement && BpmnXMLConstants.ELEMENT_INTERFACE.Equals(xtr.LocalName))
                    {
                        readyWithInterface = true;
                    }

                    if (xtr.IsEmptyElement && BpmnXMLConstants.ELEMENT_INTERFACE.Equals(xtr.LocalName))
                    {
                        readyWithInterface = true;
                    }
                }
            }
            catch (Exception e)
            {
                log.LogWarning(e, "Error parsing interface child elements");
            }

            model.Interfaces.Add(interfaceObject);
        }
Exemple #30
0
        public override void ParseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model)
        {
            if (!(parentElement is Activity))
            {
                return;
            }
            MultiInstanceLoopCharacteristics multiInstanceDef = new MultiInstanceLoopCharacteristics();

            BpmnXMLUtil.AddXMLLocation(multiInstanceDef, xtr);
            if (xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_MULTIINSTANCE_SEQUENTIAL) != null)
            {
                multiInstanceDef.Sequential = Convert.ToBoolean(xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_MULTIINSTANCE_SEQUENTIAL));
            }
            multiInstanceDef.InputDataItem        = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_MULTIINSTANCE_COLLECTION);
            multiInstanceDef.ElementVariable      = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_MULTIINSTANCE_VARIABLE);
            multiInstanceDef.ElementIndexVariable = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_MULTIINSTANCE_INDEX_VARIABLE);

            bool readyWithMultiInstance = false;

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

                    if (xtr.IsStartElement() && BpmnXMLConstants.ELEMENT_MULTIINSTANCE_CARDINALITY.Equals(xtr.LocalName, StringComparison.CurrentCultureIgnoreCase))
                    {
                        multiInstanceDef.LoopCardinality = xtr.ElementText;
                    }
                    else if (xtr.IsStartElement() && BpmnXMLConstants.ELEMENT_MULTIINSTANCE_DATAINPUT.Equals(xtr.LocalName, StringComparison.CurrentCultureIgnoreCase))
                    {
                        multiInstanceDef.InputDataItem = xtr.ElementText;
                    }
                    else if (xtr.IsStartElement() && BpmnXMLConstants.ELEMENT_MULTIINSTANCE_DATAITEM.Equals(xtr.LocalName, StringComparison.CurrentCultureIgnoreCase))
                    {
                        if (xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_NAME) != null)
                        {
                            multiInstanceDef.ElementVariable = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_NAME);
                        }
                    }
                    else if (xtr.IsStartElement() && BpmnXMLConstants.ELEMENT_MULTIINSTANCE_CONDITION.Equals(xtr.LocalName, StringComparison.CurrentCultureIgnoreCase))
                    {
                        multiInstanceDef.CompletionCondition = xtr.ElementText;
                    }
                    else if (xtr.EndElement && ElementName.Equals(xtr.LocalName, StringComparison.CurrentCultureIgnoreCase))
                    {
                        readyWithMultiInstance = true;
                    }

                    if (xtr.IsEmptyElement && ElementName.Equals(xtr.LocalName, StringComparison.OrdinalIgnoreCase))
                    {
                        readyWithMultiInstance = true;
                    }
                }
            }
            catch (Exception e)
            {
                log.LogWarning(e, "Error parsing multi instance definition");
            }
            ((Activity)parentElement).LoopCharacteristics = multiInstanceDef;
        }