锘??xml version="1.0" encoding="utf-8" standalone="yes"?> // get the tasklist from jbpm for user
ExecutionService es=JbpmServiceFactory.getInstance().openExecutionService(user);
HashMap vs=new HashMap();
//涓浜涘弬鏁?BR> vs.put(Constants.REQUEST_STATUS,String.valueOf(0));
vs.put(Constants.REQUEST_RETURN_INFO,"No info!");
vs.put(Constants.USER_NAME,EncodeTransfer.toISO(user));
vs.put(Constants.REQUEST_DAYS,String.valueOf(rea.getDays()));
try {
//寮鍚鍋囨祦紼?BR> es.startProcessInstance(Constants.WORK_NAME, vs);
log.info("["+user+"]"+"鐢寵鍋囨湡寮濮嬶紒璇峰亣"+rea.getDays()+"澶╋紒");
return am.findForward("main");
} catch (ExecutionException ex) {
ex.printStackTrace();
log.error("璇峰亣榪涚▼鏃犳硶寮濮嬶紒");
return am.findForward("error");
}finally{
es.close();
}
錛堜簩錛夊綋鍓嶆墽琛屼換鍔?BR> 瀵逛簬閮ㄩ棬緇忕悊鎴栬呰佹澘錛屾壘鍒拌澶勭悊鐨勮鍋囥?BR> String actorId = (String) req.getSession().getAttribute(Constants.USER);
if(actorId.equals("wang")){
actorId="boss";
}else if(actorId.equals("bigli")){
actorId="chief";
}
// get the execution service
ExecutionService executionService = JbpmServiceFactory.getInstance().
openExecutionService(actorId);
List tasks = new ArrayList();
// add the jbpm tasks
tasks.addAll(executionService.getTaskList(actorId));
// put the tasklist into the form
mf.setTasks(tasks);
// get the tasklist from jbpm for user
List definitions = new ArrayList();
// add the jbpm definitions
definitions.addAll(executionService.getLatestDefinitions());
// put the tasklist into the form
mf.setRequests(definitions);
// close the execution service
executionService.close();
req.getSession().setAttribute("mainForm",mf);
log.debug("浠誨姟: " + tasks);
log.debug("褰撳墠鍙互鎵ц鐨勮姹? " + definitions);
錛堜笁錛夊鐞嗚鍋?BR> String actorId = (String) reqrest.getSession().getAttribute(Constants.
USER);
Long tokenId=new Long(req.getParameter("tokenId"));
// get the execution service
ExecutionService executionService = JbpmServiceFactory.getInstance().
openExecutionService(actorId);
Map hm=executionService.getVariables(tokenId);//鍙橀噺
String act=req.getParameter("action");//榪涜杞崲鐨則ransition
executionService.endOfState(tokenId,hm,act);
executionService.close();
]]>
錛堜簩錛塂ecision
package kellerdu.jbpm.delegation;
import org.jbpm.delegation.*;
import kellerdu.jbpm.LogsFactory;
import org.apache.commons.logging.Log;
import kellerdu.jbpm.Constants;
public class ChiefDecision implements DecisionHandler {
public ChiefDecision() {
}
/**
* 鍒ゆ柇鏄惁闇瑕佷富綆℃壒鍑嗭紝鍐沖畾涓嬩竴涓榪涜鐨則ransition
*
* @param executionContext ExecutionContext
* @return String
* @todo Implement this org.jbpm.delegation.DecisionHandler method
*/
public String decide(ExecutionContext executionContext) {
Log log=LogsFactory.getLogInstance(this.getClass());
String ac=(String)executionContext.getVariable(Constants.USER_NAME);
if(ac!=null&&(ac.equals("dali")||ac.equals("wang"))){
log.info(ac+"闇瑕佽佹澘鎵瑰噯錛?);
return "BossApprove";
}else{
log.info(ac+"闇瑕佸厛緇忎富綆℃壒鍑?);
return "ChiefApprove";
}
}
}
錛濓紳錛濓紳錛濓紳錛濓紳錛濓紳錛濓紳錛濓紳錛濓紳錛濓紳錛濓紳錛濓紳錛?BR>錛堜笁錛塮ork
package kellerdu.jbpm.delegation;
import org.jbpm.*;
import org.jbpm.delegation.*;
import org.jbpm.model.execution.*;
import java.util.*;
public class DecidedJoin implements JoinHandler {
public DecidedJoin() {
}
/**
* fork錛屽彧瑕佷竴涓垎鏀埌杈撅紝鍗沖彲榪涜涓嬩竴姝ユ搷浣滐紝鍚屾椂鍙栨秷鍏跺畠鍚屾椂榪涜鐨勫垎鏀?BR> * 榪欓噷灝辨槸鐢ㄦ埛濡傛灉鍙栨秷錛岃鍋囧氨鍙栨秷銆傚鏋滅敤鎴瘋鍋囨壒鍑嗭紝鍒欑敤鎴蜂笉鑳藉彇娑堛?BR> *
* @param forkContext ForkContext
* @throws ExecutionException
* @todo Implement this org.jbpm.delegation.ForkHandler method
*/
public void join(JoinContext joinContext) throws ExecutionException {
Iterator it=joinContext.getConcurrentTokens().values().iterator();
Token arrivingToken = joinContext.getToken();
while(it.hasNext()){
Token to=(Token)it.next();
if(to.getId().equals(arrivingToken.getId())){
//鍙栨秷鍏跺畠鎵ц鐨凾oken
joinContext.getExecutionService().cancelToken(to.getId());
}
}
// reactivate the parent token.
joinContext.reactivateToken( arrivingToken.getParent() );
}
}
import org.jbpm.delegation.*;
import kellerdu.jbpm.LogsFactory;
import org.apache.commons.logging.Log;
public class BossSwimlane implements AssignmentHandler {
public BossSwimlane() {
}
/**
* 褰撳墠鐨勭姸鎬佹湁鍝釜actor鏉ュ叿浣撹礋璐e鐞嗭紝閫夋嫨鏄佹澘鐨刟ctor鏉ュ鐞嗐?BR> *
* 濡傛灉鐜嬫灄鏄佹澘錛岄偅涔堜粬璇峰亣鍙互鐢ㄤ粬鐨勫悕縐版潵寮濮嬩竴涓鍋囨祦紼嬶紝褰撲粬媯(gè)鏌ヤ粬闇瑕佹壒紺虹殑
* 璇峰亣鏃訛紝浣跨敤actorId=boss鏉ユ壘鍑烘墍鏈夌殑鎵圭ず銆傝繖鏃秙electActor榪斿洖鐨勫煎氨鏄竴涓父閲忊渂oss鈥?BR> *
*
* @param assignmentContext AssignmentContext
* @return String
* @todo Implement this org.jbpm.delegation.AssignmentHandler method
*/
public String selectActor(AssignmentContext assignmentContext) {
Log log = LogsFactory.getLogInstance(this.getClass());
log.info("浠誨姟鍒嗛厤緇欒佹澘");
return "boss";
}
}
錛濓紳錛濓紳錛濓紳錛濓紳錛濓紳錛濓紳錛濓紳錛濓紳錛濓紳錛濓紳錛濓紳錛濓紳錛濓紳錛濓紳錛濓紳錛濓紳錛濓紳錛濓紳錛濓紳錛濓紳
ackage kellerdu.jbpm.delegation;
import org.jbpm.delegation.*;
import kellerdu.jbpm.LogsFactory;
import org.apache.commons.logging.Log;
public class ChiefSwimlane implements AssignmentHandler {
public ChiefSwimlane() {
}
/**
* selectActor
* @see BossSwimlane
*
* @param assignmentContext AssignmentContext
* @return String
* @todo Implement this org.jbpm.delegation.AssignmentHandler method
*/
public String selectActor(AssignmentContext assignmentContext) {
Log log = LogsFactory.getLogInstance(this.getClass());
log.info("浠誨姟鍒嗛厤緇欎笂綰т富綆?);
return "chief";
}
}