protected internal override void ExecuteParse(BpmnParse bpmnParse, StartEvent element) { if (element.SubProcess != null && element.SubProcess is EventSubProcess) { if (CollectionUtil.IsNotEmpty(element.EventDefinitions)) { EventDefinition eventDefinition = element.EventDefinitions[0]; if (eventDefinition is MessageEventDefinition messageDefinition) { BpmnModel bpmnModel = bpmnParse.BpmnModel; string messageRef = messageDefinition.MessageRef; if (bpmnModel.ContainsMessageId(messageRef)) { Message message = bpmnModel.GetMessage(messageRef); messageDefinition.MessageRef = message.Name; messageDefinition.ExtensionElements = message.ExtensionElements; } element.Behavior = bpmnParse.ActivityBehaviorFactory.CreateEventSubProcessMessageStartEventActivityBehavior(element, messageDefinition); } else if (eventDefinition is ErrorEventDefinition) { element.Behavior = bpmnParse.ActivityBehaviorFactory.CreateEventSubProcessErrorStartEventActivityBehavior(element); } } } else if (CollectionUtil.IsEmpty(element.EventDefinitions)) { element.Behavior = bpmnParse.ActivityBehaviorFactory.CreateNoneStartEventActivityBehavior(element); } if (element.SubProcess == null && (CollectionUtil.IsEmpty(element.EventDefinitions) || bpmnParse.CurrentProcess.InitialFlowElement == null)) { bpmnParse.CurrentProcess.InitialFlowElement = element; } }
public virtual void Parse(XMLStreamReader xtr, BpmnModel model) { string resourceId = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_ID); string resourceName = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_NAME); Resource resource; if (model.ContainsResourceId(resourceId)) { resource = model.GetResource(resourceId); resource.Name = resourceName; foreach (Process process in model.Processes) { foreach (FlowElement fe in process.FlowElements) { if (fe is UserTask && ((UserTask)fe).CandidateGroups.Contains(resourceId)) { ((UserTask)fe).CandidateGroups.Remove(resourceId); ((UserTask)fe).CandidateGroups.Add(resourceName); } } } } else { resource = new Resource(resourceId, resourceName); model.AddResource(resource); } BpmnXMLUtil.AddXMLLocation(resource, xtr); }
protected internal virtual string ParseMessageRef(string messageRef, BpmnModel model) { string result = null; if (!string.IsNullOrWhiteSpace(messageRef)) { int indexOfP = messageRef.IndexOf(':'); if (indexOfP != -1) { string prefix = messageRef.Substring(0, indexOfP); string resolvedNamespace = model.GetNamespace(prefix); messageRef = messageRef.Substring(indexOfP + 1); if (resolvedNamespace is null) { // if it's an invalid prefix will consider this is not a // namespace prefix so will be used as part of the // stringReference messageRef = prefix + ":" + messageRef; } else if (!resolvedNamespace.Equals(model.TargetNamespace, StringComparison.CurrentCultureIgnoreCase)) { // if it's a valid namespace prefix but it's not the // targetNamespace then we'll use it as a valid namespace // (even out editor does not support defining namespaces it // is still a valid xml file) messageRef = resolvedNamespace + ":" + messageRef; } } result = messageRef; } return(result); }
protected internal override void ExecuteParse(BpmnParse bpmnParse, MessageEventDefinition messageDefinition) { BpmnModel bpmnModel = bpmnParse.BpmnModel; string messageRef = messageDefinition.MessageRef; if (bpmnModel.ContainsMessageId(messageRef)) { Message message = bpmnModel.GetMessage(messageRef); messageDefinition.MessageRef = message.Name; messageDefinition.ExtensionElements = message.ExtensionElements; } if (bpmnParse.CurrentFlowElement is IntermediateCatchEvent intermediateCatchEvent) { intermediateCatchEvent.Behavior = bpmnParse.ActivityBehaviorFactory.CreateIntermediateCatchMessageEventActivityBehavior(intermediateCatchEvent, messageDefinition); } else if (bpmnParse.CurrentFlowElement is BoundaryEvent boundaryEvent) { boundaryEvent.Behavior = bpmnParse.ActivityBehaviorFactory.CreateBoundaryMessageEventActivityBehavior(boundaryEvent, messageDefinition, boundaryEvent.CancelActivity); } else { // What to do here? } }
public virtual void Parse(XMLStreamReader xtr, BpmnModel model) { string id = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_ID); if (!string.IsNullOrWhiteSpace(id)) { DataStore dataStore = new DataStore(); dataStore.Id = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_ID); string name = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_NAME); if (!string.IsNullOrWhiteSpace(name)) { dataStore.Name = name; } string itemSubjectRef = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_ITEM_SUBJECT_REF); if (!string.IsNullOrWhiteSpace(itemSubjectRef)) { dataStore.ItemSubjectRef = itemSubjectRef; } BpmnXMLUtil.AddXMLLocation(dataStore, xtr); model.AddDataStore(dataStore.Id, dataStore); BpmnXMLUtil.ParseChildElements(BpmnXMLConstants.ELEMENT_DATA_STORE, dataStore, xtr, model); } }
public virtual void Parse(XMLStreamReader xtr, BpmnModel model) { model.TargetNamespace = xtr.GetAttributeValue(BpmnXMLConstants.TARGET_NAMESPACE_ATTRIBUTE); for (int i = 0; i < xtr.NamespaceCount; i++) { string prefix = xtr.GetNamespacePrefix(i); if (!string.IsNullOrWhiteSpace(prefix)) { model.AddNamespace(prefix, xtr.GetNamespaceURI(i)); } } for (int i = 0; i < xtr.AttributeCount; i++) { var attr = xtr.element.Attributes().ElementAt(i); ExtensionAttribute extensionAttribute = new ExtensionAttribute { Name = attr.Name.LocalName, Value = attr.Value }; if (!string.IsNullOrWhiteSpace(attr.Name.NamespaceName)) { extensionAttribute.Namespace = attr.Name.NamespaceName; } if (!string.IsNullOrWhiteSpace(xtr.element.GetPrefixOfNamespace(attr.Name.Namespace))) { extensionAttribute.NamespacePrefix = xtr.element.GetPrefixOfNamespace(attr.Name.Namespace); } if (!BpmnXMLUtil.IsBlacklisted(extensionAttribute, defaultAttributes)) { model.AddDefinitionsAttribute(extensionAttribute); } } }
protected internal override void ExecuteValidation(BpmnModel bpmnModel, Process process, IList <ValidationError> errors) { IList <Event> events = process.FindFlowElementsOfType <Event>(); foreach (Event @event in events) { if (@event.EventDefinitions != null) { foreach (EventDefinition eventDefinition in @event.EventDefinitions) { if (eventDefinition is MessageEventDefinition) { HandleMessageEventDefinition(bpmnModel, process, @event, eventDefinition, errors); } else if (eventDefinition is SignalEventDefinition) { HandleSignalEventDefinition(bpmnModel, process, @event, eventDefinition, errors); } else if (eventDefinition is TimerEventDefinition) { HandleTimerEventDefinition(process, @event, eventDefinition, errors); } else if (eventDefinition is CompensateEventDefinition) { HandleCompensationEventDefinition(bpmnModel, process, @event, eventDefinition, errors); } } } } }
protected internal override void ExecuteValidation(BpmnModel bpmnModel, Process process, IList <ValidationError> errors) { IList <SubProcess> subProcesses = process.FindFlowElementsOfType <SubProcess>(); foreach (SubProcess subProcess in subProcesses) { if (!(subProcess is EventSubProcess)) { // Verify start events IList <StartEvent> startEvents = process.FindFlowElementsInSubProcessOfType <StartEvent>(subProcess, false); if (startEvents.Count > 1) { AddError(errors, ProblemsConstants.SUBPROCESS_MULTIPLE_START_EVENTS, process, subProcess, ProcessValidatorResource.SUBPROCESS_MULTIPLE_START_EVENTS); } foreach (StartEvent startEvent in startEvents) { if (startEvent.EventDefinitions.Count > 0) { AddError(errors, ProblemsConstants.SUBPROCESS_START_EVENT_EVENT_DEFINITION_NOT_ALLOWED, process, startEvent, ProcessValidatorResource.SUBPROCESS_START_EVENT_EVENT_DEFINITION_NOT_ALLOWED); } } } } }
protected override void ExecuteValidation(BpmnModel bpmnModel, BPMN.Model.Process process, List <ValidationError> errors) { List <EventListener> eventListeners = process.EventListeners; if (eventListeners != null) { foreach (EventListener eventListener in eventListeners) { if (eventListener.ImplementationType != null && eventListener.ImplementationType == ImplementationType.IMPLEMENTATION_TYPE_INVALID_THROW_EVENT) { AddError(errors, Problems.EVENT_LISTENER_INVALID_THROW_EVENT_TYPE, process, eventListener, "Invalid or unsupported throw event type on event listener"); } else if (eventListener.ImplementationType == null || eventListener.ImplementationType.Length == 0) { AddError(errors, Problems.EVENT_LISTENER_IMPLEMENTATION_MISSING, process, eventListener, "Element 'class', 'delegateExpression' or 'throwEvent' is mandatory on eventListener"); } else if (eventListener.ImplementationType != null) { if (!ImplementationType.IMPLEMENTATION_TYPE_CLASS.Equals(eventListener.ImplementationType) && !ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION.Equals(eventListener.ImplementationType) && !ImplementationType.IMPLEMENTATION_TYPE_THROW_SIGNAL_EVENT.Equals(eventListener.ImplementationType) && !ImplementationType.IMPLEMENTATION_TYPE_THROW_GLOBAL_SIGNAL_EVENT.Equals(eventListener.ImplementationType) && !ImplementationType.IMPLEMENTATION_TYPE_THROW_MESSAGE_EVENT.Equals(eventListener.ImplementationType) && !ImplementationType.IMPLEMENTATION_TYPE_THROW_ERROR_EVENT.Equals(eventListener.ImplementationType)) { AddError(errors, Problems.EVENT_LISTENER_INVALID_IMPLEMENTATION, process, eventListener, "Unsupported implementation type for event listener"); } } } } }
protected internal override void ExecuteValidation(BpmnModel bpmnModel, Process process, IList <ValidationError> errors) { IList <StartEvent> startEvents = process.FindFlowElementsOfType <StartEvent>(false); ValidateEventDefinitionTypes(startEvents, process, errors); ValidateMultipleStartEvents(startEvents, process, errors); }
protected internal override void ExecuteValidation(BpmnModel bpmnModel, Process process, IList <ValidationError> errors) { IList <EventListener> eventListeners = process.EventListeners; if (eventListeners != null) { foreach (EventListener eventListener in eventListeners) { if (string.IsNullOrWhiteSpace(eventListener.ImplementationType) || eventListener.ImplementationType.Equals(ImplementationType.IMPLEMENTATION_TYPE_INVALID_THROW_EVENT)) { AddError(errors, ProblemsConstants.EVENT_LISTENER_INVALID_THROW_EVENT_TYPE, process, eventListener, ProcessValidatorResource.EVENT_LISTENER_INVALID_THROW_EVENT_TYPE); } else if (string.IsNullOrWhiteSpace(eventListener.ImplementationType) || eventListener.ImplementationType.Length == 0) { AddError(errors, ProblemsConstants.EVENT_LISTENER_IMPLEMENTATION_MISSING, process, eventListener, ProcessValidatorResource.EVENT_LISTENER_IMPLEMENTATION_MISSING); } else if (!string.IsNullOrWhiteSpace(eventListener.ImplementationType)) { if (!ImplementationType.IMPLEMENTATION_TYPE_CLASS.Equals(eventListener.ImplementationType) && !ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION.Equals(eventListener.ImplementationType) && !ImplementationType.IMPLEMENTATION_TYPE_THROW_SIGNAL_EVENT.Equals(eventListener.ImplementationType) && !ImplementationType.IMPLEMENTATION_TYPE_THROW_GLOBAL_SIGNAL_EVENT.Equals(eventListener.ImplementationType) && !ImplementationType.IMPLEMENTATION_TYPE_THROW_MESSAGE_EVENT.Equals(eventListener.ImplementationType) && !ImplementationType.IMPLEMENTATION_TYPE_THROW_ERROR_EVENT.Equals(eventListener.ImplementationType)) { AddError(errors, ProblemsConstants.EVENT_LISTENER_INVALID_IMPLEMENTATION, process, eventListener, ProcessValidatorResource.EVENT_LISTENER_IMPLEMENTATION_MISSING); } } } } }
public virtual void DispatchEvent(IActivitiEvent @event) { if (enabled) { eventSupport.DispatchEvent(@event); } if (@event.Type == ActivitiEventType.ENTITY_DELETED && @event is IActivitiEntityEvent) { IActivitiEntityEvent entityEvent = (IActivitiEntityEvent)@event; if (entityEvent.Entity is IProcessDefinition) { // process definition deleted event doesn't need to be dispatched to event listeners return; } } // Try getting hold of the Process definition, based on the process definition key, if a context is active ICommandContext commandContext = Context.CommandContext; if (commandContext != null) { BpmnModel bpmnModel = ExtractBpmnModelFromEvent(@event); if (bpmnModel != null) { ((ActivitiEventSupport)bpmnModel.EventSupport).DispatchEvent(@event); } } }
protected internal virtual void CreateAssociation(BpmnParse bpmnParse, Association association) { BpmnModel bpmnModel = bpmnParse.BpmnModel; if (bpmnModel.GetArtifact(association.SourceRef) != null || bpmnModel.GetArtifact(association.TargetRef) != null) { // connected to a text annotation so skipping it return; } // ActivityImpl sourceActivity = // parentScope.findActivity(association.getSourceRef()); // ActivityImpl targetActivity = // parentScope.findActivity(association.getTargetRef()); // an association may reference elements that are not parsed as // activities (like for instance // text annotations so do not throw an exception if sourceActivity or // targetActivity are null) // However, we make sure they reference 'something': // if (sourceActivity == null) { // bpmnModel.addProblem("Invalid reference sourceRef '" + // association.getSourceRef() + "' of association element ", // association.getId()); // } else if (targetActivity == null) { // bpmnModel.addProblem("Invalid reference targetRef '" + // association.getTargetRef() + "' of association element ", // association.getId()); /* * } else { if (sourceActivity.getProperty("type").equals("compensationBoundaryCatch" )) { Object isForCompensation = targetActivity.getProperty(PROPERTYNAME_IS_FOR_COMPENSATION); if * (isForCompensation == null || !(Boolean) isForCompensation) { logger.warn( "compensation boundary catch must be connected to element with isForCompensation=true" ); } else { ActivityImpl * compensatedActivity = sourceActivity.getParentActivity(); compensatedActivity.setProperty(BpmnParse .PROPERTYNAME_COMPENSATION_HANDLER_ID, targetActivity.getId()); } } } */ }
protected internal virtual void CreateOperations(BpmnModel bpmnModel) { foreach (Interface interfaceObject in bpmnModel.Interfaces) { BpmnInterface bpmnInterface = new BpmnInterface(interfaceObject.Id, interfaceObject.Name) { Implementation = wsServiceMap[interfaceObject.ImplementationRef] }; foreach (Operation operationObject in interfaceObject.Operations) { if (!operationMap.ContainsKey(operationObject.Id)) { MessageDefinition inMessage = messageDefinitionMap[operationObject.InMessageRef]; Webservice.Operation operation = new Webservice.Operation(operationObject.Id, operationObject.Name, bpmnInterface, inMessage) { Implementation = wsOperationMap[operationObject.ImplementationRef] }; if (!string.IsNullOrWhiteSpace(operationObject.OutMessageRef)) { if (messageDefinitionMap.ContainsKey(operationObject.OutMessageRef)) { MessageDefinition outMessage = messageDefinitionMap[operationObject.OutMessageRef]; operation.OutMessage = outMessage; } } operationMap[operation.Id] = operation; } } } }
protected internal virtual void CreateItemDefinitions(BpmnModel bpmnModel) { foreach (ItemDefinition itemDefinitionElement in bpmnModel.ItemDefinitions.Values) { if (!itemDefinitionMap.ContainsKey(itemDefinitionElement.Id)) { IStructureDefinition structure = null; try { // it is a class Type classStructure = ReflectUtil.LoadClass(itemDefinitionElement.StructureRef); structure = new ClassStructureDefinition(classStructure); } catch (ActivitiException) { // it is a reference to a different structure structure = structureDefinitionMap[itemDefinitionElement.StructureRef]; } Datas.ItemDefinition itemDefinition = new Datas.ItemDefinition(itemDefinitionElement.Id, structure); if (!string.IsNullOrWhiteSpace(itemDefinitionElement.ItemKind)) { itemDefinition.ItemKind = (ItemKind)Enum.Parse(typeof(ItemKind), itemDefinitionElement.ItemKind); } itemDefinitionMap[itemDefinition.Id] = itemDefinition; } } }
protected internal virtual void VerifyWebservice(BpmnModel bpmnModel, Process process, ServiceTask serviceTask, IList <ValidationError> errors) { if (ImplementationType.IMPLEMENTATION_TYPE_WEBSERVICE.Equals(serviceTask.ImplementationType, StringComparison.CurrentCultureIgnoreCase) && !string.IsNullOrWhiteSpace(serviceTask.OperationRef)) { bool operationFound = false; if (bpmnModel.Interfaces != null && bpmnModel.Interfaces.Count > 0) { foreach (Interface bpmnInterface in bpmnModel.Interfaces) { if (bpmnInterface.Operations != null && bpmnInterface.Operations.Count > 0) { foreach (Operation operation in bpmnInterface.Operations) { if (operation.Id is object && operation.Id.Equals(serviceTask.OperationRef)) { operationFound = true; } } } } } if (!operationFound) { AddError(errors, ProblemsConstants.SERVICE_TASK_WEBSERVICE_INVALID_OPERATION_REF, process, serviceTask, ProcessValidatorResource.SERVICE_TASK_WEBSERVICE_INVALID_OPERATION_REF); } } }
public override void Validate(BpmnModel bpmnModel, IList <ValidationError> errors) { ICollection <Signal> signals = bpmnModel.Signals; if (signals != null && signals.Count > 0) { foreach (Signal signal in signals) { if (string.IsNullOrWhiteSpace(signal.Id)) { AddError(errors, ProblemsConstants.SIGNAL_MISSING_ID, signal, ProcessValidatorResource.SIGNAL_MISSING_ID); } if (string.IsNullOrWhiteSpace(signal.Name)) { AddError(errors, ProblemsConstants.SIGNAL_MISSING_NAME, signal, ProcessValidatorResource.SIGNAL_MISSING_NAME); } if (!string.IsNullOrWhiteSpace(signal.Name) && DuplicateName(signals, signal.Id, signal.Name)) { AddError(errors, ProblemsConstants.SIGNAL_DUPLICATE_NAME, signal, ProcessValidatorResource.SIGNAL_DUPLICATE_NAME); } if (signal.Scope is object && !signal.Scope.Equals(Signal.SCOPE_GLOBAL) && !signal.Scope.Equals(Signal.SCOPE_PROCESS_INSTANCE)) { AddError(errors, ProblemsConstants.SIGNAL_INVALID_SCOPE, signal, ProcessValidatorResource.SIGNAL_INVALID_SCOPE); } } } }
public virtual void Parse(XMLStreamReader xtr, BpmnModel model) { if (!string.IsNullOrWhiteSpace(xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_ID))) { string itemDefinitionId = model.TargetNamespace + ":" + xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_ID); string structureRef = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_STRUCTURE_REF); if (!string.IsNullOrWhiteSpace(structureRef)) { ItemDefinition item = new ItemDefinition(); item.Id = itemDefinitionId; BpmnXMLUtil.AddXMLLocation(item, xtr); int indexOfP = structureRef.IndexOf(':'); if (indexOfP != -1) { string prefix = structureRef.Substring(0, indexOfP); string resolvedNamespace = model.GetNamespace(prefix); structureRef = resolvedNamespace + ":" + structureRef.Substring(indexOfP + 1); } else { structureRef = model.TargetNamespace + ":" + structureRef; } item.StructureRef = structureRef; item.ItemKind = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_ITEM_KIND); BpmnXMLUtil.ParseChildElements(BpmnXMLConstants.ELEMENT_ITEM_DEFINITION, item, xtr, model); model.AddItemDefinition(itemDefinitionId, item); } } }
protected internal override void ExecuteValidation(BpmnModel bpmnModel, Process process, IList <ValidationError> errors) { IList <ServiceTask> serviceTasks = process.FindFlowElementsOfType <ServiceTask>(); foreach (ServiceTask serviceTask in serviceTasks) { if (string.IsNullOrWhiteSpace(serviceTask.ImplementationType)) { serviceTask.ExtensionElements.TryGetValue(BpmnXMLConstants.ELEMENT_EXTENSIONS_PROPERTY, out IList <ExtensionElement> pElements); if (pElements == null || pElements.Count == 0 || string.IsNullOrWhiteSpace(pElements.GetAttributeValue("url"))) { AddError(errors, ProblemsConstants.SERVICE_TASK_WEBSERVICE_INVALID_URL, process, serviceTask, ProcessValidatorResource.SERVICE_TASK_WEBSERVICE_INVALID_URL); } if (string.IsNullOrWhiteSpace(serviceTask.Name) || serviceTask.Name.Length > Constraints.BPMN_MODEL_NAME_MAX_LENGTH) { AddError(errors, ProblemsConstants.SERVICE_TASK_NAME_TOO_LONG, process, serviceTask, ProcessValidatorResource.NAME_TOO_LONG); } } else { //可以不校验实现类,如果没有填写实现类,默认使用ServiceWebApiBehavior VerifyImplementation(process, serviceTask, errors); VerifyType(process, serviceTask, errors); VerifyResultVariableName(process, serviceTask, errors); VerifyWebservice(bpmnModel, process, serviceTask, errors); } } }
public override void Validate(BpmnModel bpmnModel, List <ValidationError> errors) { foreach (BPMN.Model.Process process in bpmnModel.Processes) { ExecuteValidation(bpmnModel, process, errors); } }
public override void Validate(BpmnModel bpmnModel, IList <ValidationError> errors) { // Global associations ICollection <Artifact> artifacts = bpmnModel.GlobalArtifacts; if (artifacts != null) { foreach (Artifact artifact in artifacts) { if (artifact is Association) { Validate(null, (Association)artifact, errors); } } } // Process associations foreach (Process process in bpmnModel.Processes) { artifacts = process.Artifacts; foreach (Artifact artifact in artifacts) { if (artifact is Association) { Validate(process, (Association)artifact, errors); } } } }
protected internal override void ExecuteValidation(BpmnModel bpmnModel, Process process, IList <ValidationError> errors) { IList <IntermediateCatchEvent> intermediateCatchEvents = process.FindFlowElementsOfType <IntermediateCatchEvent>(); foreach (IntermediateCatchEvent intermediateCatchEvent in intermediateCatchEvents) { EventDefinition eventDefinition = null; if (intermediateCatchEvent.EventDefinitions.Count > 0) { eventDefinition = intermediateCatchEvent.EventDefinitions[0]; } if (eventDefinition == null) { AddError(errors, ProblemsConstants.INTERMEDIATE_CATCH_EVENT_NO_EVENTDEFINITION, process, intermediateCatchEvent, ProcessValidatorResource.INTERMEDIATE_CATCH_EVENT_NO_EVENTDEFINITION); } else { if (!(eventDefinition is TimerEventDefinition) && !(eventDefinition is SignalEventDefinition) && !(eventDefinition is MessageEventDefinition)) { AddError(errors, ProblemsConstants.INTERMEDIATE_CATCH_EVENT_INVALID_EVENTDEFINITION, process, intermediateCatchEvent, ProcessValidatorResource.INTERMEDIATE_CATCH_EVENT_INVALID_EVENTDEFINITION); } } } }
public static void WriteRootElement(BpmnModel model, XMLStreamWriter xtw, string encoding) { xtw.WriteStartDocument(encoding, "1.0"); // start definitions root element xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_DEFINITIONS, BpmnXMLConstants.BPMN2_NAMESPACE); xtw.DefaultNamespace = BpmnXMLConstants.BPMN2_NAMESPACE; xtw.WriteDefaultNamespace(BpmnXMLConstants.BPMN2_NAMESPACE); xtw.WriteNamespace(BpmnXMLConstants.XSI_PREFIX, BpmnXMLConstants.XSI_NAMESPACE); xtw.WriteNamespace(BpmnXMLConstants.XSD_PREFIX, BpmnXMLConstants.SCHEMA_NAMESPACE); xtw.WriteNamespace(BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX, BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE); xtw.WriteNamespace(BpmnXMLConstants.BPMNDI_PREFIX, BpmnXMLConstants.BPMNDI_NAMESPACE); xtw.WriteNamespace(BpmnXMLConstants.OMGDC_PREFIX, BpmnXMLConstants.OMGDC_NAMESPACE); xtw.WriteNamespace(BpmnXMLConstants.OMGDI_PREFIX, BpmnXMLConstants.OMGDI_NAMESPACE); foreach (string prefix in model.Namespaces.Keys) { if (!defaultNamespaces.Contains(prefix) && !string.IsNullOrWhiteSpace(prefix)) { xtw.WriteNamespace(prefix, model.Namespaces[prefix]); } } xtw.WriteAttribute(BpmnXMLConstants.TYPE_LANGUAGE_ATTRIBUTE, BpmnXMLConstants.SCHEMA_NAMESPACE); xtw.WriteAttribute(BpmnXMLConstants.EXPRESSION_LANGUAGE_ATTRIBUTE, BpmnXMLConstants.XPATH_NAMESPACE); if (!string.IsNullOrWhiteSpace(model.TargetNamespace)) { xtw.WriteAttribute(BpmnXMLConstants.TARGET_NAMESPACE_ATTRIBUTE, model.TargetNamespace); } else { xtw.WriteAttribute(BpmnXMLConstants.TARGET_NAMESPACE_ATTRIBUTE, BpmnXMLConstants.PROCESS_NAMESPACE); } //BpmnXMLUtil.WriteCustomAttributes(model.DefinitionsAttributes.Values, xtw, model.Namespaces, defaultAttributes); }
protected internal virtual void HandleBPMNModelConstraints(BpmnModel bpmnModel, IList <ValidationError> errors) { if (bpmnModel.TargetNamespace is object && bpmnModel.TargetNamespace.Length > Constraints.BPMN_MODEL_TARGET_NAMESPACE_MAX_LENGTH) { AddError(errors, ProblemsConstants.BPMN_MODEL_TARGET_NAMESPACE_TOO_LONG, string.Format(ProcessValidatorResource.BPMN_MODEL_TARGET_NAMESPACE_TOO_LONG, Constraints.BPMN_MODEL_TARGET_NAMESPACE_MAX_LENGTH)); } }
protected internal override void ExecuteValidation(BpmnModel bpmnModel, Process process, IList <ValidationError> errors) { IList <SendTask> sendTasks = process.FindFlowElementsOfType <SendTask>(); foreach (SendTask sendTask in sendTasks) { // Verify implementation if (!string.IsNullOrWhiteSpace(sendTask.ImplementationType) && string.IsNullOrWhiteSpace(sendTask.Implementation)) { AddError(errors, ProblemsConstants.SEND_TASK_INVALID_IMPLEMENTATION, process, sendTask, ProcessValidatorResource.SEND_TASK_INVALID_IMPLEMENTATION); } sendTask.ExtensionElements.TryGetValue(BpmnXMLConstants.ELEMENT_EXTENSIONS_PROPERTY, out IList <ExtensionElement> pElements); if (pElements == null) { AddError(errors, ProblemsConstants.SEND_TASK_INVALID_IMPLEMENTATION, process, sendTask, ProcessValidatorResource.SEND_TASK_TEMPLATE_NULL); continue; } string email = pElements.GetAttributeValue("email"); string wechat = pElements.GetAttributeValue("wechat"); string sms = pElements.GetAttributeValue("sms"); if (string.IsNullOrWhiteSpace(email) && string.IsNullOrWhiteSpace(wechat) && string.IsNullOrWhiteSpace(sms)) { AddError(errors, ProblemsConstants.SEND_TASK_INVALID_IMPLEMENTATION, process, sendTask, ProcessValidatorResource.SEND_TASK_TEMPLATE_NULL); } if (string.IsNullOrWhiteSpace(sendTask.Name) || sendTask.Name.Length > Constraints.BPMN_MODEL_NAME_MAX_LENGTH) { AddError(errors, ProblemsConstants.SEND_TASK_NAME_TOO_LONG, process, sendTask, ProcessValidatorResource.NAME_TOO_LONG); } //if (string.IsNullOrWhiteSpace(sendTask.Type) && !ImplementationType.IMPLEMENTATION_TYPE_WEBSERVICE.Equals(sendTask.ImplementationType, StringComparison.CurrentCultureIgnoreCase)) //{ // addError(errors, ProblemsConstants.SEND_TASK_INVALID_IMPLEMENTATION, process, sendTask, ProcessValidatorResource.SEND_TASK_INVALID_IMPLEMENTATION); //} // Verify type //if (!string.IsNullOrWhiteSpace(sendTask.Type)) //{ // if (!sendTask.Type.Equals("mail", StringComparison.CurrentCultureIgnoreCase) && !sendTask.Type.Equals("mule", StringComparison.CurrentCultureIgnoreCase) && !sendTask.Type.Equals("camel", StringComparison.CurrentCultureIgnoreCase)) // { // addError(errors, ProblemsConstants.SEND_TASK_INVALID_TYPE, process, sendTask, ProcessValidatorResource.SEND_TASK_INVALID_TYPE); // } // if (sendTask.Type.Equals("mail", StringComparison.CurrentCultureIgnoreCase)) // { // validateFieldDeclarationsForEmail(process, sendTask, sendTask.FieldExtensions, errors); // } //} // Web service //verifyWebservice(bpmnModel, process, sendTask, errors); } }
public virtual async Task <Deployment> BuildAsync() { var model = BpmnModel.FromBytes(this.modelData, this.disableModelValidations); var processes = model.Processes; if (processes.Count == 0) { throw new DeploymentException("The BPMN model does not contains any processes."); } var keys = processes.Select(x => x.Id); var prevProcessDefinitions = await this.deploymentManager.CreateDefinitionQuery() .FetchLatestVersionOnly() .SetKeyAny(keys) .ListAsync(); var prevProcessDefinitionMap = prevProcessDefinitions.ToDictionary(x => x.Key); //New deployment. var deployment = new Deployment(); deployment.Name = name; deployment.Model = new ByteArray(modelData); deployment.Created = Clock.Now; deployment.Category = this.category; deployment.Memo = this.memo; deployment.TenantId = this.tenantId; ProcessDefinition prevProcessDefinition = null; foreach (var bpmnProcess in processes) { if (!bpmnProcess.IsExecutable) { throw new DeploymentException($"The process '{bpmnProcess.Id}' is not executabe."); } prevProcessDefinition = null; if (prevProcessDefinitionMap.Count > 0) { prevProcessDefinitionMap.TryGetValue(bpmnProcess.Id, out prevProcessDefinition); } var procDef = this.CreateProcessDefinition(deployment, bpmnProcess, prevProcessDefinition); procDef.HasDiagram = model.HasDiagram(bpmnProcess.Id); deployment.ProcessDefinitions.Add(procDef); this.InitializeEventsAndScheduledJobs(procDef, bpmnProcess, prevProcessDefinition); } await this.session.SaveAsync(deployment); await this.session.FlushAsync(); return(deployment); }
public virtual void Parse(XMLStreamReader xtr, BpmnModel model) { string id = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_DI_BPMNELEMENT); IList <GraphicInfo> wayPointList = new List <GraphicInfo>(); while (xtr.HasNext()) { //xtr.next(); if (xtr.IsStartElement() && BpmnXMLConstants.ELEMENT_DI_LABEL.Equals(xtr.LocalName, StringComparison.CurrentCultureIgnoreCase)) { while (xtr.HasNext()) { //xtr.next(); if (xtr.IsStartElement() && BpmnXMLConstants.ELEMENT_DI_BOUNDS.Equals(xtr.LocalName, StringComparison.CurrentCultureIgnoreCase)) { GraphicInfo graphicInfo = new GraphicInfo(); BpmnXMLUtil.AddXMLLocation(graphicInfo, xtr); graphicInfo.X = Convert.ToDouble(xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_DI_X)); graphicInfo.Y = Convert.ToDouble(xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_DI_Y)); graphicInfo.Width = Convert.ToDouble(xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_DI_WIDTH)); graphicInfo.Height = Convert.ToDouble(xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_DI_HEIGHT)); model.AddLabelGraphicInfo(id, graphicInfo); break; } else if (xtr.EndElement && BpmnXMLConstants.ELEMENT_DI_LABEL.Equals(xtr.LocalName, StringComparison.CurrentCultureIgnoreCase)) { break; } if (xtr.IsEmptyElement && BpmnXMLConstants.ELEMENT_DI_LABEL.Equals(xtr.LocalName, StringComparison.CurrentCultureIgnoreCase)) { break; } } } else if (xtr.IsStartElement() && BpmnXMLConstants.ELEMENT_DI_WAYPOINT.Equals(xtr.LocalName, StringComparison.CurrentCultureIgnoreCase)) { GraphicInfo graphicInfo = new GraphicInfo(); BpmnXMLUtil.AddXMLLocation(graphicInfo, xtr); graphicInfo.X = Convert.ToDouble(xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_DI_X)); graphicInfo.Y = Convert.ToDouble(xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_DI_Y)); wayPointList.Add(graphicInfo); } else if (xtr.EndElement && BpmnXMLConstants.ELEMENT_DI_EDGE.Equals(xtr.LocalName, StringComparison.CurrentCultureIgnoreCase)) { break; } if (xtr.IsEmptyElement && BpmnXMLConstants.ELEMENT_DI_EDGE.Equals(xtr.LocalName, StringComparison.CurrentCultureIgnoreCase)) { break; } } model.AddFlowGraphicInfoList(id, wayPointList); }
protected internal override void ExecuteValidation(BpmnModel bpmnModel, Process process, IList <ValidationError> errors) { IList <ExclusiveGateway> gateways = process.FindFlowElementsOfType <ExclusiveGateway>(); foreach (ExclusiveGateway gateway in gateways) { ValidateExclusiveGateway(process, gateway, errors); } }
protected internal override void ExecuteValidation(BpmnModel bpmnModel, Process process, IList <ValidationError> errors) { ValidateListeners(process, process, process.ExecutionListeners, errors); foreach (FlowElement flowElement in process.FlowElements) { ValidateListeners(process, flowElement, flowElement.ExecutionListeners, errors); } }
public void 获取已完成流程节点(string bpmnFile) { string xml = IntegrationTestContext.ReadBpmn(bpmnFile); ICommandExecutor commandExecutor = (processEngine.ProcessEngineConfiguration as ProcessEngineConfigurationImpl).CommandExecutor; Authentication.AuthenticatedUser = new InProcessWorkflowEngine.TestUser() { Id = "评审员", FullName = "评审员", TenantId = context.TenantId }; IDeploymentBuilder builder = processEngine.RepositoryService.CreateDeployment() .Name(Path.GetFileNameWithoutExtension(bpmnFile)) .TenantId(context.TenantId) .AddString(bpmnFile, xml) .EnableDuplicateFiltering() .TenantId(context.TenantId); IDeployment deploy = commandExecutor.Execute(new DeployCmd(builder)); IProcessDefinition definition = processEngine.RepositoryService.CreateProcessDefinitionQuery() .SetDeploymentId(deploy.Id) .SetProcessDefinitionTenantId(context.TenantId) .SetLatestVersion() .SingleResult(); BpmnModel model = commandExecutor.Execute(new GetBpmnModelCmd(definition.Id)); IProcessInstance processInstance = commandExecutor.Execute(new StartProcessInstanceCmd(definition.Id, null)); IList <ITask> tasks = processEngine.TaskService.GetMyTasks("用户1"); ITaskEntity task = tasks[0] as ITaskEntity; IExecutionEntity execution = commandExecutor.Execute(new GetExecutionByIdCmd(task.ExecutionId)); processEngine.TaskService.Complete(task.Id, new Dictionary <string, object> { { "流程变量", "变量值" } }); var list = commandExecutor.Execute(new GetCompletedTaskModelsCmd(task.ProcessInstanceId, true)); Assert.Contains(model.MainProcess.FlowElements, x => list.Any(y => x.Id == y.Id)); tasks = processEngine.TaskService.GetMyTasks("用户2"); task = tasks[0] as ITaskEntity; processEngine.TaskService.Complete(task.Id, new Dictionary <string, object> { { "流程变量", "变量值" } }); list = commandExecutor.Execute(new GetCompletedTaskModelsCmd(task.ProcessInstanceId, true)); Assert.Contains(model.MainProcess.FlowElements, x => list.Any(y => x.Id == y.Id)); }