1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kew.api.repository.type; |
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 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | 0 | @XmlRootElement(name = KewTypeAttribute.Constants.ROOT_ELEMENT_NAME) |
40 | |
@XmlAccessorType(XmlAccessType.NONE) |
41 | |
@XmlType(name = KewTypeAttribute.Constants.TYPE_NAME, propOrder = { |
42 | |
KewTypeAttribute.Elements.ID, |
43 | |
KewTypeAttribute.Elements.TYPE_ID, |
44 | |
KewTypeAttribute.Elements.ATTR_DEFN_ID, |
45 | |
KewTypeAttribute.Elements.SEQ_NO, |
46 | |
KewTypeAttribute.Elements.ACTIVE, |
47 | |
KewTypeAttribute.Elements.ATTR_DEFN, |
48 | |
CoreConstants.CommonElements.FUTURE_ELEMENTS |
49 | |
}) |
50 | 0 | public final class KewTypeAttribute extends AbstractDataTransferObject implements KewTypeAttributeContract { |
51 | |
private static final long serialVersionUID = -304265575559412478L; |
52 | |
|
53 | |
@XmlElement(name = Elements.ID, required=true) |
54 | |
private String id; |
55 | |
@XmlElement(name = Elements.TYPE_ID, required=true) |
56 | |
private String typeId; |
57 | |
@XmlElement(name = Elements.ATTR_DEFN_ID, required=true) |
58 | |
private String attributeDefinitionId; |
59 | |
@XmlElement(name = Elements.SEQ_NO, required=true) |
60 | |
private Integer sequenceNumber; |
61 | |
@XmlElement(name = Elements.ACTIVE, required=false) |
62 | |
private boolean active; |
63 | |
@XmlElement(name = Elements.ATTR_DEFN, required=false) |
64 | |
private KewAttributeDefinition attributeDefinition; |
65 | |
|
66 | 0 | @SuppressWarnings("unused") |
67 | |
@XmlAnyElement |
68 | |
private final Collection<org.w3c.dom.Element> _futureElements = null; |
69 | |
|
70 | |
|
71 | |
|
72 | |
|
73 | 0 | private KewTypeAttribute() { |
74 | 0 | this.id = null; |
75 | 0 | this.typeId = null; |
76 | 0 | this.attributeDefinitionId = null; |
77 | 0 | this.sequenceNumber = null; |
78 | 0 | this.active = false; |
79 | 0 | this.attributeDefinition = null; |
80 | 0 | } |
81 | |
|
82 | |
|
83 | |
|
84 | |
|
85 | |
|
86 | |
|
87 | |
|
88 | 0 | private KewTypeAttribute(Builder builder) { |
89 | 0 | this.id = builder.getId(); |
90 | 0 | this.typeId = builder.getTypeId(); |
91 | 0 | this.attributeDefinitionId = builder.getAttributeDefinitionId(); |
92 | 0 | this.sequenceNumber = builder.getSequenceNumber(); |
93 | 0 | this.active = builder.isActive(); |
94 | 0 | if (builder.getAttributeDefinition() != null) { |
95 | 0 | this.attributeDefinition = builder.getAttributeDefinition().build(); |
96 | |
} |
97 | 0 | } |
98 | |
|
99 | |
public String getId() { |
100 | 0 | return this.id; |
101 | |
} |
102 | |
|
103 | |
public String getTypeId() { |
104 | 0 | return this.typeId; |
105 | |
} |
106 | |
|
107 | |
public String getAttributeDefinitionId() { |
108 | 0 | return this.attributeDefinitionId; |
109 | |
} |
110 | |
|
111 | |
public Integer getSequenceNumber() { |
112 | 0 | return this.sequenceNumber; |
113 | |
} |
114 | |
|
115 | |
public boolean isActive() { |
116 | 0 | return this.active; |
117 | |
} |
118 | |
|
119 | |
public KewAttributeDefinition getAttributeDefinition() { |
120 | 0 | return this.attributeDefinition; |
121 | |
} |
122 | |
|
123 | |
|
124 | |
|
125 | |
|
126 | 0 | public static class Builder implements KewTypeAttributeContract, ModelBuilder, Serializable { |
127 | |
private static final long serialVersionUID = 2729964674427296346L; |
128 | |
|
129 | |
private String id; |
130 | |
private String typeId; |
131 | |
private String attributeDefinitionId; |
132 | |
private Integer sequenceNumber; |
133 | |
private boolean active; |
134 | |
private KewAttributeDefinition.Builder attributeDefinition; |
135 | |
|
136 | |
|
137 | |
|
138 | |
|
139 | 0 | private Builder(String id, String typeId, String attributeDefinitionId, Integer sequenceNumber) { |
140 | 0 | setId(id); |
141 | 0 | setTypeId(typeId); |
142 | 0 | setAttributeDefinitionId(attributeDefinitionId); |
143 | 0 | setSequenceNumber(sequenceNumber); |
144 | 0 | setActive(true); |
145 | 0 | } |
146 | |
|
147 | |
public Builder attributeDefinition(KewAttributeDefinition.Builder attributeDefinition){ |
148 | 0 | setAttributeDefinition(attributeDefinition); |
149 | 0 | return this; |
150 | |
} |
151 | |
|
152 | |
|
153 | |
|
154 | |
|
155 | |
|
156 | |
|
157 | |
|
158 | |
|
159 | |
|
160 | |
|
161 | |
|
162 | |
public static Builder create(String id, String typeId, String attributeDefinitionId, Integer sequenceNumber) { |
163 | 0 | return new Builder(id, typeId, attributeDefinitionId, sequenceNumber); |
164 | |
} |
165 | |
|
166 | |
public static Builder create(KewTypeAttributeContract contract){ |
167 | 0 | if (contract == null) { |
168 | 0 | throw new IllegalArgumentException("contract is null"); |
169 | |
} |
170 | 0 | Builder builder = new Builder(contract.getId(), |
171 | |
contract.getTypeId(), |
172 | |
contract.getAttributeDefinitionId(), |
173 | |
contract.getSequenceNumber()); |
174 | 0 | if (contract.getAttributeDefinition() != null){ |
175 | 0 | KewAttributeDefinition.Builder attrBuilder = |
176 | |
KewAttributeDefinition.Builder.create(contract.getAttributeDefinition()); |
177 | 0 | builder.setAttributeDefinition(attrBuilder); |
178 | |
} |
179 | 0 | return builder; |
180 | |
} |
181 | |
|
182 | |
|
183 | |
|
184 | |
|
185 | |
|
186 | |
|
187 | |
|
188 | |
public void setId(String id) { |
189 | 0 | if (null != id && StringUtils.isBlank(id)) { |
190 | 0 | throw new IllegalArgumentException("id must be null or non-blank"); |
191 | |
} |
192 | 0 | this.id = id; |
193 | 0 | } |
194 | |
|
195 | |
public void setTypeId(String typeId) { |
196 | 0 | if (null != typeId && StringUtils.isBlank(typeId)) { |
197 | 0 | throw new IllegalArgumentException("typeId must be null or non-blank"); |
198 | |
} |
199 | 0 | this.typeId = typeId; |
200 | 0 | } |
201 | |
|
202 | |
public void setAttributeDefinitionId(String attributeDefinitionId) { |
203 | 0 | if (StringUtils.isBlank(attributeDefinitionId)) { |
204 | 0 | throw new IllegalArgumentException("the attribute definition id is blank"); |
205 | |
} |
206 | 0 | this.attributeDefinitionId = attributeDefinitionId; |
207 | 0 | } |
208 | |
|
209 | |
public void setSequenceNumber(Integer sequenceNumber) { |
210 | 0 | if (sequenceNumber == null){ |
211 | 0 | throw new IllegalArgumentException("the sequence number is null"); |
212 | |
} |
213 | 0 | this.sequenceNumber = sequenceNumber; |
214 | 0 | } |
215 | |
|
216 | |
public void setAttributeDefinition(KewAttributeDefinition.Builder attributeDefinition) { |
217 | 0 | this.attributeDefinition = attributeDefinition; |
218 | |
|
219 | 0 | } |
220 | |
|
221 | |
public void setActive(boolean active) { |
222 | 0 | this.active = active; |
223 | 0 | } |
224 | |
|
225 | |
public String getId() { |
226 | 0 | return id; |
227 | |
} |
228 | |
|
229 | |
public String getTypeId() { |
230 | 0 | return typeId; |
231 | |
} |
232 | |
|
233 | |
public String getAttributeDefinitionId() { |
234 | 0 | return attributeDefinitionId; |
235 | |
} |
236 | |
|
237 | |
public Integer getSequenceNumber() { |
238 | 0 | return sequenceNumber; |
239 | |
} |
240 | |
|
241 | |
public KewAttributeDefinition.Builder getAttributeDefinition() { |
242 | 0 | return attributeDefinition; |
243 | |
} |
244 | |
|
245 | |
|
246 | |
public boolean isActive() { |
247 | 0 | return active; |
248 | |
} |
249 | |
|
250 | |
|
251 | |
|
252 | |
|
253 | |
|
254 | |
|
255 | |
@Override |
256 | |
public KewTypeAttribute build() { |
257 | 0 | return new KewTypeAttribute(this); |
258 | |
} |
259 | |
|
260 | |
} |
261 | |
|
262 | |
|
263 | |
|
264 | |
|
265 | 0 | static class Constants { |
266 | |
final static String ROOT_ELEMENT_NAME = "KewTypeAttribute"; |
267 | |
final static String TYPE_NAME = "KewTypeAttributeType"; |
268 | |
} |
269 | |
|
270 | |
|
271 | |
|
272 | |
|
273 | |
|
274 | 0 | public static class Elements { |
275 | |
final static String ID = "id"; |
276 | |
final static String TYPE_ID = "typeId"; |
277 | |
final static String ATTR_DEFN_ID = "attributeDefinitionId"; |
278 | |
final static String SEQ_NO = "sequenceNumber"; |
279 | |
final static String ACTIVE = "active"; |
280 | |
final static String ATTR_DEFN = "attributeDefinition"; |
281 | |
} |
282 | |
} |