Search in sources :

Example 26 with ActivityImpl

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

the class EventSubProcessStartEventActivityBehavior method execute.

@Override
public void execute(ActivityExecution execution) throws Exception {
    InterpretableExecution interpretableExecution = (InterpretableExecution) execution;
    ActivityImpl activity = interpretableExecution.getProcessDefinition().findActivity(activityId);
    ActivityExecution outgoingExecution = execution;
    if (isInterrupting) {
        execution.destroyScope("Event subprocess triggered using activity " + activityId);
    } else {
        outgoingExecution = execution.createExecution();
        outgoingExecution.setActive(true);
        outgoingExecution.setScope(false);
        outgoingExecution.setConcurrent(true);
    }
    // set the outgoing execution to this activity
    ((InterpretableExecution) outgoingExecution).setActivity(activity);
    // continue execution
    outgoingExecution.takeAll(activity.getOutgoingTransitions(), Collections.EMPTY_LIST);
}
Also used : ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) ActivityExecution(org.activiti.engine.impl.pvm.delegate.ActivityExecution) InterpretableExecution(org.activiti.engine.impl.pvm.runtime.InterpretableExecution)

Example 27 with ActivityImpl

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

the class SubProcessActivityBehavior method execute.

public void execute(ActivityExecution execution) throws Exception {
    PvmActivity activity = execution.getActivity();
    ActivityImpl initialActivity = (ActivityImpl) activity.getProperty(BpmnParse.PROPERTYNAME_INITIAL);
    if (initialActivity == null) {
        throw new ActivitiException("No initial activity found for subprocess " + execution.getActivity().getId());
    }
    // initialize the template-defined data objects as variables
    initializeDataObjects(execution, activity);
    if (initialActivity.getActivityBehavior() != null && initialActivity.getActivityBehavior() instanceof NoneStartEventActivityBehavior) {
        // embedded subprocess: only none start allowed
        ((ExecutionEntity) execution).setActivity(initialActivity);
        Context.getCommandContext().getHistoryManager().recordActivityStart((ExecutionEntity) execution);
    }
    execution.executeActivity(initialActivity);
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) ExecutionEntity(org.activiti.engine.impl.persistence.entity.ExecutionEntity) PvmActivity(org.activiti.engine.impl.pvm.PvmActivity)

Example 28 with ActivityImpl

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

the class AbstractBpmnActivityBehavior method createCompensateEventSubscription.

protected void createCompensateEventSubscription(ActivityExecution execution) {
    String compensationHandlerId = (String) execution.getActivity().getProperty(BpmnParse.PROPERTYNAME_COMPENSATION_HANDLER_ID);
    ExecutionEntity executionEntity = (ExecutionEntity) execution;
    ActivityImpl compensationHandlder = executionEntity.getProcessDefinition().findActivity(compensationHandlerId);
    PvmScope scopeActivitiy = compensationHandlder.getParent();
    ExecutionEntity scopeExecution = ScopeUtil.findScopeExecutionForScope(executionEntity, scopeActivitiy);
    CompensateEventSubscriptionEntity compensateEventSubscriptionEntity = CompensateEventSubscriptionEntity.createAndInsert(scopeExecution);
    compensateEventSubscriptionEntity.setActivity(compensationHandlder);
}
Also used : PvmScope(org.activiti.engine.impl.pvm.PvmScope) ExecutionEntity(org.activiti.engine.impl.persistence.entity.ExecutionEntity) ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) CompensateEventSubscriptionEntity(org.activiti.engine.impl.persistence.entity.CompensateEventSubscriptionEntity)

Example 29 with ActivityImpl

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

the class BoundaryEventActivityBehavior method execute.

@SuppressWarnings("unchecked")
public void execute(ActivityExecution execution) throws Exception {
    ExecutionEntity executionEntity = (ExecutionEntity) execution;
    ActivityImpl boundaryActivity = executionEntity.getProcessDefinition().findActivity(activityId);
    ActivityImpl interruptedActivity = executionEntity.getActivity();
    List<PvmTransition> outgoingTransitions = boundaryActivity.getOutgoingTransitions();
    List<ExecutionEntity> interruptedExecutions = null;
    if (interrupting) {
        // Call activity
        if (executionEntity.getSubProcessInstance() != null) {
            executionEntity.getSubProcessInstance().deleteCascade(executionEntity.getDeleteReason());
        } else {
            Context.getCommandContext().getHistoryManager().recordActivityEnd(executionEntity);
        }
        executionEntity.setActivity(boundaryActivity);
        interruptedExecutions = new ArrayList<ExecutionEntity>(executionEntity.getExecutions());
        for (ExecutionEntity interruptedExecution : interruptedExecutions) {
            interruptedExecution.deleteCascade("interrupting boundary event '" + execution.getActivity().getId() + "' fired");
        }
        execution.takeAll(outgoingTransitions, (List) interruptedExecutions);
    } else {
        // non interrupting event, introduced with BPMN 2.0, we need to create a new execution in this case
        // create a new execution and move it out from the timer activity
        ExecutionEntity concurrentRoot = executionEntity.getParent().isConcurrent() ? executionEntity.getParent() : executionEntity;
        ExecutionEntity outgoingExecution = concurrentRoot.createExecution();
        outgoingExecution.setActive(true);
        outgoingExecution.setScope(false);
        outgoingExecution.setConcurrent(true);
        outgoingExecution.takeAll(outgoingTransitions, Collections.EMPTY_LIST);
        outgoingExecution.remove();
        // now we have to move the execution back to the real activity
        // since the execution stays there (non interrupting) and it was
        // set to the boundary event before
        executionEntity.setActivity(interruptedActivity);
    }
}
Also used : ExecutionEntity(org.activiti.engine.impl.persistence.entity.ExecutionEntity) ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) PvmTransition(org.activiti.engine.impl.pvm.PvmTransition)

Example 30 with ActivityImpl

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

the class CancelEndEventActivityBehavior method execute.

@Override
public void execute(ActivityExecution execution) throws Exception {
    // find cancel boundary event:
    ActivityImpl cancelBoundaryEvent = ScopeUtil.findInParentScopesByBehaviorType((ActivityImpl) execution.getActivity(), CancelBoundaryEventActivityBehavior.class);
    if (cancelBoundaryEvent == null) {
        throw new ActivitiException("Could not find cancel boundary event for cancel end event " + execution.getActivity());
    }
    ActivityExecution scopeExecution = ScopeUtil.findScopeExecutionForScope((ExecutionEntity) execution, cancelBoundaryEvent.getParentActivity());
    // end all executions and process instances in the scope of the transaction
    scopeExecution.destroyScope("cancel end event fired");
    // the scope execution executes the boundary event
    InterpretableExecution outgoingExecution = (InterpretableExecution) scopeExecution;
    outgoingExecution.setActivity(cancelBoundaryEvent);
    outgoingExecution.setActive(true);
    // execute the boundary
    cancelBoundaryEvent.getActivityBehavior().execute(outgoingExecution);
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) ActivityExecution(org.activiti.engine.impl.pvm.delegate.ActivityExecution) InterpretableExecution(org.activiti.engine.impl.pvm.runtime.InterpretableExecution)

Aggregations

ActivityImpl (org.activiti.engine.impl.pvm.process.ActivityImpl)82 ExecutionEntity (org.activiti.engine.impl.persistence.entity.ExecutionEntity)15 ActivitiException (org.activiti.engine.ActivitiException)14 ScopeImpl (org.activiti.engine.impl.pvm.process.ScopeImpl)11 ProcessDefinitionEntity (org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)9 BoundaryEvent (org.activiti.bpmn.model.BoundaryEvent)7 TransitionImpl (org.activiti.engine.impl.pvm.process.TransitionImpl)7 PvmTransition (org.activiti.engine.impl.pvm.PvmTransition)6 ActivityExecution (org.activiti.engine.impl.pvm.delegate.ActivityExecution)6 ProcessDefinitionImpl (org.activiti.engine.impl.pvm.process.ProcessDefinitionImpl)6 ArrayList (java.util.ArrayList)5 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 BpmnModel (org.activiti.bpmn.model.BpmnModel)3 IntermediateCatchEvent (org.activiti.bpmn.model.IntermediateCatchEvent)3 SignalEventDefinition (org.activiti.bpmn.model.SignalEventDefinition)3 PvmProcessDefinition (org.activiti.engine.impl.pvm.PvmProcessDefinition)3