01: /**
02: *
03: */package org.emforge.jbpm.assigner;
04:
05: import org.apache.commons.lang.ObjectUtils;
06: import org.apache.commons.lang.StringUtils;
07: import org.jbpm.graph.exe.ExecutionContext;
08: import org.jbpm.taskmgmt.def.AssignmentHandler;
09: import org.jbpm.taskmgmt.exe.Assignable;
10:
11: import ru.emdev.EmForge.security.dao.Role;
12:
13: /**
14: * Swimlane Assigment Handler This task is responsible for assigning task to some swimlane. First of all it recognize
15: * the name of swimlane it should assign task Then it will try to find variable 'AssignTo_SwimlaneName - this variable
16: * probably was set in some previous assignment task If this variable found - so, somebody (manager?) already decided
17: * who from this swimlane will do this task - and task automatically assigned to user, specified in this variable. If
18: * such variable is not exists, or empty, task assigned to Role, specified in swimlane name
19: */
20: public class SwimlaneAssignmentHandler implements AssignmentHandler {
21:
22: private static final long serialVersionUID = -7232422300057587405L;
23:
24: /**
25: * Assigns task according to swimlane (non-Javadoc)
26: *
27: * @see org.jbpm.taskmgmt.def.AssignmentHandler#assign(org.jbpm.taskmgmt.exe.Assignable,
28: * org.jbpm.graph.exe.ExecutionContext)
29: */
30: @SuppressWarnings("unchecked")
31: public void assign(Assignable i_assignable,
32: ExecutionContext i_executionContext) throws Exception {
33:
34: // first get swimlane name
35: String swimlaneName = i_executionContext.getTask()
36: .getSwimlane().getName();
37:
38: // try to find related assignTo variable
39: String roleVariable = Role.getVariableName(swimlaneName);
40: String assignTo = ObjectUtils.toString(i_executionContext
41: .getVariable(roleVariable));
42:
43: if (StringUtils.isBlank(assignTo.toString())) {
44: // AssignTo is not specified - just assign task to the role
45: // specified in swimlane
46: i_assignable.setActorId(swimlaneName);
47: } else {
48: i_assignable.setActorId(assignTo.toString());
49: }
50: }
51:
52: }
|