Search in sources :

Example 21 with PvmActivity

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

the class PvmAtomicOperationCreateConcurrentExecution method execute.

public void execute(PvmExecutionImpl execution) {
    // Invariant: execution is the Scope Execution for the activity's flow scope.
    PvmActivity activityToStart = execution.getNextActivity();
    execution.setNextActivity(null);
    PvmExecutionImpl propagatingExecution = execution.createConcurrentExecution();
    // set next activity on propagating execution
    propagatingExecution.setActivity(activityToStart);
    concurrentExecutionCreated(propagatingExecution);
}
Also used : PvmExecutionImpl(org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl) PvmActivity(org.camunda.bpm.engine.impl.pvm.PvmActivity)

Example 22 with PvmActivity

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

the class RepositoryServiceTest method testProcessDefinitionIntrospection.

public void testProcessDefinitionIntrospection() {
    String deploymentId = repositoryService.createDeployment().addClasspathResource("org/camunda/bpm/engine/test/api/repository/processOne.bpmn20.xml").deploy().getId();
    String procDefId = repositoryService.createProcessDefinitionQuery().singleResult().getId();
    ReadOnlyProcessDefinition processDefinition = ((RepositoryServiceImpl) repositoryService).getDeployedProcessDefinition(procDefId);
    assertEquals(procDefId, processDefinition.getId());
    assertEquals("Process One", processDefinition.getName());
    assertEquals("the first process", processDefinition.getProperty("documentation"));
    PvmActivity start = processDefinition.findActivity("start");
    assertNotNull(start);
    assertEquals("start", start.getId());
    assertEquals("S t a r t", start.getProperty("name"));
    assertEquals("the start event", start.getProperty("documentation"));
    assertEquals(Collections.EMPTY_LIST, start.getActivities());
    List<PvmTransition> outgoingTransitions = start.getOutgoingTransitions();
    assertEquals(1, outgoingTransitions.size());
    assertEquals("${a == b}", outgoingTransitions.get(0).getProperty(BpmnParse.PROPERTYNAME_CONDITION_TEXT));
    PvmActivity end = processDefinition.findActivity("end");
    assertNotNull(end);
    assertEquals("end", end.getId());
    PvmTransition transition = outgoingTransitions.get(0);
    assertEquals("flow1", transition.getId());
    assertEquals("Flow One", transition.getProperty("name"));
    assertEquals("The only transitions in the process", transition.getProperty("documentation"));
    assertSame(start, transition.getSource());
    assertSame(end, transition.getDestination());
    repositoryService.deleteDeployment(deploymentId);
}
Also used : ReadOnlyProcessDefinition(org.camunda.bpm.engine.impl.pvm.ReadOnlyProcessDefinition) RepositoryServiceImpl(org.camunda.bpm.engine.impl.RepositoryServiceImpl) PvmActivity(org.camunda.bpm.engine.impl.pvm.PvmActivity) PvmTransition(org.camunda.bpm.engine.impl.pvm.PvmTransition)

Example 23 with PvmActivity

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

the class ThrowEscalationEventActivityBehavior method execute.

@Override
public void execute(ActivityExecution execution) throws Exception {
    final PvmActivity currentActivity = execution.getActivity();
    final EscalationEventDefinitionFinder escalationEventDefinitionFinder = new EscalationEventDefinitionFinder(escalation.getEscalationCode(), currentActivity);
    ActivityExecutionMappingCollector activityExecutionMappingCollector = new ActivityExecutionMappingCollector(execution);
    ActivityExecutionHierarchyWalker walker = new ActivityExecutionHierarchyWalker(execution);
    walker.addScopePreVisitor(escalationEventDefinitionFinder);
    walker.addExecutionPreVisitor(activityExecutionMappingCollector);
    walker.addExecutionPreVisitor(new OutputVariablesPropagator());
    walker.walkUntil(new ReferenceWalker.WalkCondition<ActivityExecutionTuple>() {

        @Override
        public boolean isFulfilled(ActivityExecutionTuple element) {
            return escalationEventDefinitionFinder.getEscalationEventDefinition() != null || element == null;
        }
    });
    EscalationEventDefinition escalationEventDefinition = escalationEventDefinitionFinder.getEscalationEventDefinition();
    if (escalationEventDefinition != null) {
        executeEscalationHandler(escalationEventDefinition, activityExecutionMappingCollector);
    }
    if (escalationEventDefinition == null || !escalationEventDefinition.isCancelActivity()) {
        leaveExecution(execution, currentActivity, escalationEventDefinition);
    }
}
Also used : ActivityExecutionMappingCollector(org.camunda.bpm.engine.impl.tree.ActivityExecutionMappingCollector) ActivityExecutionHierarchyWalker(org.camunda.bpm.engine.impl.tree.ActivityExecutionHierarchyWalker) EscalationEventDefinition(org.camunda.bpm.engine.impl.bpmn.parser.EscalationEventDefinition) ReferenceWalker(org.camunda.bpm.engine.impl.tree.ReferenceWalker) OutputVariablesPropagator(org.camunda.bpm.engine.impl.tree.OutputVariablesPropagator) PvmActivity(org.camunda.bpm.engine.impl.pvm.PvmActivity) ActivityExecutionTuple(org.camunda.bpm.engine.impl.tree.ActivityExecutionTuple)

Example 24 with PvmActivity

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

the class SequentialMultiInstanceActivityBehavior method complete.

public void complete(ActivityExecution scopeExecution) {
    int loopCounter = getLoopVariable(scopeExecution, LOOP_COUNTER) + 1;
    int nrOfInstances = getLoopVariable(scopeExecution, NUMBER_OF_INSTANCES);
    int nrOfCompletedInstances = getLoopVariable(scopeExecution, NUMBER_OF_COMPLETED_INSTANCES) + 1;
    setLoopVariable(scopeExecution, NUMBER_OF_COMPLETED_INSTANCES, nrOfCompletedInstances);
    if (loopCounter == nrOfInstances || completionConditionSatisfied(scopeExecution)) {
        leave(scopeExecution);
    } else {
        PvmActivity innerActivity = getInnerActivity(scopeExecution.getActivity());
        performInstance(scopeExecution, innerActivity, loopCounter);
    }
}
Also used : PvmActivity(org.camunda.bpm.engine.impl.pvm.PvmActivity)

Example 25 with PvmActivity

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

the class BpmnParseTest method testParseNamespaceInConditionExpressionType.

@Deployment
public void testParseNamespaceInConditionExpressionType() {
    CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
    ProcessDefinitionEntity processDefinitionEntity = commandExecutor.execute(new Command<ProcessDefinitionEntity>() {

        @Override
        public ProcessDefinitionEntity execute(CommandContext commandContext) {
            return Context.getProcessEngineConfiguration().getDeploymentCache().findDeployedLatestProcessDefinitionByKey("resolvableNamespacesProcess");
        }
    });
    // Test that the process definition has been deployed
    assertNotNull(processDefinitionEntity);
    PvmActivity activity = processDefinitionEntity.findActivity("ExclusiveGateway_1");
    assertNotNull(activity);
    // Test that the conditions has been resolved
    for (PvmTransition transition : activity.getOutgoingTransitions()) {
        if (transition.getDestination().getId().equals("Task_2")) {
            assertTrue(transition.getProperty("conditionText").equals("#{approved}"));
        } else if (transition.getDestination().getId().equals("Task_3")) {
            assertTrue(transition.getProperty("conditionText").equals("#{!approved}"));
        } else {
            fail("Something went wrong");
        }
    }
}
Also used : CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) CommandExecutor(org.camunda.bpm.engine.impl.interceptor.CommandExecutor) ProcessDefinitionEntity(org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity) PvmActivity(org.camunda.bpm.engine.impl.pvm.PvmActivity) PvmTransition(org.camunda.bpm.engine.impl.pvm.PvmTransition) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

PvmActivity (org.camunda.bpm.engine.impl.pvm.PvmActivity)39 PvmExecutionImpl (org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl)13 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)9 PvmTransition (org.camunda.bpm.engine.impl.pvm.PvmTransition)7 ActivityExecution (org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution)6 ScopeImpl (org.camunda.bpm.engine.impl.pvm.process.ScopeImpl)6 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)4 TransitionImpl (org.camunda.bpm.engine.impl.pvm.process.TransitionImpl)4 ReferenceWalker (org.camunda.bpm.engine.impl.tree.ReferenceWalker)4 ArrayList (java.util.ArrayList)3 PvmScope (org.camunda.bpm.engine.impl.pvm.PvmScope)3 ActivityBehavior (org.camunda.bpm.engine.impl.pvm.delegate.ActivityBehavior)3 CompositeActivityBehavior (org.camunda.bpm.engine.impl.pvm.delegate.CompositeActivityBehavior)3 List (java.util.List)2 ActivityImpl (org.camunda.bpm.engine.impl.pvm.process.ActivityImpl)2 ProcessDefinitionImpl (org.camunda.bpm.engine.impl.pvm.process.ProcessDefinitionImpl)2 ExecutionStartContext (org.camunda.bpm.engine.impl.pvm.runtime.ExecutionStartContext)2 ActivityExecutionHierarchyWalker (org.camunda.bpm.engine.impl.tree.ActivityExecutionHierarchyWalker)2 ActivityExecutionMappingCollector (org.camunda.bpm.engine.impl.tree.ActivityExecutionMappingCollector)2 ActivityExecutionTuple (org.camunda.bpm.engine.impl.tree.ActivityExecutionTuple)2