Java Code Examples for org.activiti.engine.impl.persistence.entity.ExecutionEntity#start()
The following examples show how to use
org.activiti.engine.impl.persistence.entity.ExecutionEntity#start() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TimerStartEventJobHandler.java From flowable-engine with Apache License 2.0 | 7 votes |
protected void startProcessInstanceWithInitialActivity(Job job, String configuration, DeploymentManager deploymentManager, CommandContext commandContext) { ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) deploymentManager.findDeployedProcessDefinitionById(job.getProcessDefinitionId()); String activityId = getActivityIdFromConfiguration(configuration); ActivityImpl startActivity = processDefinition.findActivity(activityId); if (!deploymentManager.isProcessDefinitionSuspended(processDefinition.getId())) { dispatchTimerFiredEvent(job, commandContext); ExecutionEntity processInstance = processDefinition.createProcessInstance(null, startActivity); processInstance.start(); } else { LOGGER.debug("Ignoring timer of suspended process definition {}", processDefinition.getId()); } }
Example 2
Source File: SubmitStartFormCmd.java From flowable-engine with Apache License 2.0 | 6 votes |
@Override protected ProcessInstance execute(CommandContext commandContext, ProcessDefinition processDefinition) { ProcessDefinitionEntity processDefinitionEntity = (ProcessDefinitionEntity) processDefinition; ExecutionEntity processInstance = null; if (businessKey != null) { processInstance = processDefinitionEntity.createProcessInstance(businessKey); } else { processInstance = processDefinitionEntity.createProcessInstance(); } commandContext.getHistoryManager() .reportFormPropertiesSubmitted(processInstance, properties, null); StartFormHandler startFormHandler = processDefinitionEntity.getStartFormHandler(); startFormHandler.submitFormProperties(properties, processInstance); processInstance.start(); return processInstance; }
Example 3
Source File: SignalEventHandler.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override public void handleEvent(EventSubscriptionEntity eventSubscription, Object payload, CommandContext commandContext) { if (eventSubscription.getExecutionId() != null) { super.handleEvent(eventSubscription, payload, commandContext); } else if (eventSubscription.getProcessDefinitionId() != null) { // Start event String processDefinitionId = eventSubscription.getProcessDefinitionId(); DeploymentManager deploymentCache = Context .getProcessEngineConfiguration() .getDeploymentManager(); ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) deploymentCache.findDeployedProcessDefinitionById(processDefinitionId); if (processDefinition == null) { throw new ActivitiObjectNotFoundException("No process definition found for id '" + processDefinitionId + "'", ProcessDefinition.class); } ActivityImpl startActivity = processDefinition.findActivity(eventSubscription.getActivityId()); if (startActivity == null) { throw new ActivitiException("Could no handle signal: no start activity found with id " + eventSubscription.getActivityId()); } ExecutionEntity processInstance = processDefinition.createProcessInstance(null, startActivity); if (processInstance == null) { throw new ActivitiException("Could not handle signal: no process instance started"); } if (payload != null) { if (payload instanceof Map) { Map<String, Object> variables = (Map<String, Object>) payload; processInstance.setVariables(variables); } } processInstance.start(); } else { throw new ActivitiException("Invalid signal handling: no execution nor process definition set"); } }
Example 4
Source File: ReOpenProcessCmd.java From lemon with Apache License 2.0 | 5 votes |
public Void execute(CommandContext commandContext) { HistoricProcessInstanceEntity historicProcessInstanceEntity = commandContext .getHistoricProcessInstanceEntityManager() .findHistoricProcessInstance(historicProcessInstanceId); if (historicProcessInstanceEntity.getEndTime() == null) { logger.info("historicProcessInstanceId is running"); return null; } historicProcessInstanceEntity.setEndActivityId(null); historicProcessInstanceEntity.setEndTime(null); String processDefinitionId = historicProcessInstanceEntity .getProcessDefinitionId(); String initiator = historicProcessInstanceEntity.getStartUserId(); String businessKey = historicProcessInstanceEntity.getBusinessKey(); ProcessDefinitionEntity processDefinition = new GetDeploymentProcessDefinitionCmd( processDefinitionId).execute(commandContext); // ExecutionEntity processInstance = processDefinition // .createProcessInstance(businessKey); ExecutionEntity processInstance = this.createProcessInstance( historicProcessInstanceEntity.getId(), businessKey, initiator, processDefinition); try { Authentication.setAuthenticatedUserId(initiator); // start processInstance.start(); } finally { Authentication.setAuthenticatedUserId(null); } return null; }
Example 5
Source File: StartProcessInstanceCmd.java From flowable-engine with Apache License 2.0 | 4 votes |
@Override public ProcessInstance execute(CommandContext commandContext) { DeploymentManager deploymentManager = commandContext .getProcessEngineConfiguration() .getDeploymentManager(); // Find the process definition ProcessDefinition processDefinition = null; if (processDefinitionId != null) { processDefinition = deploymentManager.findDeployedProcessDefinitionById(processDefinitionId); if (processDefinition == null) { throw new ActivitiObjectNotFoundException("No process definition found for id = '" + processDefinitionId + "'", ProcessDefinition.class); } } else if (processDefinitionKey != null && (tenantId == null || ProcessEngineConfiguration.NO_TENANT_ID.equals(tenantId))) { processDefinition = deploymentManager.findDeployedLatestProcessDefinitionByKey(processDefinitionKey); if (processDefinition == null) { throw new ActivitiObjectNotFoundException("No process definition found for key '" + processDefinitionKey + "'", ProcessDefinition.class); } } else if (processDefinitionKey != null && tenantId != null && !ProcessEngineConfiguration.NO_TENANT_ID.equals(tenantId)) { processDefinition = deploymentManager.findDeployedLatestProcessDefinitionByKeyAndTenantId(processDefinitionKey, tenantId); if (processDefinition == null) { throw new ActivitiObjectNotFoundException("No process definition found for key '" + processDefinitionKey + "' for tenant identifier " + tenantId, ProcessDefinition.class); } } else { throw new ActivitiIllegalArgumentException("processDefinitionKey and processDefinitionId are null"); } // 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"); } // Start the process instance ExecutionEntity processInstance = ((ProcessDefinitionEntity) processDefinition).createProcessInstance(businessKey); // now set the variables passed into the start command initializeVariables(processInstance); // now set processInstance name if (processInstanceName != null) { processInstance.setName(processInstanceName); commandContext.getHistoryManager().recordProcessInstanceNameChange(processInstance.getId(), processInstanceName); } processInstance.start(); return processInstance; }
Example 6
Source File: StartProcessInstanceByMessageCmd.java From flowable-engine with Apache License 2.0 | 4 votes |
@Override 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 = (ProcessDefinitionEntity) 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); } if (transientVariables != null) { processInstance.setTransientVariables(transientVariables); } processInstance.start(); return processInstance; }