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