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); }
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); }
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); }
public override object Create(IFlowElementsContainer parent, IParseContext context, XElement element) { var task = context.BpmnFactory.CreateManualTask(); parent.FlowElements.Add(task); return(task); }
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); }
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); }
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); }
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); }
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); }
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); } } } }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); } } } } }
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); }
public FlowElementCollection(IFlowElementsContainer container) { this.container = container; }
public FlowElementScope(IFlowElementsContainer Container) { this.Container = Container; }
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"); } }