Java Code Examples for org.flowable.engine.delegate.DelegateExecution#getProcessInstanceId()

The following examples show how to use org.flowable.engine.delegate.DelegateExecution#getProcessInstanceId() . 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: AbstractProcessExecutionListener.java    From multiapps-controller with Apache License 2.0 6 votes vote down vote up
@Override
public void notify(DelegateExecution execution) {
    try {
        String correlationId = VariableHandling.get(execution, Variables.CORRELATION_ID);
        if (correlationId == null) {
            correlationId = execution.getProcessInstanceId();
            VariableHandling.set(execution, Variables.CORRELATION_ID, correlationId);
        }
        this.stepLogger = createStepLogger(execution);
        notifyInternal(execution);
    } catch (Exception e) {
        logException(e, Messages.EXECUTION_OF_PROCESS_LISTENER_HAS_FAILED);
        throw new SLException(e, Messages.EXECUTION_OF_PROCESS_LISTENER_HAS_FAILED);
    } finally {
        finalizeLogs(execution);
    }
}
 
Example 2
Source File: ProcessStepHelper.java    From multiapps-controller with Apache License 2.0 5 votes vote down vote up
private String getCurrentActivityId(DelegateExecution execution) {
    List<Execution> processExecutions = processEngineConfiguration.getRuntimeService()
                                                                  .createExecutionQuery()
                                                                  .processInstanceId(execution.getProcessInstanceId())
                                                                  .list();
    List<Execution> processExecutionsWithActivityIds = processExecutions.stream()
                                                                        .filter(e -> e.getActivityId() != null)
                                                                        .collect(Collectors.toList());
    if (processExecutionsWithActivityIds.isEmpty()) {
        // if this happen then there is a really big problem with Flowable :)
        throw new SLException("There are no executions for process with id: " + execution.getProcessInstanceId());
    }
    return processExecutionsWithActivityIds.get(0)
                                           .getActivityId();
}
 
Example 3
Source File: ProcessLoggerProvider.java    From multiapps-controller with Apache License 2.0 5 votes vote down vote up
public ProcessLogger getLogger(DelegateExecution execution, String logName, PatternLayout layout) {
    String name = getLoggerName(execution, logName);
    String correlationId = getCorrelationId(execution);
    String spaceId = getSpaceId(execution);
    String activityId = getTaskId(execution);
    String logNameWithExtension = logName + LOG_FILE_EXTENSION;
    if (correlationId == null || activityId == null) {
        return new NullProcessLogger(spaceId, execution.getProcessInstanceId(), activityId);
    }
    return loggersCache.computeIfAbsent(name, (String loggerName) -> createProcessLogger(spaceId, correlationId, activityId, loggerName,
                                                                                         logNameWithExtension, layout));
}
 
Example 4
Source File: TestService.java    From flowable-engine with 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 File: ListenerNotificationHelper.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
protected void planTransactionDependentExecutionListener(ListenerFactory listenerFactory, DelegateExecution execution, 
                TransactionDependentExecutionListener executionListener, FlowableListener listener) {
    
    Map<String, Object> executionVariablesToUse = execution.getVariables();
    CustomPropertiesResolver customPropertiesResolver = createCustomPropertiesResolver(listener);
    Map<String, Object> customPropertiesMapToUse = invokeCustomPropertiesResolver(execution, customPropertiesResolver);

    TransactionDependentExecutionListenerExecutionScope scope = new TransactionDependentExecutionListenerExecutionScope(
            execution.getProcessInstanceId(), execution.getId(), execution.getCurrentFlowElement(), executionVariablesToUse, customPropertiesMapToUse);

    addTransactionListener(listener, new ExecuteExecutionListenerTransactionListener(executionListener, scope, 
                    CommandContextUtil.getProcessEngineConfiguration().getCommandExecutor()));
}
 
Example 6
Source File: ListenerNotificationHelper.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
protected void planTransactionDependentTaskListener(DelegateExecution execution, TransactionDependentTaskListener taskListener, FlowableListener listener) {
    Map<String, Object> executionVariablesToUse = execution.getVariables();
    CustomPropertiesResolver customPropertiesResolver = createCustomPropertiesResolver(listener);
    Map<String, Object> customPropertiesMapToUse = invokeCustomPropertiesResolver(execution, customPropertiesResolver);

    TransactionDependentTaskListenerExecutionScope scope = new TransactionDependentTaskListenerExecutionScope(
            execution.getProcessInstanceId(), execution.getId(), (Task) execution.getCurrentFlowElement(), executionVariablesToUse, customPropertiesMapToUse);
    addTransactionListener(listener, new ExecuteTaskListenerTransactionListener(taskListener, scope,
                    CommandContextUtil.getProcessEngineConfiguration().getCommandExecutor()));
}
 
Example 7
Source File: TestService.java    From flowable-engine with 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 8
Source File: AbstractProcessExecutionListener.java    From multiapps-controller with Apache License 2.0 4 votes vote down vote up
protected boolean isRootProcess(DelegateExecution execution) {
    String correlationId = VariableHandling.get(execution, Variables.CORRELATION_ID);
    String processInstanceId = execution.getProcessInstanceId();
    return processInstanceId.equals(correlationId);
}
 
Example 9
Source File: CdiExecutionListener.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
protected BusinessProcessEvent createEvent(DelegateExecution execution) {
    ProcessDefinition processDefinition = ProcessDefinitionUtil.getProcessDefinition(execution.getProcessDefinitionId());
    ProcessEngineConfiguration engineConfiguration = org.flowable.engine.impl.context.Context.getProcessEngineConfiguration(); 
    Date now = engineConfiguration.getClock().getCurrentTime();
    return new CdiBusinessProcessEvent(activityId, transitionName, processDefinition, execution, type, execution.getProcessInstanceId(), execution.getId(), now);
}