import javax.persistence.Query;
import org.mxchange.jcontacts.exceptions.ContactAlreadyAddedException;
import org.mxchange.jcontacts.exceptions.ContactNotFoundException;
-import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
+import org.mxchange.pizzaaplication.database.BasePizzaEnterpriseBean;
/**
* An administrative contact EJB
* @author Roland Häder<roland@mxchange.org>
*/
@Stateless (name = "adminContact", description = "An administrative contact EJB")
-public class PizzaAdminContactSessionBean extends BasePizzaDatabaseBean implements AdminContactSessionBeanRemote {
+public class PizzaAdminContactSessionBean extends BasePizzaEnterpriseBean implements AdminContactSessionBeanRemote {
/**
* Serial number
import javax.persistence.NoResultException;
import javax.persistence.Query;
import org.mxchange.jcontacts.exceptions.ContactNotFoundException;
-import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
+import org.mxchange.pizzaaplication.database.BasePizzaEnterpriseBean;
/**
* A contact EJB
* <p>
* @author Roland Häder<roland@mxchange.org>
*/
@Stateless (name = "contact", description = "A bean handling contact data")
-public class PizzaContactSessionBean extends BasePizzaDatabaseBean implements ContactSessionBeanRemote {
+public class PizzaContactSessionBean extends BasePizzaEnterpriseBean implements ContactSessionBeanRemote {
/**
* Serial number
import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber;
import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber;
-import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
+import org.mxchange.pizzaaplication.database.BasePizzaEnterpriseBean;
/**
* A session EJB for administrative contact's phone number purposes
* @author Roland Häder<roland@mxchange.org>
*/
@Stateless (name = "adminContactPhone", description = "An administrative bean handling contact's phone (fax, land-line and mobile) data")
-public class PizzaAdminContactPhoneSessionBean extends BasePizzaDatabaseBean implements AdminContactsPhoneSessionBeanRemote {
+public class PizzaAdminContactPhoneSessionBean extends BasePizzaEnterpriseBean implements AdminContactsPhoneSessionBeanRemote {
/**
* Serial number
import org.mxchange.jcontactsbusiness.exceptions.basicdata.BasicCompanyDataAlreadyAddedException;
import org.mxchange.jcontactsbusiness.model.employee.Employee;
import org.mxchange.jusercore.model.user.User;
-import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
+import org.mxchange.pizzaaplication.database.BasePizzaEnterpriseBean;
/**
* An administrative stateless session bean for business data
* @author Roland Häder<roland@mxchange.org>
*/
@Stateless (name = "adminBasicCompanyData", description = "An administrative statless bean for handling business data (all)")
-public class PizzaAdminBusinessDataSessionBean extends BasePizzaDatabaseBean implements AdminBasicCompanyDataSessionBeanRemote {
+public class PizzaAdminBusinessDataSessionBean extends BasePizzaEnterpriseBean implements AdminBasicCompanyDataSessionBeanRemote {
/**
* Serial number
import javax.ejb.Stateless;
import javax.persistence.NoResultException;
import javax.persistence.Query;
-import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
+import org.mxchange.pizzaaplication.database.BasePizzaEnterpriseBean;
import org.mxchange.jcontactsbusiness.exceptions.basicdata.BasicCompanyDataNotFoundException;
/**
* @author Roland Häder<roland@mxchange.org>
*/
@Stateless (name = "basicCompanyData", description = "A general statless bean for handling business data (all)")
-public class PizzaBusinessDataSessionBean extends BasePizzaDatabaseBean implements BasicCompanyDataSessionBeanRemote {
+public class PizzaBusinessDataSessionBean extends BasePizzaEnterpriseBean implements BasicCompanyDataSessionBeanRemote {
/**
* Serial number
import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTime;
import org.mxchange.jcountry.model.data.Country;
import org.mxchange.jusercore.model.user.User;
-import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
+import org.mxchange.pizzaaplication.database.BasePizzaEnterpriseBean;
/**
* A stateless session bean for administrative branch office purposes
* @author Roland Häder<roland@mxchange.org>
*/
@Stateless (name = "adminBranchOffice", description = "An administrative statless bean for handling branch office data (all)")
-public class PizzaAdminBranchOfficeSessionBean extends BasePizzaDatabaseBean implements AdminBranchOfficeSessionBeanRemote {
+public class PizzaAdminBranchOfficeSessionBean extends BasePizzaEnterpriseBean implements AdminBranchOfficeSessionBeanRemote {
/**
* Serial number
+++ /dev/null
-/*
- * 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.department;
-
-import java.text.MessageFormat;
-import java.util.Date;
-import java.util.List;
-import javax.ejb.EJB;
-import javax.ejb.Stateless;
-import org.mxchange.jcontactsbusiness.exceptions.department.DepartmentAlreadyAddedException;
-import org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData;
-import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice;
-import org.mxchange.jcontactsbusiness.model.employee.Employee;
-import org.mxchange.jcontactsbusiness.model.headquarters.HeadquartersData;
-import org.mxchange.jfinancials.database.BaseFinancialsDatabaseBean;
-import org.mxchange.jusercore.model.user.User;
-
-/**
- * A stateless session bean for administrative department purposes
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Stateless (name = "adminDepartment", description = "An administrative statless bean for handling department data (all)")
-public class FinancialsAdminDepartmentSessionBean extends BaseFinancialsDatabaseBean implements AdminDepartmentSessionBeanRemote {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 58_467_386_571_701L;
-
- /**
- * General department bean
- */
- @EJB (lookup = "java:global/jfinancials-ejb/department!org.mxchange.jcontactsbusiness.model.department.DepartmentSessionBeanRemote")
- private DepartmentSessionBeanRemote departmentBean;
-
- /**
- * Default constructor
- */
- public FinancialsAdminDepartmentSessionBean () {
- // Call super constructor
- super();
- }
-
- @Override
- public Department addDepartment (final Department department) throws DepartmentAlreadyAddedException {
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addDepartment(): department={1} - CALLED!", this.getClass().getSimpleName(), department)); //NOI18N
-
- // Validate parameter
- if (null == department) {
- // Throw NPE
- throw new NullPointerException("department is null"); //NOI18N
- } else if (department.getDepartmentId() instanceof Long) {
- // Should not happen
- throw new IllegalArgumentException("department.departmentId should not be set."); //NOI18N
- } else if (department.getDepartmentCompany() == null) {
- // Throw NPE
- throw new NullPointerException("department.departmentCompany is null"); //NOI18N
- } else if (department.getDepartmentCompany().getBasicDataId() == null) {
- // Throw NPE again
- throw new NullPointerException("department.departmentCompany.basicDataId is null"); //NOI18N
- } else if (department.getDepartmentCompany().getBasicDataId() < 1) {
- // Throw IAE
- throw new IllegalArgumentException(MessageFormat.format("department.departmentCompany.basicDataId={0} is invalid", department.getDepartmentCompany().getBasicDataId())); //NOI18N
- } else if (department.getDepartmentI18nKey() == null) {
- // Throw NPE
- throw new NullPointerException("department.departmentName is null"); //NOI18N
- } else if (department.getDepartmentI18nKey().isEmpty()) {
- // Throw IAE
- throw new NullPointerException("department.departmentName is empty"); //NOI18N
- } else if (this.isDepartmentFound(department)) {
- // Already added, abort here
- throw new DepartmentAlreadyAddedException(department);
- }
-
- // Set created timestamp
- department.setDepartmentCreated(new Date());
-
- // Get managed basic data instance
- final BusinessBasicData managedBasicData = this.createManaged(department.getDepartmentCompany());
-
- // Set it back
- department.setDepartmentCompany(managedBasicData);
-
- // Is branch office set?
- if (department.getDepartmentBranchOffice() instanceof BranchOffice) {
- // Get managed branch office
- final BranchOffice managedBranchOffice = this.createManaged(department.getDepartmentBranchOffice());
-
- // Set it back
- department.setDepartmentBranchOffice(managedBranchOffice);
- }
-
- // Is headquarters set?
- if (department.getDepartmentHeadquarters() instanceof HeadquartersData) {
- // Get managed headquarters
- final HeadquartersData managedHeadquarters = this.createManaged(department.getDepartmentHeadquarters());
-
- // Set it back
- department.setDepartmentHeadquarters(managedHeadquarters);
- }
-
- // Is lead employee set?
- if (department.getDepartmentLead()instanceof Employee) {
- // Get managed lead employee
- final Employee managedEmployee = this.createManaged(department.getDepartmentLead());
-
- // Set it back
- department.setDepartmentLead(managedEmployee);
- }
-
- // Is "owning" user set?
- if (department.getDepartmentUserOwner()instanceof User) {
- // Get managed user
- final User managedUser = this.createManaged(department.getDepartmentUserOwner());
-
- // Set it back
- department.setDepartmentUserOwner(managedUser);
- }
-
- // Persist it
- this.getEntityManager().persist(department);
-
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addDepartment(): department.departmentId={1} - EXIT!", this.getClass().getSimpleName(), department.getDepartmentId())); //NOI18N
-
- // Return updated instance
- return department;
- }
-
- /**
- * Checks if given department's address is already persisted. The whole
- * (persisted) list is being loaded and each address is being matched
- * against the given department's address.
- * <p>
- * @param department Branch office being checked
- * <p>
- * @return Whether it has been found
- */
- private boolean isDepartmentFound (final Department department) {
- // Get whole list
- final List<Department> departments = this.departmentBean.allDepartments();
-
- // Default is not found
- boolean isFound = false;
-
- // Check all single addresses
- for (final Department dep : departments) {
- // Is the same address found?
- if (Departments.isSameDepartment(dep, department)) {
- // Found one
- isFound = true;
- break;
- }
- }
-
- // Return flag
- return isFound;
- }
-
-}
+++ /dev/null
-/*
- * 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.department;
-
-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.department.DepartmentNotFoundException;
-import org.mxchange.jfinancials.database.BaseFinancialsDatabaseBean;
-
-/**
- * A stateless session bean for general department purposes
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Stateless (name = "department", description = "A general statless bean for handling branch office data (all)")
-public class FinancialsDepartmentSessionBean extends BaseFinancialsDatabaseBean implements DepartmentSessionBeanRemote {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 58_467_386_571_701L;
-
- @Override
- @SuppressWarnings ("unchecked")
- public List<Department> allDepartments () {
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allDepartments: CALLED!", this.getClass().getSimpleName())); //NOI18N
-
- // Get query
- final Query query = this.getEntityManager().createNamedQuery("AllDepartments"); //NOI18N
-
- // Get list from it
- final List<Department> list = query.getResultList();
-
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allDepartments: list.size()={1} - EXIT!", this.getClass().getSimpleName(), list.size())); //NOI18N
-
- // Return it
- return list;
- }
-
- @Override
- public Department findDepartmentById (final Long departmentId) throws DepartmentNotFoundException {
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findDepartmentById: CALLED!", this.getClass().getSimpleName())); //NOI18N
-
- // Validate parameter
- if (null == departmentId) {
- // Throw NPE
- throw new NullPointerException("departmentId is null"); //NOI18N
- } else if (departmentId < 1) {
- // Throw NPE
- throw new NullPointerException(MessageFormat.format("departmentId={0}is invalid", departmentId)); //NOI18N
- }
-
- // Get query
- final Query query = this.getEntityManager().createNamedQuery("SearchDepartmentById", CompanyDepartment.class); //NOI18N
-
- // Set parameter
- query.setParameter("departmentId", departmentId); //NOI18N
-
- // Get single instance
- final Department department;
-
- // Try to find a result
- try {
- // Find a single result
- department = (Department) query.getSingleResult();
-
- // Log trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findDepartmentById: Found department={1}", this.getClass().getSimpleName(), department)); //NOI18N
- } catch (final NoResultException ex) {
- // No result found
- throw new DepartmentNotFoundException(departmentId, ex);
- }
-
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findDepartmentById: department={1} - EXIT!", this.getClass().getSimpleName(), department)); //NOI18N
-
- // Return it
- return department;
- }
-
-}
--- /dev/null
+/*
+ * 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.department;
+
+import java.text.MessageFormat;
+import java.util.Date;
+import java.util.List;
+import javax.ejb.EJB;
+import javax.ejb.Stateless;
+import org.mxchange.jcontactsbusiness.exceptions.department.DepartmentAlreadyAddedException;
+import org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData;
+import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice;
+import org.mxchange.jcontactsbusiness.model.employee.Employee;
+import org.mxchange.jcontactsbusiness.model.headquarters.HeadquartersData;
+import org.mxchange.jfinancials.database.BasePizzaEnterpriseBean;
+import org.mxchange.jusercore.model.user.User;
+
+/**
+ * A stateless session bean for administrative department purposes
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Stateless (name = "adminDepartment", description = "An administrative statless bean for handling department data (all)")
+public class PizzaAdminDepartmentSessionBean extends BasePizzaEnterpriseBean implements AdminDepartmentSessionBeanRemote {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 58_467_386_571_701L;
+
+ /**
+ * General department bean
+ */
+ @EJB (lookup = "java:global/jfinancials-ejb/department!org.mxchange.jcontactsbusiness.model.department.DepartmentSessionBeanRemote")
+ private DepartmentSessionBeanRemote departmentBean;
+
+ /**
+ * Default constructor
+ */
+ public PizzaAdminDepartmentSessionBean () {
+ // Call super constructor
+ super();
+ }
+
+ @Override
+ public Department addDepartment (final Department department) throws DepartmentAlreadyAddedException {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addDepartment(): department={1} - CALLED!", this.getClass().getSimpleName(), department)); //NOI18N
+
+ // Validate parameter
+ if (null == department) {
+ // Throw NPE
+ throw new NullPointerException("department is null"); //NOI18N
+ } else if (department.getDepartmentId() instanceof Long) {
+ // Should not happen
+ throw new IllegalArgumentException("department.departmentId should not be set."); //NOI18N
+ } else if (department.getDepartmentCompany() == null) {
+ // Throw NPE
+ throw new NullPointerException("department.departmentCompany is null"); //NOI18N
+ } else if (department.getDepartmentCompany().getBasicDataId() == null) {
+ // Throw NPE again
+ throw new NullPointerException("department.departmentCompany.basicDataId is null"); //NOI18N
+ } else if (department.getDepartmentCompany().getBasicDataId() < 1) {
+ // Throw IAE
+ throw new IllegalArgumentException(MessageFormat.format("department.departmentCompany.basicDataId={0} is invalid", department.getDepartmentCompany().getBasicDataId())); //NOI18N
+ } else if (department.getDepartmentI18nKey() == null) {
+ // Throw NPE
+ throw new NullPointerException("department.departmentName is null"); //NOI18N
+ } else if (department.getDepartmentI18nKey().isEmpty()) {
+ // Throw IAE
+ throw new NullPointerException("department.departmentName is empty"); //NOI18N
+ } else if (this.isDepartmentFound(department)) {
+ // Already added, abort here
+ throw new DepartmentAlreadyAddedException(department);
+ }
+
+ // Set created timestamp
+ department.setDepartmentCreated(new Date());
+
+ // Get managed basic data instance
+ final BusinessBasicData managedBasicData = this.createManaged(department.getDepartmentCompany());
+
+ // Set it back
+ department.setDepartmentCompany(managedBasicData);
+
+ // Is branch office set?
+ if (department.getDepartmentBranchOffice() instanceof BranchOffice) {
+ // Get managed branch office
+ final BranchOffice managedBranchOffice = this.createManaged(department.getDepartmentBranchOffice());
+
+ // Set it back
+ department.setDepartmentBranchOffice(managedBranchOffice);
+ }
+
+ // Is headquarters set?
+ if (department.getDepartmentHeadquarters() instanceof HeadquartersData) {
+ // Get managed headquarters
+ final HeadquartersData managedHeadquarters = this.createManaged(department.getDepartmentHeadquarters());
+
+ // Set it back
+ department.setDepartmentHeadquarters(managedHeadquarters);
+ }
+
+ // Is lead employee set?
+ if (department.getDepartmentLead()instanceof Employee) {
+ // Get managed lead employee
+ final Employee managedEmployee = this.createManaged(department.getDepartmentLead());
+
+ // Set it back
+ department.setDepartmentLead(managedEmployee);
+ }
+
+ // Is "owning" user set?
+ if (department.getDepartmentUserOwner()instanceof User) {
+ // Get managed user
+ final User managedUser = this.createManaged(department.getDepartmentUserOwner());
+
+ // Set it back
+ department.setDepartmentUserOwner(managedUser);
+ }
+
+ // Persist it
+ this.getEntityManager().persist(department);
+
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addDepartment(): department.departmentId={1} - EXIT!", this.getClass().getSimpleName(), department.getDepartmentId())); //NOI18N
+
+ // Return updated instance
+ return department;
+ }
+
+ /**
+ * Checks if given department's address is already persisted. The whole
+ * (persisted) list is being loaded and each address is being matched
+ * against the given department's address.
+ * <p>
+ * @param department Branch office being checked
+ * <p>
+ * @return Whether it has been found
+ */
+ private boolean isDepartmentFound (final Department department) {
+ // Get whole list
+ final List<Department> departments = this.departmentBean.allDepartments();
+
+ // Default is not found
+ boolean isFound = false;
+
+ // Check all single addresses
+ for (final Department dep : departments) {
+ // Is the same address found?
+ if (Departments.isSameDepartment(dep, department)) {
+ // Found one
+ isFound = true;
+ break;
+ }
+ }
+
+ // Return flag
+ return isFound;
+ }
+
+}
--- /dev/null
+/*
+ * 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.department;
+
+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.department.DepartmentNotFoundException;
+import org.mxchange.jfinancials.database.BasePizzaEnterpriseBean;
+
+/**
+ * A stateless session bean for general department purposes
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Stateless (name = "department", description = "A general statless bean for handling branch office data (all)")
+public class PizzaDepartmentSessionBean extends BasePizzaEnterpriseBean implements DepartmentSessionBeanRemote {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 58_467_386_571_701L;
+
+ @Override
+ @SuppressWarnings ("unchecked")
+ public List<Department> allDepartments () {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allDepartments: CALLED!", this.getClass().getSimpleName())); //NOI18N
+
+ // Get query
+ final Query query = this.getEntityManager().createNamedQuery("AllDepartments"); //NOI18N
+
+ // Get list from it
+ final List<Department> list = query.getResultList();
+
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allDepartments: list.size()={1} - EXIT!", this.getClass().getSimpleName(), list.size())); //NOI18N
+
+ // Return it
+ return list;
+ }
+
+ @Override
+ public Department findDepartmentById (final Long departmentId) throws DepartmentNotFoundException {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findDepartmentById: CALLED!", this.getClass().getSimpleName())); //NOI18N
+
+ // Validate parameter
+ if (null == departmentId) {
+ // Throw NPE
+ throw new NullPointerException("departmentId is null"); //NOI18N
+ } else if (departmentId < 1) {
+ // Throw NPE
+ throw new NullPointerException(MessageFormat.format("departmentId={0}is invalid", departmentId)); //NOI18N
+ }
+
+ // Get query
+ final Query query = this.getEntityManager().createNamedQuery("SearchDepartmentById", CompanyDepartment.class); //NOI18N
+
+ // Set parameter
+ query.setParameter("departmentId", departmentId); //NOI18N
+
+ // Get single instance
+ final Department department;
+
+ // Try to find a result
+ try {
+ // Find a single result
+ department = (Department) query.getSingleResult();
+
+ // Log trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findDepartmentById: Found department={1}", this.getClass().getSimpleName(), department)); //NOI18N
+ } catch (final NoResultException ex) {
+ // No result found
+ throw new DepartmentNotFoundException(departmentId, ex);
+ }
+
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findDepartmentById: department={1} - EXIT!", this.getClass().getSimpleName(), department)); //NOI18N
+
+ // Return it
+ return department;
+ }
+
+}
+++ /dev/null
-/*
- * 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.opening_time;
-
-import java.text.MessageFormat;
-import java.util.Date;
-import javax.ejb.Stateless;
-import org.mxchange.jfinancials.database.BaseFinancialsDatabaseBean;
-
-/**
- * A stateless session bean for administrative opening times purposes
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Stateless (name = "adminOpeningTimes", description = "An administrative statless bean for handling opening times")
-public class FinancialsAdminOpeningTimesSessionBean extends BaseFinancialsDatabaseBean implements AdminOpeningTimeSessionBeanRemote {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 58_467_386_571_701L;
-
- /**
- * Default constructor
- */
- public FinancialsAdminOpeningTimesSessionBean () {
- // Call super constructor
- super();
- }
-
- @Override
- public OpeningTime addOpeningTime (final OpeningTime openingTime) {
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addOpeningTimes(): openingTime={1} - CALLED!", this.getClass().getSimpleName(), openingTime)); //NOI18N
-
- // Validate parameter
- if (null == openingTime) {
- // Throw NPE
- throw new NullPointerException("openingTime is null"); //NOI18N
- } else if (openingTime.getOpeningId() instanceof Long) {
- // Should not happen
- throw new IllegalArgumentException("openingTime.openingId should not be set."); //NOI18N
- } else if (openingTime.getOpeningStartDay()== null) {
- // Throw NPE
- throw new NullPointerException("openingTime.openingStartDay is null"); //NOI18N
- } else if (openingTime.getOpeningStartTime()== null) {
- // Throw NPE
- throw new NullPointerException("openingTime.openingStartTime is null"); //NOI18N
- } else if (openingTime.getOpeningEndDay()== null) {
- // Throw NPE
- throw new NullPointerException("openingTime.openingEndDay is null"); //NOI18N
- } else if (openingTime.getOpeningEndTime()== null) {
- // Throw NPE
- throw new NullPointerException("openingTime.openingEndTime is null"); //NOI18N
- }
-
- // Set created timestamp
- openingTime.setOpeningCreated(new Date());
-
- // Persist it
- this.getEntityManager().persist(openingTime);
-
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addOpeningTimes(): openingTime.openingId={1} - EXIT!", this.getClass().getSimpleName(), openingTime.getOpeningId())); //NOI18N
-
- // Return updated instance
- return openingTime;
- }
-
-}
+++ /dev/null
-/*
- * 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.opening_time;
-
-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.opening_time.OpeningTimeNotFoundException;
-import org.mxchange.jfinancials.database.BaseFinancialsDatabaseBean;
-
-/**
- * A stateless session bean for general opening times purposes
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Stateless (name = "openingTimes", description = "A general statless bean for handling branch office data (all)")
-public class FinancialsOpeningTimesSessionBean extends BaseFinancialsDatabaseBean implements OpeningTimeSessionBeanRemote {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 58_467_386_571_701L;
-
- @Override
- @SuppressWarnings ("unchecked")
- public List<OpeningTime> allOpeningTimes () {
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allOpeningTimes: CALLED!", this.getClass().getSimpleName())); //NOI18N
-
- // Get query
- final Query query = this.getEntityManager().createNamedQuery("AllOpeningTimes"); //NOI18N
-
- // Get list from it
- final List<OpeningTime> list = query.getResultList();
-
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allOpeningTimes: list.size()={1} - EXIT!", this.getClass().getSimpleName(), list.size())); //NOI18N
-
- // Return it
- return list;
- }
-
- @Override
- public OpeningTime findOpeningTimesById (final Long departmentId) throws OpeningTimeNotFoundException {
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findOpeningTimesById: CALLED!", this.getClass().getSimpleName())); //NOI18N
-
- // Validate parameter
- if (null == departmentId) {
- // Throw NPE
- throw new NullPointerException("departmentId is null"); //NOI18N
- } else if (departmentId < 1) {
- // Throw NPE
- throw new NullPointerException(MessageFormat.format("departmentId={0}is invalid", departmentId)); //NOI18N
- }
-
- // Get query
- final Query query = this.getEntityManager().createNamedQuery("SearchOpeningTimesById", BusinessOpeningTime.class); //NOI18N
-
- // Set parameter
- query.setParameter("departmentId", departmentId); //NOI18N
-
- // Get single instance
- final OpeningTime department;
-
- // Try to find a result
- try {
- // Find a single result
- department = (OpeningTime) query.getSingleResult();
-
- // Log trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findOpeningTimesById: Found department={1}", this.getClass().getSimpleName(), department)); //NOI18N
- } catch (final NoResultException ex) {
- // No result found
- throw new OpeningTimeNotFoundException(departmentId, ex);
- }
-
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findOpeningTimesById: department={1} - EXIT!", this.getClass().getSimpleName(), department)); //NOI18N
-
- // Return it
- return department;
- }
-
-}
--- /dev/null
+/*
+ * 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.opening_time;
+
+import java.text.MessageFormat;
+import java.util.Date;
+import javax.ejb.Stateless;
+import org.mxchange.jfinancials.database.BasePizzaEnterpriseBean;
+
+/**
+ * A stateless session bean for administrative opening times purposes
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Stateless (name = "adminOpeningTimes", description = "An administrative statless bean for handling opening times")
+public class PizzaAdminOpeningTimesSessionBean extends BasePizzaEnterpriseBean implements AdminOpeningTimeSessionBeanRemote {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 58_467_386_571_701L;
+
+ /**
+ * Default constructor
+ */
+ public PizzaAdminOpeningTimesSessionBean () {
+ // Call super constructor
+ super();
+ }
+
+ @Override
+ public OpeningTime addOpeningTime (final OpeningTime openingTime) {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addOpeningTimes(): openingTime={1} - CALLED!", this.getClass().getSimpleName(), openingTime)); //NOI18N
+
+ // Validate parameter
+ if (null == openingTime) {
+ // Throw NPE
+ throw new NullPointerException("openingTime is null"); //NOI18N
+ } else if (openingTime.getOpeningId() instanceof Long) {
+ // Should not happen
+ throw new IllegalArgumentException("openingTime.openingId should not be set."); //NOI18N
+ } else if (openingTime.getOpeningStartDay()== null) {
+ // Throw NPE
+ throw new NullPointerException("openingTime.openingStartDay is null"); //NOI18N
+ } else if (openingTime.getOpeningStartTime()== null) {
+ // Throw NPE
+ throw new NullPointerException("openingTime.openingStartTime is null"); //NOI18N
+ } else if (openingTime.getOpeningEndDay()== null) {
+ // Throw NPE
+ throw new NullPointerException("openingTime.openingEndDay is null"); //NOI18N
+ } else if (openingTime.getOpeningEndTime()== null) {
+ // Throw NPE
+ throw new NullPointerException("openingTime.openingEndTime is null"); //NOI18N
+ }
+
+ // Set created timestamp
+ openingTime.setOpeningCreated(new Date());
+
+ // Persist it
+ this.getEntityManager().persist(openingTime);
+
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addOpeningTimes(): openingTime.openingId={1} - EXIT!", this.getClass().getSimpleName(), openingTime.getOpeningId())); //NOI18N
+
+ // Return updated instance
+ return openingTime;
+ }
+
+}
--- /dev/null
+/*
+ * 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.opening_time;
+
+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.opening_time.OpeningTimeNotFoundException;
+import org.mxchange.jfinancials.database.BasePizzaEnterpriseBean;
+
+/**
+ * A stateless session bean for general opening times purposes
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Stateless (name = "openingTimes", description = "A general statless bean for handling branch office data (all)")
+public class PizzaOpeningTimesSessionBean extends BasePizzaEnterpriseBean implements OpeningTimeSessionBeanRemote {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 58_467_386_571_701L;
+
+ @Override
+ @SuppressWarnings ("unchecked")
+ public List<OpeningTime> allOpeningTimes () {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allOpeningTimes: CALLED!", this.getClass().getSimpleName())); //NOI18N
+
+ // Get query
+ final Query query = this.getEntityManager().createNamedQuery("AllOpeningTimes"); //NOI18N
+
+ // Get list from it
+ final List<OpeningTime> list = query.getResultList();
+
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allOpeningTimes: list.size()={1} - EXIT!", this.getClass().getSimpleName(), list.size())); //NOI18N
+
+ // Return it
+ return list;
+ }
+
+ @Override
+ public OpeningTime findOpeningTimesById (final Long departmentId) throws OpeningTimeNotFoundException {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findOpeningTimesById: CALLED!", this.getClass().getSimpleName())); //NOI18N
+
+ // Validate parameter
+ if (null == departmentId) {
+ // Throw NPE
+ throw new NullPointerException("departmentId is null"); //NOI18N
+ } else if (departmentId < 1) {
+ // Throw NPE
+ throw new NullPointerException(MessageFormat.format("departmentId={0}is invalid", departmentId)); //NOI18N
+ }
+
+ // Get query
+ final Query query = this.getEntityManager().createNamedQuery("SearchOpeningTimesById", BusinessOpeningTime.class); //NOI18N
+
+ // Set parameter
+ query.setParameter("departmentId", departmentId); //NOI18N
+
+ // Get single instance
+ final OpeningTime department;
+
+ // Try to find a result
+ try {
+ // Find a single result
+ department = (OpeningTime) query.getSingleResult();
+
+ // Log trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findOpeningTimesById: Found department={1}", this.getClass().getSimpleName(), department)); //NOI18N
+ } catch (final NoResultException ex) {
+ // No result found
+ throw new OpeningTimeNotFoundException(departmentId, ex);
+ }
+
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findOpeningTimesById: department={1} - EXIT!", this.getClass().getSimpleName(), department)); //NOI18N
+
+ // Return it
+ return department;
+ }
+
+}
import javax.persistence.NoResultException;
import javax.persistence.Query;
import org.mxchange.jcountry.exceptions.CountryAlreadyAddedException;
-import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
+import org.mxchange.pizzaaplication.database.BasePizzaEnterpriseBean;
/**
* A singleton EJB for country informations
*/
@Startup
@Singleton (name = "country", description = "A singleton session-scoped bean for country informations")
-public class PizzaCountrySingletonBean extends BasePizzaDatabaseBean implements CountrySingletonBeanRemote {
+public class PizzaCountrySingletonBean extends BasePizzaEnterpriseBean implements CountrySingletonBeanRemote {
/**
* Serial number
import java.util.Date;
import javax.ejb.Stateless;
import org.mxchange.jphone.exceptions.MobileProviderAlreadyAddedException;
-import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
+import org.mxchange.pizzaaplication.database.BasePizzaEnterpriseBean;
/**
* Administrative singleton EJB for mobile provider informations
* @author Roland Häder<roland@mxchange.org>
*/
@Stateless (name = "adminMobileProvider", description = "A singleton session-scoped bean for mobile provider informations, admin-edition")
-public class PizzaAdminMobileProviderSessionBean extends BasePizzaDatabaseBean implements AdminMobileProviderSessionBeanRemote {
+public class PizzaAdminMobileProviderSessionBean extends BasePizzaEnterpriseBean implements AdminMobileProviderSessionBeanRemote {
/**
* Serial number
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.pizzaaplication.database.BasePizzaDatabaseBean;
+import org.mxchange.pizzaaplication.database.BasePizzaEnterpriseBean;
/**
* An EJB for administrative phone purposes
* @author Roland Häder<roland@mxchange.org>
*/
@Stateless (name = "adminPhone", description = "An administrative bean handling phone data")
-public class PizzaAdminPhoneSessionBean extends BasePizzaDatabaseBean implements AdminPhoneSessionBeanRemote {
+public class PizzaAdminPhoneSessionBean extends BasePizzaEnterpriseBean implements AdminPhoneSessionBeanRemote {
/**
* Serial number
import org.mxchange.jphone.model.phonenumbers.landline.LandLineNumber;
import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber;
import org.mxchange.jphone.model.phonenumbers.mobile.MobileNumber;
-import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
+import org.mxchange.pizzaaplication.database.BasePizzaEnterpriseBean;
/**
* A general phone EJB
* @author Roland Häder<roland@mxchange.org>
*/
@Stateless (name = "phone", description = "A bean handling phone data")
-public class PizzaPhoneSessionBean extends BasePizzaDatabaseBean implements PhoneSessionBeanRemote {
+public class PizzaPhoneSessionBean extends BasePizzaEnterpriseBean implements PhoneSessionBeanRemote {
/**
* Serial number
import org.mxchange.jusercore.exceptions.UserStatusUnconfirmedException;
import org.mxchange.jusercore.model.user.status.UserAccountStatus;
import org.mxchange.juserlogincore.model.user.register.UserRegistrationSessionBeanRemote;
-import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
+import org.mxchange.pizzaaplication.database.BasePizzaEnterpriseBean;
/**
* An administrative user EJB
* @author Roland Häder<roland@mxchange.org>
*/
@Stateless (name = "adminUser", description = "A bean handling the user data")
-public class PizzaAdminUserSessionBean extends BasePizzaDatabaseBean implements AdminUserSessionBeanRemote {
+public class PizzaAdminUserSessionBean extends BasePizzaEnterpriseBean implements AdminUserSessionBeanRemote {
/**
* Serial number
import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
import org.mxchange.jusercore.model.user.status.UserAccountStatus;
import org.mxchange.juserlogincore.model.user.register.UserRegistrationSessionBeanRemote;
-import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
+import org.mxchange.pizzaaplication.database.BasePizzaEnterpriseBean;
/**
* A user EJB
* @author Roland Häder<roland@mxchange.org>
*/
@Stateless (name = "user", description = "A bean handling the user data")
-public class PizzaUserSessionBean extends BasePizzaDatabaseBean implements UserSessionBeanRemote {
+public class PizzaUserSessionBean extends BasePizzaEnterpriseBean implements UserSessionBeanRemote {
/**
* Serial number
import javax.jms.MessageListener;
import javax.jms.ObjectMessage;
import org.mxchange.jusercore.model.user.User;
-import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
+import org.mxchange.pizzaaplication.database.BasePizzaEnterpriseBean;
/**
* A message-driven bean for adding user activity log
)
}
)
-public class PizzaUserActivityLogMessageBean extends BasePizzaDatabaseBean implements MessageListener {
+public class PizzaUserActivityLogMessageBean extends BasePizzaEnterpriseBean implements MessageListener {
/**
* Serial number
import javax.jms.JMSException;
import javax.jms.ObjectMessage;
import javax.persistence.Query;
-import org.mxchange.jcoreee.database.BaseDatabaseBean;
+import org.mxchange.jcoreee.database.BaseEnterpriseBean;
import org.mxchange.jusercore.model.user.User;
/**
- * An EJB for user activity log. This class extends BaseDatabaseBean and not
+ * An EJB for user activity log. This class extends BaseEnterpriseBean and not
* project-specific "base class". The simple reason is that this class requires
* no email queue as no emails are ever being sent from this class.
* <p>
* @author Roland Häder<roland@mxchange.org>
*/
@Stateless (name = "userActivity", description = "A bean handling the user data")
-public class PizzaUserActivitySessionBean extends BaseDatabaseBean implements UserActivityLogSessionBeanRemote {
+public class PizzaUserActivitySessionBean extends BaseEnterpriseBean implements UserActivityLogSessionBeanRemote {
/**
* Serial number
import org.mxchange.jusercore.model.email_address.EmailAddressChange;
import org.mxchange.jusercore.model.user.UserSessionBeanRemote;
import org.mxchange.juserlogincore.login.UserLoginUtils;
-import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
+import org.mxchange.pizzaaplication.database.BasePizzaEnterpriseBean;
/**
* A session-scoped bean for changing email addresses
* @author Roland Häder<roland@mxchange.org>
*/
@Stateless (name = "userEmailChange", description = "A bean handling user email changes")
-public class PizzaUserEmailChangeSessionBean extends BasePizzaDatabaseBean implements UserEmailChangeSessionBeanRemote {
+public class PizzaUserEmailChangeSessionBean extends BasePizzaEnterpriseBean implements UserEmailChangeSessionBeanRemote {
/**
* Serial number
import javax.ejb.Stateless;
import javax.persistence.Query;
import org.mxchange.jusercore.model.user.User;
-import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
+import org.mxchange.pizzaaplication.database.BasePizzaEnterpriseBean;
/**
* A user password history EJB
* @author Roland Häder<roland@mxchange.org>
*/
@Stateless (name = "userPasswordHistory", description = "A stateless EJB for user's password history. This bean does return the full user's password history and not limited. The application then needs to limit it to it's purpose.")
-public class PizzaUserPasswordHistorySessionBean extends BasePizzaDatabaseBean implements UserPasswordHistorySessionBeanRemote {
+public class PizzaUserPasswordHistorySessionBean extends BasePizzaEnterpriseBean implements UserPasswordHistorySessionBeanRemote {
/**
* Serial number
import org.mxchange.juserlogincore.exceptions.UserPasswordMismatchException;
import org.mxchange.juserlogincore.login.UserLoginUtils;
import org.mxchange.juserlogincore.model.user.register.UserRegistrationSessionBeanRemote;
-import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
+import org.mxchange.pizzaaplication.database.BasePizzaEnterpriseBean;
/**
* A session EJB for user logins
* @author Roland Häder<roland@mxchange.org>
*/
@Stateless (name = "userLogin", description = "A bean handling the user login for Pizza project")
-public class PizzaUserLoginSessionBean extends BasePizzaDatabaseBean implements UserLoginSessionBeanRemote {
+public class PizzaUserLoginSessionBean extends BasePizzaEnterpriseBean implements UserLoginSessionBeanRemote {
/**
* Serial number
import org.mxchange.jusercore.model.user.User;
import org.mxchange.jusercore.model.user.UserSessionBeanRemote;
import org.mxchange.juserlogincore.login.UserLoginUtils;
-import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
+import org.mxchange.pizzaaplication.database.BasePizzaEnterpriseBean;
/**
* A session-scoped bean for user registration
* @author Roland Häder<roland@mxchange.org>
*/
@Stateless (name = "userRegistration", description = "A bean handling the user registration")
-public class PizzaUserRegistrationSessionBean extends BasePizzaDatabaseBean implements UserRegistrationSessionBeanRemote {
+public class PizzaUserRegistrationSessionBean extends BasePizzaEnterpriseBean implements UserRegistrationSessionBeanRemote {
/**
* Serial number
import org.mxchange.jusercore.model.user.UserSessionBeanRemote;
import org.mxchange.jusercore.model.user.status.UserAccountStatus;
import org.mxchange.juserlogincore.model.user.register.UserRegistrationSessionBeanRemote;
-import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
+import org.mxchange.pizzaaplication.database.BasePizzaEnterpriseBean;
/**
* A session-based EJB for resending confirmation links
* @author Roland Häder<roland@mxchange.org>
*/
@Stateless (name = "userResendConfirmationLink", description = "A bean resending confirmation links")
-public class PizzaResendLinkSessionBean extends BasePizzaDatabaseBean implements ResendLinkSessionBeanRemote {
+public class PizzaResendLinkSessionBean extends BasePizzaEnterpriseBean implements ResendLinkSessionBeanRemote {
/**
* Serial number
+++ /dev/null
-/*
- * 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 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.pizzaaplication.database;
-
-import java.text.MessageFormat;
-import java.util.Date;
-import java.util.List;
-import java.util.Objects;
-import java.util.Properties;
-import javax.ejb.EJBException;
-import javax.jms.JMSException;
-import javax.jms.ObjectMessage;
-import javax.mail.Address;
-import javax.mail.internet.AddressException;
-import javax.mail.internet.InternetAddress;
-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.branchoffice.BranchOffice;
-import org.mxchange.jcontactsbusiness.model.branchoffice.CompanyBranchOffice;
-import org.mxchange.jcontactsbusiness.model.employee.CompanyEmployee;
-import org.mxchange.jcontactsbusiness.model.employee.Employee;
-import org.mxchange.jcontactsbusiness.model.headquarters.CompanyHeadquartersData;
-import org.mxchange.jcontactsbusiness.model.headquarters.HeadquartersData;
-import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTime;
-import org.mxchange.jcoreee.database.BaseDatabaseBean;
-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.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;
-import org.mxchange.jusercore.model.user.UserUtils;
-
-/**
- * A helper class for beans that access the database.
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public abstract class BasePizzaEnterpriseBean extends BaseDatabaseBean {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 12_895_410_275_811_963L;
-
- /**
- * Protected constructor
- */
- protected BasePizzaEnterpriseBean () {
- // Call super constructor
- super();
- }
-
- /**
- * Constructor with queue factory JNDI and queue JNDI names
- * <p>
- * @param factoryJndi JNDI name for queue factory
- * @param queueJndi JNDI name for email queue
- */
- protected BasePizzaEnterpriseBean (final String factoryJndi, final String queueJndi) {
- // Call super constructor
- super(factoryJndi, queueJndi);
- }
-
- /**
- * Updates all contact's phone entry's created timestamps
- * <p>
- * @param contact Contact instance to update
- */
- protected void setAllContactPhoneEntriesCreated (final Contact contact) {
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.setAllContactPhoneEntriesCreated: 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
- }
-
- // Get all phone instances
- final DialableLandLineNumber landLineNumber = contact.getContactLandLineNumber();
- final DialableFaxNumber faxNumber = contact.getContactFaxNumber();
- final DialableMobileNumber mobileNumber = contact.getContactMobileNumber();
-
- // Debug message
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.setAllContactPhoneEntriesCreated: landLineNumber={1},faxNumber={2},mobileNumber={3}", this.getClass().getSimpleName(), landLineNumber, faxNumber, mobileNumber)); //NOI18N
-
- // Is a phone number instance set?
- if ((landLineNumber instanceof DialableLandLineNumber) && (landLineNumber.getPhoneId() == null)) {
- // Debug message
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.setAllContactPhoneEntriesCreated: Setting created timestamp for land-line number ...", this.getClass().getSimpleName())); //NOI18N
-
- // Set updated timestamp
- landLineNumber.setPhoneEntryCreated(new Date());
- }
-
- // Is a fax number instance set?
- if ((faxNumber instanceof DialableFaxNumber) && (faxNumber.getPhoneId() == null)) {
- // Debug message
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.setAllContactPhoneEntriesCreated: Setting created timestamp for fax number ...", this.getClass().getSimpleName())); //NOI18N
-
- // Set updated timestamp
- faxNumber.setPhoneEntryCreated(new Date());
- }
-
- // Is a mobile number instance set?
- if ((mobileNumber instanceof DialableMobileNumber) && (mobileNumber.getPhoneId() == null)) {
- // Debug message
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.setAllContactPhoneEntriesCreated: Setting created timestamp for mobile number ...", this.getClass().getSimpleName())); //NOI18N
-
- // Set updated timestamp
- mobileNumber.setPhoneEntryCreated(new Date());
- }
-
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.setAllContactPhoneEntriesCreated: EXIT!", this.getClass().getSimpleName())); //NOI18N
- }
-
- /**
- * Returns a managed instance from given mobile number
- * <p>
- * @param mobileNumber Mobile instance
- * @param fetchedNumber Found mobile number in database
- * <p>
- * @return Managed instance
- */
- protected DialableMobileNumber createManaged (final DialableMobileNumber mobileNumber, final DialableMobileNumber fetchedNumber) {
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getDetached: mobileNumber={1},fetchedNumber={2} - CALLED!", this.getClass().getSimpleName(), mobileNumber, fetchedNumber)); //NOI18N
-
- // Should be valid
- if (null == mobileNumber) {
- // Throw NPE
- throw new NullPointerException("mobileNumber is null"); //NOI18N
- } else if (null == fetchedNumber) {
- // Throw NPE again
- throw new NullPointerException("fetchedNumber is null"); //NOI18N
- } else if (fetchedNumber.getPhoneId() == null) {
- // ..and again
- throw new NullPointerException("fetchedNumber.phoneId is null"); //NOI18N
- }
-
- // Debug message
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: fetchedNumber.phoneId={0}", fetchedNumber.getPhoneId())); //NOI18N
-
- // Init query instance
- final DialableMobileNumber foundNumber = this.getEntityManager().find(fetchedNumber.getClass(), fetchedNumber.getPhoneId());
-
- // Debug message
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: foundNumber={0}", foundNumber)); //NOI18N
-
- // Default is null
- DialableMobileNumber detachedNumber = null;
-
- // Is there a difference?
- if (!PhoneUtils.isSameMobileNumber(mobileNumber, fetchedNumber)) {
- // Merge this entry
- detachedNumber = this.getEntityManager().merge(foundNumber);
-
- // @TODO Copy all
- }
-
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getDetached: detachedNumber={1} - EXIT!", this.getClass().getSimpleName(), detachedNumber)); //NOI18N
-
- // Return it
- return detachedNumber;
- }
-
- /**
- * Returns a managed instance from given land-line number
- * <p>
- * @param landLineNumber Land-line instance
- * @param fetchedNumber Found land-line number in database
- * <p>
- * @return Managed instance
- */
- protected DialableLandLineNumber createManaged (final DialableLandLineNumber landLineNumber, final DialableLandLineNumber fetchedNumber) {
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getDetached: landLineNumber={1},fetchedNumber={2} - CALLED!", this.getClass().getSimpleName(), landLineNumber, fetchedNumber)); //NOI18N
-
- // Should be valid
- if (null == landLineNumber) {
- // Throw NPE
- throw new NullPointerException("landLineNumber is null"); //NOI18N
- } else if (null == fetchedNumber) {
- // Throw NPE again
- throw new NullPointerException("fetchedNumber is null"); //NOI18N
- } else if (fetchedNumber.getPhoneId() == null) {
- // ..and again
- throw new NullPointerException("landLineNumber.phoneId is null"); //NOI18N
- }
-
- // Debug message
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: fetchedNumber.phoneId={0}", fetchedNumber.getPhoneId())); //NOI18N
-
- // Init query instance
- final DialableLandLineNumber foundNumber = this.getEntityManager().find(fetchedNumber.getClass(), fetchedNumber.getPhoneId());
-
- // Debug message
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: foundNumber={0}", foundNumber)); //NOI18N
-
- // Default is null
- DialableLandLineNumber detachedNumber = null;
-
- // Is there a difference?
- if (!PhoneUtils.isSameLandLineNumber(landLineNumber, fetchedNumber)) {
- // Merge this entry
- detachedNumber = this.getEntityManager().merge(foundNumber);
-
- // @TODO Copy all
- }
-
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getDetached: detachedNumber={1} - EXIT!", this.getClass().getSimpleName(), detachedNumber)); //NOI18N
-
- // Return it
- return detachedNumber;
- }
-
- /**
- * Returns a managed instance from given fax number
- * <p>
- * @param faxNumber Fax instance
- * @param fetchedNumber Found fax number in database
- * <p>
- * @return Managed instance
- */
- protected DialableFaxNumber createManaged (final DialableFaxNumber faxNumber, final DialableFaxNumber fetchedNumber) {
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getDetached: faxNumber={1},fetchedNumber={2} - CALLED!", this.getClass().getSimpleName(), faxNumber, fetchedNumber)); //NOI18N
-
- // Should be valid
- if (null == faxNumber) {
- // Throw NPE
- throw new NullPointerException("faxNumber is null"); //NOI18N
- } else if (null == fetchedNumber) {
- // Throw NPE again
- throw new NullPointerException("fetchedNumber is null"); //NOI18N
- } else if (fetchedNumber.getPhoneId() == null) {
- // ..and again
- throw new NullPointerException("fetchedNumber.phoneId is null"); //NOI18N
- }
-
- // Debug message
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: fetchedNumber.phoneId={0}", fetchedNumber.getPhoneId())); //NOI18N
-
- // Init query instance
- final DialableFaxNumber foundNumber = this.getEntityManager().find(fetchedNumber.getClass(), fetchedNumber.getPhoneId());
-
- // Debug message
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: foundNumber={0}", foundNumber)); //NOI18N
-
- // Default is null
- DialableFaxNumber detachedNumber = null;
-
- // Is there a difference?
- if (!PhoneUtils.isSameFaxNumber(faxNumber, fetchedNumber)) {
- // Merge this entry
- detachedNumber = this.getEntityManager().merge(foundNumber);
-
- // @TODO Copy all
- }
-
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getDetached: detachedNumber={1} - EXIT!", this.getClass().getSimpleName(), detachedNumber)); //NOI18N
-
- // Return it
- return detachedNumber;
- }
-
- /**
- * Get back a managed instance from given contact
- * <p>
- * @param contact Unmanaged/detached contact instance
- * <p>
- * @return Managed contact instance
- */
- protected Contact createManaged (final Contact contact) {
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: contact={1} - CALLED!", this.getClass().getSimpleName(), contact)); //NOI18N
-
- // user should not be null
- if (null == contact) {
- // Abort here
- throw new NullPointerException("contact is null"); //NOI18N
- } else if (contact.getContactId() == null) {
- // Id is set
- throw new NullPointerException("contact.contactId is null"); //NOI18N
- } else if (contact.getContactId() < 1) {
- // Id is set
- throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is invalid", contact.getContactId())); //NOI18N
- }
-
- // Try to find it (should be there)
- final Contact managedContact = this.getEntityManager().find(UserContact.class, contact.getContactId());
-
- // Should be there
- assert (managedContact instanceof Contact) : "managedContact is null"; //NOI18N
-
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: managedContact={1} - EXIT!", this.getClass().getSimpleName(), managedContact)); //NOI18N
-
- // Return it
- return managedContact;
- }
-
- /**
- * Get back a managed instance from given country
- * <p>
- * @param country Unmanaged/detached country instance
- * <p>
- * @return Managed country instance
- */
- protected Country createManaged (final Country country) {
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: country={1} - CALLED!", this.getClass().getSimpleName(), country)); //NOI18N
-
- // user should not be null
- if (null == country) {
- // Abort here
- throw new NullPointerException("country is null"); //NOI18N
- } else if (country.getCountryId() == null) {
- // Id is set
- throw new NullPointerException("country.countryId is null"); //NOI18N
- } else if (country.getCountryId() < 1) {
- // Id is set
- throw new IllegalArgumentException(MessageFormat.format("country.countryId={0} is invalid", country.getCountryId())); //NOI18N
- }
-
- // Try to find it (should be there)
- final Country managedCountry = this.getEntityManager().find(CountryData.class, country.getCountryId());
-
- // Should be there
- assert (managedCountry instanceof Country) : "managedCountry is null"; //NOI18N
-
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: managedCountry={1} - EXIT!", this.getClass().getSimpleName(), managedCountry)); //NOI18N
-
- // Return it
- return managedCountry;
- }
-
- /**
- * Get back a managed instance from given basic data
- * <p>
- * @param basicData Unmanaged/detached basic data instance
- * <p>
- * @return Managed basic data instance
- */
- protected BusinessBasicData createManaged (final BusinessBasicData basicData) {
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: basicData={1} - CALLED!", this.getClass().getSimpleName(), basicData)); //NOI18N
-
- // user should not be null
- if (null == basicData) {
- // Abort here
- throw new NullPointerException("basicData is null"); //NOI18N
- } else if (basicData.getBasicDataId() == null) {
- // Id is set
- throw new NullPointerException("basicData.basicDataId is null"); //NOI18N
- } else if (basicData.getBasicDataId() < 1) {
- // Id is set
- throw new IllegalArgumentException(MessageFormat.format("basicData.basicDataId={0} is invalid", basicData.getBasicDataId())); //NOI18N
- }
-
- // Try to find it (should be there)
- final BusinessBasicData managedBasicData = this.getEntityManager().find(CompanyBasicData.class, basicData.getBasicDataId());
-
- // Should be there
- assert (managedBasicData instanceof BusinessBasicData) : "managedBasicData is null"; //NOI18N
-
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: managedBasicData={1} - EXIT!", this.getClass().getSimpleName(), managedBasicData)); //NOI18N
-
- // Return it
- return managedBasicData;
- }
-
- /**
- * Get back a managed instance from given branch office
- * <p>
- * @param branchOffice Unmanaged/detached branch office instance
- * <p>
- * @return Managed basic data instance
- */
- protected BranchOffice createManaged (final BranchOffice branchOffice) {
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: branchOffice={1} - CALLED!", this.getClass().getSimpleName(), branchOffice)); //NOI18N
-
- // user should not be null
- if (null == branchOffice) {
- // Abort here
- throw new NullPointerException("branchOffice is null"); //NOI18N
- } else if (branchOffice.getBranchId() == null) {
- // Id is set
- throw new NullPointerException("branchOffice.branchOfficeId is null"); //NOI18N
- } else if (branchOffice.getBranchId() < 1) {
- // Id is set
- throw new IllegalArgumentException(MessageFormat.format("branchOffice.branchOfficeId={0} is invalid", branchOffice.getBranchId())); //NOI18N
- }
-
- // Try to find it (should be there)
- final BranchOffice managedBranchOffice = this.getEntityManager().find(CompanyBranchOffice.class, branchOffice.getBranchId());
-
- // Should be there
- assert (managedBranchOffice instanceof BusinessBasicData) : "managedBranchOffice is null"; //NOI18N
-
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: managedBranchOffice={1} - EXIT!", this.getClass().getSimpleName(), managedBranchOffice)); //NOI18N
-
- // Return it
- return managedBranchOffice;
- }
-
- /**
- * Get back a managed instance from given employee
- * <p>
- * @param employee Unmanaged/detached employee instance
- * <p>
- * @return Managed employee instance
- */
- protected Employee createManaged (final Employee employee) {
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: employee={1} - CALLED!", this.getClass().getSimpleName(), employee)); //NOI18N
-
- // user should not be null
- if (null == employee) {
- // Abort here
- throw new NullPointerException("employee is null"); //NOI18N
- } else if (employee.getEmployeeId() == null) {
- // Id is set
- throw new NullPointerException("employee.employeeId is null"); //NOI18N
- } else if (employee.getEmployeeId() < 1) {
- // Id is set
- throw new IllegalArgumentException(MessageFormat.format("employee.employeeId={0} is invalid", employee.getEmployeeId())); //NOI18N
- }
-
- // Try to find it (should be there)
- final Employee managedEmployee = this.getEntityManager().find(CompanyEmployee.class, employee.getEmployeeId());
-
- // Should be there
- assert (managedEmployee instanceof Employee) : "managedEmployee is null"; //NOI18N
-
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: managedEmployee={1} - EXIT!", this.getClass().getSimpleName(), managedEmployee)); //NOI18N
-
- // Return it
- return managedEmployee;
- }
-
- /**
- * Get back a managed instance from given headquarters
- * <p>
- * @param headquarters Unmanaged/detached headquarters instance
- * <p>
- * @return Managed basic data instance
- */
- protected HeadquartersData createManaged (final HeadquartersData headquarters) {
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: branchOffice={1} - CALLED!", this.getClass().getSimpleName(), headquarters)); //NOI18N
-
- // user should not be null
- if (null == headquarters) {
- // Abort here
- throw new NullPointerException("branchOffice is null"); //NOI18N
- } else if (headquarters.getHeadquartersId() == null) {
- // Id is set
- throw new NullPointerException("branchOffice.headquartersId is null"); //NOI18N
- } else if (headquarters.getHeadquartersId() < 1) {
- // Id is set
- throw new IllegalArgumentException(MessageFormat.format("branchOffice.headquartersId={0} is invalid", headquarters.getHeadquartersId())); //NOI18N
- }
-
- // Try to find it (should be there)
- final HeadquartersData managedHeadquarters = this.getEntityManager().find(CompanyHeadquartersData.class, headquarters.getHeadquartersId());
-
- // Should be there
- assert (managedHeadquarters instanceof BusinessBasicData) : "managedHeadquarters is null"; //NOI18N
-
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: managedHeadquarters={1} - EXIT!", this.getClass().getSimpleName(), managedHeadquarters)); //NOI18N
-
- // Return it
- return managedHeadquarters;
- }
-
- /**
- * Get back a managed instance from given user
- * <p>
- * @param user Unmanaged/detached user instance
- * <p>
- * @return Managed user instance
- */
- protected User createManaged (final User user) {
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N
-
- // user should not be null
- if (null == user) {
- // Abort here
- throw new NullPointerException("user is null"); //NOI18N
- } else if (user.getUserId() == null) {
- // Id is set
- throw new NullPointerException("user.userId is null"); //NOI18N
- } else if (user.getUserId() < 1) {
- // Id is set
- throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is invalid", user.getUserId())); //NOI18N
- } else if (user.getUserContact() == null) {
- // Throw NPE again
- throw new NullPointerException("user.userContact is null"); //NOI18N
- } else if (user.getUserContact().getContactId() == null) {
- // Throw NPE again
- throw new NullPointerException("user.userContact.contactId is null"); //NOI18N
- } else if (user.getUserContact().getContactId() < 1) {
- // Not valid id number
- throw new IllegalArgumentException(MessageFormat.format("user.userContact.contactId={0} is not valid", user.getUserContact().getContactId())); //NOI18N#
- }
-
- // Try to find it (should be there)
- final User managedUser = this.getEntityManager().find(LoginUser.class, user.getUserId());
-
- // Should be there
- assert (managedUser instanceof User) : "managedUser is null"; //NOI18N
-
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: managedUser={1} - EXIT!", this.getClass().getSimpleName(), managedUser)); //NOI18N
-
- // Return it
- return managedUser;
- }
-
- /**
- * Sets created timestamp on all opening times.
- * <p>
- * @param openingTimes Opening times list
- * <p>
- * @throws NullPointerException If given list is null
- * @throws IllegalArgumentException If given list is empty
- * @throws IllegalStateException If openingId is not null
- */
- protected void setAllOpeningTimesCreated (final List<OpeningTime> openingTimes) {
- // Validate parameter
- if (null == openingTimes) {
- // Throw NPE
- throw new NullPointerException("openingTimes is null");
- } else if (openingTimes.isEmpty()) {
- // Throw IAE
- throw new IllegalArgumentException("openingTimes is empty");
- }
-
- // Walk through whole list
- for (final OpeningTime openingTime : openingTimes) {
- // Id should not be set
- if (openingTime.getOpeningId() != null) {
- // Abort here
- throw new IllegalStateException("openingTime.openingId is not null");
- }
-
- // Set created timestamp
- openingTime.setOpeningCreated(new Date());
- }
- }
-
- /**
- * Updates all contact's phone entry's created timestamps
- * <p>
- * @param contact Contact instance to update
- */
- protected void setAllPhoneEntriesCreated (final Contact contact) {
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("setAllPhoneEntriesCreated: contact={0} - CALLED!", contact)); //NOI18N
-
- // The contact instance must be valid
- if (null == contact) {
- // Throw NPE
- throw new NullPointerException("contact is null"); //NOI18N
- } else if (contact.getContactId() != null) {
- // Throw IAE
- throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is unexpected.", contact.getContactId()));
- }
-
- // Get all phone instances
- final DialableLandLineNumber landLineNumber = contact.getContactLandLineNumber();
- final DialableFaxNumber faxNumber = contact.getContactFaxNumber();
- final DialableMobileNumber mobileNumber = contact.getContactMobileNumber();
-
- // Debug message
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("setAllPhoneEntriesCreated: landLineNumber={0},faxNumber={1},mobileNumber={2}", landLineNumber, faxNumber, mobileNumber)); //NOI18N
-
- // Is a phone number instance set?
- if ((landLineNumber instanceof DialableLandLineNumber) && (landLineNumber.getPhoneId() == null)) {
- // Debug message
- this.getLoggerBeanLocal().logDebug("setAllPhoneEntriesCreated: Setting created timestamp for land-line number ..."); //NOI18N
-
- // Set updated timestamp
- landLineNumber.setPhoneEntryCreated(new Date());
- }
-
- // Is a fax number instance set?
- if ((faxNumber instanceof DialableFaxNumber) && (faxNumber.getPhoneId() == null)) {
- // Debug message
- this.getLoggerBeanLocal().logDebug("setAllPhoneEntriesCreated: Setting created timestamp for fax number ..."); //NOI18N
-
- // Set updated timestamp
- faxNumber.setPhoneEntryCreated(new Date());
- }
-
- // Is a mobile number instance set?
- if ((mobileNumber instanceof DialableMobileNumber) && (mobileNumber.getPhoneId() == null)) {
- // Debug message
- this.getLoggerBeanLocal().logDebug("setAllPhoneEntriesCreated: Setting created timestamp for mobile number ..."); //NOI18N
-
- // Set updated timestamp
- mobileNumber.setPhoneEntryCreated(new Date());
- }
-
- // Trace message
- this.getLoggerBeanLocal().logTrace("setAllPhoneEntriesCreated: EXIT!"); //NOI18N
- }
-
- /**
- * Updates all branch office's phone entry's created timestamps
- * <p>
- * @param branchOffice Branch office instance to update
- */
- protected void setAllPhoneEntriesCreated (final BranchOffice branchOffice) {
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("setAllPhoneEntriesCreated: branchOffice={0} - CALLED!", branchOffice)); //NOI18N
-
- // The contact instance must be valid
- if (null == branchOffice) {
- // Throw NPE again
- throw new NullPointerException("branchOffice is null"); //NOI18N
- } else if (branchOffice.getBranchId() != null) {
- // Throw IAE
- throw new IllegalArgumentException(MessageFormat.format("branchOffice.branchId={0} is unexpected.", branchOffice.getBranchId()));
- }
-
- // Get all phone instances
- final DialableLandLineNumber landLineNumber = branchOffice.getBranchLandLineNumber();
- final DialableFaxNumber faxNumber = branchOffice.getBranchFaxNumber();
-
- // Debug message
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("setAllPhoneEntriesCreated: landLineNumber={0},faxNumber={1}", landLineNumber, faxNumber)); //NOI18N
-
- // Is a phone number instance set?
- if ((landLineNumber instanceof DialableLandLineNumber) && (landLineNumber.getPhoneId() == null)) {
- // Debug message
- this.getLoggerBeanLocal().logDebug("setAllPhoneEntriesCreated: Setting created timestamp for land-line number ..."); //NOI18N
-
- // Set updated timestamp
- landLineNumber.setPhoneEntryCreated(new Date());
- }
-
- // Is a fax number instance set?
- if ((faxNumber instanceof DialableFaxNumber) && (faxNumber.getPhoneId() == null)) {
- // Debug message
- this.getLoggerBeanLocal().logDebug("setAllPhoneEntriesCreated: Setting created timestamp for fax number ..."); //NOI18N
-
- // Set updated timestamp
- faxNumber.setPhoneEntryCreated(new Date());
- }
-
- // Trace message
- this.getLoggerBeanLocal().logTrace("setAllPhoneEntriesCreated: EXIT!"); //NOI18N
- }
-
- /**
- * Updates all company's phone entry's created timestamps
- * <p>
- * @param basicData Company basic data instance to update
- */
- protected void setAllPhoneEntriesCreated (final BusinessBasicData basicData) {
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("setAllPhoneEntriesCreated: basicData={0} - CALLED!", basicData)); //NOI18N
-
- // The contact instance must be valid
- if (null == basicData) {
- // Throw NPE again
- throw new NullPointerException("basicData is null"); //NOI18N
- } else if (basicData.getBasicDataId() != null) {
- // Throw IAE
- throw new IllegalArgumentException(MessageFormat.format("basicData.basicDataId={0} is unexpected.", basicData.getBasicDataId()));
- }
-
- // Get all phone instances
- final DialableLandLineNumber landLineNumber = basicData.getCompanyLandLineNumber();
- final DialableFaxNumber faxNumber = basicData.getCompanyFaxNumber();
-
- // Debug message
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("setAllPhoneEntriesCreated: landLineNumber={0},faxNumber={1}", landLineNumber, faxNumber)); //NOI18N
-
- // Is a phone number instance set?
- if ((landLineNumber instanceof DialableLandLineNumber) && (landLineNumber.getPhoneId() == null)) {
- // Debug message
- this.getLoggerBeanLocal().logDebug("setAllPhoneEntriesCreated: Setting created timestamp for land-line number ..."); //NOI18N
-
- // Set updated timestamp
- landLineNumber.setPhoneEntryCreated(new Date());
-
- // Set it back in basic data
- basicData.setCompanyLandLineNumber(landLineNumber);
- }
-
- // Is a fax number instance set?
- if ((faxNumber instanceof DialableFaxNumber) && (faxNumber.getPhoneId() == null)) {
- // Debug message
- this.getLoggerBeanLocal().logDebug("setAllPhoneEntriesCreated: Setting created timestamp for fax number ..."); //NOI18N
-
- // Set updated timestamp
- faxNumber.setPhoneEntryCreated(new Date());
-
- // Set it back in basic data
- basicData.setCompanyFaxNumber(faxNumber);
- }
-
- // Trace message
- this.getLoggerBeanLocal().logTrace("setAllPhoneEntriesCreated: EXIT!"); //NOI18N
- }
-
- /**
- * Returns a detached instance from given mobile instance
- * <p>
- * @param mobileNumber Mobile instance
- * @param fetchedNumber Found mobile number in database
- * <p>
- * @return Detached instance
- */
- protected DialableMobileNumber getDetached (final DialableMobileNumber mobileNumber, final DialableMobileNumber fetchedNumber) {
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("getDetached: mobileNumber={0},fetchedNumber={1} - CALLED!", mobileNumber, fetchedNumber)); //NOI18N
-
- // Should be valid
- if (null == mobileNumber) {
- // Throw NPE
- throw new NullPointerException("mobileNumber is null"); //NOI18N
- } else if (fetchedNumber.getPhoneId() == null) {
- // ..and again
- throw new NullPointerException("fetchedNumber.phoneId is null"); //NOI18N
- }
-
- // Debug message
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: fetchedNumber.phoneId={0}", fetchedNumber.getPhoneId())); //NOI18N
-
- // Init query instance
- final DialableMobileNumber foundNumber = this.getEntityManager().find(fetchedNumber.getClass(), fetchedNumber.getPhoneId());
-
- // Debug message
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: foundNumber={0}", foundNumber)); //NOI18N
-
- // Default is null
- DialableMobileNumber detachedNumber = null;
-
- // Is there a difference?
- if (!PhoneUtils.isSameMobileNumber(mobileNumber, fetchedNumber)) {
- // Merge this entry
- detachedNumber = this.getEntityManager().merge(foundNumber);
-
- // @TODO Copy all
- }
-
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("getDetached: detachedNumber={0} - EXIT!", detachedNumber)); //NOI18N
-
- // Return it
- return detachedNumber;
- }
-
- /**
- * Returns a detached instance from given land-line instance
- * <p>
- * @param landLineNumber Land-line instance
- * @param fetchedNumber Found land-line number in database
- * <p>
- * @return Detached instance
- */
- protected DialableLandLineNumber getDetached (final DialableLandLineNumber landLineNumber, final DialableLandLineNumber fetchedNumber) {
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("getDetached: landLineNumber={0},fetchedNumber={1} - CALLED!", landLineNumber, fetchedNumber)); //NOI18N
-
- // Should be valid
- if (null == landLineNumber) {
- // Throw NPE
- throw new NullPointerException("landLineNumber is null"); //NOI18N
- } else if (fetchedNumber.getPhoneId() == null) {
- // ..and again
- throw new NullPointerException("landLineNumber.phoneId is null"); //NOI18N
- }
-
- // Debug message
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: fetchedNumber.phoneId={0}", fetchedNumber.getPhoneId())); //NOI18N
-
- // Init query instance
- final DialableLandLineNumber foundNumber = this.getEntityManager().find(fetchedNumber.getClass(), fetchedNumber.getPhoneId());
-
- // Debug message
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: foundNumber={0}", foundNumber)); //NOI18N
-
- // Default is null
- DialableLandLineNumber detachedNumber = null;
-
- // Is there a difference?
- if (!PhoneUtils.isSameLandLineNumber(landLineNumber, fetchedNumber)) {
- // Merge this entry
- detachedNumber = this.getEntityManager().merge(foundNumber);
-
- // @TODO Copy all
- }
-
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("getDetached: detachedNumber={0} - EXIT!", detachedNumber)); //NOI18N
-
- // Return it
- return detachedNumber;
- }
-
- /**
- * Returns a detached instance from given fax instance
- * <p>
- * @param faxNumber Fax instance
- * @param fetchedNumber Found fax number in database
- * <p>
- * @return Detached instance
- */
- protected DialableFaxNumber getDetached (final DialableFaxNumber faxNumber, final DialableFaxNumber fetchedNumber) {
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("getDetached: faxNumber={0},fetchedNumber={1} - CALLED!", faxNumber, fetchedNumber)); //NOI18N
-
- // Should be valid
- if (null == faxNumber) {
- // Throw NPE
- throw new NullPointerException("faxNumber is null"); //NOI18N
- } else if (fetchedNumber.getPhoneId() == null) {
- // ..and again
- throw new NullPointerException("fetchedNumber.phoneId is null"); //NOI18N
- }
-
- // Debug message
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: fetchedNumber.phoneId={0}", fetchedNumber.getPhoneId())); //NOI18N
-
- // Init query instance
- final DialableFaxNumber foundNumber = this.getEntityManager().find(fetchedNumber.getClass(), fetchedNumber.getPhoneId());
-
- // Debug message
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: foundNumber={0}", foundNumber)); //NOI18N
-
- // Default is null
- DialableFaxNumber detachedNumber = null;
-
- // Is there a difference?
- if (!PhoneUtils.isSameFaxNumber(faxNumber, fetchedNumber)) {
- // Merge this entry
- detachedNumber = this.getEntityManager().merge(foundNumber);
-
- // @TODO Copy all
- }
-
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("getDetached: detachedNumber={0} - EXIT!", detachedNumber)); //NOI18N
-
- // Return it
- return detachedNumber;
- }
-
- /**
- * Merges given contact's data
- * <p>
- * @param detachedContact Contact instance to merge
- * <p>
- * @return Detached contact instance
- */
- protected Contact mergeContactData (final Contact detachedContact) {
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.mergeContactData: contact={1} - CALLED!", this.getClass().getSimpleName(), detachedContact)); //NOI18N
-
- // The contact instance must be valid
- if (null == detachedContact) {
- // Throw NPE again
- throw new NullPointerException("detachedContact is null"); //NOI18N
- } else if (detachedContact.getContactId() == null) {
- // Throw NPE again
- throw new NullPointerException("detachedContact.contactId is null"); //NOI18N //NOI18N
- } else if (detachedContact.getContactId() < 1) {
- // Not valid
- throw new IllegalStateException(MessageFormat.format("{0}.detachedContact.contactId={1} is not valid.", this.getClass().getSimpleName(), detachedContact.getContactId())); //NOI18N
- }
-
- // Set updated timestamp
- detachedContact.setContactUpdated(new Date());
-
- // Get contact from it and find it
- final Contact foundContact = this.getEntityManager().find(detachedContact.getClass(), detachedContact.getContactId());
-
- // Should be found
- assert (foundContact instanceof Contact) : MessageFormat.format("Contact with id {0} not found, but should be.", detachedContact.getContactId()); //NOI18N
-
- // Debug message
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.updateUserPersonalData: foundContact.contactId={1}", this.getClass().getSimpleName(), foundContact.getContactId())); //NOI18N
-
- // Is a fax number set?
- if (detachedContact.getContactFaxNumber() instanceof DialableFaxNumber) {
- // Make fax numbers managed
- foundContact.setContactFaxNumber(this.createManaged(detachedContact.getContactFaxNumber(), detachedContact.getContactFaxNumber()));
- }
-
- // Is a land-line number set?
- if (detachedContact.getContactLandLineNumber() instanceof DialableLandLineNumber) {
- // Make land-line numbers managed
- foundContact.setContactLandLineNumber(this.createManaged(detachedContact.getContactLandLineNumber(), detachedContact.getContactLandLineNumber()));
- }
-
- // Is a mobile number set?
- if (detachedContact.getContactMobileNumber() instanceof DialableMobileNumber) {
- // Make mobile numbers managed
- foundContact.setContactMobileNumber(this.createManaged(detachedContact.getContactMobileNumber(), detachedContact.getContactMobileNumber()));
- }
-
- // Merge contact instance
- final Contact managedContact = this.getEntityManager().merge(foundContact);
-
- // Copy all
- ContactUtils.copyAll(detachedContact, managedContact);
-
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.mergeContactData: managedContact={1} - EXIT!", this.getClass().getSimpleName(), managedContact)); //NOI18N
-
- // Return detached contact
- return managedContact;
- }
-
- /**
- * Merges given (detached) contact's mobile, land-line and fax numbers
- * <p>
- * @param detachedContact Detached contact instance
- */
- protected void mergeContactsMobileLandLineFaxNumbers (final Contact detachedContact) {
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.mergeContactsMobileLandLineFaxNumbers: detachedContact={1} - CALLED!", this.getClass().getSimpleName(), detachedContact)); //NOI18N
-
- // The contact instance must be valid
- if (null == detachedContact) {
- // Throw NPE again
- throw new NullPointerException("detachedContact is null"); //NOI18N
- } else if (detachedContact.getContactId() == null) {
- // Throw NPE again
- throw new NullPointerException("detachedContact.contactId is null"); //NOI18N //NOI18N
- } else if (detachedContact.getContactId() < 1) {
- // Not valid
- throw new IllegalStateException(MessageFormat.format("{0}.detachedContact.contactId={1} is not valid.", this.getClass().getSimpleName(), detachedContact.getContactId())); //NOI18N
- }
-
- // Get all instances
- final DialableMobileNumber mobile = detachedContact.getContactMobileNumber();
- final DialableLandLineNumber landLine = detachedContact.getContactLandLineNumber();
- final DialableFaxNumber fax = detachedContact.getContactFaxNumber();
-
- // Is there a mobile instance set?
- if (mobile instanceof DialableMobileNumber) {
- // Debug message
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: mobile.phoneId={0} is being updated ...", mobile.getPhoneId())); //NOI18N
-
- // Then find it, too
- final DialableMobileNumber foundMobile = this.getEntityManager().find(mobile.getClass(), mobile.getPhoneId());
-
- // Should be there
- assert (foundMobile instanceof DialableMobileNumber) : MessageFormat.format("Mobile number with id {0} not found but should be.", foundMobile.getPhoneId()); //NOI18N
-
- // Then merge it, too
- final DialableMobileNumber managedMobile = this.getEntityManager().merge(foundMobile);
-
- // Should be there
- assert (managedMobile instanceof DialableMobileNumber) : MessageFormat.format("Mobile number with id {0} not found but should be.", managedMobile.getPhoneId()); //NOI18N
-
- // Copy all
- MobileNumbers.copyAll(detachedContact.getContactMobileNumber(), managedMobile);
-
- // Set it back
- detachedContact.setContactMobileNumber(managedMobile);
- }
-
- // Is there a fax instance set?
- if (fax instanceof DialableFaxNumber) {
- // Debug message
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: fax.phoneId={0} is being updated ...", fax.getPhoneId())); //NOI18N
-
- // Then find it, too
- final DialableFaxNumber foundFax = this.getEntityManager().find(fax.getClass(), fax.getPhoneId());
-
- // Should be there
- assert (foundFax instanceof DialableFaxNumber) : MessageFormat.format("Fax number with id {0} not found but should be.", foundFax.getPhoneId()); //NOI18N
-
- // Then merge it, too
- final DialableFaxNumber managedFax = this.getEntityManager().merge(foundFax);
-
- // Should be there
- assert (managedFax instanceof DialableFaxNumber) : MessageFormat.format("Fax number with id {0} not found but should be.", managedFax.getPhoneId()); //NOI18N
-
- // Copy all
- FaxNumbers.copyAll(detachedContact.getContactFaxNumber(), managedFax);
-
- // Set it back
- detachedContact.setContactFaxNumber(managedFax);
- }
-
- // Is there a fax instance set?
- if (landLine instanceof DialableLandLineNumber) {
- // Debug message
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: landLine.phoneId={0} is being updated ...", landLine.getPhoneId())); //NOI18N
-
- // Then find it, too
- final DialableLandLineNumber foundLandLine = this.getEntityManager().find(landLine.getClass(), landLine.getPhoneId());
-
- // Should be there
- assert (foundLandLine instanceof DialableLandLineNumber) : MessageFormat.format("Land line number with id {0} not found but should be.", foundLandLine.getPhoneId()); //NOI18N
-
- // Then merge it, too
- final DialableLandLineNumber managedLandLine = this.getEntityManager().merge(foundLandLine);
-
- // Should be there
- assert (managedLandLine instanceof DialableLandLineNumber) : MessageFormat.format("Land line number with id {0} not found but should be.", managedLandLine.getPhoneId()); //NOI18N
-
- // Copy all
- LandLineNumbers.copyAll(detachedContact.getContactLandLineNumber(), managedLandLine);
-
- // Set it back
- detachedContact.setContactLandLineNumber(managedLandLine);
- }
-
- // Trace message
- this.getLoggerBeanLocal().logTrace("mergeContactsMobileLandLineFaxNumbers: EXIT!"); //NOI18N
- }
-
- /**
- * Sends an email with given subject line, template name to given recipient
- * and user data
- * <p>
- * @param subjectLine Subject line
- * @param templateName Template name
- * @param user User instance
- * @param baseUrl Base URL
- * @param randomPassword A randomly-generated password or NULL if user had
- * to enter it.
- */
- protected void sendEmail (final String subjectLine, final String templateName, final User user, final String baseUrl, final String randomPassword) {
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("sendEmail: subjectLine={0},templateName={1},user={2},baseUrl={3} - CALLED!", subjectLine, templateName, user, baseUrl)); //NOI18N
-
- // All should be set
- if (null == subjectLine) {
- // Throw NPE
- throw new NullPointerException("subjectLine is null"); //NOI18N
- } else if (subjectLine.isEmpty()) {
- // No subject line
- throw new IllegalArgumentException("subjectLine is empty"); //NOI18N
- } else if (null == templateName) {
- // Throw NPE
- throw new NullPointerException("templateName is null"); //NOI18N
- } else if (templateName.isEmpty()) {
- // No template name
- throw new IllegalArgumentException("templateName is empty"); //NOI18N
- } else if (null == user) {
- // Throw NPE
- throw new NullPointerException("user is null"); //NOI18N
- } else if (user.getUserId() == null) {
- // Throw NPE again
- throw new NullPointerException("user.userId is null"); //NOI18N
- } else if (user.getUserId() < 1) {
- // Not valid number
- throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid.", user.getUserId())); //NOI18N
- } else if (user.getUserName() == null) {
- // Throw NPE again
- throw new NullPointerException("user.userName is null"); //NOI18N
- } else if (user.getUserName().isEmpty()) {
- // Empty string
- throw new IllegalArgumentException("user.userName is empty"); //NOI18N
- } else if (user.getUserAccountStatus() == null) {
- // Throw NPE
- throw new NullPointerException("user.userAccountStatus is null"); //NOI18N
- } else if (user.getUserContact() == null) {
- // Throw it again
- throw new NullPointerException("user.userContact is null"); //NOI18N
- } else if (user.getUserContact().getContactId() == null) {
- // .. and again
- throw new NullPointerException("user.userContact.contactId is null"); //NOI18N
- } else if (user.getUserContact().getContactId() < 1) {
- // Invalid id
- throw new IllegalArgumentException(MessageFormat.format("user.userContact.contactId={0} is invalid", user.getUserContact().getContactId())); //NOI18N
- } else if (user.getUserContact().getContactPersonalTitle() == null) {
- // Throw NPE again
- throw new NullPointerException("user.userContact.contactPersonalTitle is null"); //NOI18N
- } else if (user.getUserLocale() == null) {
- // Throw NPE again
- throw new NullPointerException("user.userLocale is null"); //NOI18N
- } else if (this.getSession() == null) {
- // Throw NPE
- throw new NullPointerException("this.session is not set. Have you forgotten to call super(String, String) and called only super() ?"); //NOI18N
- }
-
- // Set all values
- final Properties variables = UserUtils.getAllUserFields(user);
-
- // Set base URL and random password
- variables.put("baseUrl", baseUrl); //NOI18N
- variables.put("randomPassword", ""); //NOI18N
-
- // Is the random password set?
- if ((randomPassword instanceof String) && (!randomPassword.isEmpty())) {
- variables.put("randomPassword", randomPassword); //NOI18N
- }
-
- // Init addresss
- final Address recipientAddress;
-
- try {
- // Create email address and set
- recipientAddress = new InternetAddress(user.getUserContact().getContactEmailAddress());
- } catch (final AddressException ex) {
- // Throw again
- throw new EJBException(ex);
- }
-
- // Prepare mail wrapper
- // @TODO Language from message bundle
- final WrapableEmailDelivery emailWrapper = new EmailDeliveryWrapper(recipientAddress, subjectLine, templateName, variables, user.getUserLocale());
-
- try {
- // Send out email change
- final ObjectMessage message = this.getSession().createObjectMessage();
- message.setObject(emailWrapper);
-
- // Send message
- this.sendMessage(message);
- } catch (final JMSException ex) {
- // Throw again
- throw new EJBException(ex);
- }
-
- // Trace message
- this.getLoggerBeanLocal().logTrace("sendEmail: EXIT!"); //NOI18N
- }
-
- /**
- * Updates all contact's phone instances from other contact, both contacts
- * should be the same.
- * <p>
- * @param contact Contact to set instances
- * @param other Other contact to get instances from
- */
- protected void setAllContactPhoneEntries (final Contact contact, final Contact other) {
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.setAllContactPhoneEntries: contact={1},other={2} - CALLED!", this.getClass().getSimpleName(), contact, other)); //NOI18N
-
- // Both must be the same and not null
- if (null == contact) {
- // Throw NPE
- throw new NullPointerException("contact is null"); //NOI18N
- } else if (null == other) {
- // Throw NPE
- throw new NullPointerException("other is null"); //NOI18N
- } else if (!Objects.equals(contact, other)) {
- // Not same instances
- throw new IllegalArgumentException(MessageFormat.format("contact={0} and other={1} are not equal!", contact, other)); //NOI18N
- }
-
- // Debug message
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.setAllContactPhoneEntries: other.contactMobileNumber={0}", other.getContactMobileNumber())); //NOI18N
-
- // Is other mobile not set?
- if ((other.getContactMobileNumber() == null) || (PhoneUtils.isSameMobileNumber(contact.getContactMobileNumber(), other.getContactMobileNumber()))) {
- // Debug message
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.setAllContactPhoneEntries: Copying mobile entry ...", this.getClass().getSimpleName())); //NOI18N
-
- // Is the fax number set?
- if (other.getContactMobileNumber() instanceof DialableMobileNumber) {
- // Copy mobile number
- contact.setContactMobileNumber(this.createManaged(other.getContactMobileNumber(), contact.getContactMobileNumber()));
- } else {
- // Null it
- contact.setContactMobileNumber(null);
- }
- }
-
- // Debug message
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.setAllContactPhoneEntries: other.contactLandLineNumber={0}", other.getContactLandLineNumber())); //NOI18N
-
- // Is other mobile not set?
- if ((other.getContactLandLineNumber() == null) || (PhoneUtils.isSameLandLineNumber(contact.getContactLandLineNumber(), other.getContactLandLineNumber()))) {
- // Debug message
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.setAllContactPhoneEntries: Copying land-line entry ...", this.getClass().getSimpleName())); //NOI18N
-
- // Is the land-line number set?
- if (other.getContactLandLineNumber() instanceof DialableLandLineNumber) {
- // Copy land-line number
- contact.setContactLandLineNumber(this.createManaged(other.getContactLandLineNumber(), contact.getContactLandLineNumber()));
- } else {
- // Null it
- contact.setContactLandLineNumber(null);
- }
- }
-
- // Debug message
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.setAllContactPhoneEntries: other.contactFaxNumber={1}", this.getClass().getSimpleName(), other.getContactFaxNumber())); //NOI18N
-
- // Is other mobile not set?
- if ((other.getContactFaxNumber() == null) || (PhoneUtils.isSameFaxNumber(contact.getContactFaxNumber(), other.getContactFaxNumber()))) {
- // Debug message
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.setAllContactPhoneEntries: Copying fax entry ...", this.getClass().getSimpleName())); //NOI18N
-
- // Is the fax number set?
- if (other.getContactFaxNumber() instanceof DialableFaxNumber) {
- // Copy fax number
- contact.setContactFaxNumber(this.createManaged(other.getContactFaxNumber(), contact.getContactFaxNumber()));
- } else {
- // Null it
- contact.setContactFaxNumber(null);
- }
- }
-
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.setAllContactPhoneEntries: EXIT!", this.getClass().getSimpleName())); //NOI18N
- }
-
- /**
- * Updates all contact's phone entry's updated timestamps
- * <p>
- * @param contact Contact instance to update
- * @param isMobileUnlinked Whether a mobile entry has been unlinked in
- * contact instance
- * @param isLandlineUnlinked Whether a land-line entry has been unlinked in
- * contact instance
- * @param isFaxUnlinked Whether a fax entry has been unlinked in
- * contact instance
- */
- protected void setAllContactPhoneEntriesUpdated (final Contact contact, final boolean isMobileUnlinked, final boolean isLandlineUnlinked, final boolean isFaxUnlinked) {
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.setAllContactPhoneEntriesUpdated: 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 //NOI18N
- } else if (contact.getContactId() < 1) {
- // Not valid
- throw new IllegalStateException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
- }
-
- // Get all phone instances
- final DialableLandLineNumber landLineNumber = contact.getContactLandLineNumber();
- final DialableFaxNumber faxNumber = contact.getContactFaxNumber();
- final DialableMobileNumber mobileNumber = contact.getContactMobileNumber();
-
- // Flags and instances must be constistent
- if (isMobileUnlinked && mobileNumber instanceof DialableMobileNumber) {
- // Bad state
- throw new IllegalStateException("isCellPhoneUnlinked is TRUE, but mobileNumber is set."); //NOI18N
- } else if (isLandlineUnlinked && landLineNumber instanceof DialableLandLineNumber) {
- // Bad state
- throw new IllegalStateException("isLandlineUnlinked is TRUE, but landLineNumber is set."); //NOI18N
- } else if (isFaxUnlinked && faxNumber instanceof DialableFaxNumber) {
- // Bad state
- throw new IllegalStateException("isFaxUnlinked is TRUE, but faxNumber is set."); //NOI18N
- }
-
- // Is a phone number instance set?
- if ((landLineNumber instanceof DialableLandLineNumber) && (landLineNumber.getPhoneId() instanceof Long) && (landLineNumber.getPhoneId() > 0)) {
- // Debug message
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.setAllContactPhoneEntriesUpdated: Setting updated timestamp for land-line number ...", this.getClass().getSimpleName())); //NOI18N
-
- // Set updated timestamp
- landLineNumber.setPhoneEntryUpdated(new Date());
- }
-
- // Is a fax number instance set?
- if ((faxNumber instanceof DialableFaxNumber) && (faxNumber.getPhoneId() instanceof Long) && (faxNumber.getPhoneId() > 0)) {
- // Debug message
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.setAllContactPhoneEntriesUpdated: Setting updated timestamp for fax number ...", this.getClass().getSimpleName())); //NOI18N
-
- // Set updated timestamp
- faxNumber.setPhoneEntryUpdated(new Date());
- }
-
- // Is a mobile number instance set?
- if ((mobileNumber instanceof DialableMobileNumber) && (mobileNumber.getPhoneId() instanceof Long) && (mobileNumber.getPhoneId() > 0)) {
- // Debug message
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.setAllContactPhoneEntriesUpdated: Setting updated timestamp for mobile number ...", this.getClass().getSimpleName())); //NOI18N
-
- // Set updated timestamp
- mobileNumber.setPhoneEntryUpdated(new Date());
- }
-
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.setAllContactPhoneEntriesUpdated: EXIT!", this.getClass().getSimpleName())); //NOI18N
- }
-
-}
+++ /dev/null
-/*
- * 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.jfinancials.model.receipt;
-
-import java.text.MessageFormat;
-import java.util.GregorianCalendar;
-import java.util.List;
-import java.util.Objects;
-import javax.ejb.Stateless;
-import javax.persistence.Query;
-import org.mxchange.jfinancials.database.BaseFinancialsDatabaseBean;
-import org.mxchange.jfinancials.exceptions.ReceiptAlreadyAddedException;
-import org.mxchange.jusercore.model.user.User;
-
-/**
- * A stateless bean for general purposes for receipts
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Stateless (name = "financialReceipt", description = "A stateless session bean for handling receipts.")
-public class FinancialReceiptSessionBean extends BaseFinancialsDatabaseBean implements FinancialReceiptSessionBeanRemote {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 659_868_076_723_741L;
-
- @Override
- public BillableReceipt addReceipt (final BillableReceipt receipt) throws ReceiptAlreadyAddedException {
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addReceipt(): receipt={1} - CALLED!", this.getClass().getSimpleName(), receipt));
-
- // Validate parameter
- if (null == receipt) {
- // Throw NPE
- throw new NullPointerException("receipt is null");
- } else if (receipt.getReceiptId() != null) {
- // Throw IAE
- throw new IllegalArgumentException(MessageFormat.format("receipt.receiptId={0} is not expected.", receipt.getReceiptId()));
- } else if (receipt.getReceiptIssued() == null) {
- // Throw NPE again
- throw new NullPointerException("receipt.receiptIssued is null");
- } else if (receipt.getReceiptBranchOffice() == null) {
- // Throw it again
- throw new NullPointerException("receipt.receiptBranchOffice is null");
- } else if (receipt.getReceiptBranchOffice().getBranchId() == null) {
- // Throw it again
- throw new NullPointerException("receipt.receiptBranchOffice.branchId is null");
- } else if (receipt.getReceiptBranchOffice().getBranchId() < 1) {
- // Throw IAE
- throw new IllegalArgumentException(MessageFormat.format("receipt.receiptBranchOffice.branchId={0} is not valid.", receipt.getReceiptBranchOffice().getBranchId()));
- } else if (receipt.getReceiptPaymentType() == null) {
- // Throw NPE
- throw new NullPointerException("receipt.receiptPaymentType is null");
- } else if ((receipt.getReceiptUser() instanceof User) && receipt.getReceiptUser().getUserId() == null) {
- // Throw NPE again
- throw new NullPointerException("receipt.receiptUser.userId is null");
- } else if ((receipt.getReceiptUser() instanceof User) && receipt.getReceiptUser().getUserId() < 1) {
- // Throw NPE again
- throw new NullPointerException(MessageFormat.format("receipt.receiptUser.userId={0} is not valid", receipt.getReceiptUser().getUserId()));
- } else if (this.isReceiptRegistered(receipt)) {
- // Has already been registered
- throw new ReceiptAlreadyAddedException(receipt);
- }
-
- // Add created instance
- receipt.setReceiptCreated(new GregorianCalendar());
-
- // Persist it
- this.getEntityManager().persist(receipt);
-
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addReceipt(): receipt.receiptId={1} - EXIT!", this.getClass().getSimpleName(), receipt.getReceiptId()));
-
- // Return it
- return receipt;
- }
-
- @Override
- @SuppressWarnings ("unchecked")
- public List<BillableReceipt> allReceipts () {
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allReceipts(): CALLED!", this.getClass().getSimpleName()));
-
- // Query all
- final Query query = this.getEntityManager().createNamedQuery("AllReceipts");
-
- // Get all
- final List<BillableReceipt> receipts = query.getResultList();
-
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allReceipts(): receipts.size()={1} EXIT!", this.getClass().getSimpleName(), receipts.size()));
-
- // Return it
- return receipts;
- }
-
- @Override
- @SuppressWarnings ("unchecked")
- public List<BillableReceipt> allUsersReceipts (final User user) {
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allUsersReceipts(): user={1} - CALLED!", this.getClass().getSimpleName(), user));
-
- // Validate parameter
- if (null == user) {
- // Throw NPE
- throw new NullPointerException("user is null");
- } else if (user.getUserId() == null) {
- // Throw it again
- throw new NullPointerException("user.userId is null");
- } else if (user.getUserId() < 1) {
- // Throw IAE
- throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid", user.getUserId()));
- }
-
- // Query all
- final Query query = this.getEntityManager().createNamedQuery("SearchAllUserReceipts");
-
- // Add parameter
- query.setParameter("receiptUser", user);
-
- // Get all
- final List<BillableReceipt> receipts = query.getResultList();
-
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allUsersReceipts(): receipts.size()={1} EXIT!", this.getClass().getSimpleName(), receipts.size()));
-
- // Return it
- return receipts;
- }
-
- /**
- * Checks if given receipt is already persisted by checking receipt number
- * and branch office combination.
- * <p>
- * @param receipt Receipt instance
- * <p>
- * @return Whether the receipt has already been registered
- */
- private boolean isReceiptRegistered (final BillableReceipt receipt) {
- // Get all receipts
- final List<BillableReceipt> receipts = this.allReceipts();
-
- // Is the list empty?
- if (receipts.isEmpty()) {
- // Abort here
- return false;
- }
-
- // Default is not found
- boolean isFound = false;
-
- // Now, check each entry
- for (final BillableReceipt foundReceipt : receipts) {
- // Is same entity or same receipt number and branch office found?
- if (Objects.equals(foundReceipt, receipt)) {
- // Yes, then stop searching
- isFound = true;
- break;
- } else if (Receipts.isSameReceipt(foundReceipt, receipt)){
- // Yes, then stop searching
- isFound = true;
- break;
- }
- }
-
- // Return flag
- return isFound;
- }
-
-}
--- /dev/null
+/*
+ * 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 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.pizzaaplication.enterprise;
+
+import java.text.MessageFormat;
+import java.util.Date;
+import java.util.List;
+import java.util.Objects;
+import java.util.Properties;
+import javax.ejb.EJBException;
+import javax.jms.JMSException;
+import javax.jms.ObjectMessage;
+import javax.mail.Address;
+import javax.mail.internet.AddressException;
+import javax.mail.internet.InternetAddress;
+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.branchoffice.BranchOffice;
+import org.mxchange.jcontactsbusiness.model.branchoffice.CompanyBranchOffice;
+import org.mxchange.jcontactsbusiness.model.employee.CompanyEmployee;
+import org.mxchange.jcontactsbusiness.model.employee.Employee;
+import org.mxchange.jcontactsbusiness.model.headquarters.CompanyHeadquartersData;
+import org.mxchange.jcontactsbusiness.model.headquarters.HeadquartersData;
+import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTime;
+import org.mxchange.jcoreee.database.BaseEnterpriseBean;
+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.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;
+import org.mxchange.jusercore.model.user.UserUtils;
+
+/**
+ * A helper class for beans that access the database.
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public abstract class BasePizzaEnterpriseBean extends BaseEnterpriseBean {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 12_895_410_275_811_963L;
+
+ /**
+ * Protected constructor
+ */
+ protected BasePizzaEnterpriseBean () {
+ // Call super constructor
+ super();
+ }
+
+ /**
+ * Constructor with queue factory JNDI and queue JNDI names
+ * <p>
+ * @param factoryJndi JNDI name for queue factory
+ * @param queueJndi JNDI name for email queue
+ */
+ protected BasePizzaEnterpriseBean (final String factoryJndi, final String queueJndi) {
+ // Call super constructor
+ super(factoryJndi, queueJndi);
+ }
+
+ /**
+ * Updates all contact's phone entry's created timestamps
+ * <p>
+ * @param contact Contact instance to update
+ */
+ protected void setAllContactPhoneEntriesCreated (final Contact contact) {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.setAllContactPhoneEntriesCreated: 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
+ }
+
+ // Get all phone instances
+ final DialableLandLineNumber landLineNumber = contact.getContactLandLineNumber();
+ final DialableFaxNumber faxNumber = contact.getContactFaxNumber();
+ final DialableMobileNumber mobileNumber = contact.getContactMobileNumber();
+
+ // Debug message
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.setAllContactPhoneEntriesCreated: landLineNumber={1},faxNumber={2},mobileNumber={3}", this.getClass().getSimpleName(), landLineNumber, faxNumber, mobileNumber)); //NOI18N
+
+ // Is a phone number instance set?
+ if ((landLineNumber instanceof DialableLandLineNumber) && (landLineNumber.getPhoneId() == null)) {
+ // Debug message
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.setAllContactPhoneEntriesCreated: Setting created timestamp for land-line number ...", this.getClass().getSimpleName())); //NOI18N
+
+ // Set updated timestamp
+ landLineNumber.setPhoneEntryCreated(new Date());
+ }
+
+ // Is a fax number instance set?
+ if ((faxNumber instanceof DialableFaxNumber) && (faxNumber.getPhoneId() == null)) {
+ // Debug message
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.setAllContactPhoneEntriesCreated: Setting created timestamp for fax number ...", this.getClass().getSimpleName())); //NOI18N
+
+ // Set updated timestamp
+ faxNumber.setPhoneEntryCreated(new Date());
+ }
+
+ // Is a mobile number instance set?
+ if ((mobileNumber instanceof DialableMobileNumber) && (mobileNumber.getPhoneId() == null)) {
+ // Debug message
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.setAllContactPhoneEntriesCreated: Setting created timestamp for mobile number ...", this.getClass().getSimpleName())); //NOI18N
+
+ // Set updated timestamp
+ mobileNumber.setPhoneEntryCreated(new Date());
+ }
+
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.setAllContactPhoneEntriesCreated: EXIT!", this.getClass().getSimpleName())); //NOI18N
+ }
+
+ /**
+ * Returns a managed instance from given mobile number
+ * <p>
+ * @param mobileNumber Mobile instance
+ * @param fetchedNumber Found mobile number in database
+ * <p>
+ * @return Managed instance
+ */
+ protected DialableMobileNumber createManaged (final DialableMobileNumber mobileNumber, final DialableMobileNumber fetchedNumber) {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getDetached: mobileNumber={1},fetchedNumber={2} - CALLED!", this.getClass().getSimpleName(), mobileNumber, fetchedNumber)); //NOI18N
+
+ // Should be valid
+ if (null == mobileNumber) {
+ // Throw NPE
+ throw new NullPointerException("mobileNumber is null"); //NOI18N
+ } else if (null == fetchedNumber) {
+ // Throw NPE again
+ throw new NullPointerException("fetchedNumber is null"); //NOI18N
+ } else if (fetchedNumber.getPhoneId() == null) {
+ // ..and again
+ throw new NullPointerException("fetchedNumber.phoneId is null"); //NOI18N
+ }
+
+ // Debug message
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: fetchedNumber.phoneId={0}", fetchedNumber.getPhoneId())); //NOI18N
+
+ // Init query instance
+ final DialableMobileNumber foundNumber = this.getEntityManager().find(fetchedNumber.getClass(), fetchedNumber.getPhoneId());
+
+ // Debug message
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: foundNumber={0}", foundNumber)); //NOI18N
+
+ // Default is null
+ DialableMobileNumber detachedNumber = null;
+
+ // Is there a difference?
+ if (!PhoneUtils.isSameMobileNumber(mobileNumber, fetchedNumber)) {
+ // Merge this entry
+ detachedNumber = this.getEntityManager().merge(foundNumber);
+
+ // @TODO Copy all
+ }
+
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getDetached: detachedNumber={1} - EXIT!", this.getClass().getSimpleName(), detachedNumber)); //NOI18N
+
+ // Return it
+ return detachedNumber;
+ }
+
+ /**
+ * Returns a managed instance from given land-line number
+ * <p>
+ * @param landLineNumber Land-line instance
+ * @param fetchedNumber Found land-line number in database
+ * <p>
+ * @return Managed instance
+ */
+ protected DialableLandLineNumber createManaged (final DialableLandLineNumber landLineNumber, final DialableLandLineNumber fetchedNumber) {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getDetached: landLineNumber={1},fetchedNumber={2} - CALLED!", this.getClass().getSimpleName(), landLineNumber, fetchedNumber)); //NOI18N
+
+ // Should be valid
+ if (null == landLineNumber) {
+ // Throw NPE
+ throw new NullPointerException("landLineNumber is null"); //NOI18N
+ } else if (null == fetchedNumber) {
+ // Throw NPE again
+ throw new NullPointerException("fetchedNumber is null"); //NOI18N
+ } else if (fetchedNumber.getPhoneId() == null) {
+ // ..and again
+ throw new NullPointerException("landLineNumber.phoneId is null"); //NOI18N
+ }
+
+ // Debug message
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: fetchedNumber.phoneId={0}", fetchedNumber.getPhoneId())); //NOI18N
+
+ // Init query instance
+ final DialableLandLineNumber foundNumber = this.getEntityManager().find(fetchedNumber.getClass(), fetchedNumber.getPhoneId());
+
+ // Debug message
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: foundNumber={0}", foundNumber)); //NOI18N
+
+ // Default is null
+ DialableLandLineNumber detachedNumber = null;
+
+ // Is there a difference?
+ if (!PhoneUtils.isSameLandLineNumber(landLineNumber, fetchedNumber)) {
+ // Merge this entry
+ detachedNumber = this.getEntityManager().merge(foundNumber);
+
+ // @TODO Copy all
+ }
+
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getDetached: detachedNumber={1} - EXIT!", this.getClass().getSimpleName(), detachedNumber)); //NOI18N
+
+ // Return it
+ return detachedNumber;
+ }
+
+ /**
+ * Returns a managed instance from given fax number
+ * <p>
+ * @param faxNumber Fax instance
+ * @param fetchedNumber Found fax number in database
+ * <p>
+ * @return Managed instance
+ */
+ protected DialableFaxNumber createManaged (final DialableFaxNumber faxNumber, final DialableFaxNumber fetchedNumber) {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getDetached: faxNumber={1},fetchedNumber={2} - CALLED!", this.getClass().getSimpleName(), faxNumber, fetchedNumber)); //NOI18N
+
+ // Should be valid
+ if (null == faxNumber) {
+ // Throw NPE
+ throw new NullPointerException("faxNumber is null"); //NOI18N
+ } else if (null == fetchedNumber) {
+ // Throw NPE again
+ throw new NullPointerException("fetchedNumber is null"); //NOI18N
+ } else if (fetchedNumber.getPhoneId() == null) {
+ // ..and again
+ throw new NullPointerException("fetchedNumber.phoneId is null"); //NOI18N
+ }
+
+ // Debug message
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: fetchedNumber.phoneId={0}", fetchedNumber.getPhoneId())); //NOI18N
+
+ // Init query instance
+ final DialableFaxNumber foundNumber = this.getEntityManager().find(fetchedNumber.getClass(), fetchedNumber.getPhoneId());
+
+ // Debug message
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: foundNumber={0}", foundNumber)); //NOI18N
+
+ // Default is null
+ DialableFaxNumber detachedNumber = null;
+
+ // Is there a difference?
+ if (!PhoneUtils.isSameFaxNumber(faxNumber, fetchedNumber)) {
+ // Merge this entry
+ detachedNumber = this.getEntityManager().merge(foundNumber);
+
+ // @TODO Copy all
+ }
+
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getDetached: detachedNumber={1} - EXIT!", this.getClass().getSimpleName(), detachedNumber)); //NOI18N
+
+ // Return it
+ return detachedNumber;
+ }
+
+ /**
+ * Get back a managed instance from given contact
+ * <p>
+ * @param contact Unmanaged/detached contact instance
+ * <p>
+ * @return Managed contact instance
+ */
+ protected Contact createManaged (final Contact contact) {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: contact={1} - CALLED!", this.getClass().getSimpleName(), contact)); //NOI18N
+
+ // user should not be null
+ if (null == contact) {
+ // Abort here
+ throw new NullPointerException("contact is null"); //NOI18N
+ } else if (contact.getContactId() == null) {
+ // Id is set
+ throw new NullPointerException("contact.contactId is null"); //NOI18N
+ } else if (contact.getContactId() < 1) {
+ // Id is set
+ throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is invalid", contact.getContactId())); //NOI18N
+ }
+
+ // Try to find it (should be there)
+ final Contact managedContact = this.getEntityManager().find(UserContact.class, contact.getContactId());
+
+ // Should be there
+ assert (managedContact instanceof Contact) : "managedContact is null"; //NOI18N
+
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: managedContact={1} - EXIT!", this.getClass().getSimpleName(), managedContact)); //NOI18N
+
+ // Return it
+ return managedContact;
+ }
+
+ /**
+ * Get back a managed instance from given country
+ * <p>
+ * @param country Unmanaged/detached country instance
+ * <p>
+ * @return Managed country instance
+ */
+ protected Country createManaged (final Country country) {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: country={1} - CALLED!", this.getClass().getSimpleName(), country)); //NOI18N
+
+ // user should not be null
+ if (null == country) {
+ // Abort here
+ throw new NullPointerException("country is null"); //NOI18N
+ } else if (country.getCountryId() == null) {
+ // Id is set
+ throw new NullPointerException("country.countryId is null"); //NOI18N
+ } else if (country.getCountryId() < 1) {
+ // Id is set
+ throw new IllegalArgumentException(MessageFormat.format("country.countryId={0} is invalid", country.getCountryId())); //NOI18N
+ }
+
+ // Try to find it (should be there)
+ final Country managedCountry = this.getEntityManager().find(CountryData.class, country.getCountryId());
+
+ // Should be there
+ assert (managedCountry instanceof Country) : "managedCountry is null"; //NOI18N
+
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: managedCountry={1} - EXIT!", this.getClass().getSimpleName(), managedCountry)); //NOI18N
+
+ // Return it
+ return managedCountry;
+ }
+
+ /**
+ * Get back a managed instance from given basic data
+ * <p>
+ * @param basicData Unmanaged/detached basic data instance
+ * <p>
+ * @return Managed basic data instance
+ */
+ protected BusinessBasicData createManaged (final BusinessBasicData basicData) {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: basicData={1} - CALLED!", this.getClass().getSimpleName(), basicData)); //NOI18N
+
+ // user should not be null
+ if (null == basicData) {
+ // Abort here
+ throw new NullPointerException("basicData is null"); //NOI18N
+ } else if (basicData.getBasicDataId() == null) {
+ // Id is set
+ throw new NullPointerException("basicData.basicDataId is null"); //NOI18N
+ } else if (basicData.getBasicDataId() < 1) {
+ // Id is set
+ throw new IllegalArgumentException(MessageFormat.format("basicData.basicDataId={0} is invalid", basicData.getBasicDataId())); //NOI18N
+ }
+
+ // Try to find it (should be there)
+ final BusinessBasicData managedBasicData = this.getEntityManager().find(CompanyBasicData.class, basicData.getBasicDataId());
+
+ // Should be there
+ assert (managedBasicData instanceof BusinessBasicData) : "managedBasicData is null"; //NOI18N
+
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: managedBasicData={1} - EXIT!", this.getClass().getSimpleName(), managedBasicData)); //NOI18N
+
+ // Return it
+ return managedBasicData;
+ }
+
+ /**
+ * Get back a managed instance from given branch office
+ * <p>
+ * @param branchOffice Unmanaged/detached branch office instance
+ * <p>
+ * @return Managed basic data instance
+ */
+ protected BranchOffice createManaged (final BranchOffice branchOffice) {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: branchOffice={1} - CALLED!", this.getClass().getSimpleName(), branchOffice)); //NOI18N
+
+ // user should not be null
+ if (null == branchOffice) {
+ // Abort here
+ throw new NullPointerException("branchOffice is null"); //NOI18N
+ } else if (branchOffice.getBranchId() == null) {
+ // Id is set
+ throw new NullPointerException("branchOffice.branchOfficeId is null"); //NOI18N
+ } else if (branchOffice.getBranchId() < 1) {
+ // Id is set
+ throw new IllegalArgumentException(MessageFormat.format("branchOffice.branchOfficeId={0} is invalid", branchOffice.getBranchId())); //NOI18N
+ }
+
+ // Try to find it (should be there)
+ final BranchOffice managedBranchOffice = this.getEntityManager().find(CompanyBranchOffice.class, branchOffice.getBranchId());
+
+ // Should be there
+ assert (managedBranchOffice instanceof BusinessBasicData) : "managedBranchOffice is null"; //NOI18N
+
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: managedBranchOffice={1} - EXIT!", this.getClass().getSimpleName(), managedBranchOffice)); //NOI18N
+
+ // Return it
+ return managedBranchOffice;
+ }
+
+ /**
+ * Get back a managed instance from given employee
+ * <p>
+ * @param employee Unmanaged/detached employee instance
+ * <p>
+ * @return Managed employee instance
+ */
+ protected Employee createManaged (final Employee employee) {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: employee={1} - CALLED!", this.getClass().getSimpleName(), employee)); //NOI18N
+
+ // user should not be null
+ if (null == employee) {
+ // Abort here
+ throw new NullPointerException("employee is null"); //NOI18N
+ } else if (employee.getEmployeeId() == null) {
+ // Id is set
+ throw new NullPointerException("employee.employeeId is null"); //NOI18N
+ } else if (employee.getEmployeeId() < 1) {
+ // Id is set
+ throw new IllegalArgumentException(MessageFormat.format("employee.employeeId={0} is invalid", employee.getEmployeeId())); //NOI18N
+ }
+
+ // Try to find it (should be there)
+ final Employee managedEmployee = this.getEntityManager().find(CompanyEmployee.class, employee.getEmployeeId());
+
+ // Should be there
+ assert (managedEmployee instanceof Employee) : "managedEmployee is null"; //NOI18N
+
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: managedEmployee={1} - EXIT!", this.getClass().getSimpleName(), managedEmployee)); //NOI18N
+
+ // Return it
+ return managedEmployee;
+ }
+
+ /**
+ * Get back a managed instance from given headquarters
+ * <p>
+ * @param headquarters Unmanaged/detached headquarters instance
+ * <p>
+ * @return Managed basic data instance
+ */
+ protected HeadquartersData createManaged (final HeadquartersData headquarters) {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: branchOffice={1} - CALLED!", this.getClass().getSimpleName(), headquarters)); //NOI18N
+
+ // user should not be null
+ if (null == headquarters) {
+ // Abort here
+ throw new NullPointerException("branchOffice is null"); //NOI18N
+ } else if (headquarters.getHeadquartersId() == null) {
+ // Id is set
+ throw new NullPointerException("branchOffice.headquartersId is null"); //NOI18N
+ } else if (headquarters.getHeadquartersId() < 1) {
+ // Id is set
+ throw new IllegalArgumentException(MessageFormat.format("branchOffice.headquartersId={0} is invalid", headquarters.getHeadquartersId())); //NOI18N
+ }
+
+ // Try to find it (should be there)
+ final HeadquartersData managedHeadquarters = this.getEntityManager().find(CompanyHeadquartersData.class, headquarters.getHeadquartersId());
+
+ // Should be there
+ assert (managedHeadquarters instanceof BusinessBasicData) : "managedHeadquarters is null"; //NOI18N
+
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: managedHeadquarters={1} - EXIT!", this.getClass().getSimpleName(), managedHeadquarters)); //NOI18N
+
+ // Return it
+ return managedHeadquarters;
+ }
+
+ /**
+ * Get back a managed instance from given user
+ * <p>
+ * @param user Unmanaged/detached user instance
+ * <p>
+ * @return Managed user instance
+ */
+ protected User createManaged (final User user) {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N
+
+ // user should not be null
+ if (null == user) {
+ // Abort here
+ throw new NullPointerException("user is null"); //NOI18N
+ } else if (user.getUserId() == null) {
+ // Id is set
+ throw new NullPointerException("user.userId is null"); //NOI18N
+ } else if (user.getUserId() < 1) {
+ // Id is set
+ throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is invalid", user.getUserId())); //NOI18N
+ } else if (user.getUserContact() == null) {
+ // Throw NPE again
+ throw new NullPointerException("user.userContact is null"); //NOI18N
+ } else if (user.getUserContact().getContactId() == null) {
+ // Throw NPE again
+ throw new NullPointerException("user.userContact.contactId is null"); //NOI18N
+ } else if (user.getUserContact().getContactId() < 1) {
+ // Not valid id number
+ throw new IllegalArgumentException(MessageFormat.format("user.userContact.contactId={0} is not valid", user.getUserContact().getContactId())); //NOI18N#
+ }
+
+ // Try to find it (should be there)
+ final User managedUser = this.getEntityManager().find(LoginUser.class, user.getUserId());
+
+ // Should be there
+ assert (managedUser instanceof User) : "managedUser is null"; //NOI18N
+
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: managedUser={1} - EXIT!", this.getClass().getSimpleName(), managedUser)); //NOI18N
+
+ // Return it
+ return managedUser;
+ }
+
+ /**
+ * Sets created timestamp on all opening times.
+ * <p>
+ * @param openingTimes Opening times list
+ * <p>
+ * @throws NullPointerException If given list is null
+ * @throws IllegalArgumentException If given list is empty
+ * @throws IllegalStateException If openingId is not null
+ */
+ protected void setAllOpeningTimesCreated (final List<OpeningTime> openingTimes) {
+ // Validate parameter
+ if (null == openingTimes) {
+ // Throw NPE
+ throw new NullPointerException("openingTimes is null");
+ } else if (openingTimes.isEmpty()) {
+ // Throw IAE
+ throw new IllegalArgumentException("openingTimes is empty");
+ }
+
+ // Walk through whole list
+ for (final OpeningTime openingTime : openingTimes) {
+ // Id should not be set
+ if (openingTime.getOpeningId() != null) {
+ // Abort here
+ throw new IllegalStateException("openingTime.openingId is not null");
+ }
+
+ // Set created timestamp
+ openingTime.setOpeningCreated(new Date());
+ }
+ }
+
+ /**
+ * Updates all contact's phone entry's created timestamps
+ * <p>
+ * @param contact Contact instance to update
+ */
+ protected void setAllPhoneEntriesCreated (final Contact contact) {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("setAllPhoneEntriesCreated: contact={0} - CALLED!", contact)); //NOI18N
+
+ // The contact instance must be valid
+ if (null == contact) {
+ // Throw NPE
+ throw new NullPointerException("contact is null"); //NOI18N
+ } else if (contact.getContactId() != null) {
+ // Throw IAE
+ throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is unexpected.", contact.getContactId()));
+ }
+
+ // Get all phone instances
+ final DialableLandLineNumber landLineNumber = contact.getContactLandLineNumber();
+ final DialableFaxNumber faxNumber = contact.getContactFaxNumber();
+ final DialableMobileNumber mobileNumber = contact.getContactMobileNumber();
+
+ // Debug message
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("setAllPhoneEntriesCreated: landLineNumber={0},faxNumber={1},mobileNumber={2}", landLineNumber, faxNumber, mobileNumber)); //NOI18N
+
+ // Is a phone number instance set?
+ if ((landLineNumber instanceof DialableLandLineNumber) && (landLineNumber.getPhoneId() == null)) {
+ // Debug message
+ this.getLoggerBeanLocal().logDebug("setAllPhoneEntriesCreated: Setting created timestamp for land-line number ..."); //NOI18N
+
+ // Set updated timestamp
+ landLineNumber.setPhoneEntryCreated(new Date());
+ }
+
+ // Is a fax number instance set?
+ if ((faxNumber instanceof DialableFaxNumber) && (faxNumber.getPhoneId() == null)) {
+ // Debug message
+ this.getLoggerBeanLocal().logDebug("setAllPhoneEntriesCreated: Setting created timestamp for fax number ..."); //NOI18N
+
+ // Set updated timestamp
+ faxNumber.setPhoneEntryCreated(new Date());
+ }
+
+ // Is a mobile number instance set?
+ if ((mobileNumber instanceof DialableMobileNumber) && (mobileNumber.getPhoneId() == null)) {
+ // Debug message
+ this.getLoggerBeanLocal().logDebug("setAllPhoneEntriesCreated: Setting created timestamp for mobile number ..."); //NOI18N
+
+ // Set updated timestamp
+ mobileNumber.setPhoneEntryCreated(new Date());
+ }
+
+ // Trace message
+ this.getLoggerBeanLocal().logTrace("setAllPhoneEntriesCreated: EXIT!"); //NOI18N
+ }
+
+ /**
+ * Updates all branch office's phone entry's created timestamps
+ * <p>
+ * @param branchOffice Branch office instance to update
+ */
+ protected void setAllPhoneEntriesCreated (final BranchOffice branchOffice) {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("setAllPhoneEntriesCreated: branchOffice={0} - CALLED!", branchOffice)); //NOI18N
+
+ // The contact instance must be valid
+ if (null == branchOffice) {
+ // Throw NPE again
+ throw new NullPointerException("branchOffice is null"); //NOI18N
+ } else if (branchOffice.getBranchId() != null) {
+ // Throw IAE
+ throw new IllegalArgumentException(MessageFormat.format("branchOffice.branchId={0} is unexpected.", branchOffice.getBranchId()));
+ }
+
+ // Get all phone instances
+ final DialableLandLineNumber landLineNumber = branchOffice.getBranchLandLineNumber();
+ final DialableFaxNumber faxNumber = branchOffice.getBranchFaxNumber();
+
+ // Debug message
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("setAllPhoneEntriesCreated: landLineNumber={0},faxNumber={1}", landLineNumber, faxNumber)); //NOI18N
+
+ // Is a phone number instance set?
+ if ((landLineNumber instanceof DialableLandLineNumber) && (landLineNumber.getPhoneId() == null)) {
+ // Debug message
+ this.getLoggerBeanLocal().logDebug("setAllPhoneEntriesCreated: Setting created timestamp for land-line number ..."); //NOI18N
+
+ // Set updated timestamp
+ landLineNumber.setPhoneEntryCreated(new Date());
+ }
+
+ // Is a fax number instance set?
+ if ((faxNumber instanceof DialableFaxNumber) && (faxNumber.getPhoneId() == null)) {
+ // Debug message
+ this.getLoggerBeanLocal().logDebug("setAllPhoneEntriesCreated: Setting created timestamp for fax number ..."); //NOI18N
+
+ // Set updated timestamp
+ faxNumber.setPhoneEntryCreated(new Date());
+ }
+
+ // Trace message
+ this.getLoggerBeanLocal().logTrace("setAllPhoneEntriesCreated: EXIT!"); //NOI18N
+ }
+
+ /**
+ * Updates all company's phone entry's created timestamps
+ * <p>
+ * @param basicData Company basic data instance to update
+ */
+ protected void setAllPhoneEntriesCreated (final BusinessBasicData basicData) {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("setAllPhoneEntriesCreated: basicData={0} - CALLED!", basicData)); //NOI18N
+
+ // The contact instance must be valid
+ if (null == basicData) {
+ // Throw NPE again
+ throw new NullPointerException("basicData is null"); //NOI18N
+ } else if (basicData.getBasicDataId() != null) {
+ // Throw IAE
+ throw new IllegalArgumentException(MessageFormat.format("basicData.basicDataId={0} is unexpected.", basicData.getBasicDataId()));
+ }
+
+ // Get all phone instances
+ final DialableLandLineNumber landLineNumber = basicData.getCompanyLandLineNumber();
+ final DialableFaxNumber faxNumber = basicData.getCompanyFaxNumber();
+
+ // Debug message
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("setAllPhoneEntriesCreated: landLineNumber={0},faxNumber={1}", landLineNumber, faxNumber)); //NOI18N
+
+ // Is a phone number instance set?
+ if ((landLineNumber instanceof DialableLandLineNumber) && (landLineNumber.getPhoneId() == null)) {
+ // Debug message
+ this.getLoggerBeanLocal().logDebug("setAllPhoneEntriesCreated: Setting created timestamp for land-line number ..."); //NOI18N
+
+ // Set updated timestamp
+ landLineNumber.setPhoneEntryCreated(new Date());
+
+ // Set it back in basic data
+ basicData.setCompanyLandLineNumber(landLineNumber);
+ }
+
+ // Is a fax number instance set?
+ if ((faxNumber instanceof DialableFaxNumber) && (faxNumber.getPhoneId() == null)) {
+ // Debug message
+ this.getLoggerBeanLocal().logDebug("setAllPhoneEntriesCreated: Setting created timestamp for fax number ..."); //NOI18N
+
+ // Set updated timestamp
+ faxNumber.setPhoneEntryCreated(new Date());
+
+ // Set it back in basic data
+ basicData.setCompanyFaxNumber(faxNumber);
+ }
+
+ // Trace message
+ this.getLoggerBeanLocal().logTrace("setAllPhoneEntriesCreated: EXIT!"); //NOI18N
+ }
+
+ /**
+ * Returns a detached instance from given mobile instance
+ * <p>
+ * @param mobileNumber Mobile instance
+ * @param fetchedNumber Found mobile number in database
+ * <p>
+ * @return Detached instance
+ */
+ protected DialableMobileNumber getDetached (final DialableMobileNumber mobileNumber, final DialableMobileNumber fetchedNumber) {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("getDetached: mobileNumber={0},fetchedNumber={1} - CALLED!", mobileNumber, fetchedNumber)); //NOI18N
+
+ // Should be valid
+ if (null == mobileNumber) {
+ // Throw NPE
+ throw new NullPointerException("mobileNumber is null"); //NOI18N
+ } else if (fetchedNumber.getPhoneId() == null) {
+ // ..and again
+ throw new NullPointerException("fetchedNumber.phoneId is null"); //NOI18N
+ }
+
+ // Debug message
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: fetchedNumber.phoneId={0}", fetchedNumber.getPhoneId())); //NOI18N
+
+ // Init query instance
+ final DialableMobileNumber foundNumber = this.getEntityManager().find(fetchedNumber.getClass(), fetchedNumber.getPhoneId());
+
+ // Debug message
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: foundNumber={0}", foundNumber)); //NOI18N
+
+ // Default is null
+ DialableMobileNumber detachedNumber = null;
+
+ // Is there a difference?
+ if (!PhoneUtils.isSameMobileNumber(mobileNumber, fetchedNumber)) {
+ // Merge this entry
+ detachedNumber = this.getEntityManager().merge(foundNumber);
+
+ // @TODO Copy all
+ }
+
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("getDetached: detachedNumber={0} - EXIT!", detachedNumber)); //NOI18N
+
+ // Return it
+ return detachedNumber;
+ }
+
+ /**
+ * Returns a detached instance from given land-line instance
+ * <p>
+ * @param landLineNumber Land-line instance
+ * @param fetchedNumber Found land-line number in database
+ * <p>
+ * @return Detached instance
+ */
+ protected DialableLandLineNumber getDetached (final DialableLandLineNumber landLineNumber, final DialableLandLineNumber fetchedNumber) {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("getDetached: landLineNumber={0},fetchedNumber={1} - CALLED!", landLineNumber, fetchedNumber)); //NOI18N
+
+ // Should be valid
+ if (null == landLineNumber) {
+ // Throw NPE
+ throw new NullPointerException("landLineNumber is null"); //NOI18N
+ } else if (fetchedNumber.getPhoneId() == null) {
+ // ..and again
+ throw new NullPointerException("landLineNumber.phoneId is null"); //NOI18N
+ }
+
+ // Debug message
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: fetchedNumber.phoneId={0}", fetchedNumber.getPhoneId())); //NOI18N
+
+ // Init query instance
+ final DialableLandLineNumber foundNumber = this.getEntityManager().find(fetchedNumber.getClass(), fetchedNumber.getPhoneId());
+
+ // Debug message
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: foundNumber={0}", foundNumber)); //NOI18N
+
+ // Default is null
+ DialableLandLineNumber detachedNumber = null;
+
+ // Is there a difference?
+ if (!PhoneUtils.isSameLandLineNumber(landLineNumber, fetchedNumber)) {
+ // Merge this entry
+ detachedNumber = this.getEntityManager().merge(foundNumber);
+
+ // @TODO Copy all
+ }
+
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("getDetached: detachedNumber={0} - EXIT!", detachedNumber)); //NOI18N
+
+ // Return it
+ return detachedNumber;
+ }
+
+ /**
+ * Returns a detached instance from given fax instance
+ * <p>
+ * @param faxNumber Fax instance
+ * @param fetchedNumber Found fax number in database
+ * <p>
+ * @return Detached instance
+ */
+ protected DialableFaxNumber getDetached (final DialableFaxNumber faxNumber, final DialableFaxNumber fetchedNumber) {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("getDetached: faxNumber={0},fetchedNumber={1} - CALLED!", faxNumber, fetchedNumber)); //NOI18N
+
+ // Should be valid
+ if (null == faxNumber) {
+ // Throw NPE
+ throw new NullPointerException("faxNumber is null"); //NOI18N
+ } else if (fetchedNumber.getPhoneId() == null) {
+ // ..and again
+ throw new NullPointerException("fetchedNumber.phoneId is null"); //NOI18N
+ }
+
+ // Debug message
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: fetchedNumber.phoneId={0}", fetchedNumber.getPhoneId())); //NOI18N
+
+ // Init query instance
+ final DialableFaxNumber foundNumber = this.getEntityManager().find(fetchedNumber.getClass(), fetchedNumber.getPhoneId());
+
+ // Debug message
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: foundNumber={0}", foundNumber)); //NOI18N
+
+ // Default is null
+ DialableFaxNumber detachedNumber = null;
+
+ // Is there a difference?
+ if (!PhoneUtils.isSameFaxNumber(faxNumber, fetchedNumber)) {
+ // Merge this entry
+ detachedNumber = this.getEntityManager().merge(foundNumber);
+
+ // @TODO Copy all
+ }
+
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("getDetached: detachedNumber={0} - EXIT!", detachedNumber)); //NOI18N
+
+ // Return it
+ return detachedNumber;
+ }
+
+ /**
+ * Merges given contact's data
+ * <p>
+ * @param detachedContact Contact instance to merge
+ * <p>
+ * @return Detached contact instance
+ */
+ protected Contact mergeContactData (final Contact detachedContact) {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.mergeContactData: contact={1} - CALLED!", this.getClass().getSimpleName(), detachedContact)); //NOI18N
+
+ // The contact instance must be valid
+ if (null == detachedContact) {
+ // Throw NPE again
+ throw new NullPointerException("detachedContact is null"); //NOI18N
+ } else if (detachedContact.getContactId() == null) {
+ // Throw NPE again
+ throw new NullPointerException("detachedContact.contactId is null"); //NOI18N //NOI18N
+ } else if (detachedContact.getContactId() < 1) {
+ // Not valid
+ throw new IllegalStateException(MessageFormat.format("{0}.detachedContact.contactId={1} is not valid.", this.getClass().getSimpleName(), detachedContact.getContactId())); //NOI18N
+ }
+
+ // Set updated timestamp
+ detachedContact.setContactUpdated(new Date());
+
+ // Get contact from it and find it
+ final Contact foundContact = this.getEntityManager().find(detachedContact.getClass(), detachedContact.getContactId());
+
+ // Should be found
+ assert (foundContact instanceof Contact) : MessageFormat.format("Contact with id {0} not found, but should be.", detachedContact.getContactId()); //NOI18N
+
+ // Debug message
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.updateUserPersonalData: foundContact.contactId={1}", this.getClass().getSimpleName(), foundContact.getContactId())); //NOI18N
+
+ // Is a fax number set?
+ if (detachedContact.getContactFaxNumber() instanceof DialableFaxNumber) {
+ // Make fax numbers managed
+ foundContact.setContactFaxNumber(this.createManaged(detachedContact.getContactFaxNumber(), detachedContact.getContactFaxNumber()));
+ }
+
+ // Is a land-line number set?
+ if (detachedContact.getContactLandLineNumber() instanceof DialableLandLineNumber) {
+ // Make land-line numbers managed
+ foundContact.setContactLandLineNumber(this.createManaged(detachedContact.getContactLandLineNumber(), detachedContact.getContactLandLineNumber()));
+ }
+
+ // Is a mobile number set?
+ if (detachedContact.getContactMobileNumber() instanceof DialableMobileNumber) {
+ // Make mobile numbers managed
+ foundContact.setContactMobileNumber(this.createManaged(detachedContact.getContactMobileNumber(), detachedContact.getContactMobileNumber()));
+ }
+
+ // Merge contact instance
+ final Contact managedContact = this.getEntityManager().merge(foundContact);
+
+ // Copy all
+ ContactUtils.copyAll(detachedContact, managedContact);
+
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.mergeContactData: managedContact={1} - EXIT!", this.getClass().getSimpleName(), managedContact)); //NOI18N
+
+ // Return detached contact
+ return managedContact;
+ }
+
+ /**
+ * Merges given (detached) contact's mobile, land-line and fax numbers
+ * <p>
+ * @param detachedContact Detached contact instance
+ */
+ protected void mergeContactsMobileLandLineFaxNumbers (final Contact detachedContact) {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.mergeContactsMobileLandLineFaxNumbers: detachedContact={1} - CALLED!", this.getClass().getSimpleName(), detachedContact)); //NOI18N
+
+ // The contact instance must be valid
+ if (null == detachedContact) {
+ // Throw NPE again
+ throw new NullPointerException("detachedContact is null"); //NOI18N
+ } else if (detachedContact.getContactId() == null) {
+ // Throw NPE again
+ throw new NullPointerException("detachedContact.contactId is null"); //NOI18N //NOI18N
+ } else if (detachedContact.getContactId() < 1) {
+ // Not valid
+ throw new IllegalStateException(MessageFormat.format("{0}.detachedContact.contactId={1} is not valid.", this.getClass().getSimpleName(), detachedContact.getContactId())); //NOI18N
+ }
+
+ // Get all instances
+ final DialableMobileNumber mobile = detachedContact.getContactMobileNumber();
+ final DialableLandLineNumber landLine = detachedContact.getContactLandLineNumber();
+ final DialableFaxNumber fax = detachedContact.getContactFaxNumber();
+
+ // Is there a mobile instance set?
+ if (mobile instanceof DialableMobileNumber) {
+ // Debug message
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: mobile.phoneId={0} is being updated ...", mobile.getPhoneId())); //NOI18N
+
+ // Then find it, too
+ final DialableMobileNumber foundMobile = this.getEntityManager().find(mobile.getClass(), mobile.getPhoneId());
+
+ // Should be there
+ assert (foundMobile instanceof DialableMobileNumber) : MessageFormat.format("Mobile number with id {0} not found but should be.", foundMobile.getPhoneId()); //NOI18N
+
+ // Then merge it, too
+ final DialableMobileNumber managedMobile = this.getEntityManager().merge(foundMobile);
+
+ // Should be there
+ assert (managedMobile instanceof DialableMobileNumber) : MessageFormat.format("Mobile number with id {0} not found but should be.", managedMobile.getPhoneId()); //NOI18N
+
+ // Copy all
+ MobileNumbers.copyAll(detachedContact.getContactMobileNumber(), managedMobile);
+
+ // Set it back
+ detachedContact.setContactMobileNumber(managedMobile);
+ }
+
+ // Is there a fax instance set?
+ if (fax instanceof DialableFaxNumber) {
+ // Debug message
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: fax.phoneId={0} is being updated ...", fax.getPhoneId())); //NOI18N
+
+ // Then find it, too
+ final DialableFaxNumber foundFax = this.getEntityManager().find(fax.getClass(), fax.getPhoneId());
+
+ // Should be there
+ assert (foundFax instanceof DialableFaxNumber) : MessageFormat.format("Fax number with id {0} not found but should be.", foundFax.getPhoneId()); //NOI18N
+
+ // Then merge it, too
+ final DialableFaxNumber managedFax = this.getEntityManager().merge(foundFax);
+
+ // Should be there
+ assert (managedFax instanceof DialableFaxNumber) : MessageFormat.format("Fax number with id {0} not found but should be.", managedFax.getPhoneId()); //NOI18N
+
+ // Copy all
+ FaxNumbers.copyAll(detachedContact.getContactFaxNumber(), managedFax);
+
+ // Set it back
+ detachedContact.setContactFaxNumber(managedFax);
+ }
+
+ // Is there a fax instance set?
+ if (landLine instanceof DialableLandLineNumber) {
+ // Debug message
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: landLine.phoneId={0} is being updated ...", landLine.getPhoneId())); //NOI18N
+
+ // Then find it, too
+ final DialableLandLineNumber foundLandLine = this.getEntityManager().find(landLine.getClass(), landLine.getPhoneId());
+
+ // Should be there
+ assert (foundLandLine instanceof DialableLandLineNumber) : MessageFormat.format("Land line number with id {0} not found but should be.", foundLandLine.getPhoneId()); //NOI18N
+
+ // Then merge it, too
+ final DialableLandLineNumber managedLandLine = this.getEntityManager().merge(foundLandLine);
+
+ // Should be there
+ assert (managedLandLine instanceof DialableLandLineNumber) : MessageFormat.format("Land line number with id {0} not found but should be.", managedLandLine.getPhoneId()); //NOI18N
+
+ // Copy all
+ LandLineNumbers.copyAll(detachedContact.getContactLandLineNumber(), managedLandLine);
+
+ // Set it back
+ detachedContact.setContactLandLineNumber(managedLandLine);
+ }
+
+ // Trace message
+ this.getLoggerBeanLocal().logTrace("mergeContactsMobileLandLineFaxNumbers: EXIT!"); //NOI18N
+ }
+
+ /**
+ * Sends an email with given subject line, template name to given recipient
+ * and user data
+ * <p>
+ * @param subjectLine Subject line
+ * @param templateName Template name
+ * @param user User instance
+ * @param baseUrl Base URL
+ * @param randomPassword A randomly-generated password or NULL if user had
+ * to enter it.
+ */
+ protected void sendEmail (final String subjectLine, final String templateName, final User user, final String baseUrl, final String randomPassword) {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("sendEmail: subjectLine={0},templateName={1},user={2},baseUrl={3} - CALLED!", subjectLine, templateName, user, baseUrl)); //NOI18N
+
+ // All should be set
+ if (null == subjectLine) {
+ // Throw NPE
+ throw new NullPointerException("subjectLine is null"); //NOI18N
+ } else if (subjectLine.isEmpty()) {
+ // No subject line
+ throw new IllegalArgumentException("subjectLine is empty"); //NOI18N
+ } else if (null == templateName) {
+ // Throw NPE
+ throw new NullPointerException("templateName is null"); //NOI18N
+ } else if (templateName.isEmpty()) {
+ // No template name
+ throw new IllegalArgumentException("templateName is empty"); //NOI18N
+ } else if (null == user) {
+ // Throw NPE
+ throw new NullPointerException("user is null"); //NOI18N
+ } else if (user.getUserId() == null) {
+ // Throw NPE again
+ throw new NullPointerException("user.userId is null"); //NOI18N
+ } else if (user.getUserId() < 1) {
+ // Not valid number
+ throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid.", user.getUserId())); //NOI18N
+ } else if (user.getUserName() == null) {
+ // Throw NPE again
+ throw new NullPointerException("user.userName is null"); //NOI18N
+ } else if (user.getUserName().isEmpty()) {
+ // Empty string
+ throw new IllegalArgumentException("user.userName is empty"); //NOI18N
+ } else if (user.getUserAccountStatus() == null) {
+ // Throw NPE
+ throw new NullPointerException("user.userAccountStatus is null"); //NOI18N
+ } else if (user.getUserContact() == null) {
+ // Throw it again
+ throw new NullPointerException("user.userContact is null"); //NOI18N
+ } else if (user.getUserContact().getContactId() == null) {
+ // .. and again
+ throw new NullPointerException("user.userContact.contactId is null"); //NOI18N
+ } else if (user.getUserContact().getContactId() < 1) {
+ // Invalid id
+ throw new IllegalArgumentException(MessageFormat.format("user.userContact.contactId={0} is invalid", user.getUserContact().getContactId())); //NOI18N
+ } else if (user.getUserContact().getContactPersonalTitle() == null) {
+ // Throw NPE again
+ throw new NullPointerException("user.userContact.contactPersonalTitle is null"); //NOI18N
+ } else if (user.getUserLocale() == null) {
+ // Throw NPE again
+ throw new NullPointerException("user.userLocale is null"); //NOI18N
+ } else if (this.getSession() == null) {
+ // Throw NPE
+ throw new NullPointerException("this.session is not set. Have you forgotten to call super(String, String) and called only super() ?"); //NOI18N
+ }
+
+ // Set all values
+ final Properties variables = UserUtils.getAllUserFields(user);
+
+ // Set base URL and random password
+ variables.put("baseUrl", baseUrl); //NOI18N
+ variables.put("randomPassword", ""); //NOI18N
+
+ // Is the random password set?
+ if ((randomPassword instanceof String) && (!randomPassword.isEmpty())) {
+ variables.put("randomPassword", randomPassword); //NOI18N
+ }
+
+ // Init addresss
+ final Address recipientAddress;
+
+ try {
+ // Create email address and set
+ recipientAddress = new InternetAddress(user.getUserContact().getContactEmailAddress());
+ } catch (final AddressException ex) {
+ // Throw again
+ throw new EJBException(ex);
+ }
+
+ // Prepare mail wrapper
+ // @TODO Language from message bundle
+ final WrapableEmailDelivery emailWrapper = new EmailDeliveryWrapper(recipientAddress, subjectLine, templateName, variables, user.getUserLocale());
+
+ try {
+ // Send out email change
+ final ObjectMessage message = this.getSession().createObjectMessage();
+ message.setObject(emailWrapper);
+
+ // Send message
+ this.sendMessage(message);
+ } catch (final JMSException ex) {
+ // Throw again
+ throw new EJBException(ex);
+ }
+
+ // Trace message
+ this.getLoggerBeanLocal().logTrace("sendEmail: EXIT!"); //NOI18N
+ }
+
+ /**
+ * Updates all contact's phone instances from other contact, both contacts
+ * should be the same.
+ * <p>
+ * @param contact Contact to set instances
+ * @param other Other contact to get instances from
+ */
+ protected void setAllContactPhoneEntries (final Contact contact, final Contact other) {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.setAllContactPhoneEntries: contact={1},other={2} - CALLED!", this.getClass().getSimpleName(), contact, other)); //NOI18N
+
+ // Both must be the same and not null
+ if (null == contact) {
+ // Throw NPE
+ throw new NullPointerException("contact is null"); //NOI18N
+ } else if (null == other) {
+ // Throw NPE
+ throw new NullPointerException("other is null"); //NOI18N
+ } else if (!Objects.equals(contact, other)) {
+ // Not same instances
+ throw new IllegalArgumentException(MessageFormat.format("contact={0} and other={1} are not equal!", contact, other)); //NOI18N
+ }
+
+ // Debug message
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.setAllContactPhoneEntries: other.contactMobileNumber={0}", other.getContactMobileNumber())); //NOI18N
+
+ // Is other mobile not set?
+ if ((other.getContactMobileNumber() == null) || (PhoneUtils.isSameMobileNumber(contact.getContactMobileNumber(), other.getContactMobileNumber()))) {
+ // Debug message
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.setAllContactPhoneEntries: Copying mobile entry ...", this.getClass().getSimpleName())); //NOI18N
+
+ // Is the fax number set?
+ if (other.getContactMobileNumber() instanceof DialableMobileNumber) {
+ // Copy mobile number
+ contact.setContactMobileNumber(this.createManaged(other.getContactMobileNumber(), contact.getContactMobileNumber()));
+ } else {
+ // Null it
+ contact.setContactMobileNumber(null);
+ }
+ }
+
+ // Debug message
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.setAllContactPhoneEntries: other.contactLandLineNumber={0}", other.getContactLandLineNumber())); //NOI18N
+
+ // Is other mobile not set?
+ if ((other.getContactLandLineNumber() == null) || (PhoneUtils.isSameLandLineNumber(contact.getContactLandLineNumber(), other.getContactLandLineNumber()))) {
+ // Debug message
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.setAllContactPhoneEntries: Copying land-line entry ...", this.getClass().getSimpleName())); //NOI18N
+
+ // Is the land-line number set?
+ if (other.getContactLandLineNumber() instanceof DialableLandLineNumber) {
+ // Copy land-line number
+ contact.setContactLandLineNumber(this.createManaged(other.getContactLandLineNumber(), contact.getContactLandLineNumber()));
+ } else {
+ // Null it
+ contact.setContactLandLineNumber(null);
+ }
+ }
+
+ // Debug message
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.setAllContactPhoneEntries: other.contactFaxNumber={1}", this.getClass().getSimpleName(), other.getContactFaxNumber())); //NOI18N
+
+ // Is other mobile not set?
+ if ((other.getContactFaxNumber() == null) || (PhoneUtils.isSameFaxNumber(contact.getContactFaxNumber(), other.getContactFaxNumber()))) {
+ // Debug message
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.setAllContactPhoneEntries: Copying fax entry ...", this.getClass().getSimpleName())); //NOI18N
+
+ // Is the fax number set?
+ if (other.getContactFaxNumber() instanceof DialableFaxNumber) {
+ // Copy fax number
+ contact.setContactFaxNumber(this.createManaged(other.getContactFaxNumber(), contact.getContactFaxNumber()));
+ } else {
+ // Null it
+ contact.setContactFaxNumber(null);
+ }
+ }
+
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.setAllContactPhoneEntries: EXIT!", this.getClass().getSimpleName())); //NOI18N
+ }
+
+ /**
+ * Updates all contact's phone entry's updated timestamps
+ * <p>
+ * @param contact Contact instance to update
+ * @param isMobileUnlinked Whether a mobile entry has been unlinked in
+ * contact instance
+ * @param isLandlineUnlinked Whether a land-line entry has been unlinked in
+ * contact instance
+ * @param isFaxUnlinked Whether a fax entry has been unlinked in
+ * contact instance
+ */
+ protected void setAllContactPhoneEntriesUpdated (final Contact contact, final boolean isMobileUnlinked, final boolean isLandlineUnlinked, final boolean isFaxUnlinked) {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.setAllContactPhoneEntriesUpdated: 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 //NOI18N
+ } else if (contact.getContactId() < 1) {
+ // Not valid
+ throw new IllegalStateException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
+ }
+
+ // Get all phone instances
+ final DialableLandLineNumber landLineNumber = contact.getContactLandLineNumber();
+ final DialableFaxNumber faxNumber = contact.getContactFaxNumber();
+ final DialableMobileNumber mobileNumber = contact.getContactMobileNumber();
+
+ // Flags and instances must be constistent
+ if (isMobileUnlinked && mobileNumber instanceof DialableMobileNumber) {
+ // Bad state
+ throw new IllegalStateException("isCellPhoneUnlinked is TRUE, but mobileNumber is set."); //NOI18N
+ } else if (isLandlineUnlinked && landLineNumber instanceof DialableLandLineNumber) {
+ // Bad state
+ throw new IllegalStateException("isLandlineUnlinked is TRUE, but landLineNumber is set."); //NOI18N
+ } else if (isFaxUnlinked && faxNumber instanceof DialableFaxNumber) {
+ // Bad state
+ throw new IllegalStateException("isFaxUnlinked is TRUE, but faxNumber is set."); //NOI18N
+ }
+
+ // Is a phone number instance set?
+ if ((landLineNumber instanceof DialableLandLineNumber) && (landLineNumber.getPhoneId() instanceof Long) && (landLineNumber.getPhoneId() > 0)) {
+ // Debug message
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.setAllContactPhoneEntriesUpdated: Setting updated timestamp for land-line number ...", this.getClass().getSimpleName())); //NOI18N
+
+ // Set updated timestamp
+ landLineNumber.setPhoneEntryUpdated(new Date());
+ }
+
+ // Is a fax number instance set?
+ if ((faxNumber instanceof DialableFaxNumber) && (faxNumber.getPhoneId() instanceof Long) && (faxNumber.getPhoneId() > 0)) {
+ // Debug message
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.setAllContactPhoneEntriesUpdated: Setting updated timestamp for fax number ...", this.getClass().getSimpleName())); //NOI18N
+
+ // Set updated timestamp
+ faxNumber.setPhoneEntryUpdated(new Date());
+ }
+
+ // Is a mobile number instance set?
+ if ((mobileNumber instanceof DialableMobileNumber) && (mobileNumber.getPhoneId() instanceof Long) && (mobileNumber.getPhoneId() > 0)) {
+ // Debug message
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.setAllContactPhoneEntriesUpdated: Setting updated timestamp for mobile number ...", this.getClass().getSimpleName())); //NOI18N
+
+ // Set updated timestamp
+ mobileNumber.setPhoneEntryUpdated(new Date());
+ }
+
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.setAllContactPhoneEntriesUpdated: EXIT!", this.getClass().getSimpleName())); //NOI18N
+ }
+
+}
import org.mxchange.jshopcore.model.customer.ShopCustomerUtils;
import org.mxchange.jshopcore.model.order.Orderable;
import org.mxchange.jshopcore.model.order.ShopOrder;
-import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
+import org.mxchange.pizzaaplication.database.BasePizzaEnterpriseBean;
/**
* A basket for orderable items
* @author Roland Häder<roland@mxchange.org>
*/
@Stateless (name = "basket", description = "A bean handling persisting baskets of logged-in customers")
-public class PizzaBasketSessionBean extends BasePizzaDatabaseBean implements BasketSessionBeanRemote {
+public class PizzaBasketSessionBean extends BasePizzaEnterpriseBean implements BasketSessionBeanRemote {
/**
* Serial number
import org.mxchange.jproduct.model.category.Category;
import org.mxchange.jproduct.model.category.ProductCategory;
import org.mxchange.jshopcore.model.category.AdminCategorySessionBeanRemote;
-import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
+import org.mxchange.pizzaaplication.database.BasePizzaEnterpriseBean;
/**
* An EJB for administrative access on categories
* @author Roland Häder<roland@mxchange.org>
*/
@Stateless (name = "adminCategory", description = "An administrative bean handling product categories")
-public class PizzaAdminCategorySessionBean extends BasePizzaDatabaseBean implements AdminCategorySessionBeanRemote {
+public class PizzaAdminCategorySessionBean extends BasePizzaEnterpriseBean implements AdminCategorySessionBeanRemote {
/**
* Serial number
import org.mxchange.jproduct.model.category.Category;
import org.mxchange.jproduct.model.category.ProductCategory;
import org.mxchange.jshopcore.model.category.CategorySessionBeanRemote;
-import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
+import org.mxchange.pizzaaplication.database.BasePizzaEnterpriseBean;
/**
* Main shop class
* @author Roland Häder<roland@mxchange.org>
*/
@Stateless (name = "category", description = "A bean handling categories for all others (non-admin)")
-public class PizzaCategorySessionBean extends BasePizzaDatabaseBean implements CategorySessionBeanRemote {
+public class PizzaCategorySessionBean extends BasePizzaEnterpriseBean implements CategorySessionBeanRemote {
/**
* Serial number
import org.mxchange.jcustomercore.exceptions.CustomerAlreadyRegisteredException;
import org.mxchange.jcustomercore.model.customer.Customer;
import org.mxchange.jcustomercore.utils.CustomerUtils;
-import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
+import org.mxchange.pizzaaplication.database.BasePizzaEnterpriseBean;
/**
* A stateless administrative customer session-scoped bean (EJB)
* @author Roland Häder<roland@mxchange.org>
*/
@Stateless (name = "admincustomer", description = "Administrative bean handling customer data")
-public class PizzaAdminCustomerSessionBean extends BasePizzaDatabaseBean implements PizzaAdminCustomerSessionBeanRemote {
+public class PizzaAdminCustomerSessionBean extends BasePizzaEnterpriseBean implements PizzaAdminCustomerSessionBeanRemote {
/**
* Serial number
import org.mxchange.jcustomercore.exceptions.CustomerAlreadyRegisteredException;
import org.mxchange.jcustomercore.exceptions.CustomerNotFoundException;
import org.mxchange.jcustomercore.model.customer.Customer;
-import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
+import org.mxchange.pizzaaplication.database.BasePizzaEnterpriseBean;
/**
* A stateless customer session-scoped bean (EJB)
* @author Roland Häder<roland@mxchange.org>
*/
@Stateless (name = "customer", description = "A bean handling customer data")
-public class PizzaCustomerSessionBean extends BasePizzaDatabaseBean implements PizzaCustomerSessionBeanRemote {
+public class PizzaCustomerSessionBean extends BasePizzaEnterpriseBean implements PizzaCustomerSessionBeanRemote {
/**
* Serial number
import org.mxchange.jproduct.model.product.GenericProduct;
import org.mxchange.jproduct.model.product.Product;
import org.mxchange.jshopcore.model.product.AdminProductSessionBeanRemote;
-import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
+import org.mxchange.pizzaaplication.database.BasePizzaEnterpriseBean;
/**
* A session-scoped bean for non-administrative roles for products
* @author Roland Häder<roland@mxchange.org>
*/
@Stateless (name = "adminProduct", description = "An administrative bean handling products")
-public class PizzaAdminProductSessionBean extends BasePizzaDatabaseBean implements AdminProductSessionBeanRemote {
+public class PizzaAdminProductSessionBean extends BasePizzaEnterpriseBean implements AdminProductSessionBeanRemote {
/**
* Serial number
import org.mxchange.jproduct.model.product.Product;
import org.mxchange.jshopcore.model.product.AdminProductSessionBeanRemote;
import org.mxchange.jshopcore.model.product.ProductSessionBeanRemote;
-import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
+import org.mxchange.pizzaaplication.database.BasePizzaEnterpriseBean;
/**
* A session-scoped bean for non-administrative roles for products
* @author Roland Häder<roland@mxchange.org>
*/
@Stateless (name = "product", description = "A bean handling products for all others (non-admin)")
-public class PizzaProductSessionBean extends BasePizzaDatabaseBean implements ProductSessionBeanRemote {
+public class PizzaProductSessionBean extends BasePizzaEnterpriseBean implements ProductSessionBeanRemote {
/**
* Serial number