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