1 package org.jbpm.webapp.bean; 2 3 import java.util.List ; 4 5 import org.jbpm.db.GraphSession; 6 import org.jbpm.db.JbpmSession; 7 import org.jbpm.db.TaskMgmtSession; 8 import org.jbpm.graph.def.ProcessDefinition; 9 import org.jbpm.graph.exe.ProcessInstance; 10 import org.jbpm.taskmgmt.exe.TaskInstance; 11 import org.jbpm.webapp.context.Context; 12 13 public class HomeBean { 14 15 UserBean userBean; 16 TaskBean taskBean; 17 GraphSession graphSession; 18 TaskMgmtSession taskMgmtSession; 19 20 public HomeBean() { 21 JbpmSession jbpmSession = Context.getPersistenceContext().getJbpmSession(); 22 this.graphSession = jbpmSession.getGraphSession(); 23 this.taskMgmtSession = jbpmSession.getTaskMgmtSession(); 24 } 25 26 public List getTaskInstances() { 27 return taskMgmtSession.findTaskInstances(userBean.getUserName()); 28 } 29 30 public List getLatestProcessDefinitions() { 31 return graphSession.findLatestProcessDefinitions(); 32 } 33 34 37 public String selectTaskInstance() { 38 long taskInstanceId = JsfHelper.getId("taskInstanceId"); 40 TaskInstance taskInstance = taskMgmtSession.loadTaskInstance(taskInstanceId); 41 taskBean.initialize(taskInstance); 42 return "task"; 43 } 44 45 48 public String startProcessInstance() { 49 long processDefinitionId = JsfHelper.getId("processDefinitionId"); 51 ProcessDefinition processDefinition = graphSession.loadProcessDefinition(processDefinitionId); 52 53 ProcessInstance processInstance = new ProcessInstance(processDefinition); 55 56 TaskInstance taskInstance = processInstance.getTaskMgmtInstance().createStartTaskInstance(); 58 59 graphSession.saveProcessInstance(processInstance); 61 62 taskBean.initialize(taskInstance); 64 65 return "task"; 66 } 67 68 public UserBean getUserBean() { 69 return userBean; 70 } 71 public void setUserBean(UserBean userBean) { 72 this.userBean = userBean; 73 } 74 public TaskBean getTaskBean() { 75 return taskBean; 76 } 77 public void setTaskBean(TaskBean taskBean) { 78 this.taskBean = taskBean; 79 } 80 } 81 | Popular Tags |