使用jBpm支持高级用户交互模式 - 编程入门网
= new StringBuffer();
boolean first = true;
for(Assignee a : assignees){
if(!first)
sb.append(" ");
else
first = false;
sb.append(a.getUserID());
}
return sb.toString();
}
public List<Assignee> getAssignees() {
return assignees;
}
public void reserve(String userID) throws JbpmException {
if(task == null)
throw new JbpmException("can''t reserve instance with no task");
// Duplicate assignment is ok
for(Assignee a : assignees){
if(userID.equals(a.getUserID()))
return;
}
// Can we add one more guy?
if(task.getNumSignatures() > assignees.size()){
assignees.add(new Assignee(userID));
return;
}
throw new JbpmException("task is already reserved by " +
getAssigneeIDs());
}
public void unreserve(String userID){
for(Assignee a : assignees){
if(userID.equals(a.getUserID())){
assignees.remove(a);
return;
}
}
}
private void completeTask(Assignee assignee, String transition){
assignee.setEndDate(new Date());
// Calculate completed assignments
int completed = 0;
for(Assignee a : assignees){
if(a.getEndDate() != null)
completed ++;
}
if(completed < task.getNumSignatures())
return;
if(transition == null)
end();
else
end(transition);
}
public void complete(String userID, String transition) throws JbpmException{
if(task == null)
throw new JbpmException("can''t complete instance with no task");
// make sure it was reserved
for(Assignee a : assignees){
if(userID.equals(a.getUserID())){
completeTask(a, transition);
return;
}
}
throw new JbpmException("task was not reserved by " + userID);
}
public boolean isCompleted(){
return (end != null);
}
}
使用jBpm支持高级用户交互模式(4)时间:2011-07-08 infoq 译:胡键清单6 扩展TaskInstance类 这个实现扩展了jBPM提供的TaskInstance类,并跟踪完成该实例所需的参与者 个数。它引入了几个新方法,允许参与者预留(reserve)/退还(unreserve)任 务实例,以及让指定参与者完成任务执行。 清单6的实现依赖一个支持类Assignee(清单7)
|
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |