Example #1
0
        protected internal virtual string ParseActivityType(FlowElement element)
        {
            string elementType = element.GetType().Name;

            elementType = elementType.Substring(0, 1).ToLower() + elementType.Substring(1);
            return(elementType);
        }
Example #2
0
        private void assertFlowElementIs(Type elementClass)
        {
            BpmnModelInstance modelInstance = ModelExecutionContextExecutionListener.modelInstance;

            assertNotNull(modelInstance);

            Model model = modelInstance.Model;
            ICollection <ModelElementInstance> events = modelInstance.getModelElementsByType(model.getType(typeof(Event)));

            assertEquals(3, events.Count);
            ICollection <ModelElementInstance> gateways = modelInstance.getModelElementsByType(model.getType(typeof(Gateway)));

            assertEquals(1, gateways.Count);
            ICollection <ModelElementInstance> tasks = modelInstance.getModelElementsByType(model.getType(typeof(Task)));

            assertEquals(1, tasks.Count);

            FlowElement flowElement = ModelExecutionContextExecutionListener.flowElement;

            assertNotNull(flowElement);
            assertTrue(elementClass.IsAssignableFrom(flowElement.GetType()));
        }
Example #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sequenceFlow"></param>
        protected internal virtual void ContinueThroughSequenceFlow(SequenceFlow sequenceFlow)
        {
            // Execution listener. Sequenceflow only 'take' makes sense ... but we've supported all three since the beginning
            if (CollectionUtil.IsNotEmpty(sequenceFlow.ExecutionListeners))
            {
                ExecuteExecutionListeners(sequenceFlow, BaseExecutionListenerFields.EVENTNAME_START);
                ExecuteExecutionListeners(sequenceFlow, BaseExecutionListenerFields.EVENTNAME_TAKE);
                ExecuteExecutionListeners(sequenceFlow, BaseExecutionListenerFields.EVENTNAME_END);
            }

            // Firing event that transition is being taken
            ProcessEngineConfigurationImpl processEngineConfiguration = Context.ProcessEngineConfiguration;

            if (processEngineConfiguration != null && processEngineConfiguration.EventDispatcher.Enabled)
            {
                FlowElement sourceFlowElement = sequenceFlow.SourceFlowElement;
                FlowElement targetFlowElement = sequenceFlow.TargetFlowElement;

                IActivitiSequenceFlowTakenEvent asft = ActivitiEventBuilder.CreateSequenceFlowTakenEvent(execution, ActivitiEventType.SEQUENCEFLOW_TAKEN, sequenceFlow.Id,
                                                                                                         sourceFlowElement?.Id,
                                                                                                         sourceFlowElement?.Name,
                                                                                                         sourceFlowElement?.GetType().FullName,
                                                                                                         sourceFlowElement == null ? null : ((FlowNode)sourceFlowElement).Behavior,
                                                                                                         targetFlowElement?.Id,
                                                                                                         targetFlowElement?.Name,
                                                                                                         targetFlowElement?.GetType().FullName,
                                                                                                         targetFlowElement == null ? null : ((FlowNode)targetFlowElement).Behavior);
                processEngineConfiguration.EventDispatcher.DispatchEvent(asft);
            }

            {
                FlowElement targetFlowElement = sequenceFlow.TargetFlowElement;
                execution.CurrentFlowElement = targetFlowElement;

                log.LogDebug($"Sequence flow '{sequenceFlow.Id}' encountered. Continuing process by following it using execution {execution.Id}");
                Context.Agenda.PlanContinueProcessOperation(execution);
            }
        }
        public virtual void CreateXML(FlowElement flowElement, BpmnModel model, XMLStreamWriter xtw)
        {
            if (flowElement is SubProcess subProcess)
            {
                if (flowElement is Transaction)
                {
                    xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_TRANSACTION, BpmnXMLConstants.BPMN2_NAMESPACE);
                }
                else if (flowElement is AdhocSubProcess)
                {
                    xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_ADHOC_SUBPROCESS, BpmnXMLConstants.BPMN2_NAMESPACE);
                }
                else
                {
                    xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_SUBPROCESS, BpmnXMLConstants.BPMN2_NAMESPACE);
                }

                xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_ID, subProcess.Id);
                if (!string.IsNullOrWhiteSpace(subProcess.Name))
                {
                    xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_NAME, subProcess.Name);
                }
                else
                {
                    xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_NAME, "subProcess");
                }

                if (subProcess is EventSubProcess)
                {
                    xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_TRIGGERED_BY, BpmnXMLConstants.ATTRIBUTE_VALUE_TRUE);
                }
                else if (!(subProcess is Transaction))
                {
                    if (subProcess.Asynchronous)
                    {
                        BpmnXMLUtil.WriteQualifiedAttribute(BpmnXMLConstants.ATTRIBUTE_ACTIVITY_ASYNCHRONOUS, BpmnXMLConstants.ATTRIBUTE_VALUE_TRUE, xtw);
                        if (subProcess.NotExclusive)
                        {
                            BpmnXMLUtil.WriteQualifiedAttribute(BpmnXMLConstants.ATTRIBUTE_ACTIVITY_EXCLUSIVE, BpmnXMLConstants.ATTRIBUTE_VALUE_FALSE, xtw);
                        }
                    }
                }
                else if (subProcess is AdhocSubProcess hocSubProcess)
                {
                    BpmnXMLUtil.WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_CANCEL_REMAINING_INSTANCES, hocSubProcess.CancelRemainingInstances.ToString(), xtw);
                    if (!string.IsNullOrWhiteSpace(hocSubProcess.Ordering))
                    {
                        BpmnXMLUtil.WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_ORDERING, hocSubProcess.Ordering, xtw);
                    }
                }

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

                bool didWriteExtensionStartElement = ActivitiListenerExport.WriteListeners(subProcess, false, xtw);

                didWriteExtensionStartElement = BpmnXMLUtil.WriteExtensionElements(subProcess, didWriteExtensionStartElement, model.Namespaces, xtw);
                if (didWriteExtensionStartElement)
                {
                    // closing extensions element
                    xtw.WriteEndElement();
                }

                MultiInstanceExport.WriteMultiInstance(subProcess, xtw);

                if (subProcess is AdhocSubProcess adhocSubProcess)
                {
                    if (!string.IsNullOrWhiteSpace(adhocSubProcess.CompletionCondition))
                    {
                        xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_COMPLETION_CONDITION, BpmnXMLConstants.BPMN2_NAMESPACE);
                        xtw.WriteCData(adhocSubProcess.CompletionCondition);
                        xtw.WriteEndElement();
                    }
                }

                foreach (FlowElement subElement in subProcess.FlowElements)
                {
                    CreateXML(subElement, model, xtw);
                }

                foreach (Artifact artifact in subProcess.Artifacts)
                {
                    CreateXML(artifact, model, xtw);
                }

                xtw.WriteEndElement();
            }
            else
            {
                BaseBpmnXMLConverter converter = convertersToXMLMap[flowElement.GetType()];

                if (converter == null)
                {
                    throw new XMLException("No converter for " + flowElement.GetType() + " found");
                }

                converter.ConvertToXML(xtw, flowElement, model);
            }
        }