Java Code Examples for org.flowable.task.service.delegate.DelegateTask#setVariableLocal()

The following examples show how to use org.flowable.task.service.delegate.DelegateTask#setVariableLocal() . 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: SetRandomVariablesTaskListener.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void notify(DelegateTask delegateTask) {
    String varName;
    for (int i = 0; i < 5; i++) {
        varName = "variable-" + new Random().nextInt(10);
        delegateTask.setVariable(varName, getRandomValue());
    }

    for (int i = 0; i < 5; i++) {
        varName = "task-variable-" + new Random().nextInt(10);
        delegateTask.setVariableLocal(varName, getRandomValue());
    }
}
 
Example 2
Source File: TaskCompleteListener.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void notify(DelegateTask delegateTask) {
    ExecutionEntity execution = CommandContextUtil.getExecutionEntityManager().findById(delegateTask.getExecutionId());
    execution.setVariable("greeting", "Hello from " + greeter.getValue(execution));
    execution.setVariable("shortName", shortName.getValue(execution));

    delegateTask.setVariableLocal("myTaskVariable", "test");
}
 
Example 3
Source File: SetRandomVariablesTaskListener.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void notify(DelegateTask delegateTask) {
    String varName;
    for (int i = 0; i < 5; i++) {
        varName = "variable-" + new Random().nextInt(10);
        ExecutionEntity execution = CommandContextUtil.getExecutionEntityManager().findById(delegateTask.getExecutionId());
        execution.setVariable(varName, getRandomValue());
    }

    for (int i = 0; i < 5; i++) {
        varName = "task-variable-" + new Random().nextInt(10);
        delegateTask.setVariableLocal(varName, getRandomValue());
    }
}
 
Example 4
Source File: TaskCompleteListener.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public void notify(DelegateTask delegateTask) {
    delegateTask.setVariable("greeting", "Hello from " + greeter.getValue(delegateTask));
    delegateTask.setVariable("shortName", shortName.getValue(delegateTask));

    delegateTask.setVariableLocal("myTaskVariable", "test");
}
 
Example 5
Source File: VariableEventsTaskListener.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
public void notify(DelegateTask delegateTask) {
    delegateTask.setVariableLocal("variable", 123);
    delegateTask.setVariableLocal("variable", 456);
    delegateTask.removeVariableLocal("variable");
}
 
Example 6
Source File: VariableEventsTaskListener.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
public void notify(DelegateTask delegateTask) {
    delegateTask.setVariableLocal("variable", 123);
    delegateTask.setVariableLocal("variable", 456);
    delegateTask.removeVariableLocal("variable");
}
 
Example 7
Source File: TestCacheTaskListener.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
public void notify(DelegateTask delegateTask) {
    ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration();
    TaskService taskService = processEngineConfiguration.getTaskService();
    Task task = taskService.createTaskQuery().taskId(delegateTask.getId()).singleResult();
    if (task != null && task.getId().equals(delegateTask.getId())) {
        TASK_ID = task.getId();
    }
    
    HistoryService historyService = processEngineConfiguration.getHistoryService();
    HistoricTaskInstance historicTask = historyService.createHistoricTaskInstanceQuery().taskId(delegateTask.getId()).singleResult();
    if (historicTask != null && historicTask.getId().equals(delegateTask.getId())) {
        HISTORIC_TASK_ID = historicTask.getId();
    }

    delegateTask.setVariable("varFromTheListener", "valueFromTheListener");
    delegateTask.setVariableLocal("localVar", "localValue");

    // Used in CacheTaskTest#testTaskQueryWithIncludeVariables
    ProcessInstance processInstance = processEngineConfiguration.getRuntimeService().createProcessInstanceQuery()
        .processInstanceId(task.getProcessInstanceId())
        .includeProcessVariables()
        .singleResult();
    PROCESS_VARIABLES = processInstance.getProcessVariables();

    HistoricProcessInstance historicProcessInstance = processEngineConfiguration.getHistoryService().createHistoricProcessInstanceQuery()
        .processInstanceId(task.getProcessInstanceId())
        .includeProcessVariables()
        .singleResult();
    HISTORIC_PROCESS_VARIABLES = historicProcessInstance.getProcessVariables();

    // Used in CacheTaskTest#testTaskQueryWithIncludeVariables
    Task taskFromQuery = processEngineConfiguration.getTaskService().createTaskQuery()
        .taskId(delegateTask.getId())
        .includeProcessVariables()
        .includeTaskLocalVariables()
        .singleResult();
    TASK_PROCESS_VARIABLES = taskFromQuery.getProcessVariables();
    TASK_LOCAL_VARIABLES = taskFromQuery.getTaskLocalVariables();

    HistoricTaskInstance historicTaskFromQuery = processEngineConfiguration.getHistoryService().createHistoricTaskInstanceQuery()
        .taskId(delegateTask.getId())
        .includeProcessVariables()
        .includeTaskLocalVariables()
        .singleResult();
    HISTORIC_TASK_PROCESS_VARIABLES = historicTaskFromQuery.getProcessVariables();
    HISTORIC_TASK_LOCAL_VARIABLES = historicTaskFromQuery.getTaskLocalVariables();

}