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