use of org.activiti.engine.impl.pvm.process.ActivityImpl in project Activiti by Activiti.
the class StartProcessInstanceByMessageCmd method execute.
public ProcessInstance execute(CommandContext commandContext) {
if (messageName == null) {
throw new ActivitiIllegalArgumentException("Cannot start process instance by message: message name is null");
}
MessageEventSubscriptionEntity messageEventSubscription = commandContext.getEventSubscriptionEntityManager().findMessageStartEventSubscriptionByName(messageName, tenantId);
if (messageEventSubscription == null) {
throw new ActivitiObjectNotFoundException("Cannot start process instance by message: no subscription to message with name '" + messageName + "' found.", MessageEventSubscriptionEntity.class);
}
String processDefinitionId = messageEventSubscription.getConfiguration();
if (processDefinitionId == null) {
throw new ActivitiException("Cannot start process instance by message: subscription to message with name '" + messageName + "' is not a message start event.");
}
DeploymentManager deploymentManager = commandContext.getProcessEngineConfiguration().getDeploymentManager();
ProcessDefinitionEntity processDefinition = deploymentManager.findDeployedProcessDefinitionById(processDefinitionId);
if (processDefinition == null) {
throw new ActivitiObjectNotFoundException("No process definition found for id '" + processDefinitionId + "'", ProcessDefinition.class);
}
// Do not start process a process instance if the process definition is suspended
if (deploymentManager.isProcessDefinitionSuspended(processDefinition.getId())) {
throw new ActivitiException("Cannot start process instance. Process definition " + processDefinition.getName() + " (id = " + processDefinition.getId() + ") is suspended");
}
ActivityImpl startActivity = processDefinition.findActivity(messageEventSubscription.getActivityId());
ExecutionEntity processInstance = processDefinition.createProcessInstance(businessKey, startActivity);
if (processVariables != null) {
processInstance.setVariables(processVariables);
}
processInstance.start();
return processInstance;
}
use of org.activiti.engine.impl.pvm.process.ActivityImpl in project Activiti by Activiti.
the class AbstractEventHandler method dispatchExecutionCancelled.
protected void dispatchExecutionCancelled(EventSubscriptionEntity eventSubscription, ExecutionEntity execution, CommandContext commandContext) {
// subprocesses
for (ExecutionEntity subExecution : execution.getExecutions()) {
dispatchExecutionCancelled(eventSubscription, subExecution, commandContext);
}
// call activities
ExecutionEntity subProcessInstance = commandContext.getExecutionEntityManager().findSubProcessInstanceBySuperExecutionId(execution.getId());
if (subProcessInstance != null) {
dispatchExecutionCancelled(eventSubscription, subProcessInstance, commandContext);
}
// activity with message/signal boundary events
ActivityImpl activity = execution.getActivity();
if (activity != null && activity.getActivityBehavior() != null) {
dispatchActivityCancelled(eventSubscription, execution, activity, commandContext);
}
}
use of org.activiti.engine.impl.pvm.process.ActivityImpl in project Activiti by Activiti.
the class ProcessDefinitionBuilder method buildProcessDefinition.
public PvmProcessDefinition buildProcessDefinition() {
for (Object[] unresolvedTransition : unresolvedTransitions) {
TransitionImpl transition = (TransitionImpl) unresolvedTransition[0];
String destinationActivityName = (String) unresolvedTransition[1];
ActivityImpl destination = processDefinition.findActivity(destinationActivityName);
if (destination == null) {
throw new ActivitiException("destination '" + destinationActivityName + "' not found. (referenced from transition in '" + transition.getSource().getId() + "')");
}
transition.setDestination(destination);
}
return processDefinition;
}
use of org.activiti.engine.impl.pvm.process.ActivityImpl in project Activiti by Activiti.
the class ProcessDefinitionBuilder method startTransition.
public ProcessDefinitionBuilder startTransition(String destinationActivityId, String transitionId) {
if (destinationActivityId == null) {
throw new PvmException("destinationActivityId is null");
}
ActivityImpl activity = getActivity();
transition = activity.createOutgoingTransition(transitionId);
unresolvedTransitions.add(new Object[] { transition, destinationActivityId });
processElement = transition;
return this;
}
use of org.activiti.engine.impl.pvm.process.ActivityImpl in project Activiti by Activiti.
the class CustomUserTaskBpmnParseHandler method executeParse.
protected void executeParse(BpmnParse bpmnParse, UserTask userTask) {
// Do the regular stuff
super.executeParse(bpmnParse, userTask);
// Make user tasks always async
ActivityImpl activity = findActivity(bpmnParse, userTask.getId());
activity.setAsync(true);
}
Aggregations