Search in sources :

Example 6 with ProcessDefinitionImpl

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

the class ProcessTaskActivityBehavior method triggerCallableElement.

protected void triggerCallableElement(CmmnActivityExecution execution, Map<String, Object> variables, String businessKey) {
    ProcessDefinitionImpl definition = getProcessDefinitionToCall(execution, getCallableElement());
    PvmProcessInstance processInstance = execution.createSubProcessInstance(definition, businessKey);
    processInstance.start(variables);
}
Also used : PvmProcessInstance(org.camunda.bpm.engine.impl.pvm.PvmProcessInstance) ProcessDefinitionImpl(org.camunda.bpm.engine.impl.pvm.process.ProcessDefinitionImpl)

Example 7 with ProcessDefinitionImpl

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

the class CallableElementUtil method getProcessDefinitionToCall.

public static ProcessDefinitionImpl getProcessDefinitionToCall(VariableScope execution, BaseCallableElement callableElement) {
    String processDefinitionKey = callableElement.getDefinitionKey(execution);
    String tenantId = callableElement.getDefinitionTenantId(execution);
    DeploymentCache deploymentCache = getDeploymentCache();
    ProcessDefinitionImpl processDefinition = null;
    if (callableElement.isLatestBinding()) {
        processDefinition = deploymentCache.findDeployedLatestProcessDefinitionByKeyAndTenantId(processDefinitionKey, tenantId);
    } else if (callableElement.isDeploymentBinding()) {
        String deploymentId = callableElement.getDeploymentId();
        processDefinition = deploymentCache.findDeployedProcessDefinitionByDeploymentAndKey(deploymentId, processDefinitionKey);
    } else if (callableElement.isVersionBinding()) {
        Integer version = callableElement.getVersion(execution);
        processDefinition = deploymentCache.findDeployedProcessDefinitionByKeyVersionAndTenantId(processDefinitionKey, version, tenantId);
    }
    return processDefinition;
}
Also used : ProcessDefinitionImpl(org.camunda.bpm.engine.impl.pvm.process.ProcessDefinitionImpl) DeploymentCache(org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache)

Example 8 with ProcessDefinitionImpl

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

the class PvmActivityInstanceTest method testStartInSubProcess.

public void testStartInSubProcess() {
    ActivityInstanceVerification verifier = new ActivityInstanceVerification();
    PvmProcessDefinition processDefinition = new ProcessDefinitionBuilder().createActivity("start").initial().behavior(new Automatic()).executionListener(ExecutionListener.EVENTNAME_START, verifier).executionListener(ExecutionListener.EVENTNAME_END, verifier).transition("embeddedsubprocess").endActivity().createActivity("embeddedsubprocess").scope().behavior(new EmbeddedSubProcess()).executionListener(ExecutionListener.EVENTNAME_START, verifier).executionListener(ExecutionListener.EVENTNAME_END, verifier).createActivity("startInside").behavior(new Automatic()).executionListener(ExecutionListener.EVENTNAME_START, verifier).executionListener(ExecutionListener.EVENTNAME_END, verifier).transition("endInside").endActivity().createActivity("endInside").behavior(new End()).executionListener(ExecutionListener.EVENTNAME_START, verifier).executionListener(ExecutionListener.EVENTNAME_END, verifier).endActivity().transition("end").endActivity().executionListener(ExecutionListener.EVENTNAME_START, verifier).executionListener(ExecutionListener.EVENTNAME_END, verifier).createActivity("end").behavior(new End()).executionListener(ExecutionListener.EVENTNAME_START, verifier).executionListener(ExecutionListener.EVENTNAME_END, verifier).endActivity().buildProcessDefinition();
    PvmProcessInstance processInstance = ((ProcessDefinitionImpl) processDefinition).createProcessInstanceForInitial((ActivityImpl) processDefinition.findActivity("endInside"));
    processInstance.start();
    assertTrue(processInstance.isEnded());
    verifier.assertStartInstanceCount(0, "start");
    verifier.assertStartInstanceCount(1, "embeddedsubprocess");
    verifier.assertProcessInstanceParent("embeddedsubprocess", processInstance);
    verifier.assertStartInstanceCount(0, "startInside");
    verifier.assertIsCompletingActivityInstance("endInside", 1);
    verifier.assertStartInstanceCount(1, "end");
}
Also used : EmbeddedSubProcess(org.camunda.bpm.engine.test.standalone.pvm.activities.EmbeddedSubProcess) PvmProcessInstance(org.camunda.bpm.engine.impl.pvm.PvmProcessInstance) ProcessDefinitionImpl(org.camunda.bpm.engine.impl.pvm.process.ProcessDefinitionImpl) PvmProcessDefinition(org.camunda.bpm.engine.impl.pvm.PvmProcessDefinition) End(org.camunda.bpm.engine.test.standalone.pvm.activities.End) ProcessDefinitionBuilder(org.camunda.bpm.engine.impl.pvm.ProcessDefinitionBuilder) Automatic(org.camunda.bpm.engine.test.standalone.pvm.activities.Automatic)

Example 9 with ProcessDefinitionImpl

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

the class PvmEmbeddedSubProcessTest method testStartInScope.

/**
 *           +------------------------------+
 *           | embedded subprocess          |
 * +-----+   |  +-----------+   +---------+ |   +---+
 * |start|-->|  |startInside|-->|endInside| |-->|end|
 * +-----+   |  +-----------+   +---------+ |   +---+
 *           +------------------------------+
 */
public void testStartInScope() {
    PvmProcessDefinition processDefinition = new ProcessDefinitionBuilder().createActivity("start").initial().behavior(new Automatic()).transition("embeddedsubprocess").endActivity().createActivity("embeddedsubprocess").scope().behavior(new EmbeddedSubProcess()).createActivity("startInside").behavior(new Automatic()).transition("endInside").endActivity().createActivity("endInside").behavior(new End()).endActivity().transition("end").endActivity().createActivity("end").behavior(new WaitState()).endActivity().buildProcessDefinition();
    PvmProcessInstance processInstance = ((ProcessDefinitionImpl) processDefinition).createProcessInstanceForInitial((ActivityImpl) processDefinition.findActivity("startInside"));
    processInstance.start();
    List<String> expectedActiveActivityIds = new ArrayList<String>();
    expectedActiveActivityIds.add("end");
    assertEquals(expectedActiveActivityIds, processInstance.findActiveActivityIds());
}
Also used : EmbeddedSubProcess(org.camunda.bpm.engine.test.standalone.pvm.activities.EmbeddedSubProcess) WaitState(org.camunda.bpm.engine.test.standalone.pvm.activities.WaitState) PvmProcessInstance(org.camunda.bpm.engine.impl.pvm.PvmProcessInstance) ProcessDefinitionImpl(org.camunda.bpm.engine.impl.pvm.process.ProcessDefinitionImpl) ArrayList(java.util.ArrayList) PvmProcessDefinition(org.camunda.bpm.engine.impl.pvm.PvmProcessDefinition) End(org.camunda.bpm.engine.test.standalone.pvm.activities.End) ProcessDefinitionBuilder(org.camunda.bpm.engine.impl.pvm.ProcessDefinitionBuilder) Automatic(org.camunda.bpm.engine.test.standalone.pvm.activities.Automatic)

Example 10 with ProcessDefinitionImpl

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

the class ActivityBeforeInstantiationCmd method execute.

@Override
public Void execute(CommandContext commandContext) {
    ExecutionEntity processInstance = commandContext.getExecutionManager().findExecutionById(processInstanceId);
    ProcessDefinitionImpl processDefinition = processInstance.getProcessDefinition();
    PvmActivity activity = processDefinition.findActivity(activityId);
    // forbid instantiation of compensation boundary events
    if (activity != null && "compensationBoundaryCatch".equals(activity.getProperty("type"))) {
        throw new ProcessEngineException("Cannot start before activity " + activityId + "; activity " + "is a compensation boundary event.");
    }
    return super.execute(commandContext);
}
Also used : ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) ProcessDefinitionImpl(org.camunda.bpm.engine.impl.pvm.process.ProcessDefinitionImpl) PvmActivity(org.camunda.bpm.engine.impl.pvm.PvmActivity) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Aggregations

ProcessDefinitionImpl (org.camunda.bpm.engine.impl.pvm.process.ProcessDefinitionImpl)13 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)6 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)4 PvmProcessInstance (org.camunda.bpm.engine.impl.pvm.PvmProcessInstance)4 ArrayList (java.util.ArrayList)2 DeploymentCache (org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache)2 ProcessDefinitionBuilder (org.camunda.bpm.engine.impl.pvm.ProcessDefinitionBuilder)2 PvmActivity (org.camunda.bpm.engine.impl.pvm.PvmActivity)2 PvmProcessDefinition (org.camunda.bpm.engine.impl.pvm.PvmProcessDefinition)2 ActivityImpl (org.camunda.bpm.engine.impl.pvm.process.ActivityImpl)2 ScopeImpl (org.camunda.bpm.engine.impl.pvm.process.ScopeImpl)2 TransitionImpl (org.camunda.bpm.engine.impl.pvm.process.TransitionImpl)2 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)2 Automatic (org.camunda.bpm.engine.test.standalone.pvm.activities.Automatic)2 EmbeddedSubProcess (org.camunda.bpm.engine.test.standalone.pvm.activities.EmbeddedSubProcess)2 End (org.camunda.bpm.engine.test.standalone.pvm.activities.End)2 HashSet (java.util.HashSet)1 NotValidException (org.camunda.bpm.engine.exception.NotValidException)1 ActivityExecutionTreeMapping (org.camunda.bpm.engine.impl.ActivityExecutionTreeMapping)1 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)1