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);
}
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;
}
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");
}
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());
}
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);
}
Aggregations