2 * Copyright (C) 2017 RRoland Häder
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Affero General Public License as
6 * published by the Free Software Foundation, either version 3 of the
7 * License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Affero General Public License for more details.
14 * You should have received a copy of the GNU Affero General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package org.mxchange.pizzaapplication.beans.business.employee;
19 import java.util.LinkedList;
20 import java.util.List;
21 import javax.annotation.PostConstruct;
22 import javax.enterprise.context.SessionScoped;
23 import javax.faces.view.facelets.FaceletException;
24 import javax.inject.Named;
25 import javax.naming.Context;
26 import javax.naming.InitialContext;
27 import javax.naming.NamingException;
28 import org.mxchange.jcontactsbusiness.employee.CompanyEmployeeSessionBeanRemote;
29 import org.mxchange.jcontactsbusiness.employee.Employee;
30 import org.mxchange.pizzaapplication.beans.BasePizzaController;
33 * A request-scoped bean for general purposes for company employees.
35 * @author Roland Häder<roland@mxchange.org>
37 @Named ("companyEmployeeController")
39 public class PizzaCompanyEmployeeWebRequestBean extends BasePizzaController implements PizzaCompanyEmployeeWebSessionController {
44 private static final long serialVersionUID = 12_886_968_547_361L;
47 * EJB for general company employee purposes
49 private CompanyEmployeeSessionBeanRemote companyEmployeeBean;
52 * List of all company employees
54 private final List<Employee> companyEmployees;
59 public PizzaCompanyEmployeeWebRequestBean () {
60 // Call super constructor
64 this.companyEmployees = new LinkedList<>();
68 * Returns a list of all company employees
70 * @return List of all company employees
72 @SuppressWarnings ("ReturnOfCollectionOrArrayField")
73 public List<Employee> allCompanyEmployees () {
74 return this.companyEmployees;
78 * Initialization method
84 // Get initial context
85 Context context = new InitialContext();
88 this.companyEmployeeBean = (CompanyEmployeeSessionBeanRemote) context.lookup("java:global/pizzaservice-ejb/adminCompanyEmployee!org.mxchange.jcontactsbusiness.employee.CompanyEmployeeSessionBeanRemote"); //NOI18N
89 } catch (final NamingException e) {
91 throw new FaceletException(e);
94 // Get all entries from remote bean
95 List<Employee> employees = this.companyEmployeeBean.allCompanyEmployees();
97 // Copy it to main list
98 this.companyEmployees.addAll(employees);