1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kew.rule;
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.rule.RuleExtension;
23 import org.kuali.rice.kew.engine.RouteContext;
24 import org.kuali.rice.kew.routeheader.DocumentContent;
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58 public abstract class GenericRoleAttribute extends GenericWorkflowAttribute implements RoleAttribute {
59 public GenericRoleAttribute() {
60 super(null);
61 }
62
63 public GenericRoleAttribute(String uniqueName) {
64 super(uniqueName);
65 }
66
67 public boolean isMatch(DocumentContent docContent, List<RuleExtension> ruleExtensions) {
68
69
70
71
72 return true;
73 }
74
75 public List<String> getQualifiedRoleNames(String roleName, DocumentContent documentContent) {
76 List<QualifiedRoleName> qualifiedRoleNames = generateQualifiedRoleNames(roleName, documentContent);
77 if (qualifiedRoleNames == null) {
78 return null;
79 }
80 List<String> q = new ArrayList<String>(qualifiedRoleNames.size());
81 for (QualifiedRoleName qrn: qualifiedRoleNames) {
82 q.add(qrn.encode());
83 }
84 return q;
85 }
86
87
88
89
90
91 protected List<QualifiedRoleName> generateQualifiedRoleNames(String roleName, DocumentContent documentContent) {
92 List<String> qualifiers = getRoleNameQualifiers(roleName, documentContent);
93 if (qualifiers == null) {
94 qualifiers = new ArrayList<String>(0);
95 }
96 List<QualifiedRoleName> qualifiedRoleNames = new ArrayList<QualifiedRoleName>(qualifiers.size());
97 for (String qualifier: qualifiers) {
98 qualifiedRoleNames.add(new QualifiedRoleName(roleName, qualifier));
99 }
100 return qualifiedRoleNames;
101 }
102
103
104
105
106 protected List<String> getRoleNameQualifiers(String roleName, DocumentContent documentContent) {
107 return null;
108 }
109
110 public ResolvedQualifiedRole resolveQualifiedRole(RouteContext routeContext, String roleName, String qualifiedRoleName) {
111 QualifiedRoleName qrn = QualifiedRoleName.parse(qualifiedRoleName);
112 return resolveQualifiedRole(routeContext, qrn);
113 }
114
115
116
117
118
119 protected ResolvedQualifiedRole resolveQualifiedRole(RouteContext routeContext, QualifiedRoleName qualifiedRoleName) {
120 List<Id> recipients = resolveRecipients(routeContext, qualifiedRoleName);
121 ResolvedQualifiedRole rqr = new ResolvedQualifiedRole(getLabelForQualifiedRoleName(qualifiedRoleName),
122 recipients
123 );
124 return rqr;
125 }
126
127 protected String getLabelForQualifiedRoleName(QualifiedRoleName qualifiedRoleName) {
128
129 return qualifiedRoleName.getBaseRoleName();
130 }
131
132
133
134
135 protected List<Id> resolveRecipients(RouteContext routeContext, QualifiedRoleName qualifiedRoleName) {
136 return null;
137 }
138 }