From: Roland Häder Date: Sun, 8 Oct 2017 00:07:03 +0000 (+0200) Subject: Please cherry-pick: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=3337f8108959e9bf61b2bd5cba134d5783f6c86e;p=jfinancials-war.git Please cherry-pick: - renamed companyEmployee to employee as there was no need for - also renamed EJB name and backing beans - half-added event for being fired (and fully observed by general bean) when an employee has been added - if an employee's displayed name is being rendered, also try to render an assigned department (if any) Signed-off-by: Roland Häder --- diff --git a/src/java/org/mxchange/jfinancials/beans/business/basicdata/FinancialsBusinessDataWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/business/basicdata/FinancialsBusinessDataWebRequestBean.java index 7b49d0af..c5d12c37 100644 --- a/src/java/org/mxchange/jfinancials/beans/business/basicdata/FinancialsBusinessDataWebRequestBean.java +++ b/src/java/org/mxchange/jfinancials/beans/business/basicdata/FinancialsBusinessDataWebRequestBean.java @@ -407,8 +407,7 @@ public class FinancialsBusinessDataWebRequestBean extends BaseFinancialsBean imp public int compare (final BusinessBasicData o1, final BusinessBasicData o2) { return o1.getBasicDataId() > o2.getBasicDataId() ? 1 : o1.getBasicDataId() < o2.getBasicDataId() ? -1 : 0; } - } - ); + }); } } diff --git a/src/java/org/mxchange/jfinancials/beans/business/branchoffice/FinancialsBranchOfficeWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/business/branchoffice/FinancialsBranchOfficeWebRequestBean.java index 369717e7..fe35a43d 100644 --- a/src/java/org/mxchange/jfinancials/beans/business/branchoffice/FinancialsBranchOfficeWebRequestBean.java +++ b/src/java/org/mxchange/jfinancials/beans/business/branchoffice/FinancialsBranchOfficeWebRequestBean.java @@ -178,8 +178,7 @@ public class FinancialsBranchOfficeWebRequestBean extends BaseFinancialsBean imp public int compare (final BranchOffice o1, final BranchOffice o2) { return o1.getBranchId() > o2.getBranchId() ? 1 : o1.getBranchId() < o2.getBranchId() ? -1 : 0; } - } - ); + }); } } diff --git a/src/java/org/mxchange/jfinancials/beans/business/department/FinancialsDepartmentWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/business/department/FinancialsDepartmentWebRequestBean.java index 61ca5a73..294670fc 100644 --- a/src/java/org/mxchange/jfinancials/beans/business/department/FinancialsDepartmentWebRequestBean.java +++ b/src/java/org/mxchange/jfinancials/beans/business/department/FinancialsDepartmentWebRequestBean.java @@ -178,8 +178,7 @@ public class FinancialsDepartmentWebRequestBean extends BaseFinancialsBean imple public int compare (final Department o1, final Department o2) { return o1.getDepartmentId() > o2.getDepartmentId() ? 1 : o1.getDepartmentId() < o2.getDepartmentId() ? -1 : 0; } - } - ); + }); } } diff --git a/src/java/org/mxchange/jfinancials/beans/business/employee/FinancialsAdminCompanyEmployeeWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/business/employee/FinancialsAdminCompanyEmployeeWebRequestBean.java deleted file mode 100644 index e936038b..00000000 --- a/src/java/org/mxchange/jfinancials/beans/business/employee/FinancialsAdminCompanyEmployeeWebRequestBean.java +++ /dev/null @@ -1,313 +0,0 @@ -/* - * Copyright (C) 2017 RRoland 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 . - */ -package org.mxchange.jfinancials.beans.business.employee; - -import javax.ejb.EJB; -import javax.enterprise.context.RequestScoped; -import javax.inject.Named; -import org.mxchange.jcontacts.model.contact.Contact; -import org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData; -import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice; -import org.mxchange.jcontactsbusiness.model.department.Department; -import org.mxchange.jcontactsbusiness.model.employee.AdminCompanyEmployeeSessionBeanRemote; -import org.mxchange.jcontactsbusiness.model.headquarters.HeadquartersData; -import org.mxchange.jfinancials.beans.BaseFinancialsBean; -import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider; -import org.mxchange.jusercore.model.user.User; - -/** - * A request-scoped bean for administrative purposes for company employees. - *

- * @author Roland Häder - */ -@Named ("adminCompanyEmployeeController") -@RequestScoped -public class FinancialsAdminCompanyEmployeeWebRequestBean extends BaseFinancialsBean implements FinancialsAdminCompanyEmployeeWebRequestController { - - /** - * Serial number - */ - private static final long serialVersionUID = 12_886_968_547_360L; - - /** - * EJB for administrative company employee purposes - */ - @EJB (lookup = "java:global/jfinancials-ejb/adminCompanyEmployee!org.mxchange.jcontactsbusiness.model.employee.AdminCompanyEmployeeSessionBeanRemote") - private AdminCompanyEmployeeSessionBeanRemote adminCompanyEmployeeBean; - - /** - * Assigned branch office - */ - private BranchOffice employeeBranchOffice; - - /** - * Assigned basic data instance - */ - private BusinessBasicData employeeCompany; - - /** - * Department where employee works (alternative to headquarters) - */ - private Department employeeDepartment; - - /** - * Employee's business email address - */ - private String employeeEmailAddress; - - /** - * Employee's Headquarters data, if he is working there - */ - private HeadquartersData employeeHeadquarters; - - /** - * Assigned personal data of the employee - */ - private Contact employeePersonalContact; - - /** - * Employee's phone extension (on top of a "main number") - */ - private Long employeePhoneExtension; - - /** - * Employee's staff number - */ - private Long employeeStaffNumber; - - /** - * Assigned user account - */ - private User employeeUserOwner; - - /** - * Mobile number for employee's business mobile - */ - private Long mobileNumber; - - /** - * Mobile provider instance for employee's business mobile - */ - private MobileProvider mobileProvider; - - /** - * Default constructor - */ - public FinancialsAdminCompanyEmployeeWebRequestBean () { - // Call super constructor - super(); - } - - /** - * Getter for employee's assigned branch office - *

- * @return Employee's assigned branch office - */ - public BranchOffice getEmployeeBranchOffice () { - return this.employeeBranchOffice; - } - - /** - * Setter for employee's assigned branch office - *

- * @param employeeBranchOffice Employee's assigned branch office - */ - public void setEmployeeBranchOffice (final BranchOffice employeeBranchOffice) { - this.employeeBranchOffice = employeeBranchOffice; - } - - /** - * Getter for employee's assigned basic company data - *

- * @return Employee's assigned basic company data - */ - public BusinessBasicData getEmployeeCompany () { - return this.employeeCompany; - } - - /** - * Setter for employee's assigned basic company data - *

- * @param employeeCompany Employee's assigned basic company data - */ - public void setEmployeeCompany (final BusinessBasicData employeeCompany) { - this.employeeCompany = employeeCompany; - } - - /** - * Getter for employee's assigned department - *

- * @return Employee's assigned department - */ - public Department getEmployeeDepartment () { - return this.employeeDepartment; - } - - /** - * Setter for employee's assigned department - *

- * @param employeeDepartment Employee's assigned department - */ - public void setEmployeeDepartment (final Department employeeDepartment) { - this.employeeDepartment = employeeDepartment; - } - - /** - * Getter for employee's business email address - *

- * @return Employee's business email address - */ - public String getEmployeeEmailAddress () { - return this.employeeEmailAddress; - } - - /** - * Setter for employee's business email address - *

- * @param employeeEmailAddress Employee's business email address - */ - public void setEmployeeEmailAddress (final String employeeEmailAddress) { - this.employeeEmailAddress = employeeEmailAddress; - } - - /** - * Getter for employee's assigned headquarters (if no branch office) - *

- * @return Employee's assigned headquarters - */ - public HeadquartersData getEmployeeHeadquarters () { - return this.employeeHeadquarters; - } - - /** - * Setter for employee's assigned headquarters (if no branch office) - *

- * @param employeeHeadquarters Employee's assigned headquarters - */ - public void setEmployeeHeadquarters (final HeadquartersData employeeHeadquarters) { - this.employeeHeadquarters = employeeHeadquarters; - } - - /** - * Getter for employee's personal contact data - *

- * @return Employee's personal contact data - */ - public Contact getEmployeePersonalContact () { - return this.employeePersonalContact; - } - - /** - * Setter for employee's personal contact data - *

- * @param employeePersonalContact Employee's personal contact data - */ - public void setEmployeePersonalContact (final Contact employeePersonalContact) { - this.employeePersonalContact = employeePersonalContact; - } - - /** - * Getter for employee's phone extension - *

- * @return Employee's phone extension - */ - public Long getEmployeePhoneExtension () { - return this.employeePhoneExtension; - } - - /** - * Getter for employee's phone extension - *

- * @param employeePhoneExtension Employee's phone extension - */ - public void setEmployeePhoneExtension (final Long employeePhoneExtension) { - this.employeePhoneExtension = employeePhoneExtension; - } - - /** - * Getter for employee's staff number - *

- * @return Employee's staff number - */ - public Long getEmployeeStaffNumber () { - return this.employeeStaffNumber; - } - - /** - * Setter for employee's staff number - *

- * @param employeeStaffNumber Employee's staff number - */ - public void setEmployeeStaffNumber (final Long employeeStaffNumber) { - this.employeeStaffNumber = employeeStaffNumber; - } - - /** - * Getter for employee's user "owner" - *

- * @return Employee's user "owner" - */ - public User getEmployeeUserOwner () { - return this.employeeUserOwner; - } - - /** - * Setter for employee's user "owner" - *

- * @param employeeUserOwner Employee's user "owner" - */ - public void setEmployeeUserOwner (final User employeeUserOwner) { - this.employeeUserOwner = employeeUserOwner; - } - - /** - * Getter for mobile number - *

- * @return Mobile number - */ - public Long getMobileNumber () { - return this.mobileNumber; - } - - /** - * Setter for mobile number - *

- * @param mobileNumber Mobile number - */ - public void setMobileNumber (final Long mobileNumber) { - this.mobileNumber = mobileNumber; - } - - /** - * Getter for mobile provider instance - *

- * @return Mobile provider instance - */ - public MobileProvider getMobileProvider () { - return this.mobileProvider; - } - - /** - * Setter for mobile provider instance - *

- * @param mobileProvider Mobile provider instance - */ - public void setMobileProvider (final MobileProvider mobileProvider) { - this.mobileProvider = mobileProvider; - } - -} diff --git a/src/java/org/mxchange/jfinancials/beans/business/employee/FinancialsAdminCompanyEmployeeWebRequestController.java b/src/java/org/mxchange/jfinancials/beans/business/employee/FinancialsAdminCompanyEmployeeWebRequestController.java deleted file mode 100644 index d8bb8d7b..00000000 --- a/src/java/org/mxchange/jfinancials/beans/business/employee/FinancialsAdminCompanyEmployeeWebRequestController.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package org.mxchange.jfinancials.beans.business.employee; - -import java.io.Serializable; - -/** - * An interface for request-scoped administrative company employee beans - *

- * @author Roland Häder - */ -public interface FinancialsAdminCompanyEmployeeWebRequestController extends Serializable { - -} diff --git a/src/java/org/mxchange/jfinancials/beans/business/employee/FinancialsAdminEmployeeWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/business/employee/FinancialsAdminEmployeeWebRequestBean.java new file mode 100644 index 00000000..12545fdb --- /dev/null +++ b/src/java/org/mxchange/jfinancials/beans/business/employee/FinancialsAdminEmployeeWebRequestBean.java @@ -0,0 +1,324 @@ +/* + * Copyright (C) 2017 RRoland 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 . + */ +package org.mxchange.jfinancials.beans.business.employee; + +import javax.ejb.EJB; +import javax.enterprise.context.RequestScoped; +import javax.enterprise.event.Event; +import javax.enterprise.inject.Any; +import javax.inject.Inject; +import javax.inject.Named; +import org.mxchange.jcontacts.model.contact.Contact; +import org.mxchange.jcontactsbusiness.events.employee.added.ObservableEmployeeAddedEvent; +import org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData; +import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice; +import org.mxchange.jcontactsbusiness.model.department.Department; +import org.mxchange.jcontactsbusiness.model.employee.AdminCompanyEmployeeSessionBeanRemote; +import org.mxchange.jcontactsbusiness.model.headquarters.HeadquartersData; +import org.mxchange.jfinancials.beans.BaseFinancialsBean; +import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider; +import org.mxchange.jusercore.model.user.User; + +/** + * A request-scoped bean for administrative purposes for company employees. + *

+ * @author Roland Häder + */ +@Named ("adminEmployeeController") +@RequestScoped +public class FinancialsAdminEmployeeWebRequestBean extends BaseFinancialsBean implements FinancialsAdminEmployeeWebRequestController { + + /** + * Serial number + */ + private static final long serialVersionUID = 12_886_968_547_360L; + + /** + * An event being fired when an employee has been added + */ + @Inject + @Any + private Event addedEmployeeEvent; + + /** + * EJB for administrative company employee purposes + */ + @EJB (lookup = "java:global/jfinancials-ejb/adminCompanyEmployee!org.mxchange.jcontactsbusiness.model.employee.AdminCompanyEmployeeSessionBeanRemote") + private AdminCompanyEmployeeSessionBeanRemote adminCompanyEmployeeBean; + + /** + * Assigned branch office + */ + private BranchOffice employeeBranchOffice; + + /** + * Assigned basic data instance + */ + private BusinessBasicData employeeCompany; + + /** + * Department where employee works (alternative to headquarters) + */ + private Department employeeDepartment; + + /** + * Employee's business email address + */ + private String employeeEmailAddress; + + /** + * Employee's Headquarters data, if he is working there + */ + private HeadquartersData employeeHeadquarters; + + /** + * Assigned personal data of the employee + */ + private Contact employeePersonalContact; + + /** + * Employee's phone extension (on top of a "main number") + */ + private Long employeePhoneExtension; + + /** + * Employee's staff number + */ + private Long employeeStaffNumber; + + /** + * Assigned user account + */ + private User employeeUserOwner; + + /** + * Mobile number for employee's business mobile + */ + private Long mobileNumber; + + /** + * Mobile provider instance for employee's business mobile + */ + private MobileProvider mobileProvider; + + /** + * Default constructor + */ + public FinancialsAdminEmployeeWebRequestBean () { + // Call super constructor + super(); + } + + /** + * Getter for employee's assigned branch office + *

+ * @return Employee's assigned branch office + */ + public BranchOffice getEmployeeBranchOffice () { + return this.employeeBranchOffice; + } + + /** + * Setter for employee's assigned branch office + *

+ * @param employeeBranchOffice Employee's assigned branch office + */ + public void setEmployeeBranchOffice (final BranchOffice employeeBranchOffice) { + this.employeeBranchOffice = employeeBranchOffice; + } + + /** + * Getter for employee's assigned basic company data + *

+ * @return Employee's assigned basic company data + */ + public BusinessBasicData getEmployeeCompany () { + return this.employeeCompany; + } + + /** + * Setter for employee's assigned basic company data + *

+ * @param employeeCompany Employee's assigned basic company data + */ + public void setEmployeeCompany (final BusinessBasicData employeeCompany) { + this.employeeCompany = employeeCompany; + } + + /** + * Getter for employee's assigned department + *

+ * @return Employee's assigned department + */ + public Department getEmployeeDepartment () { + return this.employeeDepartment; + } + + /** + * Setter for employee's assigned department + *

+ * @param employeeDepartment Employee's assigned department + */ + public void setEmployeeDepartment (final Department employeeDepartment) { + this.employeeDepartment = employeeDepartment; + } + + /** + * Getter for employee's business email address + *

+ * @return Employee's business email address + */ + public String getEmployeeEmailAddress () { + return this.employeeEmailAddress; + } + + /** + * Setter for employee's business email address + *

+ * @param employeeEmailAddress Employee's business email address + */ + public void setEmployeeEmailAddress (final String employeeEmailAddress) { + this.employeeEmailAddress = employeeEmailAddress; + } + + /** + * Getter for employee's assigned headquarters (if no branch office) + *

+ * @return Employee's assigned headquarters + */ + public HeadquartersData getEmployeeHeadquarters () { + return this.employeeHeadquarters; + } + + /** + * Setter for employee's assigned headquarters (if no branch office) + *

+ * @param employeeHeadquarters Employee's assigned headquarters + */ + public void setEmployeeHeadquarters (final HeadquartersData employeeHeadquarters) { + this.employeeHeadquarters = employeeHeadquarters; + } + + /** + * Getter for employee's personal contact data + *

+ * @return Employee's personal contact data + */ + public Contact getEmployeePersonalContact () { + return this.employeePersonalContact; + } + + /** + * Setter for employee's personal contact data + *

+ * @param employeePersonalContact Employee's personal contact data + */ + public void setEmployeePersonalContact (final Contact employeePersonalContact) { + this.employeePersonalContact = employeePersonalContact; + } + + /** + * Getter for employee's phone extension + *

+ * @return Employee's phone extension + */ + public Long getEmployeePhoneExtension () { + return this.employeePhoneExtension; + } + + /** + * Getter for employee's phone extension + *

+ * @param employeePhoneExtension Employee's phone extension + */ + public void setEmployeePhoneExtension (final Long employeePhoneExtension) { + this.employeePhoneExtension = employeePhoneExtension; + } + + /** + * Getter for employee's staff number + *

+ * @return Employee's staff number + */ + public Long getEmployeeStaffNumber () { + return this.employeeStaffNumber; + } + + /** + * Setter for employee's staff number + *

+ * @param employeeStaffNumber Employee's staff number + */ + public void setEmployeeStaffNumber (final Long employeeStaffNumber) { + this.employeeStaffNumber = employeeStaffNumber; + } + + /** + * Getter for employee's user "owner" + *

+ * @return Employee's user "owner" + */ + public User getEmployeeUserOwner () { + return this.employeeUserOwner; + } + + /** + * Setter for employee's user "owner" + *

+ * @param employeeUserOwner Employee's user "owner" + */ + public void setEmployeeUserOwner (final User employeeUserOwner) { + this.employeeUserOwner = employeeUserOwner; + } + + /** + * Getter for mobile number + *

+ * @return Mobile number + */ + public Long getMobileNumber () { + return this.mobileNumber; + } + + /** + * Setter for mobile number + *

+ * @param mobileNumber Mobile number + */ + public void setMobileNumber (final Long mobileNumber) { + this.mobileNumber = mobileNumber; + } + + /** + * Getter for mobile provider instance + *

+ * @return Mobile provider instance + */ + public MobileProvider getMobileProvider () { + return this.mobileProvider; + } + + /** + * Setter for mobile provider instance + *

+ * @param mobileProvider Mobile provider instance + */ + public void setMobileProvider (final MobileProvider mobileProvider) { + this.mobileProvider = mobileProvider; + } + +} diff --git a/src/java/org/mxchange/jfinancials/beans/business/employee/FinancialsAdminEmployeeWebRequestController.java b/src/java/org/mxchange/jfinancials/beans/business/employee/FinancialsAdminEmployeeWebRequestController.java new file mode 100644 index 00000000..75d1f5a8 --- /dev/null +++ b/src/java/org/mxchange/jfinancials/beans/business/employee/FinancialsAdminEmployeeWebRequestController.java @@ -0,0 +1,28 @@ +/* + * 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 . + */ +package org.mxchange.jfinancials.beans.business.employee; + +import java.io.Serializable; + +/** + * An interface for request-scoped administrative company employee beans + *

+ * @author Roland Häder + */ +public interface FinancialsAdminEmployeeWebRequestController extends Serializable { + +} diff --git a/src/java/org/mxchange/jfinancials/beans/business/employee/FinancialsCompanyEmployeeWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/business/employee/FinancialsCompanyEmployeeWebRequestBean.java deleted file mode 100644 index 56869c26..00000000 --- a/src/java/org/mxchange/jfinancials/beans/business/employee/FinancialsCompanyEmployeeWebRequestBean.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright (C) 2017 RRoland 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 . - */ -package org.mxchange.jfinancials.beans.business.employee; - -import fish.payara.cdi.jsr107.impl.NamedCache; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import javax.annotation.PostConstruct; -import javax.cache.Cache; -import javax.ejb.EJB; -import javax.enterprise.context.RequestScoped; -import javax.inject.Inject; -import javax.inject.Named; -import org.mxchange.jcontactsbusiness.model.employee.CompanyEmployeeSessionBeanRemote; -import org.mxchange.jcontactsbusiness.model.employee.Employee; -import org.mxchange.jfinancials.beans.BaseFinancialsBean; - -/** - * A request-scoped bean for general purposes for company employees. - *

- * @author Roland Häder - */ -@Named ("companyEmployeeController") -@RequestScoped -public class FinancialsCompanyEmployeeWebRequestBean extends BaseFinancialsBean implements FinancialsCompanyEmployeeWebRequestController { - - /** - * Serial number - */ - private static final long serialVersionUID = 12_886_968_547_361L; - - /** - * EJB for general company employee purposes - */ - @EJB (lookup = "java:global/jfinancials-ejb/companyEmployee!org.mxchange.jcontactsbusiness.model.employee.CompanyEmployeeSessionBeanRemote") - private CompanyEmployeeSessionBeanRemote companyEmployeeBean; - - /** - * List of all company employees - */ - @Inject - @NamedCache (cacheName = "companyEmployeeCache") - private Cache companyEmployeeCache; - - /** - * A list of filtered employees - */ - private List filteredEmployees; - - /** - * Default constructor - */ - public FinancialsCompanyEmployeeWebRequestBean () { - // Call super constructor - super(); - } - - /** - * Returns a list of all company employees - *

- * @return List of all company employees - */ - @SuppressWarnings ("ReturnOfCollectionOrArrayField") - public List allCompanyEmployees () { - // Init list - final List list = new LinkedList<>(); - - // Get iterator - final Iterator> iterator = this.companyEmployeeCache.iterator(); - - // Loop over all - while (iterator.hasNext()) { - // Get next entry - final Cache.Entry next = iterator.next(); - - // Add value to list - list.add(next.getValue()); - } - - // Return it - return list; - } - - /** - * Getter for filtered list of employees - *

- * @return Filtered list of employees - */ - @SuppressWarnings ("ReturnOfCollectionOrArrayField") - public List getFilteredEmployees () { - return this.filteredEmployees; - } - - /** - * Getter for filtered list of employees - *

- * @param filteredEmployees Filtered list of employees - */ - @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter") - public void setFilteredEmployees (final List filteredEmployees) { - this.filteredEmployees = filteredEmployees; - } - - /** - * Initialization method - */ - @PostConstruct - public void init () { - // Is cache there? - if (!this.companyEmployeeCache.iterator().hasNext()) { - // Get whole list - final List list = this.companyEmployeeBean.allCompanyEmployees(); - - // Add all - for (final Iterator iterator = list.iterator(); iterator.hasNext();) { - // Get next element - final Employee next = iterator.next(); - - // Add it to cache - this.companyEmployeeCache.put(next.getEmployeeId(), next); - } - } - } - -} diff --git a/src/java/org/mxchange/jfinancials/beans/business/employee/FinancialsCompanyEmployeeWebRequestController.java b/src/java/org/mxchange/jfinancials/beans/business/employee/FinancialsCompanyEmployeeWebRequestController.java deleted file mode 100644 index ef6bd148..00000000 --- a/src/java/org/mxchange/jfinancials/beans/business/employee/FinancialsCompanyEmployeeWebRequestController.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package org.mxchange.jfinancials.beans.business.employee; - -import java.io.Serializable; - -/** - * An interface for request-scoped general company employee beans - *

- * @author Roland Häder - */ -public interface FinancialsCompanyEmployeeWebRequestController extends Serializable { - -} diff --git a/src/java/org/mxchange/jfinancials/beans/business/employee/FinancialsEmployeeWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/business/employee/FinancialsEmployeeWebRequestBean.java new file mode 100644 index 00000000..e3554ffa --- /dev/null +++ b/src/java/org/mxchange/jfinancials/beans/business/employee/FinancialsEmployeeWebRequestBean.java @@ -0,0 +1,184 @@ +/* + * Copyright (C) 2017 RRoland 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 . + */ +package org.mxchange.jfinancials.beans.business.employee; + +import fish.payara.cdi.jsr107.impl.NamedCache; +import java.text.MessageFormat; +import java.util.Comparator; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import javax.annotation.PostConstruct; +import javax.cache.Cache; +import javax.ejb.EJB; +import javax.enterprise.context.RequestScoped; +import javax.enterprise.event.Observes; +import javax.inject.Inject; +import javax.inject.Named; +import org.mxchange.jcontactsbusiness.events.employee.added.ObservableEmployeeAddedEvent; +import org.mxchange.jcontactsbusiness.model.employee.CompanyEmployeeSessionBeanRemote; +import org.mxchange.jcontactsbusiness.model.employee.Employee; +import org.mxchange.jfinancials.beans.BaseFinancialsBean; + +/** + * A request-scoped bean for general purposes for company employees. + *

+ * @author Roland Häder + */ +@Named ("employeeController") +@RequestScoped +public class FinancialsEmployeeWebRequestBean extends BaseFinancialsBean implements FinancialsEmployeeWebRequestController { + + /** + * Serial number + */ + private static final long serialVersionUID = 12_886_968_547_361L; + + /** + * List of all employees + */ + private final List allEmployees; + + /** + * EJB for general company employee purposes + */ + @EJB (lookup = "java:global/jfinancials-ejb/employee!org.mxchange.jcontactsbusiness.model.employee.CompanyEmployeeSessionBeanRemote") + private CompanyEmployeeSessionBeanRemote employeeBean; + + /** + * List of all company employees + */ + @Inject + @NamedCache (cacheName = "companyEmployeeCache") + private Cache employeeCache; + + /** + * A list of filtered employees + */ + private List filteredEmployees; + + /** + * Default constructor + */ + public FinancialsEmployeeWebRequestBean () { + // Call super constructor + super(); + + // Init list + this.allEmployees = new LinkedList<>(); + } + + /** + * Observes events being fired when an employee has been added + *

+ * @param event Event being fired + */ + public void afterEmployeeAddedEvent (@Observes final ObservableEmployeeAddedEvent event) { + // Validate parameter + if (null == event) { + // Throw NPE + throw new NullPointerException("event is null"); //NOI18N + } else if (event.getEmployee() == null) { + // Throw it again + throw new NullPointerException("event.employee is null"); //NOI18N + } else if (event.getEmployee().getEmployeeId() == null) { + // Throw it again + throw new NullPointerException("event.employee.employeeId is null"); //NOI18N + } else if (event.getEmployee().getEmployeeId() < 1) { + // Throw IAE + throw new IllegalArgumentException(MessageFormat.format("event.employee.employeeId={0} is invalid", event.getEmployee().getEmployeeId())); //NOI18N + } + + // Add employee to cache and list + this.employeeCache.put(event.getEmployee().getEmployeeId(), event.getEmployee()); + } + + /** + * Returns a list of all company employees + *

+ * @return List of all company employees + */ + @SuppressWarnings ("ReturnOfCollectionOrArrayField") + public List allCompanyEmployees () { + return this.allEmployees; + } + + /** + * Getter for filtered list of employees + *

+ * @return Filtered list of employees + */ + @SuppressWarnings ("ReturnOfCollectionOrArrayField") + public List getFilteredEmployees () { //NOI18N + return this.filteredEmployees; + } + + /** + * Getter for filtered list of employees + *

+ * @param filteredEmployees Filtered list of employees + */ + @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter") + public void setFilteredEmployees (final List filteredEmployees) { //NOI18N + this.filteredEmployees = filteredEmployees; + } + + /** + * Initialization method + */ + @PostConstruct + public void init () { + // Is cache there? + if (!this.employeeCache.iterator().hasNext()) { + // Get whole list + final List list = this.employeeBean.allCompanyEmployees(); + + // Add all + for (final Iterator iterator = list.iterator(); iterator.hasNext();) { + // Get next element + final Employee next = iterator.next(); + + // Add it to cache + this.employeeCache.put(next.getEmployeeId(), next); + } + } + + // Is cache filled and list is empty + if ((this.employeeCache.iterator().hasNext()) && (this.allEmployees.isEmpty())) { + // Get iterator + final Iterator> iterator = this.employeeCache.iterator(); + + // Build up list + while (iterator.hasNext()) { + // GEt next element + final Cache.Entry next = iterator.next(); + + // Add to list + this.allEmployees.add(next.getValue()); + } + + // Sort list + this.allEmployees.sort(new Comparator() { + @Override + public int compare (final Employee o1, final Employee o2) { + return o1.getEmployeeId() > o2.getEmployeeId() ? 1 : o1.getEmployeeId() < o2.getEmployeeId() ? -1 : 0; + } + }); + } + } + +} diff --git a/src/java/org/mxchange/jfinancials/beans/business/employee/FinancialsEmployeeWebRequestController.java b/src/java/org/mxchange/jfinancials/beans/business/employee/FinancialsEmployeeWebRequestController.java new file mode 100644 index 00000000..e56f6fb5 --- /dev/null +++ b/src/java/org/mxchange/jfinancials/beans/business/employee/FinancialsEmployeeWebRequestController.java @@ -0,0 +1,28 @@ +/* + * 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 . + */ +package org.mxchange.jfinancials.beans.business.employee; + +import java.io.Serializable; + +/** + * An interface for request-scoped general company employee beans + *

+ * @author Roland Häder + */ +public interface FinancialsEmployeeWebRequestController extends Serializable { + +} diff --git a/src/java/org/mxchange/jfinancials/beans/helper/FinancialsWebRequestHelperBean.java b/src/java/org/mxchange/jfinancials/beans/helper/FinancialsWebRequestHelperBean.java index 67272bae..912cb454 100644 --- a/src/java/org/mxchange/jfinancials/beans/helper/FinancialsWebRequestHelperBean.java +++ b/src/java/org/mxchange/jfinancials/beans/helper/FinancialsWebRequestHelperBean.java @@ -537,6 +537,14 @@ public class FinancialsWebRequestHelperBean extends BaseFinancialsBean implement // Then create name sb.append(employee.getEmployeeNumber()); + // Is a department found? + if (employee.getEmployeeDepartment() instanceof Department) { + // Then add it's name to it + sb.append(" ("); //NOI18N + sb.append(this.renderDepartment(employee.getEmployeeDepartment())); + sb.append(")"); //NOI18N + } + // Is contact data found? if (employee.getEmployeePersonalData() instanceof Contact) { // Yes, then render it diff --git a/src/java/org/mxchange/jfinancials/beans/mobileprovider/FinancialsMobileProviderWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/mobileprovider/FinancialsMobileProviderWebRequestBean.java index 7e5a8af3..0c1b079a 100644 --- a/src/java/org/mxchange/jfinancials/beans/mobileprovider/FinancialsMobileProviderWebRequestBean.java +++ b/src/java/org/mxchange/jfinancials/beans/mobileprovider/FinancialsMobileProviderWebRequestBean.java @@ -176,8 +176,7 @@ public class FinancialsMobileProviderWebRequestBean extends BaseFinancialsBean i public int compare (final MobileProvider o1, final MobileProvider o2) { return o1.getProviderId() > o2.getProviderId() ? 1 : o1.getProviderId() < o2.getProviderId() ? -1 : 0; } - } - ); + }); } } } diff --git a/src/java/org/mxchange/jfinancials/converter/business/company_employee/FinancialsCompanyEmployeeConverter.java b/src/java/org/mxchange/jfinancials/converter/business/company_employee/FinancialsCompanyEmployeeConverter.java index cd886fff..e0867597 100644 --- a/src/java/org/mxchange/jfinancials/converter/business/company_employee/FinancialsCompanyEmployeeConverter.java +++ b/src/java/org/mxchange/jfinancials/converter/business/company_employee/FinancialsCompanyEmployeeConverter.java @@ -52,7 +52,7 @@ public class FinancialsCompanyEmployeeConverter implements Converter { final Context initial = new InitialContext(); // Lookup EJB - EMPLOYEE_BEAN = (CompanyEmployeeSessionBeanRemote) initial.lookup("java:global/jfinancials-ejb/companyEmployee!org.mxchange.jcontactsbusiness.model.employee.CompanyEmployeeSessionBeanRemote"); //NOI18N + EMPLOYEE_BEAN = (CompanyEmployeeSessionBeanRemote) initial.lookup("java:global/jfinancials-ejb/employee!org.mxchange.jcontactsbusiness.model.employee.CompanyEmployeeSessionBeanRemote"); //NOI18N } catch (final NamingException ex) { // Throw it again throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Cannot lookup EJB", ex.getMessage()), ex); //NOI18N diff --git a/src/java/org/mxchange/jfinancials/converter/business/headquarters/FinancialsCompanyHeadquartersConverter.java b/src/java/org/mxchange/jfinancials/converter/business/headquarters/FinancialsCompanyHeadquartersConverter.java index 95487473..c27cba7a 100644 --- a/src/java/org/mxchange/jfinancials/converter/business/headquarters/FinancialsCompanyHeadquartersConverter.java +++ b/src/java/org/mxchange/jfinancials/converter/business/headquarters/FinancialsCompanyHeadquartersConverter.java @@ -52,7 +52,7 @@ public class FinancialsCompanyHeadquartersConverter implements Converter - + @@ -70,7 +70,7 @@ > - + diff --git a/web/WEB-INF/templates/admin/branch_office/admin_form_branch_office_data.tpl b/web/WEB-INF/templates/admin/branch_office/admin_form_branch_office_data.tpl index 778e60a7..7e2c72b7 100644 --- a/web/WEB-INF/templates/admin/branch_office/admin_form_branch_office_data.tpl +++ b/web/WEB-INF/templates/admin/branch_office/admin_form_branch_office_data.tpl @@ -35,7 +35,7 @@ > - + diff --git a/web/WEB-INF/templates/admin/department/admin_form_department_data.tpl b/web/WEB-INF/templates/admin/department/admin_form_department_data.tpl index fb18bf89..838c2a91 100644 --- a/web/WEB-INF/templates/admin/department/admin_form_department_data.tpl +++ b/web/WEB-INF/templates/admin/department/admin_form_department_data.tpl @@ -62,7 +62,7 @@ > - + diff --git a/web/WEB-INF/templates/admin/employee/admin_form_employee_data.tpl b/web/WEB-INF/templates/admin/employee/admin_form_employee_data.tpl index 2ebc4023..8a2bf917 100644 --- a/web/WEB-INF/templates/admin/employee/admin_form_employee_data.tpl +++ b/web/WEB-INF/templates/admin/employee/admin_form_employee_data.tpl @@ -15,7 +15,7 @@ @@ -41,7 +41,7 @@ @@ -53,7 +53,7 @@ @@ -63,13 +63,13 @@ - + - + @@ -79,12 +79,12 @@ - + @@ -96,7 +96,7 @@ @@ -106,7 +106,7 @@ - + diff --git a/web/admin/basic_company_data/admin_basic_company_data_list.xhtml b/web/admin/basic_company_data/admin_basic_company_data_list.xhtml index e3059b2c..0fb9c237 100644 --- a/web/admin/basic_company_data/admin_basic_company_data_list.xhtml +++ b/web/admin/basic_company_data/admin_basic_company_data_list.xhtml @@ -98,7 +98,7 @@ > - + @@ -123,7 +123,7 @@ > - + diff --git a/web/admin/branch_office/admin_branch_office_list.xhtml b/web/admin/branch_office/admin_branch_office_list.xhtml index 1b0fca22..26bd0c68 100644 --- a/web/admin/branch_office/admin_branch_office_list.xhtml +++ b/web/admin/branch_office/admin_branch_office_list.xhtml @@ -122,7 +122,7 @@ > - + diff --git a/web/admin/department/admin_department_list.xhtml b/web/admin/department/admin_department_list.xhtml index dfe8a967..d131c45b 100644 --- a/web/admin/department/admin_department_list.xhtml +++ b/web/admin/department/admin_department_list.xhtml @@ -57,7 +57,7 @@ - + @@ -99,7 +99,7 @@ - + @@ -116,7 +116,7 @@ > - + diff --git a/web/admin/employee/admin_employee_list.xhtml b/web/admin/employee/admin_employee_list.xhtml index bd6be330..3ac1c784 100644 --- a/web/admin/employee/admin_employee_list.xhtml +++ b/web/admin/employee/admin_employee_list.xhtml @@ -21,11 +21,11 @@