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