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.add.AdminAddedContactEvent;
39 import org.mxchange.jcontacts.events.contact.update.AdminUpdatedContactEvent;
40 import org.mxchange.jcontacts.exceptions.ContactNotFoundException;
41 import org.mxchange.jcountry.data.Country;
42 import org.mxchange.jcustomercore.events.customer.added.AdminAddedCustomerEvent;
43 import org.mxchange.jphone.phonenumbers.cellphone.CellphoneNumber;
44 import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber;
45 import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
46 import org.mxchange.jphone.phonenumbers.fax.FaxNumber;
47 import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
48 import org.mxchange.jphone.phonenumbers.landline.LandLineNumber;
49 import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider;
50 import org.mxchange.jusercore.events.login.UserLoggedInEvent;
51 import org.mxchange.jusercore.events.registration.UserRegisteredEvent;
52 import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent;
53 import org.mxchange.jusercore.exceptions.UserPasswordMismatchException;
54 import org.mxchange.pizzaapplication.beans.login.PizzaUserLoginWebSessionController;
57 * A general contact bean (controller)
59 * @author Roland Haeder<roland@mxchange.org>
61 @Named ("contactController")
63 public class PizzaContactWebSessionBean implements PizzaContactWebSessionController {
68 private static final long serialVersionUID = 542_145_347_916L;
73 private Date birthday;
76 * Cellphone number's carrier
78 private MobileProvider cellphoneCarrier;
83 private Long cellphoneNumber;
93 private String comment;
98 private final ContactSessionBeanRemote contactBean;
103 private List<Contact> contactList;
108 private Country country;
113 private String emailAddress;
118 private List<String> emailAddressList;
121 * Email address repeated
123 private String emailAddressRepeat;
128 private String familyName;
131 * Fax number's area code
133 private Integer faxAreaCode;
136 * Country instance for fax number
138 private Country faxCountry;
143 private Long faxNumber;
148 private String firstName;
153 private Gender gender;
158 private Short houseNumber;
161 * Whether a cellphone entry has been unlinked
163 private boolean isCellphoneUnlinked;
166 * Whether a fax entry has been unlinked
168 private boolean isFaxUnlinked;
171 * Whether a land-line number has been unlinked
173 private boolean isLandLineUnlinked;
176 * Login bean (controller)
179 private PizzaUserLoginWebSessionController userLoginController;
182 * Phone number area code
184 private Integer phoneAreaCode;
187 * Country instance for phone number
189 private Country phoneCountry;
194 private Long phoneNumber;
199 private String street;
204 private Integer zipCode;
207 * Default constructor
209 public PizzaContactWebSessionBean () {
212 // Get initial context
213 Context context = new InitialContext();
216 this.contactBean = (ContactSessionBeanRemote) context.lookup("java:global/PizzaService-ejb/contact!org.mxchange.jcontacts.contact.ContactSessionBeanRemote"); //NOI18N
217 } catch (final NamingException e) {
219 throw new FaceletException(e);
224 public void addEmailAddress (final String contactEmailAddress) {
226 this.emailAddressList.add(contactEmailAddress);
230 public void afterAdminAddedContact (@Observes final AdminAddedContactEvent event) {
231 // The event must be valid
234 throw new NullPointerException("event is null"); //NOI18N
235 } else if (event.getAddedContact() == null) {
237 throw new NullPointerException("event.addedContact is null"); //NOI18N
238 } else if (event.getAddedContact().getContactId() == null) {
240 throw new NullPointerException("event.addedContact.customerId is null"); //NOI18N
241 } else if (event.getAddedContact().getContactId() < 1) {
243 throw new IllegalArgumentException(MessageFormat.format("event.addedContact.customerId={0} is not valid", event.getAddedContact().getContactId())); //NOI18N //NOI18N
250 this.contactList.add(event.getAddedContact());
254 public void afterAdminAddedCustomer (@Observes final AdminAddedCustomerEvent event) {
255 // The event must be valid
258 throw new NullPointerException("event is null"); //NOI18N
259 } else if (event.getAddedCustomer() == null) {
261 throw new NullPointerException("event.addedCustomer is null"); //NOI18N
262 } else if (event.getAddedCustomer().getCustomerId() == null) {
264 throw new NullPointerException("event.addedCustomer.customerId is null"); //NOI18N
265 } else if (event.getAddedCustomer().getCustomerId() < 1) {
267 throw new IllegalArgumentException(MessageFormat.format("event.addedCustomer.customerId={0} is not valid", event.getAddedCustomer().getCustomerId())); //NOI18N //NOI18N
274 this.contactList.add(event.getAddedCustomer().getCustomerContact());
278 public void afterAdminAddedUserEvent (@Observes final AdminAddedUserEvent event) {
280 //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("UserWebBean:afterAdminAddedUserEvent: event={0} - CALLED!", event)); //NOI18N
282 // event should not be null
285 throw new NullPointerException("event is null"); //NOI18N
286 } else if (event.getAddedUser() == null) {
288 throw new NullPointerException("event.addedUser is null"); //NOI18N
289 } else if (event.getAddedUser().getUserId() == null) {
291 throw new NullPointerException("event.addedUser.userId is null"); //NOI18N
292 } else if (event.getAddedUser().getUserId() < 1) {
294 throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getAddedUser(), event.getAddedUser().getUserId())); //NOI18N
301 //* NOISY-DEBUG: */ System.out.println("UserWebBean:afterAdminAddedUserEvent: EXIT!"); //NOI18N
305 public void afterAdminUpdatedContactDataEvent (@Observes final AdminUpdatedContactEvent event) {
307 //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("ContactWebBean:afterAdminUpdatedContactDataEvent: event={0} - CALLED!", event)); //NOI18N
309 // event should not be null
312 throw new NullPointerException("event is null"); //NOI18N
313 } else if (event.getUpdatedContact() == null) {
315 throw new NullPointerException("event.updatedUser is null"); //NOI18N
316 } else if (event.getUpdatedContact().getContactId() == null) {
318 throw new NullPointerException("event.updatedUser.userId is null"); //NOI18N
319 } else if (event.getUpdatedContact().getContactId() < 1) {
321 throw new IllegalArgumentException(MessageFormat.format("contactId of contact={0} is not valid: {1}", event.getUpdatedContact(), event.getUpdatedContact().getContactId())); //NOI18N
324 // Get iterator from list
325 Iterator<Contact> iterator = this.contactList.iterator();
327 // "Walk" through all entries
328 while (iterator.hasNext()) {
330 Contact next = iterator.next();
332 // Is id number the same?
333 if (Objects.equals(event.getUpdatedContact().getContactId(), next.getContactId())) {
334 // Found entry, so remove it and abort
335 this.contactList.remove(next);
337 // Remove also email from list
338 this.emailAddressList.remove(next.getContactEmailAddress());
343 // Add contact to list
344 this.contactList.add(event.getUpdatedContact());
346 // Add email address to list
347 this.emailAddressList.add(event.getUpdatedContact().getContactEmailAddress());
351 public void afterRegistrationEvent (@Observes final UserRegisteredEvent event) {
353 //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("ContactWebBean:afterRegistration: event={0} - CALLED!", event)); //NOI18N
355 // event should not be null
358 throw new NullPointerException("event is null"); //NOI18N
359 } else if (event.getRegisteredUser() == null) {
361 throw new NullPointerException("event.user is null"); //NOI18N
362 } else if (event.getRegisteredUser().getUserId() == null) {
364 throw new NullPointerException("event.user.userId is null"); //NOI18N
365 } else if (event.getRegisteredUser().getUserId() < 1) {
367 throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getRegisteredUser(), event.getRegisteredUser().getUserId())); //NOI18N
371 Contact registeredContact = event.getRegisteredUser().getUserContact();
374 //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("ContactWebBean:afterRegistration: registeredContact={0}", registeredContact)); //NOI18N
375 // Copy all data from registered->user
376 this.copyContact(registeredContact);
378 // Add user name and email address
379 this.addUserNameEmailAddress(registeredContact);
385 //* NOISY-DEBUG: */ System.out.println("ContactWebBean:afterRegistration: EXIT!"); //NOI18N
389 public void afterUserLogin (@Observes final UserLoggedInEvent event) {
391 //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("ContactWebBean:afterUserLogin: event={0} - CALLED!", event)); //NOI18N
393 // event should not be null
396 throw new NullPointerException("event is null"); //NOI18N
397 } else if (event.getLoggedInUser() == null) {
399 throw new NullPointerException("event.user is null"); //NOI18N
400 } else if (event.getLoggedInUser().getUserId() == null) {
402 throw new NullPointerException("event.user.userId is null"); //NOI18N
403 } else if (event.getLoggedInUser().getUserId() < 1) {
405 throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getLoggedInUser(), event.getLoggedInUser().getUserId())); //NOI18N
408 // Copy all data to this bean
409 this.copyContact(event.getLoggedInUser().getUserContact());
412 //* NOISY-DEBUG: */ System.out.println("ContactWebBean:afterUserLogin - EXIT!"); //NOI18N
416 @SuppressWarnings ("ReturnOfCollectionOrArrayField")
417 public List<Contact> allContacts () {
418 return this.contactList;
422 public Contact createContactInstance () {
424 //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("{0}.createContactInstance: CALLED!", this.getClass().getSimpleName()));
426 // Is all required data set?
427 if (!this.isRequiredPersonalDataSet()) {
428 // No, then abort here
429 throw new FaceletException(new IllegalArgumentException("Not all personal data is set, but createContactInstance() is called.")); //NOI18N
432 // Required personal data must be set
433 assert (this.isRequiredPersonalDataSet()) : "not all personal data is set"; //NOI18N
435 // Generate phone number
436 DialableLandLineNumber phone = new LandLineNumber(this.getPhoneCountry(), this.getPhoneAreaCode(), this.getPhoneNumber());
437 DialableCellphoneNumber cellphone = new CellphoneNumber(this.getCellphoneCarrier(), this.getCellphoneNumber());
438 DialableFaxNumber fax = new FaxNumber(this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());
440 // Create new contact
441 Contact contact = new UserContact(this.getGender(), this.getFirstName(), this.getFamilyName());
442 contact.setContactStreet(this.getStreet());
443 contact.setContactHouseNumber(this.getHouseNumber());
444 contact.setContactZipCode(this.getZipCode());
445 contact.setContactCity(this.getCity());
446 contact.setContactCountry(this.getCountry());
447 contact.setContactEmailAddress(this.getEmailAddress());
448 contact.setContactBirthday(this.getBirthday());
449 contact.setContactComment(this.getComment());
452 //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("{0}.createContactInstance: this.emailAddress={1}", this.getClass().getSimpleName(), this.getEmailAddress()));
453 // Don't set null or wrong references
454 if ((phone instanceof DialableLandLineNumber) && (phone.getPhoneCountry() instanceof Country) && (this.getPhoneAreaCode() != null) && (this.getPhoneNumber() != null) && (this.getPhoneAreaCode() > 0) && (this.getPhoneNumber() > 0)) {
455 // Now the number must be given
456 if (phone.getPhoneAreaCode() == null) {
458 throw new NullPointerException("phone.phoneAreaCode is null"); //NOI18N
459 } else if (phone.getPhoneAreaCode() < 1) {
461 throw new IllegalArgumentException("phone.phoneAreaCode is zero or below."); //NOI18N
462 } else if (phone.getPhoneNumber() == null) {
464 throw new NullPointerException("phone.phoneNumber is null"); //NOI18N
465 } else if (phone.getPhoneNumber() < 1) {
467 throw new IllegalArgumentException("phone.phoneNumber is zero or below."); //NOI18N
471 contact.setContactLandLineNumber(phone);
474 // Don't set null or wrong references
475 if ((fax instanceof DialableFaxNumber) && (fax.getPhoneCountry() instanceof Country) && (this.getFaxAreaCode() != null) && (this.getFaxNumber() != null) && (this.getFaxAreaCode() > 0) && (this.getFaxNumber() > 0)) {
476 // Now the number must be given
477 if (fax.getPhoneAreaCode() == null) {
479 throw new NullPointerException("fax.phoneAreaCode is null"); //NOI18N
480 } else if (fax.getPhoneAreaCode() < 1) {
482 throw new IllegalArgumentException("fax.phoneAreaCode is zero or below."); //NOI18N
483 } else if (fax.getPhoneNumber() == null) {
485 throw new NullPointerException("fax.phoneNumber is null"); //NOI18N
486 } else if (fax.getPhoneNumber() < 1) {
488 throw new IllegalArgumentException("fax.phoneNumber is zero or below."); //NOI18N
492 contact.setContactFaxNumber(fax);
495 // Is the provider set?
496 if ((cellphone instanceof DialableCellphoneNumber) && (this.getCellphoneCarrier() instanceof MobileProvider) && (this.getCellphoneNumber() != null) && (this.getCellphoneNumber() > 0)) {
497 // Is the number set?
498 if (cellphone.getPhoneNumber() == null) {
500 throw new NullPointerException("cellphone.phoneNumber is null"); //NOI18N
501 } else if (cellphone.getPhoneNumber() < 1) {
503 throw new IllegalArgumentException("cellphone.phoneNumber is zero or below."); //NOI18N
506 // Set cellphone number
507 contact.setContactCellphoneNumber(cellphone);
515 public String doChangePersonalContactData () {
516 // This method shall only be called if the user is logged-in
517 if (!this.userLoginController.isUserLoggedIn()) {
519 throw new IllegalStateException("User is not logged-in"); //NOI18N
520 } else if (!this.isRequiredChangePersonalDataSet()) {
521 // Not all required fields are set
522 throw new FaceletException("Not all required fields are set."); //NOI18N
523 } else if (!this.userLoginController.ifCurrentPasswordMatches()) {
524 // Password not matching
525 throw new FaceletException(new UserPasswordMismatchException(this.userLoginController.getLoggedInUser()));
528 // Get contact instance
529 Contact contact = this.userLoginController.getLoggedInUser().getUserContact();
531 // It should be there, so run some tests on it
532 assert (contact instanceof Contact) : "Instance userLoginController.loggedInUser.userContact is null"; //NOI18N
533 assert (contact.getContactId() instanceof Long) : "Instance userLoginController.userContact.contactId is null"; //NOI18N
534 assert (contact.getContactId() > 0) : MessageFormat.format("Instance userLoginController.userContact.contactId={0} is invalid", contact.getContactId()); //NOI18N
537 contact.setContactGender(this.getGender());
538 contact.setContactFirstName(this.getFirstName());
539 contact.setContactFamilyName(this.getFamilyName());
540 contact.setContactStreet(this.getStreet());
541 contact.setContactHouseNumber(this.getHouseNumber());
542 contact.setContactZipCode(this.getZipCode());
543 contact.setContactCity(this.getCity());
544 contact.setContactCountry(this.getCountry());
546 // Update contact's cellphone number
547 this.isCellphoneUnlinked = ContactUtils.updateCellPhoneNumber(contact, this.getCellphoneCarrier(), this.getCellphoneNumber());
549 // Update contact's land-line number
550 this.isLandLineUnlinked = ContactUtils.updateLandLineNumber(contact, this.getPhoneCountry(), this.getPhoneAreaCode(), this.getPhoneNumber());
552 // Update contact's fax number
553 this.isFaxUnlinked = ContactUtils.updateFaxNumber(contact, this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());
555 // Send it to the EJB
556 this.contactBean.updateContactData(contact, this.isCellphoneUnlinked, this.isLandLineUnlinked, this.isFaxUnlinked);
559 return "contact_data_saved"; //NOI18N
563 @SuppressWarnings ("ReturnOfDateField")
564 public Date getBirthday () {
565 return this.birthday;
569 @SuppressWarnings ("AssignmentToDateFieldFromParameter")
570 public void setBirthday (final Date birthday) {
571 this.birthday = birthday;
575 public MobileProvider getCellphoneCarrier () {
576 return this.cellphoneCarrier;
580 public void setCellphoneCarrier (final MobileProvider cellphoneCarrier) {
581 this.cellphoneCarrier = cellphoneCarrier;
585 public Long getCellphoneNumber () {
586 return this.cellphoneNumber;
590 public void setCellphoneNumber (Long cellphoneNumber) {
591 this.cellphoneNumber = cellphoneNumber;
595 public String getCity () {
600 public void setCity (final String city) {
605 public String getComment () {
610 public void setComment (final String comment) {
611 this.comment = comment;
615 public Country getCountry () {
620 public void setCountry (final Country country) {
621 this.country = country;
625 public String getEmailAddress () {
626 return this.emailAddress;
630 public void setEmailAddress (final String emailAddress) {
631 this.emailAddress = emailAddress;
635 public String getEmailAddressRepeat () {
636 return this.emailAddressRepeat;
640 public void setEmailAddressRepeat (final String emailAddressRepeat) {
641 this.emailAddressRepeat = emailAddressRepeat;
645 public String getFamilyName () {
646 return this.familyName;
650 public void setFamilyName (final String familyName) {
651 this.familyName = familyName;
655 public Integer getFaxAreaCode () {
656 return this.faxAreaCode;
660 public void setFaxAreaCode (final Integer faxAreaCode) {
661 this.faxAreaCode = faxAreaCode;
665 public Country getFaxCountry () {
666 return this.faxCountry;
670 public void setFaxCountry (final Country faxCountry) {
671 this.faxCountry = faxCountry;
675 public Long getFaxNumber () {
676 return this.faxNumber;
680 public void setFaxNumber (final Long faxNumber) {
681 this.faxNumber = faxNumber;
685 public String getFirstName () {
686 return this.firstName;
690 public void setFirstName (final String firstName) {
691 this.firstName = firstName;
695 public Gender getGender () {
700 public void setGender (final Gender gender) {
701 this.gender = gender;
705 public Short getHouseNumber () {
706 return this.houseNumber;
710 public void setHouseNumber (final Short houseNumber) {
711 this.houseNumber = houseNumber;
715 public Integer getPhoneAreaCode () {
716 return this.phoneAreaCode;
720 public void setPhoneAreaCode (final Integer phoneAreaCode) {
721 this.phoneAreaCode = phoneAreaCode;
725 public Country getPhoneCountry () {
726 return this.phoneCountry;
730 public void setPhoneCountry (final Country phoneCountry) {
731 this.phoneCountry = phoneCountry;
735 public Long getPhoneNumber () {
736 return this.phoneNumber;
740 public void setPhoneNumber (final Long phoneNumber) {
741 this.phoneNumber = phoneNumber;
745 public String getStreet () {
750 public void setStreet (final String street) {
751 this.street = street;
755 public Integer getZipCode () {
760 public void setZipCode (final Integer zipCode) {
761 this.zipCode = zipCode;
765 public boolean hasContacts () {
766 return (!this.allContacts().isEmpty());
770 * Post-initialization of this class
773 public void init () {
774 // Get full email address list for reducing EJB calls
775 this.emailAddressList = this.contactBean.getEmailAddressList();
777 // Get full contact list
778 this.contactList = this.contactBean.getAllContacts();
782 public boolean isEmailAddressRegistered (final Contact contact) {
783 return ((this.emailAddressList instanceof List) && (this.emailAddressList.contains(contact.getContactEmailAddress())));
787 public boolean isRequiredChangePersonalDataSet () {
788 return ((this.getGender() != null) &&
789 (this.getFirstName() != null) &&
790 (this.getFamilyName() != null) &&
791 (this.getStreet() != null) &&
792 (this.getHouseNumber() != null) &&
793 (this.getZipCode() != null) &&
794 (this.getCity() != null));
798 public boolean isRequiredPersonalDataSet () {
799 return ((this.getGender() != null) &&
800 (this.getFirstName() != null) &&
801 (this.getFamilyName() != null) &&
802 (this.getStreet() != null) &&
803 (this.getHouseNumber() != null) &&
804 (this.getZipCode() != null) &&
805 (this.getCity() != null) &&
806 (this.getEmailAddress() != null) &&
807 (this.getEmailAddressRepeat() != null));
811 public boolean isSameEmailAddressEntered () {
812 return (Objects.equals(this.getEmailAddress(), this.getEmailAddressRepeat()));
816 public Contact lookupContactById (final Long contactId) throws ContactNotFoundException {
818 Contact localContact = null;
823 // Try to lookup it in visible user list
824 for (final Iterator<Contact> iterator = this.contactList.iterator(); iterator.hasNext();) {
826 Contact next = iterator.next();
828 // Is the user id found?
829 if (Objects.equals(next.getContactId(), contactId)) {
830 // Copy to other variable
837 if (null == localContact) {
838 // Not visible for the current user
839 throw new ContactNotFoundException(contactId);
842 // Copy all data to this bean
843 this.copyContact(localContact);
850 public void updateContactDataFromController (final Contact userContact) {
851 // Is the instance valid?
852 if (null == userContact) {
854 throw new NullPointerException("userContact is null"); //NOI18N
855 } else if (userContact.getContactId() == null) {
857 throw new NullPointerException("userContact.contactId is null"); //NOI18N
858 } else if (userContact.getContactId() < 1) {
859 // Not valid id number
860 throw new IllegalArgumentException(MessageFormat.format("userContact.contactId={0} is not valid.", userContact.getContactId())); //NOI18N
864 this.copyContact(userContact);
868 * Adds email address to bean's internal list.
870 * @param contact Contact instance
872 private void addUserNameEmailAddress (final Contact contact) {
873 // Make sure the entry is not added yet
874 if (this.emailAddressList.contains(contact.getContactEmailAddress())) {
876 throw new IllegalArgumentException(MessageFormat.format("Email address {0} already added.", contact.getContactEmailAddress())); //NOI18N
880 this.emailAddressList.add(contact.getContactEmailAddress());
886 private void clear () {
889 this.setGender(Gender.UNKNOWN);
890 this.setFirstName(null);
891 this.setFamilyName(null);
892 this.setStreet(null);
893 this.setHouseNumber(null);
894 this.setZipCode(null);
896 this.setCountry(null);
899 this.setEmailAddress(null);
900 this.setEmailAddressRepeat(null);
901 this.setPhoneCountry(null);
902 this.setPhoneAreaCode(null);
903 this.setPhoneNumber(null);
904 this.setCellphoneCarrier(null);
905 this.setCellphoneNumber(null);
906 this.setFaxCountry(null);
907 this.setFaxAreaCode(null);
908 this.setFaxNumber(null);
911 this.setBirthday(null);
912 this.setComment(null);
916 * Copies given contact into the controller
918 * @param contact Contact instance
920 private void copyContact (final Contact contact) {
923 this.setGender(contact.getContactGender());
924 this.setFirstName(contact.getContactFirstName());
925 this.setFamilyName(contact.getContactFamilyName());
926 this.setStreet(contact.getContactStreet());
927 this.setHouseNumber(contact.getContactHouseNumber());
928 this.setZipCode(contact.getContactZipCode());
929 this.setCity(contact.getContactCity());
930 this.setCountry(contact.getContactCountry());
932 // Get cellphone, phone and fax instance
933 DialableCellphoneNumber cellphone = contact.getContactCellphoneNumber();
934 DialableFaxNumber fax = contact.getContactFaxNumber();
935 DialableLandLineNumber phone = contact.getContactLandLineNumber();
938 if ((phone instanceof DialableLandLineNumber) && (phone.getPhoneAreaCode() > 0)) {
939 this.setPhoneCountry(phone.getPhoneCountry());
940 this.setPhoneAreaCode(phone.getPhoneAreaCode());
941 this.setPhoneNumber(phone.getPhoneNumber());
943 if ((cellphone instanceof DialableCellphoneNumber) && (cellphone.getCellphoneProvider() instanceof MobileProvider)) {
944 this.setCellphoneCarrier(cellphone.getCellphoneProvider());
945 this.setCellphoneNumber(cellphone.getPhoneNumber());
947 if ((fax instanceof DialableFaxNumber) && (fax.getPhoneAreaCode() > 0)) {
948 this.setFaxCountry(fax.getPhoneCountry());
949 this.setFaxAreaCode(fax.getPhoneAreaCode());
950 this.setFaxNumber(fax.getPhoneNumber());
952 this.setEmailAddress(contact.getContactEmailAddress());
955 this.setBirthday(contact.getContactBirthday());
956 this.setComment(contact.getContactComment());