]> git.mxchange.org Git - pizzaservice-war.git/blob
cb060dd36a5626aa4eb9aed7a67d0bf03f85b14a
[pizzaservice-war.git] /
1 /*
2  * Copyright (C) 2016, 2017 Roland 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.pizzaapplication.beans.business.basicdata;
18
19 import java.util.List;
20 import javax.annotation.PostConstruct;
21 import javax.enterprise.context.SessionScoped;
22 import javax.faces.view.facelets.FaceletException;
23 import javax.inject.Inject;
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.basicdata.AdminBusinessDataSessionBeanRemote;
29 import org.mxchange.jcontactsbusiness.basicdata.BusinessBasicData;
30 import org.mxchange.jcontactsbusiness.basicdata.BusinessDataSessionBeanRemote;
31 import org.mxchange.jcountry.data.Country;
32 import org.mxchange.pizzaapplication.beans.BasePizzaController;
33 import org.mxchange.pizzaapplication.beans.user.login.PizzaUserLoginWebSessionController;
34
35 /**
36  * A business contact bean (controller)
37  * <p>
38  * @author Roland Häder<roland@mxchange.org>
39  */
40 @Named ("businessDataController")
41 @SessionScoped
42 public class PizzaBusinessDataWebSessionBean extends BasePizzaController implements PizzaBusinessDataWebSessionController {
43
44         /**
45          * Serial number
46          */
47         private static final long serialVersionUID = 56_189_028_928_371L;
48
49         /**
50          * Remote contact bean
51          */
52         private AdminBusinessDataSessionBeanRemote adminBusinessDataBean;
53
54         /**
55          * A list of all registered companies (globally)
56          */
57         private List<BusinessBasicData> businessContacts;
58
59         /**
60          * Remote contact bean
61          */
62         private BusinessDataSessionBeanRemote businessDataBean;
63
64         /**
65          * Comments for this company
66          */
67         private String companyComments;
68
69         /**
70          * Companies (main) email address (example: info@company.example)
71          */
72         private String companyEmailAddress;
73
74         /**
75          * Company name
76          */
77         private String companyName;
78
79         /**
80          * Area code for fax number
81          */
82         private Integer faxAreaCode;
83
84         /**
85          * Country for fax number
86          */
87         private Country faxCountry;
88
89         /**
90          * Dial number for fax number
91          */
92         private Long faxNumber;
93
94         /**
95          * Area code for land-line number
96          */
97         private Integer landLineAreaCode;
98
99         /**
100          * Country for land-line number
101          */
102         private Country landLineCountry;
103
104         /**
105          * Dial number for land-line number
106          */
107         private Long landLineNumber;
108
109         /**
110          * User instance
111          */
112         @Inject
113         private PizzaUserLoginWebSessionController userLoginController;
114
115         /**
116          * Constructor
117          */
118         public PizzaBusinessDataWebSessionBean () {
119                 // Call super constructor
120                 super();
121         }
122
123         @Override
124         @SuppressWarnings ("ReturnOfCollectionOrArrayField")
125         public List<BusinessBasicData> allBusinessContacts () {
126                 return this.businessContacts;
127         }
128
129         /**
130          * Getter for comments
131          * <p>
132          * @return Comments
133          */
134         public String getCompanyComments () {
135                 return this.companyComments;
136         }
137
138         /**
139          * Setter for comments
140          * <p>
141          * @param companyComments Comments
142          */
143         public void setCompanyComments (final String companyComments) {
144                 this.companyComments = companyComments;
145         }
146
147         /**
148          * Getter for company's (main) email address
149          * <p>
150          * @return Company's (main) email address
151          */
152         public String getCompanyEmailAddress () {
153                 return this.companyEmailAddress;
154         }
155
156         /**
157          * Setter for company's (main) email address
158          * <p>
159          * @param companyEmailAddress Company's (main) email address
160          */
161         public void setCompanyEmailAddress (final String companyEmailAddress) {
162                 this.companyEmailAddress = companyEmailAddress;
163         }
164
165         /**
166          * Getter for company name
167          * <p>
168          * @return Company name
169          */
170         public String getCompanyName () {
171                 return this.companyName;
172         }
173
174         /**
175          * Setter for company name
176          * <p>
177          * @param companyName Company name
178          */
179         public void setCompanyName (final String companyName) {
180                 this.companyName = companyName;
181         }
182
183         /**
184          * Getter for fax number's area code
185          * <p>
186          * @return Fax number's area code
187          */
188         public Integer getFaxAreaCode () {
189                 return this.faxAreaCode;
190         }
191
192         /**
193          * Setter for fax number's area code
194          * <p>
195          * @param faxAreaCode Fax number's area code
196          */
197         public void setFaxAreaCode (final Integer faxAreaCode) {
198                 this.faxAreaCode = faxAreaCode;
199         }
200
201         /**
202          * Getter for fax's country instance
203          * <p>
204          * @return Fax' country instance
205          */
206         public Country getFaxCountry () {
207                 return this.faxCountry;
208         }
209
210         /**
211          * Setter for fax's country instance
212          * <p>
213          * @param faxCountry Fax' country instance
214          */
215         public void setFaxCountry (final Country faxCountry) {
216                 this.faxCountry = faxCountry;
217         }
218
219         /**
220          * Getter for fax number
221          * <p>
222          * @return Fax number
223          */
224         public Long getFaxNumber () {
225                 return this.faxNumber;
226         }
227
228         /**
229          * Setter for fax number
230          * <p>
231          * @param faxNumber Fax number
232          */
233         public void setFaxNumber (final Long faxNumber) {
234                 this.faxNumber = faxNumber;
235         }
236
237         /**
238          * Getter for land-line number's area code
239          * <p>
240          * @return Land-line number's area code
241          */
242         public Integer getLandLineAreaCode () {
243                 return this.landLineAreaCode;
244         }
245
246         /**
247          * Setter for land-line number's area code
248          * <p>
249          * @param landLineAreaCode Land-line number's area code
250          */
251         public void setLandLineAreaCode (final Integer landLineAreaCode) {
252                 this.landLineAreaCode = landLineAreaCode;
253         }
254
255         /**
256          * Getter for land-line number's country instance
257          * <p>
258          * @return Land-line number's country instance
259          */
260         public Country getLandLineCountry () {
261                 return this.landLineCountry;
262         }
263
264         /**
265          * Setter for land-line number's country instance
266          * <p>
267          * @param landLineCountry Land-line number's country instance
268          */
269         public void setLandLineCountry (final Country landLineCountry) {
270                 this.landLineCountry = landLineCountry;
271         }
272
273         /**
274          * Getter for land-line number
275          * <p>
276          * @return Land-line number
277          */
278         public Long getLandLineNumber () {
279                 return this.landLineNumber;
280         }
281
282         /**
283          * Setter for land-line number
284          * <p>
285          * @param landLineNumber Land-line number
286          */
287         public void setLandLineNumber (final Long landLineNumber) {
288                 this.landLineNumber = landLineNumber;
289         }
290
291         /**
292          * Post-initialization of this class
293          */
294         @PostConstruct
295         public void init () {
296                 // Try it
297                 try {
298                         // Get initial context
299                         Context context = new InitialContext();
300
301                         // Try to lookup
302                         this.businessDataBean = (BusinessDataSessionBeanRemote) context.lookup("java:global/jfinancials-ejb/businessData!org.mxchange.jcontactsbusiness.basicdata.BusinessDataSessionBeanRemote"); //NOI18N
303
304                         // Try to lookup
305                         this.adminBusinessDataBean = (AdminBusinessDataSessionBeanRemote) context.lookup("java:global/jfinancials-ejb/adminBusinessData!org.mxchange.jcontactsbusiness.basicdata.BusinessDataAdminSessionBeanRemote"); //NOI18N
306                 } catch (final NamingException e) {
307                         // Throw again
308                         throw new FaceletException(e);
309                 }
310
311                 // Init user's contact list
312                 this.businessContacts = this.adminBusinessDataBean.allBusinessContacts();
313         }
314
315 }