protected internal override BaseElement ConvertXMLToElement(XMLStreamReader xtr, BpmnModel model)
        {
            BoundaryEvent boundaryEvent = new BoundaryEvent();

            BpmnXMLUtil.AddXMLLocation(boundaryEvent, xtr);
            if (!string.IsNullOrWhiteSpace(xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_BOUNDARY_CANCELACTIVITY)))
            {
                string cancelActivity = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_BOUNDARY_CANCELACTIVITY);
                if (BpmnXMLConstants.ATTRIBUTE_VALUE_FALSE.Equals(cancelActivity, StringComparison.CurrentCultureIgnoreCase))
                {
                    boundaryEvent.CancelActivity = false;
                }
            }
            boundaryEvent.AttachedToRefId = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_BOUNDARY_ATTACHEDTOREF);
            ParseChildElements(XMLElementName, boundaryEvent, model, xtr);

            // Explicitly set cancel activity to false for error boundary events
            if (boundaryEvent.EventDefinitions.Count == 1)
            {
                EventDefinition eventDef = boundaryEvent.EventDefinitions[0];

                if (eventDef is ErrorEventDefinition)
                {
                    boundaryEvent.CancelActivity = false;
                }
            }

            return(boundaryEvent);
        }
        protected internal override BaseElement ConvertXMLToElement(XMLStreamReader xtr, BpmnModel model)
        {
            string     formKey    = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_FORM_FORMKEY);
            StartEvent startEvent = null;

            if (!string.IsNullOrWhiteSpace(formKey) && model.StartEventFormTypes != null && model.StartEventFormTypes.Contains(formKey))
            {
                startEvent = new AlfrescoStartEvent();
            }
            if (startEvent == null)
            {
                startEvent = new StartEvent();
            }
            BpmnXMLUtil.AddXMLLocation(startEvent, xtr);
            startEvent.Initiator = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_EVENT_START_INITIATOR);
            bool   interrupting          = true;
            string interruptingAttribute = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_EVENT_START_INTERRUPTING);

            if (BpmnXMLConstants.ATTRIBUTE_VALUE_FALSE.Equals(interruptingAttribute, StringComparison.OrdinalIgnoreCase))
            {
                interrupting = false;
            }
            startEvent.Interrupting = interrupting;
            startEvent.FormKey      = formKey;

            ParseChildElements(XMLElementName, startEvent, model, xtr);

            return(startEvent);
        }
Пример #3
0
        protected internal override BaseElement ConvertXMLToElement(XMLStreamReader xtr, BpmnModel model)
        {
            CallActivity callActivity = new CallActivity();

            BpmnXMLUtil.AddXMLLocation(callActivity, xtr);
            callActivity.CalledElement = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_CALL_ACTIVITY_CALLEDELEMENT);
            callActivity.BusinessKey   = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_CALL_ACTIVITY_BUSINESS_KEY);
            bool.TryParse(xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_CALL_ACTIVITY_INHERIT_BUSINESS_KEY), out callActivity.inheritBusinessKey);
            bool.TryParse(xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_CALL_ACTIVITY_INHERITVARIABLES), out callActivity.inheritVariables);
            ParseChildElements(XMLElementName, callActivity, childParserMap, model, xtr);
            return(callActivity);
        }
        protected internal override BaseElement ConvertXMLToElement(XMLStreamReader xtr, BpmnModel model)
        {
            SequenceFlow sequenceFlow = new SequenceFlow();

            BpmnXMLUtil.AddXMLLocation(sequenceFlow, xtr);
            sequenceFlow.SourceRef      = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_FLOW_SOURCE_REF);
            sequenceFlow.TargetRef      = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_FLOW_TARGET_REF);
            sequenceFlow.Name           = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_NAME);
            sequenceFlow.SkipExpression = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_FLOW_SKIP_EXPRESSION);

            ParseChildElements(XMLElementName, sequenceFlow, model, xtr);

            return(sequenceFlow);
        }
        protected internal override BaseElement ConvertXMLToElement(XMLStreamReader xtr, BpmnModel model)
        {
            BusinessRuleTask businessRuleTask = new BusinessRuleTask();

            BpmnXMLUtil.AddXMLLocation(businessRuleTask, xtr);
            businessRuleTask.InputVariables     = ParseDelimitedList(xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_RULE_VARIABLES_INPUT));
            businessRuleTask.RuleNames          = ParseDelimitedList(xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_RULE_RULES));
            businessRuleTask.ResultVariableName = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_RULE_RESULT_VARIABLE);
            businessRuleTask.ClassName          = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_RULE_CLASS);
            string exclude = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_RULE_EXCLUDE);

            if (BpmnXMLConstants.ATTRIBUTE_VALUE_TRUE.Equals(exclude, StringComparison.CurrentCultureIgnoreCase))
            {
                businessRuleTask.Exclude = true;
            }
            ParseChildElements(XMLElementName, businessRuleTask, model, xtr);
            return(businessRuleTask);
        }
        protected internal override BaseElement ConvertXMLToElement(XMLStreamReader xtr, BpmnModel model)
        {
            TextAnnotation textAnnotation = new TextAnnotation();

            BpmnXMLUtil.AddXMLLocation(textAnnotation, xtr);
            textAnnotation.TextFormat = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_TEXTFORMAT);
            ParseChildElements(XMLElementName, textAnnotation, childParserMap, model, xtr);
            return(textAnnotation);
        }
Пример #7
0
        protected internal override BaseElement ConvertXMLToElement(XMLStreamReader xtr, BpmnModel model)
        {
            ScriptTask scriptTask = new ScriptTask();

            BpmnXMLUtil.AddXMLLocation(scriptTask, xtr);
            scriptTask.ScriptFormat   = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_TASK_SCRIPT_FORMAT);
            scriptTask.ResultVariable = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_SCRIPT_RESULTVARIABLE);
            if (string.IsNullOrWhiteSpace(scriptTask.ResultVariable))
            {
                scriptTask.ResultVariable = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_SERVICE_RESULTVARIABLE);
            }
            string autoStoreVariables = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_SCRIPT_AUTO_STORE_VARIABLE);

            if (!string.IsNullOrWhiteSpace(autoStoreVariables))
            {
                scriptTask.AutoStoreVariables = Convert.ToBoolean(autoStoreVariables);
            }
            ParseChildElements(XMLElementName, scriptTask, childParserMap, model, xtr);
            return(scriptTask);
        }
Пример #8
0
        protected internal virtual bool ParseForCompensation(XMLStreamReader xtr)
        {
            bool   isForCompensation  = false;
            string compensationString = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_ACTIVITY_ISFORCOMPENSATION);

            if (BpmnXMLConstants.ATTRIBUTE_VALUE_TRUE.Equals(compensationString, StringComparison.CurrentCultureIgnoreCase))
            {
                isForCompensation = true;
            }
            return(isForCompensation);
        }
Пример #9
0
        protected internal virtual bool ParseNotExclusive(XMLStreamReader xtr)
        {
            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;
            }
            return(notExclusive);
        }
Пример #10
0
        protected internal virtual bool ParseAsync(XMLStreamReader xtr)
        {
            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;
            }
            return(async);
        }
Пример #11
0
        protected internal override BaseElement ConvertXMLToElement(XMLStreamReader xtr, BpmnModel model)
        {
            Association association = new Association();

            BpmnXMLUtil.AddXMLLocation(association, xtr);
            association.SourceRef = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_FLOW_SOURCE_REF);
            association.TargetRef = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_FLOW_TARGET_REF);
            association.Id        = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_ID);

            string asociationDirectionString = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_ASSOCIATION_DIRECTION);

            if (!string.IsNullOrWhiteSpace(asociationDirectionString))
            {
                AssociationDirection associationDirection = AssociationDirection.ValueOf(asociationDirectionString.ToUpper());

                association.AssociationDirection = associationDirection;
            }

            ParseChildElements(XMLElementName, association, model, xtr);

            return(association);
        }
Пример #12
0
        protected internal override BaseElement ConvertXMLToElement(XMLStreamReader xtr, BpmnModel model)
        {
            SendTask sendTask = new SendTask();

            BpmnXMLUtil.AddXMLLocation(sendTask, xtr);
            //sendTask.Type = xtr.getAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TYPE);

            if (!string.IsNullOrWhiteSpace(xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_SERVICE_CLASS)))
            {
                sendTask.ImplementationType = ImplementationType.IMPLEMENTATION_TYPE_CLASS;
                sendTask.Implementation     = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_SERVICE_CLASS);
            }

            //if ("##WebService".Equals(xtr.getAttributeValue(BpmnXMLConstants.ATTRIBUTE_TASK_IMPLEMENTATION)))
            //{
            //    sendTask.ImplementationType = ImplementationType.IMPLEMENTATION_TYPE_WEBSERVICE;
            //    sendTask.OperationRef = parseOperationRef(xtr.getAttributeValue(BpmnXMLConstants.ATTRIBUTE_TASK_OPERATION_REF), model);
            //}

            ParseChildElements(XMLElementName, sendTask, model, xtr);

            return(sendTask);
        }
Пример #13
0
            public override void ParseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model)
            {
                string source           = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_IOPARAMETER_SOURCE);
                string sourceExpression = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_IOPARAMETER_SOURCE_EXPRESSION);
                string target           = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_IOPARAMETER_TARGET);

                if ((!string.IsNullOrWhiteSpace(source) || !string.IsNullOrWhiteSpace(sourceExpression)) && !string.IsNullOrWhiteSpace(target))
                {
                    IOParameter parameter = new IOParameter();
                    if (!string.IsNullOrWhiteSpace(sourceExpression))
                    {
                        parameter.SourceExpression = sourceExpression;
                    }
                    else
                    {
                        parameter.Source = source;
                    }

                    parameter.Target = target;

                    ((CallActivity)parentElement).OutParameters.Add(parameter);
                }
            }
Пример #14
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);
                            }
                        }
                    }
                }
            }
        protected internal override BaseElement ConvertXMLToElement(XMLStreamReader xtr, BpmnModel model)
        {
            ValuedDataObject dataObject     = null;
            ItemDefinition   itemSubjectRef = new ItemDefinition();

            string structureRef = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_DATA_ITEM_REF);

            if (!string.IsNullOrWhiteSpace(structureRef) && structureRef.Contains(":"))
            {
                string dataType = structureRef.Substring(structureRef.IndexOf(':') + 1);

                if (dataType.Equals("string"))
                {
                    dataObject = new StringDataObject();
                }
                else if (dataType.Equals("int"))
                {
                    dataObject = new IntegerDataObject();
                }
                else if (dataType.Equals("long"))
                {
                    dataObject = new LongDataObject();
                }
                else if (dataType.Equals("double"))
                {
                    dataObject = new DoubleDataObject();
                }
                else if (dataType.Equals("boolean"))
                {
                    dataObject = new BooleanDataObject();
                }
                else if (dataType.Equals("datetime"))
                {
                    dataObject = new DateDataObject();
                }
                else
                {
                    logger.LogError($"Error converting {xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_DATA_NAME)}, invalid data type: {dataType}");
                }
            }
            else
            {
                // use String as default type
                dataObject   = new StringDataObject();
                structureRef = "xsd:string";
            }

            if (dataObject != null)
            {
                dataObject.Id   = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_DATA_ID);
                dataObject.Name = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_DATA_NAME);

                BpmnXMLUtil.AddXMLLocation(dataObject, xtr);

                itemSubjectRef.StructureRef = structureRef;
                dataObject.ItemSubjectRef   = itemSubjectRef;

                ParseChildElements(XMLElementName, dataObject, model, xtr);

                dataObject.ExtensionElements.TryGetValue("value", out IList <ExtensionElement> valuesElement);
                if (valuesElement != null && valuesElement.Count > 0)
                {
                    ExtensionElement valueElement = valuesElement[0];
                    if (!string.IsNullOrWhiteSpace(valueElement.ElementText))
                    {
                        if (dataObject is DateDataObject)
                        {
                            try
                            {
                                dataObject.Value = DateTime.Parse(valueElement.ElementText, new DateTimeFormatInfo()
                                {
                                    FullDateTimePattern = sdf
                                });
                            }
                            catch (Exception e)
                            {
                                logger.LogError(e, $"Error converting {dataObject.Name} \r\n {e.Message}");
                            }
                        }
                        else
                        {
                            dataObject.Value = valueElement.ElementText;
                        }
                    }

                    // remove value element
                    dataObject.ExtensionElements.Remove("value");
                }
            }

            return(dataObject);
        }
Пример #16
0
        public virtual BpmnModel ConvertToBpmnModel(XMLStreamReader xtr)
        {
            BpmnModel model = new BpmnModel
            {
                StartEventFormTypes = startEventFormTypes,
                UserTaskFormTypes   = userTaskFormTypes
            };

            try
            {
                Process            activeProcess        = null;
                IList <SubProcess> activeSubProcessList = new List <SubProcess>();
                while (xtr.HasNext())
                {
                    // xtr.next();
                    if (xtr.EndElement && (BpmnXMLConstants.ELEMENT_SUBPROCESS.Equals(xtr.LocalName) || BpmnXMLConstants.ELEMENT_TRANSACTION.Equals(xtr.LocalName) || BpmnXMLConstants.ELEMENT_ADHOC_SUBPROCESS.Equals(xtr.LocalName)))
                    {
                        activeSubProcessList.RemoveAt(activeSubProcessList.Count - 1);
                    }

                    if (!xtr.IsStartElement())
                    {
                        if (BpmnXMLConstants.ELEMENT_DI_DIAGRAM == xtr.LocalName)
                        {
                            xtr.Skip();
                        }
                        else
                        {
                            continue;
                        }
                    }

                    if (xtr.IsStartElement() && BpmnXMLConstants.ELEMENT_DEFINITIONS.Equals(xtr.LocalName))
                    {
                        definitionsParser.Parse(xtr, model);
                    }
                    else if (BpmnXMLConstants.ELEMENT_RESOURCE.Equals(xtr.LocalName))
                    {
                        resourceParser.Parse(xtr, model);
                    }
                    else if (BpmnXMLConstants.ELEMENT_SIGNAL.Equals(xtr.LocalName))
                    {
                        signalParser.Parse(xtr, model);
                    }
                    else if (BpmnXMLConstants.ELEMENT_MESSAGE.Equals(xtr.LocalName))
                    {
                        messageParser.Parse(xtr, model);
                    }
                    else if (BpmnXMLConstants.ELEMENT_ERROR.Equals(xtr.LocalName))
                    {
                        if (!string.IsNullOrWhiteSpace(xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_ID)))
                        {
                            model.AddError(xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_ID), xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_ERROR_CODE));
                        }
                    }
                    else if (BpmnXMLConstants.ELEMENT_IMPORT.Equals(xtr.LocalName))
                    {
                        importParser.Parse(xtr, model);
                    }
                    else if (BpmnXMLConstants.ELEMENT_ITEM_DEFINITION.Equals(xtr.LocalName))
                    {
                        itemDefinitionParser.Parse(xtr, model);
                    }
                    else if (BpmnXMLConstants.ELEMENT_DATA_STORE.Equals(xtr.LocalName))
                    {
                        dataStoreParser.Parse(xtr, model);
                    }
                    else if (BpmnXMLConstants.ELEMENT_INTERFACE.Equals(xtr.LocalName))
                    {
                        interfaceParser.Parse(xtr, model);
                    }
                    else if (BpmnXMLConstants.ELEMENT_IOSPECIFICATION.Equals(xtr.LocalName))
                    {
                        ioSpecificationParser.ParseChildElement(xtr, activeProcess, model);
                    }
                    else if (BpmnXMLConstants.ELEMENT_PARTICIPANT.Equals(xtr.LocalName))
                    {
                        participantParser.Parse(xtr, model);
                    }
                    else if (BpmnXMLConstants.ELEMENT_MESSAGE_FLOW.Equals(xtr.LocalName))
                    {
                        messageFlowParser.Parse(xtr, model);
                    }
                    else if (BpmnXMLConstants.ELEMENT_PROCESS.Equals(xtr.LocalName))
                    {
                        Process process = processParser.Parse(xtr, model);
                        if (process != null)
                        {
                            activeProcess = process;
                        }
                    }
                    else if (BpmnXMLConstants.ELEMENT_POTENTIAL_STARTER.Equals(xtr.LocalName))
                    {
                        potentialStarterParser.Parse(xtr, activeProcess);
                    }
                    else if (BpmnXMLConstants.ELEMENT_LANE.Equals(xtr.LocalName))
                    {
                        laneParser.Parse(xtr, activeProcess, model);
                    }
                    else if (BpmnXMLConstants.ELEMENT_DOCUMENTATION.Equals(xtr.LocalName))
                    {
                        BaseElement parentElement = null;
                        if (activeSubProcessList.Count > 0)
                        {
                            parentElement = activeSubProcessList[activeSubProcessList.Count - 1];
                        }
                        else if (activeProcess != null)
                        {
                            parentElement = activeProcess;
                        }
                        documentationParser.ParseChildElement(xtr, parentElement, model);
                    }
                    else if (activeProcess == null && BpmnXMLConstants.ELEMENT_TEXT_ANNOTATION.Equals(xtr.LocalName))
                    {
                        string         elementId      = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_ID);
                        TextAnnotation textAnnotation = (TextAnnotation)(new TextAnnotationXMLConverter()).ConvertXMLToElement(xtr, model);
                        textAnnotation.Id = elementId;
                        model.GlobalArtifacts.Add(textAnnotation);
                    }
                    else if (activeProcess == null && BpmnXMLConstants.ELEMENT_ASSOCIATION.Equals(xtr.LocalName))
                    {
                        string      elementId   = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_ID);
                        Association association = (Association)(new AssociationXMLConverter()).ConvertXMLToElement(xtr, model);
                        association.Id = elementId;
                        model.GlobalArtifacts.Add(association);
                    }
                    else if (BpmnXMLConstants.ELEMENT_EXTENSIONS.Equals(xtr.LocalName))
                    {
                        extensionElementsParser.Parse(xtr, activeSubProcessList, activeProcess, model);
                    }
                    else if (BpmnXMLConstants.ELEMENT_SUBPROCESS.Equals(xtr.LocalName) || BpmnXMLConstants.ELEMENT_TRANSACTION.Equals(xtr.LocalName) || BpmnXMLConstants.ELEMENT_ADHOC_SUBPROCESS.Equals(xtr.LocalName))
                    {
                        subProcessParser.Parse(xtr, activeSubProcessList, activeProcess);
                    }
                    else if (BpmnXMLConstants.ELEMENT_COMPLETION_CONDITION.Equals(xtr.LocalName))
                    {
                        if (activeSubProcessList.Count > 0)
                        {
                            SubProcess subProcess = activeSubProcessList[activeSubProcessList.Count - 1];
                            if (subProcess is AdhocSubProcess adhocSubProcess)
                            {
                                adhocSubProcess.CompletionCondition = xtr.ElementText;
                            }
                        }
                    }
                    else if (BpmnXMLConstants.ELEMENT_DI_SHAPE.Equals(xtr.LocalName))
                    {
                        bpmnShapeParser.Parse(xtr, model);
                    }
                    else if (BpmnXMLConstants.ELEMENT_DI_EDGE.Equals(xtr.LocalName))
                    {
                        bpmnEdgeParser.Parse(xtr, model);
                    }
                    else
                    {
                        if (activeSubProcessList.Count > 0 && BpmnXMLConstants.ELEMENT_MULTIINSTANCE.Equals(xtr.LocalName, StringComparison.CurrentCultureIgnoreCase))
                        {
                            multiInstanceParser.ParseChildElement(xtr, activeSubProcessList[activeSubProcessList.Count - 1], model);
                        }
                        else if (convertersToBpmnMap.ContainsKey(xtr.LocalName))
                        {
                            if (activeProcess != null)
                            {
                                BaseBpmnXMLConverter converter = convertersToBpmnMap[xtr.LocalName];
                                converter.ConvertToBpmnModel(xtr, model, activeProcess, activeSubProcessList);
                            }
                        }
                    }
                    //try
                    //{
                    //    xtr.next();
                    //}
                    //catch (Exception e)
                    //{
                    //    //LOGGER.debug("Error reading XML document", e);
                    //    throw new XMLException("Error reading XML", e);
                    //}
                }

                foreach (Process process in model.Processes)
                {
                    foreach (Pool pool in model.Pools)
                    {
                        if (process.Id.Equals(pool.ProcessRef))
                        {
                            pool.Executable = process.Executable;
                        }
                    }
                    ProcessFlowElements(process.FlowElements, process);
                }
            }
            catch (Exception e)
            {
                log.LogError(e, "Error processing BPMN document");
                throw new XMLException("Error processing BPMN document", e);
            }
            return(model);
        }
Пример #17
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);
                }
            }
        }
Пример #18
0
        protected internal override BaseElement ConvertXMLToElement(XMLStreamReader xtr, BpmnModel model)
        {
            string   formKey  = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_FORM_FORMKEY);
            UserTask userTask = null;

            if (!string.IsNullOrWhiteSpace(formKey))
            {
                if (model.UserTaskFormTypes != null && model.UserTaskFormTypes.Contains(formKey))
                {
                    userTask = new AlfrescoUserTask();
                }
            }
            if (userTask == null)
            {
                userTask = new UserTask();
            }
            BpmnXMLUtil.AddXMLLocation(userTask, xtr);
            userTask.DueDate = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_USER_DUEDATE);
            userTask.BusinessCalendarName = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_USER_BUSINESS_CALENDAR_NAME);
            userTask.Category             = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_USER_CATEGORY);
            userTask.FormKey  = formKey;
            userTask.Assignee = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_USER_ASSIGNEE);
            userTask.Owner    = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_USER_OWNER);
            userTask.Priority = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_USER_PRIORITY);

            if (!string.IsNullOrWhiteSpace(xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_USER_CANDIDATEUSERS)))
            {
                string expression = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_USER_CANDIDATEUSERS);
                (userTask.CandidateUsers as List <string>).AddRange(ParseDelimitedList(expression));
            }

            if (!string.IsNullOrWhiteSpace(xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_USER_CANDIDATEGROUPS)))
            {
                string expression = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_USER_CANDIDATEGROUPS);
                (userTask.CandidateGroups as List <string>).AddRange(ParseDelimitedList(expression));
            }

            userTask.ExtensionId = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_SERVICE_EXTENSIONID);

            if (!string.IsNullOrWhiteSpace(xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_USER_SKIP_EXPRESSION)))
            {
                string expression = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_USER_SKIP_EXPRESSION);
                userTask.SkipExpression = expression;
            }

            BpmnXMLUtil.AddCustomAttributes(xtr, userTask, defaultElementAttributes, defaultActivityAttributes, defaultUserTaskAttributes);

            ParseChildElements(XMLElementName, userTask, childParserMap, model, xtr);

            return(userTask);
        }
        protected internal override BaseElement ConvertXMLToElement(XMLStreamReader xtr, BpmnModel model)
        {
            ServiceTask serviceTask = new ServiceTask();

            BpmnXMLUtil.AddXMLLocation(serviceTask, xtr);
            if (!string.IsNullOrWhiteSpace(xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_SERVICE_CLASS)))
            {
                serviceTask.ImplementationType = ImplementationType.IMPLEMENTATION_TYPE_CLASS;
                serviceTask.Implementation     = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_SERVICE_CLASS);
            }
            else if (!string.IsNullOrWhiteSpace(xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_SERVICE_EXPRESSION)))
            {
                serviceTask.ImplementationType = ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION;
                serviceTask.Implementation     = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_SERVICE_EXPRESSION);
            }
            else if (!string.IsNullOrWhiteSpace(xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_SERVICE_DELEGATEEXPRESSION)))
            {
                serviceTask.ImplementationType = ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION;
                serviceTask.Implementation     = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_SERVICE_DELEGATEEXPRESSION);
            }
            else if ("##WebService".Equals(xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_TASK_IMPLEMENTATION)))
            {
                serviceTask.ImplementationType = ImplementationType.IMPLEMENTATION_TYPE_WEBSERVICE;
                serviceTask.OperationRef       = ParseOperationRef(xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_TASK_OPERATION_REF), model);
            }
            else
            {
                serviceTask.Implementation = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_TASK_IMPLEMENTATION);
            }

            serviceTask.ResultVariableName = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_SERVICE_RESULTVARIABLE);
            if (string.IsNullOrWhiteSpace(serviceTask.ResultVariableName))
            {
                serviceTask.ResultVariableName = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, "resultVariable");
            }

            serviceTask.Type        = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TYPE);
            serviceTask.ExtensionId = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_SERVICE_EXTENSIONID);

            if (!string.IsNullOrWhiteSpace(xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_SERVICE_SKIP_EXPRESSION)))
            {
                serviceTask.SkipExpression = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_SERVICE_SKIP_EXPRESSION);
            }
            ParseChildElements(XMLElementName, serviceTask, model, xtr);

            return(serviceTask);
        }