]> git.mxchange.org Git - jfinancials-war.git/blobdiff - src/java/org/mxchange/jfinancials/beans/contact/phone/FinancialsAdminContactPhoneWebRequestBean.java
Updated copyright year
[jfinancials-war.git] / src / java / org / mxchange / jfinancials / beans / contact / phone / FinancialsAdminContactPhoneWebRequestBean.java
index 828aa197debd6d37e0258cb0533a9ae046189924..c1cac3dfb972c06e6dbdf29359a3271d4b075048 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016, 2017 Roland Häder
+ * Copyright (C) 2016 - 2022 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.jfinancials.beans.contact.phone;
 
 import java.text.MessageFormat;
-import javax.annotation.PostConstruct;
+import java.util.Date;
+import javax.ejb.EJB;
 import javax.enterprise.context.RequestScoped;
 import javax.enterprise.event.Event;
 import javax.enterprise.event.Observes;
 import javax.enterprise.inject.Any;
-import javax.faces.view.facelets.FaceletException;
+import javax.faces.application.FacesMessage;
 import javax.inject.Inject;
 import javax.inject.Named;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import org.mxchange.jcontacts.contact.Contact;
 import org.mxchange.jcontacts.events.contact.add.ObservableAdminAddedContactEvent;
+import org.mxchange.jcontacts.events.contact.created.ObservableCreatedContactEvent;
 import org.mxchange.jcontacts.events.contact.update.ObservableAdminUpdatedContactEvent;
+import org.mxchange.jcontacts.events.contact.update.ObservableUpdatedContactEvent;
 import org.mxchange.jcontacts.events.fax.linked.AdminLinkedFaxNumberEvent;
 import org.mxchange.jcontacts.events.fax.linked.ObservableAdminLinkedFaxNumberEvent;
 import org.mxchange.jcontacts.events.fax.unlinked.AdminUnlinkedFaxNumberEvent;
@@ -39,24 +38,20 @@ import org.mxchange.jcontacts.events.landline.linked.AdminLinkedLandLineNumberEv
 import org.mxchange.jcontacts.events.landline.linked.ObservableAdminLinkedLandLineNumberEvent;
 import org.mxchange.jcontacts.events.landline.unlinked.AdminUnlinkedLandLineNumberEvent;
 import org.mxchange.jcontacts.events.landline.unlinked.ObservableAdminUnlinkedLandLineNumberEvent;
-import org.mxchange.jcontacts.events.mobile.linked.AdminLinkedMobileNumberEvent;
-import org.mxchange.jcontacts.events.mobile.linked.ObservableAdminLinkedMobileNumberEvent;
-import org.mxchange.jcontacts.events.mobile.unlinked.AdminUnlinkedMobileNumberEvent;
-import org.mxchange.jcontacts.events.mobile.unlinked.ObservableAdminUnlinkedMobileNumberEvent;
-import org.mxchange.jcontacts.phone.AdminContactsPhoneSessionBeanRemote;
-import org.mxchange.jcountry.data.Country;
-import org.mxchange.jfinancials.beans.BaseFinancialsController;
-import org.mxchange.jfinancials.beans.helper.FinancialsWebRequestHelperController;
+import org.mxchange.jcontacts.exceptions.ContactNotFoundException;
+import org.mxchange.jcontacts.model.contact.Contact;
+import org.mxchange.jcontacts.model.phone.AdminContactsPhoneSessionBeanRemote;
+import org.mxchange.jcountry.model.data.Country;
+import org.mxchange.jfinancials.beans.BaseFinancialsBean;
 import org.mxchange.jfinancials.beans.phone.FinancialsAdminPhoneWebRequestController;
-import org.mxchange.jphone.exceptions.PhoneNumberAlreadyLinkedException;
-import org.mxchange.jphone.exceptions.PhoneNumberNotLinkedException;
-import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
-import org.mxchange.jphone.phonenumbers.fax.FaxNumber;
-import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
-import org.mxchange.jphone.phonenumbers.landline.LandLineNumber;
-import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
-import org.mxchange.jphone.phonenumbers.mobile.MobileNumber;
-import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider;
+import org.mxchange.jphone.events.fax.created.ObservableCreatedFaxNumberEvent;
+import org.mxchange.jphone.events.landline.created.ObservableCreatedLandLineNumberEvent;
+import org.mxchange.jphone.exceptions.phone.PhoneNumberAlreadyLinkedException;
+import org.mxchange.jphone.exceptions.phone.PhoneNumberNotLinkedException;
+import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
+import org.mxchange.jphone.model.phonenumbers.fax.FaxNumber;
+import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber;
+import org.mxchange.jphone.model.phonenumbers.landline.LandLineNumber;
 import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent;
 
 /**
@@ -66,7 +61,7 @@ import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent;
  */
 @Named ("adminContactPhoneController")
 @RequestScoped
-public class FinancialsAdminContactPhoneWebRequestBean extends BaseFinancialsController implements FinancialsAdminContactPhoneWebRequestController {
+public class FinancialsAdminContactPhoneWebRequestBean extends BaseFinancialsBean implements FinancialsAdminContactPhoneWebRequestController {
 
        /**
         * Call-stack instance (5 may show BeanELResolver.getValue as caller)
@@ -78,6 +73,12 @@ public class FinancialsAdminContactPhoneWebRequestBean extends BaseFinancialsCon
         */
        private static final long serialVersionUID = 542_145_347_916L;
 
+       /**
+        * Administrative EJB for phone number
+        */
+       @EJB (lookup = "java:global/jfinancials-ejb/adminContactPhone!org.mxchange.jcontacts.model.phone.AdminContactsPhoneSessionBeanRemote")
+       private AdminContactsPhoneSessionBeanRemote adminContactPhoneBean;
+
        /**
         * Event being fired when a fax number has been linked
         */
@@ -92,18 +93,6 @@ public class FinancialsAdminContactPhoneWebRequestBean extends BaseFinancialsCon
        @Any
        private Event<ObservableAdminLinkedLandLineNumberEvent> adminLinkedLandLineNumberEvent;
 
-       /**
-        * Event being fired when a mobile number has been linked
-        */
-       @Inject
-       @Any
-       private Event<ObservableAdminLinkedMobileNumberEvent> adminLinkedMobileNumberEvent;
-
-       /**
-        * Administrative EJB for phone number
-        */
-       private AdminContactsPhoneSessionBeanRemote adminPhoneBean;
-
        /**
         * Administrative phone controller
         */
@@ -111,31 +100,9 @@ public class FinancialsAdminContactPhoneWebRequestBean extends BaseFinancialsCon
        private FinancialsAdminPhoneWebRequestController adminPhoneController;
 
        /**
-        * Bean helper
+        * Contact instance
         */
-       @Inject
-       private FinancialsWebRequestHelperController beanHelper;
-
-       /**
-        * Event being fired when a fax number has been unlinked
-        */
-       @Inject
-       @Any
-       private Event<ObservableAdminUnlinkedFaxNumberEvent> faxNumberUnlinkedEvent;
-
-       /**
-        * Event being fired when a land-line number has been unlinked
-        */
-       @Inject
-       @Any
-       private Event<ObservableAdminUnlinkedLandLineNumberEvent> landLineNumberUnlinkedEvent;
-
-       /**
-        * Event being fired when admin unlinks mobile from contact
-        */
-       @Inject
-       @Any
-       private Event<ObservableAdminUnlinkedMobileNumberEvent> mobileNumberUnlinkedEvent;
+       private Contact contact;
 
        /**
         * Area code (city dial prefix) for fax number
@@ -152,6 +119,13 @@ public class FinancialsAdminContactPhoneWebRequestBean extends BaseFinancialsCon
         */
        private Long faxNumber;
 
+       /**
+        * Event being fired when a fax number has been unlinked
+        */
+       @Inject
+       @Any
+       private Event<ObservableAdminUnlinkedFaxNumberEvent> faxNumberUnlinkedEvent;
+
        /**
         * Area code (city dial prefix) for land-line number
         */
@@ -168,14 +142,26 @@ public class FinancialsAdminContactPhoneWebRequestBean extends BaseFinancialsCon
        private Long landLineNumber;
 
        /**
-        * Mobile provider
+        * Event being fired when a land-line number has been unlinked
+        */
+       @Inject
+       @Any
+       private Event<ObservableAdminUnlinkedLandLineNumberEvent> landLineNumberUnlinkedEvent;
+
+       /**
+        * When phone number has been created
         */
-       private MobileProvider mobileProvider;
+       private Date phoneEntryCreated;
 
        /**
-        * Mobile number
+        * When phone number has been updated
         */
-       private Long mobileNumber;
+       private Date phoneEntryUpdated;
+
+       /**
+        * Phone id (primary key)
+        */
+       private Long phoneId;
 
        /**
         * Default constructor
@@ -220,7 +206,7 @@ public class FinancialsAdminContactPhoneWebRequestBean extends BaseFinancialsCon
         * @param event Event being fired
         */
        public void afterAdminAddedUserEvent (@Observes final ObservableAdminAddedUserEvent event) {
-               // event should not be null
+               // Event and contained entity instance should not be null
                if (null == event) {
                        // Throw NPE
                        throw new NullPointerException("event is null"); //NOI18N
@@ -245,7 +231,129 @@ public class FinancialsAdminContactPhoneWebRequestBean extends BaseFinancialsCon
         * @param event Updated contact data event
         */
        public void afterAdminUpdatedContactDataEvent (@Observes final ObservableAdminUpdatedContactEvent event) {
-               // event should not be null
+               // Event and contained entity instance should not be null
+               if (null == event) {
+                       // Throw NPE
+                       throw new NullPointerException("event is null"); //NOI18N
+               } else if (event.getUpdatedContact() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("event.updatedContact is null"); //NOI18N
+               } else if (event.getUpdatedContact().getContactId() == null) {
+                       // userId is null
+                       throw new NullPointerException("event.updatedContact.contactId is null"); //NOI18N
+               } else if (event.getUpdatedContact().getContactId() < 1) {
+                       // Not avalid id
+                       throw new IllegalArgumentException(MessageFormat.format("contactId of contact={0} is not valid: {1}", event.getUpdatedContact(), event.getUpdatedContact().getContactId())); //NOI18N
+               }
+
+               // Clear all data
+               this.clear();
+       }
+
+       /**
+        * Observer for events being fired when a bean helper has successfully
+        * created a contact instance.
+        * <p>
+        * @param event Event being fired
+        */
+       public void afterCreatedContactEvent (@Observes final ObservableCreatedContactEvent event) {
+               // Log message
+               //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("AdminContactController::afterCreatedContactEvent(): contact={0} - CALLED!", contact)); //NOI18N
+
+               // The event instance must be valid
+               if (null == event) {
+                       // Throw NPE again
+                       throw new NullPointerException("event is null"); //NOI18N
+               } else if (event.getCreatedContact() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("event.createdContact is null"); //NOI18N
+               } else if (event.getCreatedContact().getContactId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("event.createdContact.contactId is null"); //NOI18N
+               } else if (event.getCreatedContact().getContactId() < 1) {
+                       // Not valid
+                       throw new IllegalStateException(MessageFormat.format("event.createdContact.contactId={0} is not valid.", event.getCreatedContact().getContactId())); //NOI18N
+               }
+
+               // Set it here
+               this.setContact(event.getCreatedContact());
+       }
+
+       /**
+        * Observes events being fired when a bean helper has successfully created a
+        * fax number instance.
+        * <p>
+        * @param event Event being fired
+        */
+       public void afterCreatedFaxNumberEvent (@Observes final ObservableCreatedFaxNumberEvent event) {
+               // The event instance must be valid
+               if (null == event) {
+                       // Throw NPE
+                       throw new NullPointerException("event is null"); //NOI18N
+               } else if (event.getFaxNumber() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("event.faxNumber is null"); //NOI18N
+               } else if (event.getFaxNumber().getPhoneId() == null) {
+                       // Throw NPE yet again
+                       throw new NullPointerException("event.faxNumber.phoneId is null"); //NOI18N
+               } else if (event.getFaxNumber().getPhoneId() < 1) {
+                       // Throw NPE yet again
+                       throw new NullPointerException(MessageFormat.format("event.faxNumber.phoneId={0} is invalid", event.getFaxNumber().getPhoneId())); //NOI18N
+               }
+
+               // Get fax number from event
+               final DialableFaxNumber number = event.getFaxNumber();
+
+               // Copy all data to this bean
+               this.setPhoneId(number.getPhoneId());
+               this.setFaxCountry(number.getPhoneCountry());
+               this.setFaxAreaCode(number.getPhoneAreaCode());
+               this.setFaxNumber(number.getPhoneNumber());
+               this.setPhoneEntryCreated(number.getPhoneEntryCreated());
+               this.setPhoneEntryUpdated(number.getPhoneEntryUpdated());
+       }
+
+       /**
+        * Observes events being fired when a bean helper has successfully created a
+        * land-line number instance.
+        * <p>
+        * @param event Event being fired
+        */
+       public void afterCreatedLandLineNumberEvent (@Observes final ObservableCreatedLandLineNumberEvent event) {
+               // The event instance must be valid
+               if (null == event) {
+                       // Throw NPE
+                       throw new NullPointerException("event is null"); //NOI18N
+               } else if (event.getLandLineNumber() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("event.landLineNumber is null"); //NOI18N
+               } else if (event.getLandLineNumber().getPhoneId() == null) {
+                       // Throw NPE yet again
+                       throw new NullPointerException("event.landLineNumber.phoneId is null"); //NOI18N
+               } else if (event.getLandLineNumber().getPhoneId() < 1) {
+                       // Throw NPE yet again
+                       throw new NullPointerException(MessageFormat.format("event.landLineNumber.phoneId={0} is invalid", event.getLandLineNumber().getPhoneId())); //NOI18N
+               }
+
+               // Get fax number from event
+               final DialableLandLineNumber number = event.getLandLineNumber();
+
+               // Copy all data to this bean
+               this.setPhoneId(number.getPhoneId());
+               this.setLandLineCountry(number.getPhoneCountry());
+               this.setLandLineAreaCode(number.getPhoneAreaCode());
+               this.setLandLineNumber(number.getPhoneNumber());
+               this.setPhoneEntryCreated(number.getPhoneEntryCreated());
+               this.setPhoneEntryUpdated(number.getPhoneEntryUpdated());
+       }
+
+       /**
+        * Event observer for updated contact data by the user
+        * <p>
+        * @param event Updated contact data event
+        */
+       public void afterUpdatedContactDataEvent (@Observes final ObservableUpdatedContactEvent event) {
+               // Event and contained entity instance should not be null
                if (null == event) {
                        // Throw NPE
                        throw new NullPointerException("event is null"); //NOI18N
@@ -271,18 +379,18 @@ public class FinancialsAdminContactPhoneWebRequestBean extends BaseFinancialsCon
         */
        public String doLinkMainFaxNumber () {
                // Get contact from helper
-               Contact contact = this.beanHelper.getContact();
+               final Contact targetContact = this.getContact();
 
                // Is all data properly set?
-               if (null == contact) {
+               if (null == targetContact) {
                        // Throw NPE
-                       throw new NullPointerException("contact is null"); //NOI18N
-               } else if (contact.getContactId() == null) {
+                       throw new NullPointerException("targetContact is null"); //NOI18N
+               } else if (targetContact.getContactId() == null) {
                        // Throw it again
-                       throw new NullPointerException("contact.contactId is null"); //NOI18N
-               } else if (contact.getContactId() < 1) {
+                       throw new NullPointerException("targetContact.contactId is null"); //NOI18N
+               } else if (targetContact.getContactId() < 1) {
                        // Is not valid
-                       throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N
+                       throw new IllegalArgumentException(MessageFormat.format("targetContact.contactId={0} is not valid", targetContact.getContactId())); //NOI18N
                } else if (this.getFaxCountry() == null) {
                        // Throw NPE again
                        throw new NullPointerException("this.faxCountry is null"); //NOI18N
@@ -307,16 +415,16 @@ public class FinancialsAdminContactPhoneWebRequestBean extends BaseFinancialsCon
                }
 
                // Init instances
-               Contact updatedContact;
-               DialableFaxNumber number = new FaxNumber(this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());
+               final Contact updatedContact;
+               final DialableFaxNumber number = new FaxNumber(this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());
 
                // Try it again
                try {
                        // Link it, too
-                       updatedContact = this.adminPhoneBean.linkNewFaxNumberWithContact(contact, number);
-               } catch (final PhoneNumberAlreadyLinkedException ex) {
+                       updatedContact = this.adminContactPhoneBean.linkNewFaxNumberWithContact(targetContact, number);
+               } catch (final PhoneNumberAlreadyLinkedException | ContactNotFoundException ex) {
                        // Throw again as cause
-                       this.showFacesMessage("form_add_contact_fax:faxNumber", ex); //NOI18N
+                       this.showFacesMessage("form_add_contact_fax:faxNumber", ex, FacesMessage.SEVERITY_ERROR); //NOI18N
                        return ""; //NOI18N
                }
 
@@ -335,18 +443,18 @@ public class FinancialsAdminContactPhoneWebRequestBean extends BaseFinancialsCon
         */
        public String doLinkMainLandLineNumber () {
                // Get contact from helper
-               Contact contact = this.beanHelper.getContact();
+               final Contact targetContact = this.getContact();
 
                // Is all data properly set?
-               if (null == contact) {
+               if (null == targetContact) {
                        // Throw NPE
-                       throw new NullPointerException("contact is null"); //NOI18N
-               } else if (contact.getContactId() == null) {
+                       throw new NullPointerException("targetContact is null"); //NOI18N
+               } else if (targetContact.getContactId() == null) {
                        // Throw it again
-                       throw new NullPointerException("contact.contactId is null"); //NOI18N
-               } else if (contact.getContactId() < 1) {
+                       throw new NullPointerException("targetContact.contactId is null"); //NOI18N
+               } else if (targetContact.getContactId() < 1) {
                        // Is not valid
-                       throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N
+                       throw new IllegalArgumentException(MessageFormat.format("targetContact.contactId={0} is not valid", targetContact.getContactId())); //NOI18N
                } else if (this.getLandLineCountry() == null) {
                        // Throw NPE again
                        throw new NullPointerException("this.landLineCountry is null"); //NOI18N
@@ -371,16 +479,16 @@ public class FinancialsAdminContactPhoneWebRequestBean extends BaseFinancialsCon
                }
 
                // Init instance
-               Contact updatedContact;
-               DialableLandLineNumber number = new LandLineNumber(this.getLandLineCountry(), this.getLandLineAreaCode(), this.getLandLineNumber());
+               final Contact updatedContact;
+               final DialableLandLineNumber number = new LandLineNumber(this.getLandLineCountry(), this.getLandLineAreaCode(), this.getLandLineNumber());
 
                // Try it again
                try {
                        // Link it, too
-                       updatedContact = this.adminPhoneBean.linkNewLandLineNumberWithContact(contact, number);
-               } catch (final PhoneNumberAlreadyLinkedException ex) {
+                       updatedContact = this.adminContactPhoneBean.linkNewLandLineNumberWithContact(targetContact, number);
+               } catch (final PhoneNumberAlreadyLinkedException | ContactNotFoundException ex) {
                        // Throw again as cause
-                       this.showFacesMessage("form_add_contact_landLine:landLineNumber", ex); //NOI18N
+                       this.showFacesMessage("form_add_contact_landLine:landLineNumber", ex, FacesMessage.SEVERITY_ERROR); //NOI18N
                        return ""; //NOI18N
                }
 
@@ -392,60 +500,21 @@ public class FinancialsAdminContactPhoneWebRequestBean extends BaseFinancialsCon
        }
 
        /**
-        * Links mobile number to contact from bean helper as "main mobile number".
+        * Getter for contact instance
         * <p>
-        * @return Redirect outcome
+        * @return Contact instance
         */
-       public String doLinkMainMobileNumber () {
-               // Get contact from helper
-               Contact contact = this.beanHelper.getContact();
-
-               // Is all data properly set?
-               if (null == contact) {
-                       // Throw NPE
-                       throw new NullPointerException("contact is null"); //NOI18N
-               } else if (contact.getContactId() == null) {
-                       // Throw it again
-                       throw new NullPointerException("contact.contactId is null"); //NOI18N
-               } else if (contact.getContactId() < 1) {
-                       // Is not valid
-                       throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N
-               } else if (this.getMobileProvider() == null) {
-                       // Throw NPE
-                       throw new NullPointerException("this.mobileProvider is null"); //NOI18N
-               } else if (this.getMobileProvider().getProviderId() == null) {
-                       // Throw NPE
-                       throw new NullPointerException("this.mobileProvider.providerId is null"); //NOI18N
-               } else if (this.getMobileProvider().getProviderId() < 1) {
-                       // Throw NPE
-                       throw new NullPointerException(MessageFormat.format("this.mobileProvider.providerId={0} is invalid", this.getMobileProvider().getProviderId())); //NOI18N
-               } else if (this.getMobileNumber() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("this.mobileNumber is null"); //NOI18N
-               } else if (this.getMobileNumber() < 1) {
-                       // Invalid id number
-                       throw new IllegalArgumentException(MessageFormat.format("this.mobileNumber={0} is invalid", this.getMobileNumber())); //NOI18N
-               }
-
-               // Init instance
-               Contact updatedContact;
-               DialableMobileNumber number = new MobileNumber(this.getMobileProvider(), this.getMobileNumber());
-
-               // Try it again
-               try {
-                       // Link it, too
-                       updatedContact = this.adminPhoneBean.linkNewMobileNumberWithContact(contact, number);
-               } catch (final PhoneNumberAlreadyLinkedException ex) {
-                       // Throw again as cause
-                       this.showFacesMessage("form_add_contact_mobile:mobileNumber", ex); //NOI18N
-                       return ""; //NOI18N
-               }
-
-               // Fire event
-               this.adminLinkedMobileNumberEvent.fire(new AdminLinkedMobileNumberEvent(updatedContact, number));
+       public Contact getContact () {
+               return this.contact;
+       }
 
-               // Return to contact profile
-               return "admin_show_contact"; //NOI18N
+       /**
+        * Setter for contact instance
+        * <p>
+        * @param contact Contact instance
+        */
+       public void setContact (final Contact contact) {
+               this.contact = contact;
        }
 
        /**
@@ -557,57 +626,21 @@ public class FinancialsAdminContactPhoneWebRequestBean extends BaseFinancialsCon
        }
 
        /**
-        * Getter for mobile provider
-        * <p>
-        * @return Mobile provider
-        */
-       public MobileProvider getMobileProvider () {
-               return this.mobileProvider;
-       }
-
-       /**
-        * Setter for mobile provider
-        * <p>
-        * @param mobileProvider Mobile provider
-        */
-       public void setMobileProvider (final MobileProvider mobileProvider) {
-               this.mobileProvider = mobileProvider;
-       }
-
-       /**
-        * Getter for mobile number
+        * Setter for phone id
         * <p>
-        * @return Mobile number
+        * @return Phone id
         */
-       public Long getMobileNumber () {
-               return this.mobileNumber;
+       public Long getPhoneId () {
+               return this.phoneId;
        }
 
        /**
-        * Setter for mobile number
+        * Getter for phone id
         * <p>
-        * @param mobileNumber Mobile number
+        * @param phoneId Phone id
         */
-       public void setMobileNumber (final Long mobileNumber) {
-               this.mobileNumber = mobileNumber;
-       }
-
-       /**
-        * Post-construction method
-        */
-       @PostConstruct
-       public void init () {
-               // Try it
-               try {
-                       // Get initial context
-                       Context context = new InitialContext();
-
-                       // Try to lookup the beans
-                       this.adminPhoneBean = (AdminContactsPhoneSessionBeanRemote) context.lookup("java:global/jfinancials-ejb/adminContactPhone!org.mxchange.jcontacts.phone.AdminContactsPhoneSessionBeanRemote"); //NOI18N
-               } catch (final NamingException e) {
-                       // Throw again
-                       throw new FaceletException(e);
-               }
+       public void setPhoneId (final Long phoneId) {
+               this.phoneId = phoneId;
        }
 
        /**
@@ -616,47 +649,50 @@ public class FinancialsAdminContactPhoneWebRequestBean extends BaseFinancialsCon
         * @return Redirect outcome
         */
        public String unlinkFaxContactData () {
+               // Create fax number instance
+               final DialableFaxNumber number = this.createFaxNumber();
+
                // Is all data set
-               if (this.beanHelper.getFaxNumber() == null) {
+               if (number == null) {
                        // Not set, throw NPE
-                       throw new NullPointerException("this.beanHelper.faxNumber is null"); //NOI18N
-               } else if (this.beanHelper.getFaxNumber().getPhoneId() == null) {
+                       throw new NullPointerException("number is null"); //NOI18N
+               } else if (number.getPhoneId() == null) {
                        // Throw NPE again
-                       throw new NullPointerException("this.beanHelper.faxNumber.phoneId is null"); //NOI18N
-               } else if (this.beanHelper.getFaxNumber().getPhoneId() < 1) {
+                       throw new NullPointerException("number.phoneId is null"); //NOI18N
+               } else if (number.getPhoneId() < 1) {
                        // Invalid number
-                       throw new IllegalArgumentException(MessageFormat.format("this.beanHelper.faxNumber.phoneId={0} is not valid", this.beanHelper.getFaxNumber().getPhoneId())); //NOI18N
-               } else if (this.beanHelper.getFaxNumber().getPhoneNumber() == null) {
+                       throw new IllegalArgumentException(MessageFormat.format("number.phoneId={0} is not valid", number.getPhoneId())); //NOI18N
+               } else if (number.getPhoneNumber() == null) {
                        // Throw NPE again
-                       throw new NullPointerException("this.beanHelper.faxNumber.phoneNumber is null"); //NOI18N
-               } else if (this.beanHelper.getFaxNumber().getPhoneNumber() < 1) {
+                       throw new NullPointerException("number.phoneNumber is null"); //NOI18N
+               } else if (number.getPhoneNumber() < 1) {
                        // Throw it again ...
-                       throw new NullPointerException(MessageFormat.format("this.beanHelper.faxNumber.phoneNumber={0} is not valid.", this.beanHelper.getFaxNumber().getPhoneNumber())); //NOI18N
-               } else if (this.beanHelper.getContact() == null) {
+                       throw new NullPointerException(MessageFormat.format("number.phoneNumber={0} is not valid.", number.getPhoneNumber())); //NOI18N
+               } else if (this.getContact() == null) {
                        // ... and throw again
-                       throw new NullPointerException("this.beanHelper.contact is null"); //NOI18N
-               } else if (this.beanHelper.getContact().getContactId() == null) {
+                       throw new NullPointerException("this.contact is null"); //NOI18N
+               } else if (this.getContact().getContactId() == null) {
                        // ... and again ...
-                       throw new NullPointerException("this.beanHelper.contact.contactId is null"); //NOI18N
-               } else if (this.beanHelper.getContact().getContactId() < 1) {
+                       throw new NullPointerException("this.contact.contactId is null"); //NOI18N
+               } else if (this.getContact().getContactId() < 1) {
                        // Invalid id number
-                       throw new IllegalArgumentException(MessageFormat.format("this.beanHelper.contact.contactId={0} is invalid.", this.beanHelper.getContact().getContactId())); //NOI18N
+                       throw new IllegalArgumentException(MessageFormat.format("this.contact.contactId={0} is invalid.", this.getContact().getContactId())); //NOI18N
                }
 
                // Init contact instance
-               Contact updatedContact;
+               final Contact updatedContact;
 
                try {
                        // Unlink it and return contact without fax instance
-                       updatedContact = this.adminPhoneBean.unlinkFaxDataFromContact(this.beanHelper.getContact(), this.beanHelper.getFaxNumber());
-               } catch (final PhoneNumberNotLinkedException ex) {
+                       updatedContact = this.adminContactPhoneBean.unlinkFaxDataFromContact(this.getContact(), number);
+               } catch (final PhoneNumberNotLinkedException | ContactNotFoundException ex) {
                        // Did not work
-                       this.showFacesMessage("form_unlink_contact_fax:faxNumberId", ex); //NOI18N
+                       this.showFacesMessage("form_unlink_contact_fax:faxNumberId", ex, FacesMessage.SEVERITY_ERROR); //NOI18N
                        return ""; //NOI18N
                }
 
                // Fire event
-               this.faxNumberUnlinkedEvent.fire(new AdminUnlinkedFaxNumberEvent(updatedContact, this.beanHelper.getFaxNumber()));
+               this.faxNumberUnlinkedEvent.fire(new AdminUnlinkedFaxNumberEvent(updatedContact, number));
 
                // All fine here
                return "admin_show_contact"; //NOI18N
@@ -668,118 +704,137 @@ public class FinancialsAdminContactPhoneWebRequestBean extends BaseFinancialsCon
         * @return Redirect outcome
         */
        public String unlinkLandLineContactData () {
+               // Create fax number instance
+               final DialableLandLineNumber number = this.createLandLineNumber();
+
                // Is all data set
-               if (this.beanHelper.getLandLineNumber() == null) {
+               if (number == null) {
                        // Not set, throw NPE
-                       throw new NullPointerException("this.beanHelper.landLineNumber is null"); //NOI18N
-               } else if (this.beanHelper.getLandLineNumber().getPhoneId() == null) {
+                       throw new NullPointerException("number is null"); //NOI18N
+               } else if (number.getPhoneId() == null) {
                        // Throw NPE again
-                       throw new NullPointerException("this.beanHelper.landLineNumber.phoneId is null"); //NOI18N
-               } else if (this.beanHelper.getLandLineNumber().getPhoneId() < 1) {
+                       throw new NullPointerException("number.phoneId is null"); //NOI18N
+               } else if (number.getPhoneId() < 1) {
                        // Invalid number
-                       throw new IllegalArgumentException(MessageFormat.format("this.beanHelper.landLineNumber.phoneId={0} is not valid", this.beanHelper.getLandLineNumber().getPhoneId())); //NOI18N
-               } else if (this.beanHelper.getLandLineNumber().getPhoneNumber() == null) {
+                       throw new IllegalArgumentException(MessageFormat.format("number.phoneId={0} is not valid", number.getPhoneId())); //NOI18N
+               } else if (number.getPhoneNumber() == null) {
                        // Throw NPE again
-                       throw new NullPointerException("this.beanHelper.landLineNumber.phoneNumber is null"); //NOI18N
-               } else if (this.beanHelper.getLandLineNumber().getPhoneNumber() < 1) {
+                       throw new NullPointerException("number.phoneNumber is null"); //NOI18N
+               } else if (number.getPhoneNumber() < 1) {
                        // Throw it again ...
-                       throw new NullPointerException(MessageFormat.format("this.beanHelper.landLineNumber.phoneNumber={0} is not valid.", this.beanHelper.getLandLineNumber().getPhoneNumber())); //NOI18N
-               } else if (this.beanHelper.getContact() == null) {
+                       throw new NullPointerException(MessageFormat.format("number.phoneNumber={0} is not valid.", number.getPhoneNumber())); //NOI18N
+               } else if (this.getContact() == null) {
                        // ... and throw again
-                       throw new NullPointerException("this.beanHelper.contact is null"); //NOI18N
-               } else if (this.beanHelper.getContact().getContactId() == null) {
+                       throw new NullPointerException("this.contact is null"); //NOI18N
+               } else if (this.getContact().getContactId() == null) {
                        // ... and again ...
-                       throw new NullPointerException("this.beanHelper.contact.contactId is null"); //NOI18N
-               } else if (this.beanHelper.getContact().getContactId() < 1) {
+                       throw new NullPointerException("this.contact.contactId is null"); //NOI18N
+               } else if (this.getContact().getContactId() < 1) {
                        // Invalid id number
-                       throw new IllegalArgumentException(MessageFormat.format("this.beanHelper.contact.contactId={0} is invalid.", this.beanHelper.getContact().getContactId())); //NOI18N
+                       throw new IllegalArgumentException(MessageFormat.format("this.contact.contactId={0} is invalid.", this.getContact().getContactId())); //NOI18N
                }
 
                // Init contact instance
-               Contact updatedContact;
+               final Contact updatedContact;
 
                try {
                        // Unlink it and return contact without landLine instance
-                       updatedContact = this.adminPhoneBean.unlinkLandLineDataFromContact(this.beanHelper.getContact(), this.beanHelper.getLandLineNumber());
-               } catch (final PhoneNumberNotLinkedException ex) {
+                       updatedContact = this.adminContactPhoneBean.unlinkLandLineDataFromContact(this.getContact(), number);
+               } catch (final PhoneNumberNotLinkedException | ContactNotFoundException ex) {
                        // Did not work
-                       this.showFacesMessage("form_unlink_contact_landLine:landLineNumberId", ex); //NOI18N
+                       this.showFacesMessage("form_unlink_contact_landLine:landLineNumberId", ex, FacesMessage.SEVERITY_ERROR); //NOI18N
                        return ""; //NOI18N
                }
 
                // Fire event
-               this.landLineNumberUnlinkedEvent.fire(new AdminUnlinkedLandLineNumberEvent(updatedContact, this.beanHelper.getLandLineNumber()));
+               this.landLineNumberUnlinkedEvent.fire(new AdminUnlinkedLandLineNumberEvent(updatedContact, number));
 
                // All fine here
                return "admin_show_contact"; //NOI18N
        }
 
        /**
-        * Unlinks mobile data with current contact
+        * Clears this bean
+        */
+       private void clear () {
+               // Clear all data
+       }
+
+       /**
+        * Creates an instance of a DialableFaxNumber class
         * <p>
-        * @return Redirect outcome
+        * @return DialableFaxNumber class
         */
-       public String unlinkMobileContactData () {
-               // Is all data set
-               if (this.beanHelper.getMobileNumber() == null) {
-                       // Not set, throw NPE
-                       throw new NullPointerException("this.beanHelper.mobileNumber is null"); //NOI18N
-               } else if (this.beanHelper.getMobileNumber().getPhoneId() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("this.beanHelper.mobileNumber.phoneId is null"); //NOI18N
-               } else if (this.beanHelper.getMobileNumber().getPhoneId() < 1) {
-                       // Invalid number
-                       throw new IllegalArgumentException(MessageFormat.format("this.beanHelper.mobileNumber.phoneId={0} is not valid", this.beanHelper.getMobileNumber().getPhoneId())); //NOI18N
-               } else if (this.beanHelper.getMobileNumber().getMobileProvider() == null) {
-                       // Throw NPE
-                       throw new NullPointerException("this.beanHelper.mobileNumber.mobileProvider is null"); //NOI18N
-               } else if (this.beanHelper.getMobileNumber().getMobileProvider().getProviderId() == null) {
-                       // ... throw again
-                       throw new NullPointerException("this.beanHelper.mobileNumber.mobileProvider.providerId is null"); //NOI18N
-               } else if (this.beanHelper.getMobileNumber().getMobileProvider().getProviderId() < 1) {
-                       // Id not valid
-                       throw new IllegalArgumentException(MessageFormat.format("this.beanHelper.mobileNumber.mobileProvider.providerId={0} is not valid.", this.beanHelper.getMobileNumber().getMobileProvider().getProviderId())); //NOI18N
-               } else if (this.beanHelper.getMobileNumber().getPhoneNumber() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("this.beanHelper.mobileNumber.phoneNumber is null"); //NOI18N
-               } else if (this.beanHelper.getMobileNumber().getPhoneNumber() < 1) {
-                       // Throw it again ...
-                       throw new NullPointerException(MessageFormat.format("this.beanHelper.mobileNumber.phoneNumber={0} is not valid.", this.beanHelper.getMobileNumber().getPhoneNumber())); //NOI18N
-               } else if (this.beanHelper.getContact() == null) {
-                       // ... and throw again
-                       throw new NullPointerException("this.beanHelper.contact is null"); //NOI18N
-               } else if (this.beanHelper.getContact().getContactId() == null) {
-                       // ... and again ...
-                       throw new NullPointerException("this.beanHelper.contact.contactId is null"); //NOI18N
-               } else if (this.beanHelper.getContact().getContactId() < 1) {
-                       // Invalid id number
-                       throw new IllegalArgumentException(MessageFormat.format("this.beanHelper.contact.contactId={0} is invalid.", this.beanHelper.getContact().getContactId())); //NOI18N
-               }
+       private DialableFaxNumber createFaxNumber () {
+               // Instanciate it
+               final DialableFaxNumber number = new FaxNumber(this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());
 
-               // Init contact instance
-               Contact updatedContact;
+               // Set all other fields
+               number.setPhoneEntryCreated(this.getPhoneEntryCreated());
+               number.setPhoneEntryUpdated(this.getPhoneEntryUpdated());
+               number.setPhoneId(this.getPhoneId());
 
-               try {
-                       // Unlink it and return contact without mobile instance
-                       updatedContact = this.adminPhoneBean.unlinkMobileDataFromContact(this.beanHelper.getContact(), this.beanHelper.getMobileNumber());
-               } catch (final PhoneNumberNotLinkedException ex) {
-                       // Did not work
-                       this.showFacesMessage("form_unlink_contact_mobile:mobileNumberId", ex); //NOI18N
-                       return ""; //NOI18N
-               }
+               // Return it
+               return number;
+       }
 
-               // Fire event
-               this.mobileNumberUnlinkedEvent.fire(new AdminUnlinkedMobileNumberEvent(updatedContact, this.beanHelper.getMobileNumber()));
+       /**
+        * Returns an instance of a DialableLandLineNumber from all fields stored in
+        * this bean.
+        * <p>
+        * @return An instance of a DialableLandLineNumber class
+        */
+       private DialableLandLineNumber createLandLineNumber () {
+               // Initialize it
+               final DialableLandLineNumber number = new LandLineNumber(this.getLandLineCountry(), this.getLandLineAreaCode(), this.getLandLineNumber());
 
-               // All fine here
-               return "admin_show_contact"; //NOI18N
+               // Add all other data
+               number.setPhoneEntryCreated(this.getPhoneEntryCreated());
+               number.setPhoneEntryUpdated(this.getPhoneEntryUpdated());
+               number.setPhoneId(this.getPhoneId());
+
+               // Return it
+               return number;
        }
 
        /**
-        * Clears this bean
+        * Getter for phone entry created
+        * <p>
+        * @return Phone entry created
         */
-       private void clear () {
-               // Clear all data
+       @SuppressWarnings ("ReturnOfDateField")
+       private Date getPhoneEntryCreated () {
+               return this.phoneEntryCreated;
+       }
+
+       /**
+        * Setter for phone entry created
+        * <p>
+        * @param phoneEntryCreated Phone entry created
+        */
+       @SuppressWarnings ("AssignmentToDateFieldFromParameter")
+       private void setPhoneEntryCreated (final Date phoneEntryCreated) {
+               this.phoneEntryCreated = phoneEntryCreated;
+       }
+
+       /**
+        * Getter for phone entry updated
+        * <p>
+        * @return Phone entry updated
+        */
+       @SuppressWarnings ("ReturnOfDateField")
+       private Date getPhoneEntryUpdated () {
+               return this.phoneEntryUpdated;
+       }
+
+       /**
+        * Setter for phone entry updated
+        * <p>
+        * @param phoneEntryUpdated Phone entry updated
+        */
+       @SuppressWarnings ("AssignmentToDateFieldFromParameter")
+       private void setPhoneEntryUpdated (final Date phoneEntryUpdated) {
+               this.phoneEntryUpdated = phoneEntryUpdated;
        }
 
 }