日期:2014-05-19 浏览次数:20842 次
public void testDeployProcessDefinition(){ JbpmContext context = configuration.createJbpmContext() ; try { ProcessDefinition pd = new ProcessDefinition(processDefinitionName) ; JbpmUtil.deployProcessDefinition(context, pd) ; } catch (Exception e) { context.setRollbackOnly() ; e.printStackTrace(); }finally{ context.close() ; } } public void testStartNewProcessInstance(){ JbpmContext context = configuration.createJbpmContext() ; try { ProcessInstance pi = JbpmUtil.startNewProcessInstance(context, processDefinitionName) ; System.out.println("Current ProcessInstance Id : "+pi.getId()); } catch (Exception e) { context.setRollbackOnly() ; e.printStackTrace(); }finally{ context.close() ; } } public void testFinishFullProcessInstace(){ JbpmContext context = configuration.createJbpmContext() ; try { JbpmUtil.finishFullProcessInstace(context) ; } catch (Exception e) { context.setRollbackOnly() ; e.printStackTrace(); }finally{ context.close() ; } } public static void finishFullProcessInstace(JbpmContext context){ ProcessInstance pi = context.getProcessInstance(DataUtil.getProcessInstanceId()) ; context.getSession().setFlushMode(FlushMode.ALWAYS) ; while( ! ( pi.getRootToken().getNode() instanceof EndState ) ){ Node node = pi.getRootToken().getNode() ; if( node instanceof StartState ){ System.out.println("StartState : "+node.getName()); pi.signal() ; }else if(node instanceof State){ System.out.println("State : "+node.getName()); pi.signal() ; }else if(node instanceof TaskNode){ System.out.println("TaskNode : "+node.getName()); pi.signal() ; }else if(node instanceof Node){ System.out.println(" Node : "+node.getName()); }else{ System.out.println("Unknown Node : "+node.getName() ); } } }