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