📄 approveactionhandler_db.java
字号:
*/
}
/**
*
* @param daycount
* 请假天数
*
*/
protected void userWriteRequest(int daycount) {
System.out.println("==MyRequestProcessTest.userWriteRequest()==");
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
GraphSession graphSession = jbpmContext.getGraphSession();
ProcessDefinition processDefinition =
graphSession.findLatestProcessDefinition("MyRequest");
assertNotNull("Definition should not be null", processDefinition);
List processInstances =
graphSession.findProcessInstances(processDefinition.getId());
ProcessInstance processInstance =
(ProcessInstance) processInstances.get(0);
long id = processInstance.getId();
System.out.println("processInstance id:" + id);
assertNotNull("processInstance should not be null", processInstance);
//System.out.println("processInstance:" + processInstance.getId());
TaskMgmtInstance taskMgmtInstance = processInstance.getTaskMgmtInstance();
System.out.println("****************************************************************");
TaskInstance wr = (TaskInstance) taskMgmtInstance
.getTaskInstances().iterator().next();
System.out.println("****************************************************************");
assertEquals(this.userId, wr.getActorId());
ContextInstance ci = processInstance.getContextInstance();
ci.setVariable("dayCount", new Integer(daycount));
wr.end();
processInstance.signal();
jbpmContext.save(processInstance);
jbpmContext.close();
}
/**
*
* @param isApprove
* 部门主管是否同意请假
*
*/
protected void chiefDecide(boolean isApprove)
{
System.out.println("==MyRequestProcessTest.chiefDecide()==");
// String chiefId="today123";
/**
*
* 如果后台使用数据库的话,就可以使用
*
* org.jbpm.db.TaskMgmtSession.findTaskInstances(java.lang.String
* actorId) 得到所有分配给chiefId的taskInstance
*
*/
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
GraphSession graphSession = jbpmContext.getGraphSession();
ProcessDefinition processDefinition =
graphSession.findLatestProcessDefinition("MyRequest");
assertNotNull("Definition should not be null", processDefinition);
List processInstances =
graphSession.findProcessInstances(processDefinition.getId());
ProcessInstance processInstance =
(ProcessInstance) processInstances.get(0);
assertNotNull("processInstance should not be null", processInstance);
Collection coll = processInstance.getTaskMgmtInstance().getTaskInstances();
Iterator it = coll.iterator();
while (it.hasNext()) {
TaskInstance ti = (TaskInstance) it.next();
if (ti.getName().equals("Task_ChiefDecide")) {
assertEquals("today123", ti.getActorId());
if (isApprove)
ti.end("Tr_ChiefApprove");
else
ti.end("Tr_ChiefNotApprove");
return;
}
}
processInstance.signal();
jbpmContext.save(processInstance);
jbpmContext.close();
}
/**
*
* @param isApprove
* 老板是否同意请假
*
*/
protected void bossDecide(boolean isApprove) {
System.out.println("==MyRequestProcessTest.bossDecide()==");
// String bossId="elena";
/**
*
* 如果后台使用数据库的话,就可以使用
*
* org.jbpm.db.TaskMgmtSession.findTaskInstances(java.lang.String
* actorId) 得到所有分配给bossId的taskInstance
*
*/
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
GraphSession graphSession = jbpmContext.getGraphSession();
ProcessDefinition processDefinition =
graphSession.findLatestProcessDefinition("MyRequest");
assertNotNull("Definition should not be null", processDefinition);
ProcessInstance processInstance = graphSession.getProcessInstance(this.processInstant_id);
assertNotNull("processInstance should not be null", processInstance);
Collection coll = processInstance.getTaskMgmtInstance().getTaskInstances();
Iterator it = coll.iterator();
while (it.hasNext()) {
TaskInstance ti = (TaskInstance) it.next();
if (ti.getName().equals("Task_BossDecide")) {
assertEquals("elena", ti.getActorId());
if (isApprove)
ti.end("Tr_BossApprove");
else
ti.end("Tr_BossNotApprove");
break;
}
}
processInstance.signal();
jbpmContext.save(processInstance);
jbpmContext.close();
}
protected void userCancel() {
System.out.println("==MyRequestProcessTest.userCancel()==");
/**
*
* 如果后台使用数据库的话,就可以使用
*
* org.jbpm.db.TaskMgmtSession.findTaskInstances(java.lang.String
* actorId) 得到所有分配给userid的taskInstance
*
*/
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
GraphSession graphSession = jbpmContext.getGraphSession();
ProcessDefinition processDefinition =
graphSession.findLatestProcessDefinition("MyRequest");
assertNotNull("Definition should not be null", processDefinition);
ProcessInstance processInstance = graphSession.getProcessInstance(this.processInstant_id);
assertNotNull("processInstance should not be null", processInstance);
Collection coll = processInstance.getTaskMgmtInstance().getTaskInstances();
Iterator it = coll.iterator();
while (it.hasNext()) {
TaskInstance ti = (TaskInstance) it.next();
if (ti.getName().equals("Task_CancelRequest")) {
assertEquals(this.userId, ti.getActorId());
ti.end();
break;
}
}
processInstance.signal();
jbpmContext.save(processInstance);
jbpmContext.close();
}
protected void checkTasks() {
System.out.println("==MyRequestProcessTest.checkTasks()==");
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
GraphSession graphSession = jbpmContext.getGraphSession();
ProcessDefinition processDefinition =
graphSession.findLatestProcessDefinition("MyRequest");
assertNotNull("Definition should not be null", processDefinition);
ProcessInstance processInstance = graphSession.getProcessInstance(this.processInstant_id);
assertNotNull("processInstance should not be null", processInstance);
Collection coll = processInstance.getTaskMgmtInstance().getTaskInstances();
Iterator it = coll.iterator();
System.out.println("====Process has task:====");
while (it.hasNext()) {
TaskInstance ti = (TaskInstance) it.next();
System.out.println("==" + ti.getName() + "==");
System.out.println("==" + ti.getActorId() + "==");
System.out.println("==" + ti.getVariables().toString() + "==");
}
processInstance.signal();
jbpmContext.save(processInstance);
jbpmContext.close();
System.out.println("====end====");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -