示例#1
0
        static ExclusiveGateway CreateExclusiveGateway(XElement xElement)
        {
            var gateway = new ExclusiveGateway();

            FillCommonProcessElementAttributes(gateway, xElement);
            return(gateway);
        }
示例#2
0
        static ExclusiveGateway CreateExclusiveGateway(XElement xElement)
        {
            var gateway = new ExclusiveGateway();

            gateway.Id   = GetProcessId(xElement);
            gateway.Name = RemoveWhitespaces(GetProcessName(xElement));
            return(gateway);
        }
示例#3
0
        public virtual ExclusiveGateway CreateExclusiveGateway()
        {
            var gateway = new ExclusiveGateway();

            //gateway.Tag = new ExclusiveGatewayActivityBehavior();

            return(gateway);
        }
        protected internal override BaseElement ConvertXMLToElement(XMLStreamReader xtr, BpmnModel model)
        {
            ExclusiveGateway gateway = new ExclusiveGateway();

            BpmnXMLUtil.AddXMLLocation(gateway, xtr);
            ParseChildElements(XMLElementName, gateway, model, xtr);
            return(gateway);
        }
示例#5
0
        public override BaseElement Clone()
        {
            ExclusiveGateway clone = new ExclusiveGateway
            {
                Values = this
            };

            return(clone);
        }
        public override object Clone()
        {
            var result = new ExclusiveGateway
            {
                Default = Default
            };

            FeedGateway(result);
            return(result);
        }
示例#7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void parseModel()
        public virtual void parseModel()
        {
            modelInstance        = Bpmn.readModelFromStream(this.GetType().getResourceAsStream(this.GetType().Name + ".xml"));
            collaboration        = modelInstance.getModelElementById(COLLABORATION_ID);
            participant          = modelInstance.getModelElementById(PARTICIPANT_ID + 1);
            process              = modelInstance.getModelElementById(PROCESS_ID + 1);
            serviceTask          = modelInstance.getModelElementById(SERVICE_TASK_ID);
            exclusiveGateway     = modelInstance.getModelElementById(EXCLUSIVE_GATEWAY);
            startEvent           = modelInstance.getModelElementById(START_EVENT_ID + 2);
            sequenceFlow         = modelInstance.getModelElementById(SEQUENCE_FLOW_ID + 3);
            messageFlow          = modelInstance.getModelElementById(MESSAGE_FLOW_ID);
            dataInputAssociation = modelInstance.getModelElementById(DATA_INPUT_ASSOCIATION_ID);
            association          = modelInstance.getModelElementById(ASSOCIATION_ID);
            endEvent             = modelInstance.getModelElementById(END_EVENT_ID + 2);
        }
示例#8
0
        public virtual void ValidateExclusiveGateway(Process process, ExclusiveGateway exclusiveGateway, IList <ValidationError> errors)
        {
            if (exclusiveGateway.OutgoingFlows.Count == 0)
            {
                AddError(errors, ProblemsConstants.EXCLUSIVE_GATEWAY_NO_OUTGOING_SEQ_FLOW, process, exclusiveGateway, ProcessValidatorResource.EXCLUSIVE_GATEWAY_NO_OUTGOING_SEQ_FLOW);
            }
            else if (exclusiveGateway.OutgoingFlows.Count == 1)
            {
                SequenceFlow sequenceFlow = exclusiveGateway.OutgoingFlows[0];
                if (!string.IsNullOrWhiteSpace(sequenceFlow.ConditionExpression))
                {
                    AddError(errors, ProblemsConstants.EXCLUSIVE_GATEWAY_CONDITION_NOT_ALLOWED_ON_SINGLE_SEQ_FLOW, process, exclusiveGateway, ProcessValidatorResource.EXCLUSIVE_GATEWAY_CONDITION_NOT_ALLOWED_ON_SINGLE_SEQ_FLOW);
                }
            }
            else
            {
                string defaultSequenceFlow = exclusiveGateway.DefaultFlow;

                IList <SequenceFlow> flowsWithoutCondition = new List <SequenceFlow>();
                foreach (SequenceFlow flow in exclusiveGateway.OutgoingFlows)
                {
                    string condition     = flow.ConditionExpression;
                    bool   isDefaultFlow = flow.Id is object && flow.Id.Equals(defaultSequenceFlow);
                    bool   hasConditon   = !string.IsNullOrWhiteSpace(condition);

                    if (!hasConditon && !isDefaultFlow)
                    {
                        flowsWithoutCondition.Add(flow);
                    }
                    if (hasConditon && isDefaultFlow)
                    {
                        AddError(errors, ProblemsConstants.EXCLUSIVE_GATEWAY_CONDITION_ON_DEFAULT_SEQ_FLOW, process, exclusiveGateway, ProcessValidatorResource.EXCLUSIVE_GATEWAY_CONDITION_ON_DEFAULT_SEQ_FLOW);
                    }
                }

                if (flowsWithoutCondition.Count > 0)
                {
                    AddWarning(errors, ProblemsConstants.EXCLUSIVE_GATEWAY_SEQ_FLOW_WITHOUT_CONDITIONS, process, exclusiveGateway, ProcessValidatorResource.EXCLUSIVE_GATEWAY_SEQ_FLOW_WITHOUT_CONDITIONS);
                }
            }
        }
示例#9
0
        private void CombineLinkedMergeNodes()
        {
            List <SequenceFlow>  sequenceFlows = trail.GetSequenceFlowsBetweenMergeNodes();
            Queue <SequenceFlow> seqQueue      = new Queue <SequenceFlow>();

            sequenceFlows.ForEach(seqQueue.Enqueue);
            SequenceFlow     curr     = null;
            ExclusiveGateway firstEg  = null;
            ExclusiveGateway secondEg = null;

            while (seqQueue.Count > 0)
            {
                curr     = seqQueue.Dequeue();
                firstEg  = trail.GetExclusiveGateWay(curr.sourceRef);
                secondEg = trail.GetExclusiveGateWay(curr.targetRef);
                firstEg.incoming.ForEach(x =>
                {
                    secondEg.incoming.Add(x);
                    trail.ChangeTargetRefOnSequenceFlow(x, secondEg.id);
                });
                firstEg.incoming.RemoveAll(x => true);
                trail.RemoveEventWithSequences(firstEg.id);
            }
        }
        // private static Logger log = LoggerFactory.getLogger(typeof(ExclusiveGatewayActivityBehavior));

        /// <summary>
        /// The default behaviour of BPMN, taking every outgoing sequence flow (where the condition evaluates to true), is not valid for an exclusive gateway.
        ///
        /// Hence, this behaviour is overridden and replaced by the correct behavior: selecting the first sequence flow which condition evaluates to true (or which hasn't got a condition) and leaving the
        /// activity through that sequence flow.
        ///
        /// If no sequence flow is selected (ie all conditions evaluate to false), then the default sequence flow is taken (if defined).
        /// </summary>
        public override void Leave(IExecutionEntity execution)
        {
            if (log.IsEnabled(LogLevel.Debug))
            {
                log.LogDebug($"Leaving exclusive gateway '{execution.CurrentActivityId}'");
            }

            ExclusiveGateway exclusiveGateway = (ExclusiveGateway)execution.CurrentFlowElement;

            ProcessEngineConfigurationImpl processEngineConfiguration = Context.ProcessEngineConfiguration;

            if (processEngineConfiguration is object && processEngineConfiguration.EventDispatcher.Enabled)
            {
                processEngineConfiguration.EventDispatcher.DispatchEvent(ActivitiEventBuilder.CreateActivityEvent(ActivitiEventType.ACTIVITY_COMPLETED, exclusiveGateway.Id, exclusiveGateway.Name, execution.Id, execution.ProcessInstanceId, execution.ProcessDefinitionId, exclusiveGateway));
            }

            SequenceFlow outgoingSequenceFlow  = null;
            SequenceFlow defaultSequenceFlow   = null;
            string       defaultSequenceFlowId = exclusiveGateway.DefaultFlow;

            // Determine sequence flow to take
            foreach (SequenceFlow sequenceFlow in exclusiveGateway.OutgoingFlows)
            {
                string skipExpressionString = sequenceFlow.SkipExpression;
                if (!SkipExpressionUtil.IsSkipExpressionEnabled(execution, skipExpressionString))
                {
                    bool conditionEvaluatesToTrue = ConditionUtil.HasTrueCondition(sequenceFlow, execution);
                    if (conditionEvaluatesToTrue && (defaultSequenceFlowId is null || !defaultSequenceFlowId.Equals(sequenceFlow.Id)))
                    {
                        if (log.IsEnabled(LogLevel.Debug))
                        {
                            log.LogDebug($"Sequence flow '{sequenceFlow.Id}'selected as outgoing sequence flow.");
                        }
                        outgoingSequenceFlow = sequenceFlow;
                        break;
                    }
                }
                else if (SkipExpressionUtil.ShouldSkipFlowElement(Context.CommandContext, execution, skipExpressionString))
                {
                    outgoingSequenceFlow = sequenceFlow;
                    break;
                }

                // Already store it, if we would need it later. Saves one for loop.
                if (defaultSequenceFlowId is object && defaultSequenceFlowId.Equals(sequenceFlow.Id))
                {
                    defaultSequenceFlow = sequenceFlow;
                }
            }

            // We have to record the end here, or else we're already past it
            Context.CommandContext.HistoryManager.RecordActivityEnd(execution, null);

            // Leave the gateway
            if (outgoingSequenceFlow != null)
            {
                execution.CurrentFlowElement = outgoingSequenceFlow;

                log.LogInformation($"条件表达式:id={outgoingSequenceFlow.Id} expression={outgoingSequenceFlow.ConditionExpression}");
            }
            else
            {
                if (defaultSequenceFlow != null)
                {
                    execution.CurrentFlowElement = defaultSequenceFlow;

                    log.LogInformation($"条件表达式:id={defaultSequenceFlow.Id} expression={defaultSequenceFlow.ConditionExpression}");
                }
                else
                {
                    // No sequence flow could be found, not even a default one
                    throw new ActivitiException("No outgoing sequence flow of the exclusive gateway '" + exclusiveGateway.Id + "' could be selected for continuing the process");
                }
            }

            base.Leave(execution);
        }
示例#11
0
        public void XorGwProcess()
        {
            var startNode = new StartNode("1. Submit claim");
            var xorGw = new ExclusiveGateway<string>("X. Decide", (e => transitionState));
            var n2 = new Activity("2. Alternative A");
            var n3 = new Activity("3. Alternative B");
            var n4 = new Activity("D. Default");
            var endNode = new EndNode("4. Closed");

            var t1gw = new SequenceFlow(startNode, xorGw);
            var tgw2 = new ConditionalFlow<string>(xorGw, n2, "a");
            var tgw3 = new ConditionalFlow<string>(xorGw, n3, "b");
            var tgw4 = new DefaultFlow(xorGw, n4);
            var t2End = new SequenceFlow(n2, endNode);
            var t3End = new SequenceFlow(n3, endNode);
            var t4End = new SequenceFlow(n4, endNode);

            this.process = new Process(startNode);
        }
示例#12
0
        private BPMNTrail FixMergeGateLocationsInRepeatedSequences(List <string> repSeq, Tuple <int, List <int> > startLocs, List <string> trace, BPMNTrail workingTrail)
        {
            string        idString  = string.Empty;
            List <string> repSeqIds = new List <string>();
            List <string> ids       = new List <string>();

            for (int i = 0; i < repSeq.Count + startLocs.Item1; i++)
            {
                idString += trace[i];
                if (i >= startLocs.Item1)
                {
                    repSeqIds.Add(idString);
                }
            }
            if (!(repSeqIds[0] + repSeqIds[0]).Equals(repSeqIds[1]))
            {
                foreach (int pos in startLocs.Item2)
                {
                    idString = string.Empty;
                    for (int i = 0; i < pos + repSeq.Count; i++)
                    {
                        idString += trace[i];
                        if (i >= pos)
                        {
                            ids.Add(idString);
                        }
                    }
                }

                Task             current     = workingTrail.GetTask(repSeqIds.Last <string>());
                Task             helperTask1 = null;
                Task             helperTask2 = null;
                ExclusiveGateway eg          = null;
                SequenceFlow     seqFlow     = null;
                int    index  = 0;
                string nextId = ids[0];
                string helper = string.Empty;
                while (!current.id.Equals(ids.Last <string>()))
                {
                    helper = workingTrail.GetSequenceFlow(current.outgoing[0]).targetRef;
                    if (helper.Equals(nextId))
                    {
                        if (!nextId.Equals(ids.Last <string>()))
                        {
                            nextId = ids[index += 1];
                        }
                        current = workingTrail.GetTask(helper);
                    }
                    else if (workingTrail.ExclusiveGatewayExists(helper))
                    {
                        eg = workingTrail.GetExclusiveGateWay(helper);
                        foreach (string s in eg.outgoing)
                        {
                            helper = workingTrail.GetSequenceFlow(s).targetRef;
                            if (helper.Equals(nextId))
                            {
                                seqFlow     = workingTrail.GetSequenceFlow(s);
                                helperTask1 = workingTrail.GetTask(helper);
                                helperTask2 = workingTrail.GetTaskByNameIfIdInList(helperTask1.name, repSeqIds);
                                if (!repSeqIds.Contains(current.id))
                                {
                                    workingTrail.MoveMergeGate(eg.id, workingTrail.GetSequenceFlowByTargetRefId(helperTask2.id).sourceRef, helperTask1.id);
                                }
                                if (!nextId.Equals(ids.Last <string>()))
                                {
                                    nextId = ids[index += 1];
                                }
                                current = helperTask1;
                                break;
                            }
                        }
                    }
                }
            }

            return(workingTrail);
        }
        // Gateways

        public virtual ExclusiveGatewayActivityBehavior CreateExclusiveGatewayActivityBehavior(ExclusiveGateway exclusiveGateway)
        {
            return(new ExclusiveGatewayActivityBehavior());
        }
 public ExclusiveGatewayConverter(ExclusiveGateway gatewayElement, ProcessConverter converterService)
 {
     this.gatewayElement = gatewayElement;
     processConverter    = converterService;
 }
示例#15
0
 protected internal AbstractExclusiveGatewayBuilder(BpmnModelInstance modelInstance, ExclusiveGateway element, Type selfType) : base(modelInstance, element, selfType)
 {
 }
示例#16
0
 public ExclusiveGatewayConverter(ExclusiveGateway gateway)
 {
     this.gateway = gateway;
 }