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 import org.kuali.rice.krms.api.KrmsConstants;
37
38
39
40
41
42
43
44
45
46
47 @XmlRootElement(name = AgendaTreeDefinition.Constants.ROOT_ELEMENT_NAME)
48 @XmlAccessorType(XmlAccessType.NONE)
49 @XmlType(name = AgendaTreeDefinition.Constants.TYPE_NAME, propOrder = {
50 AgendaTreeDefinition.Elements.AGENDA_ID,
51 AgendaTreeDefinition.Elements.ENTRIES,
52 CoreConstants.CommonElements.FUTURE_ELEMENTS
53 })
54 public final class AgendaTreeDefinition extends AbstractDataTransferObject {
55
56 private static final long serialVersionUID = 3355519740298280591L;
57
58 @XmlElement(name = Elements.AGENDA_ID, required = false)
59 private final String agendaId;
60
61 @XmlElements(value = {
62 @XmlElement(name = Elements.RULE, type = AgendaTreeRuleEntry.class, required = false),
63 @XmlElement(name = Elements.SUB_AGENDA, type = AgendaTreeSubAgendaEntry.class, required = false)
64 })
65 private final List<AgendaTreeEntryDefinitionContract> entries;
66
67 @SuppressWarnings("unused")
68 @XmlAnyElement
69 private final Collection<org.w3c.dom.Element> _futureElements = null;
70
71
72
73
74
75 private AgendaTreeDefinition() {
76 this.agendaId = null;
77 this.entries = null;
78 }
79
80
81
82
83
84
85
86 private AgendaTreeDefinition(Builder builder) {
87 this.agendaId = builder.getAgendaId();
88 this.entries = builder.getEntries();
89 }
90
91
92
93
94
95 public String getAgendaId() {
96 return agendaId;
97 }
98
99
100
101
102
103 public List<AgendaTreeEntryDefinitionContract> getEntries() {
104 if (entries == null){
105 return Collections.emptyList();
106 }
107 return Collections.unmodifiableList(entries);
108 }
109
110
111
112
113
114 public static class Builder implements ModelBuilder, Serializable {
115
116 private static final long serialVersionUID = 7981215392039022620L;
117
118 private String agendaId;
119 private List<AgendaTreeEntryDefinitionContract> entries;
120
121
122
123
124 private Builder() {
125 this.entries = new ArrayList<AgendaTreeEntryDefinitionContract>();
126 }
127
128
129
130
131
132 public static Builder create(){
133 return new Builder();
134 }
135
136
137
138
139
140
141 public void setAgendaId(String agendaId) {
142 if (StringUtils.isBlank(agendaId)) {
143 throw new IllegalArgumentException("agendaItemId was null or blank");
144 }
145 this.agendaId = agendaId;
146 }
147
148
149
150
151
152
153 public void addRuleEntry(AgendaTreeRuleEntry ruleEntry) {
154 if (ruleEntry == null) {
155 throw new IllegalArgumentException("ruleEntry was null");
156 }
157 entries.add(ruleEntry);
158 }
159
160
161
162
163
164
165 public void addSubAgendaEntry(AgendaTreeSubAgendaEntry subAgendaEntry) {
166 if (subAgendaEntry == null) {
167 throw new IllegalArgumentException("subAgendaEntry was null");
168 }
169 entries.add(subAgendaEntry);
170 }
171
172
173
174
175
176 public String getAgendaId() {
177 return this.agendaId;
178 }
179
180
181
182
183
184 public List<AgendaTreeEntryDefinitionContract> getEntries() {
185 return this.entries;
186 }
187
188 @Override
189 public AgendaTreeDefinition build() {
190 return new AgendaTreeDefinition(this);
191 }
192
193 }
194
195
196
197
198 static class Constants {
199 final static String ROOT_ELEMENT_NAME = "agendaTreeDefinition";
200 final static String TYPE_NAME = "AgendaTreeDefinition";
201 }
202
203
204
205
206
207 static class Elements {
208 final static String AGENDA_ID = "agendaId";
209 final static String ENTRIES = "entries";
210 final static String RULE = "rule";
211 final static String SUB_AGENDA = "subAgenda";
212 }
213
214 public static class Cache {
215 public static final String NAME = KrmsConstants.Namespaces.KRMS_NAMESPACE_2_0 + "/" + AgendaTreeDefinition.Constants.TYPE_NAME;
216 }
217
218 }