public virtual ParsedDeployment Build(BpmnDeploymentHelper bpmnDeploymentHelper)
        {
            IList <IProcessDefinitionEntity> processDefinitions = new List <IProcessDefinitionEntity>();
            IDictionary <IProcessDefinitionEntity, BpmnParse>       processDefinitionsToBpmnParseMap = new Dictionary <IProcessDefinitionEntity, BpmnParse>();
            IDictionary <IProcessDefinitionEntity, IResourceEntity> processDefinitionsToResourceMap  = new Dictionary <IProcessDefinitionEntity, IResourceEntity>();

            var resources = deployment.GetResources().Values;

            foreach (IResourceEntity resource in resources)
            {
                if (IsBpmnResource(resource.Name))
                {
                    log.LogDebug($"Processing BPMN resource {resource.Name}");
                    BpmnParse parse = CreateBpmnParseFromResource(bpmnDeploymentHelper, resource);
                    foreach (IProcessDefinitionEntity processDefinition in parse.ProcessDefinitions)
                    {
                        processDefinition.BusinessKey  = parse.Deployment.BusinessKey;
                        processDefinition.StartForm    = parse.Deployment.StartForm;
                        processDefinition.BusinessPath = parse.Deployment.BusinessPath;
                        processDefinitions.Add(processDefinition);
                        processDefinitionsToBpmnParseMap[processDefinition] = parse;
                        processDefinitionsToResourceMap[processDefinition]  = resource;
                    }
                }
            }

            return(new ParsedDeployment(deployment, processDefinitions, processDefinitionsToBpmnParseMap, processDefinitionsToResourceMap));
        }
Beispiel #2
0
 protected internal override void ExecuteParse(BpmnParse bpmnParse, ServiceTask serviceTask)
 {
     if (!string.IsNullOrWhiteSpace(serviceTask.Type))
     {
         CreateActivityBehaviorForServiceTaskType(bpmnParse, serviceTask);
     }
     else if (ImplementationType.IMPLEMENTATION_TYPE_CLASS.Equals(serviceTask.ImplementationType, StringComparison.CurrentCultureIgnoreCase))
     {
         CreateClassDelegateServiceTask(bpmnParse, serviceTask);
     }
     else if (ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION.Equals(serviceTask.ImplementationType, StringComparison.CurrentCultureIgnoreCase))
     {
         CreateServiceTaskDelegateExpressionActivityBehavior(bpmnParse, serviceTask);
     }
     else if (ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION.Equals(serviceTask.ImplementationType, StringComparison.CurrentCultureIgnoreCase))
     {
         CreateServiceTaskExpressionActivityBehavior(bpmnParse, serviceTask);
     }
     else if (ImplementationType.IMPLEMENTATION_TYPE_WEBSERVICE.Equals(serviceTask.ImplementationType, StringComparison.CurrentCultureIgnoreCase) && !string.IsNullOrWhiteSpace(serviceTask.OperationRef))
     {
         CreateWebServiceActivityBehavior(bpmnParse, serviceTask);
     }
     else
     {
         CreateDefaultServiceTaskActivityBehavior(bpmnParse, serviceTask);
     }
 }
Beispiel #3
0
        protected internal override void ExecuteParse(BpmnParse bpmnParse, ThrowEvent intermediateEvent)
        {
            EventDefinition eventDefinition = null;

            if (intermediateEvent.EventDefinitions.Count > 0)
            {
                eventDefinition = intermediateEvent.EventDefinitions[0];
            }

            if (eventDefinition is SignalEventDefinition signalEventDefinition)
            {
                intermediateEvent.Behavior = bpmnParse.ActivityBehaviorFactory.CreateIntermediateThrowSignalEventActivityBehavior(intermediateEvent, signalEventDefinition, bpmnParse.BpmnModel.GetSignal(signalEventDefinition.SignalRef));
            }
            else if (eventDefinition is CompensateEventDefinition compensateEventDefinition)
            {
                intermediateEvent.Behavior = bpmnParse.ActivityBehaviorFactory.CreateIntermediateThrowCompensationEventActivityBehavior(intermediateEvent, compensateEventDefinition);
            }
            else if (eventDefinition is MessageEventDefinition messageEventDefinition)
            {
                intermediateEvent.Behavior = bpmnParse.ActivityBehaviorFactory.CreateIntermediateThrowMessgeEventActivityBehavior(intermediateEvent, messageEventDefinition, bpmnParse.BpmnModel.GetMessage(messageEventDefinition.MessageRef));
            }
            else if (eventDefinition == null)
            {
                intermediateEvent.Behavior = bpmnParse.ActivityBehaviorFactory.CreateIntermediateThrowNoneEventActivityBehavior(intermediateEvent);
            }
            else
            {
                logger.LogWarning("Unsupported intermediate throw event type for throw event " + intermediateEvent.Id);
            }
        }
Beispiel #4
0
        protected internal override void ExecuteParse(BpmnParse bpmnParse, SequenceFlow sequenceFlow)
        {
            Process process = bpmnParse.CurrentProcess;

            sequenceFlow.SourceFlowElement = process.GetFlowElement(sequenceFlow.SourceRef, true);
            sequenceFlow.TargetFlowElement = process.GetFlowElement(sequenceFlow.TargetRef, true);
        }
Beispiel #5
0
        //解析xml 生成ProcessDefinitionEntity
        protected internal override IList <ProcessDefinitionEntity> TransformDefinitions(DeploymentEntity deployment, ResourceEntity resource, Core.Model.Properties properties)
        {
            byte[] bytes = resource.Bytes;
            System.IO.MemoryStream inputStream = new System.IO.MemoryStream(bytes);

            BpmnParse bpmnParse = bpmnParser.CreateBpmnParse().SourceInputStream(inputStream).Deployment(deployment).SetName(resource.Name);

            if (!deployment.IsValidatingSchema)
            {
                bpmnParse.SchemaResource = null;
            }
            //执行实际解析
            bpmnParse.Execute();

            //TODO 解析后续行为
            if (!properties.Contains(JobDeclarationsProperty))
            {
                properties.Set(JobDeclarationsProperty, new Dictionary <string, IList <IJobDeclaration> >());
            }
            var oldProperties = properties.Get(JobDeclarationsProperty);

            foreach (var item in bpmnParse.GetJobDeclarations())
            {
                oldProperties[item.Key] = item.Value;
            }
            //foreach (var item in oldProperties)
            //{
            //    bpmnParse.JobDeclarations[item.Key] = item.Value;
            //}
            //properties.Set<string, IList<IJobDeclaration>>(JobDeclarationsProperty, bpmnParse.JobDeclarations);

            return(bpmnParse.ProcessDefinitions);
        }
Beispiel #6
0
 protected internal virtual void CreateDefaultServiceTaskActivityBehavior(BpmnParse bpmnParse, ServiceTask serviceTask)
 {
     serviceTask.ImplementationType = ImplementationType.IMPLEMENTATION_TYPE_CLASS;
     serviceTask.Implementation     = ImplementationType.IMPLEMENTATION_TASK_SERVICE_DEFAULT;
     //修改默认ServiceTaskBehavior
     serviceTask.Behavior = bpmnParse.ActivityBehaviorFactory.CreateClassDelegateServiceTask(serviceTask);
     //serviceTask.Behavior = bpmnParse.ActivityBehaviorFactory.createDefaultServiceTaskBehavior(serviceTask);
 }
        protected internal override void ExecuteParse(BpmnParse bpmnParse, ScriptTask scriptTask)
        {
            if (string.IsNullOrWhiteSpace(scriptTask.Script))
            {
                logger.LogWarning("No script provided for scriptTask " + scriptTask.Id);
            }

            scriptTask.Behavior = bpmnParse.ActivityBehaviorFactory.CreateScriptTaskActivityBehavior(scriptTask);
        }
Beispiel #8
0
        protected internal virtual void CreateMultiInstanceLoopCharacteristics(BpmnParse bpmnParse, Activity modelActivity)
        {
            MultiInstanceLoopCharacteristics loopCharacteristics = modelActivity.LoopCharacteristics;

            // Activity Behavior
            MultiInstanceActivityBehavior miActivityBehavior;

            if (loopCharacteristics.Sequential)
            {
                miActivityBehavior = bpmnParse.ActivityBehaviorFactory.CreateSequentialMultiInstanceBehavior(modelActivity, (AbstractBpmnActivityBehavior)modelActivity.Behavior);
            }
            else
            {
                miActivityBehavior = bpmnParse.ActivityBehaviorFactory.CreateParallelMultiInstanceBehavior(modelActivity, (AbstractBpmnActivityBehavior)modelActivity.Behavior);
            }

            modelActivity.Behavior = miActivityBehavior;

            ExpressionManager expressionManager = Context.ProcessEngineConfiguration.ExpressionManager;

            // loop cardinality
            if (!string.IsNullOrWhiteSpace(loopCharacteristics.LoopCardinality))
            {
                miActivityBehavior.LoopCardinalityExpression = expressionManager.CreateExpression(loopCharacteristics.LoopCardinality);
            }

            // completion condition
            if (!string.IsNullOrWhiteSpace(loopCharacteristics.CompletionCondition))
            {
                miActivityBehavior.CompletionConditionExpression = expressionManager.CreateExpression(loopCharacteristics.CompletionCondition);
            }

            // activiti:collection
            if (!string.IsNullOrWhiteSpace(loopCharacteristics.InputDataItem))
            {
                if (loopCharacteristics.InputDataItem.Contains("{"))
                {
                    miActivityBehavior.CollectionExpression = expressionManager.CreateExpression(loopCharacteristics.InputDataItem);
                }
                else
                {
                    miActivityBehavior.CollectionVariable = loopCharacteristics.InputDataItem;
                }
            }

            // activiti:elementVariable
            if (!string.IsNullOrWhiteSpace(loopCharacteristics.ElementVariable))
            {
                miActivityBehavior.CollectionElementVariable = loopCharacteristics.ElementVariable;
            }

            // activiti:elementIndexVariable
            if (!string.IsNullOrWhiteSpace(loopCharacteristics.ElementIndexVariable))
            {
                miActivityBehavior.CollectionElementIndexVariable = loopCharacteristics.ElementIndexVariable;
            }
        }
Beispiel #9
0
        public override void Parse(BpmnParse bpmnParse, BaseElement element)
        {
            base.Parse(bpmnParse, element);

            if (element is Activity && ((Activity)element).LoopCharacteristics != null)
            {
                CreateMultiInstanceLoopCharacteristics(bpmnParse, (Activity)element);
            }
        }
Beispiel #10
0
        protected internal virtual void ParseFormData(BpmnParse bpmnParse, ExpressionManager expressionManager,
                                                      Element extensionElement)
        {
            var formData = extensionElement.ElementNs(BpmnParse.CamundaBpmnExtensionsNs, "formData");

            if (formData != null)
            {
                BusinessKeyFieldId = formData.GetAttributeValue(BusinessKeyAttribute);
                ParseFormFields(formData, bpmnParse, expressionManager);
            }
        }
Beispiel #11
0
 protected internal override void ExecuteParse(BpmnParse bpmnParse, TimerEventDefinition timerEventDefinition)
 {
     if (bpmnParse.CurrentFlowElement is IntermediateCatchEvent intermediateCatchEvent)
     {
         intermediateCatchEvent.Behavior = bpmnParse.ActivityBehaviorFactory.CreateIntermediateCatchTimerEventActivityBehavior(intermediateCatchEvent, timerEventDefinition);
     }
     else if (bpmnParse.CurrentFlowElement is BoundaryEvent boundaryEvent)
     {
         boundaryEvent.Behavior = bpmnParse.ActivityBehaviorFactory.CreateBoundaryTimerEventActivityBehavior(boundaryEvent, timerEventDefinition, boundaryEvent.CancelActivity);
     }
 }