]> git.mxchange.org Git - pizzaservice-ejb.git/commitdiff
Please cherry-pick:
authorRoland Häder <roland@mxchange.org>
Sat, 9 Sep 2017 12:18:10 +0000 (14:18 +0200)
committerRoland Häder <roland@mxchange.org>
Sat, 9 Sep 2017 13:39:32 +0000 (15:39 +0200)
- introduced isSameCompanyNameAdded() which encapsulates checking for if a
  company name has already been used. This is, together with the thrown checked
  exception a last effort to prevent bad bad SqlException or any other
  "low-level" exception as they are more severage than this.
- thumb of a rule: always pre-validate if all conditions are met (return "okay")
  prior doing risky things where uncontrolled exceptions may be thrown.
- make company-owner (User), founder (Employee) and contact person (dito)
  managed before persisting the whole BasicData instance as this makes sure that
  no duplicates will end up in database

Signed-off-by: Roland Häder <roland@mxchange.org>
35 files changed:
src/java/org/mxchange/jcontacts/contact/PizzaAdminContactSessionBean.java [deleted file]
src/java/org/mxchange/jcontacts/contact/PizzaContactSessionBean.java [deleted file]
src/java/org/mxchange/jcontacts/model/contact/PizzaAdminContactSessionBean.java [new file with mode: 0644]
src/java/org/mxchange/jcontacts/model/contact/PizzaContactSessionBean.java [new file with mode: 0644]
src/java/org/mxchange/jcontacts/model/phone/PizzaAdminContactPhoneSessionBean.java [new file with mode: 0644]
src/java/org/mxchange/jcontacts/phone/PizzaAdminContactPhoneSessionBean.java [deleted file]
src/java/org/mxchange/jcontactsbusiness/basicdata/PizzaAdminBusinessDataSessionBean.java [deleted file]
src/java/org/mxchange/jcontactsbusiness/basicdata/PizzaBusinessDataSessionBean.java [deleted file]
src/java/org/mxchange/jcontactsbusiness/branchoffice/PizzaAdminBranchOfficeSessionBean.java [deleted file]
src/java/org/mxchange/jcontactsbusiness/branchoffice/PizzaBranchOfficeSessionBean.java [deleted file]
src/java/org/mxchange/jcontactsbusiness/employee/PizzaAdminCompanyEmployeeSessionBean.java [deleted file]
src/java/org/mxchange/jcontactsbusiness/employee/PizzaCompanyEmployeeSessionBean.java [deleted file]
src/java/org/mxchange/jcontactsbusiness/model/basicdata/PizzaAdminBusinessDataSessionBean.java [new file with mode: 0644]
src/java/org/mxchange/jcontactsbusiness/model/basicdata/PizzaBusinessDataSessionBean.java [new file with mode: 0644]
src/java/org/mxchange/jcontactsbusiness/model/branchoffice/PizzaAdminBranchOfficeSessionBean.java [new file with mode: 0644]
src/java/org/mxchange/jcontactsbusiness/model/branchoffice/PizzaBranchOfficeSessionBean.java [new file with mode: 0644]
src/java/org/mxchange/jcontactsbusiness/model/employee/PizzaAdminCompanyEmployeeSessionBean.java [new file with mode: 0644]
src/java/org/mxchange/jcontactsbusiness/model/employee/PizzaCompanyEmployeeSessionBean.java [new file with mode: 0644]
src/java/org/mxchange/jcountry/data/PizzaCountrySingletonBean.java [deleted file]
src/java/org/mxchange/jcountry/model/data/PizzaCountrySingletonBean.java [new file with mode: 0644]
src/java/org/mxchange/jphone/model/phonenumbers/mobileprovider/PizzaAdminMobileProviderSessionBean.java [new file with mode: 0644]
src/java/org/mxchange/jphone/model/phonenumbers/mobileprovider/PizzaMobileProviderSingletonBean.java [new file with mode: 0644]
src/java/org/mxchange/jphone/model/phonenumbers/phone/PizzaAdminPhoneSessionBean.java [new file with mode: 0644]
src/java/org/mxchange/jphone/model/phonenumbers/phone/PizzaPhoneSessionBean.java [new file with mode: 0644]
src/java/org/mxchange/jphone/phonenumbers/mobileprovider/PizzaAdminMobileProviderSessionBean.java [deleted file]
src/java/org/mxchange/jphone/phonenumbers/mobileprovider/PizzaMobileProviderSingletonBean.java [deleted file]
src/java/org/mxchange/jphone/phonenumbers/phone/PizzaAdminPhoneSessionBean.java [deleted file]
src/java/org/mxchange/jphone/phonenumbers/phone/PizzaPhoneSessionBean.java [deleted file]
src/java/org/mxchange/jusercore/model/user/PizzaAdminUserSessionBean.java
src/java/org/mxchange/jusercore/model/user/PizzaUserSessionBean.java
src/java/org/mxchange/jusercore/model/user/activity/PizzaUserActivityLogMessageBean.java
src/java/org/mxchange/jusercore/model/user/email_address/PizzaUserEmailChangeSessionBean.java
src/java/org/mxchange/juserlogincore/model/user/register/PizzaUserRegistrationSessionBean.java
src/java/org/mxchange/pizzaaplication/database/BasePizzaDatabaseBean.java
src/java/org/mxchange/pizzaapplication/model/customer/PizzaAdminCustomerSessionBean.java

diff --git a/src/java/org/mxchange/jcontacts/contact/PizzaAdminContactSessionBean.java b/src/java/org/mxchange/jcontacts/contact/PizzaAdminContactSessionBean.java
deleted file mode 100644 (file)
index fe254f5..0000000
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Copyright (C) 2016, 2017 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jcontacts.contact;
-
-import java.text.MessageFormat;
-import java.util.GregorianCalendar;
-import javax.ejb.Stateless;
-import javax.persistence.NoResultException;
-import javax.persistence.Query;
-import org.mxchange.jcontacts.exceptions.ContactAlreadyAddedException;
-import org.mxchange.jcontacts.exceptions.ContactNotFoundException;
-import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
-
-/**
- * An administrative contact EJB
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Stateless (name = "adminContact", description = "An administrative contact EJB")
-public class PizzaAdminContactSessionBean extends BasePizzaDatabaseBean implements AdminContactSessionBeanRemote {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 542_145_347_916L;
-
-       /**
-        * Default constructor
-        */
-       public PizzaAdminContactSessionBean () {
-               // Call super constructor
-               super();
-       }
-
-       @Override
-       public Contact addContact (final Contact contact) throws ContactAlreadyAddedException {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addContact: contact={1} - CALLED!", this.getClass().getSimpleName(), contact)); //NOI18N
-
-               // Is the instance set?
-               if (null == contact) {
-                       // Throw NPE
-                       throw new NullPointerException("contact is null"); //NOI18N
-               } else if (contact.getContactId() != null) {
-                       // Should be null
-                       throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} - is not null", contact.getContactId())); //NOI18N
-               } else if (this.isContactFound(contact)) {
-                       // Already registered
-                       throw new ContactAlreadyAddedException(contact);
-               }
-
-               // Set created timestamp
-               contact.setContactCreated(new GregorianCalendar());
-
-               // Set all created timestamps, if instance is there
-               this.setAllContactPhoneEntriesCreated(contact);
-
-               // Persist it
-               this.getEntityManager().persist(contact);
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addContact: contact.contactId={1} after persisting - EXIT!", this.getClass().getSimpleName(), contact.getContactId())); //NOI18N
-
-               // Return it
-               return contact;
-       }
-
-       @Override
-       public void deleteContactData (final Contact contact) throws ContactNotFoundException {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.deleteContactData: contact={1} - CALLED!", this.getClass().getSimpleName(), contact)); //NOI18N
-
-               // Is the instance set?
-               if (null == contact) {
-                       // Throw NPE
-                       throw new NullPointerException("contact is null"); //NOI18N
-               } else if (contact.getContactId() == null) {
-                       // Should not be null
-                       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
-               } else if (!this.isContactFound(contact)) {
-                       // Contact not found
-                       throw new ContactNotFoundException(contact.getContactId());
-               }
-
-               // Merge it to get a managed entity back
-               Contact managedContact = this.getEntityManager().getReference(contact.getClass(), contact.getContactId());
-
-               // Remove it from database
-               this.getEntityManager().remove(managedContact);
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.deleteContactData: EXIT!", this.getClass().getSimpleName())); //NOI18N
-       }
-
-       /**
-        * Determines if the given contact is found
-        * <p>
-        * @param contact Contact instance
-        * <p>
-        * @return Whether the contact has been found
-        */
-       private boolean isContactFound (final Contact contact) {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isContactRegistered: contact={1} - CALLED!", this.getClass().getSimpleName(), contact)); //NOI18N
-
-               // Create query
-               Query query = this.getEntityManager().createNamedQuery("SearchContact"); //NOI18N
-
-               // Set parameter
-               query.setParameter("contact", contact); //NOI18N
-               query.setMaxResults(1);
-
-               // Default is not found
-               boolean isFound = false;
-
-               // Try it
-               try {
-                       // Try to find instance
-                       Contact dummy = (Contact) query.getSingleResult();
-
-                       // Mark as found
-                       isFound = true;
-               } catch (final NoResultException e) {
-                       // No result found
-               }
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isContactRegistered: isFound={1} - EXIT!", this.getClass().getSimpleName(), isFound)); //NOI18N
-
-               // Return flag
-               return isFound;
-       }
-
-}
diff --git a/src/java/org/mxchange/jcontacts/contact/PizzaContactSessionBean.java b/src/java/org/mxchange/jcontacts/contact/PizzaContactSessionBean.java
deleted file mode 100644 (file)
index f149355..0000000
+++ /dev/null
@@ -1,330 +0,0 @@
-/*
- * Copyright (C) 2016, 2017 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jcontacts.contact;
-
-import java.text.MessageFormat;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Objects;
-import javax.ejb.Stateless;
-import javax.persistence.NoResultException;
-import javax.persistence.Query;
-import org.mxchange.jcontacts.exceptions.ContactNotFoundException;
-import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
-/**
- * A contact EJB
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Stateless (name = "contact", description = "A bean handling contact data")
-public class PizzaContactSessionBean extends BasePizzaDatabaseBean implements ContactSessionBeanRemote {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 542_145_347_916L;
-
-       /**
-        * Default constructor
-        */
-       public PizzaContactSessionBean () {
-               // Call super constructor
-               super();
-       }
-
-       @Override
-       @SuppressWarnings ("unchecked")
-       public List<Contact> allContacts () {
-               // Log trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getAllContacts - CALLED!", this.getClass().getSimpleName())); //NOI18N
-
-               // Create query instance
-               final Query query = this.getEntityManager().createNamedQuery("AllContacts"); //NOI18N
-
-               // Get list
-               final List<Contact> contacts = query.getResultList();
-
-               // Log trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getAllContacts: contacts.size()={1} - EXIT!", this.getClass().getSimpleName(), contacts.size())); //NOI18N
-
-               // Return it
-               return contacts;
-       }
-
-       @Override
-       @SuppressWarnings ("unchecked")
-       public List<String> allEmailAddresses () {
-               // Log trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getEmailAddressList - CALLED!", this.getClass().getSimpleName())); //NOI18N
-
-               // Create query instance
-               final Query query = this.getEntityManager().createNamedQuery("AllContactEmailAddresses"); //NOI18N
-
-               // Get list
-               final List<String> emailAddresses = query.getResultList();
-
-               // Log trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getEmailAddressList: emailAddresses.size()={1} - EXIT!", this.getClass().getSimpleName(), emailAddresses.size())); //NOI18N
-
-               // Return it
-               return emailAddresses;
-       }
-
-       @Override
-       public Contact findContactByEmailAddress (final String emailAddress) throws ContactNotFoundException {
-               // Log trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findContactByEmailAddress: emailAddress={1} - CALLED!", this.getClass().getSimpleName(), emailAddress)); //NOI18N
-
-               // The parameter must be valid
-               if (null == emailAddress) {
-                       // Throw NPE
-                       throw new NullPointerException("emailAddress is null"); //NOI18N
-               } else if (emailAddress.isEmpty()) {
-                       // Not valid
-                       throw new IllegalArgumentException("emailAddress is empty"); //NOI18N
-               }
-
-               // Get query instance
-               final Query query = this.getEntityManager().createNamedQuery("SearchContactByEmailAddress", UserContact.class); //NOI18N
-
-               // Set parameter and limit
-               query.setParameter("emailAddress", emailAddress); //NOI18N
-               query.setMaxResults(1);
-
-               // Init contact instance
-               final Contact contact;
-
-               // Try to find a result
-               try {
-                       // Find a single result
-                       contact = (Contact) query.getSingleResult();
-
-                       // Log trace message
-                       this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findContactByEmailAddress: Found contact={1}", this.getClass().getSimpleName(), contact)); //NOI18N
-               } catch (final NoResultException ex) {
-                       // No result found
-                       throw new ContactNotFoundException(emailAddress, ex);
-               }
-
-               // Log trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findContactByEmailAddress: contact={1} - EXIT!", this.getClass().getSimpleName(), contact)); //NOI18N
-
-               // Return found instance
-               return contact;
-       }
-
-       @Override
-       public Contact findContactById (final Long contactId) throws ContactNotFoundException {
-               // Log trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findContactById: contactId={1} - CALLED!", this.getClass().getSimpleName(), contactId)); //NOI18N
-
-               // The parameter must be valid
-               if (null == contactId) {
-                       // Throw NPE
-                       throw new NullPointerException("contactId is null"); //NOI18N
-               } else if (contactId < 1) {
-                       // Not valid
-                       throw new IllegalArgumentException(MessageFormat.format("contactId={0} is not valid", contactId)); //NOI18N
-               }
-
-               // Get query instance
-               final Query query = this.getEntityManager().createNamedQuery("SearchContactById", UserContact.class); //NOI18N
-
-               // Set parameter
-               query.setParameter("contactId", contactId); //NOI18N
-               query.setMaxResults(1);
-
-               // Init contact instance
-               final Contact contact;
-
-               // Try to find a result
-               try {
-                       // Find a single result
-                       contact = (Contact) query.getSingleResult();
-
-                       // Log trace message
-                       this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findContactById: Found contact={1}", this.getClass().getSimpleName(), contact)); //NOI18N
-               } catch (final NoResultException ex) {
-                       // No result found
-                       throw new ContactNotFoundException(contactId, ex);
-               }
-
-               // Log trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findContactById: contact={1} - EXIT!", this.getClass().getSimpleName(), contact)); //NOI18N
-
-               // Return found instance
-               return contact;
-       }
-
-       @Override
-       public boolean isEmailAddressRegistered (final String emailAddress) {
-               // Log trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isEmailAddressRegistered: emailAddress={1} - CALLED!", this.getClass().getSimpleName(), emailAddress)); //NOI18N
-
-               // The email address should be valid
-               if (null == emailAddress) {
-                       // Is null
-                       throw new NullPointerException("emailAddress is null"); //NOI18N
-               } else if (emailAddress.isEmpty()) {
-                       // Is empty
-                       throw new IllegalArgumentException("emailAddress is empty"); //NOI18N
-               }
-
-               // Default is not found
-               boolean isFound = false;
-
-               try {
-                       // Ask other method for contact instance
-                       final Contact contact = this.findContactByEmailAddress(emailAddress);
-
-                       // Log debug message
-                       this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.isEmailAddressRegistered: Found contact={1} for emailAddress={2}", this.getClass().getSimpleName(), contact, emailAddress)); //NOI18N
-
-                       // It is found ...
-                       isFound = true;
-               } catch (final ContactNotFoundException ex) {
-                       // @TODO Was not found, log exception for spam check?
-               }
-
-               // Log trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isEmailAddressRegistered: isFound={1} - EXIT!", this.getClass().getSimpleName(), isFound)); //NOI18N
-
-               // Return status
-               return isFound;
-       }
-
-       @Override
-       public Contact lookupContact (final Contact contact) {
-               // Log trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isContactFound: contact={1} - CALLED!", this.getClass().getSimpleName(), contact)); //NOI18N
-
-               // Parameter should be valid
-               if (null == contact) {
-                       // Throw NPE
-                       throw new NullPointerException("contact is null"); //NOI18N
-               } else if ((contact.getContactId() instanceof Long) && (contact.getContactId() > 0)) {
-                       try {
-                               // Id set, ask other method
-                               return this.findContactById(contact.getContactId());
-                       } catch (final ContactNotFoundException ex) {
-                               // Not found, should not happen
-                               throw new IllegalStateException(MessageFormat.format("contact.contactId={0} is set, but not found.", contact.getContactId()), ex); //NOI18N
-                       }
-               }
-
-               // Default is not found
-               Contact foundContact = null;
-
-               // Get whole list
-               final List<Contact> contacts = this.allContacts();
-
-               // Is the list empty?
-               if (contacts.isEmpty()) {
-                       // Then abort here
-                       this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isContactFound: No contacts registered, returning NULL ...", this.getClass().getSimpleName())); //NOI18N
-                       return null;
-               }
-
-               // Get iterator
-               final Iterator<Contact> iterator = contacts.iterator();
-
-               // Loop through all
-               while (iterator.hasNext()) {
-                       // Get contact
-                       Contact next = iterator.next();
-
-                       // Debug message
-                       this.getLoggerBeanLocal().logDebug(MessageFormat.format("lookupContact: next={0}", next)); //NOI18N
-
-                       // Is same contact?
-                       if ((Objects.equals(contact, next)) || (ContactUtils.isSameContact(contact, next))) {
-                               // Debug message
-                               this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.isContactFound: Found same contact: contactId={1}", this.getClass().getSimpleName(), next.getContactId())); //NOI18N
-
-                               // Found it
-                               foundContact = next;
-                               break;
-                       }
-               }
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isContactFound: foundContact={1} - EXIT!", this.getClass().getSimpleName(), foundContact)); //NOI18N
-
-               // Return status
-               return foundContact;
-       }
-
-       @Override
-       public Contact updateContactData (final Contact contact, final boolean isMobileUnlinked, final boolean isLandlineUnlinked, final boolean isFaxUnlinked) {
-               // Log trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateContactData: contact={1},isMobileUnlinked={2},isLandlineUnlinked={3},isFaxUnlinked={4} - CALLED!", this.getClass().getSimpleName(), contact, isMobileUnlinked, isLandlineUnlinked, isFaxUnlinked)); //NOI18N
-
-               // The contact instance must be valid
-               if (null == contact) {
-                       // Throw NPE again
-                       throw new NullPointerException("contact is null"); //NOI18N
-               } else if (contact.getContactId() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("contact.contactId is null"); //NOI18N
-               } else if (contact.getContactId() < 1) {
-                       // Not valid
-                       throw new IllegalStateException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
-               }
-
-               // Merge cellphone, land-line and fix
-               Contact managedContact = this.mergeContactData(contact);
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateContactData: managedContact={1} - EXIT!", this.getClass().getSimpleName(), managedContact)); //NOI18N
-
-               // Return it
-               return managedContact;
-       }
-
-       @Override
-       public Contact updateContactData (final Contact contact) {
-               // Log trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateContactData: contact={1} - CALLED!", this.getClass().getSimpleName(), contact)); //NOI18N
-
-               // The contact instance must be valid
-               if (null == contact) {
-                       // Throw NPE again
-                       throw new NullPointerException("contact is null"); //NOI18N
-               } else if (contact.getContactId() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("contact.contactId is null"); //NOI18N
-               } else if (contact.getContactId() < 1) {
-                       // Not valid
-                       throw new IllegalStateException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
-               }
-
-               // Is cell phone/land-line/fax number unlinked?
-               boolean isMobileUnlinked = (contact.getContactMobileNumber() == null);
-               boolean isLandLineUnlinked = (contact.getContactLandLineNumber() == null);
-               boolean isFaxUnlinked = (contact.getContactFaxNumber() == null);
-
-               // Call other Method
-               Contact managedContact = this.updateContactData(contact, isMobileUnlinked, isLandLineUnlinked, isFaxUnlinked);
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateContactData: managedContact={1} - EXIT!", this.getClass().getSimpleName(), managedContact)); //NOI18N
-
-               // Return it
-               return managedContact;
-       }
-
-}
diff --git a/src/java/org/mxchange/jcontacts/model/contact/PizzaAdminContactSessionBean.java b/src/java/org/mxchange/jcontacts/model/contact/PizzaAdminContactSessionBean.java
new file mode 100644 (file)
index 0000000..1ec9392
--- /dev/null
@@ -0,0 +1,151 @@
+/*
+ * Copyright (C) 2016, 2017 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jcontacts.model.contact;
+
+import java.text.MessageFormat;
+import java.util.GregorianCalendar;
+import javax.ejb.Stateless;
+import javax.persistence.NoResultException;
+import javax.persistence.Query;
+import org.mxchange.jcontacts.exceptions.ContactAlreadyAddedException;
+import org.mxchange.jcontacts.exceptions.ContactNotFoundException;
+import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
+
+/**
+ * An administrative contact EJB
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Stateless (name = "adminContact", description = "An administrative contact EJB")
+public class PizzaAdminContactSessionBean extends BasePizzaDatabaseBean implements AdminContactSessionBeanRemote {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 542_145_347_916L;
+
+       /**
+        * Default constructor
+        */
+       public PizzaAdminContactSessionBean () {
+               // Call super constructor
+               super();
+       }
+
+       @Override
+       public Contact addContact (final Contact contact) throws ContactAlreadyAddedException {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addContact: contact={1} - CALLED!", this.getClass().getSimpleName(), contact)); //NOI18N
+
+               // Is the instance set?
+               if (null == contact) {
+                       // Throw NPE
+                       throw new NullPointerException("contact is null"); //NOI18N
+               } else if (contact.getContactId() != null) {
+                       // Should be null
+                       throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} - is not null", contact.getContactId())); //NOI18N
+               } else if (this.isContactFound(contact)) {
+                       // Already registered
+                       throw new ContactAlreadyAddedException(contact);
+               }
+
+               // Set created timestamp
+               contact.setContactCreated(new GregorianCalendar());
+
+               // Set all created timestamps, if instance is there
+               this.setAllContactPhoneEntriesCreated(contact);
+
+               // Persist it
+               this.getEntityManager().persist(contact);
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addContact: contact.contactId={1} after persisting - EXIT!", this.getClass().getSimpleName(), contact.getContactId())); //NOI18N
+
+               // Return it
+               return contact;
+       }
+
+       @Override
+       public void deleteContactData (final Contact contact) throws ContactNotFoundException {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.deleteContactData: contact={1} - CALLED!", this.getClass().getSimpleName(), contact)); //NOI18N
+
+               // Is the instance set?
+               if (null == contact) {
+                       // Throw NPE
+                       throw new NullPointerException("contact is null"); //NOI18N
+               } else if (contact.getContactId() == null) {
+                       // Should not be null
+                       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
+               } else if (!this.isContactFound(contact)) {
+                       // Contact not found
+                       throw new ContactNotFoundException(contact.getContactId());
+               }
+
+               // Merge it to get a managed entity back
+               Contact managedContact = this.getEntityManager().getReference(contact.getClass(), contact.getContactId());
+
+               // Remove it from database
+               this.getEntityManager().remove(managedContact);
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.deleteContactData: EXIT!", this.getClass().getSimpleName())); //NOI18N
+       }
+
+       /**
+        * Determines if the given contact is found
+        * <p>
+        * @param contact Contact instance
+        * <p>
+        * @return Whether the contact has been found
+        */
+       private boolean isContactFound (final Contact contact) {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isContactRegistered: contact={1} - CALLED!", this.getClass().getSimpleName(), contact)); //NOI18N
+
+               // Create query
+               Query query = this.getEntityManager().createNamedQuery("SearchContact"); //NOI18N
+
+               // Set parameter
+               query.setParameter("contact", contact); //NOI18N
+               query.setMaxResults(1);
+
+               // Default is not found
+               boolean isFound = false;
+
+               // Try it
+               try {
+                       // Try to find instance
+                       Contact dummy = (Contact) query.getSingleResult();
+
+                       // Mark as found
+                       isFound = true;
+               } catch (final NoResultException e) {
+                       // No result found
+               }
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isContactRegistered: isFound={1} - EXIT!", this.getClass().getSimpleName(), isFound)); //NOI18N
+
+               // Return flag
+               return isFound;
+       }
+
+}
diff --git a/src/java/org/mxchange/jcontacts/model/contact/PizzaContactSessionBean.java b/src/java/org/mxchange/jcontacts/model/contact/PizzaContactSessionBean.java
new file mode 100644 (file)
index 0000000..854f43a
--- /dev/null
@@ -0,0 +1,330 @@
+/*
+ * Copyright (C) 2016, 2017 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jcontacts.model.contact;
+
+import java.text.MessageFormat;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Objects;
+import javax.ejb.Stateless;
+import javax.persistence.NoResultException;
+import javax.persistence.Query;
+import org.mxchange.jcontacts.exceptions.ContactNotFoundException;
+import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
+/**
+ * A contact EJB
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Stateless (name = "contact", description = "A bean handling contact data")
+public class PizzaContactSessionBean extends BasePizzaDatabaseBean implements ContactSessionBeanRemote {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 542_145_347_916L;
+
+       /**
+        * Default constructor
+        */
+       public PizzaContactSessionBean () {
+               // Call super constructor
+               super();
+       }
+
+       @Override
+       @SuppressWarnings ("unchecked")
+       public List<Contact> allContacts () {
+               // Log trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getAllContacts - CALLED!", this.getClass().getSimpleName())); //NOI18N
+
+               // Create query instance
+               final Query query = this.getEntityManager().createNamedQuery("AllContacts"); //NOI18N
+
+               // Get list
+               final List<Contact> contacts = query.getResultList();
+
+               // Log trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getAllContacts: contacts.size()={1} - EXIT!", this.getClass().getSimpleName(), contacts.size())); //NOI18N
+
+               // Return it
+               return contacts;
+       }
+
+       @Override
+       @SuppressWarnings ("unchecked")
+       public List<String> allEmailAddresses () {
+               // Log trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getEmailAddressList - CALLED!", this.getClass().getSimpleName())); //NOI18N
+
+               // Create query instance
+               final Query query = this.getEntityManager().createNamedQuery("AllContactEmailAddresses"); //NOI18N
+
+               // Get list
+               final List<String> emailAddresses = query.getResultList();
+
+               // Log trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getEmailAddressList: emailAddresses.size()={1} - EXIT!", this.getClass().getSimpleName(), emailAddresses.size())); //NOI18N
+
+               // Return it
+               return emailAddresses;
+       }
+
+       @Override
+       public Contact findContactByEmailAddress (final String emailAddress) throws ContactNotFoundException {
+               // Log trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findContactByEmailAddress: emailAddress={1} - CALLED!", this.getClass().getSimpleName(), emailAddress)); //NOI18N
+
+               // The parameter must be valid
+               if (null == emailAddress) {
+                       // Throw NPE
+                       throw new NullPointerException("emailAddress is null"); //NOI18N
+               } else if (emailAddress.isEmpty()) {
+                       // Not valid
+                       throw new IllegalArgumentException("emailAddress is empty"); //NOI18N
+               }
+
+               // Get query instance
+               final Query query = this.getEntityManager().createNamedQuery("SearchContactByEmailAddress", UserContact.class); //NOI18N
+
+               // Set parameter and limit
+               query.setParameter("emailAddress", emailAddress); //NOI18N
+               query.setMaxResults(1);
+
+               // Init contact instance
+               final Contact contact;
+
+               // Try to find a result
+               try {
+                       // Find a single result
+                       contact = (Contact) query.getSingleResult();
+
+                       // Log trace message
+                       this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findContactByEmailAddress: Found contact={1}", this.getClass().getSimpleName(), contact)); //NOI18N
+               } catch (final NoResultException ex) {
+                       // No result found
+                       throw new ContactNotFoundException(emailAddress, ex);
+               }
+
+               // Log trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findContactByEmailAddress: contact={1} - EXIT!", this.getClass().getSimpleName(), contact)); //NOI18N
+
+               // Return found instance
+               return contact;
+       }
+
+       @Override
+       public Contact findContactById (final Long contactId) throws ContactNotFoundException {
+               // Log trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findContactById: contactId={1} - CALLED!", this.getClass().getSimpleName(), contactId)); //NOI18N
+
+               // The parameter must be valid
+               if (null == contactId) {
+                       // Throw NPE
+                       throw new NullPointerException("contactId is null"); //NOI18N
+               } else if (contactId < 1) {
+                       // Not valid
+                       throw new IllegalArgumentException(MessageFormat.format("contactId={0} is not valid", contactId)); //NOI18N
+               }
+
+               // Get query instance
+               final Query query = this.getEntityManager().createNamedQuery("SearchContactById", UserContact.class); //NOI18N
+
+               // Set parameter
+               query.setParameter("contactId", contactId); //NOI18N
+               query.setMaxResults(1);
+
+               // Init contact instance
+               final Contact contact;
+
+               // Try to find a result
+               try {
+                       // Find a single result
+                       contact = (Contact) query.getSingleResult();
+
+                       // Log trace message
+                       this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findContactById: Found contact={1}", this.getClass().getSimpleName(), contact)); //NOI18N
+               } catch (final NoResultException ex) {
+                       // No result found
+                       throw new ContactNotFoundException(contactId, ex);
+               }
+
+               // Log trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findContactById: contact={1} - EXIT!", this.getClass().getSimpleName(), contact)); //NOI18N
+
+               // Return found instance
+               return contact;
+       }
+
+       @Override
+       public boolean isEmailAddressRegistered (final String emailAddress) {
+               // Log trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isEmailAddressRegistered: emailAddress={1} - CALLED!", this.getClass().getSimpleName(), emailAddress)); //NOI18N
+
+               // The email address should be valid
+               if (null == emailAddress) {
+                       // Is null
+                       throw new NullPointerException("emailAddress is null"); //NOI18N
+               } else if (emailAddress.isEmpty()) {
+                       // Is empty
+                       throw new IllegalArgumentException("emailAddress is empty"); //NOI18N
+               }
+
+               // Default is not found
+               boolean isFound = false;
+
+               try {
+                       // Ask other method for contact instance
+                       final Contact contact = this.findContactByEmailAddress(emailAddress);
+
+                       // Log debug message
+                       this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.isEmailAddressRegistered: Found contact={1} for emailAddress={2}", this.getClass().getSimpleName(), contact, emailAddress)); //NOI18N
+
+                       // It is found ...
+                       isFound = true;
+               } catch (final ContactNotFoundException ex) {
+                       // @TODO Was not found, log exception for spam check?
+               }
+
+               // Log trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isEmailAddressRegistered: isFound={1} - EXIT!", this.getClass().getSimpleName(), isFound)); //NOI18N
+
+               // Return status
+               return isFound;
+       }
+
+       @Override
+       public Contact lookupContact (final Contact contact) {
+               // Log trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isContactFound: contact={1} - CALLED!", this.getClass().getSimpleName(), contact)); //NOI18N
+
+               // Parameter should be valid
+               if (null == contact) {
+                       // Throw NPE
+                       throw new NullPointerException("contact is null"); //NOI18N
+               } else if ((contact.getContactId() instanceof Long) && (contact.getContactId() > 0)) {
+                       try {
+                               // Id set, ask other method
+                               return this.findContactById(contact.getContactId());
+                       } catch (final ContactNotFoundException ex) {
+                               // Not found, should not happen
+                               throw new IllegalStateException(MessageFormat.format("contact.contactId={0} is set, but not found.", contact.getContactId()), ex); //NOI18N
+                       }
+               }
+
+               // Default is not found
+               Contact foundContact = null;
+
+               // Get whole list
+               final List<Contact> contacts = this.allContacts();
+
+               // Is the list empty?
+               if (contacts.isEmpty()) {
+                       // Then abort here
+                       this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isContactFound: No contacts registered, returning NULL ...", this.getClass().getSimpleName())); //NOI18N
+                       return null;
+               }
+
+               // Get iterator
+               final Iterator<Contact> iterator = contacts.iterator();
+
+               // Loop through all
+               while (iterator.hasNext()) {
+                       // Get contact
+                       Contact next = iterator.next();
+
+                       // Debug message
+                       this.getLoggerBeanLocal().logDebug(MessageFormat.format("lookupContact: next={0}", next)); //NOI18N
+
+                       // Is same contact?
+                       if ((Objects.equals(contact, next)) || (ContactUtils.isSameContact(contact, next))) {
+                               // Debug message
+                               this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.isContactFound: Found same contact: contactId={1}", this.getClass().getSimpleName(), next.getContactId())); //NOI18N
+
+                               // Found it
+                               foundContact = next;
+                               break;
+                       }
+               }
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isContactFound: foundContact={1} - EXIT!", this.getClass().getSimpleName(), foundContact)); //NOI18N
+
+               // Return status
+               return foundContact;
+       }
+
+       @Override
+       public Contact updateContactData (final Contact contact, final boolean isMobileUnlinked, final boolean isLandlineUnlinked, final boolean isFaxUnlinked) {
+               // Log trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateContactData: contact={1},isMobileUnlinked={2},isLandlineUnlinked={3},isFaxUnlinked={4} - CALLED!", this.getClass().getSimpleName(), contact, isMobileUnlinked, isLandlineUnlinked, isFaxUnlinked)); //NOI18N
+
+               // The contact instance must be valid
+               if (null == contact) {
+                       // Throw NPE again
+                       throw new NullPointerException("contact is null"); //NOI18N
+               } else if (contact.getContactId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("contact.contactId is null"); //NOI18N
+               } else if (contact.getContactId() < 1) {
+                       // Not valid
+                       throw new IllegalStateException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
+               }
+
+               // Merge cellphone, land-line and fix
+               Contact managedContact = this.mergeContactData(contact);
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateContactData: managedContact={1} - EXIT!", this.getClass().getSimpleName(), managedContact)); //NOI18N
+
+               // Return it
+               return managedContact;
+       }
+
+       @Override
+       public Contact updateContactData (final Contact contact) {
+               // Log trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateContactData: contact={1} - CALLED!", this.getClass().getSimpleName(), contact)); //NOI18N
+
+               // The contact instance must be valid
+               if (null == contact) {
+                       // Throw NPE again
+                       throw new NullPointerException("contact is null"); //NOI18N
+               } else if (contact.getContactId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("contact.contactId is null"); //NOI18N
+               } else if (contact.getContactId() < 1) {
+                       // Not valid
+                       throw new IllegalStateException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
+               }
+
+               // Is cell phone/land-line/fax number unlinked?
+               boolean isMobileUnlinked = (contact.getContactMobileNumber() == null);
+               boolean isLandLineUnlinked = (contact.getContactLandLineNumber() == null);
+               boolean isFaxUnlinked = (contact.getContactFaxNumber() == null);
+
+               // Call other Method
+               Contact managedContact = this.updateContactData(contact, isMobileUnlinked, isLandLineUnlinked, isFaxUnlinked);
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateContactData: managedContact={1} - EXIT!", this.getClass().getSimpleName(), managedContact)); //NOI18N
+
+               // Return it
+               return managedContact;
+       }
+
+}
diff --git a/src/java/org/mxchange/jcontacts/model/phone/PizzaAdminContactPhoneSessionBean.java b/src/java/org/mxchange/jcontacts/model/phone/PizzaAdminContactPhoneSessionBean.java
new file mode 100644 (file)
index 0000000..bff8e8f
--- /dev/null
@@ -0,0 +1,516 @@
+/*
+ * Copyright (C) 2016, 2017 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jcontacts.model.phone;
+
+import java.text.MessageFormat;
+import java.util.GregorianCalendar;
+import java.util.Objects;
+import javax.ejb.EJB;
+import javax.ejb.Stateless;
+import org.mxchange.jcontacts.model.contact.Contact;
+import org.mxchange.jcontacts.model.contact.ContactSessionBeanRemote;
+import org.mxchange.jphone.exceptions.PhoneNumberAlreadyLinkedException;
+import org.mxchange.jphone.exceptions.PhoneNumberNotLinkedException;
+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.pizzaaplication.database.BasePizzaDatabaseBean;
+
+/**
+ * A session EJB for administrative contact's phone number purposes
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Stateless (name = "adminContactPhone", description = "An administrative bean handling contact's phone (fax, land-line and mobile) data")
+public class PizzaAdminContactPhoneSessionBean extends BasePizzaDatabaseBean implements AdminContactsPhoneSessionBeanRemote {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 189_217_561_460_237_108L;
+
+       /**
+        * Contact EJB
+        */
+       @EJB
+       private ContactSessionBeanRemote contactBean;
+
+       /**
+        * Default constructor
+        */
+       public PizzaAdminContactPhoneSessionBean () {
+               // Call super constructor
+               super();
+       }
+
+       @Override
+       public Contact linkExistingFaxNumberWithContact (final Contact contact, final DialableFaxNumber faxNumber) throws PhoneNumberAlreadyLinkedException {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkExistingFaxNumberWithContact: contact={1},faxNumber={2} - CALLED!", this.getClass().getSimpleName(), contact, faxNumber)); //NOI18N
+
+               // Is the contact set?
+               if (null == contact) {
+                       // Throw NPE
+                       throw new NullPointerException("contact is null"); //NOI18N
+               } else if (contact.getContactId() == null) {
+                       // ... and throw again
+                       throw new NullPointerException("contact.contactId is null"); //NOI18N
+               } else if (contact.getContactId() < 1) {
+                       // Invalid id number
+                       throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
+               } else if (contact.getContactFaxNumber() instanceof DialableFaxNumber) {
+                       // Not set cell phone instance
+                       throw new PhoneNumberAlreadyLinkedException(faxNumber);
+               } else if (null == faxNumber) {
+                       // Throw NPE
+                       throw new NullPointerException("faxNumber is null"); //NOI18N
+               } else if (faxNumber.getPhoneId() == null) {
+                       // Throw it again
+                       throw new NullPointerException("faxNumber.phoneId is null"); //NOI18N
+               } else if (faxNumber.getPhoneId() < 1) {
+                       // Invalid id
+                       throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneId={0} is not valid", faxNumber.getPhoneId())); //NOI18N
+               } else if (faxNumber.getPhoneCountry() == null) {
+                       // ... and again
+                       throw new NullPointerException("faxNumber.phoneCountry is null"); //NOI18N
+               } else if (faxNumber.getPhoneAreaCode() == null) {
+                       // Throw it again
+                       throw new NullPointerException("faxNumber.phoneAreaCode is null"); //NOI18N
+               } else if (faxNumber.getPhoneAreaCode() < 1) {
+                       // Invalid id
+                       throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneAreaCode={0} is not valid", faxNumber.getPhoneAreaCode())); //NOI18N
+               } else if (faxNumber.getPhoneNumber() == null) {
+                       // Throw it again
+                       throw new NullPointerException("faxNumber.phoneNumber is null"); //NOI18N
+               } else if (faxNumber.getPhoneNumber() < 1) {
+                       // Invalid id
+                       throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneNumber={0} is not valid", faxNumber.getPhoneNumber())); //NOI18N
+               }
+
+               // Set fax number in contact
+               contact.setContactFaxNumber(faxNumber);
+
+               // Update database
+               final Contact updatedContact = this.contactBean.updateContactData(contact);
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkExistingFaxNumberWithContact: updatedContact={1} - EXIT!", this.getClass().getSimpleName(), updatedContact)); //NOI18N
+
+               // Return it
+               return updatedContact;
+       }
+
+       @Override
+       public Contact linkExistingLandLineNumberWithContact (final Contact contact, final DialableLandLineNumber landLineNumber) throws PhoneNumberAlreadyLinkedException {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkExistingLandLineNumberWithContact: contact={1},landLineNumber={2} - CALLED!", this.getClass().getSimpleName(), contact, landLineNumber)); //NOI18N
+
+               // Is the contact set?
+               if (null == contact) {
+                       // Throw NPE
+                       throw new NullPointerException("contact is null"); //NOI18N
+               } else if (contact.getContactId() == null) {
+                       // ... and throw again
+                       throw new NullPointerException("contact.contactId is null"); //NOI18N
+               } else if (contact.getContactId() < 1) {
+                       // Invalid id number
+                       throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
+               } else if (contact.getContactLandLineNumber() instanceof DialableLandLineNumber) {
+                       // Not set cell phone instance
+                       throw new PhoneNumberAlreadyLinkedException(landLineNumber);
+               } else if (null == landLineNumber) {
+                       // Throw NPE
+                       throw new NullPointerException("landLineNumber is null"); //NOI18N
+               } else if (landLineNumber.getPhoneId() == null) {
+                       // Throw it again
+                       throw new NullPointerException("landLineNumber.phoneId is null"); //NOI18N
+               } else if (landLineNumber.getPhoneId() < 1) {
+                       // Invalid id
+                       throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneId={0} is not valid", landLineNumber.getPhoneId())); //NOI18N
+               } else if (landLineNumber.getPhoneCountry() == null) {
+                       // ... and again
+                       throw new NullPointerException("landLineNumber.phoneCountry is null"); //NOI18N
+               } else if (landLineNumber.getPhoneAreaCode() == null) {
+                       // Throw it again
+                       throw new NullPointerException("landLineNumber.phoneAreaCode is null"); //NOI18N
+               } else if (landLineNumber.getPhoneAreaCode() < 1) {
+                       // Invalid id
+                       throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneAreaCode={0} is not valid", landLineNumber.getPhoneAreaCode())); //NOI18N
+               } else if (landLineNumber.getPhoneNumber() == null) {
+                       // Throw it again
+                       throw new NullPointerException("landLineNumber.phoneNumber is null"); //NOI18N
+               } else if (landLineNumber.getPhoneNumber() < 1) {
+                       // Invalid id
+                       throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneNumber={0} is not valid", landLineNumber.getPhoneNumber())); //NOI18N
+               }
+
+               // Set land-line number in contact
+               contact.setContactLandLineNumber(landLineNumber);
+
+               // Update database
+               final Contact updatedContact = this.contactBean.updateContactData(contact);
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkExistingLandLineNumberWithContact: updatedContact={1} - EXIT!", this.getClass().getSimpleName(), updatedContact)); //NOI18N
+
+               // Return it
+               return updatedContact;
+       }
+
+       @Override
+       public Contact linkExistingMobileNumberWithContact (final Contact contact, final DialableMobileNumber mobileNumber) throws PhoneNumberAlreadyLinkedException {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkExistingMobileNumberWithContact: contact={1},mobileNumber={2} - CALLED!", this.getClass().getSimpleName(), contact, mobileNumber)); //NOI18N
+
+               // Is the contact set?
+               if (null == contact) {
+                       // Throw NPE
+                       throw new NullPointerException("contact is null"); //NOI18N
+               } else if (contact.getContactId() == null) {
+                       // ... and throw again
+                       throw new NullPointerException("contact.contactId is null"); //NOI18N
+               } else if (contact.getContactId() < 1) {
+                       // Invalid id number
+                       throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
+               } else if (contact.getContactMobileNumber() instanceof DialableMobileNumber) {
+                       // Not set cell phone instance
+                       throw new PhoneNumberAlreadyLinkedException(mobileNumber);
+               } else if (null == mobileNumber) {
+                       // Throw NPE
+                       throw new NullPointerException("mobileNumber is null"); //NOI18N
+               } else if (mobileNumber.getPhoneId() == null) {
+                       // Throw it again
+                       throw new NullPointerException("mobileNumber.phoneId is null"); //NOI18N
+               } else if (mobileNumber.getPhoneId() < 1) {
+                       // Invalid id
+                       throw new IllegalArgumentException(MessageFormat.format("mobileNumber.phoneId={0} is not valid", mobileNumber.getPhoneId())); //NOI18N
+               } else if (mobileNumber.getMobileProvider() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("mobileNumber.mobileProvider is null"); //NOI18N
+               } else if (mobileNumber.getMobileProvider().getProviderId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("mobileNumber.mobileProvider.providerId is null"); //NOI18N
+               } else if (mobileNumber.getMobileProvider().getProviderId() < 1) {
+                       // Throw NPE again
+                       throw new IllegalArgumentException(MessageFormat.format("mobileNumber.mobileProvider.providerId={0} is not valid", mobileNumber.getMobileProvider().getProviderId())); //NOI18N
+               }
+
+               // Set mobile number in contact
+               contact.setContactMobileNumber(mobileNumber);
+
+               // Update database
+               final Contact updatedContact = this.contactBean.updateContactData(contact);
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkExistingMobileNumberWithContact: updatedContact={1} - EXIT!", this.getClass().getSimpleName(), updatedContact)); //NOI18N
+
+               // Return it
+               return updatedContact;
+       }
+
+       @Override
+       public Contact linkNewFaxNumberWithContact (final Contact contact, final DialableFaxNumber faxNumber) throws PhoneNumberAlreadyLinkedException {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkNewFaxNumberWithContact: contact={1},faxNumber={2} - CALLED!", this.getClass().getSimpleName(), contact, faxNumber)); //NOI18N
+
+               // Is the contact set?
+               if (null == contact) {
+                       // Throw NPE
+                       throw new NullPointerException("contact is null"); //NOI18N
+               } else if (contact.getContactId() == null) {
+                       // ... and throw again
+                       throw new NullPointerException("contact.contactId is null"); //NOI18N
+               } else if (contact.getContactId() < 1) {
+                       // Invalid id number
+                       throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
+               } else if (contact.getContactFaxNumber() instanceof DialableFaxNumber) {
+                       // Not set cell phone instance
+                       throw new PhoneNumberAlreadyLinkedException(faxNumber);
+               } else if (null == faxNumber) {
+                       // Throw NPE
+                       throw new NullPointerException("faxNumber is null"); //NOI18N
+               } else if (faxNumber.getPhoneId() instanceof Long) {
+                       // Throw it again
+                       throw new IllegalStateException(MessageFormat.format("faxNumber.phoneId={0} is not null", faxNumber.getPhoneId())); //NOI18N
+               } else if (faxNumber.getPhoneCountry() == null) {
+                       // ... and again
+                       throw new NullPointerException("faxNumber.phoneCountry is null"); //NOI18N
+               } else if (faxNumber.getPhoneAreaCode() == null) {
+                       // Throw it again
+                       throw new NullPointerException("faxNumber.phoneAreaCode is null"); //NOI18N
+               } else if (faxNumber.getPhoneAreaCode() < 1) {
+                       // Invalid id
+                       throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneAreaCode={0} is not valid", faxNumber.getPhoneAreaCode())); //NOI18N
+               } else if (faxNumber.getPhoneNumber() == null) {
+                       // Throw it again
+                       throw new NullPointerException("faxNumber.phoneNumber is null"); //NOI18N
+               } else if (faxNumber.getPhoneNumber() < 1) {
+                       // Invalid id
+                       throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneNumber={0} is not valid", faxNumber.getPhoneNumber())); //NOI18N
+               }
+
+               // Set created instance
+               faxNumber.setPhoneEntryCreated(new GregorianCalendar());
+
+               // Set fax number in contact
+               contact.setContactFaxNumber(faxNumber);
+
+               // Update database
+               final Contact updatedContact = this.contactBean.updateContactData(contact);
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkNewFaxNumberWithContact: updatedContact={1} - EXIT!", this.getClass().getSimpleName(), updatedContact)); //NOI18N
+
+               // Return it
+               return updatedContact;
+       }
+
+       @Override
+       public Contact linkNewLandLineNumberWithContact (final Contact contact, final DialableLandLineNumber landLineNumber) throws PhoneNumberAlreadyLinkedException {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkNewLandLineNumberWithContact: contact={1},landLineNumber={2} - CALLED!", this.getClass().getSimpleName(), contact, landLineNumber)); //NOI18N
+
+               // Is the contact set?
+               if (null == contact) {
+                       // Throw NPE
+                       throw new NullPointerException("contact is null"); //NOI18N
+               } else if (contact.getContactId() == null) {
+                       // ... and throw again
+                       throw new NullPointerException("contact.contactId is null"); //NOI18N
+               } else if (contact.getContactId() < 1) {
+                       // Invalid id number
+                       throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
+               } else if (contact.getContactLandLineNumber() instanceof DialableLandLineNumber) {
+                       // Not set cell phone instance
+                       throw new PhoneNumberAlreadyLinkedException(landLineNumber);
+               } else if (null == landLineNumber) {
+                       // Throw NPE
+                       throw new NullPointerException("landLineNumber is null"); //NOI18N
+               } else if (landLineNumber.getPhoneId() instanceof Long) {
+                       // Throw it again
+                       throw new IllegalStateException(MessageFormat.format("landLineNumber.phoneId={0} is not null", landLineNumber.getPhoneId())); //NOI18N
+               } else if (landLineNumber.getPhoneCountry() == null) {
+                       // ... and again
+                       throw new NullPointerException("landLineNumber.phoneCountry is null"); //NOI18N
+               } else if (landLineNumber.getPhoneAreaCode() == null) {
+                       // Throw it again
+                       throw new NullPointerException("landLineNumber.phoneAreaCode is null"); //NOI18N
+               } else if (landLineNumber.getPhoneAreaCode() < 1) {
+                       // Invalid id
+                       throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneAreaCode={0} is not valid", landLineNumber.getPhoneAreaCode())); //NOI18N
+               } else if (landLineNumber.getPhoneNumber() == null) {
+                       // Throw it again
+                       throw new NullPointerException("landLineNumber.phoneNumber is null"); //NOI18N
+               } else if (landLineNumber.getPhoneNumber() < 1) {
+                       // Invalid id
+                       throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneNumber={0} is not valid", landLineNumber.getPhoneNumber())); //NOI18N
+               }
+
+               // Set created instance
+               landLineNumber.setPhoneEntryCreated(new GregorianCalendar());
+
+               // Set landLine number in contact
+               contact.setContactLandLineNumber(landLineNumber);
+
+               // Update database
+               final Contact updatedContact = this.contactBean.updateContactData(contact);
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkNewLandLineNumberWithContact: updatedContact={1} - EXIT!", this.getClass().getSimpleName(), updatedContact)); //NOI18N
+
+               // Return it
+               return updatedContact;
+       }
+
+       @Override
+       public Contact linkNewMobileNumberWithContact (final Contact contact, final DialableMobileNumber mobileNumber) throws PhoneNumberAlreadyLinkedException {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkNewMobileNumberWithContact: contact={1},mobileNumber={2} - CALLED!", this.getClass().getSimpleName(), contact, mobileNumber)); //NOI18N
+
+               // Is the contact set?
+               if (null == contact) {
+                       // Throw NPE
+                       throw new NullPointerException("contact is null"); //NOI18N
+               } else if (contact.getContactId() == null) {
+                       // ... and throw again
+                       throw new NullPointerException("contact.contactId is null"); //NOI18N
+               } else if (contact.getContactId() < 1) {
+                       // Invalid id number
+                       throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
+               } else if (contact.getContactMobileNumber() instanceof DialableMobileNumber) {
+                       // Not set cell phone instance
+                       throw new PhoneNumberAlreadyLinkedException(mobileNumber);
+               } else if (null == mobileNumber) {
+                       // Throw NPE
+                       throw new NullPointerException("mobileNumber is null"); //NOI18N
+               } else if (mobileNumber.getPhoneId() instanceof Long) {
+                       // Throw it again
+                       throw new IllegalStateException(MessageFormat.format("mobileNumber.phoneId={0} is not null", mobileNumber.getPhoneId())); //NOI18N
+               } else if (mobileNumber.getMobileProvider() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("mobileNumber.mobileProvider is null"); //NOI18N
+               } else if (mobileNumber.getMobileProvider().getProviderId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("mobileNumber.mobileProvider.providerId is null"); //NOI18N
+               } else if (mobileNumber.getMobileProvider().getProviderId() < 1) {
+                       // Throw NPE again
+                       throw new IllegalArgumentException(MessageFormat.format("mobileNumber.mobileProvider.providerId={0} is not valid", mobileNumber.getMobileProvider().getProviderId())); //NOI18N
+               }
+
+               // Set created instance
+               mobileNumber.setPhoneEntryCreated(new GregorianCalendar());
+
+               // Set mobile number in contact
+               contact.setContactMobileNumber(mobileNumber);
+
+               // Update database
+               final Contact updatedContact = this.contactBean.updateContactData(contact);
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkNewMobileNumberWithContact: updatedContact={1} - EXIT!", this.getClass().getSimpleName(), updatedContact)); //NOI18N
+
+               // Return it
+               return updatedContact;
+       }
+
+       @Override
+       public Contact unlinkFaxDataFromContact (final Contact contact, final DialableFaxNumber faxNumber) throws PhoneNumberNotLinkedException {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.unlinkFaxDataFromContact: contact={1},faxNumber={2} - CALLED!", this.getClass().getSimpleName(), contact, faxNumber)); //NOI18N
+
+               // Is the contact set?
+               if (null == contact) {
+                       // Throw NPE
+                       throw new NullPointerException("contact is null"); //NOI18N
+               } else if (contact.getContactId() == null) {
+                       // ... and throw again
+                       throw new NullPointerException("contact.contactId is null"); //NOI18N
+               } else if (contact.getContactId() < 1) {
+                       // Invalid id number
+                       throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
+               } else if (contact.getContactFaxNumber() == null) {
+                       // Not set cell phone instance
+                       throw new PhoneNumberNotLinkedException(faxNumber);
+               } else if (contact.getContactFaxNumber().getPhoneId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("contact.contactFaxNumber.phoneId is null"); //NOI18N
+               } else if (contact.getContactFaxNumber().getPhoneId() < 1) {
+                       // Invalid id number
+                       throw new IllegalArgumentException(MessageFormat.format("contact.contactFaxNumber.phoneId={0} is invalid.", contact.getContactFaxNumber().getPhoneId())); //NOI18N
+               } else if (!Objects.equals(faxNumber.getPhoneId(), contact.getContactFaxNumber().getPhoneId())) {
+                       // Not same object
+                       throw new IllegalArgumentException(MessageFormat.format("contact.contactFaxNumber.phoneId={0} and faxNumber.phoneId={1} are not the same.", contact.getContactFaxNumber().getPhoneId(), faxNumber.getPhoneId())); //NOI18N
+               }
+
+               // Remove it from contact
+               contact.setContactFaxNumber(null);
+
+               // Update database
+               final Contact updatedContact = this.contactBean.updateContactData(contact);
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.unlinkFaxDataFromContact: updatedContact={1} - EXIT!", this.getClass().getSimpleName(), updatedContact)); //NOI18N
+
+               // Return it
+               return updatedContact;
+       }
+
+       @Override
+       public Contact unlinkLandLineDataFromContact (final Contact contact, final DialableLandLineNumber landLineNumber) throws PhoneNumberNotLinkedException {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.unlinkLandLineDataFromContact: contact={1},landLineNumber={2} - CALLED!", this.getClass().getSimpleName(), contact, landLineNumber)); //NOI18N
+
+               // Is the contact set?
+               if (null == contact) {
+                       // Throw NPE
+                       throw new NullPointerException("contact is null"); //NOI18N
+               } else if (contact.getContactId() == null) {
+                       // ... and throw again
+                       throw new NullPointerException("contact.contactId is null"); //NOI18N
+               } else if (contact.getContactId() < 1) {
+                       // Invalid id number
+                       throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
+               } else if (contact.getContactLandLineNumber() == null) {
+                       // Not set cell phone instance
+                       throw new PhoneNumberNotLinkedException(landLineNumber);
+               } else if (contact.getContactLandLineNumber().getPhoneId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("contact.contactLandLineNumber.phoneId is null"); //NOI18N
+               } else if (contact.getContactLandLineNumber().getPhoneId() < 1) {
+                       // Invalid id number
+                       throw new IllegalArgumentException(MessageFormat.format("contact.contactLandLineNumber.phoneId={0} is invalid.", contact.getContactLandLineNumber().getPhoneId())); //NOI18N
+               } else if (!Objects.equals(landLineNumber.getPhoneId(), contact.getContactLandLineNumber().getPhoneId())) {
+                       // Not same object
+                       throw new IllegalArgumentException(MessageFormat.format("contact.contactLandLineNumber.phoneId={0} and landLineNumber.phoneId={1} are not the same.", contact.getContactLandLineNumber().getPhoneId(), landLineNumber.getPhoneId())); //NOI18N
+               }
+
+               // Remove it from contact
+               contact.setContactLandLineNumber(null);
+
+               // Update database
+               final Contact updatedContact = this.contactBean.updateContactData(contact);
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.unlinkLandLineDataFromContact: updatedContact={1} - EXIT!", this.getClass().getSimpleName(), updatedContact)); //NOI18N
+
+               // Return it
+               return updatedContact;
+       }
+
+       @Override
+       public Contact unlinkMobileDataFromContact (final Contact contact, final DialableMobileNumber mobileNumber) throws PhoneNumberNotLinkedException {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.unlinkMobileDataFromContact: contact={1},mobileNumber={2} - CALLED!", this.getClass().getSimpleName(), contact, mobileNumber)); //NOI18N
+
+               // Is the contact set?
+               if (null == contact) {
+                       // Throw NPE
+                       throw new NullPointerException("contact is null"); //NOI18N
+               } else if (contact.getContactId() == null) {
+                       // ... and throw again
+                       throw new NullPointerException("contact.contactId is null"); //NOI18N
+               } else if (contact.getContactId() < 1) {
+                       // Invalid id number
+                       throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
+               } else if (contact.getContactMobileNumber() == null) {
+                       // Not set cell phone instance
+                       throw new PhoneNumberNotLinkedException(mobileNumber);
+               } else if (contact.getContactMobileNumber().getPhoneId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("contact.contactMobileNumber.phoneId is null"); //NOI18N
+               } else if (contact.getContactMobileNumber().getPhoneId() < 1) {
+                       // Invalid id number
+                       throw new IllegalArgumentException(MessageFormat.format("contact.contactMobileNumber.phoneId={0} is invalid.", contact.getContactMobileNumber().getPhoneId())); //NOI18N
+               } else if (!Objects.equals(mobileNumber.getPhoneId(), contact.getContactMobileNumber().getPhoneId())) {
+                       // Not same object
+                       throw new IllegalArgumentException(MessageFormat.format("contact.contactMobileNumber.phoneId={0} and mobileNumber.phoneId={1} are not the same.", contact.getContactMobileNumber().getPhoneId(), mobileNumber.getPhoneId())); //NOI18N
+               }
+
+               // Remove it from contact
+               contact.setContactMobileNumber(null);
+
+               // Update database
+               final Contact updatedContact = this.contactBean.updateContactData(contact);
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.unlinkMobileDataFromContact: updatedContact={1} - EXIT!", this.getClass().getSimpleName(), updatedContact)); //NOI18N
+
+               // Return it
+               return updatedContact;
+       }
+
+}
diff --git a/src/java/org/mxchange/jcontacts/phone/PizzaAdminContactPhoneSessionBean.java b/src/java/org/mxchange/jcontacts/phone/PizzaAdminContactPhoneSessionBean.java
deleted file mode 100644 (file)
index 0aa00fe..0000000
+++ /dev/null
@@ -1,516 +0,0 @@
-/*
- * Copyright (C) 2016, 2017 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jcontacts.phone;
-
-import java.text.MessageFormat;
-import java.util.GregorianCalendar;
-import java.util.Objects;
-import javax.ejb.EJB;
-import javax.ejb.Stateless;
-import org.mxchange.jcontacts.contact.Contact;
-import org.mxchange.jcontacts.contact.ContactSessionBeanRemote;
-import org.mxchange.jphone.exceptions.PhoneNumberAlreadyLinkedException;
-import org.mxchange.jphone.exceptions.PhoneNumberNotLinkedException;
-import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
-import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
-import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
-import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
-
-/**
- * A session EJB for administrative contact's phone number purposes
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Stateless (name = "adminContactPhone", description = "An administrative bean handling contact's phone (fax, land-line and mobile) data")
-public class PizzaAdminContactPhoneSessionBean extends BasePizzaDatabaseBean implements AdminContactsPhoneSessionBeanRemote {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 189_217_561_460_237_108L;
-
-       /**
-        * Contact EJB
-        */
-       @EJB
-       private ContactSessionBeanRemote contactBean;
-
-       /**
-        * Default constructor
-        */
-       public PizzaAdminContactPhoneSessionBean () {
-               // Call super constructor
-               super();
-       }
-
-       @Override
-       public Contact linkExistingFaxNumberWithContact (final Contact contact, final DialableFaxNumber faxNumber) throws PhoneNumberAlreadyLinkedException {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkExistingFaxNumberWithContact: contact={1},faxNumber={2} - CALLED!", this.getClass().getSimpleName(), contact, faxNumber)); //NOI18N
-
-               // Is the contact set?
-               if (null == contact) {
-                       // Throw NPE
-                       throw new NullPointerException("contact is null"); //NOI18N
-               } else if (contact.getContactId() == null) {
-                       // ... and throw again
-                       throw new NullPointerException("contact.contactId is null"); //NOI18N
-               } else if (contact.getContactId() < 1) {
-                       // Invalid id number
-                       throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
-               } else if (contact.getContactFaxNumber() instanceof DialableFaxNumber) {
-                       // Not set cell phone instance
-                       throw new PhoneNumberAlreadyLinkedException(faxNumber);
-               } else if (null == faxNumber) {
-                       // Throw NPE
-                       throw new NullPointerException("faxNumber is null"); //NOI18N
-               } else if (faxNumber.getPhoneId() == null) {
-                       // Throw it again
-                       throw new NullPointerException("faxNumber.phoneId is null"); //NOI18N
-               } else if (faxNumber.getPhoneId() < 1) {
-                       // Invalid id
-                       throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneId={0} is not valid", faxNumber.getPhoneId())); //NOI18N
-               } else if (faxNumber.getPhoneCountry() == null) {
-                       // ... and again
-                       throw new NullPointerException("faxNumber.phoneCountry is null"); //NOI18N
-               } else if (faxNumber.getPhoneAreaCode() == null) {
-                       // Throw it again
-                       throw new NullPointerException("faxNumber.phoneAreaCode is null"); //NOI18N
-               } else if (faxNumber.getPhoneAreaCode() < 1) {
-                       // Invalid id
-                       throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneAreaCode={0} is not valid", faxNumber.getPhoneAreaCode())); //NOI18N
-               } else if (faxNumber.getPhoneNumber() == null) {
-                       // Throw it again
-                       throw new NullPointerException("faxNumber.phoneNumber is null"); //NOI18N
-               } else if (faxNumber.getPhoneNumber() < 1) {
-                       // Invalid id
-                       throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneNumber={0} is not valid", faxNumber.getPhoneNumber())); //NOI18N
-               }
-
-               // Set fax number in contact
-               contact.setContactFaxNumber(faxNumber);
-
-               // Update database
-               final Contact updatedContact = this.contactBean.updateContactData(contact);
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkExistingFaxNumberWithContact: updatedContact={1} - EXIT!", this.getClass().getSimpleName(), updatedContact)); //NOI18N
-
-               // Return it
-               return updatedContact;
-       }
-
-       @Override
-       public Contact linkExistingLandLineNumberWithContact (final Contact contact, final DialableLandLineNumber landLineNumber) throws PhoneNumberAlreadyLinkedException {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkExistingLandLineNumberWithContact: contact={1},landLineNumber={2} - CALLED!", this.getClass().getSimpleName(), contact, landLineNumber)); //NOI18N
-
-               // Is the contact set?
-               if (null == contact) {
-                       // Throw NPE
-                       throw new NullPointerException("contact is null"); //NOI18N
-               } else if (contact.getContactId() == null) {
-                       // ... and throw again
-                       throw new NullPointerException("contact.contactId is null"); //NOI18N
-               } else if (contact.getContactId() < 1) {
-                       // Invalid id number
-                       throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
-               } else if (contact.getContactLandLineNumber() instanceof DialableLandLineNumber) {
-                       // Not set cell phone instance
-                       throw new PhoneNumberAlreadyLinkedException(landLineNumber);
-               } else if (null == landLineNumber) {
-                       // Throw NPE
-                       throw new NullPointerException("landLineNumber is null"); //NOI18N
-               } else if (landLineNumber.getPhoneId() == null) {
-                       // Throw it again
-                       throw new NullPointerException("landLineNumber.phoneId is null"); //NOI18N
-               } else if (landLineNumber.getPhoneId() < 1) {
-                       // Invalid id
-                       throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneId={0} is not valid", landLineNumber.getPhoneId())); //NOI18N
-               } else if (landLineNumber.getPhoneCountry() == null) {
-                       // ... and again
-                       throw new NullPointerException("landLineNumber.phoneCountry is null"); //NOI18N
-               } else if (landLineNumber.getPhoneAreaCode() == null) {
-                       // Throw it again
-                       throw new NullPointerException("landLineNumber.phoneAreaCode is null"); //NOI18N
-               } else if (landLineNumber.getPhoneAreaCode() < 1) {
-                       // Invalid id
-                       throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneAreaCode={0} is not valid", landLineNumber.getPhoneAreaCode())); //NOI18N
-               } else if (landLineNumber.getPhoneNumber() == null) {
-                       // Throw it again
-                       throw new NullPointerException("landLineNumber.phoneNumber is null"); //NOI18N
-               } else if (landLineNumber.getPhoneNumber() < 1) {
-                       // Invalid id
-                       throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneNumber={0} is not valid", landLineNumber.getPhoneNumber())); //NOI18N
-               }
-
-               // Set land-line number in contact
-               contact.setContactLandLineNumber(landLineNumber);
-
-               // Update database
-               final Contact updatedContact = this.contactBean.updateContactData(contact);
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkExistingLandLineNumberWithContact: updatedContact={1} - EXIT!", this.getClass().getSimpleName(), updatedContact)); //NOI18N
-
-               // Return it
-               return updatedContact;
-       }
-
-       @Override
-       public Contact linkExistingMobileNumberWithContact (final Contact contact, final DialableMobileNumber mobileNumber) throws PhoneNumberAlreadyLinkedException {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkExistingMobileNumberWithContact: contact={1},mobileNumber={2} - CALLED!", this.getClass().getSimpleName(), contact, mobileNumber)); //NOI18N
-
-               // Is the contact set?
-               if (null == contact) {
-                       // Throw NPE
-                       throw new NullPointerException("contact is null"); //NOI18N
-               } else if (contact.getContactId() == null) {
-                       // ... and throw again
-                       throw new NullPointerException("contact.contactId is null"); //NOI18N
-               } else if (contact.getContactId() < 1) {
-                       // Invalid id number
-                       throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
-               } else if (contact.getContactMobileNumber() instanceof DialableMobileNumber) {
-                       // Not set cell phone instance
-                       throw new PhoneNumberAlreadyLinkedException(mobileNumber);
-               } else if (null == mobileNumber) {
-                       // Throw NPE
-                       throw new NullPointerException("mobileNumber is null"); //NOI18N
-               } else if (mobileNumber.getPhoneId() == null) {
-                       // Throw it again
-                       throw new NullPointerException("mobileNumber.phoneId is null"); //NOI18N
-               } else if (mobileNumber.getPhoneId() < 1) {
-                       // Invalid id
-                       throw new IllegalArgumentException(MessageFormat.format("mobileNumber.phoneId={0} is not valid", mobileNumber.getPhoneId())); //NOI18N
-               } else if (mobileNumber.getMobileProvider() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("mobileNumber.mobileProvider is null"); //NOI18N
-               } else if (mobileNumber.getMobileProvider().getProviderId() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("mobileNumber.mobileProvider.providerId is null"); //NOI18N
-               } else if (mobileNumber.getMobileProvider().getProviderId() < 1) {
-                       // Throw NPE again
-                       throw new IllegalArgumentException(MessageFormat.format("mobileNumber.mobileProvider.providerId={0} is not valid", mobileNumber.getMobileProvider().getProviderId())); //NOI18N
-               }
-
-               // Set mobile number in contact
-               contact.setContactMobileNumber(mobileNumber);
-
-               // Update database
-               final Contact updatedContact = this.contactBean.updateContactData(contact);
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkExistingMobileNumberWithContact: updatedContact={1} - EXIT!", this.getClass().getSimpleName(), updatedContact)); //NOI18N
-
-               // Return it
-               return updatedContact;
-       }
-
-       @Override
-       public Contact linkNewFaxNumberWithContact (final Contact contact, final DialableFaxNumber faxNumber) throws PhoneNumberAlreadyLinkedException {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkNewFaxNumberWithContact: contact={1},faxNumber={2} - CALLED!", this.getClass().getSimpleName(), contact, faxNumber)); //NOI18N
-
-               // Is the contact set?
-               if (null == contact) {
-                       // Throw NPE
-                       throw new NullPointerException("contact is null"); //NOI18N
-               } else if (contact.getContactId() == null) {
-                       // ... and throw again
-                       throw new NullPointerException("contact.contactId is null"); //NOI18N
-               } else if (contact.getContactId() < 1) {
-                       // Invalid id number
-                       throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
-               } else if (contact.getContactFaxNumber() instanceof DialableFaxNumber) {
-                       // Not set cell phone instance
-                       throw new PhoneNumberAlreadyLinkedException(faxNumber);
-               } else if (null == faxNumber) {
-                       // Throw NPE
-                       throw new NullPointerException("faxNumber is null"); //NOI18N
-               } else if (faxNumber.getPhoneId() instanceof Long) {
-                       // Throw it again
-                       throw new IllegalStateException(MessageFormat.format("faxNumber.phoneId={0} is not null", faxNumber.getPhoneId())); //NOI18N
-               } else if (faxNumber.getPhoneCountry() == null) {
-                       // ... and again
-                       throw new NullPointerException("faxNumber.phoneCountry is null"); //NOI18N
-               } else if (faxNumber.getPhoneAreaCode() == null) {
-                       // Throw it again
-                       throw new NullPointerException("faxNumber.phoneAreaCode is null"); //NOI18N
-               } else if (faxNumber.getPhoneAreaCode() < 1) {
-                       // Invalid id
-                       throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneAreaCode={0} is not valid", faxNumber.getPhoneAreaCode())); //NOI18N
-               } else if (faxNumber.getPhoneNumber() == null) {
-                       // Throw it again
-                       throw new NullPointerException("faxNumber.phoneNumber is null"); //NOI18N
-               } else if (faxNumber.getPhoneNumber() < 1) {
-                       // Invalid id
-                       throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneNumber={0} is not valid", faxNumber.getPhoneNumber())); //NOI18N
-               }
-
-               // Set created instance
-               faxNumber.setPhoneEntryCreated(new GregorianCalendar());
-
-               // Set fax number in contact
-               contact.setContactFaxNumber(faxNumber);
-
-               // Update database
-               final Contact updatedContact = this.contactBean.updateContactData(contact);
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkNewFaxNumberWithContact: updatedContact={1} - EXIT!", this.getClass().getSimpleName(), updatedContact)); //NOI18N
-
-               // Return it
-               return updatedContact;
-       }
-
-       @Override
-       public Contact linkNewLandLineNumberWithContact (final Contact contact, final DialableLandLineNumber landLineNumber) throws PhoneNumberAlreadyLinkedException {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkNewLandLineNumberWithContact: contact={1},landLineNumber={2} - CALLED!", this.getClass().getSimpleName(), contact, landLineNumber)); //NOI18N
-
-               // Is the contact set?
-               if (null == contact) {
-                       // Throw NPE
-                       throw new NullPointerException("contact is null"); //NOI18N
-               } else if (contact.getContactId() == null) {
-                       // ... and throw again
-                       throw new NullPointerException("contact.contactId is null"); //NOI18N
-               } else if (contact.getContactId() < 1) {
-                       // Invalid id number
-                       throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
-               } else if (contact.getContactLandLineNumber() instanceof DialableLandLineNumber) {
-                       // Not set cell phone instance
-                       throw new PhoneNumberAlreadyLinkedException(landLineNumber);
-               } else if (null == landLineNumber) {
-                       // Throw NPE
-                       throw new NullPointerException("landLineNumber is null"); //NOI18N
-               } else if (landLineNumber.getPhoneId() instanceof Long) {
-                       // Throw it again
-                       throw new IllegalStateException(MessageFormat.format("landLineNumber.phoneId={0} is not null", landLineNumber.getPhoneId())); //NOI18N
-               } else if (landLineNumber.getPhoneCountry() == null) {
-                       // ... and again
-                       throw new NullPointerException("landLineNumber.phoneCountry is null"); //NOI18N
-               } else if (landLineNumber.getPhoneAreaCode() == null) {
-                       // Throw it again
-                       throw new NullPointerException("landLineNumber.phoneAreaCode is null"); //NOI18N
-               } else if (landLineNumber.getPhoneAreaCode() < 1) {
-                       // Invalid id
-                       throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneAreaCode={0} is not valid", landLineNumber.getPhoneAreaCode())); //NOI18N
-               } else if (landLineNumber.getPhoneNumber() == null) {
-                       // Throw it again
-                       throw new NullPointerException("landLineNumber.phoneNumber is null"); //NOI18N
-               } else if (landLineNumber.getPhoneNumber() < 1) {
-                       // Invalid id
-                       throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneNumber={0} is not valid", landLineNumber.getPhoneNumber())); //NOI18N
-               }
-
-               // Set created instance
-               landLineNumber.setPhoneEntryCreated(new GregorianCalendar());
-
-               // Set landLine number in contact
-               contact.setContactLandLineNumber(landLineNumber);
-
-               // Update database
-               final Contact updatedContact = this.contactBean.updateContactData(contact);
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkNewLandLineNumberWithContact: updatedContact={1} - EXIT!", this.getClass().getSimpleName(), updatedContact)); //NOI18N
-
-               // Return it
-               return updatedContact;
-       }
-
-       @Override
-       public Contact linkNewMobileNumberWithContact (final Contact contact, final DialableMobileNumber mobileNumber) throws PhoneNumberAlreadyLinkedException {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkNewMobileNumberWithContact: contact={1},mobileNumber={2} - CALLED!", this.getClass().getSimpleName(), contact, mobileNumber)); //NOI18N
-
-               // Is the contact set?
-               if (null == contact) {
-                       // Throw NPE
-                       throw new NullPointerException("contact is null"); //NOI18N
-               } else if (contact.getContactId() == null) {
-                       // ... and throw again
-                       throw new NullPointerException("contact.contactId is null"); //NOI18N
-               } else if (contact.getContactId() < 1) {
-                       // Invalid id number
-                       throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
-               } else if (contact.getContactMobileNumber() instanceof DialableMobileNumber) {
-                       // Not set cell phone instance
-                       throw new PhoneNumberAlreadyLinkedException(mobileNumber);
-               } else if (null == mobileNumber) {
-                       // Throw NPE
-                       throw new NullPointerException("mobileNumber is null"); //NOI18N
-               } else if (mobileNumber.getPhoneId() instanceof Long) {
-                       // Throw it again
-                       throw new IllegalStateException(MessageFormat.format("mobileNumber.phoneId={0} is not null", mobileNumber.getPhoneId())); //NOI18N
-               } else if (mobileNumber.getMobileProvider() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("mobileNumber.mobileProvider is null"); //NOI18N
-               } else if (mobileNumber.getMobileProvider().getProviderId() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("mobileNumber.mobileProvider.providerId is null"); //NOI18N
-               } else if (mobileNumber.getMobileProvider().getProviderId() < 1) {
-                       // Throw NPE again
-                       throw new IllegalArgumentException(MessageFormat.format("mobileNumber.mobileProvider.providerId={0} is not valid", mobileNumber.getMobileProvider().getProviderId())); //NOI18N
-               }
-
-               // Set created instance
-               mobileNumber.setPhoneEntryCreated(new GregorianCalendar());
-
-               // Set mobile number in contact
-               contact.setContactMobileNumber(mobileNumber);
-
-               // Update database
-               final Contact updatedContact = this.contactBean.updateContactData(contact);
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkNewMobileNumberWithContact: updatedContact={1} - EXIT!", this.getClass().getSimpleName(), updatedContact)); //NOI18N
-
-               // Return it
-               return updatedContact;
-       }
-
-       @Override
-       public Contact unlinkFaxDataFromContact (final Contact contact, final DialableFaxNumber faxNumber) throws PhoneNumberNotLinkedException {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.unlinkFaxDataFromContact: contact={1},faxNumber={2} - CALLED!", this.getClass().getSimpleName(), contact, faxNumber)); //NOI18N
-
-               // Is the contact set?
-               if (null == contact) {
-                       // Throw NPE
-                       throw new NullPointerException("contact is null"); //NOI18N
-               } else if (contact.getContactId() == null) {
-                       // ... and throw again
-                       throw new NullPointerException("contact.contactId is null"); //NOI18N
-               } else if (contact.getContactId() < 1) {
-                       // Invalid id number
-                       throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
-               } else if (contact.getContactFaxNumber() == null) {
-                       // Not set cell phone instance
-                       throw new PhoneNumberNotLinkedException(faxNumber);
-               } else if (contact.getContactFaxNumber().getPhoneId() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("contact.contactFaxNumber.phoneId is null"); //NOI18N
-               } else if (contact.getContactFaxNumber().getPhoneId() < 1) {
-                       // Invalid id number
-                       throw new IllegalArgumentException(MessageFormat.format("contact.contactFaxNumber.phoneId={0} is invalid.", contact.getContactFaxNumber().getPhoneId())); //NOI18N
-               } else if (!Objects.equals(faxNumber.getPhoneId(), contact.getContactFaxNumber().getPhoneId())) {
-                       // Not same object
-                       throw new IllegalArgumentException(MessageFormat.format("contact.contactFaxNumber.phoneId={0} and faxNumber.phoneId={1} are not the same.", contact.getContactFaxNumber().getPhoneId(), faxNumber.getPhoneId())); //NOI18N
-               }
-
-               // Remove it from contact
-               contact.setContactFaxNumber(null);
-
-               // Update database
-               final Contact updatedContact = this.contactBean.updateContactData(contact);
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.unlinkFaxDataFromContact: updatedContact={1} - EXIT!", this.getClass().getSimpleName(), updatedContact)); //NOI18N
-
-               // Return it
-               return updatedContact;
-       }
-
-       @Override
-       public Contact unlinkLandLineDataFromContact (final Contact contact, final DialableLandLineNumber landLineNumber) throws PhoneNumberNotLinkedException {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.unlinkLandLineDataFromContact: contact={1},landLineNumber={2} - CALLED!", this.getClass().getSimpleName(), contact, landLineNumber)); //NOI18N
-
-               // Is the contact set?
-               if (null == contact) {
-                       // Throw NPE
-                       throw new NullPointerException("contact is null"); //NOI18N
-               } else if (contact.getContactId() == null) {
-                       // ... and throw again
-                       throw new NullPointerException("contact.contactId is null"); //NOI18N
-               } else if (contact.getContactId() < 1) {
-                       // Invalid id number
-                       throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
-               } else if (contact.getContactLandLineNumber() == null) {
-                       // Not set cell phone instance
-                       throw new PhoneNumberNotLinkedException(landLineNumber);
-               } else if (contact.getContactLandLineNumber().getPhoneId() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("contact.contactLandLineNumber.phoneId is null"); //NOI18N
-               } else if (contact.getContactLandLineNumber().getPhoneId() < 1) {
-                       // Invalid id number
-                       throw new IllegalArgumentException(MessageFormat.format("contact.contactLandLineNumber.phoneId={0} is invalid.", contact.getContactLandLineNumber().getPhoneId())); //NOI18N
-               } else if (!Objects.equals(landLineNumber.getPhoneId(), contact.getContactLandLineNumber().getPhoneId())) {
-                       // Not same object
-                       throw new IllegalArgumentException(MessageFormat.format("contact.contactLandLineNumber.phoneId={0} and landLineNumber.phoneId={1} are not the same.", contact.getContactLandLineNumber().getPhoneId(), landLineNumber.getPhoneId())); //NOI18N
-               }
-
-               // Remove it from contact
-               contact.setContactLandLineNumber(null);
-
-               // Update database
-               final Contact updatedContact = this.contactBean.updateContactData(contact);
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.unlinkLandLineDataFromContact: updatedContact={1} - EXIT!", this.getClass().getSimpleName(), updatedContact)); //NOI18N
-
-               // Return it
-               return updatedContact;
-       }
-
-       @Override
-       public Contact unlinkMobileDataFromContact (final Contact contact, final DialableMobileNumber mobileNumber) throws PhoneNumberNotLinkedException {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.unlinkMobileDataFromContact: contact={1},mobileNumber={2} - CALLED!", this.getClass().getSimpleName(), contact, mobileNumber)); //NOI18N
-
-               // Is the contact set?
-               if (null == contact) {
-                       // Throw NPE
-                       throw new NullPointerException("contact is null"); //NOI18N
-               } else if (contact.getContactId() == null) {
-                       // ... and throw again
-                       throw new NullPointerException("contact.contactId is null"); //NOI18N
-               } else if (contact.getContactId() < 1) {
-                       // Invalid id number
-                       throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
-               } else if (contact.getContactMobileNumber() == null) {
-                       // Not set cell phone instance
-                       throw new PhoneNumberNotLinkedException(mobileNumber);
-               } else if (contact.getContactMobileNumber().getPhoneId() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("contact.contactMobileNumber.phoneId is null"); //NOI18N
-               } else if (contact.getContactMobileNumber().getPhoneId() < 1) {
-                       // Invalid id number
-                       throw new IllegalArgumentException(MessageFormat.format("contact.contactMobileNumber.phoneId={0} is invalid.", contact.getContactMobileNumber().getPhoneId())); //NOI18N
-               } else if (!Objects.equals(mobileNumber.getPhoneId(), contact.getContactMobileNumber().getPhoneId())) {
-                       // Not same object
-                       throw new IllegalArgumentException(MessageFormat.format("contact.contactMobileNumber.phoneId={0} and mobileNumber.phoneId={1} are not the same.", contact.getContactMobileNumber().getPhoneId(), mobileNumber.getPhoneId())); //NOI18N
-               }
-
-               // Remove it from contact
-               contact.setContactMobileNumber(null);
-
-               // Update database
-               final Contact updatedContact = this.contactBean.updateContactData(contact);
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.unlinkMobileDataFromContact: updatedContact={1} - EXIT!", this.getClass().getSimpleName(), updatedContact)); //NOI18N
-
-               // Return it
-               return updatedContact;
-       }
-
-}
diff --git a/src/java/org/mxchange/jcontactsbusiness/basicdata/PizzaAdminBusinessDataSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/basicdata/PizzaAdminBusinessDataSessionBean.java
deleted file mode 100644 (file)
index 5ad2589..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (C) 2017 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jcontactsbusiness.basicdata;
-
-import java.text.MessageFormat;
-import java.util.GregorianCalendar;
-import java.util.List;
-import java.util.Objects;
-import javax.ejb.EJB;
-import javax.ejb.Stateless;
-import org.mxchange.jcontactsbusiness.exceptions.basicdata.BusinessDataAlreadyAddedException;
-import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
-
-/**
- * An administrative stateless session bean for business data
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Stateless (name = "adminBusinessData", description = "An administrative statless bean for handling business data (all)")
-public class PizzaAdminBusinessDataSessionBean extends BasePizzaDatabaseBean implements AdminBusinessDataSessionBeanRemote {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 56_389_504_892_184_572L;
-
-       /**
-        * Administrative EJB
-        */
-       @EJB
-       private BusinessDataSessionBeanRemote businessDataBean;
-
-       /**
-        * Default constructor
-        */
-       public PizzaAdminBusinessDataSessionBean () {
-               // Call super constructor
-               super();
-       }
-
-       @Override
-       public BusinessBasicData addCompanyBasicData (final BusinessBasicData basicData) throws BusinessDataAlreadyAddedException {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addBusinessBasicData: basicData={1} - CALLED!", this.getClass().getSimpleName(), basicData)); //NOI18N
-
-               // Is the instance set?
-               if (null == basicData) {
-                       // Throw NPE
-                       throw new NullPointerException("basicData is null"); //NOI18N
-               } else if (basicData.getBasicDataId() != null) {
-                       // Should be null
-                       throw new IllegalArgumentException(MessageFormat.format("basicData.basicDataId={0} - is not null", basicData.getBasicDataId())); //NOI18N
-               }
-
-               // Get all available entries
-               final List<BusinessBasicData> list = this.businessDataBean.allCompanyBasicData();
-
-               // Is the list filled?
-               if (!list.isEmpty()) {
-                       // Then check each entry
-                       for (final BusinessBasicData entry : list) {
-                               // Is the company name matching?
-                               if (Objects.equals(entry.getCompanyName(), basicData.getCompanyName())) {
-                                       // Found match
-                                       throw new BusinessDataAlreadyAddedException(basicData);
-                               }
-                       }
-               }
-
-               // Now add current date
-               basicData.setCompanyCreated(new GregorianCalendar());
-
-               // Persist it
-               this.getEntityManager().persist(basicData);
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addBusinessBasicData: basicData.basicDataId={1} - EXIT!", this.getClass().getSimpleName(), basicData.getBasicDataId())); //NOI18N
-
-               // Return updated instance
-               return basicData;
-       }
-
-}
diff --git a/src/java/org/mxchange/jcontactsbusiness/basicdata/PizzaBusinessDataSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/basicdata/PizzaBusinessDataSessionBean.java
deleted file mode 100644 (file)
index 2e1be00..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Copyright (C) 2017 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jcontactsbusiness.basicdata;
-
-import java.text.MessageFormat;
-import java.util.List;
-import java.util.Objects;
-import javax.ejb.Stateless;
-import javax.persistence.NoResultException;
-import javax.persistence.Query;
-import org.mxchange.jcontactsbusiness.exceptions.basicdata.BusinessDataNotFoundException;
-import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
-
-/**
- * A stateless session bean for business data
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Stateless (name = "businessData", description = "A general statless bean for handling business data (all)")
-public class PizzaBusinessDataSessionBean extends BasePizzaDatabaseBean implements BusinessDataSessionBeanRemote {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 56_389_504_892_184_571L;
-
-       /**
-        * Default constructor
-        */
-       public PizzaBusinessDataSessionBean () {
-               // Call super constructor
-               super();
-       }
-
-       @Override
-       @SuppressWarnings ("unchecked")
-       public List<BusinessBasicData> allCompanyBasicData () {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allBusinessContacts: CALLED!", this.getClass().getSimpleName())); //NOI18N
-
-               // Get query
-               final Query query = this.getEntityManager().createNamedQuery("AllBusinessData"); //NOI18N
-
-               // Get list from it
-               final List<BusinessBasicData> list = query.getResultList();
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allBusinessContacts: list.size()={1} - EXIT!", this.getClass().getSimpleName(), list.size())); //NOI18N
-
-               // Return it
-               return list;
-       }
-
-       @Override
-       public BusinessBasicData findBasicDataById (final Long basicDataId) throws BusinessDataNotFoundException {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findBasicDataById: CALLED!", this.getClass().getSimpleName())); //NOI18N
-
-               // Get query
-               final Query query = this.getEntityManager().createNamedQuery("SearchBusinessDataById", CompanyBasicData.class); //NOI18N
-
-               // Set parameter
-               query.setParameter("basicDataId", basicDataId); //NOI18N
-
-               // Get single instance
-               final BusinessBasicData basicData;
-
-               // Try to find a result
-               try {
-                       // Find a single result
-                       basicData = (BusinessBasicData) query.getSingleResult();
-
-                       // Log trace message
-                       this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findBasicDataById: Found basicData={1}", this.getClass().getSimpleName(), basicData)); //NOI18N
-               } catch (final NoResultException ex) {
-                       // No result found
-                       throw new BusinessDataNotFoundException(basicDataId, ex);
-               }
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findBasicDataById: basicData={1} - EXIT!", this.getClass().getSimpleName(), basicData)); //NOI18N
-
-               // Return it
-               return basicData;
-       }
-
-       @Override
-       public Boolean isCompanyNameUsed (final String companyName) {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isCompanyNameUsed: companyName={1} - CALLED!", this.getClass().getSimpleName(), companyName)); //NOI18N
-
-               // Is the parameter valid?
-               if (null == companyName) {
-                       // Throw NPE
-                       throw new NullPointerException("companyName is null"); //NOI18N
-               } else if (companyName.isEmpty()) {
-                       // Throw IAE
-                       throw new IllegalArgumentException("companyName is empty"); //NOI18N
-               }
-
-               // Default is not found
-               Boolean isCompanyNameUsed = Boolean.FALSE;
-
-               // Get whole list
-               final List<BusinessBasicData> list = this.allCompanyBasicData();
-
-               // Check whole list
-               for (final BusinessBasicData basicData : list) {
-                       // Is name used?
-                       if (Objects.equals(basicData.getCompanyName(), companyName)) {
-                               // Found one
-                               isCompanyNameUsed = Boolean.TRUE;
-
-                               // Abort search
-                               break;
-                       }
-               }
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isCompanyNameUsed: isCompanyNameUsed={1} - EXIT!", this.getClass().getSimpleName(), isCompanyNameUsed)); //NOI18N
-
-               // Return it
-               return isCompanyNameUsed;
-       }
-
-}
diff --git a/src/java/org/mxchange/jcontactsbusiness/branchoffice/PizzaAdminBranchOfficeSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/branchoffice/PizzaAdminBranchOfficeSessionBean.java
deleted file mode 100644 (file)
index 7b328cf..0000000
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright (C) 2017 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jcontactsbusiness.branchoffice;
-
-import java.text.MessageFormat;
-import java.util.GregorianCalendar;
-import java.util.List;
-import javax.ejb.EJB;
-import javax.ejb.Stateless;
-import org.mxchange.jcontactsbusiness.basicdata.BusinessBasicData;
-import org.mxchange.jcontactsbusiness.exceptions.branchoffice.BranchOfficeAlreadyAddedException;
-import org.mxchange.jcountry.data.Country;
-import org.mxchange.jusercore.model.user.User;
-import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
-
-/**
- * A stateless session bean for administrative branch office purposes
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Stateless (name = "adminBranchOffice", description = "An administrative statless bean for handling branch office data (all)")
-public class PizzaAdminBranchOfficeSessionBean extends BasePizzaDatabaseBean implements AdminBranchOfficeSessionBeanRemote {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 58_467_386_571_701L;
-
-       /**
-        * General branch office bean
-        */
-       @EJB
-       private BranchOfficeSessionBeanRemote branchOfficeBean;
-
-       /**
-        * Default constructor
-        */
-       public PizzaAdminBranchOfficeSessionBean () {
-               // Call super constructor
-               super();
-       }
-
-       @Override
-       public BranchOffice addBranchOffice (final BranchOffice branchOffice) throws BranchOfficeAlreadyAddedException {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addBranchOffice(): branchOffice={1} - CALLED!", this.getClass().getSimpleName(), branchOffice)); //NOI18N
-
-               // Validate parameter
-               if (null == branchOffice) {
-                       // Throw NPE
-                       throw new NullPointerException("branchOffice is null"); //NOI18N
-               } else if (branchOffice.getBranchId() instanceof Long) {
-                       // Should not happen
-                       throw new IllegalArgumentException("branchOffice.branchId should not be set."); //NOI18N
-               } else if (this.isBranchOfficeFound(branchOffice)) {
-                       // Already added, abort here
-                       throw new BranchOfficeAlreadyAddedException(branchOffice);
-               }
-
-               // Add created timestamp
-               branchOffice.setBranchCreated(new GregorianCalendar());
-
-               // Is user instance set?
-               if (branchOffice.getBranchCompany() instanceof BusinessBasicData) {
-                       // Get managed instance back
-                       final BusinessBasicData managedBasicData = this.getManaged(branchOffice.getBranchCompany());
-
-                       // Set it back in branch office
-                       branchOffice.setBranchCompany(managedBasicData);
-               }
-
-               // Is user instance set?
-               if (branchOffice.getBranchUserOwner() instanceof User) {
-                       // Get managed instance back
-                       final User managedUser = this.getManaged(branchOffice.getBranchUserOwner());
-
-                       // Set it back in branch office
-                       branchOffice.setBranchUserOwner(managedUser);
-               }
-
-               // Is user instance set?
-               if (branchOffice.getBranchCountry() instanceof Country) {
-                       // Get managed instance back
-                       final Country managedCountry = this.getManaged(branchOffice.getBranchCountry());
-
-                       // Set it back in branch office
-                       branchOffice.setBranchCountry(managedCountry);
-               }
-
-               // Persist it
-               this.getEntityManager().persist(branchOffice);
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addBranchOffice(): branchOffice.branchId={1} - EXIT!", this.getClass().getSimpleName(), branchOffice.getBranchId())); //NOI18N
-
-               // Return updated instance
-               return branchOffice;
-       }
-
-       /**
-        * Checks if given branch office's address is already persisted. The whole
-        * (persisted) list is being loaded and each address is being matched
-        * against the given branch office's address.
-        * <p>
-        * @param branchOffice Branch office being checked
-        * <p>
-        * @return Whether it has been found
-        */
-       private boolean isBranchOfficeFound (final BranchOffice branchOffice) {
-               // Get whole list
-               final List<BranchOffice> branchOffices = this.branchOfficeBean.allBranchOffices();
-
-               // Default is not found
-               boolean isFound = false;
-
-               // Check all single addresses
-               for (final BranchOffice bo : branchOffices) {
-                       // Is the same address found?
-                       if (BranchOfficeUtils.isSameAddress(bo, branchOffice)) {
-                               // Found one
-                               isFound = true;
-                               break;
-                       }
-               }
-
-               // Return flag
-               return isFound;
-       }
-
-}
diff --git a/src/java/org/mxchange/jcontactsbusiness/branchoffice/PizzaBranchOfficeSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/branchoffice/PizzaBranchOfficeSessionBean.java
deleted file mode 100644 (file)
index bc251df..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2017 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jcontactsbusiness.branchoffice;
-
-import java.text.MessageFormat;
-import java.util.List;
-import javax.ejb.Stateless;
-import javax.persistence.Query;
-import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
-
-/**
- * A stateless session bean for general branch office purposes
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Stateless (name = "branchOffice", description = "A general statless bean for handling branch office data (all)")
-public class PizzaBranchOfficeSessionBean extends BasePizzaDatabaseBean implements BranchOfficeSessionBeanRemote {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 58_467_386_571_701L;
-
-       @Override
-       @SuppressWarnings ("unchecked")
-       public List<BranchOffice> allBranchOffices () {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allBranchOffices: CALLED!", this.getClass().getSimpleName())); //NOI18N
-
-               // Get query
-               final Query query = this.getEntityManager().createNamedQuery("AllBranchOffices"); //NOI18N
-
-               // Get list from it
-               final List<BranchOffice> list = query.getResultList();
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allBranchOffices: list.size()={1} - EXIT!", this.getClass().getSimpleName(), list.size())); //NOI18N
-
-               // Return it
-               return list;
-       }
-
-}
diff --git a/src/java/org/mxchange/jcontactsbusiness/employee/PizzaAdminCompanyEmployeeSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/employee/PizzaAdminCompanyEmployeeSessionBean.java
deleted file mode 100644 (file)
index aa4a95c..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2017 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jcontactsbusiness.employee;
-
-import javax.ejb.Stateless;
-import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
-
-/**
- * A stateless bean for administrative purposes for company employees.
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Stateless (name = "adminCompanyEmployee", description = "An administrative statless bean for handling company employees")
-public class PizzaAdminCompanyEmployeeSessionBean extends BasePizzaDatabaseBean implements AdminCompanyEmployeeSessionBeanRemote {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 26_458_796_703_761L;
-
-       /**
-        * Default constructor
-        */
-       public PizzaAdminCompanyEmployeeSessionBean () {
-               super();
-       }
-
-}
diff --git a/src/java/org/mxchange/jcontactsbusiness/employee/PizzaCompanyEmployeeSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/employee/PizzaCompanyEmployeeSessionBean.java
deleted file mode 100644 (file)
index 3efaf89..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (C) 2017 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jcontactsbusiness.employee;
-
-import java.text.MessageFormat;
-import java.util.List;
-import javax.ejb.Stateless;
-import javax.persistence.NoResultException;
-import javax.persistence.Query;
-import org.mxchange.jcontactsbusiness.exceptions.employee.CompanyEmployeeNotFoundException;
-import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
-
-/**
- * A stateless bean for general purposes for company employees.
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Stateless (name = "companyEmployee", description = "A general statless bean for handling company employees")
-public class PizzaCompanyEmployeeSessionBean extends BasePizzaDatabaseBean implements CompanyEmployeeSessionBeanRemote {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 26_458_796_703_761L;
-
-       /**
-        * Default constructor
-        */
-       public PizzaCompanyEmployeeSessionBean () {
-               super();
-       }
-
-       @Override
-       @SuppressWarnings ("unchecked")
-       public List<Employee> allCompanyEmployees () {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allCompanyEmployees(): CALLED!", this.getClass().getSimpleName())); //NOI18N
-
-               // Get named query
-               final Query query = this.getEntityManager().createNamedQuery("AllCompanyEmployees"); //NOI18N
-
-               // Get list form it
-               final List<Employee> employees = query.getResultList();
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allCompanyEmployees(): employees.size()={1} - EXIT!", this.getClass().getSimpleName(), employees.size())); //NOI18N
-
-               // Return it
-               return employees;
-       }
-
-       @Override
-       public Employee findCompanyEmployeeById (final Long employeeId) throws CompanyEmployeeNotFoundException {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findCompanyEmployeeById(): employeeId={1} - CALLED!", this.getClass().getSimpleName(), employeeId)); //NOI18N
-
-               // Is the employee id valid?
-               if (null == employeeId) {
-                       // Throw NPE
-                       throw new NullPointerException("employeeId is null"); //NOI18N
-               } else if (employeeId < 1) {
-                       // Not valid
-                       throw new IllegalArgumentException(MessageFormat.format("employeeId={0} is not valid", employeeId)); //NOI18N
-               }
-
-               // Now get named query
-               final Query query = this.getEntityManager().createNamedQuery("SearchCompanyEmployeeById"); //NOI18N
-
-               // Set parameter
-               query.setParameter("employeeId", employeeId); //NOI18N
-
-               // Declare instance
-               final Employee employee;
-
-               // Try to find a result
-               try {
-                       // Find a single result
-                       employee = (Employee) query.getSingleResult();
-
-                       // Log trace message
-                       this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findCompanyEmployeeById: Found employee={1}", this.getClass().getSimpleName(), employee)); //NOI18N
-               } catch (final NoResultException ex) {
-                       // No result found
-                       throw new CompanyEmployeeNotFoundException(employeeId, ex);
-               }
-
-               // Log trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findCompanyEmployeeById: employee={1} - EXIT!", this.getClass().getSimpleName(), employee)); //NOI18N
-
-               // Return found instance
-               return employee;
-       }
-
-}
diff --git a/src/java/org/mxchange/jcontactsbusiness/model/basicdata/PizzaAdminBusinessDataSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/model/basicdata/PizzaAdminBusinessDataSessionBean.java
new file mode 100644 (file)
index 0000000..e73eff3
--- /dev/null
@@ -0,0 +1,143 @@
+/*
+ * Copyright (C) 2017 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jcontactsbusiness.model.basicdata;
+
+import java.text.MessageFormat;
+import java.util.GregorianCalendar;
+import java.util.List;
+import java.util.Objects;
+import javax.ejb.EJB;
+import javax.ejb.Stateless;
+import org.mxchange.jcontactsbusiness.basicdata.AdminBusinessDataSessionBeanRemote;
+import org.mxchange.jcontactsbusiness.basicdata.BusinessDataSessionBeanRemote;
+import org.mxchange.jcontactsbusiness.exceptions.basicdata.BusinessDataAlreadyAddedException;
+import org.mxchange.jcontactsbusiness.model.employee.Employee;
+import org.mxchange.jusercore.model.user.User;
+import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
+
+/**
+ * An administrative stateless session bean for business data
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Stateless (name = "adminBusinessData", description = "An administrative statless bean for handling business data (all)")
+public class PizzaAdminBusinessDataSessionBean extends BasePizzaDatabaseBean implements AdminBusinessDataSessionBeanRemote {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 56_389_504_892_184_572L;
+
+       /**
+        * Administrative EJB
+        */
+       @EJB
+       private BusinessDataSessionBeanRemote businessDataBean;
+
+       /**
+        * Default constructor
+        */
+       public PizzaAdminBusinessDataSessionBean () {
+               // Call super constructor
+               super();
+       }
+
+       @Override
+       public BusinessBasicData addCompanyBasicData (final BusinessBasicData basicData) throws BusinessDataAlreadyAddedException {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addBusinessBasicData: basicData={1} - CALLED!", this.getClass().getSimpleName(), basicData)); //NOI18N
+
+               // Is the instance set?
+               if (null == basicData) {
+                       // Throw NPE
+                       throw new NullPointerException("basicData is null"); //NOI18N
+               } else if (basicData.getBasicDataId() != null) {
+                       // Should be null
+                       throw new IllegalArgumentException(MessageFormat.format("basicData.basicDataId={0} - is not null", basicData.getBasicDataId())); //NOI18N
+               } else if (this.isSameCompanyNameAdded(basicData)) {
+                       // Throw exception
+                       throw new BusinessDataAlreadyAddedException(basicData);
+               }
+
+               // Now add current date
+               basicData.setCompanyCreated(new GregorianCalendar());
+
+               // Is there a owner set?
+               if (basicData.getCompanyUserOwner() instanceof User) {
+                       // Get managed instance
+                       final User managedUser = this.createManaged(basicData.getCompanyUserOwner());
+
+                       // Set it back
+                       basicData.setCompanyUserOwner(managedUser);
+               }
+
+               // Is a founder set?
+               if (basicData.getCompanyFounder() instanceof Employee) {
+                       // Get managed instance
+                       final Employee managedEmployee = this.createManaged(basicData.getCompanyFounder());
+
+                       // Set it back
+                       basicData.setCompanyFounder(managedEmployee);
+               }
+
+               // Is a contact person set?
+               if (basicData.getCompanyContactEmployee() instanceof Employee) {
+                       // Get managed instance
+                       final Employee managedEmployee = this.createManaged(basicData.getCompanyContactEmployee());
+
+                       // Set it back
+                       basicData.setCompanyContactEmployee(managedEmployee);
+               }
+
+               // Persist it
+               this.getEntityManager().persist(basicData);
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addBusinessBasicData: basicData.basicDataId={1} - EXIT!", this.getClass().getSimpleName(), basicData.getBasicDataId())); //NOI18N
+
+               // Return updated instance
+               return basicData;
+       }
+
+       /**
+        * Checks if given basic data is already added by it's company name
+        * <p>
+        * @param basicData Basic data to be checked
+        *
+        * @return Whether same company name has been used
+        */
+       private boolean isSameCompanyNameAdded (final BusinessBasicData basicData) {
+               // Get all available entries
+               final List<BusinessBasicData> list = this.businessDataBean.allCompanyBasicData();
+
+               // Default is not found
+               boolean isFound = false;
+
+               // Then check each entry
+               for (final BusinessBasicData entry : list) {
+                       // Is the company name matching?
+                       if (Objects.equals(entry.getCompanyName(), basicData.getCompanyName())) {
+                               // Found match
+                               isFound = true;
+                       }
+               }
+
+               // Return flag
+               return isFound;
+       }
+
+}
diff --git a/src/java/org/mxchange/jcontactsbusiness/model/basicdata/PizzaBusinessDataSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/model/basicdata/PizzaBusinessDataSessionBean.java
new file mode 100644 (file)
index 0000000..4633530
--- /dev/null
@@ -0,0 +1,141 @@
+/*
+ * Copyright (C) 2017 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jcontactsbusiness.model.basicdata;
+
+import java.text.MessageFormat;
+import java.util.List;
+import java.util.Objects;
+import javax.ejb.Stateless;
+import javax.persistence.NoResultException;
+import javax.persistence.Query;
+import org.mxchange.jcontactsbusiness.basicdata.BusinessDataSessionBeanRemote;
+import org.mxchange.jcontactsbusiness.exceptions.basicdata.BusinessDataNotFoundException;
+import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
+
+/**
+ * A stateless session bean for business data
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Stateless (name = "businessData", description = "A general statless bean for handling business data (all)")
+public class PizzaBusinessDataSessionBean extends BasePizzaDatabaseBean implements BusinessDataSessionBeanRemote {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 56_389_504_892_184_571L;
+
+       /**
+        * Default constructor
+        */
+       public PizzaBusinessDataSessionBean () {
+               // Call super constructor
+               super();
+       }
+
+       @Override
+       @SuppressWarnings ("unchecked")
+       public List<BusinessBasicData> allCompanyBasicData () {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allBusinessContacts: CALLED!", this.getClass().getSimpleName())); //NOI18N
+
+               // Get query
+               final Query query = this.getEntityManager().createNamedQuery("AllBusinessData"); //NOI18N
+
+               // Get list from it
+               final List<BusinessBasicData> list = query.getResultList();
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allBusinessContacts: list.size()={1} - EXIT!", this.getClass().getSimpleName(), list.size())); //NOI18N
+
+               // Return it
+               return list;
+       }
+
+       @Override
+       public BusinessBasicData findBasicDataById (final Long basicDataId) throws BusinessDataNotFoundException {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findBasicDataById: CALLED!", this.getClass().getSimpleName())); //NOI18N
+
+               // Get query
+               final Query query = this.getEntityManager().createNamedQuery("SearchBusinessDataById", CompanyBasicData.class); //NOI18N
+
+               // Set parameter
+               query.setParameter("basicDataId", basicDataId); //NOI18N
+
+               // Get single instance
+               final BusinessBasicData basicData;
+
+               // Try to find a result
+               try {
+                       // Find a single result
+                       basicData = (BusinessBasicData) query.getSingleResult();
+
+                       // Log trace message
+                       this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findBasicDataById: Found basicData={1}", this.getClass().getSimpleName(), basicData)); //NOI18N
+               } catch (final NoResultException ex) {
+                       // No result found
+                       throw new BusinessDataNotFoundException(basicDataId, ex);
+               }
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findBasicDataById: basicData={1} - EXIT!", this.getClass().getSimpleName(), basicData)); //NOI18N
+
+               // Return it
+               return basicData;
+       }
+
+       @Override
+       public Boolean isCompanyNameUsed (final String companyName) {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isCompanyNameUsed: companyName={1} - CALLED!", this.getClass().getSimpleName(), companyName)); //NOI18N
+
+               // Is the parameter valid?
+               if (null == companyName) {
+                       // Throw NPE
+                       throw new NullPointerException("companyName is null"); //NOI18N
+               } else if (companyName.isEmpty()) {
+                       // Throw IAE
+                       throw new IllegalArgumentException("companyName is empty"); //NOI18N
+               }
+
+               // Default is not found
+               Boolean isCompanyNameUsed = Boolean.FALSE;
+
+               // Get whole list
+               final List<BusinessBasicData> list = this.allCompanyBasicData();
+
+               // Check whole list
+               for (final BusinessBasicData basicData : list) {
+                       // Is name used?
+                       if (Objects.equals(basicData.getCompanyName(), companyName)) {
+                               // Found one
+                               isCompanyNameUsed = Boolean.TRUE;
+
+                               // Abort search
+                               break;
+                       }
+               }
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isCompanyNameUsed: isCompanyNameUsed={1} - EXIT!", this.getClass().getSimpleName(), isCompanyNameUsed)); //NOI18N
+
+               // Return it
+               return isCompanyNameUsed;
+       }
+
+}
diff --git a/src/java/org/mxchange/jcontactsbusiness/model/branchoffice/PizzaAdminBranchOfficeSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/model/branchoffice/PizzaAdminBranchOfficeSessionBean.java
new file mode 100644 (file)
index 0000000..1bd1cac
--- /dev/null
@@ -0,0 +1,148 @@
+/*
+ * Copyright (C) 2017 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jcontactsbusiness.model.branchoffice;
+
+import java.text.MessageFormat;
+import java.util.GregorianCalendar;
+import java.util.List;
+import javax.ejb.EJB;
+import javax.ejb.Stateless;
+import org.mxchange.jcontactsbusiness.branchoffice.AdminBranchOfficeSessionBeanRemote;
+import org.mxchange.jcontactsbusiness.branchoffice.BranchOfficeSessionBeanRemote;
+import org.mxchange.jcontactsbusiness.exceptions.branchoffice.BranchOfficeAlreadyAddedException;
+import org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData;
+import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice;
+import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOfficeUtils;
+import org.mxchange.jcountry.model.data.Country;
+import org.mxchange.jusercore.model.user.User;
+import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
+
+/**
+ * A stateless session bean for administrative branch office purposes
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Stateless (name = "adminBranchOffice", description = "An administrative statless bean for handling branch office data (all)")
+public class PizzaAdminBranchOfficeSessionBean extends BasePizzaDatabaseBean implements AdminBranchOfficeSessionBeanRemote {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 58_467_386_571_701L;
+
+       /**
+        * General branch office bean
+        */
+       @EJB
+       private BranchOfficeSessionBeanRemote branchOfficeBean;
+
+       /**
+        * Default constructor
+        */
+       public PizzaAdminBranchOfficeSessionBean () {
+               // Call super constructor
+               super();
+       }
+
+       @Override
+       public BranchOffice addBranchOffice (final BranchOffice branchOffice) throws BranchOfficeAlreadyAddedException {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addBranchOffice(): branchOffice={1} - CALLED!", this.getClass().getSimpleName(), branchOffice)); //NOI18N
+
+               // Validate parameter
+               if (null == branchOffice) {
+                       // Throw NPE
+                       throw new NullPointerException("branchOffice is null"); //NOI18N
+               } else if (branchOffice.getBranchId() instanceof Long) {
+                       // Should not happen
+                       throw new IllegalArgumentException("branchOffice.branchId should not be set."); //NOI18N
+               } else if (this.isBranchOfficeFound(branchOffice)) {
+                       // Already added, abort here
+                       throw new BranchOfficeAlreadyAddedException(branchOffice);
+               }
+
+               // Add created timestamp
+               branchOffice.setBranchCreated(new GregorianCalendar());
+
+               // Is user instance set?
+               if (branchOffice.getBranchCompany() instanceof BusinessBasicData) {
+                       // Get managed instance back
+                       final BusinessBasicData managedBasicData = this.createManaged(branchOffice.getBranchCompany());
+
+                       // Set it back in branch office
+                       branchOffice.setBranchCompany(managedBasicData);
+               }
+
+               // Is user instance set?
+               if (branchOffice.getBranchUserOwner() instanceof User) {
+                       // Get managed instance back
+                       final User managedUser = this.createManaged(branchOffice.getBranchUserOwner());
+
+                       // Set it back in branch office
+                       branchOffice.setBranchUserOwner(managedUser);
+               }
+
+               // Is user instance set?
+               if (branchOffice.getBranchCountry() instanceof Country) {
+                       // Get managed instance back
+                       final Country managedCountry = this.createManaged(branchOffice.getBranchCountry());
+
+                       // Set it back in branch office
+                       branchOffice.setBranchCountry(managedCountry);
+               }
+
+               // Persist it
+               this.getEntityManager().persist(branchOffice);
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addBranchOffice(): branchOffice.branchId={1} - EXIT!", this.getClass().getSimpleName(), branchOffice.getBranchId())); //NOI18N
+
+               // Return updated instance
+               return branchOffice;
+       }
+
+       /**
+        * Checks if given branch office's address is already persisted. The whole
+        * (persisted) list is being loaded and each address is being matched
+        * against the given branch office's address.
+        * <p>
+        * @param branchOffice Branch office being checked
+        * <p>
+        * @return Whether it has been found
+        */
+       private boolean isBranchOfficeFound (final BranchOffice branchOffice) {
+               // Get whole list
+               final List<BranchOffice> branchOffices = this.branchOfficeBean.allBranchOffices();
+
+               // Default is not found
+               boolean isFound = false;
+
+               // Check all single addresses
+               for (final BranchOffice bo : branchOffices) {
+                       // Is the same address found?
+                       if (BranchOfficeUtils.isSameAddress(bo, branchOffice)) {
+                               // Found one
+                               isFound = true;
+                               break;
+                       }
+               }
+
+               // Return flag
+               return isFound;
+       }
+
+}
diff --git a/src/java/org/mxchange/jcontactsbusiness/model/branchoffice/PizzaBranchOfficeSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/model/branchoffice/PizzaBranchOfficeSessionBean.java
new file mode 100644 (file)
index 0000000..ec75390
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2017 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jcontactsbusiness.model.branchoffice;
+
+import java.text.MessageFormat;
+import java.util.List;
+import javax.ejb.Stateless;
+import javax.persistence.Query;
+import org.mxchange.jcontactsbusiness.branchoffice.BranchOfficeSessionBeanRemote;
+import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
+
+/**
+ * A stateless session bean for general branch office purposes
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Stateless (name = "branchOffice", description = "A general statless bean for handling branch office data (all)")
+public class PizzaBranchOfficeSessionBean extends BasePizzaDatabaseBean implements BranchOfficeSessionBeanRemote {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 58_467_386_571_701L;
+
+       @Override
+       @SuppressWarnings ("unchecked")
+       public List<BranchOffice> allBranchOffices () {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allBranchOffices: CALLED!", this.getClass().getSimpleName())); //NOI18N
+
+               // Get query
+               final Query query = this.getEntityManager().createNamedQuery("AllBranchOffices"); //NOI18N
+
+               // Get list from it
+               final List<BranchOffice> list = query.getResultList();
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allBranchOffices: list.size()={1} - EXIT!", this.getClass().getSimpleName(), list.size())); //NOI18N
+
+               // Return it
+               return list;
+       }
+
+}
diff --git a/src/java/org/mxchange/jcontactsbusiness/model/employee/PizzaAdminCompanyEmployeeSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/model/employee/PizzaAdminCompanyEmployeeSessionBean.java
new file mode 100644 (file)
index 0000000..03f071c
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2017 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jcontactsbusiness.model.employee;
+
+import javax.ejb.Stateless;
+import org.mxchange.jcontactsbusiness.employee.AdminCompanyEmployeeSessionBeanRemote;
+import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
+
+/**
+ * A stateless bean for administrative purposes for company employees.
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Stateless (name = "adminCompanyEmployee", description = "An administrative statless bean for handling company employees")
+public class PizzaAdminCompanyEmployeeSessionBean extends BasePizzaDatabaseBean implements AdminCompanyEmployeeSessionBeanRemote {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 26_458_796_703_761L;
+
+       /**
+        * Default constructor
+        */
+       public PizzaAdminCompanyEmployeeSessionBean () {
+               super();
+       }
+
+}
diff --git a/src/java/org/mxchange/jcontactsbusiness/model/employee/PizzaCompanyEmployeeSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/model/employee/PizzaCompanyEmployeeSessionBean.java
new file mode 100644 (file)
index 0000000..ac7c8c0
--- /dev/null
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2017 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jcontactsbusiness.model.employee;
+
+import java.text.MessageFormat;
+import java.util.List;
+import javax.ejb.Stateless;
+import javax.persistence.NoResultException;
+import javax.persistence.Query;
+import org.mxchange.jcontactsbusiness.employee.CompanyEmployeeSessionBeanRemote;
+import org.mxchange.jcontactsbusiness.exceptions.employee.CompanyEmployeeNotFoundException;
+import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
+
+/**
+ * A stateless bean for general purposes for company employees.
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Stateless (name = "companyEmployee", description = "A general statless bean for handling company employees")
+public class PizzaCompanyEmployeeSessionBean extends BasePizzaDatabaseBean implements CompanyEmployeeSessionBeanRemote {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 26_458_796_703_761L;
+
+       /**
+        * Default constructor
+        */
+       public PizzaCompanyEmployeeSessionBean () {
+               super();
+       }
+
+       @Override
+       @SuppressWarnings ("unchecked")
+       public List<Employee> allCompanyEmployees () {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allCompanyEmployees(): CALLED!", this.getClass().getSimpleName())); //NOI18N
+
+               // Get named query
+               final Query query = this.getEntityManager().createNamedQuery("AllCompanyEmployees"); //NOI18N
+
+               // Get list form it
+               final List<Employee> employees = query.getResultList();
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allCompanyEmployees(): employees.size()={1} - EXIT!", this.getClass().getSimpleName(), employees.size())); //NOI18N
+
+               // Return it
+               return employees;
+       }
+
+       @Override
+       public Employee findCompanyEmployeeById (final Long employeeId) throws CompanyEmployeeNotFoundException {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findCompanyEmployeeById(): employeeId={1} - CALLED!", this.getClass().getSimpleName(), employeeId)); //NOI18N
+
+               // Is the employee id valid?
+               if (null == employeeId) {
+                       // Throw NPE
+                       throw new NullPointerException("employeeId is null"); //NOI18N
+               } else if (employeeId < 1) {
+                       // Not valid
+                       throw new IllegalArgumentException(MessageFormat.format("employeeId={0} is not valid", employeeId)); //NOI18N
+               }
+
+               // Now get named query
+               final Query query = this.getEntityManager().createNamedQuery("SearchCompanyEmployeeById"); //NOI18N
+
+               // Set parameter
+               query.setParameter("employeeId", employeeId); //NOI18N
+
+               // Declare instance
+               final Employee employee;
+
+               // Try to find a result
+               try {
+                       // Find a single result
+                       employee = (Employee) query.getSingleResult();
+
+                       // Log trace message
+                       this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findCompanyEmployeeById: Found employee={1}", this.getClass().getSimpleName(), employee)); //NOI18N
+               } catch (final NoResultException ex) {
+                       // No result found
+                       throw new CompanyEmployeeNotFoundException(employeeId, ex);
+               }
+
+               // Log trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findCompanyEmployeeById: employee={1} - EXIT!", this.getClass().getSimpleName(), employee)); //NOI18N
+
+               // Return found instance
+               return employee;
+       }
+
+}
diff --git a/src/java/org/mxchange/jcountry/data/PizzaCountrySingletonBean.java b/src/java/org/mxchange/jcountry/data/PizzaCountrySingletonBean.java
deleted file mode 100644 (file)
index eb2b2b2..0000000
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Copyright (C) 2016, 2017 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jcountry.data;
-
-import java.text.MessageFormat;
-import java.util.GregorianCalendar;
-import java.util.List;
-import javax.ejb.Singleton;
-import javax.ejb.Startup;
-import javax.persistence.NoResultException;
-import javax.persistence.Query;
-import org.mxchange.jcountry.exceptions.CountryAlreadyAddedException;
-import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
-
-/**
- * A singleton EJB for country informations
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Startup
-@Singleton (name = "country", description = "A singleton session-scoped bean for country informations")
-public class PizzaCountrySingletonBean extends BasePizzaDatabaseBean implements CountrySingletonBeanRemote {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 15_846_983_298_691_207L;
-
-       /**
-        * Default constructor
-        */
-       public PizzaCountrySingletonBean () {
-               // Call super constructor
-               super();
-       }
-
-       @Override
-       public Country addCountry (final Country country) throws CountryAlreadyAddedException {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addCountry: country={1} - CALLED!", this.getClass().getSimpleName(), country)); //NOI18N
-
-               // Is it already there?
-               if (null == country) {
-                       // Throw NPE
-                       throw new NullPointerException("country is null"); //NOI18N
-               } else if (country.getCountryCode().isEmpty()) {
-                       // Code is not set
-                       throw new IllegalArgumentException("country.countryCode is empty"); //NOI18N
-               } else if (country.getCountryI18nKey().isEmpty()) {
-                       // I18n key is not set
-                       throw new IllegalArgumentException("country.countryI18nKey is empty"); //NOI18N
-               } else if (country.getCountryId() != null) {
-                       // Should be null
-                       throw new IllegalArgumentException(MessageFormat.format("country.countryId is not null ({0})", country.getCountryId())); //NOI18N
-               } else if (this.isCountryAdded(country)) {
-                       // Yes, then abort here
-                       throw new CountryAlreadyAddedException(country);
-               }
-
-               // Add timestamp
-               country.setCountryEntryCreated(new GregorianCalendar());
-
-               // It is not added, so persist it
-               this.getEntityManager().persist(country);
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addCountry: country={1} - EXIT!", this.getClass().getSimpleName(), country)); //NOI18N
-
-               // Return updated instance
-               return country;
-       }
-
-       @Override
-       @SuppressWarnings ("unchecked")
-       public List<Country> allCountries () {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allCountries: CALLED!", this.getClass().getSimpleName())); //NOI18N
-
-               // Init query
-               final Query query = this.getEntityManager().createNamedQuery("AllCountries", CountryData.class); //NOI18N
-
-               // Get list
-               final List<Country> countries = query.getResultList();
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allCountries: countries.size()={1} - EXIT!", this.getClass().getSimpleName(), countries.size())); //NOI18N
-
-               // Return it
-               return countries;
-       }
-
-       /**
-        * Checks whether given country is already added by i18n key or country
-        * code, what comes first.
-        * <p>
-        * @param country Country instance to check
-        * <p>
-        * @return Whether the country was found
-        */
-       private boolean isCountryAdded (final Country country) {
-               if (null == country) {
-                       // Throw NPE
-                       throw new NullPointerException("country is null"); //NOI18N
-               } else if (country.getCountryCode().isEmpty()) {
-                       // Code is not set
-                       throw new IllegalArgumentException("country.countryCode is empty"); //NOI18N
-               } else if (country.getCountryI18nKey().isEmpty()) {
-                       // I18n key is not set
-                       throw new IllegalArgumentException("country.countryI18nKey is empty"); //NOI18N
-               } else if (country.getCountryId() != null) {
-                       // Should be null
-                       throw new IllegalArgumentException(MessageFormat.format("country.countryId is not null ({0})", country.getCountryId())); //NOI18N
-               }
-
-               // Default is not found
-               boolean isAdded = false;
-
-               // Get query instance
-               final Query query = this.getEntityManager().createNamedQuery("SearchCountryByCodeI18nKey", CountryData.class); //NOI18N
-
-               // Assign all parameters
-               query.setParameter("code", country.getCountryCode()); //NOI18N
-               query.setParameter("key", country.getCountryI18nKey()); //NOI18N
-
-               // Try to get a single result
-               try {
-                       // Get single result
-                       final Country foundCountry = (Country) query.getSingleResult();
-
-                       // Found it?
-                       isAdded = (foundCountry instanceof Country);
-               } catch (final NoResultException ex) {
-                       // Not found, don't log this
-               }
-
-               // Return result
-               return isAdded;
-       }
-
-}
diff --git a/src/java/org/mxchange/jcountry/model/data/PizzaCountrySingletonBean.java b/src/java/org/mxchange/jcountry/model/data/PizzaCountrySingletonBean.java
new file mode 100644 (file)
index 0000000..7f3b2bc
--- /dev/null
@@ -0,0 +1,154 @@
+/*
+ * Copyright (C) 2016, 2017 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jcountry.model.data;
+
+import java.text.MessageFormat;
+import java.util.GregorianCalendar;
+import java.util.List;
+import javax.ejb.Singleton;
+import javax.ejb.Startup;
+import javax.persistence.NoResultException;
+import javax.persistence.Query;
+import org.mxchange.jcountry.exceptions.CountryAlreadyAddedException;
+import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
+
+/**
+ * A singleton EJB for country informations
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Startup
+@Singleton (name = "country", description = "A singleton session-scoped bean for country informations")
+public class PizzaCountrySingletonBean extends BasePizzaDatabaseBean implements CountrySingletonBeanRemote {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 15_846_983_298_691_207L;
+
+       /**
+        * Default constructor
+        */
+       public PizzaCountrySingletonBean () {
+               // Call super constructor
+               super();
+       }
+
+       @Override
+       public Country addCountry (final Country country) throws CountryAlreadyAddedException {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addCountry: country={1} - CALLED!", this.getClass().getSimpleName(), country)); //NOI18N
+
+               // Is it already there?
+               if (null == country) {
+                       // Throw NPE
+                       throw new NullPointerException("country is null"); //NOI18N
+               } else if (country.getCountryCode().isEmpty()) {
+                       // Code is not set
+                       throw new IllegalArgumentException("country.countryCode is empty"); //NOI18N
+               } else if (country.getCountryI18nKey().isEmpty()) {
+                       // I18n key is not set
+                       throw new IllegalArgumentException("country.countryI18nKey is empty"); //NOI18N
+               } else if (country.getCountryId() != null) {
+                       // Should be null
+                       throw new IllegalArgumentException(MessageFormat.format("country.countryId is not null ({0})", country.getCountryId())); //NOI18N
+               } else if (this.isCountryAdded(country)) {
+                       // Yes, then abort here
+                       throw new CountryAlreadyAddedException(country);
+               }
+
+               // Add timestamp
+               country.setCountryEntryCreated(new GregorianCalendar());
+
+               // It is not added, so persist it
+               this.getEntityManager().persist(country);
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addCountry: country={1} - EXIT!", this.getClass().getSimpleName(), country)); //NOI18N
+
+               // Return updated instance
+               return country;
+       }
+
+       @Override
+       @SuppressWarnings ("unchecked")
+       public List<Country> allCountries () {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allCountries: CALLED!", this.getClass().getSimpleName())); //NOI18N
+
+               // Init query
+               final Query query = this.getEntityManager().createNamedQuery("AllCountries", CountryData.class); //NOI18N
+
+               // Get list
+               final List<Country> countries = query.getResultList();
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allCountries: countries.size()={1} - EXIT!", this.getClass().getSimpleName(), countries.size())); //NOI18N
+
+               // Return it
+               return countries;
+       }
+
+       /**
+        * Checks whether given country is already added by i18n key or country
+        * code, what comes first.
+        * <p>
+        * @param country Country instance to check
+        * <p>
+        * @return Whether the country was found
+        */
+       private boolean isCountryAdded (final Country country) {
+               if (null == country) {
+                       // Throw NPE
+                       throw new NullPointerException("country is null"); //NOI18N
+               } else if (country.getCountryCode().isEmpty()) {
+                       // Code is not set
+                       throw new IllegalArgumentException("country.countryCode is empty"); //NOI18N
+               } else if (country.getCountryI18nKey().isEmpty()) {
+                       // I18n key is not set
+                       throw new IllegalArgumentException("country.countryI18nKey is empty"); //NOI18N
+               } else if (country.getCountryId() != null) {
+                       // Should be null
+                       throw new IllegalArgumentException(MessageFormat.format("country.countryId is not null ({0})", country.getCountryId())); //NOI18N
+               }
+
+               // Default is not found
+               boolean isAdded = false;
+
+               // Get query instance
+               final Query query = this.getEntityManager().createNamedQuery("SearchCountryByCodeI18nKey", CountryData.class); //NOI18N
+
+               // Assign all parameters
+               query.setParameter("code", country.getCountryCode()); //NOI18N
+               query.setParameter("key", country.getCountryI18nKey()); //NOI18N
+
+               // Try to get a single result
+               try {
+                       // Get single result
+                       final Country foundCountry = (Country) query.getSingleResult();
+
+                       // Found it?
+                       isAdded = (foundCountry instanceof Country);
+               } catch (final NoResultException ex) {
+                       // Not found, don't log this
+               }
+
+               // Return result
+               return isAdded;
+       }
+
+}
diff --git a/src/java/org/mxchange/jphone/model/phonenumbers/mobileprovider/PizzaAdminMobileProviderSessionBean.java b/src/java/org/mxchange/jphone/model/phonenumbers/mobileprovider/PizzaAdminMobileProviderSessionBean.java
new file mode 100644 (file)
index 0000000..4d9adf2
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2016, 2017 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jphone.model.phonenumbers.mobileprovider;
+
+import java.text.MessageFormat;
+import java.util.GregorianCalendar;
+import javax.ejb.Stateless;
+import org.mxchange.jphone.exceptions.MobileProviderAlreadyAddedException;
+import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
+
+/**
+ * Administrative singleton EJB for mobile provider informations
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Stateless (name = "adminMobileProvider", description = "A singleton session-scoped bean for mobile provider informations, admin-edition")
+public class PizzaAdminMobileProviderSessionBean extends BasePizzaDatabaseBean implements AdminMobileProviderSessionBeanRemote {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 15_846_983_298_691_207L;
+
+       /**
+        * Default constructor
+        */
+       public PizzaAdminMobileProviderSessionBean () {
+               // Call super constructor
+               super();
+       }
+
+       @Override
+       public MobileProvider addMobileProvider (final MobileProvider mobileProvider) throws MobileProviderAlreadyAddedException {
+               // Log trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addMobileProvider: mobileProvider={1} - CALLED!", this.getClass().getSimpleName(), mobileProvider)); //NOI18N
+
+               // Is the instance valid?
+               if (null == mobileProvider) {
+                       // Throw NPE
+                       throw new NullPointerException("mobileProvider is null"); //NOI18N
+               } else if (mobileProvider.getProviderDialPrefix() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("mobileProvider.providerDialPrefix is null"); //NOI18N
+               } else if (mobileProvider.getProviderDialPrefix() < 1) {
+                       // Not valid
+                       throw new IllegalArgumentException(MessageFormat.format("mobileProvider.providerDialPrefix={0} is not valid.", mobileProvider.getProviderDialPrefix())); //NOI18N
+               } else if (mobileProvider.getProviderCountry() == null) {
+                       // Throw again a NPE
+                       throw new NullPointerException("mobileProvider.providerCountry is null"); //NOI18N
+               } else if (mobileProvider.getProviderMailPattern() == null) {
+                       // ... and again ...
+                       throw new NullPointerException("mobileProvider.providerMailPattern is null"); //NOI18N
+               } else if (mobileProvider.getProviderMailPattern().isEmpty()) {
+                       // Empty pattern set (not allowed)
+                       throw new IllegalArgumentException("mobileProvider.providerMailPattern is empty."); //NOI18N
+               } else if (!mobileProvider.getProviderMailPattern().contains("%s")) { //NOI18N
+                       // No place-holder found
+                       throw new IllegalArgumentException(MessageFormat.format("mobileProvider.providerMailPattern={0} does not contain '%s' which is need to be replaced with the full mobile number.", mobileProvider.getProviderMailPattern())); //NOI18N
+               } else if (mobileProvider.getProviderName() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("mobileProvider.providerName is null"); //NOI18N
+               } else if (mobileProvider.getProviderName().isEmpty()) {
+                       // Empty name is not allowed
+                       throw new IllegalArgumentException("mobileProvider.providerName is empty"); //NOI18N
+               }
+
+               // Set creation timestamp
+               mobileProvider.setProviderEntryCreated(new GregorianCalendar());
+
+               // Persist it
+               this.getEntityManager().persist(mobileProvider);
+
+               // Log trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addMobileProvider: mobileProvider.providerId={1} - EXIT!", this.getClass().getSimpleName(), mobileProvider.getProviderId())); //NOI18N
+
+               // Return updated
+               return mobileProvider;
+       }
+
+}
diff --git a/src/java/org/mxchange/jphone/model/phonenumbers/mobileprovider/PizzaMobileProviderSingletonBean.java b/src/java/org/mxchange/jphone/model/phonenumbers/mobileprovider/PizzaMobileProviderSingletonBean.java
new file mode 100644 (file)
index 0000000..194f439
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2016, 2017 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jphone.model.phonenumbers.mobileprovider;
+
+import java.text.MessageFormat;
+import java.util.List;
+import javax.ejb.Singleton;
+import javax.ejb.Startup;
+import javax.persistence.Query;
+import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
+
+/**
+ * A singleton EJB for mobile provider informations
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Startup
+@Singleton (name = "mobileProvider", description = "A singleton session-scoped bean for SMS provider informations")
+public class PizzaMobileProviderSingletonBean extends BasePizzaDatabaseBean implements MobileProviderSingletonBeanRemote {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 15_846_983_298_691_207L;
+
+       /**
+        * Default constructor
+        */
+       public PizzaMobileProviderSingletonBean () {
+               // Call super constructor
+               super();
+       }
+
+       @Override
+       @SuppressWarnings ("unchecked")
+       public List<MobileProvider> allMobileProviders () {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allMobileProvider: CALLED!", this.getClass().getSimpleName())); //NOI18N
+
+               // Init query
+               final Query query = this.getEntityManager().createNamedQuery("AllMobileProvider", CellphoneProvider.class); //NOI18N
+
+               // Get list from it
+               final List<MobileProvider> mobileProviders = query.getResultList();
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allMobileProvider: mobileProviders.size()={1} - EXIT!", this.getClass().getSimpleName(), mobileProviders.size())); //NOI18N
+
+               // Return it
+               return mobileProviders;
+       }
+
+}
diff --git a/src/java/org/mxchange/jphone/model/phonenumbers/phone/PizzaAdminPhoneSessionBean.java b/src/java/org/mxchange/jphone/model/phonenumbers/phone/PizzaAdminPhoneSessionBean.java
new file mode 100644 (file)
index 0000000..360720c
--- /dev/null
@@ -0,0 +1,358 @@
+/*
+ * Copyright (C) 2016, 2017 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jphone.model.phonenumbers.phone;
+
+import java.text.MessageFormat;
+import java.util.GregorianCalendar;
+import javax.ejb.Stateless;
+import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
+import org.mxchange.jphone.model.phonenumbers.fax.FaxNumbers;
+import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber;
+import org.mxchange.jphone.model.phonenumbers.landline.LandLineNumbers;
+import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber;
+import org.mxchange.jphone.model.phonenumbers.mobile.MobileNumbers;
+import org.mxchange.jphone.model.phonenumbers.phone.AdminPhoneSessionBeanRemote;
+import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
+
+/**
+ * An EJB for administrative phone purposes
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Stateless (name = "adminPhone", description = "An administrative bean handling phone data")
+public class PizzaAdminPhoneSessionBean extends BasePizzaDatabaseBean implements AdminPhoneSessionBeanRemote {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 18_597_165_817_401_853L;
+
+       /**
+        * Default constructor
+        */
+       public PizzaAdminPhoneSessionBean () {
+               // Call super constructor
+               super();
+       }
+
+       @Override
+       public void deleteFaxData (final DialableFaxNumber faxNumber) {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.deleteFaxData: faxNumber={1} - CALLED!", this.getClass().getSimpleName(), faxNumber));
+
+               // Is all data set
+               if (faxNumber == null) {
+                       // Not set, throw NPE
+                       throw new NullPointerException("faxNumber is null"); //NOI18N
+               } else if (faxNumber.getPhoneId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("faxNumber.phoneId is null"); //NOI18N
+               } else if (faxNumber.getPhoneId() < 1) {
+                       // Invalid number
+                       throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneId={0} is not valid", faxNumber.getPhoneId())); //NOI18N
+               } else if (faxNumber.getPhoneCountry() == null) {
+                       // Throw NPE
+                       throw new NullPointerException("faxNumber.phoneCountry is null"); //NOI18N
+               } else if (faxNumber.getPhoneCountry().getCountryId() == null) {
+                       // Throw NPE
+                       throw new NullPointerException("faxNumber.phoneCountry.countryId is null"); //NOI18N
+               } else if (faxNumber.getPhoneCountry().getCountryId() < 1) {
+                       // Throw NPE
+                       throw new NullPointerException(MessageFormat.format("faxNumber.phoneCountry.countryId={0} is not valid", faxNumber.getPhoneCountry().getCountryId())); //NOI18N
+               } else if (faxNumber.getPhoneAreaCode() == null) {
+                       // ... throw again
+                       throw new NullPointerException("faxNumber.phoneAreaCode is null"); //NOI18N
+               } else if (faxNumber.getPhoneAreaCode() < 1) {
+                       // Id not valid
+                       throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneAreaCode={0} is not valid.", faxNumber.getPhoneAreaCode())); //NOI18N
+               } else if (faxNumber.getPhoneNumber() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("faxNumber.phoneNumber is null"); //NOI18N
+               } else if (faxNumber.getPhoneNumber() < 1) {
+                       // Throw NPE again
+                       throw new NullPointerException(MessageFormat.format("faxNumber.phoneNumber={0} is not valid.", faxNumber.getPhoneNumber())); //NOI18N
+               }
+
+               // Get a managed instance
+               final DialableFaxNumber managedNumber = this.getEntityManager().getReference(faxNumber.getClass(), faxNumber.getPhoneId());
+
+               // Remove it from database
+               this.getEntityManager().remove(managedNumber);
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.deleteMobileData: EXIT!", this.getClass().getSimpleName()));
+       }
+
+       @Override
+       public void deleteLandLineData (final DialableLandLineNumber landLineNumber) {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.deleteLandLineData: landLineNumber={1} - CALLED!", this.getClass().getSimpleName(), landLineNumber));
+
+               // Is all data set
+               if (landLineNumber == null) {
+                       // Not set, throw NPE
+                       throw new NullPointerException("landLineNumber is null"); //NOI18N
+               } else if (landLineNumber.getPhoneId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("landLineNumber.phoneId is null"); //NOI18N
+               } else if (landLineNumber.getPhoneId() < 1) {
+                       // Invalid number
+                       throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneId={0} is not valid", landLineNumber.getPhoneId())); //NOI18N
+               } else if (landLineNumber.getPhoneCountry() == null) {
+                       // Throw NPE
+                       throw new NullPointerException("landLineNumber.phoneCountry is null"); //NOI18N
+               } else if (landLineNumber.getPhoneCountry().getCountryId() == null) {
+                       // Throw NPE
+                       throw new NullPointerException("landLineNumber.phoneCountry.countryId is null"); //NOI18N
+               } else if (landLineNumber.getPhoneCountry().getCountryId() < 1) {
+                       // Throw NPE
+                       throw new NullPointerException(MessageFormat.format("landLineNumber.phoneCountry.countryId={0} is not valid", landLineNumber.getPhoneCountry().getCountryId())); //NOI18N
+               } else if (landLineNumber.getPhoneAreaCode() == null) {
+                       // ... throw again
+                       throw new NullPointerException("landLineNumber.phoneAreaCode is null"); //NOI18N
+               } else if (landLineNumber.getPhoneAreaCode() < 1) {
+                       // Id not valid
+                       throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneAreaCode={0} is not valid.", landLineNumber.getPhoneAreaCode())); //NOI18N
+               } else if (landLineNumber.getPhoneNumber() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("landLineNumber.phoneNumber is null"); //NOI18N
+               } else if (landLineNumber.getPhoneNumber() < 1) {
+                       // Throw NPE again
+                       throw new NullPointerException(MessageFormat.format("landLineNumber.phoneNumber={0} is not valid.", landLineNumber.getPhoneNumber())); //NOI18N
+               }
+
+               // Get a managed instance
+               final DialableLandLineNumber managedNumber = this.getEntityManager().getReference(landLineNumber.getClass(), landLineNumber.getPhoneId());
+
+               // Remove it from database
+               this.getEntityManager().remove(managedNumber);
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.deleteMobileData: EXIT!", this.getClass().getSimpleName()));
+       }
+
+       @Override
+       public void deleteMobileData (final DialableMobileNumber mobileNumber) {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.deleteMobileData: mobileNumber={1} - CALLED!", this.getClass().getSimpleName(), mobileNumber));
+
+               // Is all data set
+               if (null == mobileNumber) {
+                       // Not set, throw NPE
+                       throw new NullPointerException("mobileNumber is null"); //NOI18N
+               } else if (mobileNumber.getPhoneId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("mobileNumber.phoneId is null"); //NOI18N
+               } else if (mobileNumber.getPhoneId() < 1) {
+                       // Invalid number
+                       throw new IllegalArgumentException(MessageFormat.format("mobileNumber.phoneId={0} is not valid", mobileNumber.getPhoneId())); //NOI18N
+               } else if (mobileNumber.getMobileProvider() == null) {
+                       // Throw NPE
+                       throw new NullPointerException("mobileNumber.cellphoneProvider is null"); //NOI18N
+               } else if (mobileNumber.getMobileProvider().getProviderId() == null) {
+                       // ... throw again
+                       throw new NullPointerException("mobileNumber.cellphoneProvider.providerId is null"); //NOI18N
+               } else if (mobileNumber.getMobileProvider().getProviderId() < 1) {
+                       // Id not valid
+                       throw new IllegalArgumentException(MessageFormat.format("mobileNumber.cellphoneProvider.providerId={0} is not valid.", mobileNumber.getMobileProvider().getProviderId())); //NOI18N
+               } else if (mobileNumber.getPhoneNumber() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("mobileNumber.phoneNumber is null"); //NOI18N
+               } else if (mobileNumber.getPhoneNumber() < 1) {
+                       // Throw NPE again
+                       throw new NullPointerException(MessageFormat.format("mobileNumber.phoneNumber={0} is not valid.", mobileNumber.getPhoneNumber())); //NOI18N
+               }
+
+               // Get a managed instance
+               final DialableMobileNumber managedNumber = this.getEntityManager().getReference(mobileNumber.getClass(), mobileNumber.getPhoneId());
+
+               // Remove it from database
+               this.getEntityManager().remove(managedNumber);
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.deleteMobileData: EXIT!", this.getClass().getSimpleName()));
+       }
+
+       @Override
+       public DialableFaxNumber updateFaxData (final DialableFaxNumber faxNumber) {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateFaxData: faxNumber={1} - CALLED!", this.getClass().getSimpleName(), faxNumber));
+
+               // Is all data set
+               if (faxNumber == null) {
+                       // Not set, throw NPE
+                       throw new NullPointerException("faxNumber is null"); //NOI18N
+               } else if (faxNumber.getPhoneId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("faxNumber.phoneId is null"); //NOI18N
+               } else if (faxNumber.getPhoneId() < 1) {
+                       // Invalid number
+                       throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneId={0} is not valid", faxNumber.getPhoneId())); //NOI18N
+               } else if (faxNumber.getPhoneCountry() == null) {
+                       // Throw NPE
+                       throw new NullPointerException("faxNumber.phoneCountry is null"); //NOI18N
+               } else if (faxNumber.getPhoneCountry().getCountryId() == null) {
+                       // Throw NPE
+                       throw new NullPointerException("faxNumber.phoneCountry.countryId is null"); //NOI18N
+               } else if (faxNumber.getPhoneCountry().getCountryId() < 1) {
+                       // Throw NPE
+                       throw new NullPointerException(MessageFormat.format("faxNumber.phoneCountry.countryId={0} is not valid", faxNumber.getPhoneCountry().getCountryId())); //NOI18N
+               } else if (faxNumber.getPhoneAreaCode() == null) {
+                       // ... throw again
+                       throw new NullPointerException("faxNumber.phoneAreaCode is null"); //NOI18N
+               } else if (faxNumber.getPhoneAreaCode() < 1) {
+                       // Id not valid
+                       throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneAreaCode={0} is not valid.", faxNumber.getPhoneAreaCode())); //NOI18N
+               } else if (faxNumber.getPhoneNumber() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("faxNumber.phoneNumber is null"); //NOI18N
+               } else if (faxNumber.getPhoneNumber() < 1) {
+                       // Throw NPE again
+                       throw new NullPointerException(MessageFormat.format("faxNumber.phoneNumber={0} is not valid.", faxNumber.getPhoneNumber())); //NOI18N
+               }
+
+               // Get contact from it and find it
+               final DialableFaxNumber managedNumber = this.getEntityManager().find(faxNumber.getClass(), faxNumber.getPhoneId());
+
+               // Should be found
+               assert (managedNumber instanceof DialableFaxNumber) : MessageFormat.format("Cell phone number with id {0} not found, but should be.", faxNumber.getPhoneId()); //NOI18N
+
+               // Debug message
+               this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.updateFaxData: managedNumber.phoneId={1}", this.getClass().getSimpleName(), managedNumber.getPhoneId())); //NOI18N
+
+               // Set updated timestamp
+               FaxNumbers.copyAll(faxNumber, managedNumber);
+               managedNumber.setPhoneEntryUpdated(new GregorianCalendar());
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateFaxData: managedNumber={1} - EXIT!", this.getClass().getSimpleName(), managedNumber)); //NOI18N
+
+               // Return it
+               return managedNumber;
+       }
+
+       @Override
+       public DialableLandLineNumber updateLandLineData (final DialableLandLineNumber landLineNumber) {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateLandLineData: landLineNumber={1} - CALLED!", this.getClass().getSimpleName(), landLineNumber));
+
+               // Is all data set
+               if (landLineNumber == null) {
+                       // Not set, throw NPE
+                       throw new NullPointerException("landLineNumber is null"); //NOI18N
+               } else if (landLineNumber.getPhoneId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("landLineNumber.phoneId is null"); //NOI18N
+               } else if (landLineNumber.getPhoneId() < 1) {
+                       // Invalid number
+                       throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneId={0} is not valid", landLineNumber.getPhoneId())); //NOI18N
+               } else if (landLineNumber.getPhoneCountry() == null) {
+                       // Throw NPE
+                       throw new NullPointerException("landLineNumber.phoneCountry is null"); //NOI18N
+               } else if (landLineNumber.getPhoneCountry().getCountryId() == null) {
+                       // Throw NPE
+                       throw new NullPointerException("landLineNumber.phoneCountry.countryId is null"); //NOI18N
+               } else if (landLineNumber.getPhoneCountry().getCountryId() < 1) {
+                       // Throw NPE
+                       throw new NullPointerException(MessageFormat.format("landLineNumber.phoneCountry.countryId={0} is not valid", landLineNumber.getPhoneCountry().getCountryId())); //NOI18N
+               } else if (landLineNumber.getPhoneAreaCode() == null) {
+                       // ... throw again
+                       throw new NullPointerException("landLineNumber.phoneAreaCode is null"); //NOI18N
+               } else if (landLineNumber.getPhoneAreaCode() < 1) {
+                       // Id not valid
+                       throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneAreaCode={0} is not valid.", landLineNumber.getPhoneAreaCode())); //NOI18N
+               } else if (landLineNumber.getPhoneNumber() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("landLineNumber.phoneNumber is null"); //NOI18N
+               } else if (landLineNumber.getPhoneNumber() < 1) {
+                       // Throw NPE again
+                       throw new NullPointerException(MessageFormat.format("landLineNumber.phoneNumber={0} is not valid.", landLineNumber.getPhoneNumber())); //NOI18N
+               }
+
+               // Get contact from it and find it
+               final DialableLandLineNumber managedNumber = this.getEntityManager().find(landLineNumber.getClass(), landLineNumber.getPhoneId());
+
+               // Should be found
+               assert (managedNumber instanceof DialableLandLineNumber) : MessageFormat.format("Cell phone number with id {0} not found, but should be.", landLineNumber.getPhoneId()); //NOI18N
+
+               // Debug message
+               this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.updateLandLineData: managedNumber.phoneId={1}", this.getClass().getSimpleName(), managedNumber.getPhoneId())); //NOI18N
+
+               // Set updated timestamp
+               LandLineNumbers.copyAll(landLineNumber, managedNumber);
+               managedNumber.setPhoneEntryUpdated(new GregorianCalendar());
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateLandLineData: managedNumber={1} - EXIT!", this.getClass().getSimpleName(), managedNumber)); //NOI18N
+
+               // Return it
+               return managedNumber;
+       }
+
+       @Override
+       public DialableMobileNumber updateMobileData (final DialableMobileNumber mobileNumber) {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateMobileData: mobileNumber={1} - CALLED!", this.getClass().getSimpleName(), mobileNumber));
+
+               // Is all data set
+               if (null == mobileNumber) {
+                       // Not set, throw NPE
+                       throw new NullPointerException("mobileNumber is null"); //NOI18N
+               } else if (mobileNumber.getPhoneId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("mobileNumber.phoneId is null"); //NOI18N
+               } else if (mobileNumber.getPhoneId() < 1) {
+                       // Invalid number
+                       throw new IllegalArgumentException(MessageFormat.format("mobileNumber.phoneId={0} is not valid", mobileNumber.getPhoneId())); //NOI18N
+               } else if (mobileNumber.getMobileProvider() == null) {
+                       // Throw NPE
+                       throw new NullPointerException("mobileNumber.cellphoneProvider is null"); //NOI18N
+               } else if (mobileNumber.getMobileProvider().getProviderId() == null) {
+                       // ... throw again
+                       throw new NullPointerException("mobileNumber.cellphoneProvider.providerId is null"); //NOI18N
+               } else if (mobileNumber.getMobileProvider().getProviderId() < 1) {
+                       // Id not valid
+                       throw new IllegalArgumentException(MessageFormat.format("mobileNumber.cellphoneProvider.providerId={0} is not valid.", mobileNumber.getMobileProvider().getProviderId())); //NOI18N
+               } else if (mobileNumber.getPhoneNumber() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("mobileNumber.phoneNumber is null"); //NOI18N
+               } else if (mobileNumber.getPhoneNumber() < 1) {
+                       // Throw NPE again
+                       throw new NullPointerException(MessageFormat.format("mobileNumber.phoneNumber={0} is not valid.", mobileNumber.getPhoneNumber())); //NOI18N
+               }
+
+               // Get contact from it and find it
+               final DialableMobileNumber managedNumber = this.getEntityManager().find(mobileNumber.getClass(), mobileNumber.getPhoneId());
+
+               // Should be found
+               assert (managedNumber instanceof DialableMobileNumber) : MessageFormat.format("Cell phone number with id {0} not found, but should be.", mobileNumber.getPhoneId()); //NOI18N
+
+               // Debug message
+               this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.updateMobileData: managedNumber.phoneId={1}", this.getClass().getSimpleName(), managedNumber.getPhoneId())); //NOI18N
+
+               // Set updated timestamp
+               MobileNumbers.copyAll(mobileNumber, managedNumber);
+               managedNumber.setPhoneEntryUpdated(new GregorianCalendar());
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateMobileData: managedNumber={1} - EXIT!", this.getClass().getSimpleName(), managedNumber)); //NOI18N
+
+               // Return it
+               return managedNumber;
+       }
+
+}
diff --git a/src/java/org/mxchange/jphone/model/phonenumbers/phone/PizzaPhoneSessionBean.java b/src/java/org/mxchange/jphone/model/phonenumbers/phone/PizzaPhoneSessionBean.java
new file mode 100644 (file)
index 0000000..c3260d8
--- /dev/null
@@ -0,0 +1,228 @@
+/*
+ * Copyright (C) 2016, 2017 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jphone.model.phonenumbers.phone;
+
+import java.text.MessageFormat;
+import java.util.List;
+import javax.ejb.Stateless;
+import javax.persistence.NoResultException;
+import javax.persistence.Query;
+import org.mxchange.jphone.exceptions.PhoneEntityNotFoundException;
+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.jphone.model.phonenumbers.mobile.DialableMobileNumber;
+import org.mxchange.jphone.model.phonenumbers.mobile.MobileNumber;
+import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
+
+/**
+ * A general phone EJB
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Stateless (name = "phone", description = "A bean handling phone data")
+public class PizzaPhoneSessionBean extends BasePizzaDatabaseBean implements PhoneSessionBeanRemote {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 134_945_698_127_601L;
+
+       /**
+        * Default constructor
+        */
+       public PizzaPhoneSessionBean () {
+               // Call super constructor
+               super();
+       }
+
+       @SuppressWarnings ("unchecked")
+       @Override
+       public List<DialableFaxNumber> allFaxNumbers () {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allFaxNumbers: CALLED!", this.getClass().getSimpleName())); //NOI18N
+
+               // Get query
+               final Query query = this.getEntityManager().createNamedQuery("AllFaxNumbers", FaxNumber.class); //NOI18N
+
+               // Get list from it
+               final List<DialableFaxNumber> list = query.getResultList();
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allFaxNumbers: list.size()={1} - EXIT!", this.getClass().getSimpleName(), list.size())); //NOI18N
+
+               // Return it
+               return list;
+       }
+
+       @SuppressWarnings ("unchecked")
+       @Override
+       public List<DialableLandLineNumber> allLandLineNumbers () {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allLandLineNumbers: CALLED!", this.getClass().getSimpleName())); //NOI18N
+
+               // Get query
+               final Query query = this.getEntityManager().createNamedQuery("AllLandLineNumbers", LandLineNumber.class); //NOI18N
+
+               // Get list from it
+               final List<DialableLandLineNumber> list = query.getResultList();
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allLandLineNumbers: list.size()={1} - EXIT!", this.getClass().getSimpleName(), list.size())); //NOI18N
+
+               // Return it
+               return list;
+       }
+
+       @SuppressWarnings ("unchecked")
+       @Override
+       public List<DialableMobileNumber> allMobileNumbers () {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allMobileNumbers: CALLED!", this.getClass().getSimpleName())); //NOI18N
+
+               // Get query
+               final Query query = this.getEntityManager().createNamedQuery("AllMobileNumbers", MobileNumber.class); //NOI18N
+
+               // Get list from it
+               final List<DialableMobileNumber> list = query.getResultList();
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allMobileNumbers: list.size()={1} - EXIT!", this.getClass().getSimpleName(), list.size())); //NOI18N
+
+               // Return it
+               return list;
+       }
+
+       @Override
+       public DialableFaxNumber findFaxNumberById (final Long faxNumberId) throws PhoneEntityNotFoundException {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findFaxNumberById: mobileNumberId={1} - CALLED!", this.getClass().getSimpleName(), faxNumberId)); //NOI18N
+
+               // The id number should be valid
+               if (null == faxNumberId) {
+                       // Throw NPE
+                       throw new NullPointerException("faxNumberId is null"); //NOI18N
+               } else if (faxNumberId < 1) {
+                       // Not valid
+                       throw new IllegalArgumentException(MessageFormat.format("faxNumberId={0} is not valid.", faxNumberId)); //NOI18N
+               }
+
+               // Now find it
+               final Query query = this.getEntityManager().createNamedQuery("SearchFaxNumberId", FaxNumber.class); //NOI18N
+
+               // Set parameter
+               query.setParameter("faxNumberId", faxNumberId); //NOI18N
+
+               // Init instance
+               final DialableFaxNumber faxNumber;
+
+               // Try to get a result
+               try {
+                       // Get a single result
+                       faxNumber = (DialableFaxNumber) query.getSingleResult();
+               } catch (NoResultException ex) {
+                       // The entry was not found, so throw it again
+                       throw new PhoneEntityNotFoundException(faxNumberId, ex);
+               }
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findFaxNumberById: mobile={1} - EXIT!", this.getClass().getSimpleName(), faxNumber)); //NOI18N
+
+               // Return found instance
+               return faxNumber;
+       }
+
+       @Override
+       public DialableLandLineNumber findLandLineNumberById (final Long landLineNumberId) throws PhoneEntityNotFoundException {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findLandLineNumberById: mobileNumberId={1} - CALLED!", this.getClass().getSimpleName(), landLineNumberId)); //NOI18N
+
+               // The id number should be valid
+               if (null == landLineNumberId) {
+                       // Throw NPE
+                       throw new NullPointerException("landLineNumberId is null"); //NOI18N
+               } else if (landLineNumberId < 1) {
+                       // Not valid
+                       throw new IllegalArgumentException(MessageFormat.format("landLineNumberId={0} is not valid.", landLineNumberId)); //NOI18N
+               }
+
+               // Now find it
+               final Query query = this.getEntityManager().createNamedQuery("SearchLandLineNumberId", LandLineNumber.class); //NOI18N
+
+               // Set parameter
+               query.setParameter("landLineNumberId", landLineNumberId); //NOI18N
+
+               // Init instance
+               final DialableLandLineNumber landLineNumber;
+
+               // Try to get a result
+               try {
+                       // Get a single result
+                       landLineNumber = (DialableLandLineNumber) query.getSingleResult();
+               } catch (NoResultException ex) {
+                       // The entry was not found, so throw it again
+                       throw new PhoneEntityNotFoundException(landLineNumberId, ex);
+               }
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findLandLineNumberById: mobile={1} - EXIT!", this.getClass().getSimpleName(), landLineNumber)); //NOI18N
+
+               // Return found instance
+               return landLineNumber;
+       }
+
+       @Override
+       public DialableMobileNumber findMobileNumberById (final Long mobileNumberId) throws PhoneEntityNotFoundException {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findMobileNumberById: mobileNumberId={1} - CALLED!", this.getClass().getSimpleName(), mobileNumberId)); //NOI18N
+
+               // The id number should be valid
+               if (null == mobileNumberId) {
+                       // Throw NPE
+                       throw new NullPointerException("mobileNumberId is null"); //NOI18N
+               } else if (mobileNumberId < 1) {
+                       // Not valid
+                       throw new IllegalArgumentException(MessageFormat.format("mobileNumberId={0} is not valid.", mobileNumberId)); //NOI18N
+               }
+
+               // Now find it
+               final Query query = this.getEntityManager().createNamedQuery("SearchMobileNumberId", MobileNumber.class); //NOI18N
+
+               // Set parameter
+               query.setParameter("mobileNumberId", mobileNumberId); //NOI18N
+
+               // Init instance
+               final DialableMobileNumber mobile;
+
+               // Try to get a result
+               try {
+                       // Get a single result
+                       mobile = (DialableMobileNumber) query.getSingleResult();
+               } catch (NoResultException ex) {
+                       // The entry was not found, so throw it again
+                       throw new PhoneEntityNotFoundException(mobileNumberId, ex);
+               }
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findMobileNumberById: mobile={1} - EXIT!", this.getClass().getSimpleName(), mobile)); //NOI18N
+
+               // Return found instance
+               return mobile;
+       }
+
+}
diff --git a/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/PizzaAdminMobileProviderSessionBean.java b/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/PizzaAdminMobileProviderSessionBean.java
deleted file mode 100644 (file)
index 7217458..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (C) 2016, 2017 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jphone.phonenumbers.mobileprovider;
-
-import java.text.MessageFormat;
-import java.util.GregorianCalendar;
-import javax.ejb.Stateless;
-import org.mxchange.jphone.exceptions.MobileProviderAlreadyAddedException;
-import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
-
-/**
- * Administrative singleton EJB for mobile provider informations
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Stateless (name = "adminMobileProvider", description = "A singleton session-scoped bean for mobile provider informations, admin-edition")
-public class PizzaAdminMobileProviderSessionBean extends BasePizzaDatabaseBean implements AdminMobileProviderSessionBeanRemote {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 15_846_983_298_691_207L;
-
-       /**
-        * Default constructor
-        */
-       public PizzaAdminMobileProviderSessionBean () {
-               // Call super constructor
-               super();
-       }
-
-       @Override
-       public MobileProvider addMobileProvider (final MobileProvider mobileProvider) throws MobileProviderAlreadyAddedException {
-               // Log trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addMobileProvider: mobileProvider={1} - CALLED!", this.getClass().getSimpleName(), mobileProvider)); //NOI18N
-
-               // Is the instance valid?
-               if (null == mobileProvider) {
-                       // Throw NPE
-                       throw new NullPointerException("mobileProvider is null"); //NOI18N
-               } else if (mobileProvider.getProviderDialPrefix() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("mobileProvider.providerDialPrefix is null"); //NOI18N
-               } else if (mobileProvider.getProviderDialPrefix() < 1) {
-                       // Not valid
-                       throw new IllegalArgumentException(MessageFormat.format("mobileProvider.providerDialPrefix={0} is not valid.", mobileProvider.getProviderDialPrefix())); //NOI18N
-               } else if (mobileProvider.getProviderCountry() == null) {
-                       // Throw again a NPE
-                       throw new NullPointerException("mobileProvider.providerCountry is null"); //NOI18N
-               } else if (mobileProvider.getProviderMailPattern() == null) {
-                       // ... and again ...
-                       throw new NullPointerException("mobileProvider.providerMailPattern is null"); //NOI18N
-               } else if (mobileProvider.getProviderMailPattern().isEmpty()) {
-                       // Empty pattern set (not allowed)
-                       throw new IllegalArgumentException("mobileProvider.providerMailPattern is empty."); //NOI18N
-               } else if (!mobileProvider.getProviderMailPattern().contains("%s")) { //NOI18N
-                       // No place-holder found
-                       throw new IllegalArgumentException(MessageFormat.format("mobileProvider.providerMailPattern={0} does not contain '%s' which is need to be replaced with the full mobile number.", mobileProvider.getProviderMailPattern())); //NOI18N
-               } else if (mobileProvider.getProviderName() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("mobileProvider.providerName is null"); //NOI18N
-               } else if (mobileProvider.getProviderName().isEmpty()) {
-                       // Empty name is not allowed
-                       throw new IllegalArgumentException("mobileProvider.providerName is empty"); //NOI18N
-               }
-
-               // Set creation timestamp
-               mobileProvider.setProviderEntryCreated(new GregorianCalendar());
-
-               // Persist it
-               this.getEntityManager().persist(mobileProvider);
-
-               // Log trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addMobileProvider: mobileProvider.providerId={1} - EXIT!", this.getClass().getSimpleName(), mobileProvider.getProviderId())); //NOI18N
-
-               // Return updated
-               return mobileProvider;
-       }
-
-}
diff --git a/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/PizzaMobileProviderSingletonBean.java b/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/PizzaMobileProviderSingletonBean.java
deleted file mode 100644 (file)
index 222842c..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) 2016, 2017 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jphone.phonenumbers.mobileprovider;
-
-import java.text.MessageFormat;
-import java.util.List;
-import javax.ejb.Singleton;
-import javax.ejb.Startup;
-import javax.persistence.Query;
-import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
-
-/**
- * A singleton EJB for mobile provider informations
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Startup
-@Singleton (name = "mobileProvider", description = "A singleton session-scoped bean for SMS provider informations")
-public class PizzaMobileProviderSingletonBean extends BasePizzaDatabaseBean implements MobileProviderSingletonBeanRemote {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 15_846_983_298_691_207L;
-
-       /**
-        * Default constructor
-        */
-       public PizzaMobileProviderSingletonBean () {
-               // Call super constructor
-               super();
-       }
-
-       @Override
-       @SuppressWarnings ("unchecked")
-       public List<MobileProvider> allMobileProviders () {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allMobileProvider: CALLED!", this.getClass().getSimpleName())); //NOI18N
-
-               // Init query
-               final Query query = this.getEntityManager().createNamedQuery("AllMobileProvider", CellphoneProvider.class); //NOI18N
-
-               // Get list from it
-               final List<MobileProvider> mobileProviders = query.getResultList();
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allMobileProvider: mobileProviders.size()={1} - EXIT!", this.getClass().getSimpleName(), mobileProviders.size())); //NOI18N
-
-               // Return it
-               return mobileProviders;
-       }
-
-}
diff --git a/src/java/org/mxchange/jphone/phonenumbers/phone/PizzaAdminPhoneSessionBean.java b/src/java/org/mxchange/jphone/phonenumbers/phone/PizzaAdminPhoneSessionBean.java
deleted file mode 100644 (file)
index f1a9f39..0000000
+++ /dev/null
@@ -1,357 +0,0 @@
-/*
- * Copyright (C) 2016, 2017 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jphone.phonenumbers.phone;
-
-import java.text.MessageFormat;
-import java.util.GregorianCalendar;
-import javax.ejb.Stateless;
-import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
-import org.mxchange.jphone.phonenumbers.fax.FaxNumbers;
-import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
-import org.mxchange.jphone.phonenumbers.landline.LandLineNumbers;
-import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
-import org.mxchange.jphone.phonenumbers.mobile.MobileNumbers;
-import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
-
-/**
- * An EJB for administrative phone purposes
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Stateless (name = "adminPhone", description = "An administrative bean handling phone data")
-public class PizzaAdminPhoneSessionBean extends BasePizzaDatabaseBean implements AdminPhoneSessionBeanRemote {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 18_597_165_817_401_853L;
-
-       /**
-        * Default constructor
-        */
-       public PizzaAdminPhoneSessionBean () {
-               // Call super constructor
-               super();
-       }
-
-       @Override
-       public void deleteFaxData (final DialableFaxNumber faxNumber) {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.deleteFaxData: faxNumber={1} - CALLED!", this.getClass().getSimpleName(), faxNumber));
-
-               // Is all data set
-               if (faxNumber == null) {
-                       // Not set, throw NPE
-                       throw new NullPointerException("faxNumber is null"); //NOI18N
-               } else if (faxNumber.getPhoneId() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("faxNumber.phoneId is null"); //NOI18N
-               } else if (faxNumber.getPhoneId() < 1) {
-                       // Invalid number
-                       throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneId={0} is not valid", faxNumber.getPhoneId())); //NOI18N
-               } else if (faxNumber.getPhoneCountry() == null) {
-                       // Throw NPE
-                       throw new NullPointerException("faxNumber.phoneCountry is null"); //NOI18N
-               } else if (faxNumber.getPhoneCountry().getCountryId() == null) {
-                       // Throw NPE
-                       throw new NullPointerException("faxNumber.phoneCountry.countryId is null"); //NOI18N
-               } else if (faxNumber.getPhoneCountry().getCountryId() < 1) {
-                       // Throw NPE
-                       throw new NullPointerException(MessageFormat.format("faxNumber.phoneCountry.countryId={0} is not valid", faxNumber.getPhoneCountry().getCountryId())); //NOI18N
-               } else if (faxNumber.getPhoneAreaCode() == null) {
-                       // ... throw again
-                       throw new NullPointerException("faxNumber.phoneAreaCode is null"); //NOI18N
-               } else if (faxNumber.getPhoneAreaCode() < 1) {
-                       // Id not valid
-                       throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneAreaCode={0} is not valid.", faxNumber.getPhoneAreaCode())); //NOI18N
-               } else if (faxNumber.getPhoneNumber() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("faxNumber.phoneNumber is null"); //NOI18N
-               } else if (faxNumber.getPhoneNumber() < 1) {
-                       // Throw NPE again
-                       throw new NullPointerException(MessageFormat.format("faxNumber.phoneNumber={0} is not valid.", faxNumber.getPhoneNumber())); //NOI18N
-               }
-
-               // Get a managed instance
-               final DialableFaxNumber managedNumber = this.getEntityManager().getReference(faxNumber.getClass(), faxNumber.getPhoneId());
-
-               // Remove it from database
-               this.getEntityManager().remove(managedNumber);
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.deleteMobileData: EXIT!", this.getClass().getSimpleName()));
-       }
-
-       @Override
-       public void deleteLandLineData (final DialableLandLineNumber landLineNumber) {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.deleteLandLineData: landLineNumber={1} - CALLED!", this.getClass().getSimpleName(), landLineNumber));
-
-               // Is all data set
-               if (landLineNumber == null) {
-                       // Not set, throw NPE
-                       throw new NullPointerException("landLineNumber is null"); //NOI18N
-               } else if (landLineNumber.getPhoneId() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("landLineNumber.phoneId is null"); //NOI18N
-               } else if (landLineNumber.getPhoneId() < 1) {
-                       // Invalid number
-                       throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneId={0} is not valid", landLineNumber.getPhoneId())); //NOI18N
-               } else if (landLineNumber.getPhoneCountry() == null) {
-                       // Throw NPE
-                       throw new NullPointerException("landLineNumber.phoneCountry is null"); //NOI18N
-               } else if (landLineNumber.getPhoneCountry().getCountryId() == null) {
-                       // Throw NPE
-                       throw new NullPointerException("landLineNumber.phoneCountry.countryId is null"); //NOI18N
-               } else if (landLineNumber.getPhoneCountry().getCountryId() < 1) {
-                       // Throw NPE
-                       throw new NullPointerException(MessageFormat.format("landLineNumber.phoneCountry.countryId={0} is not valid", landLineNumber.getPhoneCountry().getCountryId())); //NOI18N
-               } else if (landLineNumber.getPhoneAreaCode() == null) {
-                       // ... throw again
-                       throw new NullPointerException("landLineNumber.phoneAreaCode is null"); //NOI18N
-               } else if (landLineNumber.getPhoneAreaCode() < 1) {
-                       // Id not valid
-                       throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneAreaCode={0} is not valid.", landLineNumber.getPhoneAreaCode())); //NOI18N
-               } else if (landLineNumber.getPhoneNumber() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("landLineNumber.phoneNumber is null"); //NOI18N
-               } else if (landLineNumber.getPhoneNumber() < 1) {
-                       // Throw NPE again
-                       throw new NullPointerException(MessageFormat.format("landLineNumber.phoneNumber={0} is not valid.", landLineNumber.getPhoneNumber())); //NOI18N
-               }
-
-               // Get a managed instance
-               final DialableLandLineNumber managedNumber = this.getEntityManager().getReference(landLineNumber.getClass(), landLineNumber.getPhoneId());
-
-               // Remove it from database
-               this.getEntityManager().remove(managedNumber);
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.deleteMobileData: EXIT!", this.getClass().getSimpleName()));
-       }
-
-       @Override
-       public void deleteMobileData (final DialableMobileNumber mobileNumber) {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.deleteMobileData: mobileNumber={1} - CALLED!", this.getClass().getSimpleName(), mobileNumber));
-
-               // Is all data set
-               if (null == mobileNumber) {
-                       // Not set, throw NPE
-                       throw new NullPointerException("mobileNumber is null"); //NOI18N
-               } else if (mobileNumber.getPhoneId() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("mobileNumber.phoneId is null"); //NOI18N
-               } else if (mobileNumber.getPhoneId() < 1) {
-                       // Invalid number
-                       throw new IllegalArgumentException(MessageFormat.format("mobileNumber.phoneId={0} is not valid", mobileNumber.getPhoneId())); //NOI18N
-               } else if (mobileNumber.getMobileProvider() == null) {
-                       // Throw NPE
-                       throw new NullPointerException("mobileNumber.cellphoneProvider is null"); //NOI18N
-               } else if (mobileNumber.getMobileProvider().getProviderId() == null) {
-                       // ... throw again
-                       throw new NullPointerException("mobileNumber.cellphoneProvider.providerId is null"); //NOI18N
-               } else if (mobileNumber.getMobileProvider().getProviderId() < 1) {
-                       // Id not valid
-                       throw new IllegalArgumentException(MessageFormat.format("mobileNumber.cellphoneProvider.providerId={0} is not valid.", mobileNumber.getMobileProvider().getProviderId())); //NOI18N
-               } else if (mobileNumber.getPhoneNumber() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("mobileNumber.phoneNumber is null"); //NOI18N
-               } else if (mobileNumber.getPhoneNumber() < 1) {
-                       // Throw NPE again
-                       throw new NullPointerException(MessageFormat.format("mobileNumber.phoneNumber={0} is not valid.", mobileNumber.getPhoneNumber())); //NOI18N
-               }
-
-               // Get a managed instance
-               final DialableMobileNumber managedNumber = this.getEntityManager().getReference(mobileNumber.getClass(), mobileNumber.getPhoneId());
-
-               // Remove it from database
-               this.getEntityManager().remove(managedNumber);
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.deleteMobileData: EXIT!", this.getClass().getSimpleName()));
-       }
-
-       @Override
-       public DialableFaxNumber updateFaxData (final DialableFaxNumber faxNumber) {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateFaxData: faxNumber={1} - CALLED!", this.getClass().getSimpleName(), faxNumber));
-
-               // Is all data set
-               if (faxNumber == null) {
-                       // Not set, throw NPE
-                       throw new NullPointerException("faxNumber is null"); //NOI18N
-               } else if (faxNumber.getPhoneId() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("faxNumber.phoneId is null"); //NOI18N
-               } else if (faxNumber.getPhoneId() < 1) {
-                       // Invalid number
-                       throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneId={0} is not valid", faxNumber.getPhoneId())); //NOI18N
-               } else if (faxNumber.getPhoneCountry() == null) {
-                       // Throw NPE
-                       throw new NullPointerException("faxNumber.phoneCountry is null"); //NOI18N
-               } else if (faxNumber.getPhoneCountry().getCountryId() == null) {
-                       // Throw NPE
-                       throw new NullPointerException("faxNumber.phoneCountry.countryId is null"); //NOI18N
-               } else if (faxNumber.getPhoneCountry().getCountryId() < 1) {
-                       // Throw NPE
-                       throw new NullPointerException(MessageFormat.format("faxNumber.phoneCountry.countryId={0} is not valid", faxNumber.getPhoneCountry().getCountryId())); //NOI18N
-               } else if (faxNumber.getPhoneAreaCode() == null) {
-                       // ... throw again
-                       throw new NullPointerException("faxNumber.phoneAreaCode is null"); //NOI18N
-               } else if (faxNumber.getPhoneAreaCode() < 1) {
-                       // Id not valid
-                       throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneAreaCode={0} is not valid.", faxNumber.getPhoneAreaCode())); //NOI18N
-               } else if (faxNumber.getPhoneNumber() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("faxNumber.phoneNumber is null"); //NOI18N
-               } else if (faxNumber.getPhoneNumber() < 1) {
-                       // Throw NPE again
-                       throw new NullPointerException(MessageFormat.format("faxNumber.phoneNumber={0} is not valid.", faxNumber.getPhoneNumber())); //NOI18N
-               }
-
-               // Get contact from it and find it
-               final DialableFaxNumber managedNumber = this.getEntityManager().find(faxNumber.getClass(), faxNumber.getPhoneId());
-
-               // Should be found
-               assert (managedNumber instanceof DialableFaxNumber) : MessageFormat.format("Cell phone number with id {0} not found, but should be.", faxNumber.getPhoneId()); //NOI18N
-
-               // Debug message
-               this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.updateFaxData: managedNumber.phoneId={1}", this.getClass().getSimpleName(), managedNumber.getPhoneId())); //NOI18N
-
-               // Set updated timestamp
-               FaxNumbers.copyAll(faxNumber, managedNumber);
-               managedNumber.setPhoneEntryUpdated(new GregorianCalendar());
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateFaxData: managedNumber={1} - EXIT!", this.getClass().getSimpleName(), managedNumber)); //NOI18N
-
-               // Return it
-               return managedNumber;
-       }
-
-       @Override
-       public DialableLandLineNumber updateLandLineData (final DialableLandLineNumber landLineNumber) {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateLandLineData: landLineNumber={1} - CALLED!", this.getClass().getSimpleName(), landLineNumber));
-
-               // Is all data set
-               if (landLineNumber == null) {
-                       // Not set, throw NPE
-                       throw new NullPointerException("landLineNumber is null"); //NOI18N
-               } else if (landLineNumber.getPhoneId() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("landLineNumber.phoneId is null"); //NOI18N
-               } else if (landLineNumber.getPhoneId() < 1) {
-                       // Invalid number
-                       throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneId={0} is not valid", landLineNumber.getPhoneId())); //NOI18N
-               } else if (landLineNumber.getPhoneCountry() == null) {
-                       // Throw NPE
-                       throw new NullPointerException("landLineNumber.phoneCountry is null"); //NOI18N
-               } else if (landLineNumber.getPhoneCountry().getCountryId() == null) {
-                       // Throw NPE
-                       throw new NullPointerException("landLineNumber.phoneCountry.countryId is null"); //NOI18N
-               } else if (landLineNumber.getPhoneCountry().getCountryId() < 1) {
-                       // Throw NPE
-                       throw new NullPointerException(MessageFormat.format("landLineNumber.phoneCountry.countryId={0} is not valid", landLineNumber.getPhoneCountry().getCountryId())); //NOI18N
-               } else if (landLineNumber.getPhoneAreaCode() == null) {
-                       // ... throw again
-                       throw new NullPointerException("landLineNumber.phoneAreaCode is null"); //NOI18N
-               } else if (landLineNumber.getPhoneAreaCode() < 1) {
-                       // Id not valid
-                       throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneAreaCode={0} is not valid.", landLineNumber.getPhoneAreaCode())); //NOI18N
-               } else if (landLineNumber.getPhoneNumber() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("landLineNumber.phoneNumber is null"); //NOI18N
-               } else if (landLineNumber.getPhoneNumber() < 1) {
-                       // Throw NPE again
-                       throw new NullPointerException(MessageFormat.format("landLineNumber.phoneNumber={0} is not valid.", landLineNumber.getPhoneNumber())); //NOI18N
-               }
-
-               // Get contact from it and find it
-               final DialableLandLineNumber managedNumber = this.getEntityManager().find(landLineNumber.getClass(), landLineNumber.getPhoneId());
-
-               // Should be found
-               assert (managedNumber instanceof DialableLandLineNumber) : MessageFormat.format("Cell phone number with id {0} not found, but should be.", landLineNumber.getPhoneId()); //NOI18N
-
-               // Debug message
-               this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.updateLandLineData: managedNumber.phoneId={1}", this.getClass().getSimpleName(), managedNumber.getPhoneId())); //NOI18N
-
-               // Set updated timestamp
-               LandLineNumbers.copyAll(landLineNumber, managedNumber);
-               managedNumber.setPhoneEntryUpdated(new GregorianCalendar());
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateLandLineData: managedNumber={1} - EXIT!", this.getClass().getSimpleName(), managedNumber)); //NOI18N
-
-               // Return it
-               return managedNumber;
-       }
-
-       @Override
-       public DialableMobileNumber updateMobileData (final DialableMobileNumber mobileNumber) {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateMobileData: mobileNumber={1} - CALLED!", this.getClass().getSimpleName(), mobileNumber));
-
-               // Is all data set
-               if (null == mobileNumber) {
-                       // Not set, throw NPE
-                       throw new NullPointerException("mobileNumber is null"); //NOI18N
-               } else if (mobileNumber.getPhoneId() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("mobileNumber.phoneId is null"); //NOI18N
-               } else if (mobileNumber.getPhoneId() < 1) {
-                       // Invalid number
-                       throw new IllegalArgumentException(MessageFormat.format("mobileNumber.phoneId={0} is not valid", mobileNumber.getPhoneId())); //NOI18N
-               } else if (mobileNumber.getMobileProvider() == null) {
-                       // Throw NPE
-                       throw new NullPointerException("mobileNumber.cellphoneProvider is null"); //NOI18N
-               } else if (mobileNumber.getMobileProvider().getProviderId() == null) {
-                       // ... throw again
-                       throw new NullPointerException("mobileNumber.cellphoneProvider.providerId is null"); //NOI18N
-               } else if (mobileNumber.getMobileProvider().getProviderId() < 1) {
-                       // Id not valid
-                       throw new IllegalArgumentException(MessageFormat.format("mobileNumber.cellphoneProvider.providerId={0} is not valid.", mobileNumber.getMobileProvider().getProviderId())); //NOI18N
-               } else if (mobileNumber.getPhoneNumber() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("mobileNumber.phoneNumber is null"); //NOI18N
-               } else if (mobileNumber.getPhoneNumber() < 1) {
-                       // Throw NPE again
-                       throw new NullPointerException(MessageFormat.format("mobileNumber.phoneNumber={0} is not valid.", mobileNumber.getPhoneNumber())); //NOI18N
-               }
-
-               // Get contact from it and find it
-               final DialableMobileNumber managedNumber = this.getEntityManager().find(mobileNumber.getClass(), mobileNumber.getPhoneId());
-
-               // Should be found
-               assert (managedNumber instanceof DialableMobileNumber) : MessageFormat.format("Cell phone number with id {0} not found, but should be.", mobileNumber.getPhoneId()); //NOI18N
-
-               // Debug message
-               this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.updateMobileData: managedNumber.phoneId={1}", this.getClass().getSimpleName(), managedNumber.getPhoneId())); //NOI18N
-
-               // Set updated timestamp
-               MobileNumbers.copyAll(mobileNumber, managedNumber);
-               managedNumber.setPhoneEntryUpdated(new GregorianCalendar());
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateMobileData: managedNumber={1} - EXIT!", this.getClass().getSimpleName(), managedNumber)); //NOI18N
-
-               // Return it
-               return managedNumber;
-       }
-
-}
diff --git a/src/java/org/mxchange/jphone/phonenumbers/phone/PizzaPhoneSessionBean.java b/src/java/org/mxchange/jphone/phonenumbers/phone/PizzaPhoneSessionBean.java
deleted file mode 100644 (file)
index cb89a77..0000000
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * Copyright (C) 2016, 2017 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jphone.phonenumbers.phone;
-
-import java.text.MessageFormat;
-import java.util.List;
-import javax.ejb.Stateless;
-import javax.persistence.NoResultException;
-import javax.persistence.Query;
-import org.mxchange.jphone.exceptions.PhoneEntityNotFoundException;
-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.pizzaaplication.database.BasePizzaDatabaseBean;
-
-/**
- * A general phone EJB
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Stateless (name = "phone", description = "A bean handling phone data")
-public class PizzaPhoneSessionBean extends BasePizzaDatabaseBean implements PhoneSessionBeanRemote {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 134_945_698_127_601L;
-
-       /**
-        * Default constructor
-        */
-       public PizzaPhoneSessionBean () {
-               // Call super constructor
-               super();
-       }
-
-       @SuppressWarnings ("unchecked")
-       @Override
-       public List<DialableFaxNumber> allFaxNumbers () {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allFaxNumbers: CALLED!", this.getClass().getSimpleName())); //NOI18N
-
-               // Get query
-               final Query query = this.getEntityManager().createNamedQuery("AllFaxNumbers", FaxNumber.class); //NOI18N
-
-               // Get list from it
-               final List<DialableFaxNumber> list = query.getResultList();
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allFaxNumbers: list.size()={1} - EXIT!", this.getClass().getSimpleName(), list.size())); //NOI18N
-
-               // Return it
-               return list;
-       }
-
-       @SuppressWarnings ("unchecked")
-       @Override
-       public List<DialableLandLineNumber> allLandLineNumbers () {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allLandLineNumbers: CALLED!", this.getClass().getSimpleName())); //NOI18N
-
-               // Get query
-               final Query query = this.getEntityManager().createNamedQuery("AllLandLineNumbers", LandLineNumber.class); //NOI18N
-
-               // Get list from it
-               final List<DialableLandLineNumber> list = query.getResultList();
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allLandLineNumbers: list.size()={1} - EXIT!", this.getClass().getSimpleName(), list.size())); //NOI18N
-
-               // Return it
-               return list;
-       }
-
-       @SuppressWarnings ("unchecked")
-       @Override
-       public List<DialableMobileNumber> allMobileNumbers () {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allMobileNumbers: CALLED!", this.getClass().getSimpleName())); //NOI18N
-
-               // Get query
-               final Query query = this.getEntityManager().createNamedQuery("AllMobileNumbers", MobileNumber.class); //NOI18N
-
-               // Get list from it
-               final List<DialableMobileNumber> list = query.getResultList();
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allMobileNumbers: list.size()={1} - EXIT!", this.getClass().getSimpleName(), list.size())); //NOI18N
-
-               // Return it
-               return list;
-       }
-
-       @Override
-       public DialableFaxNumber findFaxNumberById (final Long faxNumberId) throws PhoneEntityNotFoundException {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findFaxNumberById: mobileNumberId={1} - CALLED!", this.getClass().getSimpleName(), faxNumberId)); //NOI18N
-
-               // The id number should be valid
-               if (null == faxNumberId) {
-                       // Throw NPE
-                       throw new NullPointerException("faxNumberId is null"); //NOI18N
-               } else if (faxNumberId < 1) {
-                       // Not valid
-                       throw new IllegalArgumentException(MessageFormat.format("faxNumberId={0} is not valid.", faxNumberId)); //NOI18N
-               }
-
-               // Now find it
-               final Query query = this.getEntityManager().createNamedQuery("SearchFaxNumberId", FaxNumber.class); //NOI18N
-
-               // Set parameter
-               query.setParameter("faxNumberId", faxNumberId); //NOI18N
-
-               // Init instance
-               final DialableFaxNumber faxNumber;
-
-               // Try to get a result
-               try {
-                       // Get a single result
-                       faxNumber = (DialableFaxNumber) query.getSingleResult();
-               } catch (NoResultException ex) {
-                       // The entry was not found, so throw it again
-                       throw new PhoneEntityNotFoundException(faxNumberId, ex);
-               }
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findFaxNumberById: mobile={1} - EXIT!", this.getClass().getSimpleName(), faxNumber)); //NOI18N
-
-               // Return found instance
-               return faxNumber;
-       }
-
-       @Override
-       public DialableLandLineNumber findLandLineNumberById (final Long landLineNumberId) throws PhoneEntityNotFoundException {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findLandLineNumberById: mobileNumberId={1} - CALLED!", this.getClass().getSimpleName(), landLineNumberId)); //NOI18N
-
-               // The id number should be valid
-               if (null == landLineNumberId) {
-                       // Throw NPE
-                       throw new NullPointerException("landLineNumberId is null"); //NOI18N
-               } else if (landLineNumberId < 1) {
-                       // Not valid
-                       throw new IllegalArgumentException(MessageFormat.format("landLineNumberId={0} is not valid.", landLineNumberId)); //NOI18N
-               }
-
-               // Now find it
-               final Query query = this.getEntityManager().createNamedQuery("SearchLandLineNumberId", LandLineNumber.class); //NOI18N
-
-               // Set parameter
-               query.setParameter("landLineNumberId", landLineNumberId); //NOI18N
-
-               // Init instance
-               final DialableLandLineNumber landLineNumber;
-
-               // Try to get a result
-               try {
-                       // Get a single result
-                       landLineNumber = (DialableLandLineNumber) query.getSingleResult();
-               } catch (NoResultException ex) {
-                       // The entry was not found, so throw it again
-                       throw new PhoneEntityNotFoundException(landLineNumberId, ex);
-               }
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findLandLineNumberById: mobile={1} - EXIT!", this.getClass().getSimpleName(), landLineNumber)); //NOI18N
-
-               // Return found instance
-               return landLineNumber;
-       }
-
-       @Override
-       public DialableMobileNumber findMobileNumberById (final Long mobileNumberId) throws PhoneEntityNotFoundException {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findMobileNumberById: mobileNumberId={1} - CALLED!", this.getClass().getSimpleName(), mobileNumberId)); //NOI18N
-
-               // The id number should be valid
-               if (null == mobileNumberId) {
-                       // Throw NPE
-                       throw new NullPointerException("mobileNumberId is null"); //NOI18N
-               } else if (mobileNumberId < 1) {
-                       // Not valid
-                       throw new IllegalArgumentException(MessageFormat.format("mobileNumberId={0} is not valid.", mobileNumberId)); //NOI18N
-               }
-
-               // Now find it
-               final Query query = this.getEntityManager().createNamedQuery("SearchMobileNumberId", MobileNumber.class); //NOI18N
-
-               // Set parameter
-               query.setParameter("mobileNumberId", mobileNumberId); //NOI18N
-
-               // Init instance
-               final DialableMobileNumber mobile;
-
-               // Try to get a result
-               try {
-                       // Get a single result
-                       mobile = (DialableMobileNumber) query.getSingleResult();
-               } catch (NoResultException ex) {
-                       // The entry was not found, so throw it again
-                       throw new PhoneEntityNotFoundException(mobileNumberId, ex);
-               }
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findMobileNumberById: mobile={1} - EXIT!", this.getClass().getSimpleName(), mobile)); //NOI18N
-
-               // Return found instance
-               return mobile;
-       }
-
-}
index 1b1a159f70c893aebb0e96bd08814656b3245667..e451aefc08d3228610bf8b85f27a624f00399f43 100644 (file)
@@ -20,7 +20,7 @@ import java.text.MessageFormat;
 import java.util.GregorianCalendar;
 import javax.ejb.EJB;
 import javax.ejb.Stateless;
-import org.mxchange.jcontacts.contact.Contact;
+import org.mxchange.jcontacts.model.contact.Contact;
 import org.mxchange.jusercore.exceptions.EmailAddressAlreadyRegisteredException;
 import org.mxchange.jusercore.exceptions.UserNameAlreadyRegisteredException;
 import org.mxchange.jusercore.exceptions.UserNotFoundException;
@@ -137,7 +137,7 @@ public class PizzaAdminUserSessionBean extends BasePizzaDatabaseBean implements
                }
 
                // Get a managed instance
-               final User managedUser = this.getManaged(user);
+               final User managedUser = this.createManaged(user);
 
                // Should be found!
                assert (managedUser instanceof User) : MessageFormat.format("User with id {0} not found, but should be.", user.getUserId()); //NOI18N
index 15cc2773febc2b2dec4398585cb1990f0e16e2bd..9653c0987446c7f432b98340a4f5b6c961d64e47 100644 (file)
@@ -25,14 +25,14 @@ import javax.ejb.Stateless;
 import javax.persistence.NoResultException;
 import javax.persistence.PersistenceException;
 import javax.persistence.Query;
-import org.mxchange.jcontacts.contact.Contact;
-import org.mxchange.jcontacts.contact.ContactUtils;
-import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
-import org.mxchange.jphone.phonenumbers.fax.FaxNumbers;
-import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
-import org.mxchange.jphone.phonenumbers.landline.LandLineNumbers;
-import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
-import org.mxchange.jphone.phonenumbers.mobile.MobileNumbers;
+import org.mxchange.jcontacts.model.contact.Contact;
+import org.mxchange.jcontacts.model.contact.ContactUtils;
+import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
+import org.mxchange.jphone.model.phonenumbers.fax.FaxNumbers;
+import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber;
+import org.mxchange.jphone.model.phonenumbers.landline.LandLineNumbers;
+import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber;
+import org.mxchange.jphone.model.phonenumbers.mobile.MobileNumbers;
 import org.mxchange.jusercore.exceptions.UserNotFoundException;
 import org.mxchange.jusercore.exceptions.UserStatusConfirmedException;
 import org.mxchange.jusercore.exceptions.UserStatusLockedException;
@@ -764,7 +764,7 @@ public class PizzaUserSessionBean extends BasePizzaDatabaseBean implements UserS
                        MobileNumbers.copyAll(managedUser.getUserContact().getContactMobileNumber(), managedMobile);
 
                        // Set it back
-                       managedContact.setContactMobileNumber(this.getManaged(mobileNumber, mobileNumber));
+                       managedContact.setContactMobileNumber(this.createManaged(mobileNumber, mobileNumber));
                }
 
                // Get mobile instance
index 3d64e9ca642a5b2723ebe4c8e3f7b8e93aa42417..66371693039a3e81cc057d39386ef77f49f28d88 100644 (file)
@@ -136,7 +136,7 @@ public class PizzaUserActivityLogMessageBean extends BasePizzaDatabaseBean imple
                }
 
                // Make user instance managed
-               final User managedUser = this.getManaged(userActivity.getActivityUser());
+               final User managedUser = this.createManaged(userActivity.getActivityUser());
 
                // Set it back
                userActivity.setActivityUser(managedUser);
index e8c3a59ff4cd785ee7ada813cf063b65a8bad19d..6383c7d6d54d246d3bebde06fcb5e1b00db908bd 100644 (file)
@@ -110,7 +110,7 @@ public class PizzaUserEmailChangeSessionBean extends BasePizzaDatabaseBean imple
                this.generateSecureHash(emailChange);
 
                // Make user managed
-               emailChange.setEmailChangeUser(this.getManaged(emailChange.getEmailChangeUser()));
+               emailChange.setEmailChangeUser(this.createManaged(emailChange.getEmailChangeUser()));
 
                // Persist it
                //@TODO Fix email delivery then allow this: this.getEntityManager().persist(emailChange);
index 1d7d30a23ca4f968def3ce7f0e8256af17616a2c..de9fdcab912fce7b4802637285d165f4535d6343 100644 (file)
@@ -22,7 +22,7 @@ import javax.ejb.EJB;
 import javax.ejb.Stateless;
 import javax.persistence.NoResultException;
 import javax.persistence.Query;
-import org.mxchange.jcontacts.contact.Contact;
+import org.mxchange.jcontacts.model.contact.Contact;
 import org.mxchange.jusercore.exceptions.EmailAddressAlreadyRegisteredException;
 import org.mxchange.jusercore.exceptions.UserNameAlreadyRegisteredException;
 import org.mxchange.jusercore.model.user.AdminUserSessionBeanRemote;
index 7776ddf26b7b27790cb94a43ec675ee1d5940b7c..b45b7bf8c4950bd216bde3c283f484729ec499f1 100644 (file)
@@ -26,22 +26,24 @@ import javax.jms.ObjectMessage;
 import javax.mail.Address;
 import javax.mail.internet.AddressException;
 import javax.mail.internet.InternetAddress;
-import org.mxchange.jcontacts.contact.Contact;
-import org.mxchange.jcontacts.contact.ContactUtils;
-import org.mxchange.jcontacts.contact.UserContact;
-import org.mxchange.jcontactsbusiness.basicdata.BusinessBasicData;
-import org.mxchange.jcontactsbusiness.basicdata.CompanyBasicData;
+import org.mxchange.jcontacts.model.contact.Contact;
+import org.mxchange.jcontacts.model.contact.ContactUtils;
+import org.mxchange.jcontacts.model.contact.UserContact;
+import org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData;
+import org.mxchange.jcontactsbusiness.model.basicdata.CompanyBasicData;
+import org.mxchange.jcontactsbusiness.model.employee.CompanyEmployee;
+import org.mxchange.jcontactsbusiness.model.employee.Employee;
 import org.mxchange.jcoreee.database.BaseDatabaseBean;
-import org.mxchange.jcountry.data.Country;
-import org.mxchange.jcountry.data.CountryData;
+import org.mxchange.jcountry.model.data.Country;
+import org.mxchange.jcountry.model.data.CountryData;
 import org.mxchange.jmailee.model.delivery.wrapper.EmailDeliveryWrapper;
 import org.mxchange.jmailee.model.delivery.wrapper.WrapableEmailDelivery;
-import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
-import org.mxchange.jphone.phonenumbers.fax.FaxNumbers;
-import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
-import org.mxchange.jphone.phonenumbers.landline.LandLineNumbers;
-import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
-import org.mxchange.jphone.phonenumbers.mobile.MobileNumbers;
+import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
+import org.mxchange.jphone.model.phonenumbers.fax.FaxNumbers;
+import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber;
+import org.mxchange.jphone.model.phonenumbers.landline.LandLineNumbers;
+import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber;
+import org.mxchange.jphone.model.phonenumbers.mobile.MobileNumbers;
 import org.mxchange.jphone.utils.PhoneUtils;
 import org.mxchange.jusercore.model.user.LoginUser;
 import org.mxchange.jusercore.model.user.User;
@@ -140,7 +142,7 @@ public abstract class BasePizzaDatabaseBean extends BaseDatabaseBean {
         * <p>
         * @return Managed instance
         */
-       protected DialableMobileNumber getManaged (final DialableMobileNumber mobileNumber, final DialableMobileNumber fetchedNumber) {
+       protected DialableMobileNumber createManaged (final DialableMobileNumber mobileNumber, final DialableMobileNumber fetchedNumber) {
                // Trace message
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getDetached: mobileNumber={1},fetchedNumber={2} - CALLED!", this.getClass().getSimpleName(), mobileNumber, fetchedNumber)); //NOI18N
 
@@ -191,7 +193,7 @@ public abstract class BasePizzaDatabaseBean extends BaseDatabaseBean {
         * <p>
         * @return Managed instance
         */
-       protected DialableLandLineNumber getManaged (final DialableLandLineNumber landLineNumber, final DialableLandLineNumber fetchedNumber) {
+       protected DialableLandLineNumber createManaged (final DialableLandLineNumber landLineNumber, final DialableLandLineNumber fetchedNumber) {
                // Trace message
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getDetached: landLineNumber={1},fetchedNumber={2} - CALLED!", this.getClass().getSimpleName(), landLineNumber, fetchedNumber)); //NOI18N
 
@@ -242,7 +244,7 @@ public abstract class BasePizzaDatabaseBean extends BaseDatabaseBean {
         * <p>
         * @return Managed instance
         */
-       protected DialableFaxNumber getManaged (final DialableFaxNumber faxNumber, final DialableFaxNumber fetchedNumber) {
+       protected DialableFaxNumber createManaged (final DialableFaxNumber faxNumber, final DialableFaxNumber fetchedNumber) {
                // Trace message
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getDetached: faxNumber={1},fetchedNumber={2} - CALLED!", this.getClass().getSimpleName(), faxNumber, fetchedNumber)); //NOI18N
 
@@ -292,9 +294,9 @@ public abstract class BasePizzaDatabaseBean extends BaseDatabaseBean {
         * <p>
         * @return Managed contact instance
         */
-       protected Contact getManaged (final Contact contact) {
+       protected Contact createManaged (final Contact contact) {
                // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getManaged: contact={1} - CALLED!", this.getClass().getSimpleName(), contact)); //NOI18N
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: contact={1} - CALLED!", this.getClass().getSimpleName(), contact)); //NOI18N
 
                // user should not be null
                if (null == contact) {
@@ -315,7 +317,7 @@ public abstract class BasePizzaDatabaseBean extends BaseDatabaseBean {
                assert (managedContact instanceof Contact) : "managedContact is null"; //NOI18N
 
                // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getManaged: managedContact={1} - EXIT!", this.getClass().getSimpleName(), managedContact)); //NOI18N
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: managedContact={1} - EXIT!", this.getClass().getSimpleName(), managedContact)); //NOI18N
 
                // Return it
                return managedContact;
@@ -328,9 +330,9 @@ public abstract class BasePizzaDatabaseBean extends BaseDatabaseBean {
         * <p>
         * @return Managed country instance
         */
-       protected Country getManaged (final Country country) {
+       protected Country createManaged (final Country country) {
                // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getManaged: country={1} - CALLED!", this.getClass().getSimpleName(), country)); //NOI18N
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: country={1} - CALLED!", this.getClass().getSimpleName(), country)); //NOI18N
 
                // user should not be null
                if (null == country) {
@@ -351,22 +353,22 @@ public abstract class BasePizzaDatabaseBean extends BaseDatabaseBean {
                assert (managedCountry instanceof Country) : "managedCountry is null"; //NOI18N
 
                // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getManaged: managedCountry={1} - EXIT!", this.getClass().getSimpleName(), managedCountry)); //NOI18N
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: managedCountry={1} - EXIT!", this.getClass().getSimpleName(), managedCountry)); //NOI18N
 
                // Return it
                return managedCountry;
        }
 
        /**
-        * Get back a managed instance from given contact
+        * Get back a managed instance from given basic data
         * <p>
-        * @param basicData Unmanaged/detached contact instance
+        * @param basicData Unmanaged/detached basic data instance
         * <p>
-        * @return Managed contact instance
+        * @return Managed basic data instance
         */
-       protected BusinessBasicData getManaged (final BusinessBasicData basicData) {
+       protected BusinessBasicData createManaged (final BusinessBasicData basicData) {
                // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getManaged: basicData={1} - CALLED!", this.getClass().getSimpleName(), basicData)); //NOI18N
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: basicData={1} - CALLED!", this.getClass().getSimpleName(), basicData)); //NOI18N
 
                // user should not be null
                if (null == basicData) {
@@ -387,12 +389,48 @@ public abstract class BasePizzaDatabaseBean extends BaseDatabaseBean {
                assert (managedBasicData instanceof BusinessBasicData) : "managedBasicData is null"; //NOI18N
 
                // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getManaged: managedBasicData={1} - EXIT!", this.getClass().getSimpleName(), managedBasicData)); //NOI18N
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: managedBasicData={1} - EXIT!", this.getClass().getSimpleName(), managedBasicData)); //NOI18N
 
                // Return it
                return managedBasicData;
        }
 
+       /**
+        * Get back a managed instance from given employee
+        * <p>
+        * @param employee Unmanaged/detached employee instance
+        * <p>
+        * @return Managed employee instance
+        */
+       protected Employee createManaged (final Employee employee) {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: employee={1} - CALLED!", this.getClass().getSimpleName(), employee)); //NOI18N
+
+               // user should not be null
+               if (null == employee) {
+                       // Abort here
+                       throw new NullPointerException("employee is null"); //NOI18N
+               } else if (employee.getEmployeeId() == null) {
+                       // Id is set
+                       throw new NullPointerException("employee.employeeId is null"); //NOI18N
+               } else if (employee.getEmployeeId() < 1) {
+                       // Id is set
+                       throw new IllegalArgumentException(MessageFormat.format("employee.employeeId={0} is null", employee.getEmployeeId())); //NOI18N
+               }
+
+               // Try to find it (should be there)
+               final Employee managedEmployee = this.getEntityManager().find(CompanyEmployee.class, employee.getEmployeeId());
+
+               // Should be there
+               assert (managedEmployee instanceof Employee) : "managedEmployee is null"; //NOI18N
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: managedEmployee={1} - EXIT!", this.getClass().getSimpleName(), managedEmployee)); //NOI18N
+
+               // Return it
+               return managedEmployee;
+       }
+
        /**
         * Get back a managed instance from given user
         * <p>
@@ -400,9 +438,9 @@ public abstract class BasePizzaDatabaseBean extends BaseDatabaseBean {
         * <p>
         * @return Managed user instance
         */
-       protected User getManaged (final User user) {
+       protected User createManaged (final User user) {
                // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getManaged: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N
 
                // user should not be null
                if (null == user) {
@@ -432,7 +470,7 @@ public abstract class BasePizzaDatabaseBean extends BaseDatabaseBean {
                assert (managedUser instanceof User) : "managedUser is null"; //NOI18N
 
                // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getManaged: managedUser={1} - EXIT!", this.getClass().getSimpleName(), managedUser)); //NOI18N
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: managedUser={1} - EXIT!", this.getClass().getSimpleName(), managedUser)); //NOI18N
 
                // Return it
                return managedUser;
@@ -473,19 +511,19 @@ public abstract class BasePizzaDatabaseBean extends BaseDatabaseBean {
                // Is a fax number set?
                if (detachedContact.getContactFaxNumber() instanceof DialableFaxNumber) {
                        // Make fax numbers managed
-                       foundContact.setContactFaxNumber(this.getManaged(detachedContact.getContactFaxNumber(), detachedContact.getContactFaxNumber()));
+                       foundContact.setContactFaxNumber(this.createManaged(detachedContact.getContactFaxNumber(), detachedContact.getContactFaxNumber()));
                }
 
                // Is a land-line number set?
                if (detachedContact.getContactLandLineNumber() instanceof DialableLandLineNumber) {
                        // Make land-line numbers managed
-                       foundContact.setContactLandLineNumber(this.getManaged(detachedContact.getContactLandLineNumber(), detachedContact.getContactLandLineNumber()));
+                       foundContact.setContactLandLineNumber(this.createManaged(detachedContact.getContactLandLineNumber(), detachedContact.getContactLandLineNumber()));
                }
 
                // Is a mobile number set?
                if (detachedContact.getContactMobileNumber() instanceof DialableMobileNumber) {
                        // Make mobile numbers managed
-                       foundContact.setContactMobileNumber(this.getManaged(detachedContact.getContactMobileNumber(), detachedContact.getContactMobileNumber()));
+                       foundContact.setContactMobileNumber(this.createManaged(detachedContact.getContactMobileNumber(), detachedContact.getContactMobileNumber()));
                }
 
                // Merge contact instance
@@ -746,7 +784,7 @@ public abstract class BasePizzaDatabaseBean extends BaseDatabaseBean {
                        // Is the fax number set?
                        if (other.getContactMobileNumber() instanceof DialableMobileNumber) {
                                // Copy mobile number
-                               contact.setContactMobileNumber(this.getManaged(other.getContactMobileNumber(), contact.getContactMobileNumber()));
+                               contact.setContactMobileNumber(this.createManaged(other.getContactMobileNumber(), contact.getContactMobileNumber()));
                        } else {
                                // Null it
                                contact.setContactMobileNumber(null);
@@ -764,7 +802,7 @@ public abstract class BasePizzaDatabaseBean extends BaseDatabaseBean {
                        // Is the land-line number set?
                        if (other.getContactLandLineNumber() instanceof DialableLandLineNumber) {
                                // Copy land-line number
-                               contact.setContactLandLineNumber(this.getManaged(other.getContactLandLineNumber(), contact.getContactLandLineNumber()));
+                               contact.setContactLandLineNumber(this.createManaged(other.getContactLandLineNumber(), contact.getContactLandLineNumber()));
                        } else {
                                // Null it
                                contact.setContactLandLineNumber(null);
@@ -782,7 +820,7 @@ public abstract class BasePizzaDatabaseBean extends BaseDatabaseBean {
                        // Is the fax number set?
                        if (other.getContactFaxNumber() instanceof DialableFaxNumber) {
                                // Copy fax number
-                               contact.setContactFaxNumber(this.getManaged(other.getContactFaxNumber(), contact.getContactFaxNumber()));
+                               contact.setContactFaxNumber(this.createManaged(other.getContactFaxNumber(), contact.getContactFaxNumber()));
                        } else {
                                // Null it
                                contact.setContactFaxNumber(null);
index 964c9c155b6f3801e3fe72ea277914b7e24fc198..a6c19eac0acf34a18cd74262236f5e3ce59e402d 100644 (file)
@@ -23,9 +23,9 @@ import javax.ejb.EJB;
 import javax.ejb.Stateless;
 import javax.persistence.NoResultException;
 import javax.persistence.Query;
-import org.mxchange.jcontacts.contact.Contact;
-import org.mxchange.jcontacts.contact.ContactSessionBeanRemote;
 import org.mxchange.jcontacts.exceptions.ContactAlreadyAddedException;
+import org.mxchange.jcontacts.model.contact.Contact;
+import org.mxchange.jcontacts.model.contact.ContactSessionBeanRemote;
 import org.mxchange.jcustomercore.exceptions.CustomerAlreadyRegisteredException;
 import org.mxchange.jcustomercore.model.customer.Customer;
 import org.mxchange.jcustomercore.utils.CustomerUtils;