public ActivityImpl createActivityOnCurrentScope(BpmnParse bpmnParse, FlowElement flowElement, String xmlLocalName) { return createActivityOnScope(bpmnParse, flowElement, xmlLocalName, bpmnParse.getCurrentScope()); }
protected ActivityImpl findActivity(BpmnParse bpmnParse, String id) { return bpmnParse.getCurrentScope().findActivity(id); }
public ActivityImpl createActivityOnCurrentScope(BpmnParse bpmnParse, FlowElement flowElement, String xmlLocalName) { return createActivityOnScope(bpmnParse, flowElement, xmlLocalName, bpmnParse.getCurrentScope()); }
protected ActivityImpl findActivity(BpmnParse bpmnParse, String id) { return bpmnParse.getCurrentScope().findActivity(id); }
public void parse(BpmnParse bpmnParse, BaseElement element) { ActivityImpl activity = bpmnParse.getCurrentScope().findActivity(element.getId()); activity.addExecutionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_START, ACTIVITY_INSTANCE_START_LISTENER, 0); activity.addExecutionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_END, ACTIVITI_INSTANCE_END_LISTENER); }
@Override protected void executeParse(BpmnParse bpmnParse, StartEvent startEvent) { ActivityImpl startEventActivity = createActivityOnCurrentScope(bpmnParse, startEvent, BpmnXMLConstants.ELEMENT_EVENT_START); ScopeImpl scope = bpmnParse.getCurrentScope(); if (scope instanceof ProcessDefinitionEntity) { createProcessDefinitionStartEvent(bpmnParse, startEventActivity, startEvent, (ProcessDefinitionEntity) scope); selectInitial(bpmnParse, startEventActivity, startEvent, (ProcessDefinitionEntity) scope); createStartFormHandlers(bpmnParse, startEvent, (ProcessDefinitionEntity) scope); } else { createScopeStartEvent(bpmnParse, startEventActivity, startEvent); } }
@Override protected void executeParse(BpmnParse bpmnParse, StartEvent startEvent) { ActivityImpl startEventActivity = createActivityOnCurrentScope(bpmnParse, startEvent, BpmnXMLConstants.ELEMENT_EVENT_START); ScopeImpl scope = bpmnParse.getCurrentScope(); if (scope instanceof ProcessDefinitionEntity) { createProcessDefinitionStartEvent(bpmnParse, startEventActivity, startEvent, (ProcessDefinitionEntity) scope); selectInitial(bpmnParse, startEventActivity, startEvent, (ProcessDefinitionEntity) scope); createStartFormHandlers(bpmnParse, startEvent, (ProcessDefinitionEntity) scope); } else { createScopeStartEvent(bpmnParse, startEventActivity, startEvent); } }
@Override public void parse(BpmnParse bpmnParse, BaseElement element) { ActivityImpl activity = bpmnParse.getCurrentScope().findActivity(element.getId()); if (element instanceof BoundaryEvent) { // A boundary-event never receives an activity start-event activity.addExecutionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_END, ACTIVITY_INSTANCE_START_LISTENER, 0); activity.addExecutionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_END, ACTIVITI_INSTANCE_END_LISTENER, 1); } else { activity.addExecutionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_START, ACTIVITY_INSTANCE_START_LISTENER, 0); activity.addExecutionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_END, ACTIVITI_INSTANCE_END_LISTENER); } }
protected void createScopeStartEvent(BpmnParse bpmnParse, ActivityImpl startEventActivity, StartEvent startEvent) { ScopeImpl scope = bpmnParse.getCurrentScope(); Object triggeredByEvent = scope.getProperty("triggeredByEvent"); boolean isTriggeredByEvent = triggeredByEvent != null && ((Boolean) triggeredByEvent); if (isTriggeredByEvent) { // event subprocess // all start events of an event subprocess share common behavior EventSubProcessStartEventActivityBehavior activityBehavior = bpmnParse.getActivityBehaviorFactory().createEventSubProcessStartEventActivityBehavior(startEvent, startEventActivity.getId()); startEventActivity.setActivityBehavior(activityBehavior); if (!startEvent.getEventDefinitions().isEmpty()) { EventDefinition eventDefinition = startEvent.getEventDefinitions().get(0); if (eventDefinition instanceof org.flowable.bpmn.model.ErrorEventDefinition || eventDefinition instanceof MessageEventDefinition || eventDefinition instanceof SignalEventDefinition) { bpmnParse.getBpmnParserHandlers().parseElement(bpmnParse, eventDefinition); } else { LOGGER.warn("start event of event subprocess must be of type 'error', 'message' or 'signal' for start event {}", startEvent.getId()); } } } else { // "regular" subprocess if (!startEvent.getEventDefinitions().isEmpty()) { LOGGER.warn("event definitions only allowed on start event if subprocess is an event subprocess {}", bpmnParse.getCurrentSubProcess().getId()); } if (scope.getProperty(PROPERTYNAME_INITIAL) == null) { scope.setProperty(PROPERTYNAME_INITIAL, startEventActivity); startEventActivity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createNoneStartEventActivityBehavior(startEvent)); } else { LOGGER.warn("multiple start events not supported for subprocess {}", bpmnParse.getCurrentSubProcess().getId()); } } }
protected void executeParse(BpmnParse bpmnParse, UserTask userTask) { ActivityImpl activity = createActivityOnCurrentScope(bpmnParse, userTask, BpmnXMLConstants.ELEMENT_TASK_USER); activity.setAsync(userTask.isAsynchronous()); activity.setExclusive(!userTask.isNotExclusive()); TaskDefinition taskDefinition = parseTaskDefinition(bpmnParse, userTask, userTask.getId(), (ProcessDefinitionEntity) bpmnParse.getCurrentScope().getProcessDefinition()); activity.setProperty(PROPERTY_TASK_DEFINITION, taskDefinition); activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createUserTaskActivityBehavior(userTask, taskDefinition)); }
@Override protected void executeParse(BpmnParse bpmnParse, UserTask userTask) { ActivityImpl activity = createActivityOnCurrentScope(bpmnParse, userTask, BpmnXMLConstants.ELEMENT_TASK_USER); activity.setAsync(userTask.isAsynchronous()); activity.setExclusive(!userTask.isNotExclusive()); TaskDefinition taskDefinition = parseTaskDefinition(bpmnParse, userTask, userTask.getId(), (ProcessDefinitionEntity) bpmnParse.getCurrentScope().getProcessDefinition()); activity.setProperty(PROPERTY_TASK_DEFINITION, taskDefinition); activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createUserTaskActivityBehavior(userTask, taskDefinition)); }
ScopeImpl scope = bpmnParse.getCurrentScope(); String eventBasedGatewayId = getPrecedingEventBasedGateway(bpmnParse, event); if (eventBasedGatewayId != null) {
@Override protected void executeParse(BpmnParse bpmnParse, SequenceFlow sequenceFlow) { ScopeImpl scope = bpmnParse.getCurrentScope(); ActivityImpl sourceActivity = scope.findActivity(sequenceFlow.getSourceRef()); ActivityImpl destinationActivity = scope.findActivity(sequenceFlow.getTargetRef()); Expression skipExpression; if (StringUtils.isNotEmpty(sequenceFlow.getSkipExpression())) { ExpressionManager expressionManager = bpmnParse.getExpressionManager(); skipExpression = expressionManager.createExpression(sequenceFlow.getSkipExpression()); } else { skipExpression = null; } TransitionImpl transition = sourceActivity.createOutgoingTransition(sequenceFlow.getId(), skipExpression); bpmnParse.getSequenceFlows().put(sequenceFlow.getId(), transition); transition.setProperty("name", sequenceFlow.getName()); transition.setProperty("documentation", sequenceFlow.getDocumentation()); transition.setDestination(destinationActivity); if (StringUtils.isNotEmpty(sequenceFlow.getConditionExpression())) { Condition expressionCondition = new UelExpressionCondition(sequenceFlow.getConditionExpression()); transition.setProperty(PROPERTYNAME_CONDITION_TEXT, sequenceFlow.getConditionExpression()); transition.setProperty(PROPERTYNAME_CONDITION, expressionCondition); } createExecutionListenersOnTransition(bpmnParse, sequenceFlow.getExecutionListeners(), transition); }
@Override protected void executeParse(BpmnParse bpmnParse, CompensateEventDefinition eventDefinition) { ScopeImpl scope = bpmnParse.getCurrentScope(); if (StringUtils.isNotEmpty(eventDefinition.getActivityRef())) { if (scope.findActivity(eventDefinition.getActivityRef()) == null) { LOGGER.warn("Invalid attribute value for 'activityRef': no activity with id '{}' in current scope {}", eventDefinition.getActivityRef(), scope.getId()); } } org.activiti.engine.impl.bpmn.parser.CompensateEventDefinition compensateEventDefinition = new org.activiti.engine.impl.bpmn.parser.CompensateEventDefinition(); compensateEventDefinition.setActivityRef(eventDefinition.getActivityRef()); compensateEventDefinition.setWaitForCompletion(eventDefinition.isWaitForCompletion()); ActivityImpl activity = bpmnParse.getCurrentActivity(); if (bpmnParse.getCurrentFlowElement() instanceof ThrowEvent) { activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createIntermediateThrowCompensationEventActivityBehavior((ThrowEvent) bpmnParse.getCurrentFlowElement(), compensateEventDefinition)); } else if (bpmnParse.getCurrentFlowElement() instanceof BoundaryEvent) { BoundaryEvent boundaryEvent = (BoundaryEvent) bpmnParse.getCurrentFlowElement(); boolean interrupting = boundaryEvent.isCancelActivity(); activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createBoundaryEventActivityBehavior(boundaryEvent, interrupting, activity)); activity.setProperty("type", "compensationBoundaryCatch"); } else { // What to do? } }
ScopeImpl scope = bpmnParse.getCurrentScope(); ActivityImpl activity = bpmnParse.getCurrentActivity(); if (bpmnParse.getCurrentFlowElement() instanceof StartEvent) {
@Override protected void executeParse(BpmnParse bpmnParse, ErrorEventDefinition eventDefinition) { ErrorEventDefinition modelErrorEvent = eventDefinition; if (bpmnParse.getBpmnModel().containsErrorRef(modelErrorEvent.getErrorCode())) { String errorCode = bpmnParse.getBpmnModel().getErrors().get(modelErrorEvent.getErrorCode()); modelErrorEvent.setErrorCode(errorCode); } ScopeImpl scope = bpmnParse.getCurrentScope(); ActivityImpl activity = bpmnParse.getCurrentActivity(); if (bpmnParse.getCurrentFlowElement() instanceof StartEvent) { if (scope.getProperty(PROPERTYNAME_INITIAL) == null) { scope.setProperty(PROPERTYNAME_INITIAL, activity); // the scope of the event subscription is the parent of the event // subprocess (subscription must be created when parent is initialized) ScopeImpl catchingScope = ((ActivityImpl) scope).getParent(); createErrorStartEventDefinition(modelErrorEvent, activity, catchingScope); } } else if (bpmnParse.getCurrentFlowElement() instanceof BoundaryEvent) { BoundaryEvent boundaryEvent = (BoundaryEvent) bpmnParse.getCurrentFlowElement(); boolean interrupting = true; // non-interrupting not yet supported activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createBoundaryEventActivityBehavior(boundaryEvent, interrupting, activity)); ActivityImpl parentActivity = scope.findActivity(boundaryEvent.getAttachedToRefId()); createBoundaryErrorEventDefinition(modelErrorEvent, interrupting, parentActivity, activity); } }
protected void executeParse(BpmnParse bpmnParse, CompensateEventDefinition eventDefinition) { ScopeImpl scope = bpmnParse.getCurrentScope(); if(StringUtils.isNotEmpty(eventDefinition.getActivityRef())) { if(scope.findActivity(eventDefinition.getActivityRef()) == null) {
protected void executeParse(BpmnParse bpmnParse, SequenceFlow sequenceFlow) { ScopeImpl scope = bpmnParse.getCurrentScope();
protected void executeParse(BpmnParse bpmnParse, SubProcess subProcess) { ActivityImpl activity = createActivityOnScope(bpmnParse, subProcess, BpmnXMLConstants.ELEMENT_SUBPROCESS, bpmnParse.getCurrentScope()); activity.setAsync(subProcess.isAsynchronous()); activity.setExclusive(!subProcess.isNotExclusive()); boolean triggeredByEvent = false; if (subProcess instanceof EventSubProcess) { triggeredByEvent = true; } activity.setProperty("triggeredByEvent", triggeredByEvent); // event subprocesses are not scopes activity.setScope(!triggeredByEvent); activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createSubprocActivityBehavior(subProcess)); bpmnParse.setCurrentScope(activity); bpmnParse.setCurrentSubProcess(subProcess); bpmnParse.processFlowElements(subProcess.getFlowElements()); processArtifacts(bpmnParse, subProcess.getArtifacts(), activity); bpmnParse.removeCurrentScope(); bpmnParse.removeCurrentSubProcess(); if (subProcess.getIoSpecification() != null) { IOSpecification ioSpecification = createIOSpecification(bpmnParse, subProcess.getIoSpecification()); activity.setIoSpecification(ioSpecification); } }
@Override protected void executeParse(BpmnParse bpmnParse, SubProcess subProcess) { ActivityImpl activity = createActivityOnScope(bpmnParse, subProcess, BpmnXMLConstants.ELEMENT_SUBPROCESS, bpmnParse.getCurrentScope()); activity.setAsync(subProcess.isAsynchronous()); activity.setExclusive(!subProcess.isNotExclusive()); boolean triggeredByEvent = false; if (subProcess instanceof EventSubProcess) { triggeredByEvent = true; } activity.setProperty("triggeredByEvent", triggeredByEvent); // event subprocesses are not scopes activity.setScope(!triggeredByEvent); activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createSubprocActivityBehavior(subProcess)); bpmnParse.setCurrentScope(activity); bpmnParse.setCurrentSubProcess(subProcess); bpmnParse.processFlowElements(subProcess.getFlowElements()); processArtifacts(bpmnParse, subProcess.getArtifacts(), activity); // no data objects for event subprocesses if (!(subProcess instanceof EventSubProcess)) { // parse out any data objects from the template in order to set up the necessary process variables Map<String, Object> variables = processDataObjects(bpmnParse, subProcess.getDataObjects(), activity); activity.setVariables(variables); } bpmnParse.removeCurrentScope(); bpmnParse.removeCurrentSubProcess(); if (subProcess.getIoSpecification() != null) { IOSpecification ioSpecification = createIOSpecification(bpmnParse, subProcess.getIoSpecification()); activity.setIoSpecification(ioSpecification); } }