2 * Copyright (C) 2016, 2017 Roland Häder
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.
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.
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/>.
17 package org.mxchange.addressbook.beans.business.basicdata;
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;
36 * A business contact bean (controller)
38 * @author Roland Häder<roland@mxchange.org>
40 @Named ("companyDataController")
42 public class AddressbookBusinessDataWebSessionBean extends BaseAddressbookController implements AddressbookBusinessDataWebSessionController {
47 private static final long serialVersionUID = 56_189_028_928_371L;
52 private AdminBusinessDataSessionBeanRemote adminBusinessDataBean;
55 * A list of all registered companies (globally)
57 private List<BusinessBasicData> businessContacts;
62 private BusinessDataSessionBeanRemote businessDataBean;
65 * Comments for this company
67 private String companyComments;
70 * Companies (main) email address (example: info@company.example)
72 private String companyEmailAddress;
77 private String companyName;
80 * Area code for fax number
82 private Integer faxAreaCode;
85 * Country for fax number
87 private Country faxCountry;
90 * Dial number for fax number
92 private Long faxNumber;
95 * Area code for land-line number
97 private Integer landLineAreaCode;
100 * Country for land-line number
102 private Country landLineCountry;
105 * Dial number for land-line number
107 private Long landLineNumber;
113 private AddressbookUserLoginWebSessionController userLoginController;
118 public AddressbookBusinessDataWebSessionBean () {
119 // Call super constructor
125 * Returns a list of all business contacts
127 * @return A list of all business contacts
129 @SuppressWarnings ("ReturnOfCollectionOrArrayField")
130 public List<BusinessBasicData> allCompanyBasicData () {
131 return this.businessContacts;
135 * Getter for comments
139 public String getCompanyComments () {
140 return this.companyComments;
144 * Setter for comments
146 * @param companyComments Comments
148 public void setCompanyComments (final String companyComments) {
149 this.companyComments = companyComments;
153 * Getter for company's (main) email address
155 * @return Company's (main) email address
157 public String getCompanyEmailAddress () {
158 return this.companyEmailAddress;
162 * Setter for company's (main) email address
164 * @param companyEmailAddress Company's (main) email address
166 public void setCompanyEmailAddress (final String companyEmailAddress) {
167 this.companyEmailAddress = companyEmailAddress;
171 * Getter for company name
173 * @return Company name
175 public String getCompanyName () {
176 return this.companyName;
180 * Setter for company name
182 * @param companyName Company name
184 public void setCompanyName (final String companyName) {
185 this.companyName = companyName;
189 * Getter for fax number's area code
191 * @return Fax number's area code
193 public Integer getFaxAreaCode () {
194 return this.faxAreaCode;
198 * Setter for fax number's area code
200 * @param faxAreaCode Fax number's area code
202 public void setFaxAreaCode (final Integer faxAreaCode) {
203 this.faxAreaCode = faxAreaCode;
207 * Getter for fax's country instance
209 * @return Fax' country instance
211 public Country getFaxCountry () {
212 return this.faxCountry;
216 * Setter for fax's country instance
218 * @param faxCountry Fax' country instance
220 public void setFaxCountry (final Country faxCountry) {
221 this.faxCountry = faxCountry;
225 * Getter for fax number
229 public Long getFaxNumber () {
230 return this.faxNumber;
234 * Setter for fax number
236 * @param faxNumber Fax number
238 public void setFaxNumber (final Long faxNumber) {
239 this.faxNumber = faxNumber;
243 * Getter for land-line number's area code
245 * @return Land-line number's area code
247 public Integer getLandLineAreaCode () {
248 return this.landLineAreaCode;
252 * Setter for land-line number's area code
254 * @param landLineAreaCode Land-line number's area code
256 public void setLandLineAreaCode (final Integer landLineAreaCode) {
257 this.landLineAreaCode = landLineAreaCode;
261 * Getter for land-line number's country instance
263 * @return Land-line number's country instance
265 public Country getLandLineCountry () {
266 return this.landLineCountry;
270 * Setter for land-line number's country instance
272 * @param landLineCountry Land-line number's country instance
274 public void setLandLineCountry (final Country landLineCountry) {
275 this.landLineCountry = landLineCountry;
279 * Getter for land-line number
281 * @return Land-line number
283 public Long getLandLineNumber () {
284 return this.landLineNumber;
288 * Setter for land-line number
290 * @param landLineNumber Land-line number
292 public void setLandLineNumber (final Long landLineNumber) {
293 this.landLineNumber = landLineNumber;
297 * Post-initialization of this class
300 public void init () {
303 // Get initial context
304 Context context = new InitialContext();
307 this.businessDataBean = (BusinessDataSessionBeanRemote) context.lookup("java:global/addressbook-ejb/businessData!org.mxchange.jcontactsbusiness.basicdata.BusinessDataSessionBeanRemote"); //NOI18N
310 this.adminBusinessDataBean = (AdminBusinessDataSessionBeanRemote) context.lookup("java:global/addressbook-ejb/adminBusinessData!org.mxchange.jcontactsbusiness.basicdata.AdminBusinessDataSessionBeanRemote"); //NOI18N
311 } catch (final NamingException e) {
313 throw new FaceletException(e);
316 // Init user's contact list
317 this.businessContacts = this.adminBusinessDataBean.allCompanyBasicData();