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.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 () {
210 // Set gender to UNKNOWN
211 this.gender = Gender.UNKNOWN;
215 // Get initial context
216 Context context = new InitialContext();
219 this.contactBean = (ContactSessionBeanRemote) context.lookup("java:global/PizzaService-ejb/contact!org.mxchange.jcontacts.contact.ContactSessionBeanRemote"); //NOI18N
220 } catch (final NamingException e) {
222 throw new FaceletException(e);
227 public void addEmailAddress (final String contactEmailAddress) {
229 this.emailAddressList.add(contactEmailAddress);
233 public void afterAdminAddedContact (@Observes final AdminAddedContactEvent event) {
234 // The event must be valid
237 throw new NullPointerException("event is null"); //NOI18N
238 } else if (event.getAddedContact()== null) {
240 throw new NullPointerException("event.addedContact is null"); //NOI18N
241 } else if (event.getAddedContact().getContactId() == null) {
243 throw new NullPointerException("event.addedContact.customerId is null"); //NOI18N
244 } else if (event.getAddedContact().getContactId() < 1) {
246 throw new IllegalArgumentException(MessageFormat.format("event.addedContact.customerId={0} is not valid", event.getAddedContact().getContactId())); //NOI18N //NOI18N
253 this.contactList.add(event.getAddedContact());
257 public void afterAdminAddedCustomer (@Observes final AdminAddedCustomerEvent event) {
258 // The event must be valid
261 throw new NullPointerException("event is null"); //NOI18N
262 } else if (event.getAddedCustomer() == null) {
264 throw new NullPointerException("event.addedCustomer is null"); //NOI18N
265 } else if (event.getAddedCustomer().getCustomerId() == null) {
267 throw new NullPointerException("event.addedCustomer.customerId is null"); //NOI18N
268 } else if (event.getAddedCustomer().getCustomerId() < 1) {
270 throw new IllegalArgumentException(MessageFormat.format("event.addedCustomer.customerId={0} is not valid", event.getAddedCustomer().getCustomerId())); //NOI18N //NOI18N
277 this.contactList.add(event.getAddedCustomer().getCustomerContact());
281 public void afterAdminAddedUserEvent (@Observes final AdminAddedUserEvent event) {
282 // The event must be valid
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
295 } else if (event.getAddedUser().getUserContact() == null) {
297 throw new NullPointerException("event.addedUser.userContact is null"); //NOI18N
298 } else if (event.getAddedUser().getUserContact().getContactId() == null) {
300 throw new NullPointerException("event.addedUser.userContact.contactId is null"); //NOI18N
301 } else if (event.getAddedUser().getUserContact().getContactId() < 1) {
303 throw new IllegalArgumentException(MessageFormat.format("event.addedUser.userContact.contactId={0} is not valid", event.getAddedUser().getUserContact().getContactId())); //NOI18N
306 // Add user to local list
307 this.contactList.add(event.getAddedUser().getUserContact());
311 public void afterAdminUpdatedContactDataEvent (@Observes final AdminUpdatedContactEvent event) {
313 //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("ContactWebBean:afterAdminUpdatedContactDataEvent: event={0} - CALLED!", event)); //NOI18N
315 // event should not be null
318 throw new NullPointerException("event is null"); //NOI18N
319 } else if (event.getUpdatedContact()== null) {
321 throw new NullPointerException("event.updatedUser is null"); //NOI18N
322 } else if (event.getUpdatedContact().getContactId() == null) {
324 throw new NullPointerException("event.updatedUser.userId is null"); //NOI18N
325 } else if (event.getUpdatedContact().getContactId() < 1) {
327 throw new IllegalArgumentException(MessageFormat.format("contactId of contact={0} is not valid: {1}", event.getUpdatedContact(), event.getUpdatedContact().getContactId())); //NOI18N
330 // Get iterator from list
331 Iterator<Contact> iterator = this.contactList.iterator();
333 // "Walk" through all entries
334 while (iterator.hasNext()) {
336 Contact next = iterator.next();
338 // Is id number the same?
339 if (Objects.equals(event.getUpdatedContact().getContactId(), next.getContactId())) {
340 // Found entry, so remove it and abort
341 this.contactList.remove(next);
343 // Remove also email from list
344 this.emailAddressList.remove(next.getContactEmailAddress());
349 // Add contact to list
350 this.contactList.add(event.getUpdatedContact());
352 // Add email address to list
353 this.emailAddressList.add(event.getUpdatedContact().getContactEmailAddress());
357 public void afterRegistrationEvent (@Observes final UserRegisteredEvent event) {
359 //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("ContactWebBean:afterRegistration: event={0} - CALLED!", event)); //NOI18N
361 // event should not be null
364 throw new NullPointerException("event is null"); //NOI18N
365 } else if (event.getRegisteredUser() == null) {
367 throw new NullPointerException("event.user is null"); //NOI18N
368 } else if (event.getRegisteredUser().getUserId() == null) {
370 throw new NullPointerException("event.user.userId is null"); //NOI18N
371 } else if (event.getRegisteredUser().getUserId() < 1) {
373 throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getRegisteredUser(), event.getRegisteredUser().getUserId())); //NOI18N
377 Contact registeredContact = event.getRegisteredUser().getUserContact();
380 //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("ContactWebBean:afterRegistration: registeredContact={0}", registeredContact)); //NOI18N
381 // Copy all data from registered->user
382 this.copyContact(registeredContact);
384 // Add user name and email address
385 this.addUserNameEmailAddress(registeredContact);
391 //* NOISY-DEBUG: */ System.out.println("ContactWebBean:afterRegistration: EXIT!"); //NOI18N
395 public void afterUserLogin (@Observes final UserLoggedInEvent event) {
397 //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("ContactWebBean:afterUserLogin: event={0} - CALLED!", event)); //NOI18N
399 // event should not be null
402 throw new NullPointerException("event is null"); //NOI18N
403 } else if (event.getLoggedInUser() == null) {
405 throw new NullPointerException("event.user is null"); //NOI18N
406 } else if (event.getLoggedInUser().getUserId() == null) {
408 throw new NullPointerException("event.user.userId is null"); //NOI18N
409 } else if (event.getLoggedInUser().getUserId() < 1) {
411 throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getLoggedInUser(), event.getLoggedInUser().getUserId())); //NOI18N
414 // Copy all data to this bean
415 this.copyContact(event.getLoggedInUser().getUserContact());
418 //* NOISY-DEBUG: */ System.out.println("ContactWebBean:afterUserLogin - EXIT!"); //NOI18N
422 @SuppressWarnings ("ReturnOfCollectionOrArrayField")
423 public List<Contact> allContacts () {
424 return this.contactList;
428 public Contact createContactInstance () {
429 // Required personal data must be set
430 assert (this.isRequiredPersonalDataSet()) : "not all personal data is set"; //NOI18N
432 // Generate phone number
433 DialableLandLineNumber phone = new LandLineNumber(this.getPhoneCountry(), this.getPhoneAreaCode(), this.getPhoneNumber());
434 DialableCellphoneNumber cellphone = new CellphoneNumber(this.getCellphoneCarrier(), this.getCellphoneNumber());
435 DialableFaxNumber fax = new FaxNumber(this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());
437 // Create new contact
438 Contact contact = new UserContact(this.getGender(), this.getFirstName(), this.getFamilyName());
439 contact.setContactStreet(this.getStreet());
440 contact.setContactHouseNumber(this.getHouseNumber());
441 contact.setContactZipCode(this.getZipCode());
442 contact.setContactCity(this.getCity());
443 contact.setContactCountry(this.getCountry());
444 contact.setContactEmailAddress(this.getEmailAddress());
445 contact.setContactBirthday(this.getBirthday());
446 contact.setContactComment(this.getComment());
449 contact.setContactOwnContact(Boolean.TRUE);
451 // Don't set null or wrong references
452 if ((phone instanceof DialableLandLineNumber) && (phone.getPhoneCountry() instanceof Country) && (this.getPhoneAreaCode() != null) && (this.getPhoneNumber() != null) && (this.getPhoneAreaCode() > 0) && (this.getPhoneNumber() > 0)) {
453 // Now the number must be given
454 if (phone.getPhoneAreaCode() == null) {
456 throw new NullPointerException("phone.phoneAreaCode is null"); //NOI18N
457 } else if (phone.getPhoneAreaCode() < 1) {
459 throw new IllegalArgumentException("phone.phoneAreaCode is zero or below."); //NOI18N
460 } else if (phone.getPhoneNumber() == null) {
462 throw new NullPointerException("phone.phoneNumber is null"); //NOI18N
463 } else if (phone.getPhoneNumber() < 1) {
465 throw new IllegalArgumentException("phone.phoneNumber is zero or below."); //NOI18N
469 contact.setContactLandLineNumber(phone);
472 // Don't set null or wrong references
473 if ((fax instanceof DialableFaxNumber) && (fax.getPhoneCountry() instanceof Country) && (this.getFaxAreaCode() != null) && (this.getFaxNumber() != null) && (this.getFaxAreaCode() > 0) && (this.getFaxNumber() > 0)) {
474 // Now the number must be given
475 if (fax.getPhoneAreaCode() == null) {
477 throw new NullPointerException("fax.phoneAreaCode is null"); //NOI18N
478 } else if (fax.getPhoneAreaCode() < 1) {
480 throw new IllegalArgumentException("fax.phoneAreaCode is zero or below."); //NOI18N
481 } else if (fax.getPhoneNumber() == null) {
483 throw new NullPointerException("fax.phoneNumber is null"); //NOI18N
484 } else if (fax.getPhoneNumber() < 1) {
486 throw new IllegalArgumentException("fax.phoneNumber is zero or below."); //NOI18N
490 contact.setContactFaxNumber(fax);
493 // Is the provider set?
494 if ((cellphone instanceof DialableCellphoneNumber) && (this.getCellphoneCarrier() instanceof MobileProvider) && (this.getCellphoneNumber() != null) && (this.getCellphoneNumber() > 0)) {
495 // Is the number set?
496 if (cellphone.getPhoneNumber() == null) {
498 throw new NullPointerException("cellphone.phoneNumber is null"); //NOI18N
499 } else if (cellphone.getPhoneNumber() < 1) {
501 throw new IllegalArgumentException("cellphone.phoneNumber is zero or below."); //NOI18N
504 // Set cellphone number
505 contact.setContactCellphoneNumber(cellphone);
513 public String doChangePersonalContactData () {
514 // This method shall only be called if the user is logged-in
515 if (!this.userLoginController.isUserLoggedIn()) {
517 throw new IllegalStateException("User is not logged-in"); //NOI18N
518 } else if (!this.isRequiredChangePersonalDataSet()) {
519 // Not all required fields are set
520 throw new FaceletException("Not all required fields are set."); //NOI18N
521 } else if (!this.userLoginController.ifCurrentPasswordMatches()) {
522 // Password not matching
523 throw new FaceletException(new UserPasswordMismatchException(this.userLoginController.getLoggedInUser()));
526 // Get contact instance
527 Contact contact = this.userLoginController.getLoggedInUser().getUserContact();
529 // It should be there, so run some tests on it
530 assert (contact instanceof Contact) : "Instance userLoginController.loggedInUser.userContact is null"; //NOI18N
531 assert (contact.getContactId() instanceof Long) : "Instance userLoginController.userContact.contactId is null"; //NOI18N
532 assert (contact.getContactId() > 0) : MessageFormat.format("Instance userLoginController.userContact.contactId={0} is invalid", contact.getContactId()); //NOI18N
535 contact.setContactGender(this.getGender());
536 contact.setContactFirstName(this.getFirstName());
537 contact.setContactFamilyName(this.getFamilyName());
538 contact.setContactStreet(this.getStreet());
539 contact.setContactHouseNumber(this.getHouseNumber());
540 contact.setContactZipCode(this.getZipCode());
541 contact.setContactCity(this.getCity());
542 contact.setContactCountry(this.getCountry());
544 // Update contact's cellphone number
545 this.isCellphoneUnlinked = ContactUtils.updateCellPhoneNumber(contact, this.getCellphoneCarrier(), this.getCellphoneNumber());
547 // Update contact's land-line number
548 this.isLandLineUnlinked = ContactUtils.updateLandLineNumber(contact, this.getPhoneCountry(), this.getPhoneAreaCode(), this.getPhoneNumber());
550 // Update contact's fax number
551 this.isFaxUnlinked = ContactUtils.updateFaxNumber(contact, this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());
553 // Send it to the EJB
554 this.contactBean.updateContactData(contact, this.isCellphoneUnlinked, this.isLandLineUnlinked, this.isFaxUnlinked);
557 return "contact_data_saved"; //NOI18N
561 @SuppressWarnings ("ReturnOfDateField")
562 public Date getBirthday () {
563 return this.birthday;
567 @SuppressWarnings ("AssignmentToDateFieldFromParameter")
568 public void setBirthday (final Date birthday) {
569 this.birthday = birthday;
573 public MobileProvider getCellphoneCarrier () {
574 return this.cellphoneCarrier;
578 public void setCellphoneCarrier (final MobileProvider cellphoneCarrier) {
579 this.cellphoneCarrier = cellphoneCarrier;
583 public Long getCellphoneNumber () {
584 return this.cellphoneNumber;
588 public void setCellphoneNumber (Long cellphoneNumber) {
589 this.cellphoneNumber = cellphoneNumber;
593 public String getCity () {
598 public void setCity (final String city) {
603 public String getComment () {
608 public void setComment (final String comment) {
609 this.comment = comment;
613 public Country getCountry () {
618 public void setCountry (final Country country) {
619 this.country = country;
623 public String getEmailAddress () {
624 return this.emailAddress;
628 public void setEmailAddress (final String emailAddress) {
629 this.emailAddress = emailAddress;
633 public String getEmailAddressRepeat () {
634 return this.emailAddressRepeat;
638 public void setEmailAddressRepeat (final String emailAddressRepeat) {
639 this.emailAddressRepeat = emailAddressRepeat;
643 public String getFamilyName () {
644 return this.familyName;
648 public void setFamilyName (final String familyName) {
649 this.familyName = familyName;
653 public Integer getFaxAreaCode () {
654 return this.faxAreaCode;
658 public void setFaxAreaCode (final Integer faxAreaCode) {
659 this.faxAreaCode = faxAreaCode;
663 public Country getFaxCountry () {
664 return this.faxCountry;
668 public void setFaxCountry (final Country faxCountry) {
669 this.faxCountry = faxCountry;
673 public Long getFaxNumber () {
674 return this.faxNumber;
678 public void setFaxNumber (final Long faxNumber) {
679 this.faxNumber = faxNumber;
683 public String getFirstName () {
684 return this.firstName;
688 public void setFirstName (final String firstName) {
689 this.firstName = firstName;
693 public Gender getGender () {
698 public void setGender (final Gender gender) {
699 this.gender = gender;
703 public Short getHouseNumber () {
704 return this.houseNumber;
708 public void setHouseNumber (final Short houseNumber) {
709 this.houseNumber = houseNumber;
713 public Integer getPhoneAreaCode () {
714 return this.phoneAreaCode;
718 public void setPhoneAreaCode (final Integer phoneAreaCode) {
719 this.phoneAreaCode = phoneAreaCode;
723 public Country getPhoneCountry () {
724 return this.phoneCountry;
728 public void setPhoneCountry (final Country phoneCountry) {
729 this.phoneCountry = phoneCountry;
733 public Long getPhoneNumber () {
734 return this.phoneNumber;
738 public void setPhoneNumber (final Long phoneNumber) {
739 this.phoneNumber = phoneNumber;
743 public String getStreet () {
748 public void setStreet (final String street) {
749 this.street = street;
753 public Integer getZipCode () {
758 public void setZipCode (final Integer zipCode) {
759 this.zipCode = zipCode;
763 * Post-initialization of this class
766 public void init () {
767 // Get full email address list for reducing EJB calls
768 this.emailAddressList = this.contactBean.getEmailAddressList();
770 // Get full contact list
771 this.contactList = this.contactBean.getAllContacts();
775 public boolean isEmailAddressRegistered (final Contact contact) {
776 return ((this.emailAddressList instanceof List) && (this.emailAddressList.contains(contact.getContactEmailAddress())));
780 public boolean isRequiredChangePersonalDataSet () {
781 return ((this.getGender() != null) &&
782 (this.getFirstName() != null) &&
783 (this.getFamilyName() != null) &&
784 (this.getStreet() != null) &&
785 (this.getHouseNumber() != null) &&
786 (this.getZipCode() != null) &&
787 (this.getCity() != null));
791 public boolean isRequiredPersonalDataSet () {
792 return ((this.getGender() != null) &&
793 (this.getFirstName() != null) &&
794 (this.getFamilyName() != null) &&
795 (this.getStreet() != null) &&
796 (this.getHouseNumber() != null) &&
797 (this.getZipCode() != null) &&
798 (this.getCity() != null) &&
799 (this.getEmailAddress() != null) &&
800 (this.getEmailAddressRepeat() != null));
804 public boolean isSameEmailAddressEntered () {
805 return (Objects.equals(this.getEmailAddress(), this.getEmailAddressRepeat()));
809 public Contact lookupContactById (final Long contactId) throws ContactNotFoundException {
811 Contact localContact = null;
816 // Try to lookup it in visible user list
817 for (final Iterator<Contact> iterator = this.contactList.iterator(); iterator.hasNext();) {
819 Contact next = iterator.next();
821 // Is the user id found?
822 if (Objects.equals(next.getContactId(), contactId)) {
823 // Copy to other variable
830 if (null == localContact) {
831 // Not visible for the current user
832 throw new ContactNotFoundException(contactId);
835 // Copy all data to this bean
836 this.copyContact(localContact);
843 public void updateContactDataFromController (final Contact userContact) {
844 // Is the instance valid?
845 if (null == userContact) {
847 throw new NullPointerException("userContact is null"); //NOI18N
848 } else if (userContact.getContactId() == null) {
850 throw new NullPointerException("userContact.contactId is null"); //NOI18N
851 } else if (userContact.getContactId() < 1) {
852 // Not valid id number
853 throw new IllegalArgumentException(MessageFormat.format("userContact.contactId={0} is not valid.", userContact.getContactId())); //NOI18N
857 this.copyContact(userContact);
861 * Adds email address to bean's internal list.
863 * @param contact Contact instance
865 private void addUserNameEmailAddress (final Contact contact) {
866 // Make sure the entry is not added yet
867 if (this.emailAddressList.contains(contact.getContactEmailAddress())) {
869 throw new IllegalArgumentException(MessageFormat.format("Email address {0} already added.", contact.getContactEmailAddress())); //NOI18N
873 this.emailAddressList.add(contact.getContactEmailAddress());
879 private void clear () {
882 this.setGender(Gender.UNKNOWN);
883 this.setFirstName(null);
884 this.setFamilyName(null);
885 this.setStreet(null);
886 this.setHouseNumber(null);
887 this.setZipCode(null);
889 this.setCountry(null);
892 this.setEmailAddress(null);
893 this.setEmailAddressRepeat(null);
894 this.setPhoneCountry(null);
895 this.setPhoneAreaCode(null);
896 this.setPhoneNumber(null);
897 this.setCellphoneCarrier(null);
898 this.setCellphoneNumber(null);
899 this.setFaxCountry(null);
900 this.setFaxAreaCode(null);
901 this.setFaxNumber(null);
904 this.setBirthday(null);
905 this.setComment(null);
909 * Copies given contact into the controller
911 * @param contact Contact instance
913 private void copyContact (final Contact contact) {
916 this.setGender(contact.getContactGender());
917 this.setFirstName(contact.getContactFirstName());
918 this.setFamilyName(contact.getContactFamilyName());
919 this.setStreet(contact.getContactStreet());
920 this.setHouseNumber(contact.getContactHouseNumber());
921 this.setZipCode(contact.getContactZipCode());
922 this.setCity(contact.getContactCity());
923 this.setCountry(contact.getContactCountry());
925 // Get cellphone, phone and fax instance
926 DialableCellphoneNumber cellphone = contact.getContactCellphoneNumber();
927 DialableFaxNumber fax = contact.getContactFaxNumber();
928 DialableLandLineNumber phone = contact.getContactLandLineNumber();
931 if ((phone instanceof DialableLandLineNumber) && (phone.getPhoneAreaCode() > 0)) {
932 this.setPhoneCountry(phone.getPhoneCountry());
933 this.setPhoneAreaCode(phone.getPhoneAreaCode());
934 this.setPhoneNumber(phone.getPhoneNumber());
936 if ((cellphone instanceof DialableCellphoneNumber) && (cellphone.getCellphoneProvider() instanceof MobileProvider)) {
937 this.setCellphoneCarrier(cellphone.getCellphoneProvider());
938 this.setCellphoneNumber(cellphone.getPhoneNumber());
940 if ((fax instanceof DialableFaxNumber) && (fax.getPhoneAreaCode() > 0)) {
941 this.setFaxCountry(fax.getPhoneCountry());
942 this.setFaxAreaCode(fax.getPhoneAreaCode());
943 this.setFaxNumber(fax.getPhoneNumber());
945 this.setEmailAddress(contact.getContactEmailAddress());
948 this.setBirthday(contact.getContactBirthday());
949 this.setComment(contact.getContactComment());