1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kew.engine;
17
18 import java.util.ArrayList;
19 import java.util.List;
20
21 import org.kuali.rice.kew.api.identity.Id;
22 import org.kuali.rice.kew.api.identity.PrincipalName;
23 import org.kuali.rice.kew.engine.node.NodeState;
24 import org.kuali.rice.kew.routeheader.DocumentContent;
25 import org.kuali.rice.kew.rule.AbstractRoleAttribute;
26 import org.kuali.rice.kew.rule.ResolvedQualifiedRole;
27
28
29 public class DynamicSubRoleAttribute extends AbstractRoleAttribute {
30
31 private static final long serialVersionUID = 5147874690575620616L;
32 private List<String> roleNames = new ArrayList<String>();
33
34 public DynamicSubRoleAttribute() {
35 roleNames.add("DynamicSub");
36 }
37
38 public List getRoleNames() {
39 return roleNames;
40 }
41
42 public List getQualifiedRoleNames(String roleName, DocumentContent documentContent) {
43 List<String> qualifiedRoleNames = new ArrayList<String>();
44 qualifiedRoleNames.add(roleName);
45 return qualifiedRoleNames;
46 }
47
48 public ResolvedQualifiedRole resolveQualifiedRole(RouteContext routeContext, String roleName, String qualifiedRole) {
49 NodeState nodeState = routeContext.getNodeInstance().getNodeState("role");
50 if (nodeState == null) {
51 return new ResolvedQualifiedRole();
52 }
53 String networkId = nodeState.getValue();
54 String label = "role " + networkId;
55 List<Id> recipients = new ArrayList<Id>();
56 recipients.add(new PrincipalName(networkId));
57 return new ResolvedQualifiedRole(label, recipients);
58 }
59 }