Search in sources :

Example 6 with TransitionImpl

use of org.camunda.bpm.engine.impl.pvm.process.TransitionImpl in project camunda-bpm-platform by camunda.

the class BpmnParseTest method testParseDiagramInterchangeElements.

@Deployment
public void testParseDiagramInterchangeElements() {
    // Graphical information is not yet exposed publicly, so we need to do some
    // plumbing
    CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
    ProcessDefinitionEntity processDefinitionEntity = commandExecutor.execute(new Command<ProcessDefinitionEntity>() {

        @Override
        public ProcessDefinitionEntity execute(CommandContext commandContext) {
            return Context.getProcessEngineConfiguration().getDeploymentCache().findDeployedLatestProcessDefinitionByKey("myProcess");
        }
    });
    assertNotNull(processDefinitionEntity);
    assertEquals(7, processDefinitionEntity.getActivities().size());
    // Check if diagram has been created based on Diagram Interchange when it's
    // not a headless instance
    List<String> resourceNames = repositoryService.getDeploymentResourceNames(processDefinitionEntity.getDeploymentId());
    if (processEngineConfiguration.isCreateDiagramOnDeploy()) {
        assertEquals(2, resourceNames.size());
    } else {
        assertEquals(1, resourceNames.size());
    }
    for (ActivityImpl activity : processDefinitionEntity.getActivities()) {
        if (activity.getId().equals("theStart")) {
            assertActivityBounds(activity, 70, 255, 30, 30);
        } else if (activity.getId().equals("task1")) {
            assertActivityBounds(activity, 176, 230, 100, 80);
        } else if (activity.getId().equals("gateway1")) {
            assertActivityBounds(activity, 340, 250, 40, 40);
        } else if (activity.getId().equals("task2")) {
            assertActivityBounds(activity, 445, 138, 100, 80);
        } else if (activity.getId().equals("gateway2")) {
            assertActivityBounds(activity, 620, 250, 40, 40);
        } else if (activity.getId().equals("task3")) {
            assertActivityBounds(activity, 453, 304, 100, 80);
        } else if (activity.getId().equals("theEnd")) {
            assertActivityBounds(activity, 713, 256, 28, 28);
        }
        for (PvmTransition sequenceFlow : activity.getOutgoingTransitions()) {
            assertTrue(((TransitionImpl) sequenceFlow).getWaypoints().size() >= 4);
            TransitionImpl transitionImpl = (TransitionImpl) sequenceFlow;
            if (transitionImpl.getId().equals("flowStartToTask1")) {
                assertSequenceFlowWayPoints(transitionImpl, 100, 270, 176, 270);
            } else if (transitionImpl.getId().equals("flowTask1ToGateway1")) {
                assertSequenceFlowWayPoints(transitionImpl, 276, 270, 340, 270);
            } else if (transitionImpl.getId().equals("flowGateway1ToTask2")) {
                assertSequenceFlowWayPoints(transitionImpl, 360, 250, 360, 178, 445, 178);
            } else if (transitionImpl.getId().equals("flowGateway1ToTask3")) {
                assertSequenceFlowWayPoints(transitionImpl, 360, 290, 360, 344, 453, 344);
            } else if (transitionImpl.getId().equals("flowTask2ToGateway2")) {
                assertSequenceFlowWayPoints(transitionImpl, 545, 178, 640, 178, 640, 250);
            } else if (transitionImpl.getId().equals("flowTask3ToGateway2")) {
                assertSequenceFlowWayPoints(transitionImpl, 553, 344, 640, 344, 640, 290);
            } else if (transitionImpl.getId().equals("flowGateway2ToEnd")) {
                assertSequenceFlowWayPoints(transitionImpl, 660, 270, 713, 270);
            }
        }
    }
}
Also used : TransitionImpl(org.camunda.bpm.engine.impl.pvm.process.TransitionImpl) CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) ActivityImpl(org.camunda.bpm.engine.impl.pvm.process.ActivityImpl) CommandExecutor(org.camunda.bpm.engine.impl.interceptor.CommandExecutor) ProcessDefinitionEntity(org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity) PvmTransition(org.camunda.bpm.engine.impl.pvm.PvmTransition) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 7 with TransitionImpl

use of org.camunda.bpm.engine.impl.pvm.process.TransitionImpl in project camunda-bpm-platform by camunda.

the class AsyncContinuationJobHandler method execute.

@Override
public void execute(AsyncContinuationConfiguration configuration, ExecutionEntity execution, CommandContext commandContext, String tenantId) {
    LegacyBehavior.repairMultiInstanceAsyncJob(execution);
    PvmAtomicOperation atomicOperation = findMatchingAtomicOperation(configuration.getAtomicOperation());
    ensureNotNull("Cannot process job with configuration " + configuration, "atomicOperation", atomicOperation);
    // reset transition id.
    String transitionId = configuration.getTransitionId();
    if (transitionId != null) {
        PvmActivity activity = execution.getActivity();
        TransitionImpl transition = (TransitionImpl) activity.findOutgoingTransition(transitionId);
        execution.setTransition(transition);
    }
    Context.getCommandInvocationContext().performOperation(atomicOperation, execution);
}
Also used : TransitionImpl(org.camunda.bpm.engine.impl.pvm.process.TransitionImpl) PvmAtomicOperation(org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperation) PvmActivity(org.camunda.bpm.engine.impl.pvm.PvmActivity)

Example 8 with TransitionImpl

use of org.camunda.bpm.engine.impl.pvm.process.TransitionImpl in project camunda-bpm-platform by camunda.

the class PvmAtomicOperationActivityInitStackNotifyListenerStart method eventNotificationsCompleted.

protected void eventNotificationsCompleted(PvmExecutionImpl execution) {
    super.eventNotificationsCompleted(execution);
    execution.activityInstanceStarted();
    ExecutionStartContext startContext = execution.getExecutionStartContext();
    InstantiationStack instantiationStack = startContext.getInstantiationStack();
    PvmExecutionImpl propagatingExecution = execution;
    ActivityImpl activity = execution.getActivity();
    if (activity.getActivityBehavior() instanceof ModificationObserverBehavior) {
        ModificationObserverBehavior behavior = (ModificationObserverBehavior) activity.getActivityBehavior();
        List<ActivityExecution> concurrentExecutions = behavior.initializeScope(propagatingExecution, 1);
        propagatingExecution = (PvmExecutionImpl) concurrentExecutions.get(0);
    }
    // if the stack has been instantiated
    if (instantiationStack.getActivities().isEmpty() && instantiationStack.getTargetActivity() != null) {
        // as if we are entering the target activity instance id via a transition
        propagatingExecution.setActivityInstanceId(null);
        // execute the target activity with this execution
        startContext.applyVariables(propagatingExecution);
        propagatingExecution.setActivity(instantiationStack.getTargetActivity());
        propagatingExecution.performOperation(ACTIVITY_START_CREATE_SCOPE);
    } else if (instantiationStack.getActivities().isEmpty() && instantiationStack.getTargetTransition() != null) {
        // as if we are entering the target activity instance id via a transition
        propagatingExecution.setActivityInstanceId(null);
        // execute the target transition with this execution
        PvmTransition transition = instantiationStack.getTargetTransition();
        startContext.applyVariables(propagatingExecution);
        propagatingExecution.setActivity(transition.getSource());
        propagatingExecution.setTransition((TransitionImpl) transition);
        propagatingExecution.performOperation(TRANSITION_START_NOTIFY_LISTENER_TAKE);
    } else {
        // else instantiate the activity stack further
        propagatingExecution.setActivity(null);
        propagatingExecution.performOperation(ACTIVITY_INIT_STACK);
    }
}
Also used : TransitionImpl(org.camunda.bpm.engine.impl.pvm.process.TransitionImpl) ActivityImpl(org.camunda.bpm.engine.impl.pvm.process.ActivityImpl) InstantiationStack(org.camunda.bpm.engine.impl.pvm.runtime.InstantiationStack) PvmExecutionImpl(org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl) ActivityExecution(org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution) ExecutionStartContext(org.camunda.bpm.engine.impl.pvm.runtime.ExecutionStartContext) ModificationObserverBehavior(org.camunda.bpm.engine.impl.pvm.delegate.ModificationObserverBehavior) PvmTransition(org.camunda.bpm.engine.impl.pvm.PvmTransition)

Example 9 with TransitionImpl

use of org.camunda.bpm.engine.impl.pvm.process.TransitionImpl in project camunda-bpm-platform by camunda.

the class PvmAtomicOperationTransitionNotifyListenerStart method eventNotificationsCompleted.

protected void eventNotificationsCompleted(PvmExecutionImpl execution) {
    super.eventNotificationsCompleted(execution);
    TransitionImpl transition = execution.getTransition();
    PvmActivity destination;
    if (transition == null) {
        // this is null after async cont. -> transition is not stored in execution
        destination = execution.getActivity();
    } else {
        destination = transition.getDestination();
    }
    execution.setTransition(null);
    execution.setActivity(destination);
    ExecutionStartContext executionStartContext = execution.getExecutionStartContext();
    if (executionStartContext != null) {
        executionStartContext.executionStarted(execution);
        execution.disposeExecutionStartContext();
    }
    execution.dispatchDelayedEventsAndPerformOperation(ACTIVITY_EXECUTE);
}
Also used : TransitionImpl(org.camunda.bpm.engine.impl.pvm.process.TransitionImpl) ExecutionStartContext(org.camunda.bpm.engine.impl.pvm.runtime.ExecutionStartContext) PvmActivity(org.camunda.bpm.engine.impl.pvm.PvmActivity)

Example 10 with TransitionImpl

use of org.camunda.bpm.engine.impl.pvm.process.TransitionImpl in project camunda-bpm-platform by camunda.

the class EntitySerializationTest method testExecutionEntitySerialization.

public void testExecutionEntitySerialization() throws Exception {
    ExecutionEntity execution = new ExecutionEntity();
    ActivityImpl activityImpl = new ActivityImpl("test", null);
    activityImpl.getExecutionListeners().put("start", Collections.<ExecutionListener>singletonList(new TestExecutionListener()));
    execution.setActivity(activityImpl);
    ProcessDefinitionImpl processDefinitionImpl = new ProcessDefinitionImpl("test");
    processDefinitionImpl.getExecutionListeners().put("start", Collections.<ExecutionListener>singletonList(new TestExecutionListener()));
    execution.setProcessDefinition(processDefinitionImpl);
    TransitionImpl transitionImpl = new TransitionImpl("test", new ProcessDefinitionImpl("test"));
    transitionImpl.addExecutionListener(new TestExecutionListener());
    execution.setTransition(transitionImpl);
    execution.getProcessInstanceStartContext().setInitial(activityImpl);
    execution.setSuperExecution(new ExecutionEntity());
    execution.setActive(true);
    execution.setCanceled(false);
    execution.setBusinessKey("myBusinessKey");
    execution.setDeleteReason("no reason");
    execution.setActivityInstanceId("123");
    execution.setScope(false);
    byte[] data = writeObject(execution);
    execution = (ExecutionEntity) readObject(data);
    assertEquals("myBusinessKey", execution.getBusinessKey());
    assertEquals("no reason", execution.getDeleteReason());
    assertEquals("123", execution.getActivityInstanceId());
}
Also used : TransitionImpl(org.camunda.bpm.engine.impl.pvm.process.TransitionImpl) ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) ActivityImpl(org.camunda.bpm.engine.impl.pvm.process.ActivityImpl) ProcessDefinitionImpl(org.camunda.bpm.engine.impl.pvm.process.ProcessDefinitionImpl)

Aggregations

TransitionImpl (org.camunda.bpm.engine.impl.pvm.process.TransitionImpl)11 ActivityImpl (org.camunda.bpm.engine.impl.pvm.process.ActivityImpl)8 PvmActivity (org.camunda.bpm.engine.impl.pvm.PvmActivity)4 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)3 PvmTransition (org.camunda.bpm.engine.impl.pvm.PvmTransition)3 CoreModelElement (org.camunda.bpm.engine.impl.core.model.CoreModelElement)2 AsyncContinuationConfiguration (org.camunda.bpm.engine.impl.jobexecutor.AsyncContinuationJobHandler.AsyncContinuationConfiguration)2 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)2 ProcessDefinitionImpl (org.camunda.bpm.engine.impl.pvm.process.ProcessDefinitionImpl)2 ExecutionStartContext (org.camunda.bpm.engine.impl.pvm.runtime.ExecutionStartContext)2 NotValidException (org.camunda.bpm.engine.exception.NotValidException)1 ActivityExecutionTreeMapping (org.camunda.bpm.engine.impl.ActivityExecutionTreeMapping)1 CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)1 CommandExecutor (org.camunda.bpm.engine.impl.interceptor.CommandExecutor)1 MigratingJobInstance (org.camunda.bpm.engine.impl.migration.instance.MigratingJobInstance)1 ProcessDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)1 PvmScope (org.camunda.bpm.engine.impl.pvm.PvmScope)1 ActivityExecution (org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution)1 ModificationObserverBehavior (org.camunda.bpm.engine.impl.pvm.delegate.ModificationObserverBehavior)1 ActivityStartBehavior (org.camunda.bpm.engine.impl.pvm.process.ActivityStartBehavior)1