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.engine.RouteContext;
23 import org.kuali.rice.kew.routeheader.DocumentContent;
24
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 public abstract class GenericRoleAttribute extends GenericWorkflowAttribute implements RoleAttribute {
58 public GenericRoleAttribute() {
59 super(null);
60 }
61
62 public GenericRoleAttribute(String uniqueName) {
63 super(uniqueName);
64 }
65
66 public boolean isMatch(DocumentContent docContent, List<RuleExtensionBo> ruleExtensions) {
67
68
69
70
71 return true;
72 }
73
74 public List<String> getQualifiedRoleNames(String roleName, DocumentContent documentContent) {
75 List<QualifiedRoleName> qualifiedRoleNames = generateQualifiedRoleNames(roleName, documentContent);
76 if (qualifiedRoleNames == null) {
77 return null;
78 }
79 List<String> q = new ArrayList<String>(qualifiedRoleNames.size());
80 for (QualifiedRoleName qrn: qualifiedRoleNames) {
81 q.add(qrn.encode());
82 }
83 return q;
84 }
85
86
87
88
89
90 protected List<QualifiedRoleName> generateQualifiedRoleNames(String roleName, DocumentContent documentContent) {
91 List<String> qualifiers = getRoleNameQualifiers(roleName, documentContent);
92 if (qualifiers == null) {
93 qualifiers = new ArrayList<String>(0);
94 }
95 List<QualifiedRoleName> qualifiedRoleNames = new ArrayList<QualifiedRoleName>(qualifiers.size());
96 for (String qualifier: qualifiers) {
97 qualifiedRoleNames.add(new QualifiedRoleName(roleName, qualifier));
98 }
99 return qualifiedRoleNames;
100 }
101
102
103
104
105 protected List<String> getRoleNameQualifiers(String roleName, DocumentContent documentContent) {
106 return null;
107 }
108
109 public ResolvedQualifiedRole resolveQualifiedRole(RouteContext routeContext, String roleName, String qualifiedRoleName) {
110 QualifiedRoleName qrn = QualifiedRoleName.parse(qualifiedRoleName);
111 return resolveQualifiedRole(routeContext, qrn);
112 }
113
114
115
116
117
118 protected ResolvedQualifiedRole resolveQualifiedRole(RouteContext routeContext, QualifiedRoleName qualifiedRoleName) {
119 List<Id> recipients = resolveRecipients(routeContext, qualifiedRoleName);
120 ResolvedQualifiedRole rqr = new ResolvedQualifiedRole(getLabelForQualifiedRoleName(qualifiedRoleName),
121 recipients
122 );
123 return rqr;
124 }
125
126 protected String getLabelForQualifiedRoleName(QualifiedRoleName qualifiedRoleName) {
127
128 return qualifiedRoleName.getBaseRoleName();
129 }
130
131
132
133
134 protected List<Id> resolveRecipients(RouteContext routeContext, QualifiedRoleName qualifiedRoleName) {
135 return null;
136 }
137 }