Java Code Examples for org.activiti.engine.delegate.DelegateExecution#getId()

The following examples show how to use org.activiti.engine.delegate.DelegateExecution#getId() . 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
protected void planTransactionDependentExecutionListener(ListenerFactory listenerFactory, DelegateExecution execution, TransactionDependentExecutionListener executionListener, ActivitiListener activitiListener) {
  Map<String, Object> executionVariablesToUse = execution.getVariables();
  CustomPropertiesResolver customPropertiesResolver = createCustomPropertiesResolver(activitiListener);
  Map<String, Object> customPropertiesMapToUse = invokeCustomPropertiesResolver(execution, customPropertiesResolver);

  TransactionDependentExecutionListenerExecutionScope scope = new TransactionDependentExecutionListenerExecutionScope(
      execution.getProcessInstanceId(), execution.getId(), execution.getCurrentFlowElement(), executionVariablesToUse, customPropertiesMapToUse);
  
  addTransactionListener(activitiListener, new ExecuteExecutionListenerTransactionListener(executionListener, scope));
}
 
Example 2
protected void planTransactionDependentTaskListener(DelegateExecution execution, TransactionDependentTaskListener taskListener, ActivitiListener activitiListener) {
  Map<String, Object> executionVariablesToUse = execution.getVariables();
  CustomPropertiesResolver customPropertiesResolver = createCustomPropertiesResolver(activitiListener);
  Map<String, Object> customPropertiesMapToUse = invokeCustomPropertiesResolver(execution, customPropertiesResolver);
  
  TransactionDependentTaskListenerExecutionScope scope = new TransactionDependentTaskListenerExecutionScope(
      execution.getProcessInstanceId(), execution.getId(), (Task) execution.getCurrentFlowElement(), executionVariablesToUse, customPropertiesMapToUse);
  addTransactionListener(activitiListener, new ExecuteTaskListenerTransactionListener(taskListener, scope));
}
 
Example 3
Source Project: activiti6-boot2   File: TestService.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void execute(DelegateExecution execution) {
  TestService.processDefinitionId = execution.getProcessDefinitionId();
  TestService.processInstanceId = execution.getProcessInstanceId();
  TestService.executionId = execution.getId();
  TestService.businessKey = execution.getProcessInstanceBusinessKey();

  throw new RuntimeException("test");

}
 
Example 4
Source Project: activiti6-boot2   File: TestService.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void execute(DelegateExecution execution) {
	TestService.processDefinitionId = execution.getProcessDefinitionId();
	TestService.processInstanceId =  execution.getProcessInstanceId();
	TestService.executionId = execution.getId();
	TestService.businessKey = execution.getProcessInstanceBusinessKey();
	
	throw new RuntimeException("test");
}
 
Example 5
Source Project: oneops   File: CMSClient.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Sets the dpmt process id.
 *
 * @param exec the exec
 * @param dpmt the dpmt
 */
public void setDpmtProcessId(DelegateExecution exec, CmsDeployment dpmt) {

    String processId = exec.getProcessInstanceId();
    String execId = exec.getId();
    // lets create strip down dpmt to update just a processId and updatedBy
    updateDeploymentAndNotify(dpmt, processId + "!" + execId, "Activiti");
}
 
Example 6
Source Project: herd   File: ExecuteJdbc.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Executes the task synchronously. overrideActivitiId is provided to customize the name of the variable to set during the execution of the task. This is
 * important when the task is running asynchronously because execution.getCurrentActivitiId() will report the ID the task that the workflow is currently in,
 * and not the ID of the task that was originally executed.
 *
 * @param execution The execution.
 * @param overrideActivitiId Optionally overrides the task id which to use to generate variable names.
 * @param jdbcExecutionRequest The request.
 *
 * @throws Exception When any exception occurs during the execution of the task.
 */
private void executeSync(DelegateExecution execution, String overrideActivitiId, JdbcExecutionRequest jdbcExecutionRequest) throws Exception
{
    String executionId = execution.getId();
    String activitiId = execution.getCurrentActivityId();
    if (overrideActivitiId != null)
    {
        activitiId = overrideActivitiId;
    }

    // Execute the request. May throw exception here in case of validation or system errors.
    // Thrown exceptions should be caught by parent implementation.
    JdbcExecutionResponse jdbcExecutionResponse = jdbcService.executeJdbc(jdbcExecutionRequest);

    // Set the response
    setJsonResponseAsWorkflowVariable(jdbcExecutionResponse, executionId, activitiId);

    /*
     * Special handling of error condition.
     * Any one of the requested SQL statements could've failed without throwing an exception.
     * If any of the statements are in ERROR, throw an exception.
     * This ensures that the workflow response variable is still available to the users.
     */
    for (JdbcStatement jdbcStatement : jdbcExecutionResponse.getStatements())
    {
        if (JdbcStatementStatus.ERROR.equals(jdbcStatement.getStatus()))
        {
            throw new IllegalArgumentException("There are failed executions. See JSON response for details.");
        }
    }
}
 
Example 7
@Override
public void execute(DelegateExecution execution) {
  ExecutionEntity executionEntity = (ExecutionEntity) execution;
  BoundaryEvent boundaryEvent = (BoundaryEvent) execution.getCurrentFlowElement();
  
  Process process = ProcessDefinitionUtil.getProcess(execution.getProcessDefinitionId());
  if (process == null) {
    throw new ActivitiException("Process model (id = " + execution.getId() + ") could not be found");
  }
  
  Activity compensationActivity = null;
  List<Association> associations = process.findAssociationsWithSourceRefRecursive(boundaryEvent.getId());
  for (Association association : associations) {
    FlowElement targetElement = process.getFlowElement(association.getTargetRef(), true);
    if (targetElement instanceof Activity) {
      Activity activity = (Activity) targetElement;
      if (activity.isForCompensation()) {
        compensationActivity = activity;
        break;
      }
    }
  }
  
  if (compensationActivity == null) {
    throw new ActivitiException("Compensation activity could not be found (or it is missing 'isForCompensation=\"true\"'");
  }
  
  // find SubProcess or Process instance execution
  ExecutionEntity scopeExecution = null;
  ExecutionEntity parentExecution = executionEntity.getParent();
  while (scopeExecution == null && parentExecution != null) {
    if (parentExecution.getCurrentFlowElement() instanceof SubProcess) {
      scopeExecution = parentExecution;
      
    } else if (parentExecution.isProcessInstanceType()) {
      scopeExecution = parentExecution;
    } else {
      parentExecution = parentExecution.getParent();
    }
  }
  
  if (scopeExecution == null) {
    throw new ActivitiException("Could not find a scope execution for compensation boundary event " + boundaryEvent.getId());
  }
  
  Context.getCommandContext().getEventSubscriptionEntityManager().insertCompensationEvent(
      scopeExecution, compensationActivity.getId());
}
 
Example 8
protected BusinessProcessEvent createEvent(DelegateExecution execution) {
  ProcessDefinition processDefinition = ProcessDefinitionUtil.getProcessDefinition(execution.getProcessDefinitionId());
  Date now = Context.getProcessEngineConfiguration().getClock().getCurrentTime();
  return new CdiBusinessProcessEvent(activityId, transitionName, processDefinition, execution, type, execution.getProcessInstanceId(), execution.getId(), now);
}
 
Example 9
Source Project: oneops   File: InductorPublisher.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * Publish message.
 *
 * @param exec         the exec
 * @param waitTaskName the wait task name
 * @param woType       the wo type
 * @throws JMSException the jMS exception
 */
public void publishMessage(DelegateExecution exec, String waitTaskName, String woType) throws JMSException {
    String processId = exec.getProcessInstanceId();
    String execId = exec.getId();

    CmsWorkOrderSimpleBase wo = (CmsWorkOrderSimpleBase) exec.getVariable("wo");
    publishMessage(processId, execId, wo, waitTaskName, woType);
}