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.jfinancials.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.jcontactsbusiness.basicdata.BusinessBasicData;
29 import org.mxchange.jcontactsbusiness.basicdata.BusinessDataSessionBeanRemote;
30 import org.mxchange.jcountry.data.Country;
31 import org.mxchange.jfinancials.beans.BaseFinancialsController;
32 import org.mxchange.jfinancials.beans.user.login.FinancialsUserLoginWebSessionController;
33 import org.mxchange.jcontactsbusiness.basicdata.AdminBusinessDataSessionBeanRemote;
36 * A business contact bean (controller)
38 * @author Roland Häder<roland@mxchange.org>
40 @Named ("businessDataController")
42 public class FinancialsBusinessDataWebSessionBean extends BaseFinancialsController implements FinancialsBusinessDataWebSessionController {
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 FinancialsUserLoginWebSessionController userLoginController;
118 public FinancialsBusinessDataWebSessionBean () {
119 // Call super constructor
124 @SuppressWarnings ("ReturnOfCollectionOrArrayField")
125 public List<BusinessBasicData> allBusinessContacts () {
126 return this.businessContacts;
130 * Getter for comments
134 public String getCompanyComments () {
135 return this.companyComments;
139 * Setter for comments
141 * @param companyComments Comments
143 public void setCompanyComments (final String companyComments) {
144 this.companyComments = companyComments;
148 * Getter for company's (main) email address
150 * @return Company's (main) email address
152 public String getCompanyEmailAddress () {
153 return this.companyEmailAddress;
157 * Setter for company's (main) email address
159 * @param companyEmailAddress Company's (main) email address
161 public void setCompanyEmailAddress (final String companyEmailAddress) {
162 this.companyEmailAddress = companyEmailAddress;
166 * Getter for company name
168 * @return Company name
170 public String getCompanyName () {
171 return this.companyName;
175 * Setter for company name
177 * @param companyName Company name
179 public void setCompanyName (final String companyName) {
180 this.companyName = companyName;
184 * Getter for fax number's area code
186 * @return Fax number's area code
188 public Integer getFaxAreaCode () {
189 return this.faxAreaCode;
193 * Setter for fax number's area code
195 * @param faxAreaCode Fax number's area code
197 public void setFaxAreaCode (final Integer faxAreaCode) {
198 this.faxAreaCode = faxAreaCode;
202 * Getter for fax's country instance
204 * @return Fax' country instance
206 public Country getFaxCountry () {
207 return this.faxCountry;
211 * Setter for fax's country instance
213 * @param faxCountry Fax' country instance
215 public void setFaxCountry (final Country faxCountry) {
216 this.faxCountry = faxCountry;
220 * Getter for fax number
224 public Long getFaxNumber () {
225 return this.faxNumber;
229 * Setter for fax number
231 * @param faxNumber Fax number
233 public void setFaxNumber (final Long faxNumber) {
234 this.faxNumber = faxNumber;
238 * Getter for land-line number's area code
240 * @return Land-line number's area code
242 public Integer getLandLineAreaCode () {
243 return this.landLineAreaCode;
247 * Setter for land-line number's area code
249 * @param landLineAreaCode Land-line number's area code
251 public void setLandLineAreaCode (final Integer landLineAreaCode) {
252 this.landLineAreaCode = landLineAreaCode;
256 * Getter for land-line number's country instance
258 * @return Land-line number's country instance
260 public Country getLandLineCountry () {
261 return this.landLineCountry;
265 * Setter for land-line number's country instance
267 * @param landLineCountry Land-line number's country instance
269 public void setLandLineCountry (final Country landLineCountry) {
270 this.landLineCountry = landLineCountry;
274 * Getter for land-line number
276 * @return Land-line number
278 public Long getLandLineNumber () {
279 return this.landLineNumber;
283 * Setter for land-line number
285 * @param landLineNumber Land-line number
287 public void setLandLineNumber (final Long landLineNumber) {
288 this.landLineNumber = landLineNumber;
292 * Post-initialization of this class
295 public void init () {
298 // Get initial context
299 Context context = new InitialContext();
302 this.businessDataBean = (BusinessDataSessionBeanRemote) context.lookup("java:global/jfinancials-ejb/businessData!org.mxchange.jcontactsbusiness.basicdata.BusinessDataSessionBeanRemote"); //NOI18N
305 this.adminBusinessDataBean = (AdminBusinessDataSessionBeanRemote) context.lookup("java:global/jfinancials-ejb/adminBusinessData!org.mxchange.jcontactsbusiness.basicdata.BusinessDataAdminSessionBeanRemote"); //NOI18N
306 } catch (final NamingException e) {
308 throw new FaceletException(e);
311 // Init user's contact list
312 this.businessContacts = this.adminBusinessDataBean.allBusinessContacts();