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

The following examples show how to use org.flowable.engine.delegate.DelegateExecution#getVariable() . 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: ThrowCustomExceptionBean.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
public void throwException(DelegateExecution execution) {
    Object exceptionClassVar = execution.getVariable("exceptionClass");
    if (exceptionClassVar == null) {
        return;
    }

    String exceptionClassName = exceptionClassVar.toString();

    if (StringUtils.isNotEmpty(exceptionClassName)) {
        RuntimeException exception = null;
        try {
            Class<?> clazz = Class.forName(exceptionClassName);
            exception = (RuntimeException) clazz.newInstance();

        } catch (Exception e) {
            throw new FlowableException("Class not found", e);
        }
        throw exception;
    }
}
 
Example 2
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 3
Source File: MultiInstanceTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void notify(DelegateExecution execution) {
    Integer loopCounter = (Integer) execution.getVariable("loopCounter");
    if (loopCounter != null) {
        countWithLoopCounter.incrementAndGet();
    } else {
        countWithoutLoopCounter.incrementAndGet();
    }
}
 
Example 4
Source File: ServiceTaskVariablesTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(DelegateExecution execution) {
    Variable v = (Variable) execution.getVariable("variable");
    synchronized (ServiceTaskVariablesTest.class) {
        // we expect this to be 'true' as well
        isOkInDelegate3 = ("delegate2".equals(v.value));
    }
}
 
Example 5
Source File: ServiceTaskVariablesTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(DelegateExecution execution) {
    Variable v = (Variable) execution.getVariable("variable");
    synchronized (ServiceTaskVariablesTest.class) {
        // we expect this to be 'true'
        isOkInDelegate2 = ("delegate1".equals(v.value));
    }
    v.value = "delegate2";
    execution.setVariable("variable", v);
}
 
Example 6
Source File: ActivityStartListener.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
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 7
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 8
Source File: SignalEventTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(DelegateExecution execution) {
    businessProcess.setVariable("processName", "throwSignal-visited (was " + businessProcess.getVariable("processName") + ")");

    String signalProcessInstanceId = (String) execution.getVariable("signalProcessInstanceId");
    String executionId = runtimeService.createExecutionQuery().processInstanceId(signalProcessInstanceId).signalEventSubscriptionName("alert").singleResult().getId();

    runtimeService.signalEventReceived("alert", executionId);
}
 
Example 9
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 10
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 11
Source File: SerializableVariableTest.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
public void execute(DelegateExecution execution) {
    TestSerializableVariable var = (TestSerializableVariable) execution.getVariable("myVar");
    var.setNumber(2);
}
 
Example 12
Source File: SaveOutput.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public void execute(DelegateExecution execution) {
    Map<String, String> outputMap = (Map<String, String>) execution.getVariable("outputMap");
    outputMap.put("outputValue", (String) execution.getVariable("camelBody"));
}
 
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 testVar = (String) execution.getVariable("testVar", false);
    execution.setVariable("testVar", testVar + "3");
}
 
Example 14
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");
    execution.setVariable("testVar", var.toUpperCase());
}
 
Example 15
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 16
Source File: DummyServiceTask.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public void execute(DelegateExecution execution) {
    Integer count = (Integer) execution.getVariable("count");
    count = count + 1;
    execution.setVariable("count", count);
}
 
Example 17
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 + "!");
}
 
Example 18
Source File: DummyServiceTask.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
public void execute(DelegateExecution execution) {
    Integer count = (Integer) execution.getVariable("count");
    count = count + 1;
    execution.setVariable("count", count);
}
 
Example 19
Source File: DummyServiceTask2.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
public void execute(DelegateExecution execution) {
    Integer count = (Integer) execution.getVariable("count2");
    count = count + 1;
    execution.setVariable("count2", count);
}
 
Example 20
Source File: StepsUtil.java    From multiapps-controller with Apache License 2.0 4 votes vote down vote up
static LogsOffset getLogOffset(DelegateExecution execution) {
    return (LogsOffset) execution.getVariable(com.sap.cloud.lm.sl.cf.core.Constants.LOGS_OFFSET);
}