Search in sources :

Example 36 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 37 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 38 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 39 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)

Example 40 with ActivityImpl

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

the class TerminateEndEventTest method testParseTerminateEndEventDefinitionWithExtensions.

public void testParseTerminateEndEventDefinitionWithExtensions() {
    org.activiti.engine.repository.Deployment deployment = repositoryService.createDeployment().addClasspathResource("org/activiti/engine/test/bpmn/event/end/TerminateEndEventTest.parseExtensionElements.bpmn20.xml").deploy();
    ProcessDefinition processDefinitionQuery = repositoryService.createProcessDefinitionQuery().deploymentId(deployment.getId()).singleResult();
    ProcessDefinitionEntity processDefinition = this.processEngineConfiguration.getProcessDefinitionCache().get(processDefinitionQuery.getId());
    assertThat(processDefinition.getActivities().size(), is(2));
    ActivityImpl endEvent = processDefinition.getActivities().get(1);
    assertThat(endEvent.getId(), is("terminateEnd"));
    assertThat(endEvent.getActivityBehavior(), instanceOf(TerminateEndEventActivityBehavior.class));
    TerminateEndEventActivityBehavior terminateEndEventBehavior = (TerminateEndEventActivityBehavior) endEvent.getActivityBehavior();
    Map<String, List<ExtensionElement>> extensionElements = terminateEndEventBehavior.getEndEvent().getExtensionElements();
    assertThat(extensionElements.size(), is(1));
    List<ExtensionElement> strangeProperties = extensionElements.get("strangeProperty");
    assertThat(strangeProperties.size(), is(1));
    ExtensionElement strangeProperty = strangeProperties.get(0);
    assertThat(strangeProperty.getNamespace(), is("http://activiti.org/bpmn"));
    assertThat(strangeProperty.getElementText(), is("value"));
    assertThat(strangeProperty.getAttributes().size(), is(1));
    ExtensionAttribute id = strangeProperty.getAttributes().get("id").get(0);
    assertThat(id.getName(), is("id"));
    assertThat(id.getValue(), is("strangeId"));
    repositoryService.deleteDeployment(deployment.getId());
}
Also used : ExtensionElement(org.activiti.bpmn.model.ExtensionElement) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) ExtensionAttribute(org.activiti.bpmn.model.ExtensionAttribute) ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) List(java.util.List) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity) TerminateEndEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.TerminateEndEventActivityBehavior)

Aggregations

ActivityImpl (org.activiti.engine.impl.pvm.process.ActivityImpl)83 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 PvmTransition (org.activiti.engine.impl.pvm.PvmTransition)7 TransitionImpl (org.activiti.engine.impl.pvm.process.TransitionImpl)7 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 HashMap (java.util.HashMap)3 BpmnModel (org.activiti.bpmn.model.BpmnModel)3 IntermediateCatchEvent (org.activiti.bpmn.model.IntermediateCatchEvent)3 SignalEventDefinition (org.activiti.bpmn.model.SignalEventDefinition)3