]> git.mxchange.org Git - jjobs-ejb.git/commitdiff
Please cherry-pick:
authorRoland Häder <roland@mxchange.org>
Sat, 9 Sep 2017 12:49:54 +0000 (14:49 +0200)
committerRoland Häder <roland@mxchange.org>
Sat, 9 Sep 2017 16:10:00 +0000 (18:10 +0200)
- re-package season has started: now all core project's entity packages do
  always have following format: tld.domain.project.model.foo.SomeFoo;
- also fixed persistence unit

Signed-off-by: Roland Häder <roland@mxchange.org>
34 files changed:
src/conf/persistence.xml
src/java/org/mxchange/jcontacts/contact/JobsAdminContactSessionBean.java [deleted file]
src/java/org/mxchange/jcontacts/contact/JobsContactSessionBean.java [deleted file]
src/java/org/mxchange/jcontacts/model/contact/JobsAdminContactSessionBean.java [new file with mode: 0644]
src/java/org/mxchange/jcontacts/model/contact/JobsContactSessionBean.java [new file with mode: 0644]
src/java/org/mxchange/jcontacts/model/phone/JobsAdminContactPhoneSessionBean.java [new file with mode: 0644]
src/java/org/mxchange/jcontacts/phone/JobsAdminContactPhoneSessionBean.java [deleted file]
src/java/org/mxchange/jcontactsbusiness/basicdata/JobsAdminBusinessDataSessionBean.java [deleted file]
src/java/org/mxchange/jcontactsbusiness/basicdata/JobsBusinessDataSessionBean.java [deleted file]
src/java/org/mxchange/jcontactsbusiness/branchoffice/JobsAdminBranchOfficeSessionBean.java [deleted file]
src/java/org/mxchange/jcontactsbusiness/branchoffice/JobsBranchOfficeSessionBean.java [deleted file]
src/java/org/mxchange/jcontactsbusiness/employee/JobsAdminCompanyEmployeeSessionBean.java [deleted file]
src/java/org/mxchange/jcontactsbusiness/employee/JobsCompanyEmployeeSessionBean.java [deleted file]
src/java/org/mxchange/jcontactsbusiness/model/basicdata/JobsAdminBusinessDataSessionBean.java [new file with mode: 0644]
src/java/org/mxchange/jcontactsbusiness/model/basicdata/JobsBusinessDataSessionBean.java [new file with mode: 0644]
src/java/org/mxchange/jcontactsbusiness/model/branchoffice/JobsAdminBranchOfficeSessionBean.java [new file with mode: 0644]
src/java/org/mxchange/jcontactsbusiness/model/branchoffice/JobsBranchOfficeSessionBean.java [new file with mode: 0644]
src/java/org/mxchange/jcontactsbusiness/model/employee/JobsAdminCompanyEmployeeSessionBean.java [new file with mode: 0644]
src/java/org/mxchange/jcontactsbusiness/model/employee/JobsCompanyEmployeeSessionBean.java [new file with mode: 0644]
src/java/org/mxchange/jcountry/data/JobsCountrySingletonBean.java [deleted file]
src/java/org/mxchange/jcountry/model/data/JobsCountrySingletonBean.java [new file with mode: 0644]
src/java/org/mxchange/jjobs/database/BaseJobsDatabaseBean.java
src/java/org/mxchange/jphone/model/phonenumbers/mobileprovider/JobsAdminMobileProviderSessionBean.java [new file with mode: 0644]
src/java/org/mxchange/jphone/model/phonenumbers/mobileprovider/JobsMobileProviderSingletonBean.java [new file with mode: 0644]
src/java/org/mxchange/jphone/model/phonenumbers/phone/JobsAdminPhoneSessionBean.java [new file with mode: 0644]
src/java/org/mxchange/jphone/model/phonenumbers/phone/JobsPhoneSessionBean.java [new file with mode: 0644]
src/java/org/mxchange/jphone/phonenumbers/mobileprovider/JobsAdminMobileProviderSessionBean.java [deleted file]
src/java/org/mxchange/jphone/phonenumbers/mobileprovider/JobsMobileProviderSingletonBean.java [deleted file]
src/java/org/mxchange/jphone/phonenumbers/phone/JobsAdminPhoneSessionBean.java [deleted file]
src/java/org/mxchange/jphone/phonenumbers/phone/JobsPhoneSessionBean.java [deleted file]
src/java/org/mxchange/jusercore/model/user/JobsAdminUserSessionBean.java
src/java/org/mxchange/jusercore/model/user/JobsUserSessionBean.java
src/java/org/mxchange/jusercore/model/user/email_address/JobsUserEmailChangeSessionBean.java
src/java/org/mxchange/juserlogincore/model/user/register/JobsUserRegistrationSessionBean.java

index d6bf42b2101ce7939ac98daba0d8b6161f961007..9376c6f244fcfa2dced4e5d69b9ff29fbc48beb7 100644 (file)
@@ -4,24 +4,24 @@
     <jta-data-source>jdbc/jjobs</jta-data-source>
     <class>org.mxchange.jaddressbook.model.addressbook.UserAddressbook</class>
     <class>org.mxchange.jaddressbook.model.addressbook.entry.UserAddressbookEntry</class>
-    <class>org.mxchange.jcontacts.contact.UserContact</class>
-    <class>org.mxchange.jcontactsbusiness.basicdata.CompanyBasicData</class>
-    <class>org.mxchange.jcontactsbusiness.branchoffice.CompanyBranchOffice</class>
-    <class>org.mxchange.jcontactsbusiness.department.CompanyDepartment</class>
-    <class>org.mxchange.jcontactsbusiness.employee.CompanyEmployee</class>
-    <class>org.mxchange.jcontactsbusiness.headquarters.CompanyHeadquartersData</class>
-    <class>org.mxchange.jcontactsbusiness.jobposition.EmployeePosition</class>
-    <class>org.mxchange.jcontactsbusiness.logo.CompanyLogo</class>
-    <class>org.mxchange.jcontactsbusiness.opening_times.BusinessOpeningTimes</class>
-    <class>org.mxchange.jcountry.data.CountryData</class>
+    <class>org.mxchange.jcontacts.model.contact.UserContact</class>
+    <class>org.mxchange.jcontactsbusiness.model.basicdata.CompanyBasicData</class>
+    <class>org.mxchange.jcontactsbusiness.model.branchoffice.CompanyBranchOffice</class>
+    <class>org.mxchange.jcontactsbusiness.model.department.CompanyDepartment</class>
+    <class>org.mxchange.jcontactsbusiness.model.employee.CompanyEmployee</class>
+    <class>org.mxchange.jcontactsbusiness.model.headquarters.CompanyHeadquartersData</class>
+    <class>org.mxchange.jcontactsbusiness.model.jobposition.EmployeePosition</class>
+    <class>org.mxchange.jcontactsbusiness.model.logo.CompanyLogo</class>
+    <class>org.mxchange.jcontactsbusiness.model.opening_times.BusinessOpeningTimes</class>
+    <class>org.mxchange.jcountry.model.data.CountryData</class>
     <class>org.mxchange.jjobs.model.jobposition.JobPosition</class>
     <class>org.mxchange.jjobs.model.jobskill.JobPositionSkill</class>
     <class>org.mxchange.jjobs.model.skill.JobSkill</class>
     <class>org.mxchange.jjobs.model.user.skills.UserSkill</class>
-    <class>org.mxchange.jphone.phonenumbers.fax.FaxNumber</class>
-    <class>org.mxchange.jphone.phonenumbers.landline.LandLineNumber</class>
-    <class>org.mxchange.jphone.phonenumbers.mobile.MobileNumber</class>
-    <class>org.mxchange.jphone.phonenumbers.mobileprovider.CellphoneProvider</class>
+    <class>org.mxchange.jphone.model.phonenumbers.fax.FaxNumber</class>
+    <class>org.mxchange.jphone.model.phonenumbers.landline.LandLineNumber</class>
+    <class>org.mxchange.jphone.model.phonenumbers.mobile.MobileNumber</class>
+    <class>org.mxchange.jphone.model.phonenumbers.mobileprovider.CellphoneProvider</class>
     <class>org.mxchange.jusercore.model.email_address.EmailAddressChange</class>
     <class>org.mxchange.jusercore.model.user.LoginUser</class>
     <class>org.mxchange.jusercore.model.user.activity.UserActivityLog</class>
diff --git a/src/java/org/mxchange/jcontacts/contact/JobsAdminContactSessionBean.java b/src/java/org/mxchange/jcontacts/contact/JobsAdminContactSessionBean.java
deleted file mode 100644 (file)
index 0c6e744..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.jjobs.database.BaseJobsDatabaseBean;
-
-/**
- * An administrative contact EJB
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Stateless (name = "adminContact", description = "An administrative contact EJB")
-public class JobsAdminContactSessionBean extends BaseJobsDatabaseBean implements AdminContactSessionBeanRemote {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 542_145_347_916L;
-
-       /**
-        * Default constructor
-        */
-       public JobsAdminContactSessionBean () {
-               // 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/JobsContactSessionBean.java b/src/java/org/mxchange/jcontacts/contact/JobsContactSessionBean.java
deleted file mode 100644 (file)
index 4768229..0000000
+++ /dev/null
@@ -1,328 +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.jjobs.database.BaseJobsDatabaseBean;
-
-/**
- * A contact EJB
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Stateless (name = "contact", description = "A bean handling contact data")
-public class JobsContactSessionBean extends BaseJobsDatabaseBean implements ContactSessionBeanRemote {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 542_145_347_916L;
-
-       /**
-        * Default constructor
-        */
-       public JobsContactSessionBean () {
-               // 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() > 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();
-
-                       // 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 found contact
-               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 mobile, 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/JobsAdminContactSessionBean.java b/src/java/org/mxchange/jcontacts/model/contact/JobsAdminContactSessionBean.java
new file mode 100644 (file)
index 0000000..5fd615b
--- /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.jjobs.database.BaseJobsDatabaseBean;
+
+/**
+ * An administrative contact EJB
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Stateless (name = "adminContact", description = "An administrative contact EJB")
+public class JobsAdminContactSessionBean extends BaseJobsDatabaseBean implements AdminContactSessionBeanRemote {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 542_145_347_916L;
+
+       /**
+        * Default constructor
+        */
+       public JobsAdminContactSessionBean () {
+               // 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/JobsContactSessionBean.java b/src/java/org/mxchange/jcontacts/model/contact/JobsContactSessionBean.java
new file mode 100644 (file)
index 0000000..52b1c9c
--- /dev/null
@@ -0,0 +1,331 @@
+/*
+ * 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.jjobs.database.BaseJobsDatabaseBean;
+
+/**
+ * A contact EJB
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Stateless (name = "contact", description = "A bean handling contact data")
+public class JobsContactSessionBean extends BaseJobsDatabaseBean implements ContactSessionBeanRemote {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 542_145_347_916L;
+
+       /**
+        * Default constructor
+        */
+       public JobsContactSessionBean () {
+               // 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() > 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();
+
+                       // 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 found contact
+               return foundContact;
+       }
+
+       @Override
+       public Contact updateContactData (final Contact contact, final boolean isCellphoneUnlinked, final boolean isLandlineUnlinked, final boolean isFaxUnlinked) {
+               // Log trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateContactData: contact={1},isCellphoneUnlinked={2},isLandlineUnlinked={3},isFaxUnlinked={4} - CALLED!", this.getClass().getSimpleName(), contact, isCellphoneUnlinked, 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
+               }
+
+               // Set updated timestamp
+               this.setAllContactPhoneEntriesUpdated(contact, isCellphoneUnlinked, isLandlineUnlinked, isFaxUnlinked);
+
+               // Merge mobile, land-line and fix
+               Contact detachedContact = this.mergeContactData(contact);
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateContactData: detachedContact={1} - EXIT!", this.getClass().getSimpleName(), detachedContact)); //NOI18N
+
+               // Return it
+               return detachedContact;
+       }
+
+       @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 isCellphoneUnlinked = (contact.getContactMobileNumber() == null);
+               boolean isLandLineUnlinked = (contact.getContactLandLineNumber() == null);
+               boolean isFaxUnlinked = (contact.getContactFaxNumber() == null);
+
+               // Call other Method
+               Contact detachedContact = this.updateContactData(contact, isCellphoneUnlinked, isLandLineUnlinked, isFaxUnlinked);
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateContactData: detachedContact={1} - EXIT!", this.getClass().getSimpleName(), detachedContact)); //NOI18N
+
+               // Return it
+               return detachedContact;
+       }
+
+}
diff --git a/src/java/org/mxchange/jcontacts/model/phone/JobsAdminContactPhoneSessionBean.java b/src/java/org/mxchange/jcontacts/model/phone/JobsAdminContactPhoneSessionBean.java
new file mode 100644 (file)
index 0000000..0555707
--- /dev/null
@@ -0,0 +1,512 @@
+/*
+ * 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.ContactSessionBeanRemote;
+import org.mxchange.jjobs.database.BaseJobsDatabaseBean;
+import org.mxchange.jphone.exceptions.PhoneNumberAlreadyLinkedException;
+import org.mxchange.jphone.exceptions.PhoneNumberNotLinkedException;
+
+/**
+ * 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 JobsAdminContactPhoneSessionBean extends BaseJobsDatabaseBean implements AdminContactsPhoneSessionBeanRemote {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 189_217_561_460_237_108L;
+
+       /**
+        * Contact EJB
+        */
+       @EJB
+       private ContactSessionBeanRemote contactBean;
+
+       /**
+        * Default constructor
+        */
+       public JobsAdminContactPhoneSessionBean () {
+               // Call super constructor
+               super();
+       }
+
+       @Override
+       public org.mxchange.jcontacts.model.contact.Contact linkExistingFaxNumberWithContact (final org.mxchange.jcontacts.model.contact.Contact contact, final org.mxchange.jphone.model.phonenumbers.fax.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 org.mxchange.jphone.model.phonenumbers.fax.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 org.mxchange.jcontacts.model.contact.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 org.mxchange.jcontacts.model.contact.Contact linkExistingLandLineNumberWithContact (final org.mxchange.jcontacts.model.contact.Contact contact, final org.mxchange.jphone.model.phonenumbers.landline.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 org.mxchange.jphone.model.phonenumbers.landline.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 org.mxchange.jcontacts.model.contact.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 org.mxchange.jcontacts.model.contact.Contact linkExistingMobileNumberWithContact (final org.mxchange.jcontacts.model.contact.Contact contact, final org.mxchange.jphone.model.phonenumbers.mobile.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 org.mxchange.jphone.model.phonenumbers.mobile.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 org.mxchange.jcontacts.model.contact.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 org.mxchange.jcontacts.model.contact.Contact linkNewFaxNumberWithContact (final org.mxchange.jcontacts.model.contact.Contact contact, final org.mxchange.jphone.model.phonenumbers.fax.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 org.mxchange.jphone.model.phonenumbers.fax.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 org.mxchange.jcontacts.model.contact.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 org.mxchange.jcontacts.model.contact.Contact linkNewLandLineNumberWithContact (final org.mxchange.jcontacts.model.contact.Contact contact, final org.mxchange.jphone.model.phonenumbers.landline.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 org.mxchange.jphone.model.phonenumbers.landline.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 org.mxchange.jcontacts.model.contact.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 org.mxchange.jcontacts.model.contact.Contact linkNewMobileNumberWithContact (final org.mxchange.jcontacts.model.contact.Contact contact, final org.mxchange.jphone.model.phonenumbers.mobile.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 org.mxchange.jphone.model.phonenumbers.mobile.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 org.mxchange.jcontacts.model.contact.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 org.mxchange.jcontacts.model.contact.Contact unlinkFaxDataFromContact (final org.mxchange.jcontacts.model.contact.Contact contact, final org.mxchange.jphone.model.phonenumbers.fax.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 org.mxchange.jcontacts.model.contact.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 org.mxchange.jcontacts.model.contact.Contact unlinkLandLineDataFromContact (final org.mxchange.jcontacts.model.contact.Contact contact, final org.mxchange.jphone.model.phonenumbers.landline.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 org.mxchange.jcontacts.model.contact.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 org.mxchange.jcontacts.model.contact.Contact unlinkMobileDataFromContact (final org.mxchange.jcontacts.model.contact.Contact contact, final org.mxchange.jphone.model.phonenumbers.mobile.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 org.mxchange.jcontacts.model.contact.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/JobsAdminContactPhoneSessionBean.java b/src/java/org/mxchange/jcontacts/phone/JobsAdminContactPhoneSessionBean.java
deleted file mode 100644 (file)
index 9a1c12c..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.jjobs.database.BaseJobsDatabaseBean;
-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;
-
-/**
- * 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 JobsAdminContactPhoneSessionBean extends BaseJobsDatabaseBean implements AdminContactsPhoneSessionBeanRemote {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 189_217_561_460_237_108L;
-
-       /**
-        * Contact EJB
-        */
-       @EJB
-       private ContactSessionBeanRemote contactBean;
-
-       /**
-        * Default constructor
-        */
-       public JobsAdminContactPhoneSessionBean () {
-               // 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/JobsAdminBusinessDataSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/basicdata/JobsAdminBusinessDataSessionBean.java
deleted file mode 100644 (file)
index bc5279d..0000000
+++ /dev/null
@@ -1,141 +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.jcontactsbusiness.model.employee.Employee;
-import org.mxchange.jjobs.database.BaseJobsDatabaseBean;
-import org.mxchange.jusercore.model.user.User;
-
-/**
- * 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 JobsAdminBusinessDataSessionBean extends BaseJobsDatabaseBean implements AdminBusinessDataSessionBeanRemote {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 56_389_504_892_184_572L;
-
-       /**
-        * Administrative EJB
-        */
-       @EJB
-       private BusinessDataSessionBeanRemote businessDataBean;
-
-       /**
-        * Default constructor
-        */
-       public JobsAdminBusinessDataSessionBean () {
-               // 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/basicdata/JobsBusinessDataSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/basicdata/JobsBusinessDataSessionBean.java
deleted file mode 100644 (file)
index bec3cc5..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.jjobs.database.BaseJobsDatabaseBean;
-
-/**
- * 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 JobsBusinessDataSessionBean extends BaseJobsDatabaseBean implements BusinessDataSessionBeanRemote {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 56_389_504_892_184_571L;
-
-       /**
-        * Default constructor
-        */
-       public JobsBusinessDataSessionBean () {
-               // 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/JobsAdminBranchOfficeSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/branchoffice/JobsAdminBranchOfficeSessionBean.java
deleted file mode 100644 (file)
index ce149fb..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.jjobs.database.BaseJobsDatabaseBean;
-import org.mxchange.jusercore.model.user.User;
-
-/**
- * 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 JobsAdminBranchOfficeSessionBean extends BaseJobsDatabaseBean 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 JobsAdminBranchOfficeSessionBean () {
-               // 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/branchoffice/JobsBranchOfficeSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/branchoffice/JobsBranchOfficeSessionBean.java
deleted file mode 100644 (file)
index bf02f66..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.jjobs.database.BaseJobsDatabaseBean;
-
-/**
- * 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 JobsBranchOfficeSessionBean extends BaseJobsDatabaseBean 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/JobsAdminCompanyEmployeeSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/employee/JobsAdminCompanyEmployeeSessionBean.java
deleted file mode 100644 (file)
index cf3c022..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.jjobs.database.BaseJobsDatabaseBean;
-
-/**
- * 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 JobsAdminCompanyEmployeeSessionBean extends BaseJobsDatabaseBean implements AdminCompanyEmployeeSessionBeanRemote {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 26_458_796_703_761L;
-
-       /**
-        * Default constructor
-        */
-       public JobsAdminCompanyEmployeeSessionBean () {
-               super();
-       }
-
-}
diff --git a/src/java/org/mxchange/jcontactsbusiness/employee/JobsCompanyEmployeeSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/employee/JobsCompanyEmployeeSessionBean.java
deleted file mode 100644 (file)
index 86055b8..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.jjobs.database.BaseJobsDatabaseBean;
-
-/**
- * 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 JobsCompanyEmployeeSessionBean extends BaseJobsDatabaseBean implements CompanyEmployeeSessionBeanRemote {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 26_458_796_703_761L;
-
-       /**
-        * Default constructor
-        */
-       public JobsCompanyEmployeeSessionBean () {
-               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/JobsAdminBusinessDataSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/model/basicdata/JobsAdminBusinessDataSessionBean.java
new file mode 100644 (file)
index 0000000..b1bd1ba
--- /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.jjobs.database.BaseJobsDatabaseBean;
+import org.mxchange.jusercore.model.user.User;
+
+/**
+ * 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 JobsAdminBusinessDataSessionBean extends BaseJobsDatabaseBean implements AdminBusinessDataSessionBeanRemote {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 56_389_504_892_184_572L;
+
+       /**
+        * Administrative EJB
+        */
+       @EJB
+       private BusinessDataSessionBeanRemote businessDataBean;
+
+       /**
+        * Default constructor
+        */
+       public JobsAdminBusinessDataSessionBean () {
+               // 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/JobsBusinessDataSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/model/basicdata/JobsBusinessDataSessionBean.java
new file mode 100644 (file)
index 0000000..a0c473d
--- /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.jjobs.database.BaseJobsDatabaseBean;
+
+/**
+ * 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 JobsBusinessDataSessionBean extends BaseJobsDatabaseBean implements BusinessDataSessionBeanRemote {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 56_389_504_892_184_571L;
+
+       /**
+        * Default constructor
+        */
+       public JobsBusinessDataSessionBean () {
+               // 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/JobsAdminBranchOfficeSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/model/branchoffice/JobsAdminBranchOfficeSessionBean.java
new file mode 100644 (file)
index 0000000..b8be625
--- /dev/null
@@ -0,0 +1,144 @@
+/*
+ * 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.jjobs.database.BaseJobsDatabaseBean;
+import org.mxchange.jusercore.model.user.User;
+
+/**
+ * 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 JobsAdminBranchOfficeSessionBean extends BaseJobsDatabaseBean 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 JobsAdminBranchOfficeSessionBean () {
+               // 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 org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData) {
+                       // Get managed instance back
+                       final org.mxchange.jcontactsbusiness.model.basicdata.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 org.mxchange.jcountry.model.data.Country) {
+                       // Get managed instance back
+                       final org.mxchange.jcountry.model.data.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/JobsBranchOfficeSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/model/branchoffice/JobsBranchOfficeSessionBean.java
new file mode 100644 (file)
index 0000000..f1ed632
--- /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.jjobs.database.BaseJobsDatabaseBean;
+
+/**
+ * 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 JobsBranchOfficeSessionBean extends BaseJobsDatabaseBean 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/JobsAdminCompanyEmployeeSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/model/employee/JobsAdminCompanyEmployeeSessionBean.java
new file mode 100644 (file)
index 0000000..79b4897
--- /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.jjobs.database.BaseJobsDatabaseBean;
+
+/**
+ * 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 JobsAdminCompanyEmployeeSessionBean extends BaseJobsDatabaseBean implements AdminCompanyEmployeeSessionBeanRemote {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 26_458_796_703_761L;
+
+       /**
+        * Default constructor
+        */
+       public JobsAdminCompanyEmployeeSessionBean () {
+               super();
+       }
+
+}
diff --git a/src/java/org/mxchange/jcontactsbusiness/model/employee/JobsCompanyEmployeeSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/model/employee/JobsCompanyEmployeeSessionBean.java
new file mode 100644 (file)
index 0000000..959056c
--- /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.jjobs.database.BaseJobsDatabaseBean;
+
+/**
+ * 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 JobsCompanyEmployeeSessionBean extends BaseJobsDatabaseBean implements CompanyEmployeeSessionBeanRemote {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 26_458_796_703_761L;
+
+       /**
+        * Default constructor
+        */
+       public JobsCompanyEmployeeSessionBean () {
+               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/JobsCountrySingletonBean.java b/src/java/org/mxchange/jcountry/data/JobsCountrySingletonBean.java
deleted file mode 100644 (file)
index 2fc68b8..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.jjobs.database.BaseJobsDatabaseBean;
-
-/**
- * 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 JobsCountrySingletonBean extends BaseJobsDatabaseBean implements CountrySingletonBeanRemote {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 15_846_983_298_691_207L;
-
-       /**
-        * Default constructor
-        */
-       public JobsCountrySingletonBean () {
-               // 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/JobsCountrySingletonBean.java b/src/java/org/mxchange/jcountry/model/data/JobsCountrySingletonBean.java
new file mode 100644 (file)
index 0000000..8629f05
--- /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.jjobs.database.BaseJobsDatabaseBean;
+
+/**
+ * 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 JobsCountrySingletonBean extends BaseJobsDatabaseBean implements CountrySingletonBeanRemote {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 15_846_983_298_691_207L;
+
+       /**
+        * Default constructor
+        */
+       public JobsCountrySingletonBean () {
+               // 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;
+       }
+
+}
index b37d6e390dee02d0bf974dc6cda9aa5817ba175b..5a06d185ffba313e3c602e36c99636cb4a988f2a 100644 (file)
@@ -26,24 +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.jcontactsbusiness.employee.CompanyEmployee;
-import org.mxchange.jcontactsbusiness.employee.Employee;
+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;
diff --git a/src/java/org/mxchange/jphone/model/phonenumbers/mobileprovider/JobsAdminMobileProviderSessionBean.java b/src/java/org/mxchange/jphone/model/phonenumbers/mobileprovider/JobsAdminMobileProviderSessionBean.java
new file mode 100644 (file)
index 0000000..22e4489
--- /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.jjobs.database.BaseJobsDatabaseBean;
+import org.mxchange.jphone.exceptions.MobileProviderAlreadyAddedException;
+
+/**
+ * An 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 JobsAdminMobileProviderSessionBean extends BaseJobsDatabaseBean implements AdminMobileProviderSessionBeanRemote {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 15_846_983_298_691_207L;
+
+       /**
+        * Default constructor
+        */
+       public JobsAdminMobileProviderSessionBean () {
+               // 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/JobsMobileProviderSingletonBean.java b/src/java/org/mxchange/jphone/model/phonenumbers/mobileprovider/JobsMobileProviderSingletonBean.java
new file mode 100644 (file)
index 0000000..e881ffd
--- /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.jjobs.database.BaseJobsDatabaseBean;
+
+/**
+ * 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 JobsMobileProviderSingletonBean extends BaseJobsDatabaseBean implements MobileProviderSingletonBeanRemote {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 15_846_983_298_691_207L;
+
+       /**
+        * Default constructor
+        */
+       public JobsMobileProviderSingletonBean () {
+               // 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/JobsAdminPhoneSessionBean.java b/src/java/org/mxchange/jphone/model/phonenumbers/phone/JobsAdminPhoneSessionBean.java
new file mode 100644 (file)
index 0000000..9b387f6
--- /dev/null
@@ -0,0 +1,352 @@
+/*
+ * 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.jjobs.database.BaseJobsDatabaseBean;
+import org.mxchange.jphone.model.phonenumbers.phone.AdminPhoneSessionBeanRemote;
+
+/**
+ * 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 JobsAdminPhoneSessionBean extends BaseJobsDatabaseBean implements AdminPhoneSessionBeanRemote {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 18_597_165_817_401_853L;
+
+       /**
+        * Default constructor
+        */
+       public JobsAdminPhoneSessionBean () {
+               // Call super constructor
+               super();
+       }
+
+       @Override
+       public void deleteFaxData (final org.mxchange.jphone.model.phonenumbers.fax.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 org.mxchange.jphone.model.phonenumbers.fax.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 org.mxchange.jphone.model.phonenumbers.landline.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 org.mxchange.jphone.model.phonenumbers.landline.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 org.mxchange.jphone.model.phonenumbers.mobile.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 org.mxchange.jphone.model.phonenumbers.mobile.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 org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber updateFaxData (final org.mxchange.jphone.model.phonenumbers.fax.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 org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber managedNumber = this.getEntityManager().find(faxNumber.getClass(), faxNumber.getPhoneId());
+
+               // Should be found
+               assert (managedNumber instanceof org.mxchange.jphone.model.phonenumbers.fax.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
+               org.mxchange.jphone.model.phonenumbers.fax.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 org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber updateLandLineData (final org.mxchange.jphone.model.phonenumbers.landline.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 org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber managedNumber = this.getEntityManager().find(landLineNumber.getClass(), landLineNumber.getPhoneId());
+
+               // Should be found
+               assert (managedNumber instanceof org.mxchange.jphone.model.phonenumbers.landline.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
+               org.mxchange.jphone.model.phonenumbers.landline.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 org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber updateMobileData (final org.mxchange.jphone.model.phonenumbers.mobile.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 org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber managedNumber = this.getEntityManager().find(mobileNumber.getClass(), mobileNumber.getPhoneId());
+
+               // Should be found
+               assert (managedNumber instanceof org.mxchange.jphone.model.phonenumbers.mobile.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
+               org.mxchange.jphone.model.phonenumbers.mobile.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/JobsPhoneSessionBean.java b/src/java/org/mxchange/jphone/model/phonenumbers/phone/JobsPhoneSessionBean.java
new file mode 100644 (file)
index 0000000..9a07dc9
--- /dev/null
@@ -0,0 +1,223 @@
+/*
+ * 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.jjobs.database.BaseJobsDatabaseBean;
+import org.mxchange.jphone.exceptions.PhoneEntityNotFoundException;
+import org.mxchange.jphone.model.phonenumbers.phone.PhoneSessionBeanRemote;
+
+/**
+ * A general phone EJB
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Stateless (name = "phone", description = "A bean handling phone data")
+public class JobsPhoneSessionBean extends BaseJobsDatabaseBean implements PhoneSessionBeanRemote {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 134_945_698_127_601L;
+
+       /**
+        * Default constructor
+        */
+       public JobsPhoneSessionBean () {
+               // Call super constructor
+               super();
+       }
+
+       @SuppressWarnings ("unchecked")
+       @Override
+       public List<org.mxchange.jphone.model.phonenumbers.fax.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", org.mxchange.jphone.model.phonenumbers.fax.FaxNumber.class); //NOI18N
+
+               // Get list from it
+               final List<org.mxchange.jphone.model.phonenumbers.fax.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<org.mxchange.jphone.model.phonenumbers.landline.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", org.mxchange.jphone.model.phonenumbers.landline.LandLineNumber.class); //NOI18N
+
+               // Get list from it
+               final List<org.mxchange.jphone.model.phonenumbers.landline.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<org.mxchange.jphone.model.phonenumbers.mobile.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", org.mxchange.jphone.model.phonenumbers.mobile.MobileNumber.class); //NOI18N
+
+               // Get list from it
+               final List<org.mxchange.jphone.model.phonenumbers.mobile.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 org.mxchange.jphone.model.phonenumbers.fax.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", org.mxchange.jphone.model.phonenumbers.fax.FaxNumber.class); //NOI18N
+
+               // Set parameter
+               query.setParameter("faxNumberId", faxNumberId); //NOI18N
+
+               // Init instance
+               final org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber faxNumber;
+
+               // Try to get a result
+               try {
+                       // Get a single result
+                       faxNumber = (org.mxchange.jphone.model.phonenumbers.fax.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 org.mxchange.jphone.model.phonenumbers.landline.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", org.mxchange.jphone.model.phonenumbers.landline.LandLineNumber.class); //NOI18N
+
+               // Set parameter
+               query.setParameter("landLineNumberId", landLineNumberId); //NOI18N
+
+               // Init instance
+               final org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber landLineNumber;
+
+               // Try to get a result
+               try {
+                       // Get a single result
+                       landLineNumber = (org.mxchange.jphone.model.phonenumbers.landline.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 org.mxchange.jphone.model.phonenumbers.mobile.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", org.mxchange.jphone.model.phonenumbers.mobile.MobileNumber.class); //NOI18N
+
+               // Set parameter
+               query.setParameter("mobileNumberId", mobileNumberId); //NOI18N
+
+               // Init instance
+               final org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber mobile;
+
+               // Try to get a result
+               try {
+                       // Get a single result
+                       mobile = (org.mxchange.jphone.model.phonenumbers.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/JobsAdminMobileProviderSessionBean.java b/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/JobsAdminMobileProviderSessionBean.java
deleted file mode 100644 (file)
index 6111b67..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.jjobs.database.BaseJobsDatabaseBean;
-import org.mxchange.jphone.exceptions.MobileProviderAlreadyAddedException;
-
-/**
- * An 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 JobsAdminMobileProviderSessionBean extends BaseJobsDatabaseBean implements AdminMobileProviderSessionBeanRemote {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 15_846_983_298_691_207L;
-
-       /**
-        * Default constructor
-        */
-       public JobsAdminMobileProviderSessionBean () {
-               // 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/JobsMobileProviderSingletonBean.java b/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/JobsMobileProviderSingletonBean.java
deleted file mode 100644 (file)
index 0284357..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.jjobs.database.BaseJobsDatabaseBean;
-
-/**
- * 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 JobsMobileProviderSingletonBean extends BaseJobsDatabaseBean implements MobileProviderSingletonBeanRemote {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 15_846_983_298_691_207L;
-
-       /**
-        * Default constructor
-        */
-       public JobsMobileProviderSingletonBean () {
-               // 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/JobsAdminPhoneSessionBean.java b/src/java/org/mxchange/jphone/phonenumbers/phone/JobsAdminPhoneSessionBean.java
deleted file mode 100644 (file)
index 7ba5b51..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.jjobs.database.BaseJobsDatabaseBean;
-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;
-
-/**
- * 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 JobsAdminPhoneSessionBean extends BaseJobsDatabaseBean implements AdminPhoneSessionBeanRemote {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 18_597_165_817_401_853L;
-
-       /**
-        * Default constructor
-        */
-       public JobsAdminPhoneSessionBean () {
-               // 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.mobileProvider is null"); //NOI18N
-               } else if (mobileNumber.getMobileProvider().getProviderId() == null) {
-                       // ... throw again
-                       throw new NullPointerException("mobileNumber.mobileProvider.providerId is null"); //NOI18N
-               } else if (mobileNumber.getMobileProvider().getProviderId() < 1) {
-                       // Id not valid
-                       throw new IllegalArgumentException(MessageFormat.format("mobileNumber.mobileProvider.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.mobileProvider is null"); //NOI18N
-               } else if (mobileNumber.getMobileProvider().getProviderId() == null) {
-                       // ... throw again
-                       throw new NullPointerException("mobileNumber.mobileProvider.providerId is null"); //NOI18N
-               } else if (mobileNumber.getMobileProvider().getProviderId() < 1) {
-                       // Id not valid
-                       throw new IllegalArgumentException(MessageFormat.format("mobileNumber.mobileProvider.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/JobsPhoneSessionBean.java b/src/java/org/mxchange/jphone/phonenumbers/phone/JobsPhoneSessionBean.java
deleted file mode 100644 (file)
index 883df63..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.jjobs.database.BaseJobsDatabaseBean;
-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;
-
-/**
- * A general phone EJB
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Stateless (name = "phone", description = "A bean handling phone data")
-public class JobsPhoneSessionBean extends BaseJobsDatabaseBean implements PhoneSessionBeanRemote {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 134_945_698_127_601L;
-
-       /**
-        * Default constructor
-        */
-       public JobsPhoneSessionBean () {
-               // 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 2ed096f1c4dae944fd33cdd343763eb689ec64c9..fac2bbd41955553d7ef3ddb6446cdd42be418ef1 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.jjobs.database.BaseJobsDatabaseBean;
 import org.mxchange.jusercore.exceptions.EmailAddressAlreadyRegisteredException;
 import org.mxchange.jusercore.exceptions.UserNameAlreadyRegisteredException;
index 0b4513dde428db31e2a1dca63b30dbb975403187..e4a65fada66e9c0474404bdd809eaedb29c6a6a3 100644 (file)
@@ -25,15 +25,15 @@ 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.jcontacts.model.contact.Contact;
+import org.mxchange.jcontacts.model.contact.ContactUtils;
 import org.mxchange.jjobs.database.BaseJobsDatabaseBean;
-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.jusercore.exceptions.UserNotFoundException;
 import org.mxchange.jusercore.exceptions.UserStatusConfirmedException;
 import org.mxchange.jusercore.exceptions.UserStatusLockedException;
index 2f02a3b125b1d784a121b0052e56c9dcd23feb52..3f7b67751d859fa4ebb4ce1c71027967883ad3ea 100644 (file)
@@ -110,7 +110,7 @@ public class JobsUserEmailChangeSessionBean extends BaseJobsDatabaseBean impleme
                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 cc82aa10d8426823ca58b9f6195badf70269829f..a09c73a0eee558f2f3b837446fabdabab9ef45ce 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.jjobs.database.BaseJobsDatabaseBean;
 import org.mxchange.jusercore.exceptions.EmailAddressAlreadyRegisteredException;
 import org.mxchange.jusercore.exceptions.UserNameAlreadyRegisteredException;