Search in sources :

Example 81 with ActivityImpl

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;
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) ExecutionEntity(org.activiti.engine.impl.persistence.entity.ExecutionEntity) DeploymentManager(org.activiti.engine.impl.persistence.deploy.DeploymentManager) ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException) MessageEventSubscriptionEntity(org.activiti.engine.impl.persistence.entity.MessageEventSubscriptionEntity)

Example 82 with ActivityImpl

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);
    }
}
Also used : ExecutionEntity(org.activiti.engine.impl.persistence.entity.ExecutionEntity) ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl)

Example 83 with ActivityImpl

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;
}
Also used : TransitionImpl(org.activiti.engine.impl.pvm.process.TransitionImpl) ActivitiException(org.activiti.engine.ActivitiException) ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl)

Example 84 with ActivityImpl

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;
}
Also used : ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl)

Example 85 with ActivityImpl

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);
}
Also used : ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl)

Aggregations

ActivityImpl (org.activiti.engine.impl.pvm.process.ActivityImpl)87 ExecutionEntity (org.activiti.engine.impl.persistence.entity.ExecutionEntity)15 ActivitiException (org.activiti.engine.ActivitiException)14 ProcessDefinitionEntity (org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)13 ScopeImpl (org.activiti.engine.impl.pvm.process.ScopeImpl)11 TransitionImpl (org.activiti.engine.impl.pvm.process.TransitionImpl)9 PvmTransition (org.activiti.engine.impl.pvm.PvmTransition)8 BoundaryEvent (org.activiti.bpmn.model.BoundaryEvent)7 ArrayList (java.util.ArrayList)6 ActivityExecution (org.activiti.engine.impl.pvm.delegate.ActivityExecution)6 ProcessDefinitionImpl (org.activiti.engine.impl.pvm.process.ProcessDefinitionImpl)6 List (java.util.List)5 EventDefinition (org.activiti.bpmn.model.EventDefinition)4 StartEvent (org.activiti.bpmn.model.StartEvent)4 IOSpecification (org.activiti.engine.impl.bpmn.data.IOSpecification)4 ActivityBehavior (org.activiti.engine.impl.pvm.delegate.ActivityBehavior)4 HashMap (java.util.HashMap)3 BpmnModel (org.activiti.bpmn.model.BpmnModel)3 IntermediateCatchEvent (org.activiti.bpmn.model.IntermediateCatchEvent)3 PvmProcessDefinition (org.activiti.engine.impl.pvm.PvmProcessDefinition)3