Java Code Examples for org.activiti.engine.impl.pvm.process.ActivityImpl#setActivityBehavior()

The following examples show how to use org.activiti.engine.impl.pvm.process.ActivityImpl#setActivityBehavior() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StartEventParseHandler.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
protected void createProcessDefinitionStartEvent(BpmnParse bpmnParse, ActivityImpl startEventActivity, StartEvent startEvent, ProcessDefinitionEntity processDefinition) {
    if (StringUtils.isNotEmpty(startEvent.getInitiator())) {
        processDefinition.setProperty(PROPERTYNAME_INITIATOR_VARIABLE_NAME, startEvent.getInitiator());
    }

    // all start events share the same behavior:
    startEventActivity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createNoneStartEventActivityBehavior(startEvent));
    if (!startEvent.getEventDefinitions().isEmpty()) {
        EventDefinition eventDefinition = startEvent.getEventDefinitions().get(0);
        if (eventDefinition instanceof TimerEventDefinition
                || eventDefinition instanceof MessageEventDefinition
                || eventDefinition instanceof SignalEventDefinition) {
            bpmnParse.getBpmnParserHandlers().parseElement(bpmnParse, eventDefinition);
        } else {
            LOGGER.warn("Unsupported event definition on start event {}", eventDefinition);
        }
    }
}
 
Example 2
Source File: IntermediateThrowEventParseHandler.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Override
protected void executeParse(BpmnParse bpmnParse, ThrowEvent intermediateEvent) {

    ActivityImpl nestedActivityImpl = createActivityOnCurrentScope(bpmnParse, intermediateEvent, BpmnXMLConstants.ELEMENT_EVENT_THROW);

    EventDefinition eventDefinition = null;
    if (!intermediateEvent.getEventDefinitions().isEmpty()) {
        eventDefinition = intermediateEvent.getEventDefinitions().get(0);
    }

    nestedActivityImpl.setAsync(intermediateEvent.isAsynchronous());
    nestedActivityImpl.setExclusive(!intermediateEvent.isNotExclusive());

    if (eventDefinition instanceof SignalEventDefinition) {
        bpmnParse.getBpmnParserHandlers().parseElement(bpmnParse, eventDefinition);
    } else if (eventDefinition instanceof org.flowable.bpmn.model.CompensateEventDefinition) {
        bpmnParse.getBpmnParserHandlers().parseElement(bpmnParse, eventDefinition);
    } else if (eventDefinition == null) {
        nestedActivityImpl.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createIntermediateThrowNoneEventActivityBehavior(intermediateEvent));
    } else {
        LOGGER.warn("Unsupported intermediate throw event type for throw event {}", intermediateEvent.getId());
    }
}
 
Example 3
Source File: RuntimeActivityCreatorSupport.java    From openwebflow with BSD 2-Clause "Simplified" License 6 votes vote down vote up
protected ActivityImpl createActivity(ProcessEngine processEngine, ProcessDefinitionEntity processDefinition,
		ActivityImpl prototypeActivity, String cloneActivityId, String assignee)
{
	ActivityImpl clone = cloneActivity(processDefinition, prototypeActivity, cloneActivityId, "executionListeners",
		"properties");

	//设置assignee
	UserTaskActivityBehavior activityBehavior = (UserTaskActivityBehavior) (prototypeActivity.getActivityBehavior());

	TaskDefinition taskDefinition = cloneTaskDefinition(activityBehavior.getTaskDefinition());
	taskDefinition.setKey(cloneActivityId);
	if (assignee != null)
	{
		taskDefinition.setAssigneeExpression(new FixedValue(assignee));
	}

	UserTaskActivityBehavior cloneActivityBehavior = new UserTaskActivityBehavior(prototypeActivity.getId(), taskDefinition);
	clone.setActivityBehavior(cloneActivityBehavior);

	return clone;
}
 
Example 4
Source File: UserTaskParseHandler.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@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));
}
 
Example 5
Source File: ManualTaskParseHandler.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
protected void executeParse(BpmnParse bpmnParse, ManualTask manualTask) {
    ActivityImpl activity = createActivityOnCurrentScope(bpmnParse, manualTask, BpmnXMLConstants.ELEMENT_TASK_MANUAL);
    activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createManualTaskActivityBehavior(manualTask));

    activity.setAsync(manualTask.isAsynchronous());
    activity.setExclusive(!manualTask.isNotExclusive());
}
 
Example 6
Source File: ErrorEventDefinitionParseHandler.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@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);

    }
}
 
Example 7
Source File: CancelEventDefinitionParseHandler.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
protected void executeParse(BpmnParse bpmnParse, CancelEventDefinition cancelEventDefinition) {
    if (bpmnParse.getCurrentFlowElement() instanceof BoundaryEvent) {
        ActivityImpl activity = bpmnParse.getCurrentActivity();
        activity.setProperty("type", "cancelBoundaryCatch");
        activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createCancelBoundaryEventActivityBehavior(cancelEventDefinition));
    }

}
 
Example 8
Source File: BusinessRuleParseHandler.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
protected void executeParse(BpmnParse bpmnParse, BusinessRuleTask businessRuleTask) {

    ActivityImpl activity = createActivityOnCurrentScope(bpmnParse, businessRuleTask, BpmnXMLConstants.ELEMENT_TASK_BUSINESSRULE);
    activity.setAsync(businessRuleTask.isAsynchronous());
    activity.setExclusive(!businessRuleTask.isNotExclusive());
    activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createBusinessRuleTaskActivityBehavior(businessRuleTask));
}
 
Example 9
Source File: CallActivityParseHandler.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
protected void executeParse(BpmnParse bpmnParse, CallActivity callActivity) {

    ActivityImpl activity = createActivityOnCurrentScope(bpmnParse, callActivity, BpmnXMLConstants.ELEMENT_CALL_ACTIVITY);
    activity.setScope(true);
    activity.setAsync(callActivity.isAsynchronous());
    activity.setExclusive(!callActivity.isNotExclusive());
    activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createCallActivityBehavior(callActivity));
}
 
Example 10
Source File: SubProcessParseHandler.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@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();
}
 
Example 11
Source File: ReceiveTaskParseHandler.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
protected void executeParse(BpmnParse bpmnParse, ReceiveTask receiveTask) {
    ActivityImpl activity = createActivityOnCurrentScope(bpmnParse, receiveTask, BpmnXMLConstants.ELEMENT_TASK_RECEIVE);
    activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createReceiveTaskActivityBehavior(receiveTask));

    activity.setAsync(receiveTask.isAsynchronous());
    activity.setExclusive(!receiveTask.isNotExclusive());
}
 
Example 12
Source File: EventBasedGatewayParseHandler.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
protected void executeParse(BpmnParse bpmnParse, EventGateway gateway) {
    ActivityImpl activity = createActivityOnCurrentScope(bpmnParse, gateway, BpmnXMLConstants.ELEMENT_GATEWAY_EVENT);
    activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createEventBasedGatewayActivityBehavior(gateway));

    activity.setAsync(gateway.isAsynchronous());
    activity.setExclusive(!gateway.isNotExclusive());
    activity.setScope(true);
}
 
Example 13
Source File: SendTaskParseHandler.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
protected void executeParse(BpmnParse bpmnParse, SendTask sendTask) {

    ActivityImpl activity = createActivityOnCurrentScope(bpmnParse, sendTask, BpmnXMLConstants.ELEMENT_TASK_SEND);

    activity.setAsync(sendTask.isAsynchronous());
    activity.setExclusive(!sendTask.isNotExclusive());

    if (StringUtils.isNotEmpty(sendTask.getType())) {
        if (sendTask.getType().equalsIgnoreCase("mail")) {
            activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createMailActivityBehavior(sendTask));
        } else if (sendTask.getType().equalsIgnoreCase("mule")) {
            activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createMuleActivityBehavior(sendTask, bpmnParse.getBpmnModel()));
        } else if (sendTask.getType().equalsIgnoreCase("camel")) {
            activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createCamelActivityBehavior(sendTask, bpmnParse.getBpmnModel()));
        }

        // for web service
    } else if (ImplementationType.IMPLEMENTATION_TYPE_WEBSERVICE.equalsIgnoreCase(sendTask.getImplementationType()) &&
            StringUtils.isNotEmpty(sendTask.getOperationRef())) {

        WebServiceActivityBehavior webServiceActivityBehavior = bpmnParse.getActivityBehaviorFactory().createWebServiceActivityBehavior(sendTask, bpmnParse.getBpmnModel());
        activity.setActivityBehavior(webServiceActivityBehavior);

    } else {
        LOGGER.warn("One of the attributes 'type' or 'operation' is mandatory on sendTask {}", sendTask.getId());
    }
}
 
Example 14
Source File: InclusiveGatewayParseHandler.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
protected void executeParse(BpmnParse bpmnParse, InclusiveGateway gateway) {
    ActivityImpl activity = createActivityOnCurrentScope(bpmnParse, gateway, BpmnXMLConstants.ELEMENT_GATEWAY_INCLUSIVE);

    activity.setAsync(gateway.isAsynchronous());
    activity.setExclusive(!gateway.isNotExclusive());

    activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createInclusiveGatewayActivityBehavior(gateway));
}
 
Example 15
Source File: StartEventParseHandler.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
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());
            }
        }

    }
 
Example 16
Source File: AbstractActivityBpmnParseHandler.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
protected void createMultiInstanceLoopCharacteristics(BpmnParse bpmnParse, Activity modelActivity) {

        MultiInstanceLoopCharacteristics loopCharacteristics = modelActivity.getLoopCharacteristics();

        // Activity Behavior
        MultiInstanceActivityBehavior miActivityBehavior = null;
        ActivityImpl activity = bpmnParse.getCurrentScope().findActivity(modelActivity.getId());
        if (activity == null) {
            throw new ActivitiException("Activity " + modelActivity.getId() + " needed for multi instance cannot bv found");
        }

        if (loopCharacteristics.isSequential()) {
            miActivityBehavior = bpmnParse.getActivityBehaviorFactory().createSequentialMultiInstanceBehavior(
                    activity, (AbstractBpmnActivityBehavior) activity.getActivityBehavior());
        } else {
            miActivityBehavior = bpmnParse.getActivityBehaviorFactory().createParallelMultiInstanceBehavior(
                    activity, (AbstractBpmnActivityBehavior) activity.getActivityBehavior());
        }

        // ActivityImpl settings
        activity.setScope(true);
        activity.setProperty("multiInstance", loopCharacteristics.isSequential() ? "sequential" : "parallel");
        activity.setActivityBehavior(miActivityBehavior);

        ExpressionManager expressionManager = bpmnParse.getExpressionManager();

        // loop cardinality
        if (StringUtils.isNotEmpty(loopCharacteristics.getLoopCardinality())) {
            miActivityBehavior.setLoopCardinalityExpression(expressionManager.createExpression(loopCharacteristics.getLoopCardinality()));
        }

        // completion condition
        if (StringUtils.isNotEmpty(loopCharacteristics.getCompletionCondition())) {
            miActivityBehavior.setCompletionConditionExpression(expressionManager.createExpression(loopCharacteristics.getCompletionCondition()));
        }

        // activiti:collection
        if (StringUtils.isNotEmpty(loopCharacteristics.getInputDataItem())) {
            if (loopCharacteristics.getInputDataItem().contains("{")) {
                miActivityBehavior.setCollectionExpression(expressionManager.createExpression(loopCharacteristics.getInputDataItem()));
            } else {
                miActivityBehavior.setCollectionVariable(loopCharacteristics.getInputDataItem());
            }
        }

        // activiti:elementVariable
        if (StringUtils.isNotEmpty(loopCharacteristics.getElementVariable())) {
            miActivityBehavior.setCollectionElementVariable(loopCharacteristics.getElementVariable());
        }

        // activiti:elementIndexVariable
        if (StringUtils.isNotEmpty(loopCharacteristics.getElementIndexVariable())) {
            miActivityBehavior.setCollectionElementIndexVariable(loopCharacteristics.getElementIndexVariable());
        }

    }
 
Example 17
Source File: TransactionParseHandler.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
protected void executeParse(BpmnParse bpmnParse, Transaction transaction) {

    ActivityImpl activity = createActivityOnCurrentScope(bpmnParse, transaction, BpmnXMLConstants.ELEMENT_TRANSACTION);

    activity.setAsync(transaction.isAsynchronous());
    activity.setExclusive(!transaction.isNotExclusive());

    activity.setScope(true);
    activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createTransactionActivityBehavior(transaction));

    bpmnParse.setCurrentScope(activity);

    bpmnParse.processFlowElements(transaction.getFlowElements());
    processArtifacts(bpmnParse, transaction.getArtifacts(), activity);

    bpmnParse.removeCurrentScope();
}
 
Example 18
Source File: EndEventParseHandler.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
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.flowable.bpmn.model.ErrorEventDefinition) {
        org.flowable.bpmn.model.ErrorEventDefinition errorDefinition = (org.flowable.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));
    }
}
 
Example 19
Source File: IntermediateCatchEventParseHandler.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
protected void executeParse(BpmnParse bpmnParse, IntermediateCatchEvent event) {

    ActivityImpl nestedActivity = null;
    EventDefinition eventDefinition = null;
    if (!event.getEventDefinitions().isEmpty()) {
        eventDefinition = event.getEventDefinitions().get(0);
    }

    if (eventDefinition == null) {

        nestedActivity = createActivityOnCurrentScope(bpmnParse, event, BpmnXMLConstants.ELEMENT_EVENT_CATCH);
        nestedActivity.setAsync(event.isAsynchronous());
        nestedActivity.setExclusive(!event.isNotExclusive());

    } else {

        ScopeImpl scope = bpmnParse.getCurrentScope();
        String eventBasedGatewayId = getPrecedingEventBasedGateway(bpmnParse, event);
        if (eventBasedGatewayId != null) {
            ActivityImpl gatewayActivity = scope.findActivity(eventBasedGatewayId);
            nestedActivity = createActivityOnScope(bpmnParse, event, BpmnXMLConstants.ELEMENT_EVENT_CATCH, gatewayActivity);
        } else {
            nestedActivity = createActivityOnScope(bpmnParse, event, BpmnXMLConstants.ELEMENT_EVENT_CATCH, scope);
        }

        nestedActivity.setAsync(event.isAsynchronous());
        nestedActivity.setExclusive(!event.isNotExclusive());

        // Catch event behavior is the same for all types
        nestedActivity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createIntermediateCatchEventActivityBehavior(event));

        if (eventDefinition instanceof TimerEventDefinition
                || eventDefinition instanceof SignalEventDefinition
                || eventDefinition instanceof MessageEventDefinition) {

            bpmnParse.getBpmnParserHandlers().parseElement(bpmnParse, eventDefinition);

        } else {
            LOGGER.warn("Unsupported intermediate catch event type for event {}", event.getId());
        }
    }
}
 
Example 20
Source File: CompensateEventDefinitionParseHandler.java    From flowable-engine with Apache License 2.0 3 votes vote down vote up
@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?

    }

}