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.ArrayList;
20 import java.util.Collection;
21 import java.util.Collections;
22 import java.util.List;
23
24 import javax.xml.bind.annotation.XmlAccessType;
25 import javax.xml.bind.annotation.XmlAccessorType;
26 import javax.xml.bind.annotation.XmlAnyElement;
27 import javax.xml.bind.annotation.XmlElement;
28 import javax.xml.bind.annotation.XmlElements;
29 import javax.xml.bind.annotation.XmlRootElement;
30 import javax.xml.bind.annotation.XmlType;
31
32 import org.apache.commons.lang.StringUtils;
33 import org.kuali.rice.core.api.CoreConstants;
34 import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
35 import org.kuali.rice.core.api.mo.ModelBuilder;
36
37
38
39
40
41
42
43
44 @XmlRootElement(name = AgendaTreeDefinition.Constants.ROOT_ELEMENT_NAME)
45 @XmlAccessorType(XmlAccessType.NONE)
46 @XmlType(name = AgendaTreeDefinition.Constants.TYPE_NAME, propOrder = {
47 AgendaTreeDefinition.Elements.AGENDA_ID,
48 AgendaTreeDefinition.Elements.ENTRIES,
49 CoreConstants.CommonElements.FUTURE_ELEMENTS
50 })
51 public final class AgendaTreeDefinition extends AbstractDataTransferObject {
52
53 private static final long serialVersionUID = 3355519740298280591L;
54
55 @XmlElement(name = Elements.AGENDA_ID, required = false)
56 private final String agendaId;
57
58 @XmlElements(value = {
59 @XmlElement(name = Elements.RULE, type = AgendaTreeRuleEntry.class, required = false),
60 @XmlElement(name = Elements.SUB_AGENDA, type = AgendaTreeSubAgendaEntry.class, required = false)
61 })
62 private final List<AgendaTreeEntryDefinition> entries;
63
64 @SuppressWarnings("unused")
65 @XmlAnyElement
66 private final Collection<org.w3c.dom.Element> _futureElements = null;
67
68
69
70
71
72 private AgendaTreeDefinition() {
73 this.agendaId = null;
74 this.entries = null;
75 }
76
77 private AgendaTreeDefinition(Builder builder) {
78 this.agendaId = builder.getAgendaId();
79 this.entries = builder.getEntries();
80 }
81
82 public String getAgendaId() {
83 return agendaId;
84 }
85
86 public List<AgendaTreeEntryDefinition> getEntries() {
87 if (entries == null){
88 return Collections.emptyList();
89 }
90 return Collections.unmodifiableList(entries);
91 }
92
93 public static class Builder implements ModelBuilder, Serializable {
94
95 private static final long serialVersionUID = 7981215392039022620L;
96
97 private String agendaId;
98 private List<AgendaTreeEntryDefinition> entries;
99
100
101
102
103 private Builder() {
104 this.entries = new ArrayList<AgendaTreeEntryDefinition>();
105 }
106
107 public static Builder create(){
108 return new Builder();
109 }
110
111 public void setAgendaId(String agendaId) {
112 if (StringUtils.isBlank(agendaId)) {
113 throw new IllegalArgumentException("agendaItemId was null or blank");
114 }
115 this.agendaId = agendaId;
116 }
117
118 public void addRuleEntry(AgendaTreeRuleEntry ruleEntry) {
119 if (ruleEntry == null) {
120 throw new IllegalArgumentException("ruleEntry was null");
121 }
122 entries.add(ruleEntry);
123 }
124
125 public void addSubAgendaEntry(AgendaTreeSubAgendaEntry subAgendaEntry) {
126 if (subAgendaEntry == null) {
127 throw new IllegalArgumentException("subAgendaEntry was null");
128 }
129 entries.add(subAgendaEntry);
130 }
131
132 public String getAgendaId() {
133 return this.agendaId;
134 }
135
136 public List<AgendaTreeEntryDefinition> getEntries() {
137 return this.entries;
138 }
139
140 @Override
141 public AgendaTreeDefinition build() {
142 return new AgendaTreeDefinition(this);
143 }
144
145 }
146
147
148
149
150 static class Constants {
151 final static String ROOT_ELEMENT_NAME = "agendaTreeDefinition";
152 final static String TYPE_NAME = "AgendaTreeDefinition";
153 }
154
155
156
157
158
159 static class Elements {
160 final static String AGENDA_ID = "agendaId";
161 final static String ENTRIES = "entries";
162 final static String RULE = "rule";
163 final static String SUB_AGENDA = "subAgenda";
164 }
165
166 }