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.apache.commons.lang.ObjectUtils; |
20 | |
import org.hibernate.annotations.Fetch; |
21 | |
import org.hibernate.annotations.FetchMode; |
22 | |
import org.hibernate.annotations.GenericGenerator; |
23 | |
import org.hibernate.annotations.Parameter; |
24 | |
import org.kuali.rice.core.api.util.CollectionUtils; |
25 | |
import org.kuali.rice.core.framework.persistence.jpa.OrmUtils; |
26 | |
import org.kuali.rice.kew.rule.bo.RuleAttribute; |
27 | |
import org.kuali.rice.kew.rule.bo.RuleTemplateAttribute; |
28 | |
import org.kuali.rice.kew.service.KEWServiceLocator; |
29 | |
|
30 | |
import javax.persistence.CascadeType; |
31 | |
import javax.persistence.Column; |
32 | |
import javax.persistence.Entity; |
33 | |
import javax.persistence.FetchType; |
34 | |
import javax.persistence.GeneratedValue; |
35 | |
import javax.persistence.Id; |
36 | |
import javax.persistence.JoinColumn; |
37 | |
import javax.persistence.ManyToOne; |
38 | |
import javax.persistence.OneToMany; |
39 | |
import javax.persistence.Table; |
40 | |
import javax.persistence.Version; |
41 | |
import java.io.Serializable; |
42 | |
import java.util.ArrayList; |
43 | |
import java.util.List; |
44 | |
|
45 | |
|
46 | |
|
47 | |
|
48 | |
|
49 | |
|
50 | |
|
51 | |
|
52 | |
|
53 | |
|
54 | |
|
55 | |
|
56 | |
|
57 | |
@Entity |
58 | |
@Table(name="KREW_RULE_EXT_T") |
59 | |
|
60 | |
public class RuleExtension implements Serializable { |
61 | |
|
62 | |
private static final long serialVersionUID = 8178135296413950516L; |
63 | |
|
64 | |
@Id |
65 | |
@GeneratedValue(generator="KREW_RTE_TMPL_S") |
66 | |
@GenericGenerator(name="KREW_RTE_TMPL_S",strategy="org.hibernate.id.enhanced.SequenceStyleGenerator",parameters={ |
67 | |
@Parameter(name="sequence_name",value="KREW_RTE_TMPL_S"), |
68 | |
@Parameter(name="value_column",value="id") |
69 | |
}) |
70 | |
@Column(name="RULE_EXT_ID") |
71 | |
private String ruleExtensionId; |
72 | |
|
73 | |
@Column(name="RULE_TMPL_ATTR_ID", insertable=false, updatable=false) |
74 | |
private String ruleTemplateAttributeId; |
75 | |
|
76 | |
@Column(name="RULE_ID", insertable=false, updatable=false) |
77 | |
private String ruleBaseValuesId; |
78 | |
|
79 | |
@Version |
80 | |
@Column(name="VER_NBR") |
81 | |
private Integer lockVerNbr; |
82 | |
|
83 | |
@ManyToOne(fetch=FetchType.EAGER) |
84 | |
@JoinColumn(name="RULE_ID") |
85 | |
private RuleBaseValues ruleBaseValues; |
86 | |
|
87 | |
@ManyToOne(fetch=FetchType.EAGER) |
88 | |
@JoinColumn(name="RULE_TMPL_ATTR_ID") |
89 | |
private RuleTemplateAttribute ruleTemplateAttribute; |
90 | |
|
91 | |
@OneToMany(fetch=FetchType.EAGER, cascade={CascadeType.PERSIST, CascadeType.REMOVE, CascadeType.MERGE}, mappedBy="extension") |
92 | |
@Fetch(value = FetchMode.SELECT) |
93 | |
private List<RuleExtensionValue> extensionValues; |
94 | |
|
95 | 0 | public RuleExtension() { |
96 | 0 | extensionValues = new ArrayList<RuleExtensionValue>(); |
97 | 0 | } |
98 | |
|
99 | |
|
100 | |
public void beforeInsert(){ |
101 | 0 | OrmUtils.populateAutoIncValue(this, KEWServiceLocator.getEntityManagerFactory().createEntityManager()); |
102 | 0 | } |
103 | |
|
104 | |
public List<RuleExtensionValue> getExtensionValues() { |
105 | 0 | return extensionValues; |
106 | |
} |
107 | |
|
108 | |
public void setExtensionValues(List<RuleExtensionValue> extensionValues) { |
109 | 0 | this.extensionValues = extensionValues; |
110 | 0 | } |
111 | |
|
112 | |
public RuleTemplateAttribute getRuleTemplateAttribute() { |
113 | 0 | return ruleTemplateAttribute; |
114 | |
} |
115 | |
|
116 | |
public void setRuleTemplateAttribute(RuleTemplateAttribute ruleTemplateAttribute) { |
117 | 0 | this.ruleTemplateAttribute = ruleTemplateAttribute; |
118 | 0 | } |
119 | |
|
120 | |
public RuleExtensionValue getRuleExtensionValue(int index) { |
121 | 0 | while (getExtensionValues().size() <= index) { |
122 | 0 | getExtensionValues().add(new RuleExtensionValue()); |
123 | |
} |
124 | 0 | return (RuleExtensionValue) getExtensionValues().get(index); |
125 | |
} |
126 | |
|
127 | |
public RuleBaseValues getRuleBaseValues() { |
128 | 0 | return ruleBaseValues; |
129 | |
} |
130 | |
|
131 | |
public void setRuleBaseValues(RuleBaseValues ruleBaseValues) { |
132 | 0 | this.ruleBaseValues = ruleBaseValues; |
133 | 0 | } |
134 | |
|
135 | |
public Integer getLockVerNbr() { |
136 | 0 | return lockVerNbr; |
137 | |
} |
138 | |
|
139 | |
public void setLockVerNbr(Integer lockVerNbr) { |
140 | 0 | this.lockVerNbr = lockVerNbr; |
141 | 0 | } |
142 | |
|
143 | |
public String getRuleBaseValuesId() { |
144 | 0 | return ruleBaseValuesId; |
145 | |
} |
146 | |
|
147 | |
public void setRuleBaseValuesId(String ruleBaseValuesId) { |
148 | 0 | this.ruleBaseValuesId = ruleBaseValuesId; |
149 | 0 | } |
150 | |
|
151 | |
public String getRuleExtensionId() { |
152 | 0 | return ruleExtensionId; |
153 | |
} |
154 | |
|
155 | |
public void setRuleExtensionId(String ruleExtensionId) { |
156 | 0 | this.ruleExtensionId = ruleExtensionId; |
157 | 0 | } |
158 | |
|
159 | |
public String getRuleTemplateAttributeId() { |
160 | 0 | return ruleTemplateAttributeId; |
161 | |
} |
162 | |
|
163 | |
public void setRuleTemplateAttributeId(String ruleTemplateAttributeId) { |
164 | 0 | this.ruleTemplateAttributeId = ruleTemplateAttributeId; |
165 | 0 | } |
166 | |
|
167 | |
public boolean equals(Object o) { |
168 | 0 | if (o == null) return false; |
169 | 0 | if (!(o instanceof RuleExtension)) return false; |
170 | 0 | RuleExtension pred = (RuleExtension) o; |
171 | 0 | return ObjectUtils.equals(ruleBaseValues.getRuleTemplate(), pred.getRuleBaseValues().getRuleTemplate()) && |
172 | |
ObjectUtils.equals(ruleTemplateAttribute, pred.getRuleTemplateAttribute()) && |
173 | |
CollectionUtils.collectionsEquivalent(extensionValues, pred.getExtensionValues()); |
174 | |
} |
175 | |
|
176 | |
public String toString() { |
177 | 0 | return "[RuleExtension:" |
178 | |
+ " ruleExtensionId=" + ruleExtensionId |
179 | |
+ ", ruleTemplateAttributeId=" + ruleTemplateAttributeId |
180 | |
+ ", ruleBaseValuesId=" + ruleBaseValuesId |
181 | |
+ ", ruleBaseValues=" + ruleBaseValues |
182 | |
+ ", ruleTemplateAttribute=" + ruleTemplateAttribute |
183 | |
+ ", extensionValues=" + extensionValues |
184 | |
+ ", lockVerNbr=" + lockVerNbr |
185 | |
+ "]"; |
186 | |
} |
187 | |
|
188 | |
} |