public Lifecycle transitionTo(STATE next) { Lifecycle nextLifecycle = null; switch (next) { case SUSPENDED: // only RUNNING instances can be SUSPENDED if (STATE.RUNNING.equals(current)) { nextLifecycle = new Lifecycle(instance, next); instance.suspended = true; break; } else { throw new IllegalTransitionException(current, next); } case ENDED: // both RUNNING and SUSPENDED instances can be ENDED if (STATE.RUNNING.equals(current) || STATE.SUSPENDED.equals(current)) { nextLifecycle = new Lifecycle(instance, next); instance.suspended = false; instance.endDate = new Date(); break; } else { throw new IllegalTransitionException(current, next); } case RUNNING: // only SUSPENDED instances can become RUNNING if (STATE.SUSPENDED.equals(current)) { nextLifecycle = new Lifecycle(instance, next); instance.suspended = false; break; } else { throw new IllegalTransitionException(current, next); } default: throw new IllegalTransitionException(current, next); } return nextLifecycle; }
@Test @Ignore public void testNewProcessInstanceWithVariables() { HashMap<String, Object> variables = new HashMap<String, Object>(); variables.put("key2", "variable2"); ProcessInstanceRef instanceRef = processManager.newInstance("UserTask", variables); assertEquals("UserTask", instanceRef.getDefinitionId()); assertEquals(3, processManager.getProcessInstances("UserTask").size()); assertEquals("variable2", processManager.getInstanceData(instanceRef.getId()).get("key2")); }
public static ProcessInstanceRef processInstance(ProcessInstanceLog processInstance) { ProcessInstanceRef result = new ProcessInstanceRef( processInstance.getProcessInstanceId() + "", processInstance.getProcessId(), processInstance.getStart(), processInstance.getEnd(), false); TokenReference token = new TokenReference(processInstance.getProcessInstanceId() + "", null, ""); result.setRootToken(token); return result; }