jbpm---example

6097 단어 일 하 다jspjbpm

              。。        

  :
deployProcessDefinition.jsp

JbpmContext jbpmContext = JbpmConfiguration.getInstance().createJbpmContext();
DiskFileUpload fileUpload = new DiskFileUpload();
List list  = fileUpload.parseRequest(request);
Iterator iterator = list.iterator();
FileItem  fileItem = (FileItem)iterator.next();

if(fileItem.getContentType().indexOf("application/x-zip-compressed") == -1){
  throw new Exception("Only zip format is accepted!");
}

try{
  WorkflowEngine workflowEngine = ServiceLocator.getWorkflowEngine()
  String pdname = workflowEngine.deployProcessDefinition(fileItem.getInputStream(),null);
  out.println("        :"+pdname);

}catch(Exception e){
   
}

jbpmContext.close();

--------------------------------------------------------------------------------

saveQingjiaForm.jsp //  ,       ,        
//         ,          ,        ,    


QingjiaForm qingjiaForm = new QingjiaForm();
qingjiaForm.setApplier((String)session.getAttribute("actorId"));
qingjiaForm.setNday(Integer.parseInt(ndays));
qingjiaForm.setReason(reason);

if("commit".equals(actionType)){  
   qingjiaForm.setState(QingjiaForm.SENT); 
}else{
   qingjiaForm.setState(QingjiaForm.INITIAL);
}

JbpmContext jbpmContext = JbpmConfiguration.getInstance().getCurrentJbpmContext();
jbpmContext.getSession().save(qingjiaForm) ; //               

if("commit".equals(actionType)){ //     ,           

 	WorkflowEngine workflowEngine = ServiceLocator.getWorkflowEngine();
 	
 	Map varMap = new HashMap();
 	varMap.put("infoid",qingjiaForm.getId());
 	
 	//     ,               ,     qingjia
 	//        ,                 ,        
 	//String pdname,String starter,String version,Map varMap
 	workflowEngine.startProcess("qingjia",(String)session.getAttribute("actorId"),varMap);

}


--------listTaskInstances.jsp-->openTask.jsp--------------------------------------------------------
JbpmContext jbpmContext = JbpmConfiguration.getInstance().getCurrentJbpmContext();
Session session = jbpmContext.getSession();
Criteria rootCriteria = session.createCriteria(TaskInstance.class);

String pdname = request.getParameter("pdname");
String actorId = request.getParameter("actorId");
String tname = request.getParameter("tname");
String tstate = request.getParameter("tstate");

WorkflowEngine workflowEngine = ServiceLocator.getWorkflowEngine();
WorkitemCriteria workitemCriteria = new WorkitemCriteria();
workitemCriteria.setPdname(pdnane);
workitemCriteria.setTname(tname);
workitemCriteria.setActorId((String)session.getAttribute("actorId"));

String pageNum = request.getParameter("pageNum");
pageNum = pageNum == null || pageNum.equals("")?"0":pageNum;
int everyPage = workitemCriteria.getNeveryPage();
int target = Integer.parseInt(pageNum);
int startNum = targetPage * everyPage;

workitemCriteria.setStart(startNum);
workitemCriteria.setStatus(tstate);

PagedObject po = workflowEngine.getWorklist(workitemCriteria);

pageContext.setAttribute("list",po.getResult());

<c:forEach items="${list}" var="ti">
  <a href="<c:url value="/sysadmin/openTask.jsp?tiid=${ti.id}" />"><c:out value="ti.name" /></a>
</c:forEach>

--------------------------------------------------------------------
OpenTask.jsp        

String tiid = request.getParameter("tiid");
WorkflowEngine workflowEngine.takeWorkitem(null,tiid);

pageContext.forward(view+"?tiid="+tiid);

------------------------------------------------
auditQingjiaForm.jsp --->endTask.jsp
Long tiid = Long.parseLong(request.getParameter("tiid"));
JbpmContext jbpmContext = JbpmConfiguration.getInstance().getCurrentJbpmContext();
TaskInstance ti = jbpmContext.loadTaskInstance(tiid);
pageContext.setAttribute("tokenId",ti.getToken().getId());
Long infoid = (Long)ti.getProcessInstance().getContextInstance().getVariable("infoid");
QingjiaForm qingjiaForm = (QingjiaForm)jbpmContext.getSession().get(QingjiaForm.class,infoid);

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
...       
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
<input type="hidden" name="tiid" value="<%=tiid%>" />
List list = ti.getTask().getTaskNode().getLeavingTransitions();
pageContext.setAttribute("nextTrans",list);
if(list.size()>1){
  <select name="nextPath">
     <c:forEach items="${nextTrans}" var="nextTran" varStatus="s">
        <option value="<c:out value="${nextTran.name}"/>"><c:out value="${nextTran.name}"/></option>
     </c:forEach>
  </select>

}

<input type="submit" value="    " />


----------------------------------------------

endTask.jsp

String tiid = request.getParameter("tiid");
String transitionName = request.getParameter("nextPath");
String actorId = request.getParameter("actorId");
ti.getProcessInstance().getContextInstance().setVariable("currentUser",session.getAttribute("actorId"));

WorkflowEngine workflowEngine = ServiceLocator.getWorkflowEngine();
workflowEngine.completeWorkitem(tiid,new NextStep(transitionName.actorId));

좋은 웹페이지 즐겨찾기