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