]> git.mxchange.org Git - jjobs-war.git/blobdiff - src/java/org/mxchange/jjobs/beans/helper/JobsWebViewHelperBean.java
Please cherry-pick:
[jjobs-war.git] / src / java / org / mxchange / jjobs / beans / helper / JobsWebViewHelperBean.java
index 98d3dbed47e30ecc8c3f21aa4a1d9d295dd40c5c..6c50632482e8ac9ca4e061fc475fb3a832de4bfb 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 Roland Häder
+ * Copyright (C) 2016 - 2018 Free Software Foundation
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Affero General Public License as
 package org.mxchange.jjobs.beans.helper;
 
 import java.text.MessageFormat;
+import javax.enterprise.event.Event;
+import javax.enterprise.inject.Any;
 import javax.faces.view.ViewScoped;
 import javax.inject.Inject;
 import javax.inject.Named;
-import org.mxchange.jcontacts.contact.Contact;
-import org.mxchange.jjobs.beans.BaseJobsController;
-import org.mxchange.jjobs.beans.contact.JobsAdminContactWebRequestController;
-import org.mxchange.jjobs.beans.phone.JobsAdminPhoneWebRequestController;
-import org.mxchange.jjobs.beans.user.JobsAdminUserWebRequestController;
-import org.mxchange.jjobs.beans.user.JobsUserWebSessionController;
-import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
-import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
-import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
+import org.mxchange.jcontacts.events.contact.created.CreatedContactEvent;
+import org.mxchange.jcontacts.events.contact.created.ObservableCreatedContactEvent;
+import org.mxchange.jcontacts.model.contact.Contact;
+import org.mxchange.jcontactsbusiness.model.basicdata.BasicData;
+import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice;
+import org.mxchange.jcontactsbusiness.model.department.Department;
+import org.mxchange.jcontactsbusiness.model.employee.Employable;
+import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter;
+import org.mxchange.jcountry.model.data.Country;
+import org.mxchange.jjobs.beans.BaseJobsBean;
+import org.mxchange.jjobs.beans.localization.JobsLocalizationSessionController;
+import org.mxchange.jjobs.beans.user.JobsUserWebRequestController;
+import org.mxchange.jphone.events.fax.created.CreatedFaxNumberEvent;
+import org.mxchange.jphone.events.fax.created.ObservableCreatedFaxNumberEvent;
+import org.mxchange.jphone.events.landline.created.CreatedLandLineNumberEvent;
+import org.mxchange.jphone.events.landline.created.ObservableCreatedLandLineNumberEvent;
+import org.mxchange.jphone.events.mobile.created.CreatedMobileNumberEvent;
+import org.mxchange.jphone.events.mobile.created.ObservableCreatedMobileNumberEvent;
+import org.mxchange.jphone.model.phonenumbers.DialableNumber;
+import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
+import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber;
+import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber;
+import org.mxchange.jusercore.events.user.created.CreatedUserEvent;
+import org.mxchange.jusercore.events.user.created.ObservableCreatedUserEvent;
 import org.mxchange.jusercore.model.user.User;
 
 /**
@@ -36,58 +53,69 @@ import org.mxchange.jusercore.model.user.User;
  * <p>
  * @author Roland Häder<roland@mxchange.org>
  */
-@Named ("adminHelper")
+@Named ("beanHelper")
 @ViewScoped
-public class JobsWebViewHelperBean extends BaseJobsController implements JobsWebViewHelperController {
+public class JobsWebViewHelperBean extends BaseJobsBean implements JobsWebViewHelperController {
 
        /**
-        * Call-stack instance (5 may show BeanELResolver.getValue as caller)
+        * Serial number
         */
-       private static final short THREAD_STACK = 5;
+       private static final long serialVersionUID = 17_258_793_567_145_701L;
 
        /**
-        * Serial number
+        * Contact instance
         */
-       private static final long serialVersionUID = 17_258_793_567_145_701L;
+       private Contact contact;
 
        /**
-        * Administrative contact controller
+        * Event for when a contact instance was created
         */
+       @Any
        @Inject
-       private JobsAdminContactWebRequestController adminContactController;
+       private Event<ObservableCreatedContactEvent> contactCreatedEvent;
 
        /**
-        * Administrative phone controller
+        * Fax number
         */
-       @Inject
-       private JobsAdminPhoneWebRequestController adminPhoneController;
+       private DialableFaxNumber faxNumber;
 
        /**
-        * Administrative user controller
+        * Event for when a fax number instance was created
         */
+       @Any
        @Inject
-       private JobsAdminUserWebRequestController adminUserController;
+       private Event<ObservableCreatedFaxNumberEvent> faxNumberCreatedEvent;
 
        /**
-        * Contact instance
+        * Land-line number
         */
-       private Contact contact;
+       private DialableLandLineNumber landLineNumber;
 
        /**
-        * Fax number
+        * Event for when a land-line number instance was created
         */
-       private DialableFaxNumber faxNumber;
+       @Any
+       @Inject
+       private Event<ObservableCreatedLandLineNumberEvent> landLineNumberCreatedEvent;
 
        /**
-        * Land-line number
+        * Localization controller
         */
-       private DialableLandLineNumber landLineNumber;
+       @Inject
+       private JobsLocalizationSessionController localizationController;
 
        /**
         * Mobile number
         */
        private DialableMobileNumber mobileNumber;
 
+       /**
+        * Event for when a mobile number instance was created
+        */
+       @Any
+       @Inject
+       private Event<ObservableCreatedMobileNumberEvent> mobileNumberCreatedEvent;
+
        /**
         * User instance
         */
@@ -97,21 +125,152 @@ public class JobsWebViewHelperBean extends BaseJobsController implements JobsWeb
         * Regular user controller
         */
        @Inject
-       private JobsUserWebSessionController userController;
+       private JobsUserWebRequestController userController;
+
+       /**
+        * Event for when a user instance was created
+        */
+       @Any
+       @Inject
+       private Event<ObservableCreatedUserEvent> userCreatedEvent;
 
        /**
         * Default constructor
         */
        public JobsWebViewHelperBean () {
-               // String caller = MessageFormat.format("{0}.{1}", Thread.currentThread().getStackTrace()[3].getClassName(), Thread.currentThread().getStackTrace()[3].getMethodName());
-               // System.out.println(MessageFormat.format("{0}: Constructed, caller: {1}", this.getClass().getSimpleName(), caller));
+               // Call super constructor
+               super();
+       }
+
+       /**
+        * Getter for contact instance
+        * <p>
+        * @return Contact instance
+        */
+       public Contact getContact () {
+               return this.contact;
+       }
+
+       /**
+        * Setter for contact instance
+        * <p>
+        * @param contact Contact instance
+        */
+       public void setContact (final Contact contact) {
+               this.contact = contact;
+       }
+
+       /**
+        * Returns a message key depending on if this contact is a user and/or a
+        * contact. If this contact is unused, a default key is returned.
+        * <p>
+        * @param contact Contact instance to check
+        * <p>
+        * @return Message key
+        */
+       public String getContactUsageMessageKey (final Contact contact) {
+               // The contact must be valid
+               if (null == contact) {
+                       // Throw NPE
+                       throw new NullPointerException("contact is null"); //NOI18N
+               } else if (contact.getContactId() == null) {
+                       // Throw again ...
+                       throw new NullPointerException("contact.contactId is null"); //NOI18N
+               } else if (contact.getContactId() < 1) {
+                       // Not valid
+                       throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N
+               }
+
+               // Default key is "unused"
+               String messageKey = "CONTACT_IS_UNUSED"; //NOI18N
+
+               // Check user first
+               if (this.userController.isContactFound(contact)) {
+                       // Only user
+                       messageKey = "CONTACT_IS_USER"; //NOI18N
+               }
+
+               // Return message key
+               return messageKey;
+       }
+
+       /**
+        * Getter for dialable fax number
+        * <p>
+        * @return Dialable fax number
+        */
+       public DialableFaxNumber getFaxNumber () {
+               return this.faxNumber;
+       }
+
+       /**
+        * Setter for dialable fax number
+        * <p>
+        * @param faxNumber Dialable fax number
+        */
+       public void setFaxNumber (final DialableFaxNumber faxNumber) {
+               this.faxNumber = faxNumber;
+       }
+
+       /**
+        * Getter for dialable land-line number
+        * <p>
+        * @return Dialable land-line number
+        */
+       public DialableLandLineNumber getLandLineNumber () {
+               return this.landLineNumber;
+       }
+
+       /**
+        * Setter for dialable land-line number
+        * <p>
+        * @param landLineNumber Dialable land-line number
+        */
+       public void setLandLineNumber (final DialableLandLineNumber landLineNumber) {
+               this.landLineNumber = landLineNumber;
+       }
+
+       /**
+        * Getter for dialable mobile number
+        * <p>
+        * @return Dialable mobile number
+        */
+       public DialableMobileNumber getMobileNumber () {
+               return this.mobileNumber;
        }
 
-       @Override
-       public void copyContactToController () {
-               // String caller = MessageFormat.format("{0}.{1}", Thread.currentThread().getStackTrace()[THREAD_STACK].getClassName(), Thread.currentThread().getStackTrace()[THREAD_STACK].getMethodName());
-               // System.out.println(MessageFormat.format("{0}.copyContactToController: CALLED, caller: {2}", this.getClass().getSimpleName(), this.contact, caller));
+       /**
+        * Setter for dialable mobile number
+        * <p>
+        * @param mobileNumber Dialable mobile number
+        */
+       public void setMobileNumber (final DialableMobileNumber mobileNumber) {
+               this.mobileNumber = mobileNumber;
+       }
 
+       /**
+        * Getter for user instance
+        * <p>
+        * @return User instance
+        */
+       public User getUser () {
+               return this.user;
+       }
+
+       /**
+        * Setter for user instance
+        * <p>
+        * @param user User instance
+        */
+       public void setUser (final User user) {
+               this.user = user;
+       }
+
+       /**
+        * Notifies other controllers (backing beans) if a contact id has been
+        * successfully converted to a Contact instance.
+        */
+       public void notifyControllerContactConverted () {
                // Validate contact instance
                if (this.getContact() == null) {
                        // Throw NPE
@@ -128,144 +287,148 @@ public class JobsWebViewHelperBean extends BaseJobsController implements JobsWeb
                this.setPhoneInstances(this.getContact());
 
                // Set all fields: user
-               this.adminContactController.copyContactToController(this.getContact());
+               this.contactCreatedEvent.fire(new CreatedContactEvent(this.getContact()));
        }
 
-       @Override
-       public void copyFaxNumberToController () {
+       /**
+        * Notifies other controllers (backing beans) if a phone id has been
+        * successfully converted to a DialableFaxNumber instance.
+        */
+       public void notifyControllerFaxNumberConverted () {
                // Validate fax instance
                if (this.getFaxNumber() == null) {
                        // Throw NPE
-                       throw new NullPointerException("this.faxNumber is null");
+                       throw new NullPointerException("this.faxNumber is null"); //NOI18N
                } else if (this.getFaxNumber().getPhoneId() == null) {
                        // Throw again
-                       throw new NullPointerException("this.faxNumber.phoneId is null");
+                       throw new NullPointerException("this.faxNumber.phoneId is null"); //NOI18N
                } else if (this.getFaxNumber().getPhoneId() < 1) {
                        // Invalid id number
-                       throw new IllegalArgumentException(MessageFormat.format("this.faxNumber.phoneId={0} is not valid", this.getFaxNumber().getPhoneId()));
+                       throw new IllegalArgumentException(MessageFormat.format("this.faxNumber.phoneId={0} is not valid", this.getFaxNumber().getPhoneId())); //NOI18N
                } else if (this.getFaxNumber().getPhoneAreaCode() == null) {
                        // Throw again
-                       throw new NullPointerException("this.faxNumber.phoneAreaCode is null");
+                       throw new NullPointerException("this.faxNumber.phoneAreaCode is null"); //NOI18N
                } else if (this.getFaxNumber().getPhoneAreaCode() < 1) {
                        // Invalid id number
-                       throw new IllegalArgumentException(MessageFormat.format("this.faxNumber.phoneAreaCode={0} is not valid", this.getFaxNumber().getPhoneAreaCode()));
+                       throw new IllegalArgumentException(MessageFormat.format("this.faxNumber.phoneAreaCode={0} is not valid", this.getFaxNumber().getPhoneAreaCode())); //NOI18N
                } else if (this.getFaxNumber().getPhoneCountry() == null) {
                        // Throw NPE again
-                       throw new NullPointerException("this.faxNumber.phoneCountry is null");
+                       throw new NullPointerException("this.faxNumber.phoneCountry is null"); //NOI18N
                } else if (this.getFaxNumber().getPhoneCountry().getCountryId() == null) {
                        // ... throw again
-                       throw new NullPointerException("this.faxNumber.phoneCountry.countryId is null");
+                       throw new NullPointerException("this.faxNumber.phoneCountry.countryId is null"); //NOI18N
                } else if (this.getFaxNumber().getPhoneCountry().getCountryId() < 1) {
                        // Invalid id
-                       throw new IllegalArgumentException(MessageFormat.format("this.faxNumber.phoneCountry.countryId={0} is invalid", this.getFaxNumber().getPhoneCountry().getCountryId()));
+                       throw new IllegalArgumentException(MessageFormat.format("this.faxNumber.phoneCountry.countryId={0} is invalid", this.getFaxNumber().getPhoneCountry().getCountryId())); //NOI18N
                } else if (this.getFaxNumber().getPhoneNumber() == null) {
                        // Throw NPE again ...
-                       throw new NullPointerException("this.faxNumber.phoneNumber is null");
+                       throw new NullPointerException("this.faxNumber.phoneNumber is null"); //NOI18N
                } else if (this.getFaxNumber().getPhoneNumber() < 1) {
                        // Invalid id number
-                       throw new IllegalArgumentException(MessageFormat.format("this.faxNumber.phoneNumber={0} is not valid", this.getFaxNumber().getPhoneNumber()));
+                       throw new IllegalArgumentException(MessageFormat.format("this.faxNumber.phoneNumber={0} is not valid", this.getFaxNumber().getPhoneNumber())); //NOI18N
                }
 
-               // Copy all (changeable) data fields to admin controller
-               this.adminPhoneController.setPhoneAreaCode(this.getFaxNumber().getPhoneAreaCode());
-               this.adminPhoneController.setPhoneCountry(this.getFaxNumber().getPhoneCountry());
-               this.adminPhoneController.setPhoneNumber(this.getFaxNumber().getPhoneNumber());
+               // Fire event
+               this.faxNumberCreatedEvent.fire(new CreatedFaxNumberEvent(this.getFaxNumber()));
        }
 
-       @Override
-       public void copyLandLineNumberToController () {
+       /**
+        * Notifies other controllers (backing beans) if a phone id has been
+        * successfully converted to a DialableLandLineNumber instance.
+        */
+       public void notifyControllerLandLineNumberConverted () {
                // Validate land-line instance
                if (this.getLandLineNumber() == null) {
                        // Throw NPE
-                       throw new NullPointerException("this.landLineNumber is null");
+                       throw new NullPointerException("this.landLineNumber is null"); //NOI18N
                } else if (this.getLandLineNumber().getPhoneId() == null) {
                        // Throw again
-                       throw new NullPointerException("this.landLineNumber.phoneId is null");
+                       throw new NullPointerException("this.landLineNumber.phoneId is null"); //NOI18N
                } else if (this.getLandLineNumber().getPhoneId() < 1) {
                        // Invalid id number
-                       throw new IllegalArgumentException(MessageFormat.format("this.landLineNumber.phoneId={0} is not valid", this.getLandLineNumber().getPhoneId()));
+                       throw new IllegalArgumentException(MessageFormat.format("this.landLineNumber.phoneId={0} is not valid", this.getLandLineNumber().getPhoneId())); //NOI18N
                } else if (this.getLandLineNumber().getPhoneAreaCode() == null) {
                        // Throw again
-                       throw new NullPointerException("this.landLineNumber.phoneAreaCode is null");
+                       throw new NullPointerException("this.landLineNumber.phoneAreaCode is null"); //NOI18N
                } else if (this.getLandLineNumber().getPhoneAreaCode() < 1) {
                        // Invalid id number
-                       throw new IllegalArgumentException(MessageFormat.format("this.landLineNumber.phoneAreaCode={0} is not valid", this.getFaxNumber().getPhoneAreaCode()));
+                       throw new IllegalArgumentException(MessageFormat.format("this.landLineNumber.phoneAreaCode={0} is not valid", this.getFaxNumber().getPhoneAreaCode())); //NOI18N
                } else if (this.getLandLineNumber().getPhoneCountry() == null) {
                        // Throw NPE again
-                       throw new NullPointerException("this.landLineNumber.phoneCountry is null");
+                       throw new NullPointerException("this.landLineNumber.phoneCountry is null"); //NOI18N
                } else if (this.getLandLineNumber().getPhoneCountry().getCountryId() == null) {
                        // ... throw again
-                       throw new NullPointerException("this.landLineNumber.phoneCountry.countryId is null");
+                       throw new NullPointerException("this.landLineNumber.phoneCountry.countryId is null"); //NOI18N
                } else if (this.getLandLineNumber().getPhoneCountry().getCountryId() < 1) {
                        // Invalid id
-                       throw new IllegalArgumentException(MessageFormat.format("this.landLineNumber.phoneCountry.countryId={0} is invalid", this.getLandLineNumber().getPhoneCountry().getCountryId()));
+                       throw new IllegalArgumentException(MessageFormat.format("this.landLineNumber.phoneCountry.countryId={0} is invalid", this.getLandLineNumber().getPhoneCountry().getCountryId())); //NOI18N
                } else if (this.getLandLineNumber().getPhoneNumber() == null) {
                        // Throw NPE again ...
-                       throw new NullPointerException("this.landLineNumber.phoneNumber is null");
+                       throw new NullPointerException("this.landLineNumber.phoneNumber is null"); //NOI18N
                } else if (this.getLandLineNumber().getPhoneNumber() < 1) {
                        // Invalid id number
-                       throw new IllegalArgumentException(MessageFormat.format("this.landLineNumber.phoneNumber={0} is not valid", this.getLandLineNumber().getPhoneNumber()));
+                       throw new IllegalArgumentException(MessageFormat.format("this.landLineNumber.phoneNumber={0} is not valid", this.getLandLineNumber().getPhoneNumber())); //NOI18N
                }
 
-               // Copy all (changeable) data fields to admin controller
-               this.adminPhoneController.setPhoneAreaCode(this.getLandLineNumber().getPhoneAreaCode());
-               this.adminPhoneController.setPhoneCountry(this.getLandLineNumber().getPhoneCountry());
-               this.adminPhoneController.setPhoneNumber(this.getLandLineNumber().getPhoneNumber());
+               // Fire event
+               this.landLineNumberCreatedEvent.fire(new CreatedLandLineNumberEvent(this.getLandLineNumber()));
        }
 
-       @Override
-       public void copyMobileNumberToController () {
+       /**
+        * Notifies other controllers (backing beans) if a phone id has been
+        * successfully converted to a DialableMobileNumber instance.
+        */
+       public void notifyControllerMobileNumberConverted () {
                // Validate mobile instance
                if (this.getMobileNumber() == null) {
                        // Throw NPE
-                       throw new NullPointerException("this.mobileNumber is null");
+                       throw new NullPointerException("this.mobileNumber is null"); //NOI18N
                } else if (this.getMobileNumber().getPhoneId() == null) {
                        // Throw again
-                       throw new NullPointerException("this.mobileNumber.phoneId is null");
+                       throw new NullPointerException("this.mobileNumber.phoneId is null"); //NOI18N
                } else if (this.getMobileNumber().getPhoneId() < 1) {
                        // Invalid id number
-                       throw new IllegalArgumentException(MessageFormat.format("this.mobileNumber.phoneId={0} is not valid", this.getMobileNumber().getPhoneId()));
+                       throw new IllegalArgumentException(MessageFormat.format("this.mobileNumber.phoneId={0} is not valid", this.getMobileNumber().getPhoneId())); //NOI18N
                } else if (this.getMobileNumber().getMobileProvider() == null) {
                        // Throw NPE again
-                       throw new NullPointerException("this.mobileNumber.mobileProvider is null");
+                       throw new NullPointerException("this.mobileNumber.mobileProvider is null"); //NOI18N
                } else if (this.getMobileNumber().getMobileProvider().getProviderId() == null) {
                        // ... throw again
-                       throw new NullPointerException("this.mobileNumber.mobileProvider.providerId is null");
+                       throw new NullPointerException("this.mobileNumber.mobileProvider.providerId is null"); //NOI18N
                } else if (this.getMobileNumber().getMobileProvider().getProviderId() < 1) {
                        // Invalid id
-                       throw new IllegalArgumentException(MessageFormat.format("this.mobileNumber.mobileProvider.providerId={0} is invalid", this.getMobileNumber().getMobileProvider().getProviderId()));
+                       throw new IllegalArgumentException(MessageFormat.format("this.mobileNumber.mobileProvider.providerId={0} is invalid", this.getMobileNumber().getMobileProvider().getProviderId())); //NOI18N
                } else if (this.getMobileNumber().getPhoneNumber() == null) {
                        // Throw NPE again ...
-                       throw new NullPointerException("this.mobileNumber.phoneNumber is null");
+                       throw new NullPointerException("this.mobileNumber.phoneNumber is null"); //NOI18N
                } else if (this.getMobileNumber().getPhoneNumber() < 1) {
                        // Invalid id number
-                       throw new IllegalArgumentException(MessageFormat.format("this.mobileNumber.phoneNumber={0} is not valid", this.getMobileNumber().getPhoneNumber()));
+                       throw new IllegalArgumentException(MessageFormat.format("this.mobileNumber.phoneNumber={0} is not valid", this.getMobileNumber().getPhoneNumber())); //NOI18N
                }
 
-               // Copy all (changeable) data fields to admin controller
-               this.adminPhoneController.setMobileProvider(this.getMobileNumber().getMobileProvider());
-               this.adminPhoneController.setPhoneNumber(this.getMobileNumber().getPhoneNumber());
+               // Fire event
+               this.mobileNumberCreatedEvent.fire(new CreatedMobileNumberEvent(this.getMobileNumber()));
        }
 
-       @Override
-       public void copyUserToController () {
-               // Log message
-               //* NOISY-DEBUG: */ System.out.println("AdminHelper::copyUserToController - CALLED!"); //NOI18N
-
+       /**
+        * Notifies other controllers (backing beans) if a user id has been
+        * successfully converted to a User instance.
+        */
+       public void notifyControllerUserConverted () {
                // Validate user instance
                if (this.getUser() == null) {
                        // Throw NPE
-                       throw new NullPointerException("this.user is null");
+                       throw new NullPointerException("this.user is null"); //NOI18N
                } else if (this.getUser().getUserId() == null) {
                        // Throw NPE again
-                       throw new NullPointerException("this.user.userId is null");
+                       throw new NullPointerException("this.user.userId is null"); //NOI18N
                } else if (this.getUser().getUserId() < 1) {
                        // Not valid
-                       throw new IllegalStateException(MessageFormat.format("this.user.userId={0} is not valid.", this.getUser().getUserId()));
+                       throw new IllegalStateException(MessageFormat.format("this.user.userId={0} is not valid.", this.getUser().getUserId())); //NOI18N
                }
 
                // Get contact
-               Contact userContact = this.getUser().getUserContact();
+               final Contact userContact = this.getUser().getUserContact();
 
                // Set contact here, too. This avoids parameters that cannot auto-complete in IDEs.
                this.setContact(userContact);
@@ -273,93 +436,351 @@ public class JobsWebViewHelperBean extends BaseJobsController implements JobsWeb
                // Set all phone instances
                this.setPhoneInstances(userContact);
 
-               // Set all fields: user
-               this.userController.setUserName(this.getUser().getUserName());
-               this.adminUserController.setUserName(this.getUser().getUserName());
+               // Fire event
+               this.userCreatedEvent.fire(new CreatedUserEvent(this.getUser()));
        }
 
-       @Override
-       public Contact getContact () {
-               // String caller = MessageFormat.format("{0}.{1}", Thread.currentThread().getStackTrace()[THREAD_STACK].getClassName(), Thread.currentThread().getStackTrace()[THREAD_STACK].getMethodName());
-               // System.out.println(MessageFormat.format("{0}: Returning this.contact={1}, caller: {2}", this.getClass().getSimpleName(), this.contact, caller));
-               return this.contact;
-       }
+       /**
+        * Renders data of basic company data
+        * <p>
+        * @param basicData Basic company data instance
+        * <p>
+        * @return Basic company data as string
+        */
+       public String renderBasicData (final BasicData basicData) {
+               // Default is empty string, so let's get started
+               final StringBuilder sb = new StringBuilder(30);
+
+               // Is basic company data set?
+               if (basicData instanceof BasicData) {
+                       // Add company name
+                       sb.append(basicData.getCompanyName()); //NOI18N
+
+                       // Is email address set?
+                       if (basicData.getCompanyEmailAddress() != null) {
+                               // Add it
+                               sb.append(", ").append(basicData.getCompanyEmailAddress()); //NOI18N
+                       }
+
+                       // Is tax number set?
+                       if (basicData.getCompanyTaxNumber() != null) {
+                               // Add it
+                               sb.append(", ").append(basicData.getCompanyTaxNumber()); //NOI18N
+                       }
+               }
 
-       @Override
-       public void setContact (final Contact contact) {
-               // String caller = MessageFormat.format("{0}.{1}", Thread.currentThread().getStackTrace()[THREAD_STACK].getClassName(), Thread.currentThread().getStackTrace()[THREAD_STACK].getMethodName());
-               // System.out.println(MessageFormat.format("{0}: Setting contact={1}, previous: {2}, caller: {3}", this.getClass().getSimpleName(), contact, this.contact, caller));
-               this.contact = contact;
+               // Return it
+               return sb.toString();
        }
 
-       @Override
-       public String getContactUsageMessageKey (final Contact contact) {
-               // The contact must be valid
-               if (null == contact) {
-                       // Throw NPE
-                       throw new NullPointerException("contact is null"); //NOI18N
-               } else if (contact.getContactId() == null) {
-                       // Throw again ...
-                       throw new NullPointerException("contact.contactId is null"); //NOI18N
-               } else if (contact.getContactId() < 1) {
-                       // Not valid
-                       throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N
+       /**
+        * Returns the branch office's full address. If null is provided, an empty
+        * string is returned.
+        * <p>
+        * @param branchOffice Branch office instance
+        * <p>
+        * @return Branch office's address
+        */
+       public String renderBranchOffice (final BranchOffice branchOffice) {
+               // Default is empty string, so let's get started
+               final StringBuilder sb = new StringBuilder(30);
+
+               // Is a branch office instance given?
+               if (branchOffice instanceof BranchOffice) {
+                       // This should not happen:
+                       assert (branchOffice.getBranchCompany() instanceof BasicData) : "branchOffice.branchCompany is null"; //NOI18N
+
+                       // Yes, then append all data
+                       sb.append(branchOffice.getBranchCompany().getCompanyName());
+                       sb.append(", "); //NOI18N
+                       sb.append(branchOffice.getBranchStreet());
+                       sb.append(" "); //NOI18N
+                       sb.append(branchOffice.getBranchHouseNumber());
+                       sb.append(", "); //NOI18N
+                       sb.append(branchOffice.getBranchCountry().getCountryCode());
+                       sb.append(" "); //NOI18N
+                       sb.append(branchOffice.getBranchZipCode());
+                       sb.append(" "); //NOI18N
+                       sb.append(branchOffice.getBranchCity());
                }
 
-               // Default key is "unused"
-               String messageKey = "CONTACT_IS_UNUSED"; //NOI18N
-
-               // Check user
-               boolean isUserContact = this.userController.isContactFound(contact);
+               // Return it
+               return sb.toString();
+       }
 
-               // Check user first
-               if (isUserContact) {
-                       // Only user
-                       messageKey = "CONTACT_IS_USER"; //NOI18N
+       /**
+        * Returns the contact's personal title, family name and name. If null is
+        * provided, an empty string is returned.
+        * <p>
+        * @param contact Contact instance
+        * <p>
+        * @return Contact's full name
+        */
+       public String renderContact (final Contact contact) {
+               // Default is empty string, so let's get started
+               final StringBuilder sb = new StringBuilder(20);
+
+               // Is contact set?
+               if (contact instanceof Contact) {
+                       // Then create name
+                       sb.append(this.getMessageFromBundle(contact.getContactPersonalTitle().getMessageKey()));
+                       sb.append(" "); //NOI18N
+                       sb.append(contact.getContactFirstName());
+                       sb.append(" "); //NOI18N
+                       sb.append(contact.getContactFamilyName());
                }
 
-               // Return message key
-               return messageKey;
+               // Return it
+               return sb.toString();
        }
 
-       @Override
-       public DialableFaxNumber getFaxNumber () {
-               return this.faxNumber;
-       }
+       /**
+        * Returns the text representation of given country. If null is provided, an
+        * empty string is returned.
+        * <p>
+        * @param country Country instance
+        * <p>
+        * @return Country's text representation
+        */
+       public String renderCountry (final Country country) {
+               // Default is empty string, so let's get started
+               final StringBuilder sb = new StringBuilder(20);
+
+               // Is a country given?
+               if (country instanceof Country) {
+                       // Yes, then render it
+                       sb.append(this.getMessageFromBundle(country.getCountryI18nKey()));
+                       sb.append(" ("); //NOI18N
+                       sb.append(country.getCountryCode());
+                       sb.append(")"); //NOI18N
+               }
 
-       @Override
-       public void setFaxNumber (final DialableFaxNumber faxNumber) {
-               this.faxNumber = faxNumber;
+               // Return it
+               return sb.toString();
        }
 
-       @Override
-       public DialableLandLineNumber getLandLineNumber () {
-               return this.landLineNumber;
+       /**
+        * Returns the department's name and name of assigned company. If null is
+        * provided, an empty string is returned.
+        * <p>
+        * @param department Department instance
+        * <p>
+        * @return Department's full name
+        */
+       public String renderDepartment (final Department department) {
+               // Default is empty string, so let's get started
+               final StringBuilder sb = new StringBuilder(10);
+
+               // Is a department set?
+               if (department instanceof Department) {
+                       // Then create name
+                       sb.append(this.getMessageFromBundle(department.getDepartmentI18nKey()));
+                       sb.append(" ("); //NOI18N
+                       sb.append(department.getDepartmentCompany().getCompanyName());
+                       sb.append(")"); //NOI18N
+               }
+
+               // Return it
+               return sb.toString();
        }
 
-       @Override
-       public void setLandLineNumber (final DialableLandLineNumber landLineNumber) {
-               this.landLineNumber = landLineNumber;
+       /**
+        * Returns the employee's number, personal title, family name and name if
+        * available. If null is provided, an empty string is returned.
+        * <p>
+        * @param employee Employable instance
+        * <p>
+        * @return A string representing an employee
+        */
+       public String renderEmployee (final Employable employee) {
+               // Default is empty string, so let's get started
+               final StringBuilder sb = new StringBuilder(20);
+
+               // Is employee set?
+               if (employee instanceof Employable) {
+                       // Is the number given?
+                       if (employee.getEmployeeNumber() != null) {
+                               // Then create name
+                               sb.append(employee.getEmployeeNumber());
+                       }
+
+                       // Is contact data found?
+                       if (employee.getEmployeePersonalData() instanceof Contact) {
+                               // Yes, then render it
+                               final String contactName = this.renderContact(employee.getEmployeePersonalData());
+
+                               // Is it given?
+                               if (contactName != null && !contactName.isEmpty()) {
+                                       // Only add braces when employee number is given
+                                       if (employee.getEmployeeNumber() != null) {
+                                               sb.append(" ("); //NOI18N
+                                       }
+
+                                       // Then add it
+                                       sb.append(contactName);
+
+                                       // Only add braces when employee number is given
+                                       if (employee.getEmployeeNumber() != null) {
+                                               sb.append(")"); //NOI18N
+                                       }
+                               }
+                       }
+
+                       // Is a department found?
+                       if (employee.getEmployeeDepartment() instanceof Department) {
+                               // Only add braces when employee number is given
+                               if (employee.getEmployeeNumber() != null || employee.getEmployeePersonalData() instanceof Contact) {
+                                       sb.append(" ("); //NOI18N
+                               }
+
+                               // Add department name
+                               sb.append(this.renderDepartment(employee.getEmployeeDepartment()));
+
+                               // Only add braces when employee number is given
+                               if (employee.getEmployeeNumber() != null || employee.getEmployeePersonalData() instanceof Contact) {
+                                       sb.append(")"); //NOI18N
+                               }
+                       }
+               }
+
+               // Return it
+               return sb.toString();
        }
 
-       @Override
-       public DialableMobileNumber getMobileNumber () {
-               return this.mobileNumber;
+       /**
+        * Returns the headquarter address. If null is provided, an empty string is
+        * returned.
+        * <p>
+        * @param headquarter Headquarter instance
+        * <p>
+        * @return Headquarter address
+        */
+       public String renderHeadquarter (final Headquarter headquarter) {
+               // Default is empty string, so let's get started
+               final StringBuilder sb = new StringBuilder(10);
+
+               // Is a headquarter set?
+               if (headquarter instanceof Headquarter) {
+                       // Then create name
+                       sb.append(headquarter.getHeadquarterStreet());
+                       sb.append(" "); //NOI18N
+                       sb.append(headquarter.getHeadquarterHouseNumber());
+
+                       // Is store/suite number set?
+                       if (headquarter.getHeadquarterStore() instanceof Short) {
+                               sb.append(" ("); //NOI18N
+                               sb.append(this.getMessageFromBundle("DATA_STORE")); //NOI18N
+                               sb.append(" "); //NOI18N
+                               sb.append(headquarter.getHeadquarterStore());
+                               sb.append(", "); //NOI18N
+                               sb.append(this.getMessageFromBundle("DATA_SUITE_NUMBER")); //NOI18N
+                               sb.append(" "); //NOI18N
+                               sb.append(headquarter.getHeadquarterSuiteNumber());
+                               sb.append(")"); //NOI18N
+                       }
+
+                       // Continue with country, ZIP code and city
+                       sb.append(", "); //NOI18N
+                       sb.append(headquarter.getHeadquarterCountry().getCountryCode());
+                       sb.append(" "); //NOI18N
+                       sb.append(headquarter.getHeadquarterZipCode());
+                       sb.append(" "); //NOI18N
+                       sb.append(headquarter.getHeadquarterCity());
+               }
+
+               // Return it
+               return sb.toString();
        }
 
-       @Override
-       public void setMobileNumber (final DialableMobileNumber mobileNumber) {
-               this.mobileNumber = mobileNumber;
+       /**
+        * Renders given mobile number (land-line and fax number). If null is
+        * provided, an empty string is returned.
+        * <p>
+        * @param mobileNumber Mobile number to render
+        * <p>
+        * @return Mobile number
+        */
+       public String renderMobileNumber (final DialableMobileNumber mobileNumber) {
+               // Default is empty string, so let's get started
+               final StringBuilder sb = new StringBuilder(20);
+
+               // Is a phone number given?
+               if (mobileNumber instanceof DialableMobileNumber) {
+                       // Yes, then render it
+                       sb.append(mobileNumber.getMobileProvider().getProviderCountry().getCountryAbroadDialPrefix());
+                       sb.append(mobileNumber.getMobileProvider().getProviderCountry().getCountryPhoneCode());
+                       sb.append(" ("); //NOI18N
+                       sb.append(mobileNumber.getMobileProvider().getProviderDialPrefix());
+                       sb.append(") "); //NOI18N
+                       sb.append(mobileNumber.getPhoneNumber());
+               }
+
+               // Return it
+               return sb.toString();
        }
 
-       @Override
-       public User getUser () {
-               return this.user;
+       /**
+        * Renders given phone number (land-line and fax number). If null is
+        * provided, an empty string is returned.
+        * <p>
+        * @param number Phone number to render
+        * <p>
+        * @return Phone number
+        * <p>
+        * @throws IllegalArgumentException If a mobile number is provided
+        */
+       public String renderPhoneNumber (final DialableNumber number) {
+               // Validate parameter
+               if (number instanceof DialableMobileNumber) {
+                       // Not allowed here
+                       throw new IllegalArgumentException("Mobile numbers cannot be rendered with this method. Please use renderMobileNumber() instead."); //NOI18N
+               }
+
+               // Default is empty string, so let's get started
+               final StringBuilder sb = new StringBuilder(20);
+
+               // Is a phone number given?
+               if (number instanceof DialableNumber) {
+                       // Yes, then render it
+                       sb.append(number.getPhoneCountry().getCountryAbroadDialPrefix());
+                       sb.append(number.getPhoneCountry().getCountryPhoneCode());
+                       sb.append(" ("); //NOI18N
+                       sb.append(number.getPhoneAreaCode());
+                       sb.append(") "); //NOI18N
+                       sb.append(number.getPhoneNumber());
+               }
+
+               // Return it
+               return sb.toString();
        }
 
-       @Override
-       public void setUser (final User user) {
-               this.user = user;
+       /**
+        * Returns the user's personal title, family name and name. If null is
+        * provided, an empty string is returned.
+        * <p>
+        * @param user User instance
+        * <p>
+        * @return User's full name
+        */
+       public String renderUser (final User user) {
+               // Default is empty string, so let's get started
+               final StringBuilder sb = new StringBuilder(20);
+
+               // Is user given?
+               if (user instanceof User) {
+                       // Add user name first
+                       sb.append(user.getUserName());
+                       sb.append(" ("); //NOI18N
+
+                       // Add contact data
+                       sb.append(this.renderContact(user.getUserContact()));
+
+                       // Close brace
+                       sb.append(")"); //NOI18N
+               }
+
+               // Return it
+               return sb.toString();
        }
 
        /**