1 | |
package org.kuali.rice.krms.api.repository.agenda; |
2 | |
|
3 | |
import java.io.Serializable; |
4 | |
import java.util.ArrayList; |
5 | |
import java.util.Arrays; |
6 | |
import java.util.Collection; |
7 | |
import java.util.Collections; |
8 | |
import java.util.List; |
9 | |
|
10 | |
import javax.xml.bind.annotation.XmlAccessType; |
11 | |
import javax.xml.bind.annotation.XmlAccessorType; |
12 | |
import javax.xml.bind.annotation.XmlAnyElement; |
13 | |
import javax.xml.bind.annotation.XmlElement; |
14 | |
import javax.xml.bind.annotation.XmlRootElement; |
15 | |
import javax.xml.bind.annotation.XmlType; |
16 | |
|
17 | |
import org.apache.commons.lang.StringUtils; |
18 | |
import org.apache.commons.lang.builder.EqualsBuilder; |
19 | |
import org.apache.commons.lang.builder.HashCodeBuilder; |
20 | |
import org.apache.commons.lang.builder.ToStringBuilder; |
21 | |
import org.kuali.rice.core.api.CoreConstants; |
22 | |
import org.kuali.rice.core.api.mo.ModelBuilder; |
23 | |
import org.kuali.rice.core.api.mo.ModelObjectComplete; |
24 | |
import org.kuali.rice.krms.api.repository.rule.RuleDefinition; |
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | 0 | @XmlRootElement(name = AgendaItem.Constants.ROOT_ELEMENT_NAME) |
34 | |
@XmlAccessorType(XmlAccessType.NONE) |
35 | |
@XmlType(name = AgendaItem.Constants.TYPE_NAME, propOrder = { |
36 | |
AgendaItem.Elements.ID, |
37 | |
AgendaItem.Elements.AGENDA_ID, |
38 | |
AgendaItem.Elements.RULE_ID, |
39 | |
AgendaItem.Elements.SUB_AGENDA_ID, |
40 | |
AgendaItem.Elements.WHEN_TRUE_ID, |
41 | |
AgendaItem.Elements.WHEN_FALSE_ID, |
42 | |
AgendaItem.Elements.ALWAYS_ID, |
43 | |
AgendaItem.Elements.RULE, |
44 | |
AgendaItem.Elements.SUB_AGENDA, |
45 | |
AgendaItem.Elements.WHEN_TRUE, |
46 | |
AgendaItem.Elements.WHEN_FALSE, |
47 | |
AgendaItem.Elements.ALWAYS, |
48 | |
CoreConstants.CommonElements.VERSION_NUMBER, |
49 | |
CoreConstants.CommonElements.FUTURE_ELEMENTS |
50 | |
}) |
51 | 0 | public final class AgendaItem implements AgendaItemContract, ModelObjectComplete{ |
52 | |
private static final long serialVersionUID = 2783959459503209577L; |
53 | |
|
54 | |
@XmlElement(name = Elements.ID, required=true) |
55 | |
private String id; |
56 | |
@XmlElement(name = Elements.AGENDA_ID, required=true) |
57 | |
private String agendaId; |
58 | |
@XmlElement(name = Elements.RULE_ID, required=false) |
59 | |
private String ruleId; |
60 | |
@XmlElement(name = Elements.SUB_AGENDA_ID, required=false) |
61 | |
private String subAgendaId; |
62 | |
@XmlElement(name = Elements.WHEN_TRUE_ID, required=false) |
63 | |
private String whenTrueId; |
64 | |
@XmlElement(name = Elements.WHEN_FALSE_ID, required=false) |
65 | |
private String whenFalseId; |
66 | |
@XmlElement(name = Elements.ALWAYS_ID, required=false) |
67 | |
private String alwaysId; |
68 | |
|
69 | |
@XmlElement(name = Elements.RULE, required=false) |
70 | |
private RuleDefinition rule;; |
71 | |
@XmlElement(name = Elements.SUB_AGENDA, required=false) |
72 | |
private AgendaDefinition subAgenda; |
73 | |
@XmlElement(name = Elements.WHEN_TRUE, required=false) |
74 | |
private AgendaItem whenTrue; |
75 | |
@XmlElement(name = Elements.WHEN_FALSE, required=false) |
76 | |
private AgendaItem whenFalse; |
77 | |
@XmlElement(name = Elements.ALWAYS, required=false) |
78 | |
private AgendaItem always; |
79 | |
|
80 | |
@XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false) |
81 | |
private final Long versionNumber; |
82 | |
|
83 | 0 | @SuppressWarnings("unused") |
84 | |
@XmlAnyElement |
85 | |
private final Collection<org.w3c.dom.Element> _futureElements = null; |
86 | |
|
87 | |
|
88 | |
|
89 | |
|
90 | |
|
91 | |
|
92 | 0 | private AgendaItem() { |
93 | 0 | this.id = null; |
94 | 0 | this.agendaId = null; |
95 | 0 | this.ruleId = null; |
96 | 0 | this.subAgendaId = null; |
97 | 0 | this.whenTrueId = null; |
98 | 0 | this.whenFalseId = null; |
99 | 0 | this.alwaysId = null; |
100 | |
|
101 | 0 | this.rule = null; |
102 | 0 | this.subAgenda = null; |
103 | |
|
104 | 0 | this.whenTrue = null; |
105 | 0 | this.whenFalse = null; |
106 | 0 | this.always = null; |
107 | |
|
108 | 0 | this.versionNumber = null; |
109 | 0 | } |
110 | |
|
111 | |
|
112 | |
|
113 | |
|
114 | |
|
115 | |
|
116 | |
|
117 | 0 | private AgendaItem(Builder builder) { |
118 | 0 | this.id = builder.getId(); |
119 | 0 | this.agendaId = builder.getAgendaId(); |
120 | 0 | this.ruleId = builder.getRuleId(); |
121 | 0 | this.subAgendaId = builder.getSubAgendaId(); |
122 | 0 | this.whenTrueId = builder.getWhenTrueId(); |
123 | 0 | this.whenFalseId = builder.getWhenFalseId(); |
124 | 0 | this.alwaysId = builder.getAlwaysId(); |
125 | 0 | this.versionNumber = builder.getVersionNumber(); |
126 | |
|
127 | 0 | if (builder.getRule() != null) { this.rule = builder.getRule().build(); } |
128 | 0 | if (builder.getSubAgenda() != null) { this.subAgenda = builder.getSubAgenda().build(); } |
129 | 0 | if (builder.getWhenTrue() != null) { this.whenTrue = builder.getWhenTrue().build(); } |
130 | 0 | if (builder.getWhenFalse() != null) { this.whenFalse = builder.getWhenFalse().build(); } |
131 | 0 | if (builder.getAlways() != null) { this.always = builder.getAlways().build(); } |
132 | 0 | } |
133 | |
|
134 | |
@Override |
135 | |
public String getId() { |
136 | 0 | return this.id; |
137 | |
} |
138 | |
|
139 | |
@Override |
140 | |
public String getAgendaId() { |
141 | 0 | return this.agendaId; |
142 | |
} |
143 | |
|
144 | |
@Override |
145 | |
public String getRuleId() { |
146 | 0 | return this.ruleId; |
147 | |
} |
148 | |
|
149 | |
@Override |
150 | |
public String getSubAgendaId() { |
151 | 0 | return this.subAgendaId; |
152 | |
} |
153 | |
|
154 | |
@Override |
155 | |
public String getWhenTrueId() { |
156 | 0 | return this.whenTrueId; |
157 | |
} |
158 | |
|
159 | |
@Override |
160 | |
public String getWhenFalseId() { |
161 | 0 | return this.whenFalseId; |
162 | |
} |
163 | |
|
164 | |
@Override |
165 | |
public String getAlwaysId() { |
166 | 0 | return this.alwaysId; |
167 | |
} |
168 | |
|
169 | |
@Override |
170 | |
public RuleDefinition getRule() { |
171 | 0 | return this.rule; |
172 | |
} |
173 | |
|
174 | |
@Override |
175 | |
public AgendaDefinition getSubAgenda() { |
176 | 0 | return this.subAgenda; |
177 | |
} |
178 | |
|
179 | |
@Override |
180 | |
public AgendaItem getWhenTrue() { |
181 | 0 | return this.whenTrue; |
182 | |
} |
183 | |
|
184 | |
@Override |
185 | |
public AgendaItem getWhenFalse() { |
186 | 0 | return this.whenFalse; |
187 | |
} |
188 | |
|
189 | |
@Override |
190 | |
public AgendaItem getAlways() { |
191 | 0 | return this.always; |
192 | |
} |
193 | |
|
194 | |
@Override |
195 | |
public Long getVersionNumber() { |
196 | 0 | return versionNumber; |
197 | |
} |
198 | |
|
199 | |
|
200 | |
|
201 | |
|
202 | 0 | public static class Builder implements AgendaItemContract, ModelBuilder, Serializable { |
203 | |
|
204 | |
private String id; |
205 | |
private String agendaId; |
206 | |
private String ruleId; |
207 | |
private String subAgendaId; |
208 | |
private String whenTrueId; |
209 | |
private String whenFalseId; |
210 | |
private String alwaysId; |
211 | |
private Long versionNumber; |
212 | |
|
213 | |
private RuleDefinition.Builder rule; |
214 | |
private AgendaDefinition.Builder subAgenda; |
215 | |
|
216 | |
private AgendaItem.Builder whenTrue; |
217 | |
private AgendaItem.Builder whenFalse; |
218 | |
private AgendaItem.Builder always; |
219 | |
|
220 | |
|
221 | |
|
222 | |
|
223 | |
|
224 | 0 | private Builder(String id, String agendaId) { |
225 | 0 | setId(id); |
226 | 0 | setAgendaId(agendaId); |
227 | 0 | } |
228 | |
|
229 | |
public static Builder create(String id, String agendaId){ |
230 | 0 | return new Builder(id, agendaId); |
231 | |
} |
232 | |
|
233 | |
|
234 | |
|
235 | |
|
236 | |
|
237 | |
|
238 | |
public static Builder create(AgendaItemContract contract) { |
239 | 0 | if (contract == null) { |
240 | 0 | throw new IllegalArgumentException("contract is null"); |
241 | |
} |
242 | 0 | Builder builder = new Builder(contract.getId(), contract.getAgendaId()); |
243 | 0 | builder.setRuleId(contract.getRuleId()); |
244 | 0 | builder.setSubAgendaId(contract.getSubAgendaId()); |
245 | 0 | builder.setWhenTrueId(contract.getWhenTrueId()); |
246 | 0 | builder.setWhenFalseId(contract.getWhenFalseId()); |
247 | 0 | builder.setAlwaysId(contract.getAlwaysId()); |
248 | |
|
249 | 0 | if (contract.getRule() != null){ |
250 | 0 | builder.setRule(RuleDefinition.Builder.create( contract.getRule() )); |
251 | |
} |
252 | 0 | if (contract.getSubAgenda() != null){ |
253 | 0 | builder.setSubAgenda( AgendaDefinition.Builder.create( contract.getSubAgenda())); |
254 | |
} |
255 | 0 | if (contract.getWhenTrue() != null){ |
256 | 0 | builder.setWhenTrue( AgendaItem.Builder.create( contract.getWhenTrue())); |
257 | |
} |
258 | 0 | if (contract.getWhenFalse() != null){ |
259 | 0 | builder.setWhenFalse( AgendaItem.Builder.create( contract.getWhenFalse())); |
260 | |
} |
261 | 0 | if (contract.getAlways() != null){ |
262 | 0 | builder.setAlways( AgendaItem.Builder.create( contract.getAlways())); |
263 | |
} |
264 | 0 | builder.setVersionNumber(contract.getVersionNumber()); |
265 | 0 | return builder; |
266 | |
} |
267 | |
|
268 | |
|
269 | |
|
270 | |
|
271 | |
|
272 | |
|
273 | |
|
274 | |
|
275 | |
|
276 | |
|
277 | |
|
278 | |
public void setId(String id) { |
279 | 0 | if (id != null && StringUtils.isBlank(id)) { |
280 | 0 | throw new IllegalArgumentException("agendaItemId is empty or whitespace."); |
281 | |
} |
282 | 0 | this.id = id; |
283 | 0 | } |
284 | |
|
285 | |
|
286 | |
|
287 | |
|
288 | |
|
289 | |
|
290 | |
|
291 | |
|
292 | |
public void setAgendaId(String agendaId) { |
293 | 0 | if (StringUtils.isBlank(agendaId)) { |
294 | 0 | throw new IllegalArgumentException("agendaId is blank"); |
295 | |
} |
296 | 0 | this.agendaId = agendaId; |
297 | 0 | } |
298 | |
|
299 | |
public void setRuleId(String ruleId) { |
300 | 0 | this.ruleId = ruleId; |
301 | 0 | } |
302 | |
|
303 | |
public void setSubAgendaId(String subAgendaId) { |
304 | 0 | this.subAgendaId = subAgendaId; |
305 | 0 | } |
306 | |
|
307 | |
public void setWhenTrueId(String whenTrueId) { |
308 | 0 | this.whenTrueId = whenTrueId; |
309 | 0 | } |
310 | |
|
311 | |
public void setWhenFalseId(String whenFalseId) { |
312 | 0 | this.whenFalseId = whenFalseId; |
313 | 0 | } |
314 | |
|
315 | |
public void setAlwaysId(String alwaysId) { |
316 | 0 | this.alwaysId = alwaysId; |
317 | 0 | } |
318 | |
|
319 | |
public void setRule(RuleDefinition.Builder rule) { |
320 | 0 | this.rule = rule; |
321 | 0 | } |
322 | |
|
323 | |
public void setSubAgenda(AgendaDefinition.Builder subAgenda) { |
324 | 0 | this.subAgenda = subAgenda; |
325 | 0 | } |
326 | |
|
327 | |
public void setWhenTrue(AgendaItem.Builder whenTrue) { |
328 | 0 | this.whenTrue = whenTrue; |
329 | 0 | } |
330 | |
|
331 | |
public void setWhenFalse(AgendaItem.Builder whenFalse) { |
332 | 0 | this.whenTrue = whenFalse; |
333 | 0 | } |
334 | |
|
335 | |
public void setAlways(AgendaItem.Builder always) { |
336 | 0 | this.always = always; |
337 | 0 | } |
338 | |
|
339 | |
public void setVersionNumber(Long versionNumber){ |
340 | 0 | this.versionNumber = versionNumber; |
341 | 0 | } |
342 | |
|
343 | |
@Override |
344 | |
public String getId() { |
345 | 0 | return id; |
346 | |
} |
347 | |
|
348 | |
@Override |
349 | |
public String getAgendaId() { |
350 | 0 | return agendaId; |
351 | |
} |
352 | |
|
353 | |
@Override |
354 | |
public String getRuleId() { |
355 | 0 | return ruleId; |
356 | |
} |
357 | |
|
358 | |
@Override |
359 | |
public String getSubAgendaId() { |
360 | 0 | return subAgendaId; |
361 | |
} |
362 | |
|
363 | |
@Override |
364 | |
public String getWhenTrueId() { |
365 | 0 | return whenTrueId; |
366 | |
} |
367 | |
|
368 | |
@Override |
369 | |
public String getWhenFalseId() { |
370 | 0 | return whenFalseId; |
371 | |
} |
372 | |
|
373 | |
@Override |
374 | |
public String getAlwaysId() { |
375 | 0 | return alwaysId; |
376 | |
} |
377 | |
|
378 | |
@Override |
379 | |
public RuleDefinition.Builder getRule() { |
380 | 0 | return rule; |
381 | |
} |
382 | |
|
383 | |
@Override |
384 | |
public AgendaDefinition.Builder getSubAgenda() { |
385 | 0 | return subAgenda; |
386 | |
} |
387 | |
|
388 | |
@Override |
389 | |
public AgendaItem.Builder getWhenTrue() { |
390 | 0 | return whenTrue; |
391 | |
} |
392 | |
|
393 | |
@Override |
394 | |
public AgendaItem.Builder getWhenFalse() { |
395 | 0 | return whenFalse; |
396 | |
} |
397 | |
|
398 | |
@Override |
399 | |
public AgendaItem.Builder getAlways() { |
400 | 0 | return always; |
401 | |
} |
402 | |
|
403 | |
@Override |
404 | |
public Long getVersionNumber() { |
405 | 0 | return versionNumber; |
406 | |
} |
407 | |
|
408 | |
|
409 | |
|
410 | |
|
411 | |
|
412 | |
|
413 | |
@Override |
414 | |
public AgendaItem build() { |
415 | 0 | return new AgendaItem(this); |
416 | |
} |
417 | |
|
418 | |
} |
419 | |
@Override |
420 | |
public int hashCode() { |
421 | 0 | return HashCodeBuilder.reflectionHashCode(this, Constants.HASH_CODE_EQUALS_EXCLUDE); |
422 | |
} |
423 | |
|
424 | |
@Override |
425 | |
public boolean equals(Object obj) { |
426 | 0 | return EqualsBuilder.reflectionEquals(obj, this, Constants.HASH_CODE_EQUALS_EXCLUDE); |
427 | |
} |
428 | |
|
429 | |
@Override |
430 | |
public String toString() { |
431 | 0 | return ToStringBuilder.reflectionToString(this); |
432 | |
} |
433 | |
|
434 | |
|
435 | |
|
436 | |
|
437 | 0 | static class Constants { |
438 | |
final static String ROOT_ELEMENT_NAME = "AgendaItem"; |
439 | |
final static String TYPE_NAME = "AgendaItemType"; |
440 | 0 | final static String[] HASH_CODE_EQUALS_EXCLUDE = { "_elements" }; |
441 | |
} |
442 | |
|
443 | |
|
444 | |
|
445 | |
|
446 | |
|
447 | 0 | public static class Elements { |
448 | |
final static String ID = "id"; |
449 | |
final static String AGENDA_ID = "agendaId"; |
450 | |
final static String RULE_ID = "ruleId"; |
451 | |
final static String SUB_AGENDA_ID = "subAgendaId"; |
452 | |
final static String WHEN_TRUE_ID = "whenTrueId"; |
453 | |
final static String WHEN_FALSE_ID = "whenFalseId"; |
454 | |
final static String ALWAYS_ID = "alwaysId"; |
455 | |
|
456 | |
final static String RULE = "rule"; |
457 | |
final static String SUB_AGENDA = "subAgenda"; |
458 | |
final static String WHEN_TRUE = "whenTrue"; |
459 | |
final static String WHEN_FALSE = "whenFalse"; |
460 | |
final static String ALWAYS = "always"; |
461 | |
} |
462 | |
|
463 | |
} |