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 org.hibernate.annotations.GenericGenerator; |
20 | |
import org.hibernate.annotations.Parameter; |
21 | |
import org.kuali.rice.kew.doctype.bo.DocumentType; |
22 | |
import org.kuali.rice.kew.service.KEWServiceLocator; |
23 | |
import org.kuali.rice.kew.util.KEWConstants; |
24 | |
import org.kuali.rice.kns.bo.PersistableBusinessObjectBase; |
25 | |
|
26 | |
import javax.persistence.*; |
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
@Entity |
37 | |
@Table(name="KREW_DLGN_RSP_T") |
38 | |
|
39 | |
public class RuleDelegation extends PersistableBusinessObjectBase { |
40 | |
|
41 | |
private static final long serialVersionUID = 7989203310473741293L; |
42 | |
@Id |
43 | |
@GeneratedValue(generator="KREW_RTE_TMPL_S") |
44 | |
@GenericGenerator(name="KREW_RTE_TMPL_S",strategy="org.hibernate.id.enhanced.SequenceStyleGenerator",parameters={ |
45 | |
@Parameter(name="sequence_name",value="KREW_RTE_TMPL_S"), |
46 | |
@Parameter(name="value_column",value="id") |
47 | |
}) |
48 | |
@Column(name="DLGN_RULE_ID") |
49 | |
private Long ruleDelegationId; |
50 | |
@Column(name="RSP_ID") |
51 | |
private Long responsibilityId; |
52 | |
@Column(name="DLGN_RULE_BASE_VAL_ID", insertable=false, updatable=false) |
53 | |
private Long delegateRuleId; |
54 | 0 | @Column(name="DLGN_TYP") |
55 | |
private String delegationType = KEWConstants.DELEGATION_PRIMARY; |
56 | |
|
57 | |
@OneToOne(fetch=FetchType.EAGER, cascade={CascadeType.PERSIST}) |
58 | |
@JoinColumn(name="DLGN_RULE_BASE_VAL_ID") |
59 | |
private RuleBaseValues delegationRuleBaseValues; |
60 | |
|
61 | |
|
62 | |
|
63 | |
|
64 | 0 | public RuleDelegation() { |
65 | 0 | } |
66 | |
|
67 | |
public Object copy(boolean preserveKeys) { |
68 | 0 | RuleDelegation clone = new RuleDelegation(); |
69 | 0 | if (ruleDelegationId != null && preserveKeys) { |
70 | 0 | clone.setRuleDelegationId(new Long(ruleDelegationId.longValue())); |
71 | |
} |
72 | 0 | clone.setDelegationRuleBaseValues(delegationRuleBaseValues); |
73 | 0 | clone.setDelegateRuleId(delegationRuleBaseValues.getRuleBaseValuesId()); |
74 | 0 | if (delegationType != null) { |
75 | 0 | clone.setDelegationType(new String(delegationType)); |
76 | |
} |
77 | 0 | return clone; |
78 | |
} |
79 | |
|
80 | |
public Long getDelegateRuleId() { |
81 | 0 | return delegateRuleId; |
82 | |
} |
83 | |
public void setDelegateRuleId(Long delegateRuleId) { |
84 | 0 | this.delegateRuleId = delegateRuleId; |
85 | 0 | } |
86 | |
public RuleBaseValues getDelegationRuleBaseValues() { |
87 | 0 | return delegationRuleBaseValues; |
88 | |
} |
89 | |
public void setDelegationRuleBaseValues(RuleBaseValues delegationRuleBaseValues) { |
90 | 0 | this.delegationRuleBaseValues = delegationRuleBaseValues; |
91 | 0 | } |
92 | |
public String getDelegationType() { |
93 | 0 | return delegationType; |
94 | |
} |
95 | |
public void setDelegationType(String delegationType) { |
96 | 0 | this.delegationType = delegationType; |
97 | 0 | } |
98 | |
public Long getRuleDelegationId() { |
99 | 0 | return ruleDelegationId; |
100 | |
} |
101 | |
public void setRuleDelegationId(Long ruleDelegationId) { |
102 | 0 | this.ruleDelegationId = ruleDelegationId; |
103 | 0 | } |
104 | |
|
105 | |
|
106 | |
|
107 | |
|
108 | |
|
109 | |
public RuleResponsibility getRuleResponsibility() { |
110 | 0 | if ( getResponsibilityId() == null ) { |
111 | 0 | return null; |
112 | |
} |
113 | 0 | return KEWServiceLocator.getRuleService().findRuleResponsibility(getResponsibilityId()); |
114 | |
} |
115 | |
|
116 | |
public DocumentType getDocumentType() { |
117 | 0 | return this.getDelegationRuleBaseValues().getDocumentType(); |
118 | |
} |
119 | |
|
120 | |
public Long getResponsibilityId() { |
121 | 0 | return responsibilityId; |
122 | |
} |
123 | |
public void setResponsibilityId(Long ruleResponsibilityId) { |
124 | 0 | this.responsibilityId = ruleResponsibilityId; |
125 | 0 | } |
126 | |
|
127 | |
|
128 | |
|
129 | |
|
130 | |
|
131 | |
|
132 | |
|
133 | |
|
134 | |
|
135 | |
|
136 | |
|
137 | |
@Override |
138 | |
public void refresh() { |
139 | 0 | RuleBaseValues oldRuleBaseValues = this.getDelegationRuleBaseValues(); |
140 | 0 | super.refresh(); |
141 | 0 | if (this.getDelegationRuleBaseValues() == null) { |
142 | 0 | this.refreshReferenceObject("delegationRuleBaseValues"); |
143 | 0 | if (this.getDelegationRuleBaseValues() == null) { |
144 | 0 | this.setDelegationRuleBaseValues(oldRuleBaseValues); |
145 | |
} |
146 | |
} |
147 | 0 | } |
148 | |
} |
149 | |
|