コード例 #1
0
        private List <Association> FindAssociationsWithTargetRefRecursive(IFlowElementsContainer flowElementsContainer, string targetRef)
        {
            List <Association> associations = new List <Association>();

            foreach (Artifact artifact in flowElementsContainer.GetArtifacts())
            {
                if (artifact is Association)
                {
                    Association association = (Association)artifact;
                    if (association.TargetRef != null && association.TargetRef == targetRef)
                    {
                        associations.Add(association);
                    }
                }
            }

            foreach (FlowElement flowElement in flowElementsContainer.GetFlowElements())
            {
                if (flowElement is IFlowElementsContainer)
                {
                    associations.AddRange(FindAssociationsWithTargetRefRecursive((IFlowElementsContainer)flowElement, targetRef));
                }
            }
            return(associations);
        }
コード例 #2
0
        public override object Create(IFlowElementsContainer parent, IParseContext context, XElement element)
        {
            var task = context.BpmnFactory.CreateReceiveTask();

            parent.FlowElements.Add(task);

            task.Implementation = element.GetAttribute("implementation");

            var operationRef = element.GetAttribute("operationRef");

            if (operationRef != null)
            {
                context.AddReferenceRequest(operationRef, (Operation operation) => task.OperationRef = operation);
            }

            var messageRef = element.GetAttribute("messageRef");

            if (messageRef != null)
            {
                context.AddReferenceRequest(messageRef, (Message message) => task.MessageRef = message);
            }
            //Instantiate

            base.Init(task, context, element);

            return(task);
        }
コード例 #3
0
        public override object Create(IFlowElementsContainer parent, IParseContext context, XElement element)
        {
            var dataObjectReference = context.BpmnFactory.CreateDataObjectReference();

            parent.FlowElements.Add(dataObjectReference);

            //dataObjectReference.Name = element.GetAttribute("name");

            var dataObjectRef = element.GetAttribute("dataObjectRef");

            if (dataObjectRef != null)
            {
                context.AddReferenceRequest <DataObject>(dataObjectRef, x => dataObjectReference.DataObjectRef = x);
            }

            var itemSubjectRef = element.GetAttribute("itemSubjectRef");

            if (itemSubjectRef != null)
            {
                context.AddReferenceRequest <ItemDefinition>(itemSubjectRef, x => dataObjectReference.ItemSubjectRef = x);
            }

            base.Init(dataObjectReference, context, element);

            return(dataObjectRef);
        }
コード例 #4
0
        public override object Create(IFlowElementsContainer parent, IParseContext context, XElement element)
        {
            var task = context.BpmnFactory.CreateManualTask();

            parent.FlowElements.Add(task);

            return(task);
        }
コード例 #5
0
ファイル: Process.cs プロジェクト: wangpengxpy/nactivity
 protected internal virtual IFlowElementsContainer GetFlowElementsContainer(IFlowElementsContainer flowElementsContainer, string flowElementId)
 {
     foreach (FlowElement flowElement in flowElementsContainer.FlowElements)
     {
         if (!(flowElement.Id is null) && flowElement.Id.Equals(flowElementId))
         {
             return(flowElementsContainer);
         }
コード例 #6
0
        public override object Create(IFlowElementsContainer parent, IParseContext context, XElement element)
        {
            var adHocSubProcess = context.BpmnFactory.CreateAdHocSubProcess();

            parent.FlowElements.Add(adHocSubProcess);

            base.Init(adHocSubProcess, context, element);

            return(adHocSubProcess);
        }
コード例 #7
0
        public override object Create(IFlowElementsContainer parent, IParseContext context, XElement element)
        {
            var gateway = context.BpmnFactory.CreateComplexGateway();

            parent.FlowElements.Add(gateway);

            base.Init(gateway, context, element);

            return(gateway);
        }
コード例 #8
0
        public override object Create(IFlowElementsContainer parent, IParseContext context, XElement element)
        {
            var endEvent = context.BpmnFactory.CreateEndEvent();

            parent.FlowElements.Add(endEvent);

            base.Init(endEvent, context, element);

            return(endEvent);
        }
コード例 #9
0
        public override object Create(IFlowElementsContainer parent, IParseContext context, XElement element)
        {
            var transaction = context.BpmnFactory.CreateTransaction();

            parent.FlowElements.Add(transaction);

            base.Init(transaction, context, element);

            return(transaction);
        }
コード例 #10
0
        protected internal override void ExecuteValidation(BpmnModel bpmnModel, Process process, IList <ValidationError> errors)
        {
            IList <SequenceFlow> sequenceFlows = process.FindFlowElementsOfType <SequenceFlow>();

            foreach (SequenceFlow sequenceFlow in sequenceFlows)
            {
                string sourceRef = sequenceFlow.SourceRef;
                string targetRef = sequenceFlow.TargetRef;

                if (string.IsNullOrWhiteSpace(sourceRef))
                {
                    AddError(errors, ProblemsConstants.SEQ_FLOW_INVALID_SRC, process, sequenceFlow, ProcessValidatorResource.SEQ_FLOW_INVALID_SRC);
                }
                if (string.IsNullOrWhiteSpace(targetRef))
                {
                    AddError(errors, ProblemsConstants.SEQ_FLOW_INVALID_TARGET, process, sequenceFlow, ProcessValidatorResource.SEQ_FLOW_INVALID_TARGET);
                }

                // Implicit check: sequence flow cannot cross (sub) process
                // boundaries, hence we check the parent and not the process
                // (could be subprocess for example)
                FlowElement source = process.GetFlowElement(sourceRef, true);
                FlowElement target = process.GetFlowElement(targetRef, true);

                // Src and target validation
                if (source == null)
                {
                    AddError(errors, ProblemsConstants.SEQ_FLOW_INVALID_SRC, process, sequenceFlow, ProcessValidatorResource.SEQ_FLOW_INVALID_SRC);
                }
                if (target == null)
                {
                    AddError(errors, ProblemsConstants.SEQ_FLOW_INVALID_TARGET, process, sequenceFlow, ProcessValidatorResource.SEQ_FLOW_INVALID_TARGET);
                }

                if (source != null && target != null)
                {
                    IFlowElementsContainer sourceContainer = process.GetFlowElementsContainer(source.Id);
                    IFlowElementsContainer targetContainer = process.GetFlowElementsContainer(target.Id);

                    if (sourceContainer == null)
                    {
                        AddError(errors, ProblemsConstants.SEQ_FLOW_INVALID_SRC, process, sequenceFlow, ProcessValidatorResource.SEQ_FLOW_INVALID_SRC);
                    }
                    if (targetContainer == null)
                    {
                        AddError(errors, ProblemsConstants.SEQ_FLOW_INVALID_TARGET, process, sequenceFlow, ProcessValidatorResource.SEQ_FLOW_INVALID_TARGET);
                    }
                    if (sourceContainer != null && targetContainer != null && !sourceContainer.Equals(targetContainer))
                    {
                        AddError(errors, ProblemsConstants.SEQ_FLOW_INVALID_TARGET, process, sequenceFlow, ProcessValidatorResource.SEQ_FLOW_INVALID_TARGET);
                    }
                }
            }
        }
コード例 #11
0
        public override object Create(IFlowElementsContainer parent, IParseContext context, XElement element)
        {
            var startEvent = context.BpmnFactory.CreateStartEvent();

            parent.FlowElements.Add(startEvent);

            startEvent.IsInterrupting = element.GetBoolean("isInterrupting");

            base.Init(startEvent, context, element);

            return(startEvent);
        }
コード例 #12
0
        public override object Create(IFlowElementsContainer parent, IParseContext context, XElement element)
        {
            var userTask = context.BpmnFactory.CreateUserTask();

            userTask.Implementation = element.GetAttribute("implementation");

            parent.FlowElements.Add(userTask);

            base.Init(userTask, context, element);

            return(userTask);
        }
コード例 #13
0
        public override object Create(IFlowElementsContainer parent, IParseContext context, XElement element)
        {
            var task = context.BpmnFactory.CreateScriptTask();

            parent.FlowElements.Add(task);

            task.ScriptFormat = element.GetAttribute("scriptFormat");

            base.Init(task, context, element);

            return(task);
        }
コード例 #14
0
        public override object Create(IFlowElementsContainer parent, IParseContext context, XElement element)
        {
            var gateway = context.BpmnFactory.CreateEventBasedGateway();

            gateway.Instantiate      = element.GetBoolean("instantiate");
            gateway.EventGatewayType = element.GetEnum <EventBasedGatewayType>("eventGatewayType", EventBasedGatewayType.Exclusive);

            parent.FlowElements.Add(gateway);

            base.Init(gateway, context, element);

            return(gateway);
        }
コード例 #15
0
        public override object Create(IFlowElementsContainer parent, IParseContext context, XElement element)
        {
            var callActivity = context.BpmnFactory.CreateCallActivity();

            parent.FlowElements.Add(callActivity);

            var calledElement = element.GetAttribute("calledElement");

            callActivity.CalledElement = calledElement;

            base.Init(callActivity, context, element);

            return(callActivity);
        }
コード例 #16
0
        public static bool IsReachable(Process process, FlowNode sourceElement, FlowNode targetElement, ISet <string> visitedElements)
        {
            // No outgoing seq flow: could be the end of eg . the process or an embedded subprocess
            if (sourceElement.OutgoingFlows.Count == 0)
            {
                visitedElements.Add(sourceElement.Id);

                IFlowElementsContainer parentElement = process.FindParent(sourceElement);
                if (parentElement is SubProcess)
                {
                    sourceElement = (SubProcess)parentElement;
                }
                else
                {
                    return(false);
                }
            }

            if (sourceElement.Id.Equals(targetElement.Id))
            {
                return(true);
            }

            // To avoid infinite looping, we must capture every node we visit
            // and check before going further in the graph if we have already
            // visited the node.
            visitedElements.Add(sourceElement.Id);

            IList <SequenceFlow> sequenceFlows = sourceElement.OutgoingFlows;

            if (sequenceFlows != null && sequenceFlows.Count > 0)
            {
                foreach (SequenceFlow sequenceFlow in sequenceFlows)
                {
                    string   targetRef          = sequenceFlow.TargetRef;
                    FlowNode sequenceFlowTarget = (FlowNode)process.GetFlowElement(targetRef, true);
                    if (sequenceFlowTarget != null && !visitedElements.Contains(sequenceFlowTarget.Id))
                    {
                        bool reachable = IsReachable(process, sequenceFlowTarget, targetElement, visitedElements);

                        if (reachable)
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
コード例 #17
0
ファイル: Process.cs プロジェクト: zhangzihan/nactivity
 protected internal virtual IFlowElementsContainer GetFlowElementsContainer(IFlowElementsContainer flowElementsContainer, string flowElementId)
 {
     foreach (FlowElement flowElement in flowElementsContainer.FlowElements)
     {
         if (flowElement.Id is object && flowElement.Id.Equals(flowElementId))
         {
             return(flowElementsContainer);
         }
         else if (flowElement is IFlowElementsContainer)
         {
             IFlowElementsContainer result = GetFlowElementsContainer((IFlowElementsContainer)flowElement, flowElementId);
             if (result != null)
             {
                 return(result);
             }
         }
     }
     return(null);
 }
コード例 #18
0
 private IFlowElementsContainer GetFlowElementsContainer(IFlowElementsContainer flowElementsContainer, string flowElementId)
 {
     foreach (FlowElement flowElement in flowElementsContainer.GetFlowElements())
     {
         if (flowElement.Id != null && flowElement.Id == flowElementId)
         {
             return(flowElementsContainer);
         }
         else if (flowElement is IFlowElementsContainer)
         {
             IFlowElementsContainer result = GetFlowElementsContainer((IFlowElementsContainer)flowElement, flowElementId);
             if (result != null)
             {
                 return(result);
             }
         }
     }
     return(null);
 }
コード例 #19
0
ファイル: Process.cs プロジェクト: zhangzihan/nactivity
 public virtual IFlowElementsContainer FindParent(FlowElement childElement, IFlowElementsContainer flowElementsContainer)
 {
     foreach (FlowElement flowElement in flowElementsContainer.FlowElements)
     {
         if (childElement.Id is object && childElement.Id.Equals(flowElement.Id))
         {
             return(flowElementsContainer);
         }
         if (flowElement is IFlowElementsContainer)
         {
             IFlowElementsContainer result = FindParent(childElement, (IFlowElementsContainer)flowElement);
             if (result != null)
             {
                 return(result);
             }
         }
     }
     return(null);
 }
コード例 #20
0
        public override object Create(IFlowElementsContainer parent, IParseContext context, XElement element)
        {
            var sequenceFlow = context.BpmnFactory.CreateSequenceFlow();

            parent.FlowElements.Add(sequenceFlow);

            base.Init(sequenceFlow, context, element);

            var sourceRef = element.GetAttribute("sourceRef");
            var targetRef = element.GetAttribute("targetRef");

            context.AddReferenceRequest(sourceRef, (FlowNode node) => sequenceFlow.SourceRef = node);
            context.AddReferenceRequest(targetRef, (FlowNode node) => sequenceFlow.TargetRef = node);

            context.AddSourceRef(sourceRef, sequenceFlow);
            context.AddTargetRef(targetRef, sequenceFlow);

            return(sequenceFlow);
        }
コード例 #21
0
 public IFlowElementsContainer FindParent(FlowElement childElement, IFlowElementsContainer flowElementsContainer)
 {
     foreach (FlowElement flowElement in flowElementsContainer.GetFlowElements())
     {
         if (childElement.Id != null && childElement.Id == flowElement.Id)
         {
             return(flowElementsContainer);
         }
         if (flowElement is IFlowElementsContainer)
         {
             IFlowElementsContainer result = FindParent(childElement, (IFlowElementsContainer)flowElement);
             if (result != null)
             {
                 return(result);
             }
         }
     }
     return(null);
 }
コード例 #22
0
        public override object Create(IFlowElementsContainer parent, IParseContext context, XElement element)
        {
            var dataObject = context.BpmnFactory.CreateDataObject() as ValuedDataObject;

            parent.FlowElements.Add(dataObject);

            //dataObject.Name = element.GetAttribute("name");
            dataObject.IsCollection = element.GetBoolean("isCollection");
            var itemSubjectRef = element.GetAttribute("itemSubjectRef");

            dataObject.TypeName = itemSubjectRef;

            if (itemSubjectRef != null)
            {
                context.AddReferenceRequest <ItemDefinition>(itemSubjectRef, x => dataObject.ItemSubjectRef = x);
            }

            base.Init(dataObject, context, element);

            return(dataObject);
        }
コード例 #23
0
        protected internal override void ExecuteValidation(BpmnModel bpmnModel, Process process, IList <ValidationError> errors)
        {
            IList <EndEvent> endEvents = process.FindFlowElementsOfType <EndEvent>();

            foreach (EndEvent endEvent in endEvents)
            {
                if (endEvent.EventDefinitions != null && endEvent.EventDefinitions.Count > 0)
                {
                    EventDefinition eventDefinition = endEvent.EventDefinitions[0];

                    // Error end event
                    if (eventDefinition is CancelEventDefinition)
                    {
                        IFlowElementsContainer parent = process.FindParent(endEvent);
                        if (!(parent is Transaction))
                        {
                            AddError(errors, ProblemsConstants.END_EVENT_CANCEL_ONLY_INSIDE_TRANSACTION, process, endEvent, ProcessValidatorResource.END_EVENT_CANCEL_ONLY_INSIDE_TRANSACTION);
                        }
                    }
                }
            }
        }
コード例 #24
0
ファイル: Process.cs プロジェクト: zhangzihan/nactivity
        protected internal virtual IList <Association> FindAssociationsWithTargetRefRecursive(IFlowElementsContainer flowElementsContainer, string targetRef)
        {
            IList <Association> associations = new List <Association>();

            foreach (Artifact artifact in flowElementsContainer.Artifacts)
            {
                if (artifact is Association association)
                {
                    if (association.TargetRef is object && association.TargetRef.Equals(targetRef))
                    {
                        associations.Add(association);
                    }
                }
            }

            foreach (FlowElement flowElement in flowElementsContainer.FlowElements)
            {
                if (flowElement is IFlowElementsContainer)
                {
                    ((List <Association>)associations).AddRange(FindAssociationsWithTargetRefRecursive((IFlowElementsContainer)flowElement, targetRef));
                }
            }
            return(associations);
        }
コード例 #25
0
 public FlowElementCollection(IFlowElementsContainer container)
 {
     this.container = container;
 }
コード例 #26
0
ファイル: FlowElementScope.cs プロジェクト: yb411521921/bpmtk
 public FlowElementScope(IFlowElementsContainer Container)
 {
     this.Container = Container;
 }
コード例 #27
0
        protected internal static void ExecuteCatch(IDictionary <string, IList <Event> > eventMap, IExecutionEntity delegateExecution, string errorId)
        {
            Event            matchingEvent    = null;
            IExecutionEntity currentExecution = delegateExecution;
            IExecutionEntity parentExecution;

            if ((eventMap?.ContainsKey(currentExecution.ActivityId)).GetValueOrDefault(false))
            {
                matchingEvent = eventMap[currentExecution.ActivityId][0];

                // Check for multi instance
                if (currentExecution.ParentId is object && currentExecution.Parent.IsMultiInstanceRoot)
                {
                    parentExecution = currentExecution.Parent;
                }
                else
                {
                    parentExecution = currentExecution;
                }
            }
            else
            {
                parentExecution = currentExecution.Parent;

                // Traverse parents until one is found that is a scope and matches the activity the boundary event is defined on
                while (matchingEvent == null && parentExecution != null)
                {
                    IFlowElementsContainer currentContainer = null;
                    if (parentExecution.CurrentFlowElement is IFlowElementsContainer)
                    {
                        currentContainer = (IFlowElementsContainer)parentExecution.CurrentFlowElement;
                    }
                    else if (parentExecution.Id.Equals(parentExecution.ProcessInstanceId))
                    {
                        currentContainer = ProcessDefinitionUtil.GetProcess(parentExecution.ProcessDefinitionId);
                    }

                    foreach (string refId in eventMap.Keys)
                    {
                        IList <Event> events = eventMap[refId];
                        if (CollectionUtil.IsNotEmpty(events) && events[0] is StartEvent)
                        {
                            if (currentContainer.FindFlowElement(refId) != null)
                            {
                                matchingEvent = events[0];
                            }
                        }
                    }

                    if (matchingEvent == null)
                    {
                        if ((eventMap?.ContainsKey(parentExecution.ActivityId)).GetValueOrDefault(false))
                        {
                            matchingEvent = eventMap[parentExecution.ActivityId][0];

                            // Check for multi instance
                            if (parentExecution.ParentId is object && parentExecution.Parent.IsMultiInstanceRoot)
                            {
                                parentExecution = parentExecution.Parent;
                            }
                        }
                        else if (!string.IsNullOrWhiteSpace(parentExecution.ParentId))
                        {
                            parentExecution = parentExecution.Parent;
                        }
                        else
                        {
                            parentExecution = null;
                        }
                    }
                }
            }

            if (matchingEvent != null && parentExecution != null)
            {
                ExecuteEventHandler(matchingEvent, parentExecution, currentExecution, errorId);
            }
            else
            {
                throw new ActivitiException("No matching parent execution for error code " + errorId + " found");
            }
        }