]> git.mxchange.org Git - addressbook-war.git/blob
6a6521c917a41a5dddac5cf8476066a1fca87532
[addressbook-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.addressbook.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.addressbook.beans.BaseAddressbookController;
29 import org.mxchange.addressbook.beans.user.login.AddressbookUserLoginWebSessionController;
30 import org.mxchange.jcontactsbusiness.basicdata.AdminBusinessDataSessionBeanRemote;
31 import org.mxchange.jcontactsbusiness.basicdata.BusinessBasicData;
32 import org.mxchange.jcontactsbusiness.basicdata.BusinessDataSessionBeanRemote;
33 import org.mxchange.jcountry.data.Country;
34
35 /**
36  * A business contact bean (controller)
37  * <p>
38  * @author Roland Häder<roland@mxchange.org>
39  */
40 @Named ("companyDataController")
41 @SessionScoped
42 public class AddressbookBusinessDataWebSessionBean extends BaseAddressbookController implements AddressbookBusinessDataWebSessionController {
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 AddressbookUserLoginWebSessionController userLoginController;
114
115         /**
116          * Constructor
117          */
118         public AddressbookBusinessDataWebSessionBean () {
119                 // Call super constructor
120                 super();
121         }
122
123
124         /**
125          * Returns a list of all business contacts
126          * <p>
127          * @return A list of all business contacts
128          */
129         @SuppressWarnings ("ReturnOfCollectionOrArrayField")
130         public List<BusinessBasicData> allCompanyBasicData () {
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 name
172          * <p>
173          * @return Company name
174          */
175         public String getCompanyName () {
176                 return this.companyName;
177         }
178
179         /**
180          * Setter for company name
181          * <p>
182          * @param companyName Company name
183          */
184         public void setCompanyName (final String companyName) {
185                 this.companyName = companyName;
186         }
187
188         /**
189          * Getter for fax number's area code
190          * <p>
191          * @return Fax number's area code
192          */
193         public Integer getFaxAreaCode () {
194                 return this.faxAreaCode;
195         }
196
197         /**
198          * Setter for fax number's area code
199          * <p>
200          * @param faxAreaCode Fax number's area code
201          */
202         public void setFaxAreaCode (final Integer faxAreaCode) {
203                 this.faxAreaCode = faxAreaCode;
204         }
205
206         /**
207          * Getter for fax's country instance
208          * <p>
209          * @return Fax' country instance
210          */
211         public Country getFaxCountry () {
212                 return this.faxCountry;
213         }
214
215         /**
216          * Setter for fax's country instance
217          * <p>
218          * @param faxCountry Fax' country instance
219          */
220         public void setFaxCountry (final Country faxCountry) {
221                 this.faxCountry = faxCountry;
222         }
223
224         /**
225          * Getter for fax number
226          * <p>
227          * @return Fax number
228          */
229         public Long getFaxNumber () {
230                 return this.faxNumber;
231         }
232
233         /**
234          * Setter for fax number
235          * <p>
236          * @param faxNumber Fax number
237          */
238         public void setFaxNumber (final Long faxNumber) {
239                 this.faxNumber = faxNumber;
240         }
241
242         /**
243          * Getter for land-line number's area code
244          * <p>
245          * @return Land-line number's area code
246          */
247         public Integer getLandLineAreaCode () {
248                 return this.landLineAreaCode;
249         }
250
251         /**
252          * Setter for land-line number's area code
253          * <p>
254          * @param landLineAreaCode Land-line number's area code
255          */
256         public void setLandLineAreaCode (final Integer landLineAreaCode) {
257                 this.landLineAreaCode = landLineAreaCode;
258         }
259
260         /**
261          * Getter for land-line number's country instance
262          * <p>
263          * @return Land-line number's country instance
264          */
265         public Country getLandLineCountry () {
266                 return this.landLineCountry;
267         }
268
269         /**
270          * Setter for land-line number's country instance
271          * <p>
272          * @param landLineCountry Land-line number's country instance
273          */
274         public void setLandLineCountry (final Country landLineCountry) {
275                 this.landLineCountry = landLineCountry;
276         }
277
278         /**
279          * Getter for land-line number
280          * <p>
281          * @return Land-line number
282          */
283         public Long getLandLineNumber () {
284                 return this.landLineNumber;
285         }
286
287         /**
288          * Setter for land-line number
289          * <p>
290          * @param landLineNumber Land-line number
291          */
292         public void setLandLineNumber (final Long landLineNumber) {
293                 this.landLineNumber = landLineNumber;
294         }
295
296         /**
297          * Post-initialization of this class
298          */
299         @PostConstruct
300         public void init () {
301                 // Try it
302                 try {
303                         // Get initial context
304                         Context context = new InitialContext();
305
306                         // Try to lookup
307                         this.businessDataBean = (BusinessDataSessionBeanRemote) context.lookup("java:global/addressbook-ejb/businessData!org.mxchange.jcontactsbusiness.basicdata.BusinessDataSessionBeanRemote"); //NOI18N
308
309                         // Try to lookup
310                         this.adminBusinessDataBean = (AdminBusinessDataSessionBeanRemote) context.lookup("java:global/addressbook-ejb/adminBusinessData!org.mxchange.jcontactsbusiness.basicdata.AdminBusinessDataSessionBeanRemote"); //NOI18N
311                 } catch (final NamingException e) {
312                         // Throw again
313                         throw new FaceletException(e);
314                 }
315
316                 // Init user's contact list
317                 this.businessContacts = this.adminBusinessDataBean.allCompanyBasicData();
318         }
319
320 }