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.helper;
19 import java.text.MessageFormat;
20 import javax.enterprise.event.Event;
21 import javax.enterprise.inject.Any;
22 import javax.faces.view.ViewScoped;
23 import javax.inject.Inject;
24 import javax.inject.Named;
25 import org.mxchange.jcontacts.events.contact.created.CreatedContactEvent;
26 import org.mxchange.jcontacts.events.contact.created.ObservableCreatedContactEvent;
27 import org.mxchange.jcontacts.model.contact.Contact;
28 import org.mxchange.jcontactsbusiness.model.basicdata.BasicData;
29 import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice;
30 import org.mxchange.jcontactsbusiness.model.department.Department;
31 import org.mxchange.jcontactsbusiness.model.employee.Employable;
32 import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter;
33 import org.mxchange.jcountry.model.data.Country;
34 import org.mxchange.jjobs.beans.BaseJobsBean;
35 import org.mxchange.jjobs.beans.localization.JobsLocalizationSessionController;
36 import org.mxchange.jjobs.beans.user.JobsUserWebRequestController;
37 import org.mxchange.jphone.events.fax.created.CreatedFaxNumberEvent;
38 import org.mxchange.jphone.events.fax.created.ObservableCreatedFaxNumberEvent;
39 import org.mxchange.jphone.events.landline.created.CreatedLandLineNumberEvent;
40 import org.mxchange.jphone.events.landline.created.ObservableCreatedLandLineNumberEvent;
41 import org.mxchange.jphone.events.mobile.created.CreatedMobileNumberEvent;
42 import org.mxchange.jphone.events.mobile.created.ObservableCreatedMobileNumberEvent;
43 import org.mxchange.jphone.model.phonenumbers.DialableNumber;
44 import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
45 import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber;
46 import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber;
47 import org.mxchange.jusercore.events.user.created.CreatedUserEvent;
48 import org.mxchange.jusercore.events.user.created.ObservableCreatedUserEvent;
49 import org.mxchange.jusercore.model.user.User;
52 * A general helper for beans
54 * @author Roland Häder<roland@mxchange.org>
58 public class JobsWebViewHelperBean extends BaseJobsBean implements JobsWebViewHelperController {
63 private static final long serialVersionUID = 17_258_793_567_145_701L;
68 private Contact contact;
71 * Event for when a contact instance was created
75 private Event<ObservableCreatedContactEvent> contactCreatedEvent;
78 * Regular user controller
81 private FinancialsContactListWebViewController contactListController;
86 private DialableFaxNumber faxNumber;
89 * Event for when a fax number instance was created
93 private Event<ObservableCreatedFaxNumberEvent> faxNumberCreatedEvent;
98 private DialableLandLineNumber landLineNumber;
101 * Event for when a land-line number instance was created
105 private Event<ObservableCreatedLandLineNumberEvent> landLineNumberCreatedEvent;
108 * Localization controller
111 private JobsLocalizationSessionController localizationController;
116 private DialableMobileNumber mobileNumber;
119 * Event for when a mobile number instance was created
123 private Event<ObservableCreatedMobileNumberEvent> mobileNumberCreatedEvent;
131 * Event for when a user instance was created
135 private Event<ObservableCreatedUserEvent> userCreatedEvent;
138 * Default constructor
140 public JobsWebViewHelperBean () {
141 // Call super constructor
146 * Getter for contact instance
148 * @return Contact instance
150 public Contact getContact () {
155 * Setter for contact instance
157 * @param contact Contact instance
159 public void setContact (final Contact contact) {
160 this.contact = contact;
164 * Returns a message key depending on if this contact is a user and/or a
165 * contact. If this contact is unused, a default key is returned.
167 * @param contact Contact instance to check
169 * @return Message key
171 public String getContactUsageMessageKey (final Contact contact) {
172 // The contact must be valid
173 if (null == contact) {
175 throw new NullPointerException("contact is null"); //NOI18N
176 } else if (contact.getContactId() == null) {
178 throw new NullPointerException("contact.contactId is null"); //NOI18N
179 } else if (contact.getContactId() < 1) {
181 throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N
184 // Default key is "unused"
185 String messageKey = "CONTACT_IS_UNUSED"; //NOI18N
188 if (this.contactListController.isContactFound(contact)) {
190 messageKey = "CONTACT_IS_USER"; //NOI18N
193 // Return message key
198 * Getter for dialable fax number
200 * @return Dialable fax number
202 public DialableFaxNumber getFaxNumber () {
203 return this.faxNumber;
207 * Setter for dialable fax number
209 * @param faxNumber Dialable fax number
211 public void setFaxNumber (final DialableFaxNumber faxNumber) {
212 this.faxNumber = faxNumber;
216 * Getter for dialable land-line number
218 * @return Dialable land-line number
220 public DialableLandLineNumber getLandLineNumber () {
221 return this.landLineNumber;
225 * Setter for dialable land-line number
227 * @param landLineNumber Dialable land-line number
229 public void setLandLineNumber (final DialableLandLineNumber landLineNumber) {
230 this.landLineNumber = landLineNumber;
234 * Getter for dialable mobile number
236 * @return Dialable mobile number
238 public DialableMobileNumber getMobileNumber () {
239 return this.mobileNumber;
243 * Setter for dialable mobile number
245 * @param mobileNumber Dialable mobile number
247 public void setMobileNumber (final DialableMobileNumber mobileNumber) {
248 this.mobileNumber = mobileNumber;
252 * Getter for user instance
254 * @return User instance
256 public User getUser () {
261 * Setter for user instance
263 * @param user User instance
265 public void setUser (final User user) {
270 * Notifies other controllers (backing beans) if a contact id has been
271 * successfully converted to a Contact instance.
273 public void notifyControllerContactConverted () {
274 // Validate contact instance
275 if (this.getContact() == null) {
277 throw new NullPointerException("this.contact is null"); //NOI18N
278 } else if (this.getContact().getContactId() == null) {
280 throw new NullPointerException("this.contact.contactId is null"); //NOI18N
281 } else if (this.getContact().getContactId() < 1) {
283 throw new IllegalStateException(MessageFormat.format("this.contact.contactId={0} is not valid.", this.getContact().getContactId())); //NOI18N
286 // Set all phone instances
287 this.setPhoneInstances(this.getContact());
289 // Set all fields: user
290 this.contactCreatedEvent.fire(new CreatedContactEvent(this.getContact()));
294 * Notifies other controllers (backing beans) if a phone id has been
295 * successfully converted to a DialableFaxNumber instance.
297 public void notifyControllerFaxNumberConverted () {
298 // Validate fax instance
299 if (this.getFaxNumber() == null) {
301 throw new NullPointerException("this.faxNumber is null"); //NOI18N
302 } else if (this.getFaxNumber().getPhoneId() == null) {
304 throw new NullPointerException("this.faxNumber.phoneId is null"); //NOI18N
305 } else if (this.getFaxNumber().getPhoneId() < 1) {
307 throw new IllegalArgumentException(MessageFormat.format("this.faxNumber.phoneId={0} is not valid", this.getFaxNumber().getPhoneId())); //NOI18N
308 } else if (this.getFaxNumber().getPhoneAreaCode() == null) {
310 throw new NullPointerException("this.faxNumber.phoneAreaCode is null"); //NOI18N
311 } else if (this.getFaxNumber().getPhoneAreaCode() < 1) {
313 throw new IllegalArgumentException(MessageFormat.format("this.faxNumber.phoneAreaCode={0} is not valid", this.getFaxNumber().getPhoneAreaCode())); //NOI18N
314 } else if (this.getFaxNumber().getPhoneCountry() == null) {
316 throw new NullPointerException("this.faxNumber.phoneCountry is null"); //NOI18N
317 } else if (this.getFaxNumber().getPhoneCountry().getCountryId() == null) {
319 throw new NullPointerException("this.faxNumber.phoneCountry.countryId is null"); //NOI18N
320 } else if (this.getFaxNumber().getPhoneCountry().getCountryId() < 1) {
322 throw new IllegalArgumentException(MessageFormat.format("this.faxNumber.phoneCountry.countryId={0} is invalid", this.getFaxNumber().getPhoneCountry().getCountryId())); //NOI18N
323 } else if (this.getFaxNumber().getPhoneNumber() == null) {
324 // Throw NPE again ...
325 throw new NullPointerException("this.faxNumber.phoneNumber is null"); //NOI18N
326 } else if (this.getFaxNumber().getPhoneNumber() < 1) {
328 throw new IllegalArgumentException(MessageFormat.format("this.faxNumber.phoneNumber={0} is not valid", this.getFaxNumber().getPhoneNumber())); //NOI18N
332 this.faxNumberCreatedEvent.fire(new CreatedFaxNumberEvent(this.getFaxNumber()));
336 * Notifies other controllers (backing beans) if a phone id has been
337 * successfully converted to a DialableLandLineNumber instance.
339 public void notifyControllerLandLineNumberConverted () {
340 // Validate land-line instance
341 if (this.getLandLineNumber() == null) {
343 throw new NullPointerException("this.landLineNumber is null"); //NOI18N
344 } else if (this.getLandLineNumber().getPhoneId() == null) {
346 throw new NullPointerException("this.landLineNumber.phoneId is null"); //NOI18N
347 } else if (this.getLandLineNumber().getPhoneId() < 1) {
349 throw new IllegalArgumentException(MessageFormat.format("this.landLineNumber.phoneId={0} is not valid", this.getLandLineNumber().getPhoneId())); //NOI18N
350 } else if (this.getLandLineNumber().getPhoneAreaCode() == null) {
352 throw new NullPointerException("this.landLineNumber.phoneAreaCode is null"); //NOI18N
353 } else if (this.getLandLineNumber().getPhoneAreaCode() < 1) {
355 throw new IllegalArgumentException(MessageFormat.format("this.landLineNumber.phoneAreaCode={0} is not valid", this.getFaxNumber().getPhoneAreaCode())); //NOI18N
356 } else if (this.getLandLineNumber().getPhoneCountry() == null) {
358 throw new NullPointerException("this.landLineNumber.phoneCountry is null"); //NOI18N
359 } else if (this.getLandLineNumber().getPhoneCountry().getCountryId() == null) {
361 throw new NullPointerException("this.landLineNumber.phoneCountry.countryId is null"); //NOI18N
362 } else if (this.getLandLineNumber().getPhoneCountry().getCountryId() < 1) {
364 throw new IllegalArgumentException(MessageFormat.format("this.landLineNumber.phoneCountry.countryId={0} is invalid", this.getLandLineNumber().getPhoneCountry().getCountryId())); //NOI18N
365 } else if (this.getLandLineNumber().getPhoneNumber() == null) {
366 // Throw NPE again ...
367 throw new NullPointerException("this.landLineNumber.phoneNumber is null"); //NOI18N
368 } else if (this.getLandLineNumber().getPhoneNumber() < 1) {
370 throw new IllegalArgumentException(MessageFormat.format("this.landLineNumber.phoneNumber={0} is not valid", this.getLandLineNumber().getPhoneNumber())); //NOI18N
374 this.landLineNumberCreatedEvent.fire(new CreatedLandLineNumberEvent(this.getLandLineNumber()));
378 * Notifies other controllers (backing beans) if a phone id has been
379 * successfully converted to a DialableMobileNumber instance.
381 public void notifyControllerMobileNumberConverted () {
382 // Validate mobile instance
383 if (this.getMobileNumber() == null) {
385 throw new NullPointerException("this.mobileNumber is null"); //NOI18N
386 } else if (this.getMobileNumber().getMobileId() == null) {
388 throw new NullPointerException("this.mobileNumber.mobileId is null"); //NOI18N
389 } else if (this.getMobileNumber().getMobileId() < 1) {
391 throw new IllegalArgumentException(MessageFormat.format("this.mobileNumber.mobileId={0} is not valid", this.getMobileNumber().getMobileId())); //NOI18N
392 } else if (this.getMobileNumber().getMobileProvider() == null) {
394 throw new NullPointerException("this.mobileNumber.mobileProvider is null"); //NOI18N
395 } else if (this.getMobileNumber().getMobileProvider().getProviderId() == null) {
397 throw new NullPointerException("this.mobileNumber.mobileProvider.providerId is null"); //NOI18N
398 } else if (this.getMobileNumber().getMobileProvider().getProviderId() < 1) {
400 throw new IllegalArgumentException(MessageFormat.format("this.mobileNumber.mobileProvider.providerId={0} is invalid", this.getMobileNumber().getMobileProvider().getProviderId())); //NOI18N
401 } else if (this.getMobileNumber().getMobileNumber() == null) {
402 // Throw NPE again ...
403 throw new NullPointerException("this.mobileNumber.mobileNumber is null"); //NOI18N
404 } else if (this.getMobileNumber().getMobileNumber() < 1) {
406 throw new IllegalArgumentException(MessageFormat.format("this.mobileNumber.mobileNumber={0} is not valid", this.getMobileNumber().getMobileNumber())); //NOI18N
410 this.mobileNumberCreatedEvent.fire(new CreatedMobileNumberEvent(this.getMobileNumber()));
414 * Notifies other controllers (backing beans) if a user id has been
415 * successfully converted to a User instance.
417 public void notifyControllerUserConverted () {
418 // Validate user instance
419 if (this.getUser() == null) {
421 throw new NullPointerException("this.user is null"); //NOI18N
422 } else if (this.getUser().getUserId() == null) {
424 throw new NullPointerException("this.user.userId is null"); //NOI18N
425 } else if (this.getUser().getUserId() < 1) {
427 throw new IllegalStateException(MessageFormat.format("this.user.userId={0} is not valid.", this.getUser().getUserId())); //NOI18N
431 final Contact userContact = this.getUser().getUserContact();
433 // Set contact here, too. This avoids parameters that cannot auto-complete in IDEs.
434 this.setContact(userContact);
436 // Set all phone instances
437 this.setPhoneInstances(userContact);
440 this.userCreatedEvent.fire(new CreatedUserEvent(this.getUser()));
444 * Renders data of basic company data
446 * @param basicData Basic company data instance
447 * @param useShortName Whether to use short name or long name of company
449 * @return Basic company data as string
451 public String renderBasicData (final BasicData basicData, final boolean useShortName) {
452 // Default is empty string, so let's get started
453 final StringBuilder sb = new StringBuilder(30);
455 // Is basic company data set?
456 if (basicData instanceof BasicData) {
457 // Short or long name?
459 // Add company's long name
460 sb.append(basicData.getCompanyShortName()); //NOI18N
462 // Add company's long name
463 sb.append(basicData.getCompanyName()); //NOI18N
466 // Is email address set?
467 if (basicData.getCompanyEmailAddress() != null) {
469 sb.append(", ").append(basicData.getCompanyEmailAddress()); //NOI18N
472 // Is tax number set?
473 if (basicData.getCompanyTaxNumber() != null) {
475 sb.append(", ").append(basicData.getCompanyTaxNumber()); //NOI18N
480 return sb.toString();
484 * Returns the branch office's full address. If null is provided, an empty
485 * string is returned.
487 * @param branchOffice Branch office instance
489 * @return Branch office's address
491 public String renderBranchOffice (final BranchOffice branchOffice) {
492 // Default is empty string, so let's get started
493 final StringBuilder sb = new StringBuilder(30);
495 // Is a branch office instance given?
496 if (branchOffice instanceof BranchOffice) {
497 // This should not happen:
498 if (branchOffice.getBranchId() == null) {
500 throw new NullPointerException("branchOffice.branchId is null"); //NOI18N
501 } else if (branchOffice.getBranchId() < 1) {
503 throw new IllegalArgumentException(MessageFormat.format("branchOffice.branchId={0} is invalid.", branchOffice.getBranchId())); //NOI18N
504 } else if (branchOffice.getBranchCompany() == null) {
506 throw new NullPointerException("branchOffice.branchCompany is null"); //NOI18N
507 } else if (branchOffice.getBranchCountry() == null) {
509 throw new NullPointerException("branchOffice.branchCountry is null"); //NOI18N
512 // Yes, then append all data
513 sb.append(this.renderBasicData(branchOffice.getBranchCompany(), true));
514 sb.append(", "); //NOI18N
515 sb.append(branchOffice.getBranchStreet());
516 sb.append(" "); //NOI18N
517 sb.append(branchOffice.getBranchHouseNumber());
518 sb.append(", "); //NOI18N
519 sb.append(branchOffice.getBranchCountry().getCountryCode());
520 sb.append(" "); //NOI18N
521 sb.append(branchOffice.getBranchZipCode());
522 sb.append(" "); //NOI18N
523 sb.append(branchOffice.getBranchCity());
527 return sb.toString();
531 * Returns the contact's personal title, family name and name. If null is
532 * provided, an empty string is returned.
534 * @param contact Contact instance
536 * @return Contact's full name
538 public String renderContact (final Contact contact) {
539 // Default is empty string, so let's get started
540 final StringBuilder sb = new StringBuilder(20);
543 if (contact instanceof Contact) {
545 sb.append(this.getMessageFromBundle(contact.getContactPersonalTitle().getMessageKey()));
546 sb.append(" "); //NOI18N
547 sb.append(contact.getContactFirstName());
548 sb.append(" "); //NOI18N
549 sb.append(contact.getContactFamilyName());
553 return sb.toString();
557 * Returns the text representation of given country. If null is provided, an
558 * empty string is returned.
560 * @param country Country instance
562 * @return Country's text representation
564 public String renderCountry (final Country country) {
565 // Default is empty string, so let's get started
566 final StringBuilder sb = new StringBuilder(20);
568 // Is a country given?
569 if (country instanceof Country) {
570 // Yes, then render it
571 sb.append(this.getMessageFromBundle(country.getCountryI18nKey()));
572 sb.append(" ("); //NOI18N
573 sb.append(country.getCountryCode());
574 sb.append(")"); //NOI18N
578 return sb.toString();
582 * Returns the department's name and name of assigned company. If null is
583 * provided, an empty string is returned.
585 * @param department Department instance
587 * @return Department's full name
589 public String renderDepartment (final Department department) {
590 // Default is empty string, so let's get started
591 final StringBuilder sb = new StringBuilder(10);
593 // Is a department set?
594 if (department instanceof Department) {
596 sb.append(this.getMessageFromBundle(department.getDepartmentI18nKey()));
597 sb.append(" ("); //NOI18N
598 sb.append(this.renderBasicData(department.getDepartmentCompany(), true));
599 sb.append(")"); //NOI18N
603 return sb.toString();
607 * Returns the employee's number, personal title, family name and name if
608 * available. If null is provided, an empty string is returned.
610 * @param employee Employable instance
612 * @return A string representing an employee
614 public String renderEmployee (final Employable employee) {
615 // Default is empty string, so let's get started
616 final StringBuilder sb = new StringBuilder(20);
619 if (employee instanceof Employable) {
620 // Is the number given?
621 if (employee.getEmployeeNumber() != null) {
623 sb.append(employee.getEmployeeNumber());
626 // Is contact data found?
627 if (employee.getEmployeePersonalData() instanceof Contact) {
628 // Yes, then render it
629 final String contactName = this.renderContact(employee.getEmployeePersonalData());
632 if (contactName != null && !contactName.isEmpty()) {
633 // Only add braces when employee number is given
634 if (employee.getEmployeeNumber() != null) {
635 sb.append(" ("); //NOI18N
639 sb.append(contactName);
641 // Only add braces when employee number is given
642 if (employee.getEmployeeNumber() != null) {
643 sb.append(")"); //NOI18N
648 // Is a department found?
649 if (employee.getEmployeeDepartment() instanceof Department) {
650 // Only add braces when employee number is given
651 if (employee.getEmployeeNumber() != null || employee.getEmployeePersonalData() instanceof Contact) {
652 sb.append(" ("); //NOI18N
655 // Add department name
656 sb.append(this.renderDepartment(employee.getEmployeeDepartment()));
658 // Only add braces when employee number is given
659 if (employee.getEmployeeNumber() != null || employee.getEmployeePersonalData() instanceof Contact) {
660 sb.append(")"); //NOI18N
666 return sb.toString();
670 * Returns the headquarter address. If null is provided, an empty string is
673 * @param headquarter Headquarter instance
675 * @return Headquarter address
677 public String renderHeadquarter (final Headquarter headquarter) {
678 // Default is empty string, so let's get started
679 final StringBuilder sb = new StringBuilder(10);
681 // Is a headquarter set?
682 if (headquarter instanceof Headquarter) {
684 sb.append(headquarter.getHeadquarterStreet());
685 sb.append(" "); //NOI18N
686 sb.append(headquarter.getHeadquarterHouseNumber());
688 // Is store/suite number set?
689 if (headquarter.getHeadquarterStore() instanceof Short) {
690 sb.append(" ("); //NOI18N
691 sb.append(this.getMessageFromBundle("DATA_STORE")); //NOI18N
692 sb.append(" "); //NOI18N
693 sb.append(headquarter.getHeadquarterStore());
694 sb.append(", "); //NOI18N
695 sb.append(this.getMessageFromBundle("DATA_SUITE_NUMBER")); //NOI18N
696 sb.append(" "); //NOI18N
697 sb.append(headquarter.getHeadquarterSuiteNumber());
698 sb.append(")"); //NOI18N
701 // Continue with country, ZIP code and city
702 sb.append(", "); //NOI18N
703 sb.append(headquarter.getHeadquarterCountry().getCountryCode());
704 sb.append(" "); //NOI18N
705 sb.append(headquarter.getHeadquarterZipCode());
706 sb.append(" "); //NOI18N
707 sb.append(headquarter.getHeadquarterCity());
711 return sb.toString();
715 * Renders given mobile number (land-line and fax number). If null is
716 * provided, an empty string is returned.
718 * @param mobileNumber Mobile number to render
720 * @return Mobile number
722 public String renderMobileNumber (final DialableMobileNumber mobileNumber) {
723 // Default is empty string, so let's get started
724 final StringBuilder sb = new StringBuilder(20);
726 // Is a phone number given?
727 if (mobileNumber instanceof DialableMobileNumber) {
728 // Yes, then render it
729 sb.append(mobileNumber.getMobileProvider().getProviderCountry().getCountryAbroadDialPrefix());
730 sb.append(mobileNumber.getMobileProvider().getProviderCountry().getCountryPhoneCode());
731 sb.append(" ("); //NOI18N
732 sb.append(mobileNumber.getMobileProvider().getProviderDialPrefix());
733 sb.append(") "); //NOI18N
734 sb.append(mobileNumber.getMobileNumber());
738 return sb.toString();
742 * Renders given phone number (land-line and fax number). If null is
743 * provided, an empty string is returned.
745 * @param number Phone number to render
747 * @return Phone number
749 * @throws IllegalArgumentException If a mobile number is provided
751 public String renderPhoneNumber (final DialableNumber number) {
752 // Validate parameter
753 if (number instanceof DialableMobileNumber) {
755 throw new IllegalArgumentException("Mobile numbers cannot be rendered with this method. Please use renderMobileNumber() instead."); //NOI18N
758 // Default is empty string, so let's get started
759 final StringBuilder sb = new StringBuilder(20);
761 // Is a phone number given?
762 if (number instanceof DialableNumber) {
763 // Yes, then render it
764 sb.append(number.getPhoneCountry().getCountryAbroadDialPrefix());
765 sb.append(number.getPhoneCountry().getCountryPhoneCode());
766 sb.append(" ("); //NOI18N
767 sb.append(number.getPhoneAreaCode());
768 sb.append(") "); //NOI18N
769 sb.append(number.getPhoneNumber());
773 return sb.toString();
777 * Returns the user's personal title, family name and name. If null is
778 * provided, an empty string is returned.
780 * @param user User instance
782 * @return User's full name
784 public String renderUser (final User user) {
785 // Default is empty string, so let's get started
786 final StringBuilder sb = new StringBuilder(20);
789 if (user instanceof User) {
790 // Add user name first
791 sb.append(user.getUserName());
792 sb.append(" ("); //NOI18N
795 sb.append(this.renderContact(user.getUserContact()));
798 sb.append(")"); //NOI18N
802 return sb.toString();
806 * Set's all given contact's phone instances: land-line, mobile and
809 * @param contact Contact to set phone instances for
811 private void setPhoneInstances (final Contact contact) {
812 // The contact must be valid
813 if (null == contact) {
815 throw new NullPointerException("contact is null"); //NOI18N
816 } else if (contact.getContactId() == null) {
818 throw new NullPointerException("contact.contactId is null"); //NOI18N
819 } else if (contact.getContactId() < 1) {
821 throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N
825 if (contact.getContactMobileNumber() instanceof DialableMobileNumber) {
826 // Yes, then set it in admin controller
827 this.setMobileNumber(contact.getContactMobileNumber());
831 if (contact.getContactLandLineNumber() instanceof DialableLandLineNumber) {
832 // Yes, then set it in admin controller
833 this.setLandLineNumber(contact.getContactLandLineNumber());
837 if (contact.getContactFaxNumber() instanceof DialableFaxNumber) {
838 // Yes, then set it in admin controller
839 this.setFaxNumber(contact.getContactFaxNumber());