Exemplo n.º 1
0
            public override void ParseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model)
            {
                string resourceElement = XMLStreamReaderUtil.moveDown(xtr);

                if (!string.IsNullOrWhiteSpace(resourceElement) && BpmnXMLConstants.ELEMENT_RESOURCE_ASSIGNMENT.Equals(resourceElement))

                {
                    string expression = XMLStreamReaderUtil.moveDown(xtr);
                    if (!string.IsNullOrWhiteSpace(expression) && BpmnXMLConstants.ELEMENT_FORMAL_EXPRESSION.Equals(expression))
                    {
                        ((UserTask)parentElement).Assignee = xtr.ElementText;
                    }
                }
            }
Exemplo n.º 2
0
            public override void ParseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model)
            {
                string identityLinkType = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_NAME);

                // the attribute value may be unqualified
                if (identityLinkType is null)

                {
                    identityLinkType = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_NAME);
                }

                if (identityLinkType is null)

                {
                    return;
                }

                string resourceElement = XMLStreamReaderUtil.moveDown(xtr);

                if (!string.IsNullOrWhiteSpace(resourceElement) && BpmnXMLConstants.ELEMENT_RESOURCE_ASSIGNMENT.Equals(resourceElement))

                {
                    string expression = XMLStreamReaderUtil.moveDown(xtr);
                    if (!string.IsNullOrWhiteSpace(expression) && BpmnXMLConstants.ELEMENT_FORMAL_EXPRESSION.Equals(expression))
                    {
                        IList <string> assignmentList = CommaSplitter.SplitCommas(xtr.ElementText);

                        for (var idx = 0; idx < assignmentList.Count; idx++)
                        {
                            string assignmentValue = assignmentList[idx];
                            if (assignmentValue is null)
                            {
                                continue;
                            }

                            assignmentValue = assignmentList[idx] = assignmentValue.Trim();

                            if (assignmentValue.Length == 0)
                            {
                                continue;
                            }

                            string userPrefix  = "user(";
                            string groupPrefix = "group(";
                            if (assignmentValue.StartsWith(userPrefix, StringComparison.Ordinal))
                            {
                                assignmentValue = assignmentList[idx] = StringHelper.SubstringSpecial(assignmentValue, userPrefix.Length, assignmentValue.Length - 1).Trim();
                                ((UserTask)parentElement).AddCustomUserIdentityLink(assignmentValue, identityLinkType);
                            }
                            else if (assignmentValue.StartsWith(groupPrefix, StringComparison.Ordinal))
                            {
                                assignmentValue = assignmentList[idx] = StringHelper.SubstringSpecial(assignmentValue, groupPrefix.Length, assignmentValue.Length - 1).Trim();
                                ((UserTask)parentElement).AddCustomGroupIdentityLink(assignmentValue, identityLinkType);
                            }
                            else
                            {
                                ((UserTask)parentElement).AddCustomGroupIdentityLink(assignmentValue, identityLinkType);
                            }
                        }
                    }
                }
            }
Exemplo n.º 3
0
            public override void ParseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model)
            {
                string resourceElement = XMLStreamReaderUtil.moveDown(xtr);

                if (!string.IsNullOrWhiteSpace(resourceElement) && BpmnXMLConstants.ELEMENT_RESOURCE_ASSIGNMENT.Equals(resourceElement))

                {
                    string expression = XMLStreamReaderUtil.moveDown(xtr);
                    if (!string.IsNullOrWhiteSpace(expression) && BpmnXMLConstants.ELEMENT_FORMAL_EXPRESSION.Equals(expression))
                    {
                        IList <string> assignmentList = CommaSplitter.SplitCommas(xtr.ElementText);

                        for (var idx = 0; idx < assignmentList.Count; idx++)
                        {
                            string assignmentValue = assignmentList[idx];

                            if (assignmentValue is null)
                            {
                                continue;
                            }

                            assignmentValue = assignmentList[idx] = assignmentValue.Trim();

                            if (assignmentValue.Length == 0)
                            {
                                continue;
                            }

                            string userPrefix  = "user(";
                            string groupPrefix = "group(";
                            if (assignmentValue.StartsWith(userPrefix, StringComparison.Ordinal))
                            {
                                assignmentValue = assignmentList[idx] = StringHelper.SubstringSpecial(assignmentValue, userPrefix.Length, assignmentValue.Length - 1).Trim();
                                ((UserTask)parentElement).CandidateUsers.Add(assignmentValue);
                            }
                            else if (assignmentValue.StartsWith(groupPrefix, StringComparison.Ordinal))
                            {
                                assignmentValue = assignmentList[idx] = StringHelper.SubstringSpecial(assignmentValue, groupPrefix.Length, assignmentValue.Length - 1).Trim();
                                ((UserTask)parentElement).CandidateGroups.Add(assignmentValue);
                            }
                            else
                            {
                                ((UserTask)parentElement).CandidateGroups.Add(assignmentValue);
                            }
                        }
                    }
                }
                else if (!string.IsNullOrWhiteSpace(resourceElement) && BpmnXMLConstants.ELEMENT_RESOURCE_REF.Equals(resourceElement))

                {
                    string resourceId = xtr.ElementText;
                    if (model.ContainsResourceId(resourceId))
                    {
                        Resource resource = model.GetResource(resourceId);
                        ((UserTask)parentElement).CandidateGroups.Add(resource.Name);
                    }
                    else
                    {
                        Resource resource = new Resource(resourceId, resourceId);
                        model.AddResource(resource);
                        ((UserTask)parentElement).CandidateGroups.Add(resource.Name);
                    }
                }
            }