From: Roland Haeder Date: Mon, 12 Oct 2015 09:07:04 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=029b70a8f8e8b10ef3b0ceb7765e03fc191273d2;p=jfinancials-war.git Continued: - added bean (controller) for SMS provider data retrieval - expanded phone, fax and cellphone form fields so they better fit for ongoing rewrite - updated jars Signed-off-by:Roland Häder --- diff --git a/lib/jcoreee.jar b/lib/jcoreee.jar index 7b88b148..093433c9 100644 Binary files a/lib/jcoreee.jar and b/lib/jcoreee.jar differ diff --git a/lib/jphone-core.jar b/lib/jphone-core.jar index 0cc0e98f..f7da496b 100644 Binary files a/lib/jphone-core.jar and b/lib/jphone-core.jar differ diff --git a/nbproject/faces-config.NavData b/nbproject/faces-config.NavData index a28edad9..f1818296 100644 --- a/nbproject/faces-config.NavData +++ b/nbproject/faces-config.NavData @@ -1,55 +1,55 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java/org/mxchange/addressbook/beans/smsprovider/SmsProviderWebBean.java b/src/java/org/mxchange/addressbook/beans/smsprovider/SmsProviderWebBean.java new file mode 100644 index 00000000..667fe020 --- /dev/null +++ b/src/java/org/mxchange/addressbook/beans/smsprovider/SmsProviderWebBean.java @@ -0,0 +1,82 @@ +package org.mxchange.addressbook.beans.smsprovider; + +/* + * Copyright (C) 2015 Roland Haeder + * + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later + * version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ +import java.util.Collections; +import java.util.List; +import javax.annotation.PostConstruct; +import javax.enterprise.context.ApplicationScoped; +import javax.faces.view.facelets.FaceletException; +import javax.inject.Named; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import org.mxchange.jphone.phonenumbers.smsprovider.AddressbookSmsProviderSingletonBeanRemote; +import org.mxchange.jphone.phonenumbers.smsprovider.SmsProvider; + +/** + * A country bean + *

+ * @author Roland Haeder + */ +@Named ("cellphone") +@ApplicationScoped +public class SmsProviderWebBean implements SmsProviderWebController { + + /** + * Serial number + */ + private static final long serialVersionUID = 176_985_298_681_742_960L; + + /** + * Remote country EJB + */ + private final AddressbookSmsProviderSingletonBeanRemote cellphoneBean; + + /** + * List of all countries + */ + private List cellphoneList; + + /** + * Default constructor + */ + public SmsProviderWebBean () { + // Try this + try { + // Get initial context + Context context = new InitialContext(); + + // Try to lookup the bean + this.cellphoneBean = (AddressbookSmsProviderSingletonBeanRemote) context.lookup("ejb/addressbook-singleton-smsprovider"); //NOI18N + } catch (final NamingException ex) { + // Continue to throw + throw new FaceletException(ex); + } + } + + @Override + public List allSmsProvider () { + // Return "cached" version + return Collections.unmodifiableList(this.cellphoneList); + } + + @PostConstruct + public void init () { + this.cellphoneList = this.cellphoneBean.allSmsProvider(); + } +} diff --git a/src/java/org/mxchange/addressbook/beans/smsprovider/SmsProviderWebController.java b/src/java/org/mxchange/addressbook/beans/smsprovider/SmsProviderWebController.java new file mode 100644 index 00000000..707185d7 --- /dev/null +++ b/src/java/org/mxchange/addressbook/beans/smsprovider/SmsProviderWebController.java @@ -0,0 +1,36 @@ +package org.mxchange.addressbook.beans.smsprovider; + +/* + * Copyright (C) 2015 Roland Haeder + * + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later + * version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ +import java.io.Serializable; +import java.util.List; +import org.mxchange.jphone.phonenumbers.smsprovider.SmsProvider; + +/** + * An interface for country beans + *

+ * @author Roland Haeder + */ +public interface SmsProviderWebController extends Serializable { + + /** + * A list of all countries + *

+ * @return All countries + */ + public List allSmsProvider (); +} diff --git a/src/java/org/mxchange/addressbook/beans/user/UserWebBean.java b/src/java/org/mxchange/addressbook/beans/user/UserWebBean.java index 3bc0d362..f861daab 100644 --- a/src/java/org/mxchange/addressbook/beans/user/UserWebBean.java +++ b/src/java/org/mxchange/addressbook/beans/user/UserWebBean.java @@ -32,9 +32,13 @@ import org.mxchange.jcontacts.contact.Contact; import org.mxchange.jcontacts.contact.UserContact; import org.mxchange.jcontacts.contact.gender.Gender; import org.mxchange.jcountry.data.Country; +import org.mxchange.jphone.phonenumbers.cellphone.CellphoneNumber; import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber; import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber; +import org.mxchange.jphone.phonenumbers.fax.FaxNumber; import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber; +import org.mxchange.jphone.phonenumbers.landline.LandLineNumber; +import org.mxchange.jphone.phonenumbers.smsprovider.SmsProvider; import org.mxchange.jusercore.model.user.LoginUser; import org.mxchange.jusercore.model.user.User; import org.mxchange.jusercore.model.user.UserSessionBeanRemote; @@ -59,10 +63,15 @@ public class UserWebBean implements UserWebController { */ private Date birthday; + /** + * Cellphone number's carrier + */ + private SmsProvider cellphoneCarrier; + /** * Cellphone number */ - private DialableCellphoneNumber cellphoneNumber; + private Long cellphoneNumber; /** * City @@ -99,10 +108,20 @@ public class UserWebBean implements UserWebController { */ private String familyName; + /** + * Fax number's area code + */ + private Integer faxAreaCode; + + /** + * Country instance for fax number + */ + private Country faxCountry; + /** * Fax number */ - private DialableFaxNumber faxNumber; + private Long faxNumber; /** * First name @@ -119,10 +138,20 @@ public class UserWebBean implements UserWebController { */ private Short houseNumber; + /** + * Phone number area code + */ + private Integer phoneAreaCode; + + /** + * Country instance for phone number + */ + private Country phoneCountry; + /** * Phone number */ - private DialableLandLineNumber phoneNumber; + private Long phoneNumber; /** * Street @@ -219,9 +248,9 @@ public class UserWebBean implements UserWebController { // - contact data this.setEmailAddress(null); this.setEmailAddressRepeat(null); - this.setPhoneNumber(null); - this.setCellphoneNumber(null); - this.setFaxNumber(null); + this.setPhoneAreaCode(null); + this.setCellphoneCarrier(null); + this.setFaxAreaCode(null); // - other data this.setBirthday(null); @@ -245,10 +274,26 @@ public class UserWebBean implements UserWebController { this.setCity(user.getUserContact().getCity()); this.setCountry(user.getUserContact().getCountry()); + // Get cellphone, phone and fax instance + DialableCellphoneNumber cellphone = user.getUserContact().getCellphoneNumber(); + DialableFaxNumber fax = user.getUserContact().getFaxNumber(); + DialableLandLineNumber phone = user.getUserContact().getPhoneNumber(); + // - contact data - this.setPhoneNumber(user.getUserContact().getPhoneNumber()); - this.setCellphoneNumber(user.getUserContact().getCellphoneNumber()); - this.setFaxNumber(user.getUserContact().getFaxNumber()); + if (phone instanceof DialableLandLineNumber) { + this.setPhoneCountry(phone.getPhoneCountry()); + this.setPhoneAreaCode(phone.getPhoneAreaCode()); + this.setPhoneNumber(phone.getPhoneNumber()); + } + if (cellphone instanceof DialableCellphoneNumber) { + this.setCellphoneCarrier(cellphone.getCellphoneProvider()); + this.setCellphoneNumber(cellphone.getPhoneNumber()); + } + if (fax instanceof DialableFaxNumber) { + this.setFaxCountry(fax.getPhoneCountry()); + this.setFaxAreaCode(fax.getPhoneAreaCode()); + this.setFaxNumber(fax.getPhoneNumber()); + } this.setEmailAddress(user.getUserContact().getEmailAddress()); // -- other data @@ -268,6 +313,11 @@ public class UserWebBean implements UserWebController { User user = new LoginUser(); user.setUserName(this.getUserName()); + // Generate phone number + DialableLandLineNumber phone = new LandLineNumber(this.getPhoneCountry(), this.getPhoneAreaCode(), this.getPhoneNumber()); + DialableCellphoneNumber cellphone = new CellphoneNumber(this.getCellphoneCarrier(), this.getCellphoneNumber()); + DialableFaxNumber fax = new FaxNumber(this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber()); + // Create new contact Contact contact = new UserContact(this.getGender(), this.getFirstName(), this.getFamilyName()); contact.setStreet(this.getStreet()); @@ -276,9 +326,9 @@ public class UserWebBean implements UserWebController { contact.setCity(this.getCity()); contact.setCountry(this.getCountry()); contact.setEmailAddress(this.getEmailAddress()); - contact.setPhoneNumber(this.getPhoneNumber()); - contact.setFaxNumber(this.getFaxNumber()); - contact.setCellphoneNumber(this.getCellphoneNumber()); + contact.setPhoneNumber(phone); + contact.setFaxNumber(fax); + contact.setCellphoneNumber(cellphone); contact.setBirthday(this.getBirthday()); contact.setComment(this.getComment()); @@ -307,12 +357,22 @@ public class UserWebBean implements UserWebController { } @Override - public DialableCellphoneNumber getCellphoneNumber () { + public SmsProvider getCellphoneCarrier () { + return this.cellphoneCarrier; + } + + @Override + public void setCellphoneCarrier (final SmsProvider cellphoneCarrier) { + this.cellphoneCarrier = cellphoneCarrier; + } + + @Override + public Long getCellphoneNumber () { return this.cellphoneNumber; } @Override - public void setCellphoneNumber (final DialableCellphoneNumber cellphoneNumber) { + public void setCellphoneNumber (Long cellphoneNumber) { this.cellphoneNumber = cellphoneNumber; } @@ -377,12 +437,32 @@ public class UserWebBean implements UserWebController { } @Override - public DialableFaxNumber getFaxNumber () { + public Integer getFaxAreaCode () { + return this.faxAreaCode; + } + + @Override + public void setFaxAreaCode (final Integer faxAreaCode) { + this.faxAreaCode = faxAreaCode; + } + + @Override + public Country getFaxCountry () { + return this.faxCountry; + } + + @Override + public void setFaxCountry (final Country faxCountry) { + this.faxCountry = faxCountry; + } + + @Override + public Long getFaxNumber () { return this.faxNumber; } @Override - public void setFaxNumber (final DialableFaxNumber faxNumber) { + public void setFaxNumber (final Long faxNumber) { this.faxNumber = faxNumber; } @@ -417,12 +497,32 @@ public class UserWebBean implements UserWebController { } @Override - public DialableLandLineNumber getPhoneNumber () { + public Integer getPhoneAreaCode () { + return this.phoneAreaCode; + } + + @Override + public void setPhoneAreaCode (final Integer phoneAreaCode) { + this.phoneAreaCode = phoneAreaCode; + } + + @Override + public Country getPhoneCountry () { + return this.phoneCountry; + } + + @Override + public void setPhoneCountry (final Country phoneCountry) { + this.phoneCountry = phoneCountry; + } + + @Override + public Long getPhoneNumber () { return this.phoneNumber; } @Override - public void setPhoneNumber (final DialableLandLineNumber phoneNumber) { + public void setPhoneNumber (final Long phoneNumber) { this.phoneNumber = phoneNumber; } @@ -502,18 +602,18 @@ public class UserWebBean implements UserWebController { @Override public boolean isRequiredPersonalDataSet () { - return ((this.getUserName() != null) && - (this.getGender() != null) && - (this.getFirstName() != null) && - (this.getFamilyName() != null) && - (this.getStreet() != null) && - (this.getHouseNumber() != null) && - (this.getZipCode() != null) && - (this.getCity() != null) && - (this.getEmailAddress() != null) && - (this.getEmailAddressRepeat() != null) && - (this.getUserPassword() != null) && - (this.getUserPasswordRepeat() != null)); + return ((this.getUserName() != null) + && (this.getGender() != null) + && (this.getFirstName() != null) + && (this.getFamilyName() != null) + && (this.getStreet() != null) + && (this.getHouseNumber() != null) + && (this.getZipCode() != null) + && (this.getCity() != null) + && (this.getEmailAddress() != null) + && (this.getEmailAddressRepeat() != null) + && (this.getUserPassword() != null) + && (this.getUserPasswordRepeat() != null)); } @Override diff --git a/src/java/org/mxchange/addressbook/beans/user/UserWebController.java b/src/java/org/mxchange/addressbook/beans/user/UserWebController.java index ac76a10a..2d88e45e 100644 --- a/src/java/org/mxchange/addressbook/beans/user/UserWebController.java +++ b/src/java/org/mxchange/addressbook/beans/user/UserWebController.java @@ -20,9 +20,7 @@ import java.io.Serializable; import java.util.Date; import org.mxchange.jcontacts.contact.gender.Gender; import org.mxchange.jcountry.data.Country; -import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber; -import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber; -import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber; +import org.mxchange.jphone.phonenumbers.smsprovider.SmsProvider; import org.mxchange.jusercore.model.user.User; /** @@ -73,18 +71,32 @@ public interface UserWebController extends Serializable { public void setBirthday (final Date birthday); /** - * Cellphone number + * Getter for ellphone number's carrier *

- * @return the cellphoneNumber + * @return Cellphone number's carrier */ - public DialableCellphoneNumber getCellphoneNumber (); + public SmsProvider getCellphoneCarrier (); /** - * Cellphone number + * Setter for cellphone number's carrier prefix *

- * @param cellphoneNumber the cellphoneNumber to set + * @param cellphoneCarrier Cellphone number's carrier prefix */ - public void setCellphoneNumber (final DialableCellphoneNumber cellphoneNumber); + public void setCellphoneCarrier (final SmsProvider cellphoneCarrier); + + /** + * Getter for ellphone number + *

+ * @return Cellphone number + */ + public Long getCellphoneNumber (); + + /** + * Setter for ellphone number + *

+ * @param cellphoneNumber Cellphone number + */ + public void setCellphoneNumber (final Long cellphoneNumber); /** * City @@ -171,18 +183,46 @@ public interface UserWebController extends Serializable { public void setFamilyName (final String familyName); /** - * Fax number + * Getter for fax number's area code + *

+ * @return Fax number's area code + */ + public Integer getFaxAreaCode (); + + /** + * Setter for fax number's area code + *

+ * @param faxAreaCode Fax number's area code + */ + public void setFaxAreaCode (final Integer faxAreaCode); + + /** + * Getter for fax's country instance + *

+ * @return Fax' country instance + */ + public Country getFaxCountry (); + + /** + * Setter for fax's country instance *

- * @return the faxNumber + * @param faxCountry Fax' country instance */ - public DialableFaxNumber getFaxNumber (); + public void setFaxCountry (final Country faxCountry); /** - * Fax number + * Getter for fax number *

- * @param faxNumber the faxNumber to set + * @return Fax number */ - public void setFaxNumber (final DialableFaxNumber faxNumber); + public Long getFaxNumber (); + + /** + * Setter for fax number + *

+ * @param faxNumber Fax number + */ + public void setFaxNumber (final Long faxNumber); /** * First name @@ -227,18 +267,46 @@ public interface UserWebController extends Serializable { public void setHouseNumber (final Short houseNumber); /** - * Phone number + * Getter for phone number's area code + *

+ * @return Phone number's area code + */ + public Integer getPhoneAreaCode (); + + /** + * Setter for phone number's area code + *

+ * @param phoneAreaCode Phone number's area code + */ + public void setPhoneAreaCode (final Integer phoneAreaCode); + + /** + * Getter for phone number's country instance + *

+ * @return Phone number's country instance + */ + public Country getPhoneCountry (); + + /** + * Setter for phone number's country instance + *

+ * @param phoneCountry Phone number's country instance + */ + public void setPhoneCountry (final Country phoneCountry); + + /** + * Getter for phone number *

- * @return the phoneNumber + * @return Phone number */ - public DialableLandLineNumber getPhoneNumber (); + public Long getPhoneNumber (); /** - * Phone number + * Setter for phone number *

- * @param phoneNumber the phoneNumber to set + * @param phoneNumber Phone number */ - public void setPhoneNumber (final DialableLandLineNumber phoneNumber); + public void setPhoneNumber (final Long phoneNumber); /** * Street diff --git a/web/WEB-INF/templates/generic/form_personal_data.tpl b/web/WEB-INF/templates/generic/form_personal_data.tpl index 64dd2200..8dd416e1 100644 --- a/web/WEB-INF/templates/generic/form_personal_data.tpl +++ b/web/WEB-INF/templates/generic/form_personal_data.tpl @@ -123,11 +123,21 @@

- +
- + + + + + + + + + + +
@@ -139,7 +149,17 @@
- + + + + + + + + + + +
@@ -151,7 +171,13 @@
- + + + + + + +