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

The following examples show how to use org.flowable.engine.delegate.DelegateExecution#setVariable() . 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: StartToEndTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(DelegateExecution execution) {
    execution.setVariable("string", "string");
    execution.setVariable("boolean", true);
    execution.setVariable("double", 25.5);
    execution.setVariable("long", 10L);
}
 
Example 2
Source File: VariableEventsExecutionListener.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void notify(DelegateExecution execution) {
    // Create, update and remove variable
    execution.setVariable("variable", 123);
    execution.setVariable("variable", 456);
    execution.removeVariable("variable");
}
 
Example 3
Source File: TriggerableServiceTask.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
public void incrementCount(DelegateExecution execution) {
    String variableName = "count";
    int count = 0;
    if (execution.hasVariable(variableName)) {
         count = (int) execution.getVariable(variableName);
    }
    count++;
    execution.setVariable(variableName, count);
}
 
Example 4
Source File: ServiceTaskVariablesTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
public void execute(DelegateExecution execution) {
    Variable v = (Variable) execution.getVariable("variable");
    synchronized (ServiceTaskVariablesTest.class) {
        // we expect this to be 'true'
        isNullInDelegate2 = ("delegate1".equals(v.value));
    }
    v.value = "delegate2";
    execution.setVariable("variable", v);
}
 
Example 5
Source File: TransientVariablesTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
public void notify(DelegateExecution execution) {
    String persistentVar1 = (String) execution.getVariable("persistentVar1");

    Object unusedTransientVar = execution.getVariable("unusedTransientVar");
    if (unusedTransientVar != null) {
        throw new RuntimeException("Unused transient var should have been deleted");
    }

    String secondTransientVar = (String) execution.getVariable("secondTransientVar");
    Number thirdTransientVar = (Number) execution.getTransientVariable("thirdTransientVar");

    String combinedVar = persistentVar1 + secondTransientVar + thirdTransientVar.intValue();
    execution.setVariable("combinedVar", combinedVar);
}
 
Example 6
Source File: StartToEndTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(DelegateExecution execution) {
    execution.setVariable("string", "string");
    execution.setVariable("boolean", true);
    execution.setVariable("double", 25.5);
    execution.setVariable("long", 10L);
}
 
Example 7
Source File: VariablesTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(DelegateExecution execution) {
    Map<String, Object> vars = execution.getVariables(Arrays.asList("testVar1", "testVar2", "testVar3"), false);

    String testVar1 = (String) vars.get("testVar1");
    String testVar2 = (String) vars.get("testVar2");
    String testVar3 = (String) vars.get("testVar3");

    execution.setVariable("testVar1", testVar1 + "-CHANGED", false);
    execution.setVariable("testVar2", testVar2 + "-CHANGED", false);
    execution.setVariable("testVar3", testVar3 + "-CHANGED", false);

    execution.setVariableLocal("localVar", "localValue", false);
}
 
Example 8
Source File: ActivityStartListener.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
public void notify(DelegateExecution execution) {

        Integer loopCounter = (Integer) execution.getVariable("loopCounter");
        if (loopCounter != null) {

            Integer counter = (Integer) execution.getVariable("executionListenerCounter");
            if (counter == null) {
                counter = 0;
            }
            execution.setVariable("executionListenerCounter", ++counter);

        }
    }
 
Example 9
Source File: HttpExecutionListener.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void notify(DelegateExecution execution) {
    execution.setVariable("runs", ++runs);
    for (Map.Entry e : execution.getVariables().entrySet()) {
        LOGGER.info("key: {}", e.getKey());
        if (e.getValue() != null) {
            LOGGER.info("Value: {}", e.getValue());
        }
    }
}
 
Example 10
Source File: ConditionalThrowExceptionDelegate.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(DelegateExecution execution) {
    Object throwException = execution.getVariable(execution.getCurrentActivityId());

    if (throwException != null && (boolean) throwException) {
        throw new FlowableException("throwException was true");
    }

    if (injectedVar != null && injectedVar.getValue(execution) != null) {
        execution.setVariable("injectedExecutionVariable", injectedVar.getValue(execution));
    }
}
 
Example 11
Source File: CustomBusinessRuleTask.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
public void execute(DelegateExecution execution) {
    execution.setVariable("test", "test2");
    leave((ActivityExecution) execution);
}
 
Example 12
Source File: CustomSetConditionsExecutionListener.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
public void notify(DelegateExecution execution) {
    execution.setVariable(flowId + "_activiti_conditions", conditions);
}
 
Example 13
Source File: VariablesTest.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
public void execute(DelegateExecution execution) {
    String var = (String) execution.getVariable("testVar", false);
    execution.setVariable("testVar", var.toUpperCase());
}
 
Example 14
Source File: GenerateRandomValueActivity.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
public void execute(DelegateExecution execution) {
    Integer value = random.nextInt(10);
    execution.setVariable("var", value);
}
 
Example 15
Source File: ExampleFieldInjectedExecutionListener.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public void notify(DelegateExecution execution) {
    execution.setVariable("var", fixedValue.getValue(execution).toString() + dynamicValue.getValue(execution).toString());
}
 
Example 16
Source File: VariablesTest.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public void execute(DelegateExecution execution) {
    String testVar = (String) execution.getVariable("testVar");
    execution.setVariable("testVar", testVar + "4");
}
 
Example 17
Source File: ShellActivityBehavior.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
public void execute(DelegateExecution execution) {

    readFields(execution);

    List<String> argList = new ArrayList<>();
    argList.add(commandStr);

    if (arg1Str != null)
        argList.add(arg1Str);
    if (arg2Str != null)
        argList.add(arg2Str);
    if (arg3Str != null)
        argList.add(arg3Str);
    if (arg4Str != null)
        argList.add(arg4Str);
    if (arg5Str != null)
        argList.add(arg5Str);

    ProcessBuilder processBuilder = new ProcessBuilder(argList);

    try {
        processBuilder.redirectErrorStream(redirectErrorFlag);
        if (cleanEnvBoolean) {
            Map<String, String> env = processBuilder.environment();
            env.clear();
        }
        if (directoryStr != null && directoryStr.length() > 0)
            processBuilder.directory(new File(directoryStr));

        Process process = processBuilder.start();

        if (waitFlag) {
            int errorCode = process.waitFor();

            if (resultVariableStr != null) {
                String result = convertStreamToStr(process.getInputStream());
                execution.setVariable(resultVariableStr, result);
            }

            if (errorCodeVariableStr != null) {
                execution.setVariable(errorCodeVariableStr, Integer.toString(errorCode));

            }

        }
    } catch (Exception e) {
        throw new FlowableException("Could not execute shell command ", e);
    }

    leave(execution);
}
 
Example 18
Source File: VariablesTest.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public void execute(DelegateExecution execution) {
    String var = (String) execution.getVariable("testVar", false);
    execution.setVariable("testVar", var.toUpperCase());
}
 
Example 19
Source File: VariableUpdateDelegate.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public void execute(DelegateExecution execution) {
    execution.setVariable("zzz", 123456789L);
}
 
Example 20
Source File: ToUpperCaseFieldInjected.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public void execute(DelegateExecution execution) {
    execution.setVariable("var", ((String) text.getValue(execution)).toUpperCase());
}