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.hibernate.annotations.GenericGenerator;
19 import org.hibernate.annotations.Parameter;
20 import org.kuali.rice.core.api.delegation.DelegationType;
21 import org.kuali.rice.kew.api.rule.RuleDelegationContract;
22 import org.kuali.rice.kew.doctype.bo.DocumentType;
23 import org.kuali.rice.kew.service.KEWServiceLocator;
24 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
25
26 import javax.persistence.CascadeType;
27 import javax.persistence.Column;
28 import javax.persistence.Entity;
29 import javax.persistence.FetchType;
30 import javax.persistence.GeneratedValue;
31 import javax.persistence.Id;
32 import javax.persistence.JoinColumn;
33 import javax.persistence.OneToOne;
34 import javax.persistence.Table;
35 import javax.persistence.Transient;
36
37
38
39
40
41
42
43
44
45 @Entity
46 @Table(name="KREW_DLGN_RSP_T")
47
48 public class RuleDelegationBo extends PersistableBusinessObjectBase implements RuleDelegationContract {
49
50 private static final long serialVersionUID = 7989203310473741293L;
51 @Id
52 @GeneratedValue(generator="KREW_RTE_TMPL_S")
53 @GenericGenerator(name="KREW_RTE_TMPL_S",strategy="org.hibernate.id.enhanced.SequenceStyleGenerator",parameters={
54 @Parameter(name="sequence_name",value="KREW_RTE_TMPL_S"),
55 @Parameter(name="value_column",value="id")
56 })
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")
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
208
209
210
211
212
213
214
215
216
217
218
219 @Override
220 public void refresh() {
221 RuleBaseValues oldRuleBaseValues = this.getDelegationRule();
222 super.refresh();
223 if (this.getDelegationRule() == null) {
224 this.refreshReferenceObject("delegationRuleBaseValues");
225 if (this.getDelegationRule() == null) {
226 this.setDelegationRule(oldRuleBaseValues);
227 }
228 }
229 }
230
231 public static org.kuali.rice.kew.api.rule.RuleDelegation to(RuleDelegationBo bo) {
232 if (bo == null) {
233 return null;
234 }
235 return org.kuali.rice.kew.api.rule.RuleDelegation.Builder.create(bo).build();
236
237
238
239
240
241 }
242 }
243