Search in sources :

Example 71 with ActivityImpl

use of org.activiti.engine.impl.pvm.process.ActivityImpl 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 72 with ActivityImpl

use of org.activiti.engine.impl.pvm.process.ActivityImpl 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)

Example 73 with ActivityImpl

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

the class ErrorEventDefinitionParseHandler method createBoundaryErrorEventDefinition.

public void createBoundaryErrorEventDefinition(ErrorEventDefinition errorEventDefinition, boolean interrupting, ActivityImpl activity, ActivityImpl nestedErrorEventActivity) {
    nestedErrorEventActivity.setProperty("type", "boundaryError");
    ScopeImpl catchingScope = nestedErrorEventActivity.getParent();
    ((ActivityImpl) catchingScope).setScope(true);
    org.activiti.engine.impl.bpmn.parser.ErrorEventDefinition definition = new org.activiti.engine.impl.bpmn.parser.ErrorEventDefinition(nestedErrorEventActivity.getId());
    definition.setErrorCode(errorEventDefinition.getErrorCode());
    addErrorEventDefinition(definition, catchingScope);
}
Also used : ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) ErrorEventDefinition(org.activiti.bpmn.model.ErrorEventDefinition) ScopeImpl(org.activiti.engine.impl.pvm.process.ScopeImpl)

Example 74 with ActivityImpl

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

the class TimerExecuteNestedActivityJobHandler method execute.

public void execute(JobEntity job, String configuration, ExecutionEntity execution, CommandContext commandContext) {
    String nestedActivityId = TimerEventHandler.getActivityIdFromConfiguration(configuration);
    ActivityImpl borderEventActivity = execution.getProcessDefinition().findActivity(nestedActivityId);
    if (borderEventActivity == null) {
        throw new ActivitiException("Error while firing timer: border event activity " + nestedActivityId + " not found");
    }
    try {
        if (commandContext.getEventDispatcher().isEnabled()) {
            commandContext.getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.TIMER_FIRED, job));
            dispatchActivityTimeoutIfNeeded(job, execution, commandContext);
        }
        borderEventActivity.getActivityBehavior().execute(execution);
    } catch (RuntimeException e) {
        log.error("exception during timer execution", e);
        throw e;
    } catch (Exception e) {
        log.error("exception during timer execution", e);
        throw new ActivitiException("exception during timer execution: " + e.getMessage(), e);
    }
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) ActivitiException(org.activiti.engine.ActivitiException)

Example 75 with ActivityImpl

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

the class TimerExecuteNestedActivityJobHandler method dispatchExecutionTimeOut.

protected void dispatchExecutionTimeOut(JobEntity timerEntity, ExecutionEntity execution, CommandContext commandContext) {
    // subprocesses
    for (ExecutionEntity subExecution : execution.getExecutions()) {
        dispatchExecutionTimeOut(timerEntity, subExecution, commandContext);
    }
    // call activities
    ExecutionEntity subProcessInstance = commandContext.getExecutionEntityManager().findSubProcessInstanceBySuperExecutionId(execution.getId());
    if (subProcessInstance != null) {
        dispatchExecutionTimeOut(timerEntity, subProcessInstance, commandContext);
    }
    // activity with timer boundary event
    ActivityImpl activity = execution.getActivity();
    if (activity != null && activity.getActivityBehavior() != null) {
        dispatchActivityTimeOut(timerEntity, activity, execution, commandContext);
    }
}
Also used : ExecutionEntity(org.activiti.engine.impl.persistence.entity.ExecutionEntity) ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl)

Aggregations

ActivityImpl (org.activiti.engine.impl.pvm.process.ActivityImpl)87 ExecutionEntity (org.activiti.engine.impl.persistence.entity.ExecutionEntity)15 ActivitiException (org.activiti.engine.ActivitiException)14 ProcessDefinitionEntity (org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)13 ScopeImpl (org.activiti.engine.impl.pvm.process.ScopeImpl)11 TransitionImpl (org.activiti.engine.impl.pvm.process.TransitionImpl)9 PvmTransition (org.activiti.engine.impl.pvm.PvmTransition)8 BoundaryEvent (org.activiti.bpmn.model.BoundaryEvent)7 ArrayList (java.util.ArrayList)6 ActivityExecution (org.activiti.engine.impl.pvm.delegate.ActivityExecution)6 ProcessDefinitionImpl (org.activiti.engine.impl.pvm.process.ProcessDefinitionImpl)6 List (java.util.List)5 EventDefinition (org.activiti.bpmn.model.EventDefinition)4 StartEvent (org.activiti.bpmn.model.StartEvent)4 IOSpecification (org.activiti.engine.impl.bpmn.data.IOSpecification)4 ActivityBehavior (org.activiti.engine.impl.pvm.delegate.ActivityBehavior)4 HashMap (java.util.HashMap)3 BpmnModel (org.activiti.bpmn.model.BpmnModel)3 IntermediateCatchEvent (org.activiti.bpmn.model.IntermediateCatchEvent)3 PvmProcessDefinition (org.activiti.engine.impl.pvm.PvmProcessDefinition)3