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

The following examples show how to use org.flowable.engine.delegate.DelegateExecution#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: VariablesTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
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 2
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 3
Source File: TerminateEndEventTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(DelegateExecution execution) {
    serviceTaskInvokedCount++;

    // leave only 3 out of n subprocesses
    execution.setVariableLocal("terminate", serviceTaskInvokedCount > 3);
}
 
Example 4
Source File: VariablesTest.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public void execute(DelegateExecution execution) {
    String value = (String) execution.getVariable("testVar2");
    String localVarValue = (String) execution.getVariableLocal("localValue");
    execution.setVariableLocal("testVar2", value + localVarValue);
}
 
Example 5
Source File: SetLocalVariableTask.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public void execute(DelegateExecution execution) {
    execution.setVariableLocal("test", "test2");
}
 
Example 6
Source File: TerminateEndEventTest.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public void execute(DelegateExecution execution) {
    serviceTaskInvokedCount++;

    // leave only 3 out of n subprocesses
    execution.setVariableLocal("terminate", serviceTaskInvokedCount > 3);
}
 
Example 7
Source File: SetVariablesDelegate.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public void execute(DelegateExecution execution) {
    Object nrOfCompletedInstances = execution.getVariableLocal("nrOfCompletedInstances");
    variablesMap.put(nrOfCompletedInstances, lastInt);
    execution.setVariableLocal("variable", lastInt);
    lastInt++;
}
 
Example 8
Source File: MultiInstanceActivityBehavior.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
protected void setLoopVariable(DelegateExecution execution, String variableName, Object value) {
    execution.setVariableLocal(variableName, value);
}
 
Example 9
Source File: ServiceTaskExpressionActivityBehavior.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
public void execute(DelegateExecution execution) {
    Object value = null;
    try {
        CommandContext commandContext = CommandContextUtil.getCommandContext();
        String skipExpressionText = null;
        if (skipExpression != null) {
            skipExpressionText = skipExpression.getExpressionText();
        }
        boolean isSkipExpressionEnabled = SkipExpressionUtil.isSkipExpressionEnabled(skipExpressionText, serviceTaskId, execution, commandContext);
        if (!isSkipExpressionEnabled || !SkipExpressionUtil.shouldSkipFlowElement(skipExpressionText, serviceTaskId, execution, commandContext)) {

            if (CommandContextUtil.getProcessEngineConfiguration(commandContext).isEnableProcessDefinitionInfoCache()) {
                ObjectNode taskElementProperties = BpmnOverrideContext.getBpmnOverrideElementProperties(serviceTaskId, execution.getProcessDefinitionId());
                if (taskElementProperties != null && taskElementProperties.has(DynamicBpmnConstants.SERVICE_TASK_EXPRESSION)) {
                    String overrideExpression = taskElementProperties.get(DynamicBpmnConstants.SERVICE_TASK_EXPRESSION).asText();
                    if (StringUtils.isNotEmpty(overrideExpression) && !overrideExpression.equals(expression.getExpressionText())) {
                        expression = CommandContextUtil.getProcessEngineConfiguration(commandContext).getExpressionManager().createExpression(overrideExpression);
                    }
                }
            }

            value = expression.getValue(execution);
            if (resultVariable != null) {
                if (storeResultVariableAsTransient) {
                    if (useLocalScopeForResultVariable) {
                        execution.setTransientVariableLocal(resultVariable, value);
                    } else {
                        execution.setTransientVariable(resultVariable, value);
                    }
                } else {
                    if (useLocalScopeForResultVariable) {
                        execution.setVariableLocal(resultVariable, value);
                    } else {
                        execution.setVariable(resultVariable, value);
                    }
                }
            }
        }
        if (!this.triggerable) {
            leave(execution);
        }

    } catch (Exception exc) {

        Throwable cause = exc;
        BpmnError error = null;
        while (cause != null) {
            if (cause instanceof BpmnError) {
                error = (BpmnError) cause;
                break;
            } else if (cause instanceof RuntimeException) {
                if (ErrorPropagation.mapException((RuntimeException) cause, (ExecutionEntity) execution, mapExceptions)) {
                    return;
                }
            }
            cause = cause.getCause();
        }

        if (error != null) {
            ErrorPropagation.propagateError(error, execution);
        } else {
            throw exc;
        }
    }
}
 
Example 10
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 value = (String) execution.getVariable("testVar2");
    String localVarValue = (String) execution.getVariableLocal("localValue");
    execution.setVariableLocal("testVar2", value + localVarValue);
}
 
Example 11
Source File: SetLocalVariableTask.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
public void execute(DelegateExecution execution) {
    execution.setVariableLocal("test", "test2");
}