Search in sources :

Example 71 with ActivityImpl

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

the class BpmnParseTest method testParseEscalationIntermediateThrowingEvent.

@Deployment
public void testParseEscalationIntermediateThrowingEvent() {
    ActivityImpl escalationThrowingEvent = findActivityInDeployedProcessDefinition("escalationThrowingEvent");
    assertEquals(ActivityTypes.INTERMEDIATE_EVENT_ESCALATION_THROW, escalationThrowingEvent.getProperties().get(BpmnProperties.TYPE));
    assertEquals(ThrowEscalationEventActivityBehavior.class, escalationThrowingEvent.getActivityBehavior().getClass());
}
Also used : ActivityImpl(org.camunda.bpm.engine.impl.pvm.process.ActivityImpl) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 72 with ActivityImpl

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

the class BpmnParseTest method testParseEscalationEndEvent.

@Deployment
public void testParseEscalationEndEvent() {
    ActivityImpl escalationEndEvent = findActivityInDeployedProcessDefinition("escalationEndEvent");
    assertEquals(ActivityTypes.END_EVENT_ESCALATION, escalationEndEvent.getProperties().get(BpmnProperties.TYPE));
    assertEquals(ThrowEscalationEventActivityBehavior.class, escalationEndEvent.getActivityBehavior().getClass());
}
Also used : ActivityImpl(org.camunda.bpm.engine.impl.pvm.process.ActivityImpl) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 73 with ActivityImpl

use of org.camunda.bpm.engine.impl.pvm.process.ActivityImpl 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 74 with ActivityImpl

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

the class LegacyBehavior method createActivityExecutionMapping.

/**
 * Creates an activity execution mapping, when the scope hierarchy and the execution hierarchy are out of sync.
 *
 * @param scopeExecutions
 * @param scopes
 * @return
 */
public static Map<ScopeImpl, PvmExecutionImpl> createActivityExecutionMapping(List<PvmExecutionImpl> scopeExecutions, List<ScopeImpl> scopes) {
    PvmExecutionImpl deepestExecution = scopeExecutions.get(0);
    if (isLegacyAsyncAtMultiInstance(deepestExecution)) {
        // in case the deepest execution is in fact async at multi-instance, the multi instance body is part
        // of the list of scopes, however it is not instantiated yet or has already ended. Thus it must be removed.
        scopes.remove(0);
    }
    // The trees are out of sync.
    // We are missing executions:
    int numOfMissingExecutions = scopes.size() - scopeExecutions.size();
    // We need to find out which executions are missing.
    // Consider: elements which did not use to be scopes are now scopes.
    // But, this does not mean that all instances of elements which became scopes
    // are missing their executions. We could have created new instances in the
    // lower part of the tree after legacy behavior was turned off while instances of these elements
    // further up the hierarchy miss scopes. So we need to iterate from the top down and skip all scopes which
    // were not scopes before:
    Collections.reverse(scopeExecutions);
    Collections.reverse(scopes);
    Map<ScopeImpl, PvmExecutionImpl> mapping = new HashMap<ScopeImpl, PvmExecutionImpl>();
    // process definition / process instance.
    mapping.put(scopes.get(0), scopeExecutions.get(0));
    // nested activities
    int executionCounter = 0;
    for (int i = 1; i < scopes.size(); i++) {
        ActivityImpl scope = (ActivityImpl) scopes.get(i);
        PvmExecutionImpl scopeExecutionCandidate = null;
        if (executionCounter + 1 < scopeExecutions.size()) {
            scopeExecutionCandidate = scopeExecutions.get(executionCounter + 1);
        }
        if (numOfMissingExecutions > 0 && wasNoScope(scope, scopeExecutionCandidate)) {
            // found a missing scope
            numOfMissingExecutions--;
        } else {
            executionCounter++;
        }
        if (executionCounter >= scopeExecutions.size()) {
            throw new ProcessEngineException("Cannot construct activity-execution mapping: there are " + "more scope executions missing than explained by the flow scope hierarchy.");
        }
        PvmExecutionImpl execution = scopeExecutions.get(executionCounter);
        mapping.put(scope, execution);
    }
    return mapping;
}
Also used : ActivityImpl(org.camunda.bpm.engine.impl.pvm.process.ActivityImpl) HashMap(java.util.HashMap) ScopeImpl(org.camunda.bpm.engine.impl.pvm.process.ScopeImpl) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Example 75 with ActivityImpl

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

the class LegacyBehavior method isLegacyAsyncAtMultiInstance.

/**
 * This returns true only if the provided execution has reached its wait state in a legacy engine version, because
 * only in that case, it can be async and waiting at the inner activity wrapped by the miBody. In versions >= 7.3,
 * the execution would reference the multi-instance body instead.
 */
protected static boolean isLegacyAsyncAtMultiInstance(PvmExecutionImpl execution) {
    ActivityImpl activity = execution.getActivity();
    if (activity != null) {
        boolean isAsync = execution.getActivityInstanceId() == null;
        boolean isAtMultiInstance = activity.getParentFlowScopeActivity() != null && activity.getParentFlowScopeActivity().getActivityBehavior() instanceof MultiInstanceActivityBehavior;
        return isAsync && isAtMultiInstance;
    } else {
        return false;
    }
}
Also used : ActivityImpl(org.camunda.bpm.engine.impl.pvm.process.ActivityImpl) MultiInstanceActivityBehavior(org.camunda.bpm.engine.impl.bpmn.behavior.MultiInstanceActivityBehavior) SequentialMultiInstanceActivityBehavior(org.camunda.bpm.engine.impl.bpmn.behavior.SequentialMultiInstanceActivityBehavior)

Aggregations

ActivityImpl (org.camunda.bpm.engine.impl.pvm.process.ActivityImpl)94 Deployment (org.camunda.bpm.engine.test.Deployment)29 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)12 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)12 ProcessDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)10 ScopeImpl (org.camunda.bpm.engine.impl.pvm.process.ScopeImpl)10 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)8 TransitionImpl (org.camunda.bpm.engine.impl.pvm.process.TransitionImpl)8 EventSubscriptionEntity (org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity)7 PvmExecutionImpl (org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl)7 MigrationInstruction (org.camunda.bpm.engine.migration.MigrationInstruction)5 ActivityBehavior (org.camunda.bpm.engine.impl.pvm.delegate.ActivityBehavior)4 ArrayList (java.util.ArrayList)3 DeploymentCache (org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache)3 PvmTransition (org.camunda.bpm.engine.impl.pvm.PvmTransition)3 ConditionalEventBehavior (org.camunda.bpm.engine.impl.bpmn.behavior.ConditionalEventBehavior)2 MultiInstanceActivityBehavior (org.camunda.bpm.engine.impl.bpmn.behavior.MultiInstanceActivityBehavior)2 SequentialMultiInstanceActivityBehavior (org.camunda.bpm.engine.impl.bpmn.behavior.SequentialMultiInstanceActivityBehavior)2 CoreModelElement (org.camunda.bpm.engine.impl.core.model.CoreModelElement)2 AsyncContinuationConfiguration (org.camunda.bpm.engine.impl.jobexecutor.AsyncContinuationJobHandler.AsyncContinuationConfiguration)2