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 javax.persistence.CascadeType; |
19 | |
import javax.persistence.Column; |
20 | |
import javax.persistence.Entity; |
21 | |
import javax.persistence.FetchType; |
22 | |
import javax.persistence.GeneratedValue; |
23 | |
import javax.persistence.Id; |
24 | |
import javax.persistence.JoinColumn; |
25 | |
import javax.persistence.OneToOne; |
26 | |
import javax.persistence.Table; |
27 | |
|
28 | |
import org.hibernate.annotations.GenericGenerator; |
29 | |
import org.hibernate.annotations.Parameter; |
30 | |
import org.kuali.rice.core.api.delegation.DelegationType; |
31 | |
import org.kuali.rice.kew.api.rule.RuleDelegationContract; |
32 | |
import org.kuali.rice.kew.doctype.bo.DocumentType; |
33 | |
import org.kuali.rice.kew.service.KEWServiceLocator; |
34 | |
import org.kuali.rice.krad.bo.PersistableBusinessObjectBase; |
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | 0 | @Entity |
45 | |
@Table(name="KREW_DLGN_RSP_T") |
46 | |
|
47 | |
public class RuleDelegationBo extends PersistableBusinessObjectBase implements RuleDelegationContract { |
48 | |
|
49 | |
private static final long serialVersionUID = 7989203310473741293L; |
50 | |
@Id |
51 | |
@GeneratedValue(generator="KREW_RTE_TMPL_S") |
52 | |
@GenericGenerator(name="KREW_RTE_TMPL_S",strategy="org.hibernate.id.enhanced.SequenceStyleGenerator",parameters={ |
53 | |
@Parameter(name="sequence_name",value="KREW_RTE_TMPL_S"), |
54 | |
@Parameter(name="value_column",value="id") |
55 | |
}) |
56 | |
@Column(name="DLGN_RULE_ID") |
57 | |
private String ruleDelegationId; |
58 | |
@Column(name="RSP_ID") |
59 | |
private String responsibilityId; |
60 | |
@Column(name="DLGN_RULE_BASE_VAL_ID", insertable=false, updatable=false) |
61 | |
private String delegateRuleId; |
62 | 0 | @Column(name="DLGN_TYP") |
63 | |
private String delegationTypeCode = DelegationType.PRIMARY.getCode(); |
64 | |
|
65 | |
@OneToOne(fetch=FetchType.EAGER, cascade={CascadeType.PERSIST}) |
66 | |
@JoinColumn(name="DLGN_RULE_BASE_VAL_ID") |
67 | |
private RuleBaseValues delegationRule; |
68 | |
|
69 | |
|
70 | |
|
71 | |
|
72 | 0 | public RuleDelegationBo() { |
73 | 0 | } |
74 | |
|
75 | |
public Object copy(boolean preserveKeys) { |
76 | 0 | RuleDelegationBo clone = new RuleDelegationBo(); |
77 | 0 | if (ruleDelegationId != null && preserveKeys) { |
78 | 0 | clone.setRuleDelegationId(ruleDelegationId); |
79 | |
} |
80 | 0 | clone.setDelegationRule(delegationRule); |
81 | 0 | clone.setDelegateRuleId(delegationRule.getId()); |
82 | 0 | if (delegationTypeCode != null) { |
83 | 0 | clone.setDelegationType(DelegationType.fromCode(delegationTypeCode)); |
84 | |
} |
85 | 0 | return clone; |
86 | |
} |
87 | |
|
88 | |
public String getDelegateRuleId() { |
89 | 0 | return delegateRuleId; |
90 | |
} |
91 | |
public void setDelegateRuleId(String delegateRuleId) { |
92 | 0 | this.delegateRuleId = delegateRuleId; |
93 | 0 | } |
94 | |
@Override |
95 | |
public RuleBaseValues getDelegationRule() { |
96 | 0 | return delegationRule; |
97 | |
} |
98 | |
|
99 | |
public RuleBaseValues getDelegationRuleBaseValues() { |
100 | 0 | return delegationRule; |
101 | |
} |
102 | |
|
103 | |
public void setDelegationRule(RuleBaseValues delegationRule) { |
104 | 0 | this.delegationRule = delegationRule; |
105 | 0 | } |
106 | |
|
107 | |
|
108 | |
|
109 | |
|
110 | |
|
111 | |
public void setDelegationTypeCode(String delegationTypeCode) { |
112 | 0 | DelegationType.fromCode(delegationTypeCode); |
113 | 0 | this.delegationTypeCode = delegationTypeCode; |
114 | 0 | } |
115 | |
|
116 | |
|
117 | |
|
118 | |
|
119 | |
|
120 | |
public String getDelegationTypeCode() { |
121 | 0 | return delegationTypeCode; |
122 | |
} |
123 | |
|
124 | |
@Override |
125 | |
public DelegationType getDelegationType() { |
126 | 0 | return DelegationType.fromCode(delegationTypeCode); |
127 | |
} |
128 | |
public void setDelegationType(DelegationType delegationType) { |
129 | 0 | this.delegationTypeCode = delegationType.getCode(); |
130 | 0 | } |
131 | |
public String getRuleDelegationId() { |
132 | 0 | return ruleDelegationId; |
133 | |
} |
134 | |
public void setRuleDelegationId(String ruleDelegationId) { |
135 | 0 | this.ruleDelegationId = ruleDelegationId; |
136 | 0 | } |
137 | |
|
138 | |
|
139 | |
|
140 | |
|
141 | |
|
142 | |
public RuleResponsibilityBo getRuleResponsibility() { |
143 | 0 | if ( getResponsibilityId() == null ) { |
144 | 0 | return null; |
145 | |
} |
146 | 0 | return KEWServiceLocator.getRuleService().findRuleResponsibility(getResponsibilityId()); |
147 | |
} |
148 | |
|
149 | |
public DocumentType getDocumentType() { |
150 | 0 | return this.getDelegationRule().getDocumentType(); |
151 | |
} |
152 | |
|
153 | |
public String getResponsibilityId() { |
154 | 0 | return responsibilityId; |
155 | |
} |
156 | |
public void setResponsibilityId(String ruleResponsibilityId) { |
157 | 0 | this.responsibilityId = ruleResponsibilityId; |
158 | 0 | } |
159 | |
|
160 | |
|
161 | |
|
162 | |
|
163 | |
|
164 | |
|
165 | |
|
166 | |
|
167 | |
|
168 | |
|
169 | |
|
170 | |
@Override |
171 | |
public void refresh() { |
172 | 0 | RuleBaseValues oldRuleBaseValues = this.getDelegationRule(); |
173 | 0 | super.refresh(); |
174 | 0 | if (this.getDelegationRule() == null) { |
175 | 0 | this.refreshReferenceObject("delegationRuleBaseValues"); |
176 | 0 | if (this.getDelegationRule() == null) { |
177 | 0 | this.setDelegationRule(oldRuleBaseValues); |
178 | |
} |
179 | |
} |
180 | 0 | } |
181 | |
|
182 | |
public static org.kuali.rice.kew.api.rule.RuleDelegation to(RuleDelegationBo bo) { |
183 | 0 | if (bo == null) { |
184 | 0 | return null; |
185 | |
} |
186 | 0 | return org.kuali.rice.kew.api.rule.RuleDelegation.Builder.create(bo).build(); |
187 | |
|
188 | |
|
189 | |
|
190 | |
|
191 | |
|
192 | |
} |
193 | |
} |
194 | |
|