2 * Copyright (C) 2016, 2017 Roland Häder
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;
21 import java.util.Iterator;
23 import javax.enterprise.context.RequestScoped;
24 import javax.enterprise.event.Event;
25 import javax.enterprise.event.Observes;
26 import javax.enterprise.inject.Any;
27 import javax.faces.view.facelets.FaceletException;
28 import javax.inject.Inject;
29 import javax.inject.Named;
30 import org.mxchange.jcontacts.model.contact.AdminContactSessionBeanRemote;
31 import org.mxchange.jcontacts.model.contact.Contact;
32 import org.mxchange.jcontacts.model.contact.ContactSessionBeanRemote;
33 import org.mxchange.jcontacts.model.contact.ContactUtils;
34 import org.mxchange.jcontacts.model.contact.UserContact;
35 import org.mxchange.jcontacts.model.contact.title.PersonalTitle;
36 import org.mxchange.jcontacts.events.contact.add.AdminAddedContactEvent;
37 import org.mxchange.jcontacts.events.contact.add.ObservableAdminAddedContactEvent;
38 import org.mxchange.jcontacts.events.contact.created.ObservableCreatedContactEvent;
39 import org.mxchange.jcontacts.events.contact.update.AdminUpdatedContactEvent;
40 import org.mxchange.jcontacts.events.contact.update.ObservableAdminUpdatedContactEvent;
41 import org.mxchange.jcontacts.exceptions.ContactAlreadyAddedException;
42 import org.mxchange.jcountry.model.data.Country;
43 import org.mxchange.jjobs.beans.BaseJobsController;
44 import org.mxchange.jphone.model.phonenumbers.DialableNumber;
45 import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
46 import org.mxchange.jphone.model.phonenumbers.fax.FaxNumber;
47 import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber;
48 import org.mxchange.jphone.model.phonenumbers.landline.LandLineNumber;
49 import org.mxchange.jphone.phonenumbers.model.mobile.DialableMobileNumber;
50 import org.mxchange.jphone.model.phonenumbers.mobile.MobileNumber;
51 import org.mxchange.jphone.phonenumbers.model.mobileprovider.MobileProvider;
54 * An administrative user controller (bean)
56 * @author Roland Häder<roland@mxchange.org>
58 @Named ("adminContactController")
60 public class JobsAdminContactWebRequestBean extends BaseJobsController implements JobsAdminContactWebRequestController {
65 private static final long serialVersionUID = 542_145_347_916L;
68 * Academic academicTitle
70 private String academicTitle;
73 * An event fired when the administrator has added a new contact
77 private Event<ObservableAdminAddedContactEvent> addedContactEvent;
80 * Administrative contact EJB
82 @EJB (lookup = "java:global/jjobs-ejb/adminContact!org.mxchange.jcontacts.contact.AdminContactSessionBeanRemote")
83 private AdminContactSessionBeanRemote adminContactBean;
88 private Date birthday;
98 private String comment;
101 * EJB for general contact purposes
103 @EJB (lookup = "java:global/jjobs-ejb/contact!org.mxchange.jcontacts.contact.ContactSessionBeanRemote")
104 private ContactSessionBeanRemote contactBean;
107 * General contact controller
110 private JobsContactWebRequestController contactController;
115 private Country contactCountry;
120 private Long contactId;
125 private String emailAddress;
130 private String familyName;
133 * Fax number's area code
135 private Integer faxAreaCode;
138 * Country instance for fax number
140 private Country faxCountry;
150 private Long faxNumber;
155 private String firstName;
160 private Short houseNumber;
163 * House number extension
165 private String houseNumberExtension;
168 * Whether a fax entry has been unlinked
170 private boolean isFaxUnlinked;
173 * Whether a land-line number has been unlinked
175 private boolean isLandLineUnlinked;
178 * Whether a cmobile entry has been unlinked
180 private boolean isMobileNumberUnlinked;
183 * Phone number area code
185 private Integer landLineAreaCode;
188 * Country instance for phone number
190 private Country landLineCountry;
193 * Land-line id number
195 private Long landLineId;
200 private Long landLineNumber;
205 private Long mobileId;
210 private Long mobileNumber;
213 * Mobile number's provider
215 private MobileProvider mobileProvider;
218 * PersonalTitle instance
220 private PersonalTitle personalTitle;
225 private String street;
228 * An event fired when the administrator has updated contact data
232 private Event<ObservableAdminUpdatedContactEvent> updatedContactEvent;
237 private Integer zipCode;
240 * Default constructor
242 public JobsAdminContactWebRequestBean () {
243 // Call super constructor
248 * Adds contact data to database and redirects on success. If the contact is
249 * already found, a proper exception is thrown.
251 * @return Redirect outcome
253 public String addContact () {
254 // Are all minimum fields set?
255 if (this.getPersonalTitle() == null) {
257 throw new NullPointerException("personalTitle is null"); //NOI18N
258 } else if (this.getFirstName() == null) {
260 throw new NullPointerException("firstName is null"); //NOI18N
261 } else if (this.getFirstName().isEmpty()) {
263 throw new IllegalStateException("firstName is empty"); //NOI18N
264 } else if (this.getFamilyName() == null) {
266 throw new NullPointerException("familyName is null"); //NOI18N
267 } else if (this.getFamilyName().isEmpty()) {
269 throw new IllegalStateException("familyName is empty"); //NOI18N
272 // Create new contact instance
273 final Contact contact = this.createContactInstance();
275 // Default is not same contact
276 if (this.isSameContactFound(contact)) {
277 // Already registered
278 throw new FaceletException(new ContactAlreadyAddedException(contact));
282 final Contact updatedContact;
287 updatedContact = this.adminContactBean.addContact(contact);
288 } catch (final ContactAlreadyAddedException ex) {
290 throw new FaceletException(ex);
294 this.addedContactEvent.fire(new AdminAddedContactEvent(updatedContact));
300 return "admin_list_contact"; //NOI18N
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 * @return Redirect outcome
492 public String editContactData () {
493 // Get contact instance
494 final Contact contact = this.createContactInstance();
496 // Check if contact instance is in helper and valid
497 if (null == contact) {
499 throw new NullPointerException("beanHelper.contact is null"); //NOI18N
500 } else if (contact.getContactId() == null) {
502 throw new NullPointerException("beanHelper.contact.contactId is null"); //NOI18N //NOI18N
503 } else if (contact.getContactId() < 1) {
505 throw new IllegalStateException(MessageFormat.format("beanHelper.contact.contactId={0} is invalid", contact.getContactId())); //NOI18N
508 // Update all data in contact
509 this.updateContactData(contact);
511 // Call EJB for updating contact data
512 final Contact updatedContact = this.contactBean.updateContactData(contact, this.isMobileNumberUnlinked, this.isLandLineUnlinked, this.isFaxUnlinked);
515 this.updatedContactEvent.fire(new AdminUpdatedContactEvent(updatedContact));
520 // Return to contact list (for now)
521 return "admin_list_contact"; //NOI18N
525 * Returns a text representation of given mobile number or null if not set.
527 * @param mobileNumber Mobile number
529 * @return Text representation or null
531 public String generateMobileNumber (final DialableMobileNumber mobileNumber) {
533 if (null == mobileNumber) {
539 final String number = String.format(
541 mobileNumber.getMobileProvider().getProviderCountry().getCountryExternalDialPrefix(),
542 mobileNumber.getMobileProvider().getProviderDialPrefix(),
543 mobileNumber.getPhoneNumber()
551 * Returns a text representation of given land-line or fax number or null if
554 * @param phoneNumber Land-line or fax number
556 * @return Text representation or null
558 public String generatePhoneNumber (final DialableNumber phoneNumber) {
560 if (null == phoneNumber) {
566 final String number = String.format(
568 phoneNumber.getPhoneCountry().getCountryExternalDialPrefix(),
569 phoneNumber.getPhoneAreaCode(),
570 phoneNumber.getPhoneNumber()
578 * Getter for academic title
580 * @return Academic title
582 public String getAcademicTitle () {
583 return this.academicTitle;
587 * Setter for academic title
589 * @param academicTitle Academic title
591 public void setAcademicTitle (final String academicTitle) {
592 this.academicTitle = academicTitle;
596 * Getter for birth day
600 @SuppressWarnings ("ReturnOfDateField")
601 public Date getBirthday () {
602 return this.birthday;
606 * Setter for birth day
608 * @param birthday Birth day
610 @SuppressWarnings ("AssignmentToDateFieldFromParameter")
611 public void setBirthday (final Date birthday) {
612 this.birthday = birthday;
616 * Getter for city name
620 public String getCity () {
625 * Setter for city name
627 * @param city City name
629 public void setCity (final String city) {
634 * Getter for comments
638 public String getComment () {
645 * @param comment Comments
647 public void setComment (final String comment) {
648 this.comment = comment;
652 * Getter for contactCountry instance
654 * @return Country instance
656 public Country getContactCountry () {
657 return this.contactCountry;
661 * Setter for contactCountry instance
663 * @param contactCountry Country instance
665 public void setContactCountry (final Country contactCountry) {
666 this.contactCountry = contactCountry;
670 * Getter for contact id
674 public Long getContactId () {
675 return this.contactId;
679 * Setter for contact id
681 * @param contactId Contact id
683 public void setContactId (final Long contactId) {
684 this.contactId = contactId;
688 public String getControllerType () {
689 return "admin"; //NOI18N
694 public void setControllerType (final String controllerType) {
695 throw new UnsupportedOperationException("Setting controller type is not supported."); //NOI18N
699 * Getter for email address
701 * @return Email address
703 public String getEmailAddress () {
704 return this.emailAddress;
708 * Setter for email address
710 * @param emailAddress Email address
712 public void setEmailAddress (final String emailAddress) {
713 this.emailAddress = emailAddress;
719 * @return the familyName
721 public String getFamilyName () {
722 return this.familyName;
728 * @param familyName the familyName to set
730 public void setFamilyName (final String familyName) {
731 this.familyName = familyName;
735 * Getter for fax number's area code
737 * @return Fax number's area code
739 public Integer getFaxAreaCode () {
740 return this.faxAreaCode;
744 * Setter for fax number's area code
746 * @param faxAreaCode Fax number's area code
748 public void setFaxAreaCode (final Integer faxAreaCode) {
749 this.faxAreaCode = faxAreaCode;
753 * Getter for fax's country instance
755 * @return Fax' country instance
757 public Country getFaxCountry () {
758 return this.faxCountry;
762 * Setter for fax's country instance
764 * @param faxCountry Fax' country instance
766 public void setFaxCountry (final Country faxCountry) {
767 this.faxCountry = faxCountry;
775 public Long getFaxId () {
782 * @param faxId Fax id
784 public void setFaxId (final Long faxId) {
789 * Getter for fax number
793 public Long getFaxNumber () {
794 return this.faxNumber;
798 * Setter for fax number
800 * @param faxNumber Fax number
802 public void setFaxNumber (final Long faxNumber) {
803 this.faxNumber = faxNumber;
807 * Getter for first name
811 public String getFirstName () {
812 return this.firstName;
816 * Setter for first name
818 * @param firstName First name
820 public void setFirstName (final String firstName) {
821 this.firstName = firstName;
825 * Getter for house number
827 * @return House number
829 public Short getHouseNumber () {
830 return this.houseNumber;
834 * Setter for house number
836 * @param houseNumber House number
838 public void setHouseNumber (final Short houseNumber) {
839 this.houseNumber = houseNumber;
843 * Getter for house number extension. Example: 123a, 'a' is the extension
844 * and 123 is the house number.
846 * @return House number extension
848 public String getHouseNumberExtension () {
849 return this.houseNumberExtension;
853 * Setter for house number extension
855 * @param houseNumberExtension House number extension
857 public void setHouseNumberExtension (final String houseNumberExtension) {
858 this.houseNumberExtension = houseNumberExtension;
862 * Getter for land-line number's area code
864 * @return Land-line number's area code
866 public Integer getLandLineAreaCode () {
867 return this.landLineAreaCode;
871 * Setter for land-line number's area code
873 * @param landLineAreaCode Land-line number's area code
875 public void setLandLineAreaCode (final Integer landLineAreaCode) {
876 this.landLineAreaCode = landLineAreaCode;
880 * Getter for land-line number's country instance
882 * @return Land-line number's country instance
884 public Country getLandLineCountry () {
885 return this.landLineCountry;
889 * Setter for land-line number's country instance
891 * @param landLineCountry Land-line number's country instance
893 public void setLandLineCountry (final Country landLineCountry) {
894 this.landLineCountry = landLineCountry;
898 * Getter for land-line id
900 * @return Land-line id
902 public Long getLandLineId () {
903 return this.landLineId;
907 * Setter for land-line id
909 * @param landLineId Land-line id
911 public void setLandLineId (final Long landLineId) {
912 this.landLineId = landLineId;
916 * Getter for land-line number
918 * @return Land-line number
920 public Long getLandLineNumber () {
921 return this.landLineNumber;
925 * Setter for land-line number
927 * @param landLineNumber Land-line number
929 public void setLandLineNumber (final Long landLineNumber) {
930 this.landLineNumber = landLineNumber;
934 * Getter for mobile id
938 public Long getMobileId () {
939 return this.mobileId;
943 * Setter for mobile id
945 * @param mobileId Mobile id
947 public void setMobileId (final Long mobileId) {
948 this.mobileId = mobileId;
952 * Getter for mobile number
954 * @return Mobile number
956 public Long getMobileNumber () {
957 return this.mobileNumber;
961 * Setter for mobile number
963 * @param mobileNumber Mobile number
965 public void setMobileNumber (final Long mobileNumber) {
966 this.mobileNumber = mobileNumber;
970 * Getter for mobile number's carrier
972 * @return Mobile number's carrier
974 public MobileProvider getMobileProvider () {
975 return this.mobileProvider;
979 * Setter for mobile number's carrier prefix
981 * @param mobileProvider Mobile number's carrier prefix
983 public void setMobileProvider (final MobileProvider mobileProvider) {
984 this.mobileProvider = mobileProvider;
988 * Getter for personal title
990 * @return Personal title
992 public PersonalTitle getPersonalTitle () {
993 return this.personalTitle;
997 * Setter for personal title
999 * @param personalTitle Personal title
1001 public void setPersonalTitle (final PersonalTitle personalTitle) {
1002 this.personalTitle = personalTitle;
1006 * Getter for street name
1008 * @return Street name
1010 public String getStreet () {
1015 * Setter for street name
1017 * @param street Street name
1019 public void setStreet (final String street) {
1020 this.street = street;
1024 * Getter for ZIP code
1028 public Integer getZipCode () {
1029 return this.zipCode;
1033 * Setter for ZIP code
1035 * @param zipCode ZIP code
1037 public void setZipCode (final Integer zipCode) {
1038 this.zipCode = zipCode;
1042 public void validateContactData () {
1043 if (this.getPersonalTitle() == null) {
1045 throw new NullPointerException("contactController.gender is null"); //NOI18N
1046 } else if (this.getFirstName() == null) {
1048 throw new NullPointerException("contactController.firstName is null"); //NOI18N
1049 } else if (this.getFirstName().isEmpty()) {
1051 throw new IllegalArgumentException("contactController.firstName is empty"); //NOI18N
1052 } else if (this.getFamilyName() == null) {
1054 throw new NullPointerException("contactController.familyName is null"); //NOI18N
1055 } else if (this.getFamilyName().isEmpty()) {
1057 throw new IllegalArgumentException("contactController.familyName is empty"); //NOI18N
1058 } else if (this.getEmailAddress() == null) {
1060 throw new NullPointerException("contactController.emailAddress is null"); //NOI18N
1061 } else if (this.getEmailAddress().isEmpty()) {
1063 throw new IllegalArgumentException("contactController.emailAddress is empty"); //NOI18N
1070 private void clear () {
1073 this.setAcademicTitle(null);
1074 this.setFirstName(null);
1075 this.setFamilyName(null);
1076 this.setStreet(null);
1077 this.setHouseNumber(null);
1078 this.setHouseNumberExtension(null);
1079 this.setZipCode(null);
1081 this.setContactCountry(null);
1084 this.setEmailAddress(null);
1085 this.setLandLineCountry(null);
1086 this.setLandLineAreaCode(null);
1087 this.setLandLineNumber(null);
1088 this.setMobileProvider(null);
1089 this.setMobileNumber(null);
1090 this.setFaxCountry(null);
1091 this.setFaxAreaCode(null);
1092 this.setFaxNumber(null);
1095 this.setBirthday(null);
1096 this.setComment(null);
1100 * Checks whether the given contact is found
1102 * @param contact Contact instance
1104 * @return Whether contact has been found
1106 private boolean isSameContactFound (final Contact contact) {
1107 // Default is not found
1108 boolean IsFound = false;
1111 final Iterator<Contact> iterator = this.contactController.allContacts().iterator();
1114 while (iterator.hasNext()) {
1116 final Contact next = iterator.next();
1119 if (ContactUtils.isSameContact(contact, next)) {
1120 // Yes, then abort loop
1131 * Updates all data in contact instance.
1133 * @param contact Contact instance
1135 private void updateContactData (final Contact contact) {
1136 // Contact instance should be valid
1137 if (null == contact) {
1139 throw new NullPointerException("contact is null"); //NOI18N
1140 } else if (contact.getContactId() == null) {
1142 throw new NullPointerException("contact.contactId is null"); //NOI18N //NOI18N
1143 } else if (contact.getContactId() < 1) {
1145 throw new IllegalStateException(MessageFormat.format("contact.contactId={0} is invalid", contact.getContactId())); //NOI18N
1148 // Update all fields
1149 contact.setContactPersonalTitle(this.getPersonalTitle());
1150 contact.setContactTitle(this.getAcademicTitle());
1151 contact.setContactFirstName(this.getFirstName());
1152 contact.setContactFamilyName(this.getFamilyName());
1153 contact.setContactStreet(this.getStreet());
1154 contact.setContactHouseNumber(this.getHouseNumber());
1155 contact.setContactHouseNumberExtension(this.getHouseNumberExtension());
1156 contact.setContactZipCode(this.getZipCode());
1157 contact.setContactCity(this.getCity());
1158 contact.setContactCountry(this.getContactCountry());
1160 // Update contact's cmobile number
1161 this.isMobileNumberUnlinked = ContactUtils.updateMobileNumber(contact, this.getMobileProvider(), this.getMobileNumber());
1163 // Update contact's land-line number
1164 this.isLandLineUnlinked = ContactUtils.updateLandLineNumber(contact, this.getLandLineCountry(), this.getLandLineAreaCode(), this.getLandLineNumber());
1166 // Update contact's fax number
1167 this.isFaxUnlinked = ContactUtils.updateFaxNumber(contact, this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());