01: /**
02: *
03: */package org.emforge.jbpm.assigner;
04:
05: import org.jbpm.graph.exe.ExecutionContext;
06: import org.jbpm.taskmgmt.def.AssignmentHandler;
07: import org.jbpm.taskmgmt.exe.Assignable;
08:
09: import ru.emdev.EmForge.security.EmForgeUserDetails;
10: import ru.emdev.EmForge.security.UserFactory;
11:
12: /** Task Assigment Handler
13: *
14: * This class assign task to the process owner's manager
15: * Current implementation just get manager information from "Manager" variable
16: * But later we will automatically get this information from OrgChart
17: */
18: public class AssignToOwnerManager implements AssignmentHandler {
19: private static final long serialVersionUID = -6322225891530182048L;
20: private UserFactory m_userFactory;
21:
22: public void setUserFactory(UserFactory i_userFactory) {
23: m_userFactory = i_userFactory;
24:
25: }
26:
27: /** Assigned task according to "Manager" variable
28: *
29: * (non-Javadoc)
30: * @see org.jbpm.taskmgmt.def.AssignmentHandler#assign(org.jbpm.taskmgmt.exe.Assignable, org.jbpm.graph.exe.ExecutionContext)
31: */
32: public void assign(Assignable i_assignable,
33: ExecutionContext i_executionContext) throws Exception {
34: Object ownerVar = i_executionContext.getVariable("Owner");
35: assert ownerVar != null;
36:
37: assert m_userFactory != null;
38:
39: EmForgeUserDetails owner = m_userFactory.getUser(ownerVar
40: .toString());
41: assert owner != null;
42:
43: EmForgeUserDetails manager = owner.getManager();
44: i_assignable.setActorId(manager.getUsername());
45: }
46:
47: }
|