This content has been marked as final.
Show 2 replies
-
1. Re: assign a task instance at runtime
jeffgordon May 10, 2006 3:00 PM (in response to trisko)You can do anything in an assignment handler to look up user id's or set an assigned group to get tasks into a task list, something like this will set a Pooled Actor but not assign the task:
public class GroupAssignmentHandler implements AssignmentHandler { private static final long serialVersionUID = 1L; private static final Logger log = Logger.getLogger(GroupAssignmentHandler.class.getName()); private String groupName; public void assign(Assignable assignable, ExecutionContext executionContext) { log.debug("Assigning to group "+groupName); Set group = new HashSet(); group.add(new PooledActor(groupName)); if (assignable instanceof TaskInstance) { ((TaskInstance)assignable).setPooledActors(group); } else if (assignable instanceof SwimlaneInstance) { ((SwimlaneInstance)assignable).setPooledActors(group); } else { assignable.setPooledActors(new String[] {groupName}); } } }
Then each task can be retrieved with:List tasks = jbpmContext.getTaskMgmtSession().findPooledTaskInstances(groupName); if (tasks!=null && tasks.size()>0) { // obviously you'd want to have a loop here and check to see if this task is already assigned... TaskInstance task = (TaskInstance)tasks.get(0); taskInstance.setActorId(userId); }
You'd want to save and close your jbpmContext right after this to get your changes committed. -
2. Re: assign a task instance at runtime
trisko May 17, 2006 7:08 AM (in response to trisko)I will try that, many thanks!