1 | |
package org.kuali.rice.kim.api.identity.entity; |
2 | |
|
3 | |
import org.apache.commons.collections.CollectionUtils; |
4 | |
import org.apache.commons.lang.StringUtils; |
5 | |
import org.kuali.rice.core.api.CoreConstants; |
6 | |
import org.kuali.rice.core.api.mo.AbstractDataTransferObject; |
7 | |
import org.kuali.rice.core.api.mo.ModelBuilder; |
8 | |
import org.kuali.rice.kim.api.identity.affiliation.EntityAffiliation; |
9 | |
import org.kuali.rice.kim.api.identity.affiliation.EntityAffiliationContract; |
10 | |
import org.kuali.rice.kim.api.identity.citizenship.EntityCitizenship; |
11 | |
import org.kuali.rice.kim.api.identity.citizenship.EntityCitizenshipContract; |
12 | |
import org.kuali.rice.kim.api.identity.employment.EntityEmployment; |
13 | |
import org.kuali.rice.kim.api.identity.employment.EntityEmploymentContract; |
14 | |
import org.kuali.rice.kim.api.identity.external.EntityExternalIdentifier; |
15 | |
import org.kuali.rice.kim.api.identity.external.EntityExternalIdentifierContract; |
16 | |
import org.kuali.rice.kim.api.identity.name.EntityName; |
17 | |
import org.kuali.rice.kim.api.identity.name.EntityNameContract; |
18 | |
import org.kuali.rice.kim.api.identity.personal.EntityBioDemographics; |
19 | |
import org.kuali.rice.kim.api.identity.personal.EntityEthnicity; |
20 | |
import org.kuali.rice.kim.api.identity.personal.EntityEthnicityContract; |
21 | |
import org.kuali.rice.kim.api.identity.principal.Principal; |
22 | |
import org.kuali.rice.kim.api.identity.principal.PrincipalContract; |
23 | |
import org.kuali.rice.kim.api.identity.privacy.EntityPrivacyPreferences; |
24 | |
import org.kuali.rice.kim.api.identity.residency.EntityResidency; |
25 | |
import org.kuali.rice.kim.api.identity.residency.EntityResidencyContract; |
26 | |
import org.kuali.rice.kim.api.identity.type.EntityTypeContactInfo; |
27 | |
import org.kuali.rice.kim.api.identity.type.EntityTypeContactInfoContract; |
28 | |
import org.kuali.rice.kim.api.identity.visa.EntityVisa; |
29 | |
import org.kuali.rice.kim.api.identity.visa.EntityVisaContract; |
30 | |
import org.w3c.dom.Element; |
31 | |
|
32 | |
import javax.xml.bind.annotation.XmlAccessType; |
33 | |
import javax.xml.bind.annotation.XmlAccessorType; |
34 | |
import javax.xml.bind.annotation.XmlAnyElement; |
35 | |
import javax.xml.bind.annotation.XmlElement; |
36 | |
import javax.xml.bind.annotation.XmlElementWrapper; |
37 | |
import javax.xml.bind.annotation.XmlRootElement; |
38 | |
import javax.xml.bind.annotation.XmlType; |
39 | |
import java.io.Serializable; |
40 | |
import java.util.ArrayList; |
41 | |
import java.util.Collection; |
42 | |
import java.util.List; |
43 | |
|
44 | 2 | @XmlRootElement(name = Entity.Constants.ROOT_ELEMENT_NAME) |
45 | |
@XmlAccessorType(XmlAccessType.NONE) |
46 | |
@XmlType(name = Entity.Constants.TYPE_NAME, propOrder = { |
47 | |
Entity.Elements.ID, |
48 | |
Entity.Elements.PRINCIPALS, |
49 | |
Entity.Elements.ENTITY_TYPE_CONTACT_INFOS, |
50 | |
Entity.Elements.EXTERNAL_IDENTIFIERS, |
51 | |
Entity.Elements.AFFILIATIONS, |
52 | |
Entity.Elements.NAMES, |
53 | |
Entity.Elements.EMPLOYMENT_INFORMATION, |
54 | |
Entity.Elements.PRIVACY_PREFERENCES, |
55 | |
Entity.Elements.BIO_DEMOGRAPHICS, |
56 | |
Entity.Elements.CITIZENSHIPS, |
57 | |
Entity.Elements.PRIMARY_EMPLOYMENT, |
58 | |
Entity.Elements.DEFAULT_AFFILIATION, |
59 | |
Entity.Elements.DEFAULT_NAME, |
60 | |
Entity.Elements.ETHNICITIES, |
61 | |
Entity.Elements.RESIDENCIES, |
62 | |
Entity.Elements.VISAS, |
63 | |
CoreConstants.CommonElements.VERSION_NUMBER, |
64 | |
CoreConstants.CommonElements.OBJECT_ID, |
65 | |
Entity.Elements.ACTIVE, |
66 | |
CoreConstants.CommonElements.FUTURE_ELEMENTS |
67 | |
}) |
68 | 4 | public final class Entity extends AbstractDataTransferObject |
69 | |
implements EntityContract |
70 | |
{ |
71 | |
@XmlElement(name = Elements.ID, required = false) |
72 | |
private final String id; |
73 | |
@XmlElementWrapper(name = Elements.PRINCIPALS, required = false) |
74 | |
@XmlElement(name = Elements.PRINCIPAL, required = false) |
75 | |
private final List<Principal> principals; |
76 | |
@XmlElementWrapper(name = Elements.ENTITY_TYPE_CONTACT_INFOS, required = false) |
77 | |
@XmlElement(name = Elements.ENTITY_TYPE_CONTACT_INFO, required = false) |
78 | |
private final List<EntityTypeContactInfo> entityTypeContactInfos; |
79 | |
@XmlElementWrapper(name = Elements.EXTERNAL_IDENTIFIERS, required = false) |
80 | |
@XmlElement(name = Elements.EXTERNAL_IDENTIFIER, required = false) |
81 | |
private final List<EntityExternalIdentifier> externalIdentifiers; |
82 | |
@XmlElementWrapper(name = Elements.AFFILIATIONS, required = false) |
83 | |
@XmlElement(name = Elements.AFFILIATION, required = false) |
84 | |
private final List<EntityAffiliation> affiliations; |
85 | |
@XmlElementWrapper(name = Elements.NAMES, required = false) |
86 | |
@XmlElement(name = Elements.NAME, required = false) |
87 | |
private final List<EntityName> names; |
88 | |
@XmlElementWrapper(name = Elements.EMPLOYMENT_INFORMATION, required = false) |
89 | |
@XmlElement(name = Elements.EMPLOYMENT, required = false) |
90 | |
private final List<EntityEmployment> employmentInformation; |
91 | |
@XmlElement(name = Elements.PRIVACY_PREFERENCES, required = false) |
92 | |
private final EntityPrivacyPreferences privacyPreferences; |
93 | |
@XmlElement(name = Elements.BIO_DEMOGRAPHICS, required = false) |
94 | |
private final EntityBioDemographics bioDemographics; |
95 | |
@XmlElementWrapper(name = Elements.CITIZENSHIPS, required = false) |
96 | |
@XmlElement(name = Elements.CITIZENSHIP, required = false) |
97 | |
private final List<EntityCitizenship> citizenships; |
98 | |
@XmlElement(name = Elements.PRIMARY_EMPLOYMENT, required = false) |
99 | |
private final EntityEmployment primaryEmployment; |
100 | |
@XmlElement(name = Elements.DEFAULT_AFFILIATION, required = false) |
101 | |
private final EntityAffiliation defaultAffiliation; |
102 | |
@XmlElement(name = Elements.DEFAULT_NAME, required = false) |
103 | |
private final EntityName defaultName; |
104 | |
@XmlElementWrapper(name = Elements.ETHNICITIES, required = false) |
105 | |
@XmlElement(name = Elements.ETHNICITY, required = false) |
106 | |
private final List<EntityEthnicity> ethnicities; |
107 | |
@XmlElementWrapper(name = Elements.RESIDENCIES, required = false) |
108 | |
@XmlElement(name = Elements.RESIDENCY, required = false) |
109 | |
private final List<EntityResidency> residencies; |
110 | |
@XmlElementWrapper(name = Elements.VISAS, required = false) |
111 | |
@XmlElement(name = Elements.VISA, required = false) |
112 | |
private final List<EntityVisa> visas; |
113 | |
@XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false) |
114 | |
private final Long versionNumber; |
115 | |
@XmlElement(name = CoreConstants.CommonElements.OBJECT_ID, required = false) |
116 | |
private final String objectId; |
117 | |
@XmlElement(name = Elements.ACTIVE, required = false) |
118 | |
private final boolean active; |
119 | |
|
120 | 6 | @SuppressWarnings("unused") |
121 | |
@XmlAnyElement |
122 | |
private final Collection<Element> _futureElements = null; |
123 | |
|
124 | |
|
125 | |
|
126 | |
|
127 | |
|
128 | 2 | private Entity() { |
129 | 2 | this.principals = null; |
130 | 2 | this.entityTypeContactInfos = null; |
131 | 2 | this.externalIdentifiers = null; |
132 | 2 | this.affiliations = null; |
133 | 2 | this.names = null; |
134 | 2 | this.employmentInformation = null; |
135 | 2 | this.privacyPreferences = null; |
136 | 2 | this.bioDemographics = null; |
137 | 2 | this.citizenships = null; |
138 | 2 | this.primaryEmployment = null; |
139 | 2 | this.defaultAffiliation = null; |
140 | 2 | this.defaultName = null; |
141 | 2 | this.ethnicities = null; |
142 | 2 | this.residencies = null; |
143 | 2 | this.visas = null; |
144 | 2 | this.versionNumber = null; |
145 | 2 | this.objectId = null; |
146 | 2 | this.active = false; |
147 | 2 | this.id = null; |
148 | 2 | } |
149 | |
|
150 | 4 | private Entity(Builder builder) { |
151 | 4 | this.principals = new ArrayList<Principal>(); |
152 | 4 | if (CollectionUtils.isNotEmpty(builder.getPrincipals())) { |
153 | 2 | for (Principal.Builder principal : builder.getPrincipals()) { |
154 | 2 | this.principals.add(principal.build()); |
155 | |
} |
156 | |
} |
157 | 4 | this.entityTypeContactInfos = new ArrayList<EntityTypeContactInfo>(); |
158 | 4 | if (CollectionUtils.isNotEmpty(builder.getEntityTypeContactInfos())) { |
159 | 2 | for (EntityTypeContactInfo.Builder entityTypeData : builder.getEntityTypeContactInfos()) { |
160 | 2 | this.entityTypeContactInfos.add(entityTypeData.build()); |
161 | |
} |
162 | |
} |
163 | 4 | this.externalIdentifiers = new ArrayList<EntityExternalIdentifier>(); |
164 | 4 | if (CollectionUtils.isNotEmpty(builder.getExternalIdentifiers())) { |
165 | 2 | for (EntityExternalIdentifier.Builder externalId : builder.getExternalIdentifiers()) { |
166 | 2 | this.externalIdentifiers.add(externalId.build()); |
167 | |
} |
168 | |
} |
169 | 4 | this.affiliations = new ArrayList<EntityAffiliation>(); |
170 | 4 | if (CollectionUtils.isNotEmpty(builder.getAffiliations())) { |
171 | 2 | for (EntityAffiliation.Builder affiliation : builder.getAffiliations()) { |
172 | 2 | this.affiliations.add(affiliation.build()); |
173 | |
} |
174 | |
} |
175 | 4 | this.names = new ArrayList<EntityName>(); |
176 | 4 | if (CollectionUtils.isNotEmpty(builder.getNames())) { |
177 | 2 | for (EntityName.Builder name : builder.getNames()) { |
178 | 2 | this.names.add(name.build()); |
179 | |
} |
180 | |
} |
181 | 4 | this.employmentInformation = new ArrayList<EntityEmployment>(); |
182 | 4 | if (CollectionUtils.isNotEmpty(builder.getEmploymentInformation())) { |
183 | 2 | for (EntityEmployment.Builder employment : builder.getEmploymentInformation()) { |
184 | 2 | this.employmentInformation.add(employment.build()); |
185 | |
} |
186 | |
} |
187 | 4 | this.privacyPreferences = builder.getPrivacyPreferences() == null ? null : builder.getPrivacyPreferences().build(); |
188 | 4 | this.bioDemographics = builder.getBioDemographics() == null ? null : builder.getBioDemographics().build(); |
189 | 4 | this.citizenships = new ArrayList<EntityCitizenship>(); |
190 | 4 | if (CollectionUtils.isNotEmpty(builder.getCitizenships())) { |
191 | 2 | for (EntityCitizenship.Builder citizenship : builder.getCitizenships()) { |
192 | 2 | this.citizenships.add(citizenship.build()); |
193 | |
} |
194 | |
} |
195 | 4 | this.primaryEmployment = builder.getPrimaryEmployment() == null ? null : builder.getPrimaryEmployment().build(); |
196 | 4 | this.defaultAffiliation = builder.getDefaultAffiliation() == null ? null : builder.getDefaultAffiliation().build(); |
197 | 4 | this.defaultName = builder.getDefaultName() == null ? null : builder.getDefaultName().build(); |
198 | 4 | this.ethnicities = new ArrayList<EntityEthnicity>(); |
199 | 4 | if (CollectionUtils.isNotEmpty(builder.getEthnicities())) { |
200 | 2 | for (EntityEthnicity.Builder ethnicity : builder.getEthnicities()) { |
201 | 2 | this.ethnicities.add(ethnicity.build()); |
202 | |
} |
203 | |
} |
204 | 4 | this.residencies = new ArrayList<EntityResidency>(); |
205 | 4 | if (CollectionUtils.isNotEmpty(builder.getResidencies())) { |
206 | 2 | for (EntityResidency.Builder residency : builder.getResidencies()) { |
207 | 2 | this.residencies.add(residency.build()); |
208 | |
} |
209 | |
} |
210 | 4 | this.visas = new ArrayList<EntityVisa>(); |
211 | 4 | if (CollectionUtils.isNotEmpty(builder.getVisas())) { |
212 | 2 | for (EntityVisa.Builder visa : builder.getVisas()) { |
213 | 2 | this.visas.add(visa.build()); |
214 | |
} |
215 | |
} |
216 | 4 | this.versionNumber = builder.getVersionNumber(); |
217 | 4 | this.objectId = builder.getObjectId(); |
218 | 4 | this.active = builder.isActive(); |
219 | 4 | this.id = builder.getId(); |
220 | 4 | } |
221 | |
|
222 | |
@Override |
223 | |
public List<Principal> getPrincipals() { |
224 | 2 | return this.principals; |
225 | |
} |
226 | |
|
227 | |
@Override |
228 | |
public List<EntityTypeContactInfo> getEntityTypeContactInfos() { |
229 | 2 | return this.entityTypeContactInfos; |
230 | |
} |
231 | |
|
232 | |
@Override |
233 | |
public List<EntityExternalIdentifier> getExternalIdentifiers() { |
234 | 2 | return this.externalIdentifiers; |
235 | |
} |
236 | |
|
237 | |
@Override |
238 | |
public List<EntityAffiliation> getAffiliations() { |
239 | 2 | return this.affiliations; |
240 | |
} |
241 | |
|
242 | |
@Override |
243 | |
public List<EntityName> getNames() { |
244 | 2 | return this.names; |
245 | |
} |
246 | |
|
247 | |
@Override |
248 | |
public List<EntityEmployment> getEmploymentInformation() { |
249 | 2 | return this.employmentInformation; |
250 | |
} |
251 | |
|
252 | |
@Override |
253 | |
public EntityPrivacyPreferences getPrivacyPreferences() { |
254 | 1 | return this.privacyPreferences; |
255 | |
} |
256 | |
|
257 | |
@Override |
258 | |
public EntityBioDemographics getBioDemographics() { |
259 | 1 | return this.bioDemographics; |
260 | |
} |
261 | |
|
262 | |
@Override |
263 | |
public List<EntityCitizenship> getCitizenships() { |
264 | 2 | return this.citizenships; |
265 | |
} |
266 | |
|
267 | |
@Override |
268 | |
public EntityEmployment getPrimaryEmployment() { |
269 | 0 | return this.primaryEmployment; |
270 | |
} |
271 | |
|
272 | |
@Override |
273 | |
public EntityAffiliation getDefaultAffiliation() { |
274 | 0 | return this.defaultAffiliation; |
275 | |
} |
276 | |
|
277 | |
@Override |
278 | |
public EntityExternalIdentifier getEntityExternalIdentifier(String externalIdentifierTypeCode) { |
279 | 0 | if (externalIdentifiers == null) { |
280 | 0 | return null; |
281 | |
} |
282 | 0 | for (EntityExternalIdentifier externalId : externalIdentifiers) { |
283 | 0 | if (externalId.getExternalIdentifierTypeCode().equals(externalIdentifierTypeCode)) { |
284 | 0 | return externalId; |
285 | |
} |
286 | |
} |
287 | 0 | return null; |
288 | |
} |
289 | |
|
290 | |
@Override |
291 | |
public EntityNameContract getDefaultName() { |
292 | 0 | return this.defaultName; |
293 | |
} |
294 | |
|
295 | |
@Override |
296 | |
public List<EntityEthnicity> getEthnicities() { |
297 | 2 | return this.ethnicities; |
298 | |
} |
299 | |
|
300 | |
@Override |
301 | |
public List<EntityResidency> getResidencies() { |
302 | 2 | return this.residencies; |
303 | |
} |
304 | |
|
305 | |
@Override |
306 | |
public List<EntityVisa> getVisas() { |
307 | 2 | return this.visas; |
308 | |
} |
309 | |
|
310 | |
@Override |
311 | |
public Long getVersionNumber() { |
312 | 1 | return this.versionNumber; |
313 | |
} |
314 | |
|
315 | |
@Override |
316 | |
public String getObjectId() { |
317 | 1 | return this.objectId; |
318 | |
} |
319 | |
|
320 | |
@Override |
321 | |
public boolean isActive() { |
322 | 1 | return this.active; |
323 | |
} |
324 | |
|
325 | |
@Override |
326 | |
public String getId() { |
327 | 1 | return this.id; |
328 | |
} |
329 | |
|
330 | |
public EntityTypeContactInfo getEntityTypeContactInfoByTypeCode(String entityTypeCode) { |
331 | 0 | if (entityTypeContactInfos == null) { |
332 | 0 | return null; |
333 | |
} |
334 | 0 | for (EntityTypeContactInfo entType : entityTypeContactInfos) { |
335 | 0 | if (entType.getEntityTypeCode().equals(entityTypeCode)) { |
336 | 0 | return entType; |
337 | |
} |
338 | |
} |
339 | 0 | return null; |
340 | |
} |
341 | |
|
342 | |
|
343 | |
|
344 | |
|
345 | |
|
346 | 4 | public final static class Builder |
347 | |
implements Serializable, ModelBuilder, EntityContract |
348 | |
{ |
349 | |
|
350 | |
private List<Principal.Builder> principals; |
351 | |
private List<EntityTypeContactInfo.Builder> entityTypeContactInfos; |
352 | |
private List<EntityExternalIdentifier.Builder> externalIdentifiers; |
353 | |
private List<EntityAffiliation.Builder> affiliations; |
354 | |
private List<EntityName.Builder> names; |
355 | |
private List<EntityEmployment.Builder> employmentInformation; |
356 | |
private EntityPrivacyPreferences.Builder privacyPreferences; |
357 | |
private EntityBioDemographics.Builder bioDemographics; |
358 | |
private List<EntityCitizenship.Builder> citizenships; |
359 | |
private List<EntityEthnicity.Builder> ethnicities; |
360 | |
private List<EntityResidency.Builder> residencies; |
361 | |
private List<EntityVisa.Builder> visas; |
362 | |
private Long versionNumber; |
363 | |
private String objectId; |
364 | |
private boolean active; |
365 | |
private String id; |
366 | |
|
367 | 6 | private Builder() { } |
368 | |
|
369 | |
public static Builder create() { |
370 | 6 | return new Builder(); |
371 | |
} |
372 | |
|
373 | |
public static Builder create(EntityContract contract) { |
374 | 3 | if (contract == null) { |
375 | 0 | throw new IllegalArgumentException("contract was null"); |
376 | |
} |
377 | 3 | Builder builder = create(); |
378 | 3 | if (contract.getPrincipals() != null) { |
379 | 3 | List<Principal.Builder> tempPrincipals = new ArrayList<Principal.Builder>(); |
380 | 3 | for (PrincipalContract principal : contract.getPrincipals()) { |
381 | 2 | tempPrincipals.add(Principal.Builder.create(principal)); |
382 | |
} |
383 | 3 | builder.setPrincipals(tempPrincipals); |
384 | |
} |
385 | 3 | if (contract.getEntityTypeContactInfos() != null) { |
386 | 3 | List<EntityTypeContactInfo.Builder> tempTypeData = new ArrayList<EntityTypeContactInfo.Builder>(); |
387 | 3 | for (EntityTypeContactInfoContract typeData : contract.getEntityTypeContactInfos()) { |
388 | 2 | tempTypeData.add(EntityTypeContactInfo.Builder.create(typeData)); |
389 | |
} |
390 | 3 | builder.setEntityTypes(tempTypeData); |
391 | |
} |
392 | 3 | if (contract.getExternalIdentifiers() != null) { |
393 | 3 | List<EntityExternalIdentifier.Builder> externalIds = new ArrayList<EntityExternalIdentifier.Builder>(); |
394 | 3 | for (EntityExternalIdentifierContract externalId : contract.getExternalIdentifiers()) { |
395 | 2 | externalIds.add(EntityExternalIdentifier.Builder.create(externalId)); |
396 | |
} |
397 | 3 | builder.setExternalIdentifiers(externalIds); |
398 | |
} |
399 | 3 | if (contract.getAffiliations() != null) { |
400 | 3 | List<EntityAffiliation.Builder> affils = new ArrayList<EntityAffiliation.Builder>(); |
401 | 3 | for (EntityAffiliationContract affil : contract.getAffiliations()) { |
402 | 2 | affils.add(EntityAffiliation.Builder.create(affil)); |
403 | |
} |
404 | 3 | builder.setAffiliations(affils); |
405 | |
} |
406 | 3 | if (contract.getNames() != null) { |
407 | 3 | List<EntityName.Builder> nms = new ArrayList<EntityName.Builder>(); |
408 | 3 | for (EntityNameContract nm : contract.getNames()) { |
409 | 2 | nms.add(EntityName.Builder.create(nm)); |
410 | |
} |
411 | 3 | builder.setNames(nms); |
412 | |
} |
413 | 3 | if (contract.getEmploymentInformation() != null) { |
414 | 3 | List<EntityEmployment.Builder> emps = new ArrayList<EntityEmployment.Builder>(); |
415 | 3 | for (EntityEmploymentContract emp : contract.getEmploymentInformation()) { |
416 | 2 | emps.add(EntityEmployment.Builder.create(emp)); |
417 | |
} |
418 | 3 | builder.setEmploymentInformation(emps); |
419 | |
} |
420 | 3 | builder.setPrivacyPreferences(contract.getPrivacyPreferences() == null ? null : EntityPrivacyPreferences.Builder.create(contract.getPrivacyPreferences())); |
421 | 3 | builder.setBioDemographics(contract.getBioDemographics() == null ? null : EntityBioDemographics.Builder.create(contract.getBioDemographics())); |
422 | 3 | if (contract.getCitizenships() != null) { |
423 | 3 | List<EntityCitizenship.Builder> cits = new ArrayList<EntityCitizenship.Builder>(); |
424 | 3 | for (EntityCitizenshipContract cit : contract.getCitizenships()) { |
425 | 2 | cits.add(EntityCitizenship.Builder.create(cit)); |
426 | |
} |
427 | 3 | builder.setCitizenships(cits); |
428 | |
} |
429 | 3 | if (contract.getEthnicities() != null) { |
430 | 3 | List<EntityEthnicity.Builder> ethnctys = new ArrayList<EntityEthnicity.Builder>(); |
431 | 3 | for (EntityEthnicityContract ethncty : contract.getEthnicities()) { |
432 | 2 | ethnctys.add(EntityEthnicity.Builder.create(ethncty)); |
433 | |
} |
434 | 3 | builder.setEthnicities(ethnctys); |
435 | |
} |
436 | 3 | if (contract.getResidencies() != null) { |
437 | 3 | List<EntityResidency.Builder> residencyBuilders = new ArrayList<EntityResidency.Builder>(); |
438 | 3 | for (EntityResidencyContract residency : contract.getResidencies()) { |
439 | 2 | residencyBuilders.add(EntityResidency.Builder.create(residency)); |
440 | |
} |
441 | 3 | builder.setResidencies(residencyBuilders); |
442 | |
} |
443 | 3 | if (contract.getVisas() != null) { |
444 | 3 | List<EntityVisa.Builder> visaBuilders = new ArrayList<EntityVisa.Builder>(); |
445 | 3 | for (EntityVisaContract visa : contract.getVisas()) { |
446 | 2 | visaBuilders.add(EntityVisa.Builder.create(visa)); |
447 | |
} |
448 | 3 | builder.setVisas(visaBuilders); |
449 | |
} |
450 | 3 | builder.setVersionNumber(contract.getVersionNumber()); |
451 | 3 | builder.setObjectId(contract.getObjectId()); |
452 | 3 | builder.setActive(contract.isActive()); |
453 | 3 | builder.setId(contract.getId()); |
454 | 3 | return builder; |
455 | |
} |
456 | |
|
457 | |
public Entity build() { |
458 | 4 | return new Entity(this); |
459 | |
} |
460 | |
|
461 | |
@Override |
462 | |
public List<Principal.Builder> getPrincipals() { |
463 | 6 | return this.principals; |
464 | |
} |
465 | |
|
466 | |
@Override |
467 | |
public List<EntityTypeContactInfo.Builder> getEntityTypeContactInfos() { |
468 | 6 | return this.entityTypeContactInfos; |
469 | |
} |
470 | |
|
471 | |
@Override |
472 | |
public List<EntityExternalIdentifier.Builder> getExternalIdentifiers() { |
473 | 6 | return this.externalIdentifiers; |
474 | |
} |
475 | |
|
476 | |
@Override |
477 | |
public List<EntityAffiliation.Builder> getAffiliations() { |
478 | 6 | return this.affiliations; |
479 | |
} |
480 | |
|
481 | |
@Override |
482 | |
public List<EntityName.Builder> getNames() { |
483 | 6 | return this.names; |
484 | |
} |
485 | |
|
486 | |
@Override |
487 | |
public List<EntityEmployment.Builder> getEmploymentInformation() { |
488 | 6 | return this.employmentInformation; |
489 | |
} |
490 | |
|
491 | |
@Override |
492 | |
public EntityPrivacyPreferences.Builder getPrivacyPreferences() { |
493 | 6 | return this.privacyPreferences; |
494 | |
} |
495 | |
|
496 | |
@Override |
497 | |
public EntityBioDemographics.Builder getBioDemographics() { |
498 | 6 | return this.bioDemographics; |
499 | |
} |
500 | |
|
501 | |
@Override |
502 | |
public List<EntityCitizenship.Builder> getCitizenships() { |
503 | 6 | return this.citizenships; |
504 | |
} |
505 | |
|
506 | |
@Override |
507 | |
public EntityTypeContactInfo.Builder getEntityTypeContactInfoByTypeCode(String entityTypeCode) { |
508 | 0 | if (CollectionUtils.isEmpty(this.entityTypeContactInfos)) { |
509 | 0 | return null; |
510 | |
} |
511 | 0 | for (EntityTypeContactInfo.Builder builder : this.entityTypeContactInfos) { |
512 | 0 | if (builder.getEntityTypeCode().equals(entityTypeCode) && builder.isActive()) { |
513 | 0 | return builder; |
514 | |
} |
515 | |
} |
516 | 0 | return null; |
517 | |
} |
518 | |
|
519 | |
@Override |
520 | |
public EntityEmployment.Builder getPrimaryEmployment() { |
521 | 4 | if (CollectionUtils.isEmpty(this.employmentInformation)) { |
522 | 2 | return null; |
523 | |
} |
524 | 2 | for (EntityEmployment.Builder builder : this.employmentInformation) { |
525 | 2 | if (builder.isPrimary() |
526 | |
&& builder.isActive()) { |
527 | 0 | return builder; |
528 | |
} |
529 | |
} |
530 | 2 | return null; |
531 | |
} |
532 | |
|
533 | |
@Override |
534 | |
public EntityAffiliation.Builder getDefaultAffiliation() { |
535 | 6 | if (CollectionUtils.isEmpty(this.affiliations)) { |
536 | 2 | return null; |
537 | |
} |
538 | 4 | for (EntityAffiliation.Builder builder : this.affiliations) { |
539 | 4 | if (builder.isDefaultValue() |
540 | |
&& builder.isActive()) { |
541 | 4 | return builder; |
542 | |
} |
543 | |
} |
544 | 0 | return null; |
545 | |
} |
546 | |
|
547 | |
@Override |
548 | |
public EntityExternalIdentifier.Builder getEntityExternalIdentifier(String externalIdentifierTypeCode) { |
549 | 0 | if (CollectionUtils.isEmpty(this.externalIdentifiers)) { |
550 | 0 | return null; |
551 | |
} |
552 | 0 | for (EntityExternalIdentifier.Builder builder : this.externalIdentifiers) { |
553 | 0 | if (builder.getExternalIdentifierTypeCode().equals(externalIdentifierTypeCode)) { |
554 | 0 | return builder; |
555 | |
} |
556 | |
} |
557 | 0 | return null; |
558 | |
} |
559 | |
|
560 | |
@Override |
561 | |
public EntityName.Builder getDefaultName() { |
562 | 6 | if (CollectionUtils.isEmpty(this.names)) { |
563 | 2 | return null; |
564 | |
} |
565 | 4 | for (EntityName.Builder builder : this.names) { |
566 | 4 | if (builder.isDefaultValue() |
567 | |
&& builder.isActive()) { |
568 | 4 | return builder; |
569 | |
} |
570 | |
} |
571 | 0 | return null; |
572 | |
} |
573 | |
|
574 | |
@Override |
575 | |
public List<EntityEthnicity.Builder> getEthnicities() { |
576 | 6 | return this.ethnicities; |
577 | |
} |
578 | |
|
579 | |
@Override |
580 | |
public List<EntityResidency.Builder> getResidencies() { |
581 | 6 | return this.residencies; |
582 | |
} |
583 | |
|
584 | |
@Override |
585 | |
public List<EntityVisa.Builder> getVisas() { |
586 | 6 | return this.visas; |
587 | |
} |
588 | |
|
589 | |
@Override |
590 | |
public Long getVersionNumber() { |
591 | 4 | return this.versionNumber; |
592 | |
} |
593 | |
|
594 | |
@Override |
595 | |
public String getObjectId() { |
596 | 4 | return this.objectId; |
597 | |
} |
598 | |
|
599 | |
@Override |
600 | |
public boolean isActive() { |
601 | 4 | return this.active; |
602 | |
} |
603 | |
|
604 | |
@Override |
605 | |
public String getId() { |
606 | 4 | return this.id; |
607 | |
} |
608 | |
|
609 | |
public void setPrincipals(List<Principal.Builder> principals) { |
610 | 3 | this.principals = principals; |
611 | 3 | } |
612 | |
|
613 | |
public void setEntityTypes(List<EntityTypeContactInfo.Builder> entityTypeContactInfos) { |
614 | 3 | this.entityTypeContactInfos = entityTypeContactInfos; |
615 | 3 | } |
616 | |
|
617 | |
public void setExternalIdentifiers(List<EntityExternalIdentifier.Builder> externalIdentifiers) { |
618 | 3 | this.externalIdentifiers = externalIdentifiers; |
619 | 3 | } |
620 | |
|
621 | |
public void setAffiliations(List<EntityAffiliation.Builder> affiliations) { |
622 | 3 | this.affiliations = affiliations; |
623 | 3 | } |
624 | |
|
625 | |
public void setNames(List<EntityName.Builder> names) { |
626 | 3 | this.names = names; |
627 | 3 | } |
628 | |
|
629 | |
public void setEmploymentInformation(List<EntityEmployment.Builder> employmentInformation) { |
630 | 3 | this.employmentInformation = employmentInformation; |
631 | 3 | } |
632 | |
|
633 | |
public void setPrivacyPreferences(EntityPrivacyPreferences.Builder privacyPreferences) { |
634 | 3 | this.privacyPreferences = privacyPreferences; |
635 | 3 | } |
636 | |
|
637 | |
public void setBioDemographics(EntityBioDemographics.Builder bioDemographics) { |
638 | 3 | this.bioDemographics = bioDemographics; |
639 | 3 | } |
640 | |
|
641 | |
public void setCitizenships(List<EntityCitizenship.Builder> citizenships) { |
642 | 3 | this.citizenships = citizenships; |
643 | 3 | } |
644 | |
|
645 | |
public void setEthnicities(List<EntityEthnicity.Builder> ethnicities) { |
646 | 3 | this.ethnicities = ethnicities; |
647 | 3 | } |
648 | |
|
649 | |
public void setResidencies(List<EntityResidency.Builder> residencies) { |
650 | 3 | this.residencies = residencies; |
651 | 3 | } |
652 | |
|
653 | |
public void setVisas(List<EntityVisa.Builder> visas) { |
654 | 3 | this.visas = visas; |
655 | 3 | } |
656 | |
|
657 | |
public void setVersionNumber(Long versionNumber) { |
658 | 3 | this.versionNumber = versionNumber; |
659 | 3 | } |
660 | |
|
661 | |
public void setObjectId(String objectId) { |
662 | 3 | this.objectId = objectId; |
663 | 3 | } |
664 | |
|
665 | |
public void setActive(boolean active) { |
666 | 3 | this.active = active; |
667 | 3 | } |
668 | |
|
669 | |
public void setId(String id) { |
670 | 4 | if (StringUtils.isWhitespace(id)) { |
671 | 1 | throw new IllegalArgumentException("id is blank"); |
672 | |
} |
673 | 3 | this.id = id; |
674 | 3 | } |
675 | |
|
676 | |
} |
677 | |
|
678 | |
|
679 | |
|
680 | |
|
681 | |
|
682 | |
|
683 | 0 | static class Constants { |
684 | |
|
685 | |
final static String ROOT_ELEMENT_NAME = "entity"; |
686 | |
final static String TYPE_NAME = "EntityType"; |
687 | 0 | final static String[] HASH_CODE_EQUALS_EXCLUDE = new String[] {CoreConstants.CommonElements.FUTURE_ELEMENTS }; |
688 | |
|
689 | |
} |
690 | |
|
691 | |
|
692 | |
|
693 | |
|
694 | |
|
695 | |
|
696 | 0 | static class Elements { |
697 | |
|
698 | |
final static String PRINCIPALS = "principals"; |
699 | |
final static String PRINCIPAL = "principal"; |
700 | |
final static String ENTITY_TYPE_CONTACT_INFOS = "entityTypeContactInfos"; |
701 | |
final static String ENTITY_TYPE_CONTACT_INFO = "entityTypeContactInfo"; |
702 | |
final static String EXTERNAL_IDENTIFIERS = "externalIdentifiers"; |
703 | |
final static String EXTERNAL_IDENTIFIER = "externalIdentifier"; |
704 | |
final static String AFFILIATIONS = "affiliations"; |
705 | |
final static String AFFILIATION = "affiliation"; |
706 | |
final static String NAMES = "names"; |
707 | |
final static String NAME = "name"; |
708 | |
final static String EMPLOYMENT_INFORMATION = "employmentInformation"; |
709 | |
final static String EMPLOYMENT = "employment"; |
710 | |
final static String PRIVACY_PREFERENCES = "privacyPreferences"; |
711 | |
final static String BIO_DEMOGRAPHICS = "bioDemographics"; |
712 | |
final static String CITIZENSHIPS = "citizenships"; |
713 | |
final static String CITIZENSHIP = "citizenship"; |
714 | |
final static String PRIMARY_EMPLOYMENT = "primaryEmployment"; |
715 | |
final static String DEFAULT_AFFILIATION = "defaultAffiliation"; |
716 | |
final static String DEFAULT_NAME = "defaultName"; |
717 | |
final static String ETHNICITIES = "ethnicities"; |
718 | |
final static String ETHNICITY = "ethnicity"; |
719 | |
final static String RESIDENCIES = "residencies"; |
720 | |
final static String RESIDENCY = "residency"; |
721 | |
final static String VISAS = "visas"; |
722 | |
final static String VISA = "visa"; |
723 | |
final static String ACTIVE = "active"; |
724 | |
final static String ID = "id"; |
725 | |
|
726 | |
} |
727 | |
|
728 | |
} |