1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kim.bo.entity.dto; |
17 | |
|
18 | |
import java.util.ArrayList; |
19 | |
import java.util.List; |
20 | |
|
21 | |
import org.kuali.rice.kim.bo.entity.KimEntity; |
22 | |
import org.kuali.rice.kim.bo.entity.KimEntityAffiliation; |
23 | |
import org.kuali.rice.kim.bo.entity.KimEntityCitizenship; |
24 | |
import org.kuali.rice.kim.bo.entity.KimEntityEmploymentInformation; |
25 | |
import org.kuali.rice.kim.bo.entity.KimEntityEntityType; |
26 | |
import org.kuali.rice.kim.bo.entity.KimEntityEthnicity; |
27 | |
import org.kuali.rice.kim.bo.entity.KimEntityExternalIdentifier; |
28 | |
import org.kuali.rice.kim.bo.entity.KimEntityName; |
29 | |
import org.kuali.rice.kim.bo.entity.KimEntityResidency; |
30 | |
import org.kuali.rice.kim.bo.entity.KimEntityVisa; |
31 | |
import org.kuali.rice.kim.bo.entity.KimPrincipal; |
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | 0 | public class KimEntityInfo extends KimInactivatableInfo implements KimEntity { |
40 | |
|
41 | |
private static final long serialVersionUID = 1L; |
42 | |
|
43 | |
private List<KimEntityAffiliationInfo> affiliations; |
44 | |
private KimEntityBioDemographicsInfo bioDemographics; |
45 | |
private List<KimEntityCitizenshipInfo> citizenships; |
46 | |
private List<KimEntityEmploymentInformationInfo> employmentInformation; |
47 | |
private String entityId; |
48 | |
private List<KimEntityEntityTypeInfo> entityTypes; |
49 | |
private List<KimEntityExternalIdentifierInfo> externalIdentifiers; |
50 | |
private List<KimEntityNameInfo> names; |
51 | |
private List<KimPrincipalInfo> principals; |
52 | |
private KimEntityPrivacyPreferencesInfo privacyPreferences; |
53 | |
private List<KimEntityEthnicityInfo> ethnicities; |
54 | |
private List<KimEntityResidencyInfo> residencies; |
55 | |
private List<KimEntityVisaInfo> visas; |
56 | |
|
57 | |
|
58 | |
|
59 | |
|
60 | |
public KimEntityInfo() { |
61 | 0 | super(); |
62 | 0 | active = true; |
63 | 0 | } |
64 | |
|
65 | |
|
66 | |
|
67 | |
|
68 | |
|
69 | |
|
70 | |
|
71 | |
public KimEntityInfo(KimEntity entity) { |
72 | 0 | this(); |
73 | |
|
74 | 0 | if (entity != null) { |
75 | |
|
76 | 0 | entityId = entity.getEntityId(); |
77 | 0 | active = entity.isActive(); |
78 | |
|
79 | |
|
80 | |
|
81 | |
|
82 | 0 | principals = deriveCollection(entity.getPrincipals(), new XForm<KimPrincipal, KimPrincipalInfo>() { |
83 | |
public KimPrincipalInfo xform(KimPrincipal source) { |
84 | 0 | return new KimPrincipalInfo(source); |
85 | |
} |
86 | |
}); |
87 | |
|
88 | 0 | if (entity.getBioDemographics() != null) { |
89 | 0 | bioDemographics = new KimEntityBioDemographicsInfo(entity.getBioDemographics()); |
90 | |
} |
91 | |
|
92 | 0 | if (entity.getPrivacyPreferences() != null) { |
93 | 0 | privacyPreferences = new KimEntityPrivacyPreferencesInfo(entity.getPrivacyPreferences()); |
94 | |
} |
95 | |
|
96 | 0 | names = deriveCollection(entity.getNames(), new XForm<KimEntityName, KimEntityNameInfo>() { |
97 | |
public KimEntityNameInfo xform(KimEntityName source) { |
98 | 0 | return new KimEntityNameInfo(source); |
99 | |
} |
100 | |
}); |
101 | |
|
102 | 0 | entityTypes = deriveCollection(entity.getEntityTypes(), new XForm<KimEntityEntityType, KimEntityEntityTypeInfo>() { |
103 | |
public KimEntityEntityTypeInfo xform(KimEntityEntityType source) { |
104 | 0 | return new KimEntityEntityTypeInfo(source); |
105 | |
} |
106 | |
}); |
107 | |
|
108 | 0 | affiliations = deriveCollection(entity.getAffiliations(), new XForm<KimEntityAffiliation, KimEntityAffiliationInfo>() { |
109 | |
public KimEntityAffiliationInfo xform(KimEntityAffiliation source) { |
110 | 0 | return new KimEntityAffiliationInfo(source); |
111 | |
} |
112 | |
}); |
113 | |
|
114 | 0 | employmentInformation = deriveCollection(entity.getEmploymentInformation(), |
115 | 0 | new XForm<KimEntityEmploymentInformation, KimEntityEmploymentInformationInfo>() { |
116 | |
public KimEntityEmploymentInformationInfo xform(KimEntityEmploymentInformation source) { |
117 | 0 | return new KimEntityEmploymentInformationInfo(source); |
118 | |
} |
119 | |
}); |
120 | |
|
121 | 0 | externalIdentifiers = deriveCollection(entity.getExternalIdentifiers(), |
122 | 0 | new XForm<KimEntityExternalIdentifier, KimEntityExternalIdentifierInfo>() { |
123 | |
public KimEntityExternalIdentifierInfo xform(KimEntityExternalIdentifier source) { |
124 | 0 | return new KimEntityExternalIdentifierInfo(source); |
125 | |
} |
126 | |
}); |
127 | |
|
128 | 0 | citizenships = deriveCollection(entity.getCitizenships(), new XForm<KimEntityCitizenship, KimEntityCitizenshipInfo>() { |
129 | |
public KimEntityCitizenshipInfo xform(KimEntityCitizenship source) { |
130 | 0 | return new KimEntityCitizenshipInfo(source); |
131 | |
} |
132 | |
}); |
133 | |
|
134 | 0 | ethnicities = deriveCollection(entity.getEthnicities(), new XForm<KimEntityEthnicity, KimEntityEthnicityInfo>() { |
135 | |
public KimEntityEthnicityInfo xform(KimEntityEthnicity source) { |
136 | 0 | return new KimEntityEthnicityInfo(source); |
137 | |
} |
138 | |
}); |
139 | |
|
140 | 0 | residencies = deriveCollection(entity.getResidencies(), new XForm<KimEntityResidency, KimEntityResidencyInfo>() { |
141 | |
public KimEntityResidencyInfo xform(KimEntityResidency source) { |
142 | 0 | return new KimEntityResidencyInfo(source); |
143 | |
} |
144 | |
}); |
145 | |
|
146 | 0 | visas = deriveCollection(entity.getVisas(), new XForm<KimEntityVisa, KimEntityVisaInfo>() { |
147 | |
public KimEntityVisaInfo xform(KimEntityVisa source) { |
148 | 0 | return new KimEntityVisaInfo(source); |
149 | |
} |
150 | |
}); |
151 | |
} |
152 | 0 | } |
153 | |
|
154 | |
|
155 | |
|
156 | |
|
157 | |
|
158 | |
public List<KimEntityAffiliationInfo> getAffiliations() { |
159 | |
|
160 | 0 | return (affiliations != null) ? affiliations : (affiliations = new ArrayList<KimEntityAffiliationInfo>()); |
161 | |
|
162 | |
} |
163 | |
|
164 | |
|
165 | |
|
166 | |
|
167 | |
|
168 | |
public void setAffiliations(List<KimEntityAffiliationInfo> affiliations) { |
169 | 0 | this.affiliations = affiliations; |
170 | 0 | } |
171 | |
|
172 | |
|
173 | |
|
174 | |
|
175 | |
|
176 | |
public KimEntityAffiliationInfo getDefaultAffiliation() { |
177 | 0 | KimEntityAffiliationInfo result = null; |
178 | 0 | if (affiliations != null) |
179 | 0 | for (KimEntityAffiliationInfo affiliation : affiliations) { |
180 | 0 | if (result == null) { |
181 | 0 | result = affiliation; |
182 | |
} |
183 | 0 | if (affiliation.isDefaultValue()) { |
184 | 0 | result = affiliation; |
185 | 0 | break; |
186 | |
} |
187 | |
} |
188 | 0 | return result; |
189 | |
} |
190 | |
|
191 | |
|
192 | |
|
193 | |
|
194 | |
|
195 | |
public KimEntityBioDemographicsInfo getBioDemographics() { |
196 | 0 | return bioDemographics; |
197 | |
} |
198 | |
|
199 | |
|
200 | |
|
201 | |
|
202 | |
|
203 | |
public void setBioDemographics(KimEntityBioDemographicsInfo bioDemographics) { |
204 | 0 | this.bioDemographics = bioDemographics; |
205 | 0 | } |
206 | |
|
207 | |
|
208 | |
|
209 | |
|
210 | |
|
211 | |
public List<KimEntityCitizenshipInfo> getCitizenships() { |
212 | |
|
213 | 0 | return (citizenships != null) ? citizenships : (citizenships = new ArrayList<KimEntityCitizenshipInfo>()); |
214 | |
|
215 | |
} |
216 | |
|
217 | |
|
218 | |
|
219 | |
|
220 | |
|
221 | |
public void setCitizenships(List<KimEntityCitizenshipInfo> citizenships) { |
222 | 0 | this.citizenships = citizenships; |
223 | 0 | } |
224 | |
|
225 | |
|
226 | |
|
227 | |
|
228 | |
|
229 | |
public List<KimEntityEmploymentInformationInfo> getEmploymentInformation() { |
230 | |
|
231 | 0 | return (employmentInformation != null) ? employmentInformation |
232 | |
: (employmentInformation = new ArrayList<KimEntityEmploymentInformationInfo>()); |
233 | |
} |
234 | |
|
235 | |
|
236 | |
|
237 | |
|
238 | |
|
239 | |
public void setEmploymentInformation(List<KimEntityEmploymentInformationInfo> employmentInformation) { |
240 | 0 | this.employmentInformation = employmentInformation; |
241 | 0 | } |
242 | |
|
243 | |
|
244 | |
|
245 | |
|
246 | |
|
247 | |
public KimEntityEmploymentInformationInfo getPrimaryEmployment() { |
248 | 0 | KimEntityEmploymentInformationInfo result = null; |
249 | 0 | if (employmentInformation != null) |
250 | 0 | for (KimEntityEmploymentInformationInfo employment : employmentInformation) { |
251 | 0 | if (employment.isPrimary()) { |
252 | 0 | result = employment; |
253 | |
} |
254 | |
} |
255 | 0 | return result; |
256 | |
} |
257 | |
|
258 | |
|
259 | |
|
260 | |
|
261 | |
|
262 | |
public String getEntityId() { |
263 | 0 | return entityId; |
264 | |
} |
265 | |
|
266 | |
|
267 | |
|
268 | |
|
269 | |
|
270 | |
public void setEntityId(String entityId) { |
271 | 0 | this.entityId = entityId; |
272 | 0 | } |
273 | |
|
274 | |
|
275 | |
|
276 | |
|
277 | |
|
278 | |
public List<KimEntityEntityTypeInfo> getEntityTypes() { |
279 | |
|
280 | 0 | return (entityTypes != null) ? entityTypes : (entityTypes = new ArrayList<KimEntityEntityTypeInfo>()); |
281 | |
} |
282 | |
|
283 | |
|
284 | |
|
285 | |
|
286 | |
|
287 | |
public void setEntityTypes(List<KimEntityEntityTypeInfo> entityTypes) { |
288 | 0 | this.entityTypes = entityTypes; |
289 | 0 | } |
290 | |
|
291 | |
|
292 | |
|
293 | |
|
294 | |
|
295 | |
public List<KimEntityExternalIdentifierInfo> getExternalIdentifiers() { |
296 | |
|
297 | 0 | return (externalIdentifiers != null) ? externalIdentifiers |
298 | |
: (externalIdentifiers = new ArrayList<KimEntityExternalIdentifierInfo>()); |
299 | |
} |
300 | |
|
301 | |
|
302 | |
|
303 | |
|
304 | |
|
305 | |
public void setExternalIdentifiers(List<KimEntityExternalIdentifierInfo> externalIdentifiers) { |
306 | 0 | this.externalIdentifiers = externalIdentifiers; |
307 | 0 | } |
308 | |
|
309 | |
|
310 | |
|
311 | |
|
312 | |
|
313 | |
public List<KimEntityNameInfo> getNames() { |
314 | |
|
315 | 0 | return (names != null) ? names : (names = new ArrayList<KimEntityNameInfo>()); |
316 | |
} |
317 | |
|
318 | |
|
319 | |
|
320 | |
|
321 | |
|
322 | |
public void setNames(List<KimEntityNameInfo> names) { |
323 | 0 | this.names = names; |
324 | 0 | } |
325 | |
|
326 | |
|
327 | |
|
328 | |
|
329 | |
|
330 | |
public KimEntityNameInfo getDefaultName() { |
331 | 0 | KimEntityNameInfo result = null; |
332 | 0 | for (KimEntityNameInfo name : this.getNames()) { |
333 | 0 | if (result == null) { |
334 | 0 | result = name; |
335 | |
} |
336 | 0 | if (name.isDefaultValue()) { |
337 | 0 | result = name; |
338 | 0 | break; |
339 | |
} |
340 | |
} |
341 | 0 | return result; |
342 | |
} |
343 | |
|
344 | |
|
345 | |
|
346 | |
|
347 | |
|
348 | |
public List<KimPrincipalInfo> getPrincipals() { |
349 | |
|
350 | 0 | return (principals != null) ? principals : (principals = new ArrayList<KimPrincipalInfo>()); |
351 | |
} |
352 | |
|
353 | |
|
354 | |
|
355 | |
|
356 | |
|
357 | |
public void setPrincipals(List<KimPrincipalInfo> principals) { |
358 | 0 | this.principals = principals; |
359 | 0 | } |
360 | |
|
361 | |
|
362 | |
|
363 | |
|
364 | |
|
365 | |
public KimEntityPrivacyPreferencesInfo getPrivacyPreferences() { |
366 | 0 | return privacyPreferences; |
367 | |
} |
368 | |
|
369 | |
|
370 | |
|
371 | |
|
372 | |
|
373 | |
public void setPrivacyPreferences(KimEntityPrivacyPreferencesInfo privacyPreferences) { |
374 | 0 | this.privacyPreferences = privacyPreferences; |
375 | 0 | } |
376 | |
|
377 | |
|
378 | |
|
379 | |
|
380 | |
|
381 | |
public List<KimEntityEthnicityInfo> getEthnicities() { |
382 | |
|
383 | 0 | return (ethnicities != null) ? ethnicities : (ethnicities = new ArrayList<KimEntityEthnicityInfo>()); |
384 | |
} |
385 | |
|
386 | |
|
387 | |
|
388 | |
|
389 | |
|
390 | |
public void setEthnicities(List<KimEntityEthnicityInfo> ethnicities) { |
391 | 0 | this.ethnicities = ethnicities; |
392 | 0 | } |
393 | |
|
394 | |
|
395 | |
|
396 | |
|
397 | |
|
398 | |
public List<KimEntityResidencyInfo> getResidencies() { |
399 | |
|
400 | 0 | return (residencies != null) ? residencies : (residencies = new ArrayList<KimEntityResidencyInfo>()); |
401 | |
} |
402 | |
|
403 | |
|
404 | |
|
405 | |
|
406 | |
|
407 | |
public void setResidencies(List<KimEntityResidencyInfo> residencies) { |
408 | 0 | this.residencies = residencies; |
409 | 0 | } |
410 | |
|
411 | |
|
412 | |
|
413 | |
|
414 | |
|
415 | |
public List<KimEntityVisaInfo> getVisas() { |
416 | |
|
417 | 0 | return (visas != null) ? visas : (visas = new ArrayList<KimEntityVisaInfo>()); |
418 | |
} |
419 | |
|
420 | |
|
421 | |
|
422 | |
|
423 | |
|
424 | |
public void setVisas(List<KimEntityVisaInfo> visas) { |
425 | 0 | this.visas = visas; |
426 | 0 | } |
427 | |
|
428 | |
|
429 | |
|
430 | |
|
431 | |
|
432 | |
public KimEntityExternalIdentifier getEntityExternalIdentifier(String externalIdentifierTypeCode) { |
433 | 0 | KimEntityExternalIdentifier result = null; |
434 | |
|
435 | 0 | List<KimEntityExternalIdentifierInfo> externalIdentifiers = getExternalIdentifiers(); |
436 | 0 | if (externalIdentifiers != null) |
437 | 0 | for (KimEntityExternalIdentifier eid : externalIdentifiers) { |
438 | 0 | if (eid.getExternalIdentifierTypeCode().equals(externalIdentifierTypeCode)) { |
439 | 0 | result = eid; |
440 | |
} |
441 | |
} |
442 | 0 | return result; |
443 | |
} |
444 | |
|
445 | |
|
446 | |
|
447 | |
|
448 | |
|
449 | |
public KimEntityEntityType getEntityType(String entityTypeCode) { |
450 | 0 | KimEntityEntityType result = null; |
451 | |
|
452 | 0 | if (entityTypes != null) |
453 | 0 | for (KimEntityEntityType eType : entityTypes) { |
454 | 0 | if (eType.getEntityTypeCode().equals(entityTypeCode)) { |
455 | 0 | result = eType; |
456 | |
} |
457 | |
} |
458 | 0 | return result; |
459 | |
} |
460 | |
|
461 | |
|
462 | |
|
463 | |
|
464 | |
|
465 | |
|
466 | |
|
467 | |
|
468 | |
|
469 | |
|
470 | |
|
471 | |
|
472 | |
|
473 | |
|
474 | |
|
475 | |
|
476 | |
|
477 | |
|
478 | |
|
479 | |
|
480 | |
|
481 | |
|
482 | |
|
483 | |
|
484 | |
private static <A,B,C> List<B> deriveCollection(List<A> source, XForm<C,B> transformer) { |
485 | 0 | List<B> result = null; |
486 | 0 | if (source != null) { |
487 | 0 | result = new ArrayList<B>(source.size()); |
488 | |
|
489 | 0 | for (A element : source) if (element != null) { |
490 | 0 | B mutant = transformer.xform((C)element); |
491 | 0 | if (mutant != null) { |
492 | 0 | result.add(mutant); |
493 | |
} |
494 | 0 | } |
495 | |
} else { |
496 | 0 | result = new ArrayList(); |
497 | |
} |
498 | 0 | return result; |
499 | |
} |
500 | |
|
501 | |
private static interface XForm<A,B> { |
502 | |
public B xform(A source); |
503 | |
} |
504 | |
|
505 | |
} |