2 * Copyright (C) 2016 Roland Haeder
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Affero General Public License as
6 * published by the Free Software Foundation, either version 3 of the
7 * License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Affero General Public License for more details.
14 * You should have received a copy of the GNU Affero General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package org.mxchange.pizzaapplication.beans.contact;
19 import java.text.MessageFormat;
20 import java.util.Date;
21 import java.util.Iterator;
22 import java.util.List;
23 import java.util.Objects;
24 import javax.annotation.PostConstruct;
25 import javax.enterprise.context.SessionScoped;
26 import javax.enterprise.event.Observes;
27 import javax.faces.view.facelets.FaceletException;
28 import javax.inject.Inject;
29 import javax.inject.Named;
30 import javax.naming.Context;
31 import javax.naming.InitialContext;
32 import javax.naming.NamingException;
33 import org.mxchange.jcontacts.contact.Contact;
34 import org.mxchange.jcontacts.contact.ContactSessionBeanRemote;
35 import org.mxchange.jcontacts.contact.UserContact;
36 import org.mxchange.jcontacts.contact.gender.Gender;
37 import org.mxchange.jcontacts.contact.utils.ContactUtils;
38 import org.mxchange.jcontacts.events.contact.update.AdminUpdatedContactEvent;
39 import org.mxchange.jcontacts.exceptions.ContactNotFoundException;
40 import org.mxchange.jcountry.data.Country;
41 import org.mxchange.jcustomercore.events.AdminAddedCustomerEvent;
42 import org.mxchange.jphone.phonenumbers.cellphone.CellphoneNumber;
43 import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber;
44 import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
45 import org.mxchange.jphone.phonenumbers.fax.FaxNumber;
46 import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
47 import org.mxchange.jphone.phonenumbers.landline.LandLineNumber;
48 import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider;
49 import org.mxchange.jusercore.events.login.UserLoggedInEvent;
50 import org.mxchange.jusercore.events.registration.UserRegisteredEvent;
51 import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent;
52 import org.mxchange.jusercore.exceptions.UserPasswordMismatchException;
53 import org.mxchange.pizzaapplication.beans.login.PizzaUserLoginWebSessionController;
56 * A general contact bean (controller)
58 * @author Roland Haeder<roland@mxchange.org>
60 @Named ("contactController")
62 public class PizzaContactWebSessionBean implements PizzaContactWebSessionController {
67 private static final long serialVersionUID = 542_145_347_916L;
72 private Date birthday;
75 * Cellphone number's carrier
77 private MobileProvider cellphoneCarrier;
82 private Long cellphoneNumber;
92 private String comment;
97 private final ContactSessionBeanRemote contactBean;
102 private List<Contact> contactList;
107 private Country country;
112 private String emailAddress;
117 private List<String> emailAddressList;
120 * Email address repeated
122 private String emailAddressRepeat;
127 private String familyName;
130 * Fax number's area code
132 private Integer faxAreaCode;
135 * Country instance for fax number
137 private Country faxCountry;
142 private Long faxNumber;
147 private String firstName;
152 private Gender gender;
157 private Short houseNumber;
160 * Whether a cellphone entry has been unlinked
162 private boolean isCellphoneUnlinked;
165 * Whether a fax entry has been unlinked
167 private boolean isFaxUnlinked;
170 * Whether a land-line number has been unlinked
172 private boolean isLandLineUnlinked;
175 * Login bean (controller)
178 private PizzaUserLoginWebSessionController loginController;
181 * Phone number area code
183 private Integer phoneAreaCode;
186 * Country instance for phone number
188 private Country phoneCountry;
193 private Long phoneNumber;
198 private String street;
203 private Integer zipCode;
206 * Default constructor
208 public PizzaContactWebSessionBean () {
209 // Set gender to UNKNOWN
210 this.gender = Gender.UNKNOWN;
214 // Get initial context
215 Context context = new InitialContext();
218 this.contactBean = (ContactSessionBeanRemote) context.lookup("java:global/PizzaService-ejb/contact!org.mxchange.jcontacts.contact.ContactSessionBeanRemote"); //NOI18N
219 } catch (final NamingException e) {
221 throw new FaceletException(e);
226 public void addEmailAddress (final String contactEmailAddress) {
228 this.emailAddressList.add(contactEmailAddress);
232 public void afterAdminAddedCustomer (@Observes final AdminAddedCustomerEvent event) {
233 // The event must be valid
236 throw new NullPointerException("event is null"); //NOI18N
237 } else if (event.getAddedCustomer() == null) {
239 throw new NullPointerException("event.addedCustomer is null"); //NOI18N
240 } else if (event.getAddedCustomer().getCustomerId() == null) {
242 throw new NullPointerException("event.addedCustomer.customerId is null"); //NOI18N
243 } else if (event.getAddedCustomer().getCustomerId() < 1) {
245 throw new IllegalArgumentException(MessageFormat.format("event.addedCustomer.customerId={0} is not valid", event.getAddedCustomer().getCustomerId())); //NOI18N //NOI18N
252 this.contactList.add(event.getAddedCustomer().getCustomerContact());
256 public void afterAdminAddedUserEvent (@Observes final AdminAddedUserEvent event) {
257 // The event must be valid
260 throw new NullPointerException("event is null"); //NOI18N
261 } else if (event.getAddedUser() == null) {
263 throw new NullPointerException("event.addedUser is null"); //NOI18N
264 } else if (event.getAddedUser().getUserId() == null) {
266 throw new NullPointerException("event.addedUser.userId is null"); //NOI18N
267 } else if (event.getAddedUser().getUserId() < 1) {
269 throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getAddedUser(), event.getAddedUser().getUserId())); //NOI18N
270 } else if (event.getAddedUser().getUserContact() == null) {
272 throw new NullPointerException("event.addedUser.userContact is null"); //NOI18N
273 } else if (event.getAddedUser().getUserContact().getContactId() == null) {
275 throw new NullPointerException("event.addedUser.userContact.contactId is null"); //NOI18N
276 } else if (event.getAddedUser().getUserContact().getContactId() < 1) {
278 throw new IllegalArgumentException(MessageFormat.format("event.addedUser.userContact.contactId={0} is not valid", event.getAddedUser().getUserContact().getContactId())); //NOI18N
281 // Add user to local list
282 this.contactList.add(event.getAddedUser().getUserContact());
286 public void afterAdminUpdatedContactDataEvent (@Observes final AdminUpdatedContactEvent event) {
288 //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("ContactWebBean:afterAdminUpdatedContactDataEvent: event={0} - CALLED!", event)); //NOI18N
290 // event should not be null
293 throw new NullPointerException("event is null"); //NOI18N
294 } else if (event.getUpdatedContact()== null) {
296 throw new NullPointerException("event.updatedUser is null"); //NOI18N
297 } else if (event.getUpdatedContact().getContactId() == null) {
299 throw new NullPointerException("event.updatedUser.userId is null"); //NOI18N
300 } else if (event.getUpdatedContact().getContactId() < 1) {
302 throw new IllegalArgumentException(MessageFormat.format("contactId of contact={0} is not valid: {1}", event.getUpdatedContact(), event.getUpdatedContact().getContactId())); //NOI18N
305 // Get iterator from list
306 Iterator<Contact> iterator = this.contactList.iterator();
308 // "Walk" through all entries
309 while (iterator.hasNext()) {
311 Contact next = iterator.next();
313 // Is id number the same?
314 if (Objects.equals(event.getUpdatedContact().getContactId(), next.getContactId())) {
315 // Found entry, so remove it and abort
316 this.contactList.remove(next);
318 // Remove also email from list
319 this.emailAddressList.remove(next.getContactEmailAddress());
324 // Add contact to list
325 this.contactList.add(event.getUpdatedContact());
327 // Add email address to list
328 this.emailAddressList.add(event.getUpdatedContact().getContactEmailAddress());
332 public void afterRegistrationEvent (final @Observes UserRegisteredEvent event) {
334 //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("ContactWebBean:afterRegistration: event={0} - CALLED!", event)); //NOI18N
336 // event should not be null
339 throw new NullPointerException("event is null"); //NOI18N
340 } else if (event.getRegisteredUser() == null) {
342 throw new NullPointerException("event.user is null"); //NOI18N
343 } else if (event.getRegisteredUser().getUserId() == null) {
345 throw new NullPointerException("event.user.userId is null"); //NOI18N
346 } else if (event.getRegisteredUser().getUserId() < 1) {
348 throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getRegisteredUser(), event.getRegisteredUser().getUserId())); //NOI18N
352 Contact registeredContact = event.getRegisteredUser().getUserContact();
355 //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("ContactWebBean:afterRegistration: registeredContact={0}", registeredContact)); //NOI18N
356 // Copy all data from registered->user
357 this.copyContact(registeredContact);
359 // Add user name and email address
360 this.addUserNameEmailAddress(registeredContact);
366 //* NOISY-DEBUG: */ System.out.println("ContactWebBean:afterRegistration: EXIT!"); //NOI18N
370 public void afterUserLogin (final @Observes UserLoggedInEvent event) {
372 //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("ContactWebBean:afterUserLogin: event={0} - CALLED!", event)); //NOI18N
374 // event should not be null
377 throw new NullPointerException("event is null"); //NOI18N
378 } else if (event.getLoggedInUser() == null) {
380 throw new NullPointerException("event.user is null"); //NOI18N
381 } else if (event.getLoggedInUser().getUserId() == null) {
383 throw new NullPointerException("event.user.userId is null"); //NOI18N
384 } else if (event.getLoggedInUser().getUserId() < 1) {
386 throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getLoggedInUser(), event.getLoggedInUser().getUserId())); //NOI18N
389 // Copy all data to this bean
390 this.copyContact(event.getLoggedInUser().getUserContact());
393 //* NOISY-DEBUG: */ System.out.println("ContactWebBean:afterUserLogin - EXIT!"); //NOI18N
397 public List<Contact> allContacts () {
398 return this.contactList;
402 public Contact createContactInstance () {
403 // Required personal data must be set
404 assert (this.isRequiredPersonalDataSet()) : "not all personal data is set"; //NOI18N
406 // Generate phone number
407 DialableLandLineNumber phone = new LandLineNumber(this.getPhoneCountry(), this.getPhoneAreaCode(), this.getPhoneNumber());
408 DialableCellphoneNumber cellphone = new CellphoneNumber(this.getCellphoneCarrier(), this.getCellphoneNumber());
409 DialableFaxNumber fax = new FaxNumber(this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());
411 // Create new contact
412 Contact contact = new UserContact(this.getGender(), this.getFirstName(), this.getFamilyName());
413 contact.setContactStreet(this.getStreet());
414 contact.setContactHouseNumber(this.getHouseNumber());
415 contact.setContactZipCode(this.getZipCode());
416 contact.setContactCity(this.getCity());
417 contact.setContactCountry(this.getCountry());
418 contact.setContactEmailAddress(this.getEmailAddress());
419 contact.setContactBirthday(this.getBirthday());
420 contact.setContactComment(this.getComment());
423 contact.setContactOwnContact(Boolean.TRUE);
425 // Don't set null or wrong references
426 if ((phone instanceof DialableLandLineNumber) && (phone.getPhoneCountry() instanceof Country) && (this.getPhoneAreaCode() != null) && (this.getPhoneNumber() != null) && (this.getPhoneAreaCode() > 0) && (this.getPhoneNumber() > 0)) {
427 // Now the number must be given
428 if (phone.getPhoneAreaCode() == null) {
430 throw new NullPointerException("phone.phoneAreaCode is null"); //NOI18N
431 } else if (phone.getPhoneAreaCode() < 1) {
433 throw new IllegalArgumentException("phone.phoneAreaCode is zero or below."); //NOI18N
434 } else if (phone.getPhoneNumber() == null) {
436 throw new NullPointerException("phone.phoneNumber is null"); //NOI18N
437 } else if (phone.getPhoneNumber() < 1) {
439 throw new IllegalArgumentException("phone.phoneNumber is zero or below."); //NOI18N
443 contact.setContactLandLineNumber(phone);
446 // Don't set null or wrong references
447 if ((fax instanceof DialableFaxNumber) && (fax.getPhoneCountry() instanceof Country) && (this.getFaxAreaCode() != null) && (this.getFaxNumber() != null) && (this.getFaxAreaCode() > 0) && (this.getFaxNumber() > 0)) {
448 // Now the number must be given
449 if (fax.getPhoneAreaCode() == null) {
451 throw new NullPointerException("fax.phoneAreaCode is null"); //NOI18N
452 } else if (fax.getPhoneAreaCode() < 1) {
454 throw new IllegalArgumentException("fax.phoneAreaCode is zero or below."); //NOI18N
455 } else if (fax.getPhoneNumber() == null) {
457 throw new NullPointerException("fax.phoneNumber is null"); //NOI18N
458 } else if (fax.getPhoneNumber() < 1) {
460 throw new IllegalArgumentException("fax.phoneNumber is zero or below."); //NOI18N
464 contact.setContactFaxNumber(fax);
467 // Is the provider set?
468 if ((cellphone instanceof DialableCellphoneNumber) && (this.getCellphoneCarrier() instanceof MobileProvider) && (this.getCellphoneNumber() != null) && (this.getCellphoneNumber() > 0)) {
469 // Is the number set?
470 if (cellphone.getPhoneNumber() == null) {
472 throw new NullPointerException("cellphone.phoneNumber is null"); //NOI18N
473 } else if (cellphone.getPhoneNumber() < 1) {
475 throw new IllegalArgumentException("cellphone.phoneNumber is zero or below."); //NOI18N
478 // Set cellphone number
479 contact.setContactCellphoneNumber(cellphone);
487 public String doChangePersonalContactData () {
488 // This method shall only be called if the user is logged-in
489 if (!this.loginController.isUserLoggedIn()) {
491 throw new IllegalStateException("User is not logged-in"); //NOI18N
492 } else if (!this.isRequiredChangePersonalDataSet()) {
493 // Not all required fields are set
494 throw new FaceletException("Not all required fields are set."); //NOI18N
495 } else if (!this.loginController.ifCurrentPasswordMatches()) {
496 // Password not matching
497 throw new FaceletException(new UserPasswordMismatchException(this.loginController.getLoggedInUser()));
500 // Get contact instance
501 Contact contact = this.loginController.getLoggedInUser().getUserContact();
503 // It should be there, so run some tests on it
504 assert (contact instanceof Contact) : "Instance loginController.loggedInUser.userContact is null"; //NOI18N
505 assert (contact.getContactId() instanceof Long) : "Instance loginController.userContact.contactId is null"; //NOI18N
506 assert (contact.getContactId() > 0) : MessageFormat.format("Instance loginController.userContact.contactId={0} is invalid", contact.getContactId()); //NOI18N
509 contact.setContactGender(this.getGender());
510 contact.setContactFirstName(this.getFirstName());
511 contact.setContactFamilyName(this.getFamilyName());
512 contact.setContactStreet(this.getStreet());
513 contact.setContactHouseNumber(this.getHouseNumber());
514 contact.setContactZipCode(this.getZipCode());
515 contact.setContactCity(this.getCity());
516 contact.setContactCountry(this.getCountry());
518 // Update contact's cellphone number
519 this.isCellphoneUnlinked = ContactUtils.updateCellPhoneNumber(contact, this.getCellphoneCarrier(), this.getCellphoneNumber());
521 // Update contact's land-line number
522 this.isLandLineUnlinked = ContactUtils.updateLandLineNumber(contact, this.getPhoneCountry(), this.getPhoneAreaCode(), this.getPhoneNumber());
524 // Update contact's fax number
525 this.isFaxUnlinked = ContactUtils.updateFaxNumber(contact, this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());
527 // Send it to the EJB
528 this.contactBean.updateContactData(contact, this.isCellphoneUnlinked, this.isLandLineUnlinked, this.isFaxUnlinked);
531 return "contact_data_saved"; //NOI18N
535 public Date getBirthday () {
536 return this.birthday;
540 public void setBirthday (final Date birthday) {
541 this.birthday = birthday;
545 public MobileProvider getCellphoneCarrier () {
546 return this.cellphoneCarrier;
550 public void setCellphoneCarrier (final MobileProvider cellphoneCarrier) {
551 this.cellphoneCarrier = cellphoneCarrier;
555 public Long getCellphoneNumber () {
556 return this.cellphoneNumber;
560 public void setCellphoneNumber (Long cellphoneNumber) {
561 this.cellphoneNumber = cellphoneNumber;
565 public String getCity () {
570 public void setCity (final String city) {
575 public String getComment () {
580 public void setComment (final String comment) {
581 this.comment = comment;
585 public Country getCountry () {
590 public void setCountry (final Country country) {
591 this.country = country;
595 public String getEmailAddress () {
596 return this.emailAddress;
600 public void setEmailAddress (final String emailAddress) {
601 this.emailAddress = emailAddress;
605 public String getEmailAddressRepeat () {
606 return this.emailAddressRepeat;
610 public void setEmailAddressRepeat (final String emailAddressRepeat) {
611 this.emailAddressRepeat = emailAddressRepeat;
615 public String getFamilyName () {
616 return this.familyName;
620 public void setFamilyName (final String familyName) {
621 this.familyName = familyName;
625 public Integer getFaxAreaCode () {
626 return this.faxAreaCode;
630 public void setFaxAreaCode (final Integer faxAreaCode) {
631 this.faxAreaCode = faxAreaCode;
635 public Country getFaxCountry () {
636 return this.faxCountry;
640 public void setFaxCountry (final Country faxCountry) {
641 this.faxCountry = faxCountry;
645 public Long getFaxNumber () {
646 return this.faxNumber;
650 public void setFaxNumber (final Long faxNumber) {
651 this.faxNumber = faxNumber;
655 public String getFirstName () {
656 return this.firstName;
660 public void setFirstName (final String firstName) {
661 this.firstName = firstName;
665 public Gender getGender () {
670 public void setGender (final Gender gender) {
671 this.gender = gender;
675 public Short getHouseNumber () {
676 return this.houseNumber;
680 public void setHouseNumber (final Short houseNumber) {
681 this.houseNumber = houseNumber;
685 public Integer getPhoneAreaCode () {
686 return this.phoneAreaCode;
690 public void setPhoneAreaCode (final Integer phoneAreaCode) {
691 this.phoneAreaCode = phoneAreaCode;
695 public Country getPhoneCountry () {
696 return this.phoneCountry;
700 public void setPhoneCountry (final Country phoneCountry) {
701 this.phoneCountry = phoneCountry;
705 public Long getPhoneNumber () {
706 return this.phoneNumber;
710 public void setPhoneNumber (final Long phoneNumber) {
711 this.phoneNumber = phoneNumber;
715 public String getStreet () {
720 public void setStreet (final String street) {
721 this.street = street;
725 public Integer getZipCode () {
730 public void setZipCode (final Integer zipCode) {
731 this.zipCode = zipCode;
735 * Post-initialization of this class
738 public void init () {
739 // Get full email address list for reducing EJB calls
740 this.emailAddressList = this.contactBean.getEmailAddressList();
742 // Get full contact list
743 this.contactList = this.contactBean.getAllContacts();
747 public boolean isEmailAddressRegistered (final Contact contact) {
748 return ((this.emailAddressList instanceof List) && (this.emailAddressList.contains(contact.getContactEmailAddress())));
752 public boolean isRequiredChangePersonalDataSet () {
753 return ((this.getGender() != null) &&
754 (this.getFirstName() != null) &&
755 (this.getFamilyName() != null) &&
756 (this.getStreet() != null) &&
757 (this.getHouseNumber() != null) &&
758 (this.getZipCode() != null) &&
759 (this.getCity() != null));
763 public boolean isRequiredPersonalDataSet () {
764 return ((this.getGender() != null) &&
765 (this.getFirstName() != null) &&
766 (this.getFamilyName() != null) &&
767 (this.getStreet() != null) &&
768 (this.getHouseNumber() != null) &&
769 (this.getZipCode() != null) &&
770 (this.getCity() != null) &&
771 (this.getEmailAddress() != null) &&
772 (this.getEmailAddressRepeat() != null));
776 public boolean isSameEmailAddressEntered () {
777 return (Objects.equals(this.getEmailAddress(), this.getEmailAddressRepeat()));
781 public Contact lookupContactById (final Long contactId) throws ContactNotFoundException {
783 Contact localContact = null;
788 // Try to lookup it in visible user list
789 for (final Iterator<Contact> iterator = this.contactList.iterator(); iterator.hasNext();) {
791 Contact next = iterator.next();
793 // Is the user id found?
794 if (Objects.equals(next.getContactId(), contactId)) {
795 // Copy to other variable
802 if (null == localContact) {
803 // Not visible for the current user
804 throw new ContactNotFoundException(contactId);
807 // Copy all data to this bean
808 this.copyContact(localContact);
815 public void updateContactDataFromController (final Contact userContact) {
816 // Is the instance valid?
817 if (null == userContact) {
819 throw new NullPointerException("userContact is null"); //NOI18N
820 } else if (userContact.getContactId() == null) {
822 throw new NullPointerException("userContact.contactId is null"); //NOI18N
823 } else if (userContact.getContactId() < 1) {
824 // Not valid id number
825 throw new IllegalArgumentException(MessageFormat.format("userContact.contactId={0} is not valid.", userContact.getContactId())); //NOI18N
829 this.copyContact(userContact);
833 * Adds email address to bean's internal list.
835 * @param contact Contact instance
837 private void addUserNameEmailAddress (final Contact contact) {
838 // Make sure the entry is not added yet
839 if (this.emailAddressList.contains(contact.getContactEmailAddress())) {
841 throw new IllegalArgumentException(MessageFormat.format("Email address {0} already added.", contact.getContactEmailAddress())); //NOI18N
845 this.emailAddressList.add(contact.getContactEmailAddress());
851 private void clear () {
854 this.setGender(Gender.UNKNOWN);
855 this.setFirstName(null);
856 this.setFamilyName(null);
857 this.setStreet(null);
858 this.setHouseNumber(null);
859 this.setZipCode(null);
861 this.setCountry(null);
864 this.setEmailAddress(null);
865 this.setEmailAddressRepeat(null);
866 this.setPhoneCountry(null);
867 this.setPhoneAreaCode(null);
868 this.setPhoneNumber(null);
869 this.setCellphoneCarrier(null);
870 this.setCellphoneNumber(null);
871 this.setFaxCountry(null);
872 this.setFaxAreaCode(null);
873 this.setFaxNumber(null);
876 this.setBirthday(null);
877 this.setComment(null);
881 * Copies given contact into the controller
883 * @param contact Contact instance
885 private void copyContact (final Contact contact) {
888 this.setGender(contact.getContactGender());
889 this.setFirstName(contact.getContactFirstName());
890 this.setFamilyName(contact.getContactFamilyName());
891 this.setStreet(contact.getContactStreet());
892 this.setHouseNumber(contact.getContactHouseNumber());
893 this.setZipCode(contact.getContactZipCode());
894 this.setCity(contact.getContactCity());
895 this.setCountry(contact.getContactCountry());
897 // Get cellphone, phone and fax instance
898 DialableCellphoneNumber cellphone = contact.getContactCellphoneNumber();
899 DialableFaxNumber fax = contact.getContactFaxNumber();
900 DialableLandLineNumber phone = contact.getContactLandLineNumber();
903 if ((phone instanceof DialableLandLineNumber) && (phone.getPhoneAreaCode() > 0)) {
904 this.setPhoneCountry(phone.getPhoneCountry());
905 this.setPhoneAreaCode(phone.getPhoneAreaCode());
906 this.setPhoneNumber(phone.getPhoneNumber());
908 if ((cellphone instanceof DialableCellphoneNumber) && (cellphone.getCellphoneProvider() instanceof MobileProvider)) {
909 this.setCellphoneCarrier(cellphone.getCellphoneProvider());
910 this.setCellphoneNumber(cellphone.getPhoneNumber());
912 if ((fax instanceof DialableFaxNumber) && (fax.getPhoneAreaCode() > 0)) {
913 this.setFaxCountry(fax.getPhoneCountry());
914 this.setFaxAreaCode(fax.getPhoneAreaCode());
915 this.setFaxNumber(fax.getPhoneNumber());
917 this.setEmailAddress(contact.getContactEmailAddress());
920 this.setBirthday(contact.getContactBirthday());
921 this.setComment(contact.getContactComment());