Example #1
0
        protected internal override void WriteAdditionalChildElements(BaseElement element, BpmnModel model, XMLStreamWriter xtw)
        {
            ScriptTask scriptTask = (ScriptTask)element;

            if (!string.IsNullOrWhiteSpace(scriptTask.Script))
            {
                xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ATTRIBUTE_TASK_SCRIPT_TEXT, BpmnXMLConstants.BPMN2_NAMESPACE);
                xtw.WriteCharacters(scriptTask.Script);
                xtw.WriteEndElement();
            }
        }
        protected internal virtual void WriteTerminateDefinition(Event parentEvent, TerminateEventDefinition terminateDefinition, XMLStreamWriter xtw)
        {
            xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_EVENT_TERMINATEDEFINITION, BpmnXMLConstants.BPMN2_NAMESPACE);

            if (terminateDefinition.TerminateAll)
            {
                WriteQualifiedAttribute(BpmnXMLConstants.ATTRIBUTE_TERMINATE_ALL, "true", xtw);
            }

            if (terminateDefinition.TerminateMultiInstance)
            {
                WriteQualifiedAttribute(BpmnXMLConstants.ATTRIBUTE_TERMINATE_MULTI_INSTANCE, "true", xtw);
            }

            bool didWriteExtensionStartElement = BpmnXMLUtil.WriteExtensionElements(terminateDefinition, false, xtw);

            if (didWriteExtensionStartElement)
            {
                xtw.WriteEndElement();
            }
            xtw.WriteEndElement();
        }
        protected internal override void WriteAdditionalAttributes(BaseElement element, BpmnModel model, XMLStreamWriter xtw)
        {
            SequenceFlow sequenceFlow = (SequenceFlow)element;

            WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_FLOW_SOURCE_REF, sequenceFlow.SourceRef, xtw);
            WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_FLOW_TARGET_REF, sequenceFlow.TargetRef, xtw);
            if (!string.IsNullOrWhiteSpace(sequenceFlow.SkipExpression))
            {
                WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_FLOW_SKIP_EXPRESSION, sequenceFlow.SkipExpression, xtw);
            }
        }
        protected internal virtual void WriteCancelDefinition(Event parentEvent, CancelEventDefinition cancelEventDefinition, XMLStreamWriter xtw)
        {
            xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_EVENT_CANCELDEFINITION, BpmnXMLConstants.BPMN2_NAMESPACE);
            bool didWriteExtensionStartElement = BpmnXMLUtil.WriteExtensionElements(cancelEventDefinition, false, xtw);

            if (didWriteExtensionStartElement)
            {
                xtw.WriteEndElement();
            }
            xtw.WriteEndElement();
        }
        protected internal virtual void WriteMessageDefinition(Event parentEvent, MessageEventDefinition messageDefinition, BpmnModel model, XMLStreamWriter xtw)
        {
            xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_EVENT_MESSAGEDEFINITION, BpmnXMLConstants.BPMN2_NAMESPACE);

            string messageRef = messageDefinition.MessageRef;

            if (!string.IsNullOrWhiteSpace(messageRef))
            {
                // remove the namespace from the message id if set
                if (messageRef.StartsWith(model.TargetNamespace, StringComparison.Ordinal))
                {
                    messageRef = messageRef.Replace(model.TargetNamespace, "");
                    messageRef = messageRef.ReplaceFirst(":", "");
                }
                else
                {
                    foreach (string prefix in model.Namespaces.Keys)
                    {
                        string @namespace = model.GetNamespace(prefix);
                        if (messageRef.StartsWith(@namespace, StringComparison.Ordinal))
                        {
                            messageRef = messageRef.Replace(model.TargetNamespace, "");
                            messageRef = prefix + messageRef;
                        }
                    }
                }
            }
            WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_MESSAGE_REF, messageRef, xtw);
            bool didWriteExtensionStartElement = BpmnXMLUtil.WriteExtensionElements(messageDefinition, false, xtw);

            if (didWriteExtensionStartElement)
            {
                xtw.WriteEndElement();
            }
            xtw.WriteEndElement();
        }
 protected internal virtual bool WriteListeners(BaseElement element, bool didWriteExtensionStartElement, XMLStreamWriter xtw)
 {
     return(ActivitiListenerExport.WriteListeners(element, didWriteExtensionStartElement, xtw));
 }
        protected internal virtual void WriteTimerDefinition(Event parentEvent, TimerEventDefinition timerDefinition, XMLStreamWriter xtw)
        {
            xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_EVENT_TIMERDEFINITION, BpmnXMLConstants.BPMN2_NAMESPACE);
            if (!string.IsNullOrWhiteSpace(timerDefinition.CalendarName))
            {
                WriteQualifiedAttribute(BpmnXMLConstants.ATTRIBUTE_CALENDAR_NAME, timerDefinition.CalendarName, xtw);
            }
            bool didWriteExtensionStartElement = BpmnXMLUtil.WriteExtensionElements(timerDefinition, false, xtw);

            if (didWriteExtensionStartElement)
            {
                xtw.WriteEndElement();
            }
            if (!string.IsNullOrWhiteSpace(timerDefinition.TimeDate))
            {
                xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ATTRIBUTE_TIMER_DATE, BpmnXMLConstants.BPMN2_NAMESPACE);
                xtw.WriteCharacters(timerDefinition.TimeDate);
                xtw.WriteEndElement();
            }
            else if (!string.IsNullOrWhiteSpace(timerDefinition.TimeCycle))
            {
                xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ATTRIBUTE_TIMER_CYCLE, BpmnXMLConstants.BPMN2_NAMESPACE);

                if (!string.IsNullOrWhiteSpace(timerDefinition.EndDate))
                {
                    xtw.WriteAttribute(BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX, BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_END_DATE, timerDefinition.EndDate);
                }

                xtw.WriteCharacters(timerDefinition.TimeCycle);
                xtw.WriteEndElement();
            }
            else if (!string.IsNullOrWhiteSpace(timerDefinition.TimeDuration))
            {
                xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ATTRIBUTE_TIMER_DURATION, BpmnXMLConstants.BPMN2_NAMESPACE);
                xtw.WriteCharacters(timerDefinition.TimeDuration);
                xtw.WriteEndElement();
            }

            xtw.WriteEndElement();
        }
        protected internal override bool WriteExtensionChildElements(BaseElement element, bool didWriteExtensionStartElement, XMLStreamWriter xtw)
        {
            ValuedDataObject dataObject = (ValuedDataObject)element;

            if (!string.IsNullOrWhiteSpace(dataObject.Id) && dataObject.Value != null)
            {
                if (!didWriteExtensionStartElement)
                {
                    xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_EXTENSIONS, BpmnXMLConstants.BPMN2_NAMESPACE);
                    didWriteExtensionStartElement = true;
                }

                xtw.WriteStartElement(BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX, BpmnXMLConstants.ELEMENT_DATA_VALUE, BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE);
                if (dataObject.Value != null)
                {
                    string value;
                    if (dataObject is DateDataObject)
                    {
                        value = ((DateTime)dataObject.Value).ToString(sdf);
                    }
                    else
                    {
                        value = dataObject.Value.ToString();
                    }

                    if (dataObject is StringDataObject && xmlChars.IsMatch(value))
                    {
                        xtw.WriteCData(value);
                    }
                    else
                    {
                        xtw.WriteCharacters(value);
                    }
                }
                xtw.WriteEndElement();
            }

            return(didWriteExtensionStartElement);
        }
        protected internal override void WriteAdditionalChildElements(BaseElement element, BpmnModel model, XMLStreamWriter xtw)
        {
            EndEvent endEvent = (EndEvent)element;

            WriteEventDefinitions(endEvent, endEvent.EventDefinitions, model, xtw);
        }
        protected void WriteCustomIdentities(UserTask userTask, string identityType, ISet <string> users, ISet <string> groups, XMLStreamWriter xtw)
        {
            xtw.WriteStartElement(BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX, BpmnXMLConstants.ELEMENT_CUSTOM_RESOURCE, BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE);
            WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_NAME, identityType, xtw);

            IList <string> identityList = new List <string>();

            if (users != null)
            {
                foreach (string userId in users)
                {
                    identityList.Add("user(" + userId + ")");
                }
            }

            if (groups != null)
            {
                foreach (string groupId in groups)
                {
                    identityList.Add("group(" + groupId + ")");
                }
            }

            string delimitedString = ConvertToDelimitedString(identityList);

            xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_RESOURCE_ASSIGNMENT, BpmnXMLConstants.BPMN2_NAMESPACE);
            xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_FORMAL_EXPRESSION, BpmnXMLConstants.BPMN2_NAMESPACE);
            xtw.WriteCharacters(delimitedString);
            xtw.WriteEndElement(); // End ELEMENT_FORMAL_EXPRESSION
            xtw.WriteEndElement(); // End ELEMENT_RESOURCE_ASSIGNMENT

            xtw.WriteEndElement(); // End ELEMENT_CUSTOM_RESOURCE
        }
        protected internal override void WriteAdditionalAttributes(BaseElement element, BpmnModel model, XMLStreamWriter xtw)
        {
            ValuedDataObject dataObject = (ValuedDataObject)element;

            if (dataObject.ItemSubjectRef != null && !string.IsNullOrWhiteSpace(dataObject.ItemSubjectRef.StructureRef))
            {
                WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_DATA_ITEM_REF, dataObject.ItemSubjectRef.StructureRef, xtw);
            }
        }
        protected bool WriteCustomIdentities(BaseElement element, bool didWriteExtensionStartElement, XMLStreamWriter xtw)
        {
            UserTask userTask = (UserTask)element;

            if (userTask.CustomUserIdentityLinks.Count == 0 && userTask.CustomGroupIdentityLinks.Count == 0)

            {
                return(didWriteExtensionStartElement);
            }

            if (!didWriteExtensionStartElement)
            {
                xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_EXTENSIONS, BpmnXMLConstants.BPMN2_NAMESPACE);
                didWriteExtensionStartElement = true;
            }
            List <string> identityLinkTypes = new List <string>();

            identityLinkTypes.AddRange(userTask.CustomUserIdentityLinks.Keys);
            identityLinkTypes.AddRange(userTask.CustomGroupIdentityLinks.Keys);
            foreach (string identityType in identityLinkTypes)
            {
                WriteCustomIdentities(userTask, identityType, userTask.CustomUserIdentityLinks[identityType], userTask.CustomGroupIdentityLinks[identityType], xtw);
            }

            return(didWriteExtensionStartElement);
        }
        protected internal override bool WriteExtensionChildElements(BaseElement element, bool didWriteExtensionStartElement, XMLStreamWriter xtw)
        {
            UserTask userTask = (UserTask)element;

            didWriteExtensionStartElement = WriteFormProperties(userTask, didWriteExtensionStartElement, xtw);
            didWriteExtensionStartElement = WriteCustomIdentities(element, didWriteExtensionStartElement, xtw);
            if (userTask.CustomProperties.Count() > 0)
            {
                foreach (CustomProperty customProperty in userTask.CustomProperties)
                {
                    if (string.IsNullOrWhiteSpace(customProperty.SimpleValue))
                    {
                        continue;
                    }

                    if (!didWriteExtensionStartElement)
                    {
                        xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_EXTENSIONS, BpmnXMLConstants.BPMN2_NAMESPACE);
                        didWriteExtensionStartElement = true;
                    }
                    xtw.WriteStartElement(BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX, customProperty.Name, BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE);
                    xtw.WriteCharacters(customProperty.SimpleValue);
                    xtw.WriteEndElement();
                }
            }
            return(didWriteExtensionStartElement);
        }
        protected internal override void WriteAdditionalAttributes(BaseElement element, BpmnModel model, XMLStreamWriter xtw)
        {
            UserTask userTask = (UserTask)element;

            WriteQualifiedAttribute(BpmnXMLConstants.ATTRIBUTE_TASK_USER_ASSIGNEE, userTask.Assignee, xtw);
            WriteQualifiedAttribute(BpmnXMLConstants.ATTRIBUTE_TASK_USER_OWNER, userTask.Owner, xtw);
            WriteQualifiedAttribute(BpmnXMLConstants.ATTRIBUTE_TASK_USER_CANDIDATEUSERS, ConvertToDelimitedString(userTask.CandidateUsers), xtw);
            WriteQualifiedAttribute(BpmnXMLConstants.ATTRIBUTE_TASK_USER_CANDIDATEGROUPS, ConvertToDelimitedString(userTask.CandidateGroups), xtw);
            WriteQualifiedAttribute(BpmnXMLConstants.ATTRIBUTE_TASK_USER_DUEDATE, userTask.DueDate, xtw);
            WriteQualifiedAttribute(BpmnXMLConstants.ATTRIBUTE_TASK_USER_BUSINESS_CALENDAR_NAME, userTask.BusinessCalendarName, xtw);
            WriteQualifiedAttribute(BpmnXMLConstants.ATTRIBUTE_TASK_USER_CATEGORY, userTask.Category, xtw);
            WriteQualifiedAttribute(BpmnXMLConstants.ATTRIBUTE_FORM_FORMKEY, userTask.FormKey, xtw);
            if (userTask.Priority != null)

            {
                WriteQualifiedAttribute(BpmnXMLConstants.ATTRIBUTE_TASK_USER_PRIORITY, userTask.Priority.ToString(), xtw);
            }
            if (!string.IsNullOrWhiteSpace(userTask.ExtensionId))

            {
                WriteQualifiedAttribute(BpmnXMLConstants.ATTRIBUTE_TASK_SERVICE_EXTENSIONID, userTask.ExtensionId, xtw);
            }
            if (userTask.SkipExpression != null)

            {
                WriteQualifiedAttribute(BpmnXMLConstants.ATTRIBUTE_TASK_USER_SKIP_EXPRESSION, userTask.SkipExpression, xtw);
            }
            // write custom attributes
            BpmnXMLUtil.WriteCustomAttributes(userTask.Attributes.Values, xtw, defaultElementAttributes, defaultActivityAttributes, defaultUserTaskAttributes);
        }
 protected internal abstract void WriteAdditionalChildElements(BaseElement element, BpmnModel model, XMLStreamWriter xtw);
Example #16
0
        protected internal override void WriteAdditionalAttributes(BaseElement element, BpmnModel model, XMLStreamWriter xtw)
        {
            Association association = (Association)element;

            WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_FLOW_SOURCE_REF, association.SourceRef, xtw);
            WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_FLOW_TARGET_REF, association.TargetRef, xtw);
            AssociationDirection associationDirection = association.AssociationDirection;

            if (associationDirection != null)
            {
                WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_ASSOCIATION_DIRECTION, associationDirection.Value, xtw);
            }
        }
        protected internal virtual bool WriteFormProperties(FlowElement flowElement, bool didWriteExtensionStartElement, XMLStreamWriter xtw)
        {
            IList <FormProperty> propertyList = null;

            if (flowElement is UserTask)
            {
                propertyList = ((UserTask)flowElement).FormProperties;
            }
            else if (flowElement is StartEvent)
            {
                propertyList = ((StartEvent)flowElement).FormProperties;
            }

            if (propertyList != null)
            {
                foreach (FormProperty property in propertyList)
                {
                    if (!string.IsNullOrWhiteSpace(property.Id))
                    {
                        if (!didWriteExtensionStartElement)
                        {
                            xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_EXTENSIONS, BpmnXMLConstants.BPMN2_NAMESPACE);
                            didWriteExtensionStartElement = true;
                        }

                        xtw.WriteStartElement(BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX, BpmnXMLConstants.ELEMENT_FORMPROPERTY, BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE);
                        WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_FORM_ID, property.Id, xtw);

                        WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_FORM_NAME, property.Name, xtw);
                        WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_FORM_TYPE, property.Type, xtw);
                        WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_FORM_EXPRESSION, property.Expression, xtw);
                        WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_FORM_VARIABLE, property.Variable, xtw);
                        WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_FORM_DEFAULT, property.DefaultExpression, xtw);
                        WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_FORM_DATEPATTERN, property.DatePattern, xtw);
                        if (!property.Readable)
                        {
                            WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_FORM_READABLE, BpmnXMLConstants.ATTRIBUTE_VALUE_FALSE, xtw);
                        }
                        if (!property.Writeable)
                        {
                            WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_FORM_WRITABLE, BpmnXMLConstants.ATTRIBUTE_VALUE_FALSE, xtw);
                        }
                        if (property.Required)
                        {
                            WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_FORM_REQUIRED, BpmnXMLConstants.ATTRIBUTE_VALUE_TRUE, xtw);
                        }

                        foreach (FormValue formValue in property.FormValues)
                        {
                            if (!string.IsNullOrWhiteSpace(formValue.Id))
                            {
                                xtw.WriteStartElement(BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX, BpmnXMLConstants.ELEMENT_VALUE, BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE);
                                xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_ID, formValue.Id);
                                xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_NAME, formValue.Name);
                                xtw.WriteEndElement();
                            }
                        }

                        xtw.WriteEndElement();
                    }
                }
            }

            return(didWriteExtensionStartElement);
        }
Example #18
0
        protected internal override void WriteAdditionalAttributes(BaseElement element, BpmnModel model, XMLStreamWriter xtw)
        {
            CallActivity callActivity = (CallActivity)element;

            if (!string.IsNullOrWhiteSpace(callActivity.CalledElement))
            {
                xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_CALL_ACTIVITY_CALLEDELEMENT, callActivity.CalledElement);
            }
            if (!string.IsNullOrWhiteSpace(callActivity.BusinessKey))
            {
                WriteQualifiedAttribute(BpmnXMLConstants.ATTRIBUTE_CALL_ACTIVITY_BUSINESS_KEY, callActivity.BusinessKey, xtw);
            }
            if (callActivity.InheritBusinessKey)
            {
                WriteQualifiedAttribute(BpmnXMLConstants.ATTRIBUTE_CALL_ACTIVITY_INHERIT_BUSINESS_KEY, "true", xtw);
            }
            xtw.WriteAttribute(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_CALL_ACTIVITY_INHERITVARIABLES, callActivity.InheritVariables.ToString());
        }
 protected internal virtual void WriteEventDefinitions(Event parentEvent, IList <EventDefinition> eventDefinitions, BpmnModel model, XMLStreamWriter xtw)
 {
     foreach (EventDefinition eventDefinition in eventDefinitions)
     {
         if (eventDefinition is TimerEventDefinition)
         {
             WriteTimerDefinition(parentEvent, (TimerEventDefinition)eventDefinition, xtw);
         }
         else if (eventDefinition is SignalEventDefinition)
         {
             WriteSignalDefinition(parentEvent, (SignalEventDefinition)eventDefinition, xtw);
         }
         else if (eventDefinition is MessageEventDefinition)
         {
             WriteMessageDefinition(parentEvent, (MessageEventDefinition)eventDefinition, model, xtw);
         }
         else if (eventDefinition is ErrorEventDefinition)
         {
             WriteErrorDefinition(parentEvent, (ErrorEventDefinition)eventDefinition, xtw);
         }
         else if (eventDefinition is TerminateEventDefinition)
         {
             WriteTerminateDefinition(parentEvent, (TerminateEventDefinition)eventDefinition, xtw);
         }
         else if (eventDefinition is CancelEventDefinition)
         {
             WriteCancelDefinition(parentEvent, (CancelEventDefinition)eventDefinition, xtw);
         }
         else if (eventDefinition is CompensateEventDefinition)
         {
             WriteCompensateDefinition(parentEvent, (CompensateEventDefinition)eventDefinition, xtw);
         }
     }
 }
Example #20
0
        protected internal override bool WriteExtensionChildElements(BaseElement element, bool didWriteExtensionStartElement, XMLStreamWriter xtw)
        {
            CallActivity callActivity = (CallActivity)element;

            didWriteExtensionStartElement = WriteIOParameters(BpmnXMLConstants.ELEMENT_CALL_ACTIVITY_IN_PARAMETERS, callActivity.InParameters, didWriteExtensionStartElement, xtw);
            didWriteExtensionStartElement = WriteIOParameters(BpmnXMLConstants.ELEMENT_CALL_ACTIVITY_OUT_PARAMETERS, callActivity.OutParameters, didWriteExtensionStartElement, xtw);
            return(didWriteExtensionStartElement);
        }
        protected internal virtual void WriteSignalDefinition(Event parentEvent, SignalEventDefinition signalDefinition, XMLStreamWriter xtw)
        {
            xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_EVENT_SIGNALDEFINITION, BpmnXMLConstants.BPMN2_NAMESPACE);
            WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_SIGNAL_REF, signalDefinition.SignalRef, xtw);
            if (parentEvent is ThrowEvent && signalDefinition.Async)
            {
                BpmnXMLUtil.WriteQualifiedAttribute(BpmnXMLConstants.ATTRIBUTE_ACTIVITY_ASYNCHRONOUS, "true", xtw);
            }
            bool didWriteExtensionStartElement = BpmnXMLUtil.WriteExtensionElements(signalDefinition, false, xtw);

            if (didWriteExtensionStartElement)
            {
                xtw.WriteEndElement();
            }
            xtw.WriteEndElement();
        }
Example #22
0
 protected internal override void WriteAdditionalChildElements(BaseElement element, BpmnModel model, XMLStreamWriter xtw)
 {
 }
        protected internal virtual void WriteCompensateDefinition(Event parentEvent, CompensateEventDefinition compensateEventDefinition, XMLStreamWriter xtw)
        {
            xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_EVENT_COMPENSATEDEFINITION, BpmnXMLConstants.BPMN2_NAMESPACE);
            WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_COMPENSATE_ACTIVITYREF, compensateEventDefinition.ActivityRef, xtw);
            bool didWriteExtensionStartElement = BpmnXMLUtil.WriteExtensionElements(compensateEventDefinition, false, xtw);

            if (didWriteExtensionStartElement)
            {
                xtw.WriteEndElement();
            }
            xtw.WriteEndElement();
        }
Example #24
0
        private bool WriteIOParameters(string elementName, IList <IOParameter> parameterList, bool didWriteExtensionStartElement, XMLStreamWriter xtw)
        {
            if (parameterList.Count == 0)
            {
                return(didWriteExtensionStartElement);
            }

            foreach (IOParameter ioParameter in parameterList)
            {
                if (!didWriteExtensionStartElement)
                {
                    xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_EXTENSIONS, BpmnXMLConstants.BPMN2_NAMESPACE);
                    didWriteExtensionStartElement = true;
                }

                xtw.WriteStartElement(BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX, elementName, BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE);
                if (!string.IsNullOrWhiteSpace(ioParameter.Source))
                {
                    WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_IOPARAMETER_SOURCE, ioParameter.Source, xtw);
                }
                if (!string.IsNullOrWhiteSpace(ioParameter.SourceExpression))
                {
                    WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_IOPARAMETER_SOURCE_EXPRESSION, ioParameter.SourceExpression, xtw);
                }
                if (!string.IsNullOrWhiteSpace(ioParameter.Target))
                {
                    WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_IOPARAMETER_TARGET, ioParameter.Target, xtw);
                }

                xtw.WriteEndElement();
            }

            return(didWriteExtensionStartElement);
        }
        protected internal virtual void WriteErrorDefinition(Event parentEvent, ErrorEventDefinition errorDefinition, XMLStreamWriter xtw)
        {
            xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_EVENT_ERRORDEFINITION, BpmnXMLConstants.BPMN2_NAMESPACE);
            WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_ERROR_REF, errorDefinition.ErrorCode, xtw);
            bool didWriteExtensionStartElement = BpmnXMLUtil.WriteExtensionElements(errorDefinition, false, xtw);

            if (didWriteExtensionStartElement)
            {
                xtw.WriteEndElement();
            }
            xtw.WriteEndElement();
        }
        public virtual void ConvertToXML(XMLStreamWriter xtw, BaseElement baseElement, BpmnModel model)
        {
            xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, XMLElementName, BpmnXMLConstants.BPMN2_NAMESPACE);
            bool didWriteExtensionStartElement = false;

            WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_ID, baseElement.Id, xtw);
            if (baseElement is FlowElement)
            {
                WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_NAME, ((FlowElement)baseElement).Name, xtw);
            }

            if (baseElement is FlowNode flowNode)
            {
                if (flowNode.Asynchronous)
                {
                    WriteQualifiedAttribute(BpmnXMLConstants.ATTRIBUTE_ACTIVITY_ASYNCHRONOUS, BpmnXMLConstants.ATTRIBUTE_VALUE_TRUE, xtw);
                    if (flowNode.NotExclusive)
                    {
                        WriteQualifiedAttribute(BpmnXMLConstants.ATTRIBUTE_ACTIVITY_EXCLUSIVE, BpmnXMLConstants.ATTRIBUTE_VALUE_FALSE, xtw);
                    }
                }

                if (baseElement is Activity activity)
                {
                    if (activity.ForCompensation)
                    {
                        WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_ACTIVITY_ISFORCOMPENSATION, BpmnXMLConstants.ATTRIBUTE_VALUE_TRUE, xtw);
                    }
                    if (!string.IsNullOrWhiteSpace(activity.DefaultFlow))
                    {
                        FlowElement defaultFlowElement = model.GetFlowElement(activity.DefaultFlow);
                        if (defaultFlowElement is SequenceFlow)
                        {
                            WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_DEFAULT, activity.DefaultFlow, xtw);
                        }
                    }
                }

                if (baseElement is Gateway gateway)
                {
                    if (!string.IsNullOrWhiteSpace(gateway.DefaultFlow))
                    {
                        FlowElement defaultFlowElement = model.GetFlowElement(gateway.DefaultFlow);
                        if (defaultFlowElement is SequenceFlow)
                        {
                            WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_DEFAULT, gateway.DefaultFlow, xtw);
                        }
                    }
                }
            }

            WriteAdditionalAttributes(baseElement, model, xtw);

            if (baseElement is FlowElement flowElement)
            {
                if (!string.IsNullOrWhiteSpace(flowElement.Documentation))
                {
                    xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_DOCUMENTATION, BpmnXMLConstants.BPMN2_NAMESPACE);
                    xtw.WriteCharacters(flowElement.Documentation);
                    xtw.WriteEndElement();
                }
            }

            didWriteExtensionStartElement = WriteExtensionChildElements(baseElement, didWriteExtensionStartElement, xtw);
            didWriteExtensionStartElement = WriteListeners(baseElement, didWriteExtensionStartElement, xtw);
            didWriteExtensionStartElement = BpmnXMLUtil.WriteExtensionElements(baseElement, didWriteExtensionStartElement, model.Namespaces, xtw);
            if (baseElement is Activity)
            {
                FailedJobRetryCountExport.WriteFailedJobRetryCount(baseElement as Activity, xtw);
            }

            if (didWriteExtensionStartElement)
            {
                xtw.WriteEndElement();
            }

            if (baseElement is Activity)
            {
                MultiInstanceExport.WriteMultiInstance(baseElement as Activity, xtw);
            }

            WriteAdditionalChildElements(baseElement, model, xtw);

            xtw.WriteEndElement();
        }
 protected internal virtual void WriteQualifiedAttribute(string attributeName, string value, XMLStreamWriter xtw)
 {
     BpmnXMLUtil.WriteQualifiedAttribute(attributeName, value, xtw);
 }
 protected internal virtual bool WriteExtensionChildElements(BaseElement element, bool didWriteExtensionStartElement, XMLStreamWriter xtw)
 {
     return(didWriteExtensionStartElement);
 }
        protected internal override void WriteAdditionalChildElements(BaseElement element, BpmnModel model, XMLStreamWriter xtw)
        {
            SequenceFlow sequenceFlow = (SequenceFlow)element;

            if (!string.IsNullOrWhiteSpace(sequenceFlow.ConditionExpression))
            {
                xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_FLOW_CONDITION, BpmnXMLConstants.BPMN2_NAMESPACE);
                xtw.WriteAttribute(BpmnXMLConstants.XSI_PREFIX, BpmnXMLConstants.XSI_NAMESPACE, "type", "bpmn2:tFormalExpression");
                xtw.WriteCharacters(sequenceFlow.ConditionExpression);
                xtw.WriteEndElement();
            }
        }
Example #30
0
        protected internal override void WriteAdditionalAttributes(BaseElement element, BpmnModel model, XMLStreamWriter xtw)
        {
            ScriptTask scriptTask = (ScriptTask)element;

            WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_TASK_SCRIPT_FORMAT, scriptTask.ScriptFormat, xtw);
            WriteQualifiedAttribute(BpmnXMLConstants.ATTRIBUTE_TASK_SCRIPT_RESULTVARIABLE, scriptTask.ResultVariable, xtw);
            WriteQualifiedAttribute(BpmnXMLConstants.ATTRIBUTE_TASK_SCRIPT_AUTO_STORE_VARIABLE, scriptTask.AutoStoreVariables.ToString(), xtw);
        }