]> git.mxchange.org Git - jjobs-war.git/blob - src/java/org/mxchange/jjobs/beans/helper/JobsWebRequestHelperBean.java
Please cherry-pick:
[jjobs-war.git] / src / java / org / mxchange / jjobs / beans / helper / JobsWebRequestHelperBean.java
1 /*
2  * Copyright (C) 2016, 2017 Roland Häder
3  *
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.
8  *
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.
13  *
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/>.
16  */
17 package org.mxchange.jjobs.beans.helper;
18
19 import java.text.MessageFormat;
20 import javax.enterprise.context.RequestScoped;
21 import javax.enterprise.event.Event;
22 import javax.enterprise.inject.Any;
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.branchoffice.BranchOffice;
29 import org.mxchange.jcontactsbusiness.model.department.Department;
30 import org.mxchange.jcontactsbusiness.model.employee.Employee;
31 import org.mxchange.jcontactsbusiness.model.headquarters.HeadquartersData;
32 import org.mxchange.jjobs.beans.BaseJobsBean;
33 import org.mxchange.jjobs.beans.user.JobsUserWebRequestController;
34 import org.mxchange.jphone.events.fax.created.CreatedFaxNumberEvent;
35 import org.mxchange.jphone.events.fax.created.ObservableCreatedFaxNumberEvent;
36 import org.mxchange.jphone.events.landline.created.CreatedLandLineNumberEvent;
37 import org.mxchange.jphone.events.landline.created.ObservableCreatedLandLineNumberEvent;
38 import org.mxchange.jphone.events.mobile.created.CreatedMobileNumberEvent;
39 import org.mxchange.jphone.events.mobile.created.ObservableCreatedMobileNumberEvent;
40 import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
41 import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber;
42 import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber;
43 import org.mxchange.jusercore.events.user.created.CreatedUserEvent;
44 import org.mxchange.jusercore.events.user.created.ObservableCreatedUserEvent;
45 import org.mxchange.jusercore.model.user.User;
46
47 /**
48  * A general helper for beans
49  * <p>
50  * @author Roland Häder<roland@mxchange.org>
51  */
52 @Named ("beanHelper")
53 @RequestScoped
54 public class JobsWebRequestHelperBean extends BaseJobsBean implements JobsWebRequestHelperController {
55
56         /**
57          * Call-stack instance (5 may show BeanELResolver.getValue as caller)
58          */
59         private static final short THREAD_STACK = 5;
60
61         /**
62          * Serial number
63          */
64         private static final long serialVersionUID = 17_258_793_567_145_701L;
65
66         /**
67          * Contact instance
68          */
69         private Contact contact;
70
71         /**
72          * Event for when a contact instance was created
73          */
74         @Any
75         @Inject
76         private Event<ObservableCreatedContactEvent> contactCreatedEvent;
77
78         /**
79          * Fax number
80          */
81         private DialableFaxNumber faxNumber;
82
83         /**
84          * Event for when a fax number instance was created
85          */
86         @Any
87         @Inject
88         private Event<ObservableCreatedFaxNumberEvent> faxNumberCreatedEvent;
89
90         /**
91          * Land-line number
92          */
93         private DialableLandLineNumber landLineNumber;
94
95         /**
96          * Event for when a land-line number instance was created
97          */
98         @Any
99         @Inject
100         private Event<ObservableCreatedLandLineNumberEvent> landLineNumberCreatedEvent;
101
102         /**
103          * Mobile number
104          */
105         private DialableMobileNumber mobileNumber;
106
107         /**
108          * Event for when a mobile number instance was created
109          */
110         @Any
111         @Inject
112         private Event<ObservableCreatedMobileNumberEvent> mobileNumberCreatedEvent;
113
114         /**
115          * User instance
116          */
117         private User user;
118
119         /**
120          * Regular user controller
121          */
122         @Inject
123         private JobsUserWebRequestController userController;
124
125         /**
126          * Event for when a user instance was created
127          */
128         @Any
129         @Inject
130         private Event<ObservableCreatedUserEvent> userCreatedEvent;
131
132         /**
133          * Default constructor
134          */
135         public JobsWebRequestHelperBean () {
136                 // Call super constructor
137                 super();
138         }
139
140         /**
141          * Getter for contact instance
142          * <p>
143          * @return Contact instance
144          */
145         public Contact getContact () {
146                 return this.contact;
147         }
148
149         /**
150          * Setter for contact instance
151          * <p>
152          * @param contact Contact instance
153          */
154         public void setContact (final Contact contact) {
155                 // String caller = MessageFormat.format("{0}.{1}", Thread.currentThread().getStackTrace()[THREAD_STACK].getClassName(), Thread.currentThread().getStackTrace()[THREAD_STACK].getMethodName());
156                 // System.out.println(MessageFormat.format("{0}: Setting contact={1}, previous: {2}, caller: {3}", this.getClass().getSimpleName(), contact, this.contact, caller));
157                 this.contact = contact;
158         }
159
160         /**
161          * Returns a message key depending on if this contact is a user and/or a
162          * contact. If this contact is unused, a default key is returned.
163          * <p>
164          * @param contact Contact instance to check
165          * <p>
166          * @return Message key
167          */
168         public String getContactUsageMessageKey (final Contact contact) {
169                 // The contact must be valid
170                 if (null == contact) {
171                         // Throw NPE
172                         throw new NullPointerException("contact is null"); //NOI18N
173                 } else if (contact.getContactId() == null) {
174                         // Throw again ...
175                         throw new NullPointerException("contact.contactId is null"); //NOI18N
176                 } else if (contact.getContactId() < 1) {
177                         // Not valid
178                         throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N
179                 }
180
181                 // Default key is "unused"
182                 String messageKey = "CONTACT_IS_UNUSED"; //NOI18N
183
184                 // Check user first
185                 if (this.userController.isContactFound(contact)) {
186                         // Only user
187                         messageKey = "CONTACT_IS_USER"; //NOI18N
188                 }
189
190                 // Return message key
191                 return messageKey;
192         }
193
194         /**
195          * Getter for dialable fax number
196          * <p>
197          * @return Dialable fax number
198          */
199         public DialableFaxNumber getFaxNumber () {
200                 return this.faxNumber;
201         }
202
203         /**
204          * Setter for dialable fax number
205          * <p>
206          * @param faxNumber Dialable fax number
207          */
208         public void setFaxNumber (final DialableFaxNumber faxNumber) {
209                 this.faxNumber = faxNumber;
210         }
211
212         /**
213          * Getter for dialable land-line number
214          * <p>
215          * @return Dialable land-line number
216          */
217         public DialableLandLineNumber getLandLineNumber () {
218                 return this.landLineNumber;
219         }
220
221         /**
222          * Setter for dialable land-line number
223          * <p>
224          * @param landLineNumber Dialable land-line number
225          */
226         public void setLandLineNumber (final DialableLandLineNumber landLineNumber) {
227                 this.landLineNumber = landLineNumber;
228         }
229
230         /**
231          * Getter for dialable mobile number
232          * <p>
233          * @return Dialable mobile number
234          */
235         public DialableMobileNumber getMobileNumber () {
236                 return this.mobileNumber;
237         }
238
239         /**
240          * Setter for dialable mobile number
241          * <p>
242          * @param mobileNumber Dialable mobile number
243          */
244         public void setMobileNumber (final DialableMobileNumber mobileNumber) {
245                 this.mobileNumber = mobileNumber;
246         }
247
248         /**
249          * Getter for user instance
250          * <p>
251          * @return User instance
252          */
253         public User getUser () {
254                 return this.user;
255         }
256
257         /**
258          * Setter for user instance
259          * <p>
260          * @param user User instance
261          */
262         public void setUser (final User user) {
263                 this.user = user;
264         }
265
266         /**
267          * Notifies other controllers (backing beans) if a contact id has been
268          * successfully converted to a Contact instance.
269          */
270         public void notifyControllerContactConverted () {
271                 // Validate contact instance
272                 if (this.getContact() == null) {
273                         // Throw NPE
274                         throw new NullPointerException("this.contact is null"); //NOI18N
275                 } else if (this.getContact().getContactId() == null) {
276                         // Throw NPE again
277                         throw new NullPointerException("this.contact.contactId is null"); //NOI18N
278                 } else if (this.getContact().getContactId() < 1) {
279                         // Not valid
280                         throw new IllegalStateException(MessageFormat.format("this.contact.contactId={0} is not valid.", this.getContact().getContactId())); //NOI18N
281                 }
282
283                 // Set all phone instances
284                 this.setPhoneInstances(this.getContact());
285
286                 // Set all fields: user
287                 this.contactCreatedEvent.fire(new CreatedContactEvent(this.getContact()));
288         }
289
290         /**
291          * Notifies other controllers (backing beans) if a phone id has been
292          * successfully converted to a DialableFaxNumber instance.
293          */
294         public void notifyControllerFaxNumberConverted () {
295                 // Validate fax instance
296                 if (this.getFaxNumber() == null) {
297                         // Throw NPE
298                         throw new NullPointerException("this.faxNumber is null"); //NOI18N
299                 } else if (this.getFaxNumber().getPhoneId() == null) {
300                         // Throw again
301                         throw new NullPointerException("this.faxNumber.phoneId is null"); //NOI18N
302                 } else if (this.getFaxNumber().getPhoneId() < 1) {
303                         // Invalid id number
304                         throw new IllegalArgumentException(MessageFormat.format("this.faxNumber.phoneId={0} is not valid", this.getFaxNumber().getPhoneId())); //NOI18N
305                 } else if (this.getFaxNumber().getPhoneAreaCode() == null) {
306                         // Throw again
307                         throw new NullPointerException("this.faxNumber.phoneAreaCode is null"); //NOI18N
308                 } else if (this.getFaxNumber().getPhoneAreaCode() < 1) {
309                         // Invalid id number
310                         throw new IllegalArgumentException(MessageFormat.format("this.faxNumber.phoneAreaCode={0} is not valid", this.getFaxNumber().getPhoneAreaCode())); //NOI18N
311                 } else if (this.getFaxNumber().getPhoneCountry() == null) {
312                         // Throw NPE again
313                         throw new NullPointerException("this.faxNumber.phoneCountry is null"); //NOI18N
314                 } else if (this.getFaxNumber().getPhoneCountry().getCountryId() == null) {
315                         // ... throw again
316                         throw new NullPointerException("this.faxNumber.phoneCountry.countryId is null"); //NOI18N
317                 } else if (this.getFaxNumber().getPhoneCountry().getCountryId() < 1) {
318                         // Invalid id
319                         throw new IllegalArgumentException(MessageFormat.format("this.faxNumber.phoneCountry.countryId={0} is invalid", this.getFaxNumber().getPhoneCountry().getCountryId())); //NOI18N
320                 } else if (this.getFaxNumber().getPhoneNumber() == null) {
321                         // Throw NPE again ...
322                         throw new NullPointerException("this.faxNumber.phoneNumber is null"); //NOI18N
323                 } else if (this.getFaxNumber().getPhoneNumber() < 1) {
324                         // Invalid id number
325                         throw new IllegalArgumentException(MessageFormat.format("this.faxNumber.phoneNumber={0} is not valid", this.getFaxNumber().getPhoneNumber())); //NOI18N
326                 }
327
328                 // Fire event
329                 this.faxNumberCreatedEvent.fire(new CreatedFaxNumberEvent(this.getFaxNumber()));
330         }
331
332         /**
333          * Notifies other controllers (backing beans) if a phone id has been
334          * successfully converted to a DialableLandLineNumber instance.
335          */
336         public void notifyControllerLandLineNumberConverted () {
337                 // Validate land-line instance
338                 if (this.getLandLineNumber() == null) {
339                         // Throw NPE
340                         throw new NullPointerException("this.landLineNumber is null"); //NOI18N
341                 } else if (this.getLandLineNumber().getPhoneId() == null) {
342                         // Throw again
343                         throw new NullPointerException("this.landLineNumber.phoneId is null"); //NOI18N
344                 } else if (this.getLandLineNumber().getPhoneId() < 1) {
345                         // Invalid id number
346                         throw new IllegalArgumentException(MessageFormat.format("this.landLineNumber.phoneId={0} is not valid", this.getLandLineNumber().getPhoneId())); //NOI18N
347                 } else if (this.getLandLineNumber().getPhoneAreaCode() == null) {
348                         // Throw again
349                         throw new NullPointerException("this.landLineNumber.phoneAreaCode is null"); //NOI18N
350                 } else if (this.getLandLineNumber().getPhoneAreaCode() < 1) {
351                         // Invalid id number
352                         throw new IllegalArgumentException(MessageFormat.format("this.landLineNumber.phoneAreaCode={0} is not valid", this.getFaxNumber().getPhoneAreaCode())); //NOI18N
353                 } else if (this.getLandLineNumber().getPhoneCountry() == null) {
354                         // Throw NPE again
355                         throw new NullPointerException("this.landLineNumber.phoneCountry is null"); //NOI18N
356                 } else if (this.getLandLineNumber().getPhoneCountry().getCountryId() == null) {
357                         // ... throw again
358                         throw new NullPointerException("this.landLineNumber.phoneCountry.countryId is null"); //NOI18N
359                 } else if (this.getLandLineNumber().getPhoneCountry().getCountryId() < 1) {
360                         // Invalid id
361                         throw new IllegalArgumentException(MessageFormat.format("this.landLineNumber.phoneCountry.countryId={0} is invalid", this.getLandLineNumber().getPhoneCountry().getCountryId())); //NOI18N
362                 } else if (this.getLandLineNumber().getPhoneNumber() == null) {
363                         // Throw NPE again ...
364                         throw new NullPointerException("this.landLineNumber.phoneNumber is null"); //NOI18N
365                 } else if (this.getLandLineNumber().getPhoneNumber() < 1) {
366                         // Invalid id number
367                         throw new IllegalArgumentException(MessageFormat.format("this.landLineNumber.phoneNumber={0} is not valid", this.getLandLineNumber().getPhoneNumber())); //NOI18N
368                 }
369
370                 // Fire event
371                 this.landLineNumberCreatedEvent.fire(new CreatedLandLineNumberEvent(this.getLandLineNumber()));
372         }
373
374         /**
375          * Notifies other controllers (backing beans) if a phone id has been
376          * successfully converted to a DialableMobileNumber instance.
377          */
378         public void notifyControllerMobileNumberConverted () {
379                 // Validate mobile instance
380                 if (this.getMobileNumber() == null) {
381                         // Throw NPE
382                         throw new NullPointerException("this.mobileNumber is null"); //NOI18N
383                 } else if (this.getMobileNumber().getPhoneId() == null) {
384                         // Throw again
385                         throw new NullPointerException("this.mobileNumber.phoneId is null"); //NOI18N
386                 } else if (this.getMobileNumber().getPhoneId() < 1) {
387                         // Invalid id number
388                         throw new IllegalArgumentException(MessageFormat.format("this.mobileNumber.phoneId={0} is not valid", this.getMobileNumber().getPhoneId())); //NOI18N
389                 } else if (this.getMobileNumber().getMobileProvider() == null) {
390                         // Throw NPE again
391                         throw new NullPointerException("this.mobileNumber.mobileProvider is null"); //NOI18N
392                 } else if (this.getMobileNumber().getMobileProvider().getProviderId() == null) {
393                         // ... throw again
394                         throw new NullPointerException("this.mobileNumber.mobileProvider.providerId is null"); //NOI18N
395                 } else if (this.getMobileNumber().getMobileProvider().getProviderId() < 1) {
396                         // Invalid id
397                         throw new IllegalArgumentException(MessageFormat.format("this.mobileNumber.mobileProvider.providerId={0} is invalid", this.getMobileNumber().getMobileProvider().getProviderId())); //NOI18N
398                 } else if (this.getMobileNumber().getPhoneNumber() == null) {
399                         // Throw NPE again ...
400                         throw new NullPointerException("this.mobileNumber.phoneNumber is null"); //NOI18N
401                 } else if (this.getMobileNumber().getPhoneNumber() < 1) {
402                         // Invalid id number
403                         throw new IllegalArgumentException(MessageFormat.format("this.mobileNumber.phoneNumber={0} is not valid", this.getMobileNumber().getPhoneNumber())); //NOI18N
404                 }
405
406                 // Fire event
407                 this.mobileNumberCreatedEvent.fire(new CreatedMobileNumberEvent(this.getMobileNumber()));
408         }
409
410         /**
411          * Notifies other controllers (backing beans) if a user id has been
412          * successfully converted to a User instance.
413          */
414         public void notifyControllerUserConverted () {
415                 // Validate user instance
416                 if (this.getUser() == null) {
417                         // Throw NPE
418                         throw new NullPointerException("this.user is null"); //NOI18N
419                 } else if (this.getUser().getUserId() == null) {
420                         // Throw NPE again
421                         throw new NullPointerException("this.user.userId is null"); //NOI18N
422                 } else if (this.getUser().getUserId() < 1) {
423                         // Not valid
424                         throw new IllegalStateException(MessageFormat.format("this.user.userId={0} is not valid.", this.getUser().getUserId())); //NOI18N
425                 }
426
427                 // Get contact
428                 final Contact userContact = this.getUser().getUserContact();
429
430                 // Set contact here, too. This avoids parameters that cannot auto-complete in IDEs.
431                 this.setContact(userContact);
432
433                 // Set all phone instances
434                 this.setPhoneInstances(userContact);
435
436                 // Fire event
437                 this.userCreatedEvent.fire(new CreatedUserEvent(this.getUser()));
438         }
439
440         /**
441          * Returns the branch office's full address. If null is provided, an empty
442          * string is returned.
443          * <p>
444          * @param branchOffice Branch office instance
445          * <p>
446          * @return Branch office's address
447          */
448         public String renderBranchOffice (final BranchOffice branchOffice) {
449                 // Default is empty string, so let's get started
450                 final StringBuilder sb = new StringBuilder(30);
451
452                 // Is a branch office instance given?
453                 if (branchOffice instanceof BranchOffice) {
454                         // Yes, then append all data
455                         sb.append(branchOffice.getBranchCompany().getCompanyName());
456                         sb.append(", "); //NOI18N
457                         sb.append(branchOffice.getBranchStreet());
458                         sb.append(" "); //NOI18N
459                         sb.append(branchOffice.getBranchHouseNumber());
460                         sb.append(", "); //NOI18N
461                         sb.append(branchOffice.getBranchCountry().getCountryCode());
462                         sb.append(" "); //NOI18N
463                         sb.append(branchOffice.getBranchZipCode());
464                         sb.append(" "); //NOI18N
465                         sb.append(branchOffice.getBranchCity());
466                 }
467
468                 // Return it
469                 return sb.toString();
470         }
471
472         /**
473          * Returns the contact's personal title, family name and name. If null is
474          * provided, an empty string is returned.
475          * <p>
476          * @param contact Contact instance
477          * <p>
478          * @return Contact's full name
479          */
480         public String renderContact (final Contact contact) {
481                 // Default is empty string, so let's get started
482                 final StringBuilder sb = new StringBuilder(20);
483
484                 // Is contact set?
485                 if (contact instanceof Contact) {
486                         // Then create name
487                         sb.append(this.getMessageFromBundle(contact.getContactPersonalTitle().getMessageKey()));
488                         sb.append(" "); //NOI18N
489                         sb.append(contact.getContactFirstName());
490                         sb.append(" "); //NOI18N
491                         sb.append(contact.getContactFamilyName());
492                 }
493
494                 // Return it
495                 return sb.toString();
496         }
497
498         /**
499          * Returns the department's name and name of assigned company. If null is
500          * provided, an empty string is returned.
501          * <p>
502          * @param department Department instance
503          * <p>
504          * @return Department's full name
505          */
506         public String renderDepartment (final Department department) {
507                 // Default is empty string, so let's get started
508                 final StringBuilder sb = new StringBuilder(10);
509
510                 // Is a department set?
511                 if (department instanceof Department) {
512                         // Then create name
513                         sb.append(department.getDepartmentName());
514                         sb.append(" ("); //NOI18N
515                         sb.append(department.getDepartmentCompany().getCompanyName());
516                         sb.append(")"); //NOI18N
517                 }
518
519                 // Return it
520                 return sb.toString();
521         }
522
523         /**
524          * Returns the employee's number, personal title, family name and name if
525          * available. If null is provided, an empty string is returned.
526          * <p>
527          * @param employee Employee instance
528          * <p>
529          * @return Contact's full name
530          */
531         public String renderEmployee (final Employee employee) {
532                 // Default is empty string, so let's get started
533                 final StringBuilder sb = new StringBuilder(20);
534
535                 // Is employee set?
536                 if (employee instanceof Employee) {
537                         // Then create name
538                         sb.append(employee.getEmployeeNumber());
539
540                         // Is a department found?
541                         if (employee.getEmployeeDepartment() instanceof Department) {
542                                 // Then add it's name to it
543                                 sb.append(" ("); //NOI18N
544                                 sb.append(this.renderDepartment(employee.getEmployeeDepartment()));
545                                 sb.append(")"); //NOI18N
546                         }
547
548                         // Is contact data found?
549                         if (employee.getEmployeePersonalData() instanceof Contact) {
550                                 // Yes, then render it
551                                 final String contactName = this.renderContact(employee.getEmployeePersonalData());
552
553                                 // Is it given?
554                                 if (contactName != null) {
555                                         // Then add it
556                                         sb.append(" ("); //NOI18N
557                                         sb.append(contactName);
558                                         sb.append(")"); //NOI18N
559                                 }
560                         }
561                 }
562
563                 // Return it
564                 return sb.toString();
565         }
566
567         /**
568          * Returns the headquarters' address. If null is provided, an empty string
569          * is returned.
570          * <p>
571          * @param headquarters Headquarters instance
572          * <p>
573          * @return Headquarters' address
574          */
575         public String renderHeadquarters (final HeadquartersData headquarters) {
576                 // Default is empty string, so let's get started
577                 final StringBuilder sb = new StringBuilder(10);
578
579                 // Is a headquarters set?
580                 if (headquarters instanceof HeadquartersData) {
581                         // Then create name
582                         sb.append(headquarters.getHeadquartersStreet());
583                         sb.append(" "); //NOI18N
584                         sb.append(headquarters.getHeadquartersHouseNumber());
585
586                         // Is store/suite number set?
587                         if (headquarters.getHeadquartersStore() instanceof Short) {
588                                 sb.append(" ("); //NOI18N
589                                 sb.append(this.getMessageFromBundle("DATA_STORE")); //NOI18N
590                                 sb.append(" "); //NOI18N
591                                 sb.append(headquarters.getHeadquartersStore());
592                                 sb.append(", "); //NOI18N
593                                 sb.append(this.getMessageFromBundle("DATA_SUITE_NUMBER")); //NOI18N
594                                 sb.append(" "); //NOI18N
595                                 sb.append(headquarters.getHeadquartersSuiteNumber());
596                                 sb.append(")"); //NOI18N
597                         }
598
599                         // Continue with country, ZIP code and city
600                         sb.append(", "); //NOI18N
601                         sb.append(headquarters.getHeadquartersCountry().getCountryCode());
602                         sb.append(" "); //NOI18N
603                         sb.append(headquarters.getHeadquartersZipCode());
604                         sb.append(" "); //NOI18N
605                         sb.append(headquarters.getHeadquartersCity());
606                 }
607
608                 // Return it
609                 return sb.toString();
610         }
611
612         /**
613          * Set's all given contact's phone instances: land-line, mobile and
614          * faxNumber
615          * <p>
616          * @param contact Contact to set phone instances for
617          */
618         private void setPhoneInstances (final Contact contact) {
619                 // The contact must be valid
620                 if (null == contact) {
621                         // Throw NPE
622                         throw new NullPointerException("contact is null"); //NOI18N
623                 } else if (contact.getContactId() == null) {
624                         // Throw again ...
625                         throw new NullPointerException("contact.contactId is null"); //NOI18N
626                 } else if (contact.getContactId() < 1) {
627                         // Not valid
628                         throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N
629                 }
630
631                 // Is mobile set?
632                 if (contact.getContactMobileNumber() instanceof DialableMobileNumber) {
633                         // Yes, then set it in admin controller
634                         this.setMobileNumber(contact.getContactMobileNumber());
635                 }
636
637                 // Is land-line set?
638                 if (contact.getContactLandLineNumber() instanceof DialableLandLineNumber) {
639                         // Yes, then set it in admin controller
640                         this.setLandLineNumber(contact.getContactLandLineNumber());
641                 }
642
643                 // Is faxNumber set?
644                 if (contact.getContactFaxNumber() instanceof DialableFaxNumber) {
645                         // Yes, then set it in admin controller
646                         this.setFaxNumber(contact.getContactFaxNumber());
647                 }
648         }
649
650 }