2 * Copyright (C) 2016 - 2020 Free Software Foundation
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.jjobs.beans.contact;
19 import java.text.MessageFormat;
20 import java.util.Date;
22 import javax.enterprise.context.RequestScoped;
23 import javax.enterprise.event.Event;
24 import javax.enterprise.event.Observes;
25 import javax.enterprise.inject.Any;
26 import javax.faces.view.facelets.FaceletException;
27 import javax.inject.Inject;
28 import javax.inject.Named;
29 import org.mxchange.jcontacts.events.contact.add.AdminAddedContactEvent;
30 import org.mxchange.jcontacts.events.contact.add.ObservableAdminAddedContactEvent;
31 import org.mxchange.jcontacts.events.contact.created.ObservableCreatedContactEvent;
32 import org.mxchange.jcontacts.events.contact.update.AdminUpdatedContactEvent;
33 import org.mxchange.jcontacts.events.contact.update.ObservableAdminUpdatedContactEvent;
34 import org.mxchange.jcontacts.exceptions.ContactAlreadyAddedException;
35 import org.mxchange.jcontacts.model.contact.AdminContactSessionBeanRemote;
36 import org.mxchange.jcontacts.model.contact.Contact;
37 import org.mxchange.jcontacts.model.contact.ContactSessionBeanRemote;
38 import org.mxchange.jcontacts.model.contact.Contacts;
39 import org.mxchange.jcontacts.model.contact.UserContact;
40 import org.mxchange.jcontacts.model.contact.title.PersonalTitle;
41 import org.mxchange.jcountry.model.data.Country;
42 import org.mxchange.jjobs.beans.BaseJobsBean;
43 import org.mxchange.jphone.model.phonenumbers.DialableNumber;
44 import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
45 import org.mxchange.jphone.model.phonenumbers.fax.FaxNumber;
46 import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber;
47 import org.mxchange.jphone.model.phonenumbers.landline.LandLineNumber;
48 import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber;
49 import org.mxchange.jphone.model.phonenumbers.mobile.MobileNumber;
50 import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider;
53 * An administrative user controller (bean)
55 * @author Roland Häder<roland@mxchange.org>
57 @Named ("adminContactController")
59 public class JobsAdminContactWebRequestBean extends BaseJobsBean implements JobsAdminContactWebRequestController {
64 private static final long serialVersionUID = 542_145_347_916L;
67 * Academic academicTitle
69 private String academicTitle;
72 * An event fired when the administrator has added a new contact
76 private Event<ObservableAdminAddedContactEvent> addedContactEvent;
79 * Administrative contact EJB
81 @EJB (lookup = "java:global/jjobs-ejb/adminContact!org.mxchange.jcontacts.model.contact.AdminContactSessionBeanRemote")
82 private AdminContactSessionBeanRemote adminContactBean;
87 private Date birthday;
97 private String comment;
100 * EJB for general contact purposes
102 @EJB (lookup = "java:global/jjobs-ejb/contact!org.mxchange.jcontacts.model.contact.ContactSessionBeanRemote")
103 private ContactSessionBeanRemote contactBean;
106 * General contact controller
109 private JobsContactWebRequestController contactController;
114 private Country contactCountry;
119 private Long contactId;
122 * An instance of a contact list controller
125 private JobsContactListWebViewController contactListController;
130 private String emailAddress;
135 private String familyName;
138 * Fax number's area code
140 private Integer faxAreaCode;
143 * Country instance for fax number
145 private Country faxCountry;
155 private Long faxNumber;
160 private String firstName;
165 private Short houseNumber;
168 * House number extension
170 private String houseNumberExtension;
173 * Whether a fax entry has been unlinked
175 private boolean isFaxUnlinked;
178 * Whether a land-line number has been unlinked
180 private boolean isLandLineUnlinked;
183 * Whether a cmobile entry has been unlinked
185 private boolean isMobileNumberUnlinked;
188 * Phone number area code
190 private Integer landLineAreaCode;
193 * Country instance for phone number
195 private Country landLineCountry;
198 * Land-line id number
200 private Long landLineId;
205 private Long landLineNumber;
210 private Long mobileId;
215 private Long mobileNumber;
218 * Mobile number's provider
220 private MobileProvider mobileProvider;
223 * PersonalTitle instance
225 private PersonalTitle personalTitle;
230 private String street;
233 * An event fired when the administrator has updated contact data
237 private Event<ObservableAdminUpdatedContactEvent> updatedContactEvent;
242 private Integer zipCode;
245 * Default constructor
247 public JobsAdminContactWebRequestBean () {
248 // Call super constructor
253 * Adds contact data to database and redirects on success. If the contact is
254 * already found, a proper exception is thrown.
256 public void addContact () {
257 // Are all minimum fields set?
258 if (this.getPersonalTitle() == null) {
260 throw new NullPointerException("personalTitle is null"); //NOI18N
261 } else if (this.getFirstName() == null) {
263 throw new NullPointerException("firstName is null"); //NOI18N
264 } else if (this.getFirstName().isEmpty()) {
266 throw new IllegalStateException("firstName is empty"); //NOI18N
267 } else if (this.getFamilyName() == null) {
269 throw new NullPointerException("familyName is null"); //NOI18N
270 } else if (this.getFamilyName().isEmpty()) {
272 throw new IllegalStateException("familyName is empty"); //NOI18N
275 // Create new contact instance
276 final Contact contact = this.createContactInstance();
278 // Default is not same contact
279 if (this.contactListController.isSameContactFound(contact)) {
280 // Already registered
281 throw new FaceletException(new ContactAlreadyAddedException(contact));
285 final Contact updatedContact;
290 updatedContact = this.adminContactBean.addContact(contact);
291 } catch (final ContactAlreadyAddedException ex) {
293 throw new FaceletException(ex);
297 this.addedContactEvent.fire(new AdminAddedContactEvent(updatedContact));
304 * Observer for events being fired when a bean helper has successfully
305 * created a contact instance.
307 * @param event Event being fired
309 public void afterCreatedContactEvent (@Observes final ObservableCreatedContactEvent event) {
311 //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("AdminContactController::afterCreatedContactEvent(): contact={0} - CALLED!", contact)); //NOI18N
313 // The event instance must be valid
316 throw new NullPointerException("event is null"); //NOI18N
317 } else if (event.getCreatedContact() == null) {
319 throw new NullPointerException("event.createdContact is null"); //NOI18N //NOI18N
320 } else if (event.getCreatedContact().getContactId() == null) {
322 throw new NullPointerException("event.createdContact.contactId is null"); //NOI18N //NOI18N
323 } else if (event.getCreatedContact().getContactId() < 1) {
325 throw new IllegalStateException(MessageFormat.format("event.createdContact.contactId={0} is not valid.", event.getCreatedContact().getContactId())); //NOI18N
328 // Get contact instance from event
329 final Contact contact = event.getCreatedContact();
331 // Set all fields: contact
332 this.setContactId(contact.getContactId());
333 this.setAcademicTitle(contact.getContactTitle());
334 this.setBirthday(contact.getContactBirthday());
335 this.setCity(contact.getContactCity());
336 this.setComment(contact.getContactComment());
337 this.setContactCountry(contact.getContactCountry());
338 this.setEmailAddress(contact.getContactEmailAddress());
339 this.setFamilyName(contact.getContactFamilyName());
340 this.setFirstName(contact.getContactFirstName());
341 this.setPersonalTitle(contact.getContactPersonalTitle());
342 this.setHouseNumber(contact.getContactHouseNumber());
343 this.setHouseNumberExtension(contact.getContactHouseNumberExtension());
344 this.setStreet(contact.getContactStreet());
345 this.setZipCode(contact.getContactZipCode());
347 // Is the cell phone set?
348 if (contact.getContactMobileNumber() instanceof DialableMobileNumber) {
350 this.setMobileId(contact.getContactMobileNumber().getPhoneId());
351 this.setMobileProvider(contact.getContactMobileNumber().getMobileProvider());
352 this.setMobileNumber(contact.getContactMobileNumber().getPhoneNumber());
356 if (contact.getContactFaxNumber() instanceof DialableFaxNumber) {
358 this.setFaxId(contact.getContactFaxNumber().getPhoneId());
359 this.setFaxAreaCode(contact.getContactFaxNumber().getPhoneAreaCode());
360 this.setFaxCountry(contact.getContactFaxNumber().getPhoneCountry());
361 this.setFaxNumber(contact.getContactFaxNumber().getPhoneNumber());
364 // Is the land-line number set?
365 if (contact.getContactLandLineNumber() instanceof DialableLandLineNumber) {
367 this.setLandLineId(contact.getContactLandLineNumber().getPhoneId());
368 this.setLandLineAreaCode(contact.getContactLandLineNumber().getPhoneAreaCode());
369 this.setLandLineCountry(contact.getContactLandLineNumber().getPhoneCountry());
370 this.setLandLineNumber(contact.getContactLandLineNumber().getPhoneNumber());
374 //* NOISY-DEBUG: */ System.out.println("AdminContactController::afterCreatedContactEvent(): EXIT!"); //NOI18N
378 public Contact createContactInstance () {
379 // Are all minimum fields set?
380 if (this.getPersonalTitle() == null) {
382 throw new NullPointerException("personalTitle is null"); //NOI18N
383 } else if (this.getFirstName() == null) {
385 throw new NullPointerException("firstName is null"); //NOI18N
386 } else if (this.getFirstName().isEmpty()) {
388 throw new IllegalStateException("firstName is empty"); //NOI18N
389 } else if (this.getFamilyName() == null) {
391 throw new NullPointerException("familyName is null"); //NOI18N
392 } else if (this.getFamilyName().isEmpty()) {
394 throw new IllegalStateException("familyName is empty"); //NOI18N
397 // Generate phone number
398 final DialableLandLineNumber landLine = new LandLineNumber(this.getLandLineCountry(), this.getLandLineAreaCode(), this.getLandLineNumber());
399 final DialableMobileNumber mobile = new MobileNumber(this.getMobileProvider(), this.getMobileNumber());
400 final DialableFaxNumber fax = new FaxNumber(this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());
402 // Create new instance
403 final Contact contact = new UserContact(this.getPersonalTitle(), this.getFirstName(), this.getFamilyName());
405 // Is contact id set?
406 if (this.getContactId() instanceof Long) {
408 contact.setContactId(this.getContactId());
412 contact.setContactTitle(this.getAcademicTitle());
413 contact.setContactBirthday(this.getBirthday());
414 contact.setContactStreet(this.getStreet());
415 contact.setContactHouseNumber(this.getHouseNumber());
416 contact.setContactZipCode(this.getZipCode());
417 contact.setContactCity(this.getCity());
418 contact.setContactCountry(this.getContactCountry());
419 contact.setContactEmailAddress(this.getEmailAddress());
420 contact.setContactBirthday(this.getBirthday());
421 contact.setContactComment(this.getComment());
424 contact.setContactOwnContact(Boolean.TRUE);
426 // Don't set null or wrong references
427 if ((landLine instanceof DialableLandLineNumber) && (landLine.getPhoneCountry() instanceof Country) && (this.getLandLineAreaCode() != null) && (this.getLandLineNumber() != null) && (this.getLandLineAreaCode() > 0) && (this.getLandLineNumber() > 0)) {
428 // Now the number must be given
429 if (landLine.getPhoneAreaCode() == null) {
431 throw new NullPointerException("phone.phoneAreaCode is null"); //NOI18N
432 } else if (landLine.getPhoneAreaCode() < 1) {
434 throw new IllegalArgumentException("phone.phoneAreaCode is zero or below."); //NOI18N
435 } else if (landLine.getPhoneNumber() == null) {
437 throw new NullPointerException("phone.phoneNumber is null"); //NOI18N
438 } else if (landLine.getPhoneNumber() < 1) {
440 throw new IllegalArgumentException("phone.phoneNumber is zero or below."); //NOI18N
444 contact.setContactLandLineNumber(landLine);
447 // Don't set null or wrong references
448 if ((fax instanceof DialableFaxNumber) && (fax.getPhoneCountry() instanceof Country) && (this.getFaxAreaCode() != null) && (this.getFaxNumber() != null) && (this.getFaxAreaCode() > 0) && (this.getFaxNumber() > 0)) {
449 // Now the number must be given
450 if (fax.getPhoneAreaCode() == null) {
452 throw new NullPointerException("fax.phoneAreaCode is null"); //NOI18N
453 } else if (fax.getPhoneAreaCode() < 1) {
455 throw new IllegalArgumentException("fax.phoneAreaCode is zero or below."); //NOI18N
456 } else if (fax.getPhoneNumber() == null) {
458 throw new NullPointerException("fax.phoneNumber is null"); //NOI18N
459 } else if (fax.getPhoneNumber() < 1) {
461 throw new IllegalArgumentException("fax.phoneNumber is zero or below."); //NOI18N
465 contact.setContactFaxNumber(fax);
468 // Is the provider set?
469 if ((mobile instanceof DialableMobileNumber) && (this.getMobileProvider() instanceof MobileProvider) && (this.getMobileNumber() != null) && (this.getMobileNumber() > 0)) {
470 // Is the number set?
471 if (mobile.getPhoneNumber() == null) {
473 throw new NullPointerException("cmobile.phoneNumber is null"); //NOI18N
474 } else if (mobile.getPhoneNumber() < 1) {
476 throw new IllegalArgumentException("cmobile.phoneNumber is zero or below."); //NOI18N
479 // Set cmobile number
480 contact.setContactMobileNumber(mobile);
488 * Edits currently loaded contact's data in database.
490 public void editContactData () {
491 // Get contact instance
492 final Contact contact = this.createContactInstance();
494 // Check if contact instance is in helper and valid
495 if (null == contact) {
497 throw new NullPointerException("beanHelper.contact is null"); //NOI18N
498 } else if (contact.getContactId() == null) {
500 throw new NullPointerException("beanHelper.contact.contactId is null"); //NOI18N //NOI18N
501 } else if (contact.getContactId() < 1) {
503 throw new IllegalStateException(MessageFormat.format("beanHelper.contact.contactId={0} is invalid", contact.getContactId())); //NOI18N
506 // Update all data in contact
507 this.updateContactData(contact);
509 // Call EJB for updating contact data
510 final Contact updatedContact = this.contactBean.updateContactData(contact, this.isMobileNumberUnlinked, this.isLandLineUnlinked, this.isFaxUnlinked);
513 this.updatedContactEvent.fire(new AdminUpdatedContactEvent(updatedContact));
520 * Returns a text representation of given mobile number or null if not set.
522 * @param mobileNumber Mobile number
524 * @return Text representation or null
526 public String generateMobileNumber (final DialableMobileNumber mobileNumber) {
528 if (null == mobileNumber) {
534 final String number = String.format(
536 mobileNumber.getMobileProvider().getProviderCountry().getCountryExternalDialPrefix(),
537 mobileNumber.getMobileProvider().getProviderDialPrefix(),
538 mobileNumber.getPhoneNumber()
546 * Returns a text representation of given land-line or fax number or null if
549 * @param phoneNumber Land-line or fax number
551 * @return Text representation or null
553 public String generatePhoneNumber (final DialableNumber phoneNumber) {
555 if (null == phoneNumber) {
561 final String number = String.format(
563 phoneNumber.getPhoneCountry().getCountryExternalDialPrefix(),
564 phoneNumber.getPhoneAreaCode(),
565 phoneNumber.getPhoneNumber()
573 * Getter for academic title
575 * @return Academic title
577 public String getAcademicTitle () {
578 return this.academicTitle;
582 * Setter for academic title
584 * @param academicTitle Academic title
586 public void setAcademicTitle (final String academicTitle) {
587 this.academicTitle = academicTitle;
591 * Getter for birth day
595 @SuppressWarnings ("ReturnOfDateField")
596 public Date getBirthday () {
597 return this.birthday;
601 * Setter for birth day
603 * @param birthday Birth day
605 @SuppressWarnings ("AssignmentToDateFieldFromParameter")
606 public void setBirthday (final Date birthday) {
607 this.birthday = birthday;
611 * Getter for city name
615 public String getCity () {
620 * Setter for city name
622 * @param city City name
624 public void setCity (final String city) {
629 * Getter for comments
633 public String getComment () {
640 * @param comment Comments
642 public void setComment (final String comment) {
643 this.comment = comment;
647 * Getter for contactCountry instance
649 * @return Country instance
651 public Country getContactCountry () {
652 return this.contactCountry;
656 * Setter for contactCountry instance
658 * @param contactCountry Country instance
660 public void setContactCountry (final Country contactCountry) {
661 this.contactCountry = contactCountry;
665 * Getter for contact id
669 public Long getContactId () {
670 return this.contactId;
674 * Setter for contact id
676 * @param contactId Contact id
678 public void setContactId (final Long contactId) {
679 this.contactId = contactId;
683 public String getControllerType () {
684 return "admin"; //NOI18N
689 public void setControllerType (final String controllerType) {
690 throw new UnsupportedOperationException("Setting controller type is not supported."); //NOI18N
694 * Getter for email address
696 * @return Email address
698 public String getEmailAddress () {
699 return this.emailAddress;
703 * Setter for email address
705 * @param emailAddress Email address
707 public void setEmailAddress (final String emailAddress) {
708 this.emailAddress = emailAddress;
714 * @return the familyName
716 public String getFamilyName () {
717 return this.familyName;
723 * @param familyName the familyName to set
725 public void setFamilyName (final String familyName) {
726 this.familyName = familyName;
730 * Getter for fax number's area code
732 * @return Fax number's area code
734 public Integer getFaxAreaCode () {
735 return this.faxAreaCode;
739 * Setter for fax number's area code
741 * @param faxAreaCode Fax number's area code
743 public void setFaxAreaCode (final Integer faxAreaCode) {
744 this.faxAreaCode = faxAreaCode;
748 * Getter for fax's country instance
750 * @return Fax' country instance
752 public Country getFaxCountry () {
753 return this.faxCountry;
757 * Setter for fax's country instance
759 * @param faxCountry Fax' country instance
761 public void setFaxCountry (final Country faxCountry) {
762 this.faxCountry = faxCountry;
770 public Long getFaxId () {
777 * @param faxId Fax id
779 public void setFaxId (final Long faxId) {
784 * Getter for fax number
788 public Long getFaxNumber () {
789 return this.faxNumber;
793 * Setter for fax number
795 * @param faxNumber Fax number
797 public void setFaxNumber (final Long faxNumber) {
798 this.faxNumber = faxNumber;
802 * Getter for first name
806 public String getFirstName () {
807 return this.firstName;
811 * Setter for first name
813 * @param firstName First name
815 public void setFirstName (final String firstName) {
816 this.firstName = firstName;
820 * Getter for house number
822 * @return House number
824 public Short getHouseNumber () {
825 return this.houseNumber;
829 * Setter for house number
831 * @param houseNumber House number
833 public void setHouseNumber (final Short houseNumber) {
834 this.houseNumber = houseNumber;
838 * Getter for house number extension. Example: 123a, 'a' is the extension
839 * and 123 is the house number.
841 * @return House number extension
843 public String getHouseNumberExtension () {
844 return this.houseNumberExtension;
848 * Setter for house number extension
850 * @param houseNumberExtension House number extension
852 public void setHouseNumberExtension (final String houseNumberExtension) {
853 this.houseNumberExtension = houseNumberExtension;
857 * Getter for land-line number's area code
859 * @return Land-line number's area code
861 public Integer getLandLineAreaCode () {
862 return this.landLineAreaCode;
866 * Setter for land-line number's area code
868 * @param landLineAreaCode Land-line number's area code
870 public void setLandLineAreaCode (final Integer landLineAreaCode) {
871 this.landLineAreaCode = landLineAreaCode;
875 * Getter for land-line number's country instance
877 * @return Land-line number's country instance
879 public Country getLandLineCountry () {
880 return this.landLineCountry;
884 * Setter for land-line number's country instance
886 * @param landLineCountry Land-line number's country instance
888 public void setLandLineCountry (final Country landLineCountry) {
889 this.landLineCountry = landLineCountry;
893 * Getter for land-line id
895 * @return Land-line id
897 public Long getLandLineId () {
898 return this.landLineId;
902 * Setter for land-line id
904 * @param landLineId Land-line id
906 public void setLandLineId (final Long landLineId) {
907 this.landLineId = landLineId;
911 * Getter for land-line number
913 * @return Land-line number
915 public Long getLandLineNumber () {
916 return this.landLineNumber;
920 * Setter for land-line number
922 * @param landLineNumber Land-line number
924 public void setLandLineNumber (final Long landLineNumber) {
925 this.landLineNumber = landLineNumber;
929 * Getter for mobile id
933 public Long getMobileId () {
934 return this.mobileId;
938 * Setter for mobile id
940 * @param mobileId Mobile id
942 public void setMobileId (final Long mobileId) {
943 this.mobileId = mobileId;
947 * Getter for mobile number
949 * @return Mobile number
951 public Long getMobileNumber () {
952 return this.mobileNumber;
956 * Setter for mobile number
958 * @param mobileNumber Mobile number
960 public void setMobileNumber (final Long mobileNumber) {
961 this.mobileNumber = mobileNumber;
965 * Getter for mobile number's carrier
967 * @return Mobile number's carrier
969 public MobileProvider getMobileProvider () {
970 return this.mobileProvider;
974 * Setter for mobile number's carrier prefix
976 * @param mobileProvider Mobile number's carrier prefix
978 public void setMobileProvider (final MobileProvider mobileProvider) {
979 this.mobileProvider = mobileProvider;
983 * Getter for personal title
985 * @return Personal title
987 public PersonalTitle getPersonalTitle () {
988 return this.personalTitle;
992 * Setter for personal title
994 * @param personalTitle Personal title
996 public void setPersonalTitle (final PersonalTitle personalTitle) {
997 this.personalTitle = personalTitle;
1001 * Getter for street name
1003 * @return Street name
1005 public String getStreet () {
1010 * Setter for street name
1012 * @param street Street name
1014 public void setStreet (final String street) {
1015 this.street = street;
1019 * Getter for ZIP code
1023 public Integer getZipCode () {
1024 return this.zipCode;
1028 * Setter for ZIP code
1030 * @param zipCode ZIP code
1032 public void setZipCode (final Integer zipCode) {
1033 this.zipCode = zipCode;
1037 public void validateContactData () {
1038 if (this.getPersonalTitle() == null) {
1040 throw new NullPointerException("contactController.gender is null"); //NOI18N
1041 } else if (this.getFirstName() == null) {
1043 throw new NullPointerException("contactController.firstName is null"); //NOI18N
1044 } else if (this.getFirstName().isEmpty()) {
1046 throw new IllegalArgumentException("contactController.firstName is empty"); //NOI18N
1047 } else if (this.getFamilyName() == null) {
1049 throw new NullPointerException("contactController.familyName is null"); //NOI18N
1050 } else if (this.getFamilyName().isEmpty()) {
1052 throw new IllegalArgumentException("contactController.familyName is empty"); //NOI18N
1053 } else if (this.getEmailAddress() == null) {
1055 throw new NullPointerException("contactController.emailAddress is null"); //NOI18N
1056 } else if (this.getEmailAddress().isEmpty()) {
1058 throw new IllegalArgumentException("contactController.emailAddress is empty"); //NOI18N
1065 private void clear () {
1068 this.setAcademicTitle(null);
1069 this.setFirstName(null);
1070 this.setFamilyName(null);
1071 this.setStreet(null);
1072 this.setHouseNumber(null);
1073 this.setHouseNumberExtension(null);
1074 this.setZipCode(null);
1076 this.setContactCountry(null);
1079 this.setEmailAddress(null);
1080 this.setLandLineCountry(null);
1081 this.setLandLineAreaCode(null);
1082 this.setLandLineNumber(null);
1083 this.setMobileProvider(null);
1084 this.setMobileNumber(null);
1085 this.setFaxCountry(null);
1086 this.setFaxAreaCode(null);
1087 this.setFaxNumber(null);
1090 this.setBirthday(null);
1091 this.setComment(null);
1095 * Updates all data in contact instance.
1097 * @param contact Contact instance
1099 private void updateContactData (final Contact contact) {
1100 // Contact instance should be valid
1101 if (null == contact) {
1103 throw new NullPointerException("contact is null"); //NOI18N
1104 } else if (contact.getContactId() == null) {
1106 throw new NullPointerException("contact.contactId is null"); //NOI18N //NOI18N
1107 } else if (contact.getContactId() < 1) {
1109 throw new IllegalStateException(MessageFormat.format("contact.contactId={0} is invalid", contact.getContactId())); //NOI18N
1112 // Update all fields
1113 contact.setContactPersonalTitle(this.getPersonalTitle());
1114 contact.setContactTitle(this.getAcademicTitle());
1115 contact.setContactFirstName(this.getFirstName());
1116 contact.setContactFamilyName(this.getFamilyName());
1117 contact.setContactStreet(this.getStreet());
1118 contact.setContactHouseNumber(this.getHouseNumber());
1119 contact.setContactHouseNumberExtension(this.getHouseNumberExtension());
1120 contact.setContactZipCode(this.getZipCode());
1121 contact.setContactCity(this.getCity());
1122 contact.setContactCountry(this.getContactCountry());
1124 // Update contact's cmobile number
1125 this.isMobileNumberUnlinked = Contacts.updateMobileNumber(contact, this.getMobileProvider(), this.getMobileNumber());
1127 // Update contact's land-line number
1128 this.isLandLineUnlinked = Contacts.updateLandLineNumber(contact, this.getLandLineCountry(), this.getLandLineAreaCode(), this.getLandLineNumber());
1130 // Update contact's fax number
1131 this.isFaxUnlinked = Contacts.updateFaxNumber(contact, this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());