1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
package org.kuali.rice.kew.rule.web; |
18 | |
|
19 | |
import java.util.ArrayList; |
20 | |
import java.util.List; |
21 | |
|
22 | |
import javax.servlet.http.HttpServletRequest; |
23 | |
|
24 | |
import org.kuali.rice.core.api.exception.RiceRuntimeException; |
25 | |
import org.kuali.rice.kew.rule.RuleBaseValues; |
26 | |
import org.kuali.rice.kew.rule.RuleResponsibility; |
27 | |
import org.kuali.rice.kew.service.KEWServiceLocator; |
28 | |
import org.kuali.rice.kew.util.KEWConstants; |
29 | |
import org.kuali.rice.kim.api.entity.principal.Principal; |
30 | |
import org.kuali.rice.kim.api.services.KimApiServiceLocator; |
31 | |
import org.kuali.rice.kim.api.group.Group; |
32 | |
|
33 | |
import org.kuali.rice.kns.web.struts.form.KualiForm; |
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | 0 | public class DelegateRuleForm extends KualiForm { |
42 | |
|
43 | |
private static final long serialVersionUID = 5412969516727713859L; |
44 | |
|
45 | |
private Long parentRuleId; |
46 | |
private Long parentResponsibilityId; |
47 | |
|
48 | |
private RuleBaseValues parentRule; |
49 | |
private RuleResponsibility parentResponsibility; |
50 | |
|
51 | 0 | private List<String> reviewers = new ArrayList<String>(); |
52 | 0 | private List<String> responsibilityTypes = new ArrayList<String>(); |
53 | 0 | private List<String> actionRequestCodes = new ArrayList<String>(); |
54 | |
|
55 | |
public Long getParentRuleId() { |
56 | 0 | return this.parentRuleId; |
57 | |
} |
58 | |
|
59 | |
public void setParentRuleId(Long parentRuleId) { |
60 | 0 | this.parentRuleId = parentRuleId; |
61 | 0 | } |
62 | |
|
63 | |
public Long getParentResponsibilityId() { |
64 | 0 | return this.parentResponsibilityId; |
65 | |
} |
66 | |
|
67 | |
public void setParentResponsibilityId(Long parentResponsibilityId) { |
68 | 0 | this.parentResponsibilityId = parentResponsibilityId; |
69 | 0 | } |
70 | |
|
71 | |
public RuleBaseValues getParentRule() { |
72 | 0 | return this.parentRule; |
73 | |
} |
74 | |
|
75 | |
public void setParentRule(RuleBaseValues parentRule) { |
76 | 0 | if (this.parentRule != null |
77 | |
&& parentRule != null |
78 | |
&& this.parentResponsibility != null) { |
79 | 0 | if (this.parentRule.getRuleBaseValuesId().longValue() != parentRule.getRuleBaseValuesId().longValue()) { |
80 | 0 | this.parentResponsibility = null; |
81 | 0 | this.parentResponsibilityId = null; |
82 | |
} |
83 | |
} |
84 | 0 | this.parentRule = parentRule; |
85 | 0 | } |
86 | |
|
87 | |
public RuleResponsibility getParentResponsibility() { |
88 | 0 | return this.parentResponsibility; |
89 | |
} |
90 | |
|
91 | |
public void setParentResponsibility(RuleResponsibility parentResponsibility) { |
92 | 0 | this.parentResponsibility = parentResponsibility; |
93 | 0 | } |
94 | |
|
95 | |
public List<String> getReviewers() { |
96 | 0 | return this.reviewers; |
97 | |
} |
98 | |
|
99 | |
public void setReviewers(List<String> reviewers) { |
100 | 0 | this.reviewers = reviewers; |
101 | 0 | } |
102 | |
|
103 | |
public List<String> getResponsibilityTypes() { |
104 | 0 | return this.responsibilityTypes; |
105 | |
} |
106 | |
|
107 | |
public void setResponsibilityTypes(List<String> responsibilityTypes) { |
108 | 0 | this.responsibilityTypes = responsibilityTypes; |
109 | 0 | } |
110 | |
|
111 | |
public List<String> getActionRequestCodes() { |
112 | 0 | return this.actionRequestCodes; |
113 | |
} |
114 | |
|
115 | |
public void setActionRequestCodes(List<String> actionRequestCodes) { |
116 | 0 | this.actionRequestCodes = actionRequestCodes; |
117 | 0 | } |
118 | |
|
119 | |
public String getRuleDescription() { |
120 | 0 | if (getParentRule() == null) { |
121 | 0 | return ""; |
122 | |
} |
123 | 0 | return getParentRule().getDescription(); |
124 | |
} |
125 | |
|
126 | |
@Override |
127 | |
public void populate(HttpServletRequest request) { |
128 | |
|
129 | 0 | super.populate(request); |
130 | |
|
131 | 0 | reviewers.clear(); |
132 | 0 | responsibilityTypes.clear(); |
133 | 0 | actionRequestCodes.clear(); |
134 | |
|
135 | 0 | if (getParentRuleId() != null) { |
136 | 0 | setParentRule(KEWServiceLocator.getRuleService().findRuleBaseValuesById(getParentRuleId())); |
137 | |
} |
138 | 0 | if (getParentResponsibilityId() != null && getParentRule() != null) { |
139 | 0 | for (RuleResponsibility responsibility : getParentRule().getResponsibilities()) { |
140 | 0 | if (responsibility.getResponsibilityId().equals(getParentResponsibilityId())) { |
141 | 0 | setParentResponsibility(responsibility); |
142 | 0 | break; |
143 | |
} |
144 | |
} |
145 | |
} |
146 | |
|
147 | 0 | if (getParentRule() != null) { |
148 | 0 | for (RuleResponsibility responsibility : getParentRule().getResponsibilities()) { |
149 | 0 | if (KEWConstants.RULE_RESPONSIBILITY_WORKFLOW_ID.equals(responsibility.getRuleResponsibilityType())) { |
150 | 0 | Principal principal = KEWServiceLocator.getIdentityHelperService().getPrincipal(responsibility.getRuleResponsibilityName()); |
151 | 0 | if (principal != null) { |
152 | 0 | reviewers.add(principal.getPrincipalName()); |
153 | |
} |
154 | 0 | responsibilityTypes.add(KEWConstants.RULE_RESPONSIBILITY_WORKFLOW_ID_LABEL); |
155 | 0 | } else if (KEWConstants.RULE_RESPONSIBILITY_GROUP_ID.equals(responsibility.getRuleResponsibilityType())) { |
156 | 0 | Group group = KimApiServiceLocator.getIdentityManagementService().getGroup(responsibility.getRuleResponsibilityName()); |
157 | 0 | if (group != null) { |
158 | 0 | reviewers.add(group.getNamespaceCode() + " " + group.getName()); |
159 | |
} |
160 | 0 | responsibilityTypes.add(KEWConstants.RULE_RESPONSIBILITY_GROUP_ID_LABEL); |
161 | 0 | } else if (KEWConstants.RULE_RESPONSIBILITY_ROLE_ID.equals(responsibility.getRuleResponsibilityType())) { |
162 | 0 | reviewers.add(responsibility.getResolvedRoleName()); |
163 | 0 | responsibilityTypes.add(KEWConstants.RULE_RESPONSIBILITY_ROLE_ID_LABEL); |
164 | |
} else { |
165 | 0 | throw new RiceRuntimeException("Encountered a responsibility with an invalid type, type value was " + responsibility.getRuleResponsibilityType()); |
166 | |
} |
167 | 0 | actionRequestCodes.add(KEWConstants.ACTION_REQUEST_CODES.get(responsibility.getActionRequestedCd())); |
168 | |
} |
169 | |
} |
170 | |
|
171 | 0 | } |
172 | |
|
173 | |
|
174 | |
|
175 | |
} |