protected void throwErrorIfRequested(DelegateExecution execution) { Boolean shouldThrowError = (Boolean) execution.getVariable(ERROR_INDICATOR_VARIABLE); if (Boolean.TRUE.equals(shouldThrowError)) { String errorName = (String) execution.getVariable(ERROR_NAME_VARIABLE); if (errorName == null) { errorName = DEFAULT_ERROR_NAME; } throw new BpmnError(errorName); } }
protected void throwExceptionIfRequested(DelegateExecution execution) { Boolean shouldThrowException = (Boolean) execution.getVariable(EXCEPTION_INDICATOR_VARIABLE); if (Boolean.TRUE.equals(shouldThrowException)) { String exceptionMessage = (String) execution.getVariable(EXCEPTION_MESSAGE_VARIABLE); if (exceptionMessage == null) { exceptionMessage = DEFAULT_EXCEPTION_MESSAGE; } throw new ThrowBpmnErrorDelegateException(exceptionMessage); } }
@Override public void execute(DelegateExecution execution) throws Exception { Boolean fail = (Boolean) execution.getVariable("fail"); if (fail == null || fail == true) { throw new ProcessEngineException(EXCEPTION_MESSAGE); } }
public void execute(DelegateExecution execution) throws Exception { Variable v = (Variable) execution.getVariable("variable"); synchronized (ServiceTaskVariablesTest.class) { // we expect this to be 'true' as well isNullInDelegate3 = (v.value != null && v.value.equals("delegate2")); } }
public void execute(DelegateExecution execution) throws Exception { List<String> list = (List<String>) execution.getVariable("listVar"); // implicit update of the list, so no execution.setVariable call list.add(NEW_ELEMENT); }
@Override public void execute(DelegateExecution execution) throws Exception { String flight = (String) execution.getVariable("flight"); if (flight != null) { bookedFlights.add(flight); } }
@Override public void execute(DelegateExecution execution) throws Exception { String flight = (String) execution.getVariable("flight"); if (flight != null) { canceledFlights.add(flight); } }
@Override public void execute(DelegateExecution execution) throws Exception { String version = (String) execution.getVariable("version"); if ("1.0".equals(version) || "2.0".equals(version)) { System.out.println(" ### Updating router configuration..." ); } else { throw new Exception("Unsupported Version: " + version); } }
public void execute(DelegateExecution execution) { String var = (String) execution.getVariable(VARIABLE_NAME); var = var.toUpperCase(); execution.setVariable(VARIABLE_NAME, var); }
@Override public void notify(DelegateExecution execution) throws Exception { Object variable = execution.getVariable(VARIABLE_NAME); assertNotNull(variable); } }
public void execute(DelegateExecution execution) throws Exception { List<String> list = (List<String>) execution.getVariable("listVar"); // replace the list by another object execution.setVariable("listVar", new ArrayList<String>()); // implicitly update the previous list, should update the variable value list.add(NEW_ELEMENT); }
public void execute(DelegateExecution execution) throws Exception { Boolean fail = (Boolean) execution.getVariable("fail"); if (fail != null && fail == true) { throw new ProcessEngineException("Expected exception"); } }
@Override public void execute(DelegateExecution execution) throws Exception { Boolean fail = (Boolean) execution.getVariable("fail"); if (fail == null || fail == true) { throw new ProcessEngineException(EXCEPTION_MESSAGE); } }
@Override public void execute(DelegateExecution execution) throws Exception { if ( !"23".equals(execution.getVariable("serialnumber"))) { throw new Exception( "The provided router serial number is wrong. The correct serial number is 23 ;-)" ); } execution.setVariable("version", "2.0"); }
@Override public void execute(DelegateExecution execution) throws Exception { String newKeyValue = (String) execution.getVariable(BUSINESS_KEY_VARIABLE); execution.setProcessBusinessKey(newKeyValue); }
public void notify(DelegateExecution execution) throws Exception { int listenerInvocationCount = 0; if(execution.hasVariable(LISTENER_INVOCATION_COUNT)) { listenerInvocationCount = (Integer) execution.getVariable(LISTENER_INVOCATION_COUNT); } listenerInvocationCount += 1; execution.setVariable(LISTENER_INVOCATION_COUNT, listenerInvocationCount); } };
@Override public void execute(DelegateExecution execution) throws Exception { Boolean transient1 = (Boolean) execution.getVariable("transient1"); Boolean transient2 = (Boolean) execution.getVariable("transient2"); execution.setVariable(VARIABLE_NAME, Variables.integerValue(1, transient1)); execution.setVariable(VARIABLE_NAME, Variables.integerValue(2, transient2)); } }
public void execute(DelegateExecution execution) throws Exception { Date currentTime = (Date)execution.getVariable("currentTime"); currentTime = DateUtils.addSeconds(currentTime, 1); ClockUtil.setCurrentTime(currentTime); execution.setVariable("currentTime", currentTime); }
public void execute(DelegateExecution execution) throws Exception { JavaSerializable dataObject = (JavaSerializable) execution.getVariable("varName"); Assert.assertNotNull(dataObject); Assert.assertEquals("foo", dataObject.getProperty()); }
@Override public void execute(DelegateExecution execution) throws Exception { RuntimeService runtimeService = execution.getProcessEngineServices().getRuntimeService(); TaskService taskService = execution.getProcessEngineServices().getTaskService(); String instanceToDelete = (String) execution.getVariable("instanceToComplete"); Task taskToTrigger = taskService.createTaskQuery().processInstanceId(instanceToDelete).singleResult(); taskService.complete(taskToTrigger.getId()); ActivityInstance activityInstance = runtimeService.getActivityInstance(instanceToDelete); execution.setVariable("activityInstanceNull", activityInstance == null); }