Search in sources :

Example 6 with ScopeImpl

use of org.activiti.engine.impl.pvm.process.ScopeImpl in project Activiti by Activiti.

the class MessageEventDefinitionParseHandler method executeParse.

protected void executeParse(BpmnParse bpmnParse, MessageEventDefinition messageDefinition) {
    BpmnModel bpmnModel = bpmnParse.getBpmnModel();
    String messageRef = messageDefinition.getMessageRef();
    if (bpmnModel.containsMessageId(messageRef)) {
        Message message = bpmnModel.getMessage(messageRef);
        messageDefinition.setMessageRef(message.getName());
        messageDefinition.setExtensionElements(message.getExtensionElements());
    }
    EventSubscriptionDeclaration eventSubscription = new EventSubscriptionDeclaration(messageDefinition.getMessageRef(), "message");
    ScopeImpl scope = bpmnParse.getCurrentScope();
    ActivityImpl activity = bpmnParse.getCurrentActivity();
    if (bpmnParse.getCurrentFlowElement() instanceof StartEvent && bpmnParse.getCurrentSubProcess() != null) {
        // 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();
        EventSubscriptionDeclaration eventSubscriptionDeclaration = new EventSubscriptionDeclaration(messageDefinition.getMessageRef(), "message");
        eventSubscriptionDeclaration.setActivityId(activity.getId());
        eventSubscriptionDeclaration.setStartEvent(false);
        addEventSubscriptionDeclaration(bpmnParse, eventSubscriptionDeclaration, messageDefinition, catchingScope);
    } else if (bpmnParse.getCurrentFlowElement() instanceof StartEvent) {
        activity.setProperty("type", "messageStartEvent");
        eventSubscription.setStartEvent(true);
        eventSubscription.setActivityId(activity.getId());
        addEventSubscriptionDeclaration(bpmnParse, eventSubscription, messageDefinition, bpmnParse.getCurrentProcessDefinition());
    } else if (bpmnParse.getCurrentFlowElement() instanceof IntermediateCatchEvent) {
        activity.setProperty("type", "intermediateMessageCatch");
        if (getPrecedingEventBasedGateway(bpmnParse, (IntermediateCatchEvent) bpmnParse.getCurrentFlowElement()) != null) {
            eventSubscription.setActivityId(activity.getId());
            addEventSubscriptionDeclaration(bpmnParse, eventSubscription, messageDefinition, activity.getParent());
        } else {
            activity.setScope(true);
            addEventSubscriptionDeclaration(bpmnParse, eventSubscription, messageDefinition, activity);
        }
    } 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", "boundaryMessage");
        EventSubscriptionDeclaration eventSubscriptionDeclaration = new EventSubscriptionDeclaration(messageDefinition.getMessageRef(), "message");
        eventSubscriptionDeclaration.setActivityId(activity.getId());
        addEventSubscriptionDeclaration(bpmnParse, eventSubscriptionDeclaration, messageDefinition, activity.getParent());
        if (activity.getParent() instanceof ActivityImpl) {
            ((ActivityImpl) activity.getParent()).setScope(true);
        }
    } else {
    // What to do here?
    }
}
Also used : Message(org.activiti.bpmn.model.Message) ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) BoundaryEvent(org.activiti.bpmn.model.BoundaryEvent) IntermediateCatchEvent(org.activiti.bpmn.model.IntermediateCatchEvent) StartEvent(org.activiti.bpmn.model.StartEvent) ScopeImpl(org.activiti.engine.impl.pvm.process.ScopeImpl) EventSubscriptionDeclaration(org.activiti.engine.impl.bpmn.parser.EventSubscriptionDeclaration) BpmnModel(org.activiti.bpmn.model.BpmnModel)

Example 7 with ScopeImpl

use of org.activiti.engine.impl.pvm.process.ScopeImpl in project Activiti by Activiti.

the class SequenceFlowParseHandler method executeParse.

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);
}
Also used : UelExpressionCondition(org.activiti.engine.impl.el.UelExpressionCondition) Condition(org.activiti.engine.impl.Condition) ExpressionManager(org.activiti.engine.impl.el.ExpressionManager) TransitionImpl(org.activiti.engine.impl.pvm.process.TransitionImpl) ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) Expression(org.activiti.engine.delegate.Expression) ScopeImpl(org.activiti.engine.impl.pvm.process.ScopeImpl) UelExpressionCondition(org.activiti.engine.impl.el.UelExpressionCondition)

Example 8 with ScopeImpl

use of org.activiti.engine.impl.pvm.process.ScopeImpl in project Activiti by Activiti.

the class StartEventParseHandler method executeParse.

@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);
    }
}
Also used : ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity) ScopeImpl(org.activiti.engine.impl.pvm.process.ScopeImpl)

Example 9 with ScopeImpl

use of org.activiti.engine.impl.pvm.process.ScopeImpl in project Activiti by Activiti.

the class EndEventParseHandler method executeParse.

protected void executeParse(BpmnParse bpmnParse, EndEvent endEvent) {
    ActivityImpl endEventActivity = createActivityOnCurrentScope(bpmnParse, endEvent, BpmnXMLConstants.ELEMENT_EVENT_END);
    EventDefinition eventDefinition = null;
    if (!endEvent.getEventDefinitions().isEmpty()) {
        eventDefinition = endEvent.getEventDefinitions().get(0);
    }
    // Error end event
    if (eventDefinition instanceof org.activiti.bpmn.model.ErrorEventDefinition) {
        org.activiti.bpmn.model.ErrorEventDefinition errorDefinition = (org.activiti.bpmn.model.ErrorEventDefinition) eventDefinition;
        if (bpmnParse.getBpmnModel().containsErrorRef(errorDefinition.getErrorCode())) {
            String errorCode = bpmnParse.getBpmnModel().getErrors().get(errorDefinition.getErrorCode());
            if (StringUtils.isEmpty(errorCode)) {
                logger.warn("errorCode is required for an error event " + endEvent.getId());
            }
            endEventActivity.setProperty("type", "errorEndEvent");
            errorDefinition.setErrorCode(errorCode);
        }
        endEventActivity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createErrorEndEventActivityBehavior(endEvent, errorDefinition));
    // Cancel end event      
    } else if (eventDefinition instanceof CancelEventDefinition) {
        ScopeImpl scope = bpmnParse.getCurrentScope();
        if (scope.getProperty("type") == null || !scope.getProperty("type").equals("transaction")) {
            logger.warn("end event with cancelEventDefinition only supported inside transaction subprocess (id=" + endEvent.getId() + ")");
        } else {
            endEventActivity.setProperty("type", "cancelEndEvent");
            endEventActivity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createCancelEndEventActivityBehavior(endEvent));
        }
    // Terminate end event  
    } else if (eventDefinition instanceof TerminateEventDefinition) {
        endEventActivity.setAsync(endEvent.isAsynchronous());
        endEventActivity.setExclusive(!endEvent.isNotExclusive());
        endEventActivity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createTerminateEndEventActivityBehavior(endEvent));
    // None end event  
    } else if (eventDefinition == null) {
        endEventActivity.setAsync(endEvent.isAsynchronous());
        endEventActivity.setExclusive(!endEvent.isNotExclusive());
        endEventActivity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createNoneEndEventActivityBehavior(endEvent));
    }
}
Also used : ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) CancelEventDefinition(org.activiti.bpmn.model.CancelEventDefinition) TerminateEventDefinition(org.activiti.bpmn.model.TerminateEventDefinition) TerminateEventDefinition(org.activiti.bpmn.model.TerminateEventDefinition) CancelEventDefinition(org.activiti.bpmn.model.CancelEventDefinition) EventDefinition(org.activiti.bpmn.model.EventDefinition) ScopeImpl(org.activiti.engine.impl.pvm.process.ScopeImpl)

Example 10 with ScopeImpl

use of org.activiti.engine.impl.pvm.process.ScopeImpl in project Activiti by Activiti.

the class ErrorEventDefinitionParseHandler method executeParse.

protected void executeParse(BpmnParse bpmnParse, ErrorEventDefinition eventDefinition) {
    ErrorEventDefinition modelErrorEvent = (ErrorEventDefinition) 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();
        // non-interrupting not yet supported
        boolean interrupting = true;
        activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createBoundaryEventActivityBehavior(boundaryEvent, interrupting, activity));
        ActivityImpl parentActivity = scope.findActivity(boundaryEvent.getAttachedToRefId());
        createBoundaryErrorEventDefinition(modelErrorEvent, interrupting, parentActivity, activity);
    }
}
Also used : ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) BoundaryEvent(org.activiti.bpmn.model.BoundaryEvent) ErrorEventDefinition(org.activiti.bpmn.model.ErrorEventDefinition) StartEvent(org.activiti.bpmn.model.StartEvent) ScopeImpl(org.activiti.engine.impl.pvm.process.ScopeImpl)

Aggregations

ScopeImpl (org.activiti.engine.impl.pvm.process.ScopeImpl)14 ActivityImpl (org.activiti.engine.impl.pvm.process.ActivityImpl)11 BoundaryEvent (org.activiti.bpmn.model.BoundaryEvent)3 EventDefinition (org.activiti.bpmn.model.EventDefinition)3 List (java.util.List)2 ErrorEventDefinition (org.activiti.bpmn.model.ErrorEventDefinition)2 MessageEventDefinition (org.activiti.bpmn.model.MessageEventDefinition)2 SignalEventDefinition (org.activiti.bpmn.model.SignalEventDefinition)2 StartEvent (org.activiti.bpmn.model.StartEvent)2 TimerEventDefinition (org.activiti.bpmn.model.TimerEventDefinition)2 EventSubscriptionDeclaration (org.activiti.engine.impl.bpmn.parser.EventSubscriptionDeclaration)2 ProcessDefinitionImpl (org.activiti.engine.impl.pvm.process.ProcessDefinitionImpl)2 TransitionImpl (org.activiti.engine.impl.pvm.process.TransitionImpl)2 ArrayList (java.util.ArrayList)1 BpmnModel (org.activiti.bpmn.model.BpmnModel)1 CancelEventDefinition (org.activiti.bpmn.model.CancelEventDefinition)1 CompensateEventDefinition (org.activiti.bpmn.model.CompensateEventDefinition)1 IntermediateCatchEvent (org.activiti.bpmn.model.IntermediateCatchEvent)1 Message (org.activiti.bpmn.model.Message)1 TerminateEventDefinition (org.activiti.bpmn.model.TerminateEventDefinition)1