1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
package org.kuali.rice.kew.rule; |
18 | |
|
19 | |
import javax.persistence.CascadeType; |
20 | |
import javax.persistence.Column; |
21 | |
import javax.persistence.Entity; |
22 | |
import javax.persistence.FetchType; |
23 | |
import javax.persistence.GeneratedValue; |
24 | |
import javax.persistence.Id; |
25 | |
import javax.persistence.JoinColumn; |
26 | |
import javax.persistence.OneToOne; |
27 | |
import javax.persistence.Table; |
28 | |
|
29 | |
import org.hibernate.annotations.GenericGenerator; |
30 | |
import org.hibernate.annotations.Parameter; |
31 | |
import org.kuali.rice.kew.api.action.DelegationType; |
32 | |
import org.kuali.rice.kew.doctype.bo.DocumentType; |
33 | |
import org.kuali.rice.kew.service.KEWServiceLocator; |
34 | |
import org.kuali.rice.kew.util.KEWConstants; |
35 | |
import org.kuali.rice.krad.bo.PersistableBusinessObjectBase; |
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | |
@Entity |
46 | |
@Table(name="KREW_DLGN_RSP_T") |
47 | |
|
48 | |
public class RuleDelegation extends PersistableBusinessObjectBase { |
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 | 0 | @Column(name="DLGN_TYP") |
64 | |
private String delegationType = DelegationType.PRIMARY.getCode(); |
65 | |
|
66 | |
@OneToOne(fetch=FetchType.EAGER, cascade={CascadeType.PERSIST}) |
67 | |
@JoinColumn(name="DLGN_RULE_BASE_VAL_ID") |
68 | |
private RuleBaseValues delegationRuleBaseValues; |
69 | |
|
70 | |
|
71 | |
|
72 | |
|
73 | 0 | public RuleDelegation() { |
74 | 0 | } |
75 | |
|
76 | |
public Object copy(boolean preserveKeys) { |
77 | 0 | RuleDelegation clone = new RuleDelegation(); |
78 | 0 | if (ruleDelegationId != null && preserveKeys) { |
79 | 0 | clone.setRuleDelegationId(ruleDelegationId); |
80 | |
} |
81 | 0 | clone.setDelegationRuleBaseValues(delegationRuleBaseValues); |
82 | 0 | clone.setDelegateRuleId(delegationRuleBaseValues.getRuleBaseValuesId()); |
83 | 0 | if (delegationType != null) { |
84 | 0 | clone.setDelegationType(new String(delegationType)); |
85 | |
} |
86 | 0 | return clone; |
87 | |
} |
88 | |
|
89 | |
public String getDelegateRuleId() { |
90 | 0 | return delegateRuleId; |
91 | |
} |
92 | |
public void setDelegateRuleId(String delegateRuleId) { |
93 | 0 | this.delegateRuleId = delegateRuleId; |
94 | 0 | } |
95 | |
public RuleBaseValues getDelegationRuleBaseValues() { |
96 | 0 | return delegationRuleBaseValues; |
97 | |
} |
98 | |
public void setDelegationRuleBaseValues(RuleBaseValues delegationRuleBaseValues) { |
99 | 0 | this.delegationRuleBaseValues = delegationRuleBaseValues; |
100 | 0 | } |
101 | |
public String getDelegationType() { |
102 | 0 | return delegationType; |
103 | |
} |
104 | |
public void setDelegationType(String delegationType) { |
105 | 0 | this.delegationType = delegationType; |
106 | 0 | } |
107 | |
public String getRuleDelegationId() { |
108 | 0 | return ruleDelegationId; |
109 | |
} |
110 | |
public void setRuleDelegationId(String ruleDelegationId) { |
111 | 0 | this.ruleDelegationId = ruleDelegationId; |
112 | 0 | } |
113 | |
|
114 | |
|
115 | |
|
116 | |
|
117 | |
|
118 | |
public RuleResponsibility getRuleResponsibility() { |
119 | 0 | if ( getResponsibilityId() == null ) { |
120 | 0 | return null; |
121 | |
} |
122 | 0 | return KEWServiceLocator.getRuleService().findRuleResponsibility(getResponsibilityId()); |
123 | |
} |
124 | |
|
125 | |
public DocumentType getDocumentType() { |
126 | 0 | return this.getDelegationRuleBaseValues().getDocumentType(); |
127 | |
} |
128 | |
|
129 | |
public String getResponsibilityId() { |
130 | 0 | return responsibilityId; |
131 | |
} |
132 | |
public void setResponsibilityId(String ruleResponsibilityId) { |
133 | 0 | this.responsibilityId = ruleResponsibilityId; |
134 | 0 | } |
135 | |
|
136 | |
|
137 | |
|
138 | |
|
139 | |
|
140 | |
|
141 | |
|
142 | |
|
143 | |
|
144 | |
|
145 | |
|
146 | |
@Override |
147 | |
public void refresh() { |
148 | 0 | RuleBaseValues oldRuleBaseValues = this.getDelegationRuleBaseValues(); |
149 | 0 | super.refresh(); |
150 | 0 | if (this.getDelegationRuleBaseValues() == null) { |
151 | 0 | this.refreshReferenceObject("delegationRuleBaseValues"); |
152 | 0 | if (this.getDelegationRuleBaseValues() == null) { |
153 | 0 | this.setDelegationRuleBaseValues(oldRuleBaseValues); |
154 | |
} |
155 | |
} |
156 | 0 | } |
157 | |
} |
158 | |
|