]> git.mxchange.org Git - jfinancials-war.git/blob
8d8307a28a5ab57ca2ed7cc7385f14f525a484a0
[jfinancials-war.git] /
1 /*
2  * Copyright (C) 2017 RRoland Häder
3  *
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.
8  *
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.
13  *
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/>.
16  */
17 package org.mxchange.jfinancials.beans.business.employee;
18
19 import java.util.LinkedList;
20 import java.util.List;
21 import javax.annotation.PostConstruct;
22 import javax.ejb.EJB;
23 import javax.enterprise.context.SessionScoped;
24 import javax.inject.Named;
25 import org.mxchange.jcontactsbusiness.employee.CompanyEmployeeSessionBeanRemote;
26 import org.mxchange.jcontactsbusiness.employee.Employee;
27 import org.mxchange.jfinancials.beans.BaseFinancialsController;
28
29 /**
30  * A request-scoped bean for general purposes for company employees.
31  * <p>
32  * @author Roland Häder<roland@mxchange.org>
33  */
34 @Named ("companyEmployeeController")
35 @SessionScoped
36 public class FinancialsCompanyEmployeeWebRequestBean extends BaseFinancialsController implements FinancialsCompanyEmployeeWebSessionController {
37
38         /**
39          * Serial number
40          */
41         private static final long serialVersionUID = 12_886_968_547_361L;
42
43         /**
44          * EJB for general company employee purposes
45          */
46         @EJB (lookup = "java:global/jfinancials-ejb/companyEmployee!org.mxchange.jcontactsbusiness.employee.CompanyEmployeeSessionBeanRemote")
47         private CompanyEmployeeSessionBeanRemote companyEmployeeBean;
48
49         /**
50          * List of all company employees
51          */
52         private final List<Employee> companyEmployees;
53
54         /**
55          * Default constructor
56          */
57         public FinancialsCompanyEmployeeWebRequestBean () {
58                 // Call super constructor
59                 super();
60
61                 // Init list instance
62                 this.companyEmployees = new LinkedList<>();
63         }
64
65         /**
66          * Returns a list of all company employees
67          * <p>
68          * @return List of all company employees
69          */
70         @SuppressWarnings ("ReturnOfCollectionOrArrayField")
71         public List<Employee> allCompanyEmployees () {
72                 return this.companyEmployees;
73         }
74
75         /**
76          * Initialization method
77          */
78         @PostConstruct
79         public void init () {
80                 // Get all entries from remote bean
81                 List<Employee> employees = this.companyEmployeeBean.allCompanyEmployees();
82
83                 // Copy it to main list
84                 this.companyEmployees.addAll(employees);
85         }
86
87 }