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 org.apache.commons.lang.StringUtils;
19 import org.kuali.rice.core.api.delegation.DelegationType;
20 import org.kuali.rice.kew.api.rule.RuleDelegationContract;
21 import org.kuali.rice.kew.doctype.bo.DocumentType;
22 import org.kuali.rice.kew.service.KEWServiceLocator;
23 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
24 import org.kuali.rice.kim.impl.group.GroupBo;
25 import org.kuali.rice.kim.impl.identity.PersonImpl;
26 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
27 import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator;
28
29 import javax.persistence.CascadeType;
30 import javax.persistence.Column;
31 import javax.persistence.Entity;
32 import javax.persistence.FetchType;
33 import javax.persistence.GeneratedValue;
34 import javax.persistence.Id;
35 import javax.persistence.JoinColumn;
36 import javax.persistence.OneToOne;
37 import javax.persistence.Table;
38 import javax.persistence.Transient;
39
40
41
42
43
44
45
46
47
48 @Entity
49 @Table(name="KREW_DLGN_RSP_T")
50
51 public class RuleDelegationBo extends PersistableBusinessObjectBase implements RuleDelegationContract {
52
53 private static final long serialVersionUID = 7989203310473741293L;
54 @Id
55 @PortableSequenceGenerator(name="KREW_RTE_TMPL_S")
56 @GeneratedValue(generator="KREW_RTE_TMPL_S")
57 @Column(name="DLGN_RULE_ID")
58 private String ruleDelegationId;
59 @Column(name="RSP_ID")
60 private String responsibilityId;
61 @Column(name="DLGN_RULE_BASE_VAL_ID", insertable = false, updatable = false)
62 private String delegateRuleId;
63 @Column(name="DLGN_TYP")
64 private String delegationTypeCode = DelegationType.PRIMARY.getCode();
65
66 @OneToOne(fetch=FetchType.EAGER, cascade={CascadeType.PERSIST})
67 @JoinColumn(name="DLGN_RULE_BASE_VAL_ID",nullable = false)
68 private RuleBaseValues delegationRule;
69
70
71
72
73 @Transient
74 private String groupReviewerName;
75 @Transient
76 private String groupReviewerNamespace;
77 @Transient
78 private String personReviewer;
79 @Transient
80 private String personReviewerType;
81
82 public RuleDelegationBo() {
83 }
84
85 public Object copy(boolean preserveKeys) {
86 RuleDelegationBo clone = new RuleDelegationBo();
87 if (ruleDelegationId != null && preserveKeys) {
88 clone.setRuleDelegationId(ruleDelegationId);
89 }
90 clone.setDelegationRule(delegationRule);
91 clone.setDelegateRuleId(delegationRule.getId());
92 if (delegationTypeCode != null) {
93 clone.setDelegationType(DelegationType.fromCode(delegationTypeCode));
94 }
95 return clone;
96 }
97
98 public String getDelegateRuleId() {
99 return delegateRuleId;
100 }
101 public void setDelegateRuleId(String delegateRuleId) {
102 this.delegateRuleId = delegateRuleId;
103 }
104
105 @Override
106 public RuleBaseValues getDelegationRule() {
107 return delegationRule;
108 }
109
110 public RuleBaseValues getDelegationRuleBaseValues() {
111 return delegationRule;
112 }
113
114 public void setDelegationRuleBaseValues(RuleBaseValues delegationRuleBaseValues) {
115 this.delegationRule = delegationRuleBaseValues;
116 }
117
118 public void setDelegationRule(RuleBaseValues delegationRule) {
119 this.delegationRule = delegationRule;
120 }
121
122
123
124
125
126 public void setDelegationTypeCode(String delegationTypeCode) {
127 DelegationType.fromCode(delegationTypeCode);
128 this.delegationTypeCode = delegationTypeCode;
129 }
130
131
132
133
134
135 public String getDelegationTypeCode() {
136 return delegationTypeCode;
137 }
138
139 @Override
140 public DelegationType getDelegationType() {
141 return DelegationType.fromCode(delegationTypeCode);
142 }
143 public void setDelegationType(DelegationType delegationType) {
144 this.delegationTypeCode = delegationType.getCode();
145 }
146 public String getRuleDelegationId() {
147 return ruleDelegationId;
148 }
149 public void setRuleDelegationId(String ruleDelegationId) {
150 this.ruleDelegationId = ruleDelegationId;
151 }
152
153
154
155
156
157 public RuleResponsibilityBo getRuleResponsibility() {
158 if ( getResponsibilityId() == null ) {
159 return null;
160 }
161 return KEWServiceLocator.getRuleService().findRuleResponsibility(getResponsibilityId());
162 }
163
164 public DocumentType getDocumentType() {
165 return this.getDelegationRule().getDocumentType();
166 }
167
168 public String getResponsibilityId() {
169 return responsibilityId;
170 }
171 public void setResponsibilityId(String ruleResponsibilityId) {
172 this.responsibilityId = ruleResponsibilityId;
173 }
174
175 public String getGroupReviewerName() {
176 return this.groupReviewerName;
177 }
178
179 public String getGroupReviewerNamespace() {
180 return this.groupReviewerNamespace;
181 }
182
183 public String getPersonReviewer() {
184 return this.personReviewer;
185 }
186
187 public void setGroupReviewerName(String groupReviewerName) {
188 this.groupReviewerName = groupReviewerName;
189 }
190
191 public void setGroupReviewerNamespace(String groupReviewerNamespace) {
192 this.groupReviewerNamespace = groupReviewerNamespace;
193 }
194
195 public void setPersonReviewer(String personReviewer) {
196 this.personReviewer = personReviewer;
197 }
198
199 public String getPersonReviewerType() {
200 return this.personReviewerType;
201 }
202
203 public void setPersonReviewerType(String personReviewerType) {
204 this.personReviewerType = personReviewerType;
205 }
206
207 public GroupBo getGroupBo() {
208 GroupBo groupBo = null;
209 if (StringUtils.isNotBlank(getGroupReviewerName()) && StringUtils.isNotBlank(getGroupReviewerNamespace()) ) {
210 if ( groupBo == null ) {
211 groupBo = GroupBo.from(KimApiServiceLocator.getGroupService().getGroupByNamespaceCodeAndName(
212 getGroupReviewerNamespace(), getGroupReviewerName()));
213 }
214 }
215 return groupBo;
216 }
217
218 public PersonImpl getPersonImpl() {
219 return new PersonImpl();
220 }
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244 public static org.kuali.rice.kew.api.rule.RuleDelegation to(RuleDelegationBo bo) {
245 if (bo == null) {
246 return null;
247 }
248 return org.kuali.rice.kew.api.rule.RuleDelegation.Builder.create(bo).build();
249
250
251
252
253
254 }
255 }
256