1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kim.api.common.attribute; |
17 | |
|
18 | |
import org.apache.commons.lang.StringUtils; |
19 | |
import org.kuali.rice.core.api.CoreConstants; |
20 | |
import org.kuali.rice.core.api.mo.AbstractDataTransferObject; |
21 | |
import org.kuali.rice.core.api.mo.ModelBuilder; |
22 | |
import org.w3c.dom.Element; |
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.XmlRootElement; |
29 | |
import javax.xml.bind.annotation.XmlType; |
30 | |
import java.io.Serializable; |
31 | |
import java.util.Collection; |
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
@XmlRootElement(name = KimAttribute.Constants.ROOT_ELEMENT_NAME) |
41 | |
@XmlAccessorType(XmlAccessType.NONE) |
42 | |
@XmlType(name = KimAttribute.Constants.TYPE_NAME, propOrder = { |
43 | |
KimAttribute.Elements.ID, |
44 | |
KimAttribute.Elements.COMPONENT_NAME, |
45 | |
KimAttribute.Elements.ATTRIBUTE_NAME, |
46 | |
KimAttribute.Elements.NAMESPACE_CODE, |
47 | |
KimAttribute.Elements.ATTRIBUTE_LABEL, |
48 | |
KimAttribute.Elements.ACTIVE, |
49 | |
CoreConstants.CommonElements.VERSION_NUMBER, |
50 | |
CoreConstants.CommonElements.OBJECT_ID, |
51 | |
CoreConstants.CommonElements.FUTURE_ELEMENTS |
52 | |
}) |
53 | 0 | public final class KimAttribute extends AbstractDataTransferObject implements KimAttributeContract { |
54 | |
private static final long serialVersionUID = 1L; |
55 | |
|
56 | |
@XmlElement(name = KimAttribute.Elements.ID, required = false) |
57 | |
private final String id; |
58 | |
|
59 | |
@XmlElement(name = KimAttribute.Elements.COMPONENT_NAME, required = true) |
60 | |
private final String componentName; |
61 | |
|
62 | |
@XmlElement(name = KimAttribute.Elements.ATTRIBUTE_NAME, required = true) |
63 | |
private final String attributeName; |
64 | |
|
65 | |
@XmlElement(name = KimAttribute.Elements.NAMESPACE_CODE, required = true) |
66 | |
private final String namespaceCode; |
67 | |
|
68 | |
@XmlElement(name = KimAttribute.Elements.ATTRIBUTE_LABEL, required = false) |
69 | |
private final String attributeLabel; |
70 | |
|
71 | |
@XmlElement(name = KimAttribute.Elements.ACTIVE, required = false) |
72 | |
private final boolean active; |
73 | |
|
74 | |
@XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false) |
75 | |
private final Long versionNumber; |
76 | |
|
77 | |
@XmlElement(name = CoreConstants.CommonElements.OBJECT_ID, required = false) |
78 | |
private final String objectId; |
79 | |
|
80 | 0 | @SuppressWarnings("unused") |
81 | |
@XmlAnyElement |
82 | |
private final Collection<Element> _futureElements = null; |
83 | |
|
84 | |
|
85 | |
|
86 | |
|
87 | 0 | private KimAttribute() { |
88 | 0 | this.id = null; |
89 | 0 | this.componentName = null; |
90 | 0 | this.attributeName = null; |
91 | 0 | this.namespaceCode = null; |
92 | 0 | this.attributeLabel = null; |
93 | 0 | this.active = false; |
94 | 0 | this.versionNumber = Long.valueOf(1L); |
95 | 0 | this.objectId = null; |
96 | 0 | } |
97 | |
|
98 | 0 | private KimAttribute(Builder builder) { |
99 | 0 | this.id = builder.getId(); |
100 | 0 | this.componentName = builder.getComponentName(); |
101 | 0 | this.attributeName = builder.getAttributeName(); |
102 | 0 | this.namespaceCode = builder.getNamespaceCode(); |
103 | 0 | this.attributeLabel = builder.getAttributeLabel(); |
104 | 0 | this.active = builder.isActive(); |
105 | 0 | this.versionNumber = builder.getVersionNumber(); |
106 | 0 | this.objectId = builder.getObjectId(); |
107 | 0 | } |
108 | |
|
109 | |
@Override |
110 | |
public String getId() { |
111 | 0 | return id; |
112 | |
} |
113 | |
|
114 | |
@Override |
115 | |
public String getComponentName() { |
116 | 0 | return componentName; |
117 | |
} |
118 | |
|
119 | |
@Override |
120 | |
public String getAttributeName() { |
121 | 0 | return attributeName; |
122 | |
} |
123 | |
|
124 | |
@Override |
125 | |
public String getNamespaceCode() { |
126 | 0 | return namespaceCode; |
127 | |
} |
128 | |
|
129 | |
@Override |
130 | |
public String getAttributeLabel() { |
131 | 0 | return attributeLabel; |
132 | |
} |
133 | |
|
134 | |
@Override |
135 | |
public Long getVersionNumber() { |
136 | 0 | return versionNumber; |
137 | |
} |
138 | |
|
139 | |
@Override |
140 | |
public boolean isActive() { |
141 | 0 | return active; |
142 | |
} |
143 | |
|
144 | |
@Override |
145 | |
public String getObjectId() { |
146 | 0 | return objectId; |
147 | |
} |
148 | |
|
149 | |
|
150 | |
|
151 | |
|
152 | 0 | public static final class Builder implements KimAttributeContract, ModelBuilder, Serializable { |
153 | |
private String id; |
154 | |
private String componentName; |
155 | |
private String attributeName; |
156 | |
private String namespaceCode; |
157 | |
private String attributeLabel; |
158 | |
private boolean active; |
159 | 0 | private Long versionNumber = 1L; |
160 | |
private String objectId; |
161 | |
|
162 | 0 | private Builder(String componentName, String attributeName, String namespaceCode) { |
163 | 0 | setComponentName(componentName); |
164 | 0 | setAttributeName(attributeName); |
165 | 0 | setNamespaceCode(namespaceCode); |
166 | 0 | } |
167 | |
|
168 | |
|
169 | |
|
170 | |
|
171 | |
public static Builder create(String componentName, String attributeName, String namespaceCode) { |
172 | 0 | return new Builder(componentName, attributeName, namespaceCode); |
173 | |
} |
174 | |
|
175 | |
|
176 | |
|
177 | |
|
178 | |
public static Builder create(KimAttributeContract contract) { |
179 | 0 | Builder builder = new Builder(contract.getComponentName(), contract.getAttributeName(), contract.getNamespaceCode()); |
180 | 0 | builder.setId(contract.getId()); |
181 | 0 | builder.setAttributeLabel(contract.getAttributeLabel()); |
182 | 0 | builder.setActive(contract.isActive()); |
183 | 0 | builder.setVersionNumber(contract.getVersionNumber()); |
184 | 0 | builder.setObjectId(contract.getObjectId()); |
185 | 0 | return builder; |
186 | |
} |
187 | |
|
188 | |
|
189 | |
@Override |
190 | |
public String getId() { |
191 | 0 | return id; |
192 | |
} |
193 | |
|
194 | |
public void setId(final String id) { |
195 | 0 | this.id = id; |
196 | 0 | } |
197 | |
|
198 | |
@Override |
199 | |
public String getComponentName() { |
200 | 0 | return componentName; |
201 | |
} |
202 | |
|
203 | |
public void setComponentName(final String componentName) { |
204 | 0 | if (StringUtils.isBlank(componentName)) { |
205 | 0 | throw new IllegalArgumentException("componentName is blank"); |
206 | |
} |
207 | |
|
208 | 0 | this.componentName = componentName; |
209 | 0 | } |
210 | |
|
211 | |
@Override |
212 | |
public String getAttributeName() { |
213 | 0 | return attributeName; |
214 | |
} |
215 | |
|
216 | |
public void setAttributeName(final String attributeName) { |
217 | 0 | if (StringUtils.isBlank(attributeName)) { |
218 | 0 | throw new IllegalArgumentException("attributeName is blank"); |
219 | |
} |
220 | |
|
221 | 0 | this.attributeName = attributeName; |
222 | 0 | } |
223 | |
|
224 | |
@Override |
225 | |
public String getNamespaceCode() { |
226 | 0 | return namespaceCode; |
227 | |
} |
228 | |
|
229 | |
public void setNamespaceCode(final String namespaceCode) { |
230 | 0 | if (StringUtils.isBlank(namespaceCode)) { |
231 | 0 | throw new IllegalArgumentException("namespaceCode is blank"); |
232 | |
} |
233 | |
|
234 | 0 | this.namespaceCode = namespaceCode; |
235 | 0 | } |
236 | |
|
237 | |
@Override |
238 | |
public String getAttributeLabel() { |
239 | 0 | return attributeLabel; |
240 | |
} |
241 | |
|
242 | |
public void setAttributeLabel(final String attributeLabel) { |
243 | 0 | this.attributeLabel = attributeLabel; |
244 | 0 | } |
245 | |
|
246 | |
@Override |
247 | |
public boolean isActive() { |
248 | 0 | return active; |
249 | |
} |
250 | |
|
251 | |
public void setActive(final boolean active) { |
252 | 0 | this.active = active; |
253 | 0 | } |
254 | |
|
255 | |
@Override |
256 | |
public Long getVersionNumber() { |
257 | 0 | return versionNumber; |
258 | |
} |
259 | |
|
260 | |
public void setVersionNumber(final Long versionNumber) { |
261 | 0 | if (versionNumber == null || versionNumber <= 0) { |
262 | 0 | throw new IllegalArgumentException("versionNumber is invalid"); |
263 | |
} |
264 | |
|
265 | 0 | this.versionNumber = versionNumber; |
266 | 0 | } |
267 | |
|
268 | |
@Override |
269 | |
public String getObjectId() { |
270 | 0 | return objectId; |
271 | |
} |
272 | |
|
273 | |
public void setObjectId(final String objectId) { |
274 | 0 | this.objectId = objectId; |
275 | 0 | } |
276 | |
|
277 | |
@Override |
278 | |
public KimAttribute build() { |
279 | 0 | return new KimAttribute(this); |
280 | |
} |
281 | |
} |
282 | |
|
283 | |
|
284 | |
|
285 | |
|
286 | |
|
287 | 0 | static class Constants { |
288 | |
static final String ROOT_ELEMENT_NAME = "kimAttribute"; |
289 | |
static final String TYPE_NAME = "KimAttributeType"; |
290 | |
} |
291 | |
|
292 | |
|
293 | |
|
294 | |
|
295 | |
|
296 | 0 | static class Elements { |
297 | |
static final String ID = "id"; |
298 | |
static final String COMPONENT_NAME = "componentName"; |
299 | |
static final String ATTRIBUTE_NAME = "attributeName"; |
300 | |
static final String NAMESPACE_CODE = "namespaceCode"; |
301 | |
static final String ATTRIBUTE_LABEL = "attributeLabel"; |
302 | |
static final String ACTIVE = "active"; |
303 | |
} |
304 | |
|
305 | |
} |