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