| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.kuali.rice.kim.api.identity.type; |
| 17 | |
|
| 18 | |
import org.apache.commons.collections.CollectionUtils; |
| 19 | |
import org.apache.commons.lang.StringUtils; |
| 20 | |
import org.kuali.rice.core.api.CoreConstants; |
| 21 | |
import org.kuali.rice.core.api.mo.AbstractDataTransferObject; |
| 22 | |
import org.kuali.rice.core.api.mo.ModelBuilder; |
| 23 | |
import org.kuali.rice.kim.api.identity.EntityUtils; |
| 24 | |
import org.kuali.rice.kim.api.identity.CodedAttribute; |
| 25 | |
import org.kuali.rice.kim.api.identity.CodedAttributeContract; |
| 26 | |
import org.kuali.rice.kim.api.identity.address.EntityAddress; |
| 27 | |
import org.kuali.rice.kim.api.identity.address.EntityAddressContract; |
| 28 | |
import org.kuali.rice.kim.api.identity.email.EntityEmail; |
| 29 | |
import org.kuali.rice.kim.api.identity.email.EntityEmailContract; |
| 30 | |
import org.kuali.rice.kim.api.identity.phone.EntityPhone; |
| 31 | |
import org.kuali.rice.kim.api.identity.phone.EntityPhoneContract; |
| 32 | |
import org.w3c.dom.Element; |
| 33 | |
|
| 34 | |
import javax.xml.bind.annotation.XmlAccessType; |
| 35 | |
import javax.xml.bind.annotation.XmlAccessorType; |
| 36 | |
import javax.xml.bind.annotation.XmlAnyElement; |
| 37 | |
import javax.xml.bind.annotation.XmlElement; |
| 38 | |
import javax.xml.bind.annotation.XmlElementWrapper; |
| 39 | |
import javax.xml.bind.annotation.XmlRootElement; |
| 40 | |
import javax.xml.bind.annotation.XmlType; |
| 41 | |
import java.io.Serializable; |
| 42 | |
import java.util.ArrayList; |
| 43 | |
import java.util.Collection; |
| 44 | |
import java.util.List; |
| 45 | |
|
| 46 | 0 | @XmlRootElement(name = EntityTypeContactInfo.Constants.ROOT_ELEMENT_NAME) |
| 47 | |
@XmlAccessorType(XmlAccessType.NONE) |
| 48 | |
@XmlType(name = EntityTypeContactInfo.Constants.TYPE_NAME, propOrder = { |
| 49 | |
EntityTypeContactInfo.Elements.ENTITY_ID, |
| 50 | |
EntityTypeContactInfo.Elements.ENTITY_TYPE_CODE, |
| 51 | |
EntityTypeContactInfo.Elements.ENTITY_TYPE, |
| 52 | |
EntityTypeContactInfo.Elements.ADDRESSES, |
| 53 | |
EntityTypeContactInfo.Elements.EMAIL_ADDRESSES, |
| 54 | |
EntityTypeContactInfo.Elements.PHONE_NUMBERS, |
| 55 | |
EntityTypeContactInfo.Elements.DEFAULT_ADDRESS, |
| 56 | |
EntityTypeContactInfo.Elements.DEFAULT_EMAIL_ADDRESS, |
| 57 | |
EntityTypeContactInfo.Elements.DEFAULT_PHONE_NUMBER, |
| 58 | |
CoreConstants.CommonElements.VERSION_NUMBER, |
| 59 | |
CoreConstants.CommonElements.OBJECT_ID, |
| 60 | |
EntityTypeContactInfo.Elements.ACTIVE, |
| 61 | |
CoreConstants.CommonElements.FUTURE_ELEMENTS |
| 62 | |
}) |
| 63 | 0 | public final class EntityTypeContactInfo extends AbstractDataTransferObject |
| 64 | |
implements EntityTypeContactInfoContract |
| 65 | |
{ |
| 66 | |
|
| 67 | |
@XmlElement(name = Elements.ENTITY_ID, required = true) |
| 68 | |
private final String entityId; |
| 69 | |
@XmlElement(name = Elements.ENTITY_TYPE_CODE, required = true) |
| 70 | |
private final String entityTypeCode; |
| 71 | |
@XmlElement(name = Elements.ENTITY_TYPE, required = false) |
| 72 | |
private final CodedAttribute entityType; |
| 73 | |
@XmlElementWrapper(name = Elements.ADDRESSES, required = false) |
| 74 | |
@XmlElement(name = Elements.ADDRESS, required = false) |
| 75 | |
private final List<EntityAddress> addresses; |
| 76 | |
@XmlElementWrapper(name = Elements.EMAIL_ADDRESSES, required = false) |
| 77 | |
@XmlElement(name = Elements.EMAIL_ADDRESS, required = false) |
| 78 | |
private final List<EntityEmail> emailAddresses; |
| 79 | |
@XmlElementWrapper(name = Elements.PHONE_NUMBERS, required = false) |
| 80 | |
@XmlElement(name = Elements.PHONE_NUMBER, required = false) |
| 81 | |
private final List<EntityPhone> phoneNumbers; |
| 82 | |
@XmlElement(name = Elements.DEFAULT_ADDRESS, required = false) |
| 83 | |
private final EntityAddress defaultAddress; |
| 84 | |
@XmlElement(name = Elements.DEFAULT_EMAIL_ADDRESS, required = false) |
| 85 | |
private final EntityEmail defaultEmailAddress; |
| 86 | |
@XmlElement(name = Elements.DEFAULT_PHONE_NUMBER, required = false) |
| 87 | |
private final EntityPhone defaultPhoneNumber; |
| 88 | |
@XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false) |
| 89 | |
private final Long versionNumber; |
| 90 | |
@XmlElement(name = CoreConstants.CommonElements.OBJECT_ID, required = false) |
| 91 | |
private final String objectId; |
| 92 | |
@XmlElement(name = Elements.ACTIVE, required = false) |
| 93 | |
private final boolean active; |
| 94 | 0 | @SuppressWarnings("unused") |
| 95 | |
@XmlAnyElement |
| 96 | |
private final Collection<Element> _futureElements = null; |
| 97 | |
|
| 98 | |
|
| 99 | |
|
| 100 | |
|
| 101 | 0 | private EntityTypeContactInfo() { |
| 102 | 0 | this.entityId = null; |
| 103 | 0 | this.entityTypeCode = null; |
| 104 | 0 | this.entityType = null; |
| 105 | 0 | this.addresses = null; |
| 106 | 0 | this.emailAddresses = null; |
| 107 | 0 | this.phoneNumbers = null; |
| 108 | 0 | this.defaultAddress = null; |
| 109 | 0 | this.defaultEmailAddress = null; |
| 110 | 0 | this.defaultPhoneNumber = null; |
| 111 | 0 | this.versionNumber = null; |
| 112 | 0 | this.objectId = null; |
| 113 | 0 | this.active = false; |
| 114 | 0 | } |
| 115 | |
|
| 116 | 0 | private EntityTypeContactInfo(Builder builder) { |
| 117 | 0 | this.entityId = builder.getEntityId(); |
| 118 | 0 | this.entityTypeCode = builder.getEntityTypeCode(); |
| 119 | 0 | this.entityType = (builder.getEntityType() != null) ? builder.getEntityType().build() : null; |
| 120 | 0 | this.addresses = new ArrayList<EntityAddress>(); |
| 121 | 0 | if (!CollectionUtils.isEmpty(builder.getAddresses())) { |
| 122 | 0 | for (EntityAddress.Builder address : builder.getAddresses()) { |
| 123 | 0 | this.addresses.add(address.build()); |
| 124 | |
} |
| 125 | |
} |
| 126 | |
|
| 127 | 0 | this.emailAddresses = new ArrayList<EntityEmail>(); |
| 128 | 0 | if (!CollectionUtils.isEmpty(builder.getEmailAddresses())) { |
| 129 | 0 | for (EntityEmail.Builder email : builder.getEmailAddresses()) { |
| 130 | 0 | this.emailAddresses.add(email.build()); |
| 131 | |
} |
| 132 | |
} |
| 133 | 0 | this.phoneNumbers = new ArrayList<EntityPhone>(); |
| 134 | 0 | if (!CollectionUtils.isEmpty(builder.getPhoneNumbers())) { |
| 135 | 0 | for (EntityPhone.Builder phoneNumber : builder.getPhoneNumbers()) { |
| 136 | 0 | this.phoneNumbers.add(phoneNumber.build()); |
| 137 | |
} |
| 138 | |
} |
| 139 | 0 | this.defaultAddress = builder.getDefaultAddress() != null ? builder.getDefaultAddress().build() : null; |
| 140 | 0 | this.defaultEmailAddress = builder.getDefaultEmailAddress() != null ? builder.getDefaultEmailAddress().build() : null; |
| 141 | 0 | this.defaultPhoneNumber = builder.getDefaultPhoneNumber() != null ? builder.getDefaultPhoneNumber().build() : null; |
| 142 | 0 | this.versionNumber = builder.getVersionNumber(); |
| 143 | 0 | this.objectId = builder.getObjectId(); |
| 144 | 0 | this.active = builder.isActive(); |
| 145 | 0 | } |
| 146 | |
|
| 147 | |
@Override |
| 148 | |
public String getEntityId() { |
| 149 | 0 | return this.entityId; |
| 150 | |
} |
| 151 | |
|
| 152 | |
@Override |
| 153 | |
public String getEntityTypeCode() { |
| 154 | 0 | return this.entityTypeCode; |
| 155 | |
} |
| 156 | |
|
| 157 | |
@Override |
| 158 | |
public CodedAttributeContract getEntityType() { |
| 159 | 0 | return this.entityType; |
| 160 | |
} |
| 161 | |
|
| 162 | |
@Override |
| 163 | |
public List<EntityAddress> getAddresses() { |
| 164 | 0 | return this.addresses; |
| 165 | |
} |
| 166 | |
|
| 167 | |
@Override |
| 168 | |
public List<EntityEmail> getEmailAddresses() { |
| 169 | 0 | return this.emailAddresses; |
| 170 | |
} |
| 171 | |
|
| 172 | |
@Override |
| 173 | |
public List<EntityPhone> getPhoneNumbers() { |
| 174 | 0 | return this.phoneNumbers; |
| 175 | |
} |
| 176 | |
|
| 177 | |
@Override |
| 178 | |
public EntityAddressContract getDefaultAddress() { |
| 179 | 0 | return this.defaultAddress; |
| 180 | |
} |
| 181 | |
|
| 182 | |
@Override |
| 183 | |
public EntityEmail getDefaultEmailAddress() { |
| 184 | 0 | return this.defaultEmailAddress; |
| 185 | |
} |
| 186 | |
|
| 187 | |
@Override |
| 188 | |
public EntityPhoneContract getDefaultPhoneNumber() { |
| 189 | 0 | return this.defaultPhoneNumber; |
| 190 | |
} |
| 191 | |
|
| 192 | |
@Override |
| 193 | |
public Long getVersionNumber() { |
| 194 | 0 | return this.versionNumber; |
| 195 | |
} |
| 196 | |
|
| 197 | |
@Override |
| 198 | |
public String getObjectId() { |
| 199 | 0 | return this.objectId; |
| 200 | |
} |
| 201 | |
|
| 202 | |
@Override |
| 203 | |
public boolean isActive() { |
| 204 | 0 | return this.active; |
| 205 | |
} |
| 206 | |
|
| 207 | |
|
| 208 | |
|
| 209 | |
|
| 210 | |
|
| 211 | |
|
| 212 | 0 | public final static class Builder |
| 213 | |
implements Serializable, ModelBuilder, EntityTypeContactInfoContract |
| 214 | |
{ |
| 215 | |
private String entityId; |
| 216 | |
private String entityTypeCode; |
| 217 | |
private CodedAttribute.Builder entityType; |
| 218 | |
private List<EntityAddress.Builder> addresses; |
| 219 | |
private List<EntityEmail.Builder> emailAddresses; |
| 220 | |
private List<EntityPhone.Builder> phoneNumbers; |
| 221 | |
private Long versionNumber; |
| 222 | |
private String objectId; |
| 223 | |
private boolean active; |
| 224 | |
|
| 225 | 0 | private Builder(String entityId, String entityTypeCode) { |
| 226 | 0 | setEntityId(entityId); |
| 227 | 0 | setEntityTypeCode(entityTypeCode); |
| 228 | 0 | setEntityType(CodedAttribute.Builder.create(entityTypeCode)); |
| 229 | 0 | } |
| 230 | |
|
| 231 | |
public static Builder create(String entityId, String entityTypeCode) { |
| 232 | 0 | return new Builder(entityId, entityTypeCode); |
| 233 | |
} |
| 234 | |
|
| 235 | |
public static Builder create(EntityTypeContactInfoContract contract) { |
| 236 | 0 | if (contract == null) { |
| 237 | 0 | throw new IllegalArgumentException("contract was null"); |
| 238 | |
} |
| 239 | 0 | Builder builder = create(contract.getEntityId(), contract.getEntityTypeCode()); |
| 240 | 0 | if (contract.getEntityType() != null) { |
| 241 | 0 | builder.setEntityType(CodedAttribute.Builder.create(contract.getEntityType())); |
| 242 | |
} |
| 243 | 0 | builder.addresses = new ArrayList<EntityAddress.Builder>(); |
| 244 | 0 | if (!CollectionUtils.isEmpty(contract.getAddresses())) { |
| 245 | 0 | for (EntityAddressContract addressContract : contract.getAddresses()) { |
| 246 | 0 | builder.addresses.add(EntityAddress.Builder.create(addressContract)); |
| 247 | |
} |
| 248 | |
} |
| 249 | 0 | builder.emailAddresses = new ArrayList<EntityEmail.Builder>(); |
| 250 | 0 | if (!CollectionUtils.isEmpty(contract.getEmailAddresses())) { |
| 251 | 0 | for (EntityEmailContract emailContract : contract.getEmailAddresses()) { |
| 252 | 0 | builder.emailAddresses.add(EntityEmail.Builder.create(emailContract)); |
| 253 | |
} |
| 254 | |
} |
| 255 | 0 | builder.phoneNumbers = new ArrayList<EntityPhone.Builder>(); |
| 256 | 0 | if (!CollectionUtils.isEmpty(contract.getPhoneNumbers())) { |
| 257 | 0 | for (EntityPhoneContract phoneContract : contract.getPhoneNumbers()) { |
| 258 | 0 | builder.phoneNumbers.add(EntityPhone.Builder.create(phoneContract)); |
| 259 | |
} |
| 260 | |
} |
| 261 | 0 | builder.setVersionNumber(contract.getVersionNumber()); |
| 262 | 0 | builder.setObjectId(contract.getObjectId()); |
| 263 | 0 | builder.setActive(contract.isActive()); |
| 264 | 0 | return builder; |
| 265 | |
} |
| 266 | |
|
| 267 | |
public EntityTypeContactInfo build() { |
| 268 | 0 | return new EntityTypeContactInfo(this); |
| 269 | |
} |
| 270 | |
|
| 271 | |
@Override |
| 272 | |
public String getEntityId() { |
| 273 | 0 | return this.entityId; |
| 274 | |
} |
| 275 | |
|
| 276 | |
@Override |
| 277 | |
public String getEntityTypeCode() { |
| 278 | 0 | return this.entityTypeCode; |
| 279 | |
} |
| 280 | |
|
| 281 | |
@Override |
| 282 | |
public CodedAttribute.Builder getEntityType() { |
| 283 | 0 | return this.entityType; |
| 284 | |
} |
| 285 | |
|
| 286 | |
@Override |
| 287 | |
public List<EntityAddress.Builder> getAddresses() { |
| 288 | 0 | return this.addresses; |
| 289 | |
} |
| 290 | |
|
| 291 | |
@Override |
| 292 | |
public List<EntityEmail.Builder> getEmailAddresses() { |
| 293 | 0 | return this.emailAddresses; |
| 294 | |
} |
| 295 | |
|
| 296 | |
@Override |
| 297 | |
public List<EntityPhone.Builder> getPhoneNumbers() { |
| 298 | 0 | return this.phoneNumbers; |
| 299 | |
} |
| 300 | |
|
| 301 | |
@Override |
| 302 | |
public EntityAddress.Builder getDefaultAddress() { |
| 303 | 0 | return EntityUtils.getDefaultItem(this.addresses); |
| 304 | |
} |
| 305 | |
|
| 306 | |
@Override |
| 307 | |
public EntityEmail.Builder getDefaultEmailAddress() { |
| 308 | 0 | return EntityUtils.getDefaultItem(this.emailAddresses); |
| 309 | |
} |
| 310 | |
|
| 311 | |
@Override |
| 312 | |
public EntityPhone.Builder getDefaultPhoneNumber() { |
| 313 | 0 | return EntityUtils.getDefaultItem(this.phoneNumbers); |
| 314 | |
} |
| 315 | |
|
| 316 | |
@Override |
| 317 | |
public Long getVersionNumber() { |
| 318 | 0 | return this.versionNumber; |
| 319 | |
} |
| 320 | |
|
| 321 | |
@Override |
| 322 | |
public String getObjectId() { |
| 323 | 0 | return this.objectId; |
| 324 | |
} |
| 325 | |
|
| 326 | |
@Override |
| 327 | |
public boolean isActive() { |
| 328 | 0 | return this.active; |
| 329 | |
} |
| 330 | |
|
| 331 | |
public void setEntityId(String entityId) { |
| 332 | 0 | if (StringUtils.isEmpty(entityId)) { |
| 333 | 0 | throw new IllegalArgumentException("entityId is empty"); |
| 334 | |
} |
| 335 | 0 | this.entityId = entityId; |
| 336 | 0 | } |
| 337 | |
|
| 338 | |
public void setEntityTypeCode(String entityTypeCode) { |
| 339 | 0 | if (StringUtils.isEmpty(entityTypeCode)) { |
| 340 | 0 | throw new IllegalArgumentException("entityTypeCode is empty"); |
| 341 | |
} |
| 342 | 0 | this.entityTypeCode = entityTypeCode; |
| 343 | 0 | } |
| 344 | |
|
| 345 | |
public void setEntityType(CodedAttribute.Builder entityType) { |
| 346 | 0 | this.entityType = entityType; |
| 347 | 0 | } |
| 348 | |
|
| 349 | |
public void setAddresses(List addresses) { |
| 350 | 0 | this.addresses = addresses; |
| 351 | 0 | } |
| 352 | |
|
| 353 | |
public void setEmailAddresses(List emailAddresses) { |
| 354 | 0 | this.emailAddresses = emailAddresses; |
| 355 | 0 | } |
| 356 | |
|
| 357 | |
public void setPhoneNumbers(List phoneNumbers) { |
| 358 | 0 | this.phoneNumbers = phoneNumbers; |
| 359 | 0 | } |
| 360 | |
|
| 361 | |
public void setVersionNumber(Long versionNumber) { |
| 362 | 0 | this.versionNumber = versionNumber; |
| 363 | 0 | } |
| 364 | |
|
| 365 | |
public void setObjectId(String objectId) { |
| 366 | 0 | this.objectId = objectId; |
| 367 | 0 | } |
| 368 | |
|
| 369 | |
public void setActive(boolean active) { |
| 370 | 0 | this.active = active; |
| 371 | 0 | } |
| 372 | |
} |
| 373 | |
|
| 374 | |
|
| 375 | |
|
| 376 | |
|
| 377 | |
|
| 378 | |
|
| 379 | 0 | static class Constants { |
| 380 | |
|
| 381 | |
final static String ROOT_ELEMENT_NAME = "entityTypeContactInfo"; |
| 382 | |
final static String TYPE_NAME = "EntityTypeContactInfoType"; |
| 383 | |
} |
| 384 | |
|
| 385 | |
|
| 386 | |
|
| 387 | |
|
| 388 | |
|
| 389 | |
|
| 390 | 0 | static class Elements { |
| 391 | |
|
| 392 | |
final static String ENTITY_ID = "entityId"; |
| 393 | |
final static String ENTITY_TYPE_CODE = "entityTypeCode"; |
| 394 | |
final static String ENTITY_TYPE = "entityType"; |
| 395 | |
final static String ADDRESSES = "addresses"; |
| 396 | |
final static String ADDRESS = "address"; |
| 397 | |
final static String EMAIL_ADDRESSES = "emailAddresses"; |
| 398 | |
final static String EMAIL_ADDRESS = "emailAddress"; |
| 399 | |
final static String PHONE_NUMBERS = "phoneNumbers"; |
| 400 | |
final static String PHONE_NUMBER = "phoneNumber"; |
| 401 | |
final static String DEFAULT_ADDRESS = "defaultAddress"; |
| 402 | |
final static String DEFAULT_EMAIL_ADDRESS = "defaultEmailAddress"; |
| 403 | |
final static String DEFAULT_PHONE_NUMBER = "defaultPhoneNumber"; |
| 404 | |
final static String ACTIVE = "active"; |
| 405 | |
|
| 406 | |
} |
| 407 | |
|
| 408 | |
} |