Contacts contacts = entity.getContacts();
if (contacts != null) {
List<Contact> contactList = contacts.getContact();
boolean isFirst=true;
for (Contact contact : contactList) {
User user = new UserImpl(null);
List<PersonName> pnames = (List<PersonName>) contact.getPersonName();
String pname = null;
if (pnames != null && pnames.size() > 0) {
PersonName personname = pnames.get(0);
pname = personname.getValue();
}
user.setType(contact.getUseType());
user.setPersonName(new PersonNameImpl(pname));
List<Email> emailList = contact.getEmail();
ArrayList<EmailAddress> tempEmails = new ArrayList<EmailAddress>();
for (Email email : emailList) {
tempEmails.add(new EmailAddressImpl(email.getValue(), null));
}
user.setEmailAddresses(tempEmails);
List<Address> addressList = contact.getAddress();
ArrayList<PostalAddress> tempAddresses = new ArrayList<PostalAddress>();
for (Address address : addressList) {
ArrayList<AddressLine> addressLineList = new ArrayList<AddressLine>(address.getAddressLine());
AddressLine[] alines = new AddressLine[addressLineList.size()];
addressLineList.toArray(alines);
PostalAddress pa = getPostalAddress(alines);
tempAddresses.add(pa);
}
user.setPostalAddresses(tempAddresses);
List<Phone> phoneList = contact.getPhone();
ArrayList<TelephoneNumber> tempPhones = new ArrayList<TelephoneNumber>();
for (Phone phone : phoneList) {
TelephoneNumberImpl tni = new TelephoneNumberImpl();
tni.setType(phone.getUseType());
tni.setNumber(phone.getValue());
tempPhones.add(tni);
}
user.setTelephoneNumbers(tempPhones);
if (isFirst) {
isFirst=false;
org.setPrimaryContact(user);
} else {
org.addUser(user);