From: Roland Haeder Date: Thu, 14 Apr 2016 13:36:04 +0000 (+0200) Subject: Continued with adding features: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=5feaa918c27e5a0225e81bb59e452b2438de2c3b;p=jjobs-war.git Continued with adding features: - merged add_user into list_user as other admin pages are constructed same way - introduced mobile selection "box" template with target controller to not have the same form all over again - added both regular and administrative controller with interface for administrative functionality for mobile providers - rewrote try-catch block: only the actual method call that throws the checked exception should be included in the try block - return actual list and not an unmodifiable version - added templates for list/edit/delete mobile providers (admin area) - listing of mobile providers should be okay now ("basicly finished") - renamed variable to make it more clear (mobile provider) - adding new mobile providers "basicly finished", still some improvements (avoid ugly exception output) may be required - added a lot new language strings + removed "add_user" from merger Signed-off-by: Roland Häder --- diff --git a/nbproject/faces-config.NavData b/nbproject/faces-config.NavData index 4fbac893..820dd593 100644 --- a/nbproject/faces-config.NavData +++ b/nbproject/faces-config.NavData @@ -2,41 +2,44 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java/org/mxchange/jjobs/beans/country/JobsAdminCountryWebApplicationBean.java b/src/java/org/mxchange/jjobs/beans/country/JobsAdminCountryWebApplicationBean.java index b54d3cb4..c6f4f684 100644 --- a/src/java/org/mxchange/jjobs/beans/country/JobsAdminCountryWebApplicationBean.java +++ b/src/java/org/mxchange/jjobs/beans/country/JobsAdminCountryWebApplicationBean.java @@ -133,19 +133,22 @@ public class JobsAdminCountryWebApplicationBean implements JobsAdminCountryWebAp throw new FaceletException(new CountryAlreadyAddedException(country)); } + // Init variable + Country updatedCountry = null; + try { // Send country to bean - Country updatedCountry = this.countryBean.addCountry(country); - - // Fire event - this.addedCountryEvent.fire(new AdminEventCountryAdded(updatedCountry)); - - // Clear bean - this.clear(); + updatedCountry = this.countryBean.addCountry(country); } catch (final CountryAlreadyAddedException ex) { // Throw again throw new FaceletException(ex); } + + // Fire event + this.addedCountryEvent.fire(new AdminEventCountryAdded(updatedCountry)); + + // Clear bean + this.clear(); } @Override diff --git a/src/java/org/mxchange/jjobs/beans/country/JobsCountryWebApplicationBean.java b/src/java/org/mxchange/jjobs/beans/country/JobsCountryWebApplicationBean.java index d52d2685..93cd4fdc 100644 --- a/src/java/org/mxchange/jjobs/beans/country/JobsCountryWebApplicationBean.java +++ b/src/java/org/mxchange/jjobs/beans/country/JobsCountryWebApplicationBean.java @@ -17,7 +17,6 @@ package org.mxchange.jjobs.beans.country; import java.text.MessageFormat; -import java.util.Collections; import java.util.List; import javax.annotation.PostConstruct; import javax.enterprise.context.ApplicationScoped; @@ -94,9 +93,10 @@ public class JobsCountryWebApplicationBean implements JobsCountryWebApplicationC } @Override + @SuppressWarnings ("ReturnOfCollectionOrArrayField") public List allCountries () { // Return "cached" version - return Collections.unmodifiableList(this.countryList); + return this.countryList; } /** diff --git a/src/java/org/mxchange/jjobs/converter/mobileprovider/JobsMobileProviderConverter.java b/src/java/org/mxchange/jjobs/converter/mobileprovider/JobsMobileProviderConverter.java index 6cebf1da..536b3cdd 100644 --- a/src/java/org/mxchange/jjobs/converter/mobileprovider/JobsMobileProviderConverter.java +++ b/src/java/org/mxchange/jjobs/converter/mobileprovider/JobsMobileProviderConverter.java @@ -46,9 +46,9 @@ public class JobsMobileProviderConverter implements Converter { private LoggerBeanLocal loggerBeanLocal; /** - * SMS provider bean + * Mobile provider bean */ - private MobileProviderSingletonBeanRemote providerController; + private MobileProviderSingletonBeanRemote mobileRemoteBean; /** * Initialization of this converter @@ -85,7 +85,7 @@ public class JobsMobileProviderConverter implements Converter { } // Get full list - List providerList = this.providerController.allMobileProvider(); + List providerList = this.mobileRemoteBean.allMobileProvider(); // Init value MobileProvider provider = null; diff --git a/src/java/org/mxchange/localization/bundle_de_DE.properties b/src/java/org/mxchange/localization/bundle_de_DE.properties index 17ae1be3..56286654 100644 --- a/src/java/org/mxchange/localization/bundle_de_DE.properties +++ b/src/java/org/mxchange/localization/bundle_de_DE.properties @@ -292,10 +292,6 @@ EN_US=English (US) CONTENT_PAGE_INDEX_PARA1=Text fuer 1. Absatz. CONTENT_PAGE_INDEX_PARA2=Text fuer 2. Absatz. CONTENT_PAGE_INDEX_PARA3=Text fuer 3. Absatz. -# @TODO Fix German umlaut! -LINK_ADMIN_ADD_USER=Benutzeraccount hinzufuegen -# @TODO Fix German umlaut! -LINK_ADMIN_ADD_USER_TITLE=Hier koennen Sie einen weiteren Benutzer hinzufuegen. LINK_ADMIN_LIST_USER=Benuzteraccounts auflisten LINK_ADMIN_LIST_USER_TITLE=Alle bestehenden Benutzeraccounts auflisten. LINK_ADMIN_EDIT_USER=Benuzteraccount editieren @@ -345,7 +341,7 @@ ADMIN_ADD_USER_EMAIL_LEGEND_TITLE=Vergeben Sie hier den Benutzernamen und geben ADMIN_ADD_USER_ENTER_USER_NAME=Benutzername (*1): ADMIN_ADD_USER_ENTER_EMAIL=Email-Adresse (*2): ADMIN_ADD_USER_USER_NAME_NOTICE=*1: Der Benutzername darf nur einmal vorhanden sein, das System prueft dies fuer Sie. -ADMIN_ADD_USER_PASSWORD_NOTICE=Das Passwort wird dem Benutzer nach Erstellung des Zugangs an die Email-Adresse gesendet. +ADMIN_ADD_USER_PASSWORD_NOTICE=Lassen Sie beide Passwortfelder leer und es wird ein Passwort per Zufall generiert. Das Passwort wird dem Benutzer nach Erstellung des Zugangs an die Email-Adresse gesendet. ADMIN_ADD_USER_EMAIL_ADDRESS_NOTICE=*2: Die Email-Adresse darf nur einmal vorhanden sein. ADMIN_ADD_USER_CUSTOMER_NUMBER_NOTICE=Eine Kundennummer wird automatisch beim Erstellen des Accounts erzeugt. #@TODO Please fix German umlauts! @@ -395,5 +391,51 @@ ADMIN_LIST_COUNTRY_DATA_COUNTRY_EXTERNAL_DIAL_PREFIX=Vorwahl ausserorts: ADMIN_LIST_COUNTRY_DATA_COUNTRY_NAME=Land: #@TODO Please fix German umlauts! ADMIN_LINK_EDIT_DELETE_COUNTRY_TITLE=Aendern oder loeschen der Laenderdaten +#@TODO Please fix German umlauts! +TABLE_SUMMARY_ADMIN_LIST_COUNTRIES=Listet alle bereits angelegten Laenderdaten auf. COUNTRY_GERMANY=Deutschland ERROR_TARGET_CONTROLLER_PARAMETER_NOT_SET=Fehler: Der Parameter 'targetController' ist nicht gesetzt. +ADMIN_MENU_MOBILE_PROVIDER_TITLE=Handyanbieter verwalten +#@TODO Please fix German umlauts! +LINK_ADMIN_LIST_MOBILE_PROVIDER_TITLE=Hinzufuegen, auflisten, aendern und loeschen von Handyanbietern. +PAGE_TITLE_ADMIN_MOBILE_PROVIDER_LIST=Handyanbieter verwalten +CONTENT_TITLE_ADMIN_MOBILE_PROVIDER_LIST=Verwalten von Handyanbietern: +#@TODO Please fix German umlauts! +PAGE_TITLE_ADMIN_MOBILE_PROVIDER_EDIT=Handyanbieter aendern +#@TODO Please fix German umlauts! +CONTENT_TITLE_ADMIN_MOBILE_PROVIDER_EDIT=Aendern des Handyanbieters: +#@TODO Please fix German umlauts! +PAGE_TITLE_ADMIN_MOBILE_PROVIDER_DELETE=Handyanbieter loeschen +#@TODO Please fix German umlauts! +CONTENT_TITLE_ADMIN_MOBILE_PROVIDER_DELETE=Loeschen des Handyanbieters: +#@TODO Please fix German umlauts! +ADMIN_ADD_MOBILE_PROVIDER_TITLE=Handyanbieter hinzufuegen +#@TODO Please fix German umlauts! +ADMIN_MOBILE_PROVIDER_MINIMUM_NOTICE=Es muessen alle Fehler ausgefuellt werden. +ADMIN_MOBILE_PROVIDER_LEGEND=Daten des Handyanbieters eingeben: +ADMIN_MOBILE_PROVIDER_LEGEND_TITLE=Geben Sie hier alle Daten des Handyanbieters ein. +LINK_ADMIN_LIST_MOBILE_PROVIDER=Verwalten ... +TABLE_SUMMARY_ADMIN_LIST_MOBILE_PROVIDERS=Listet alle bereits angelegten Handyanbieter auf. +#@TODO Please fix German umlauts! +ADMIN_ENTER_MOBILE_PROVIDER_DIAL_PREFIX=Vorwahl des Anbieters (keine fuehrende Null): +#@TODO Please fix German umlauts! +ADMIN_ENTER_MOBILE_PROVIDER_PATTERN=Regulaerer Ausdruck fuer Mails: +ADMIN_ENTER_MOBILE_PROVIDER_NAME=Name des Anbieters: +#@TODO Please fix German umlauts! +ADMIN_SELECT_MOBILE_PROVIDER_COUNTRY=Land auswaehlen: +#@TODO Please fix German umlauts! +BUTTON_ADMIN_ADD_MOBILE_PROVIDER=Handyanbieter hinzufuegen +#@TODO Please fix German umlauts! +ADMIN_ADD_MOBILE_PROVIDER_NOTICES=Hinweise zum Hinzufuegen von Handyanbietern: +#@TODO Please fix German umlauts! +ADMIN_ADD_MOBILE_PROVIDER_PATTERN=Der regulaere Ausdruck darf nur ein %s enthalten und dies muss die komplette Handynummer sein. Z.B. %s@smsmail.anbieter.example +ADMIN_ENTER_MOBILE_PROVIDER_PATTERN_EXAMPLE=(Beispiel: %s@smsmail.anbieter.example) +ADMIN_LIST_MOBILE_PRROVIDER_ID=Id-Nummer: +ADMIN_LIST_MOBILE_PRROVIDER_NAME=Name: +ADMIN_LIST_MOBILE_PRROVIDER_DIAL_PREFIX=Vorwahl: +ADMIN_LIST_MOBILE_PRROVIDER_COUNTRY=Land: +ADMIN_LIST_MOBILE_PRROVIDER_ENTRY_CREATED=Erstellt: +#@TODO Please fix German umlauts! +ADMIN_LINK_EDIT_DELETE_MOBILE_PROVIDER_TITLE=Aendern oder loeschen des Handyanbieters +ADMIN_ADD_USER_ENTER_PASSWORD1=Passwort eingeben: +ADMIN_ADD_USER_ENTER_PASSWORD2=Passwort wiederholen: diff --git a/src/java/org/mxchange/localization/bundle_en_US.properties b/src/java/org/mxchange/localization/bundle_en_US.properties index 65bff98d..94f073aa 100644 --- a/src/java/org/mxchange/localization/bundle_en_US.properties +++ b/src/java/org/mxchange/localization/bundle_en_US.properties @@ -266,8 +266,6 @@ EN_US=English (US) CONTENT_PAGE_INDEX_PARA1=Text for 1st paragraph. CONTENT_PAGE_INDEX_PARA2=Text for 2nd paragraph. CONTENT_PAGE_INDEX_PARA3=Text for 3rd paragraph. -LINK_ADMIN_ADD_USER=Add user account -LINK_ADMIN_ADD_USER_TITLE=Here you can add a new user account. LINK_ADMIN_LIST_USER=List user accounts LINK_ADMIN_LIST_USER_TITLE=List all existing user accounts. LINK_ADMIN_EDIT_USER=Edit user account @@ -306,7 +304,7 @@ ADMIN_ADD_USER_EMAIL_LEGEND_TITLE=Enter here a user name and email address. ADMIN_ADD_USER_ENTER_USER_NAME=User name (*1): ADMIN_ADD_USER_ENTER_EMAIL=Email address (*2): ADMIN_ADD_USER_USER_NAME_NOTICE=*1: The user name must be unique which is checked by the system for you. -ADMIN_ADD_USER_PASSWORD_NOTICE=The password is being sent to the user's email address after creation of the account. +ADMIN_ADD_USER_PASSWORD_NOTICE=Keep both password fields empty to create a random password. The password is being sent to the user's email address after creation of the account. ADMIN_ADD_USER_EMAIL_ADDRESS_NOTICE=*2: The email address must be unique. ADMIN_ADD_USER_CUSTOMER_NUMBER_NOTICE=A customer number is being automatically created on creation of the account. BUTTON_ADMIN_ADD_USER=Add new user account @@ -335,5 +333,36 @@ ADMIN_LIST_COUNTRY_DATA_COUNTRY_CODE=Country code: ADMIN_LIST_COUNTRY_DATA_COUNTRY_EXTERNAL_DIAL_PREFIX=Dial prefix outside: ADMIN_LIST_COUNTRY_DATA_COUNTRY_NAME=Country: ADMIN_LINK_EDIT_DELETE_COUNTRY_TITLE=Edit or delete country +TABLE_SUMMARY_ADMIN_LIST_COUNTRIES=List of all already added countries. COUNTRY_GERMANY=Germany ERROR_TARGET_CONTROLLER_PARAMETER_NOT_SET=Error: The parameter 'targetController' is not set. +ADMIN_MENU_MOBILE_PROVIDER_TITLE=Mobile providers +LINK_ADMIN_LIST_MOBILE_PROVIDER=Manage ... +LINK_ADMIN_LIST_MOBILE_PROVIDER_TITLE=Add, list, edit and delete mobile providers. +PAGE_TITLE_ADMIN_MOBILE_PROVIDER_LIST=Manage mobile providers +CONTENT_TITLE_ADMIN_MOBILE_PROVIDER_LIST=Manage mobile providers: +PAGE_TITLE_ADMIN_MOBILE_PROVIDER_EDIT=Edit mobile provider +ADMIN_ADD_MOBILE_PROVIDER_TITLE=Add mobile provider +ADMIN_MOBILE_PROVIDER_MINIMUM_NOTICE=All fields must be filled out. +ADMIN_MOBILE_PROVIDER_LEGEND=Enter data of mobile provider: +ADMIN_MOBILE_PROVIDER_LEGEND_TITLE=Here you can enter all data of the mobile provider. +CONTENT_TITLE_ADMIN_MOBILE_PROVIDER_DELETE=Delete mobile provider: +CONTENT_TITLE_ADMIN_MOBILE_PROVIDER_EDIT=Edit mobile provider: +PAGE_TITLE_ADMIN_MOBILE_PROVIDER_DELETE=Delete mobile provider +TABLE_SUMMARY_ADMIN_LIST_MOBILE_PROVIDERS=Lists all already added mobile providers. +ADMIN_ENTER_MOBILE_PROVIDER_DIAL_PREFIX=Dial prefix of provider (no leading zero): +ADMIN_ENTER_MOBILE_PROVIDER_PATTERN=Pattern for mails: +ADMIN_ENTER_MOBILE_PROVIDER_NAME=Name of provider: +ADMIN_SELECT_MOBILE_PROVIDER_COUNTRY=Choose country: +BUTTON_ADMIN_ADD_MOBILE_PROVIDER=Add mobile provider +ADMIN_ADD_MOBILE_PROVIDER_NOTICES=Notices for adding mobile provider: +ADMIN_ADD_MOBILE_PROVIDER_PATTERN=The pattern should only contain one %s which must be the full mobile number. Example: %s@smsmail.provider.example +ADMIN_ENTER_MOBILE_PROVIDER_PATTERN_EXAMPLE=(Example: %s@smsmail.provider.example) +ADMIN_LIST_MOBILE_PRROVIDER_ID=Id number: +ADMIN_LIST_MOBILE_PRROVIDER_NAME=Name: +ADMIN_LIST_MOBILE_PRROVIDER_DIAL_PREFIX=Dial prefix: +ADMIN_LIST_MOBILE_PRROVIDER_COUNTRY=Country: +ADMIN_LIST_MOBILE_PRROVIDER_ENTRY_CREATED=Created: +ADMIN_LINK_EDIT_DELETE_MOBILE_PROVIDER_TITLE=Edit or delete mobile provider +ADMIN_ADD_USER_ENTER_PASSWORD1=Enter password: +ADMIN_ADD_USER_ENTER_PASSWORD2=Repeat password: diff --git a/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaAdminMobileProviderWebRequestBean.java b/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaAdminMobileProviderWebRequestBean.java new file mode 100644 index 00000000..02aae750 --- /dev/null +++ b/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaAdminMobileProviderWebRequestBean.java @@ -0,0 +1,233 @@ +/* + * Copyright (C) 2016 Roland Haeder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package org.mxchange.pizzaapplication.beans.mobileprovider; + +import java.util.Iterator; +import java.util.List; +import java.util.Objects; +import javax.enterprise.context.RequestScoped; +import javax.enterprise.event.Event; +import javax.enterprise.inject.Any; +import javax.faces.view.facelets.FaceletException; +import javax.inject.Inject; +import javax.inject.Named; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import org.mxchange.jcountry.data.Country; +import org.mxchange.jphone.events.AdminAddedMobileProviderEvent; +import org.mxchange.jphone.events.AdminMobileProviderAddedEvent; +import org.mxchange.jphone.exceptions.MobileProviderAlreadyAddedException; +import org.mxchange.jphone.phonenumbers.mobileprovider.AdminMobileProviderSingletonBeanRemote; +import org.mxchange.jphone.phonenumbers.mobileprovider.CellphoneProvider; +import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider; + +/** + * Administrative bean (controller) for mobile provider + *

+ * @author Roland Haeder + */ +@Named ("adminMobileController") +@RequestScoped +public class PizzaAdminMobileProviderWebRequestBean implements PizzaAdminMobileProviderWebRequestController { + + /** + * Serial number + */ + private static final long serialVersionUID = 184_598_175_371_269_016L; + + /** + * Remote EJB for mobile providers (administrative) + */ + private AdminMobileProviderSingletonBeanRemote adminRemoteBean; + + /** + * Regular bean + */ + @Inject + private PizzaMobileProviderWebRequestController mobileController; + + /** + * Event being fired when the mobile provider was added + */ + @Inject + @Any + private Event providerAddedEvent; + + /** + * Country instance ('s dial data) + */ + private Country providerCountry; + + /** + * Provider dial prefix (example: 0177 for German E+) + */ + private Long providerDialPrefix; + + /** + * Pattern for mail gateway + */ + private String providerMailPattern; + + /** + * Name of the provider + */ + private String providerName; + + /** + * Default constructor + */ + public PizzaAdminMobileProviderWebRequestBean () { + // Try it + try { + // Get initial context + Context context = new InitialContext(); + + // Try to lookup the beans + this.adminRemoteBean = (AdminMobileProviderSingletonBeanRemote) context.lookup("java:global/PizzaService-ejb/adminmobileprovider!org.mxchange.jphone.phonenumbers.mobileprovider.AdminMobileProviderSingletonBeanRemote"); //NOI18N + } catch (final NamingException e) { + // Throw it again + throw new FaceletException(e); + } + } + + @Override + public void addMobileProvider () { + // Create mobile provider instance + MobileProvider mobileProvider = new CellphoneProvider(this.getProviderDialPrefix(), this.getProviderName(), this.getProviderCountry(), this.getProviderMailPattern()); + + // Is the provider already created? + if (this.isMobileProviderCreated(mobileProvider)) { + // Then throw exception + throw new FaceletException(new MobileProviderAlreadyAddedException(mobileProvider)); + } + + // Init variable + MobileProvider updatedProvider = null; + + try { + // Call remote EJB and get back an updated instance + updatedProvider = this.adminRemoteBean.addMobileProvider(mobileProvider); + } catch (final MobileProviderAlreadyAddedException ex) { + // Throw again + throw new FaceletException(ex); + } + + // Fire event + this.providerAddedEvent.fire(new AdminMobileProviderAddedEvent(updatedProvider)); + + // Clear this bean + this.clear(); + } + + @Override + public List allMobileProvider () { + return this.mobileController.allMobileProvider(); + } + + @Override + public Country getProviderCountry () { + return this.providerCountry; + } + + @Override + public void setProviderCountry (final Country providerCountry) { + this.providerCountry = providerCountry; + } + + @Override + public Long getProviderDialPrefix () { + return this.providerDialPrefix; + } + + @Override + public void setProviderDialPrefix (final Long providerDialPrefix) { + this.providerDialPrefix = providerDialPrefix; + } + + @Override + public String getProviderMailPattern () { + return this.providerMailPattern; + } + + @Override + public void setProviderMailPattern (final String providerMailPattern) { + this.providerMailPattern = providerMailPattern; + } + + @Override + public String getProviderName () { + return this.providerName; + } + + @Override + public void setProviderName (final String providerName) { + this.providerName = providerName; + } + + @Override + public boolean hasMobileProvider () { + return (!this.allMobileProvider().isEmpty()); + } + + /** + * Clears this bean + */ + private void clear () { + // Clear all fields + this.setProviderCountry(null); + this.setProviderDialPrefix(null); + this.setProviderMailPattern(null); + this.setProviderName(null); + } + + /** + * Checks whether if the given mobile provider is already created by + * checking both dial prefix and country. + *

+ * @param mobileProvider Mobile provider instance to check + *

+ * @return Whether the given mobile provider instance is found + */ + private boolean isMobileProviderCreated (final MobileProvider mobileProvider) { + // Default is not found + boolean isFound = false; + + // Get list of all providers + List providers = this.allMobileProvider(); + + // Get iterator from it + Iterator iterator = providers.iterator(); + + // Loop through all + while (iterator.hasNext()) { + // Get next element + MobileProvider next = iterator.next(); + + // Is the provider's dial prefix and country the same? + if ((Objects.equals(mobileProvider.getProviderDialPrefix(), next.getProviderDialPrefix())) && (Objects.equals(mobileProvider.getProviderCountry(), next.getProviderCountry()))) { + // Is the same, abort loop + isFound = true; + break; + } + } + + // Return result + return isFound; + } + +} diff --git a/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaAdminMobileProviderWebRequestController.java b/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaAdminMobileProviderWebRequestController.java new file mode 100644 index 00000000..558de55b --- /dev/null +++ b/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaAdminMobileProviderWebRequestController.java @@ -0,0 +1,109 @@ +/* + * Copyright (C) 2016 Roland Haeder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package org.mxchange.pizzaapplication.beans.mobileprovider; + +import java.io.Serializable; +import java.util.List; +import org.mxchange.jcountry.data.Country; +import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider; + +/** + * An interface for a request web controller (bean) for administrative mobile + * provider purposes. + *

+ * @author Roland Haeder + */ +public interface PizzaAdminMobileProviderWebRequestController extends Serializable { + + /** + * Adds a mobile provider to database by calling the EJB. A pre-check on + * dial-prefix and country combination is done, if found, an exception is + * thrown. + */ + void addMobileProvider (); + + /** + * Returns a list of all mobile providers + *

+ * @return A list of all mobile providers + */ + List allMobileProvider (); + + /** + * Checks whether mobile providers are registered + *

+ * @return Whether mobile providers are registered + */ + boolean hasMobileProvider (); + + /** + * Getter for provider dial prefix + *

+ * @return Provider dial prefix + */ + Long getProviderDialPrefix (); + + /** + * Setter for provider dial prefix + *

+ * @param providerDialPrefix Provider dial prefix + */ + void setProviderDialPrefix (final Long providerDialPrefix); + + /** + * Getter for provider name + *

+ * @return Provider name + */ + String getProviderName (); + + /** + * Setter for provider name + *

+ * @param providerName Provider name + */ + void setProviderName (final String providerName); + + /** + * Getter for country instance ('s dial data) + *

+ * @return Country instance + */ + Country getProviderCountry (); + + /** + * Setter for country instance ('s dial data) + *

+ * @param country Country instance + */ + void setProviderCountry (final Country country); + + /** + * Getter for pattern for mail gateway + *

+ * @return Pattern for mail gateway + */ + String getProviderMailPattern (); + + /** + * Setter for pattern for mail gateway + *

+ * @param providerMailRegex Pattern for mail gateway + */ + void setProviderMailPattern (final String providerMailRegex); + +} diff --git a/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaMobileProviderWebRequestBean.java b/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaMobileProviderWebRequestBean.java new file mode 100644 index 00000000..32656b23 --- /dev/null +++ b/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaMobileProviderWebRequestBean.java @@ -0,0 +1,110 @@ +/* + * Copyright (C) 2016 Roland Haeder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package org.mxchange.pizzaapplication.beans.mobileprovider; + +import java.text.MessageFormat; +import java.util.List; +import javax.annotation.PostConstruct; +import javax.enterprise.context.SessionScoped; +import javax.enterprise.event.Observes; +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.events.AdminAddedMobileProviderEvent; +import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider; +import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProviderSingletonBeanRemote; + +/** + * A general bean for mobile providers + *

+ * @author Roland Haeder + */ +@Named ("mobileController") +@SessionScoped +public class PizzaMobileProviderWebRequestBean implements PizzaMobileProviderWebRequestController { + + /** + * Serial number + */ + private static final long serialVersionUID = 15_869_423_671_950_276L; + + /** + * "Cached" list of mobile providers + */ + private List mobileProviders; + + /** + * Remote EJB for mobile providers (regular) + */ + private MobileProviderSingletonBeanRemote mobileRemoteBean; + + /** + * Default constructor + */ + public PizzaMobileProviderWebRequestBean () { + // Try it + try { + // Get initial context + Context context = new InitialContext(); + + // Try to lookup the beans + this.mobileRemoteBean = (MobileProviderSingletonBeanRemote) context.lookup("java:global/PizzaService-ejb/mobileprovider!org.mxchange.jphone.phonenumbers.mobileprovider.MobileProviderSingletonBeanRemote"); //NOI18N + } catch (final NamingException e) { + // Throw it again + throw new FaceletException(e); + } + } + + @Override + public void afterAdminAddedMobileProvider (@Observes final AdminAddedMobileProviderEvent event) { + // Is all valid? + if (null == event) { + // Throw NPE + throw new NullPointerException("event is null"); //NOI18N + } else if (event.getAddedMobileProvider()== null) { + // Throw again ... + throw new NullPointerException("event.addedMobileProvider is null"); //NOI18N + } else if (event.getAddedMobileProvider().getProviderId()== null) { + // And again ... + throw new NullPointerException("event.addedMobileProvider.providerId is null"); //NOI18N + } else if (event.getAddedMobileProvider().getProviderId() < 1) { + // Id is invalid + throw new IllegalArgumentException(MessageFormat.format("event.addedMobileProvider.providerId={0} is not valid.", event.getAddedMobileProvider().getProviderId())); //NOI18N + } + + // Add it to the list + this.mobileProviders.add(event.getAddedMobileProvider()); + } + + @Override + @SuppressWarnings ("ReturnOfCollectionOrArrayField") + public List allMobileProvider () { + return this.mobileProviders; + } + + /** + * Initializer method + */ + @PostConstruct + public void init () { + // Init list of mobile providers + this.mobileProviders = this.mobileRemoteBean.allMobileProvider(); + } + +} diff --git a/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaMobileProviderWebRequestController.java b/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaMobileProviderWebRequestController.java new file mode 100644 index 00000000..ba780e5c --- /dev/null +++ b/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaMobileProviderWebRequestController.java @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2016 Roland Haeder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package org.mxchange.pizzaapplication.beans.mobileprovider; + +import java.io.Serializable; +import java.util.List; +import org.mxchange.jphone.events.AdminAddedMobileProviderEvent; +import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider; + +/** + * An interface for general mobile provider controller + *

+ * @author Roland Haeder + */ +public interface PizzaMobileProviderWebRequestController extends Serializable { + + /** + * Returns a list of all mobile providers + *

+ * @return A list of all mobile providers + */ + List allMobileProvider (); + + /** + * Observes events being fired after the administrator has added a new + * mobile provider + *

+ * @param event Event being fired + */ + void afterAdminAddedMobileProvider (final AdminAddedMobileProviderEvent event); + +} diff --git a/web/WEB-INF/faces-config.xml b/web/WEB-INF/faces-config.xml index e01330bf..423709c8 100644 --- a/web/WEB-INF/faces-config.xml +++ b/web/WEB-INF/faces-config.xml @@ -134,14 +134,14 @@ admin_unlock_user /admin/admin_user_unlock.xhtml - - admin_add_user - /admin/admin_user_add.xhtml - admin_list_countries /admin/admin_country_list.xhtml + + admin_list_mobile_provider + /admin/admin_mobile_provider_list.xhtml + /user/register.xhtml @@ -222,4 +222,11 @@ //--> + + /admin/admin_mobile_provider_list.xhtml + + admin_edit_mobile_provider + /admin/admin_mobile_provider_edit.xhtml + + diff --git a/web/WEB-INF/templates/admin/admin_form_mobile_provider.tpl b/web/WEB-INF/templates/admin/admin_form_mobile_provider.tpl new file mode 100644 index 00000000..7d2232c3 --- /dev/null +++ b/web/WEB-INF/templates/admin/admin_form_mobile_provider.tpl @@ -0,0 +1,71 @@ + + + +

+ #{msg.ADMIN_MOBILE_PROVIDER_MINIMUM_NOTICE} +
+ +
+
+ #{msg.ADMIN_MOBILE_PROVIDER_LEGEND} + +
+
+ +
+ +
+ + + +
+ +
+
+ +
+
+ +
+ +
+ + + +
+ +
+
+ +
+
+ +
+ +
+ +
+ +
+
+ +
+
+ +
+ +
+ + + +
+ +
+
+
+
+ diff --git a/web/WEB-INF/templates/admin/admin_form_personal_data.tpl b/web/WEB-INF/templates/admin/admin_form_personal_data.tpl index 3f98abad..87d709e3 100644 --- a/web/WEB-INF/templates/admin/admin_form_personal_data.tpl +++ b/web/WEB-INF/templates/admin/admin_form_personal_data.tpl @@ -174,14 +174,9 @@
- - - - - - - - + + +
@@ -219,6 +214,30 @@
+
+
+ +
+ +
+ +
+ +
+
+ +
+
+ +
+ +
+ +
+ +
+
+
  • #{msg.ADMIN_ADD_USER_USER_NAME_NOTICE}
  • diff --git a/web/WEB-INF/templates/admin/admin_menu.tpl b/web/WEB-INF/templates/admin/admin_menu.tpl index 0463ea64..60095a66 100644 --- a/web/WEB-INF/templates/admin/admin_menu.tpl +++ b/web/WEB-INF/templates/admin/admin_menu.tpl @@ -19,7 +19,6 @@
    -
  • @@ -34,6 +33,14 @@
+ + +
    +
  • +
+ diff --git a/web/WEB-INF/templates/generic/form_personal_data.tpl b/web/WEB-INF/templates/generic/form_personal_data.tpl index f5f1fcdc..8771740a 100644 --- a/web/WEB-INF/templates/generic/form_personal_data.tpl +++ b/web/WEB-INF/templates/generic/form_personal_data.tpl @@ -178,14 +178,9 @@
- - - - - - - - + + +
diff --git a/web/WEB-INF/templates/generic/mobile_selection_box.tpl b/web/WEB-INF/templates/generic/mobile_selection_box.tpl new file mode 100644 index 00000000..38521303 --- /dev/null +++ b/web/WEB-INF/templates/generic/mobile_selection_box.tpl @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + diff --git a/web/admin/admin_mobile_provider_delete.xhtml b/web/admin/admin_mobile_provider_delete.xhtml new file mode 100644 index 00000000..25ac615e --- /dev/null +++ b/web/admin/admin_mobile_provider_delete.xhtml @@ -0,0 +1,20 @@ + + + + + + #{msg.PAGE_TITLE_ADMIN_MOBILE_PROVIDER_DELETE} + + + #{msg.CONTENT_TITLE_ADMIN_MOBILE_PROVIDER_DELETE} + + + + Here goes your content. + + + diff --git a/web/admin/admin_mobile_provider_edit.xhtml b/web/admin/admin_mobile_provider_edit.xhtml new file mode 100644 index 00000000..f7c36586 --- /dev/null +++ b/web/admin/admin_mobile_provider_edit.xhtml @@ -0,0 +1,20 @@ + + + + + + #{msg.PAGE_TITLE_ADMIN_MOBILE_PROVIDER_EDIT} + + + #{msg.CONTENT_TITLE_ADMIN_MOBILE_PROVIDER_EDIT} + + + + Here goes your content. + + + diff --git a/web/admin/admin_mobile_provider_list.xhtml b/web/admin/admin_mobile_provider_list.xhtml new file mode 100644 index 00000000..214e5f4d --- /dev/null +++ b/web/admin/admin_mobile_provider_list.xhtml @@ -0,0 +1,76 @@ + + + + + + #{msg.PAGE_TITLE_ADMIN_MOBILE_PROVIDER_LIST} + + + #{msg.CONTENT_TITLE_ADMIN_MOBILE_PROVIDER_LIST} + + + + + + #{msg.ADMIN_LIST_MOBILE_PRROVIDER_ID} + + + + + + + + #{msg.ADMIN_LIST_MOBILE_PRROVIDER_NAME} + + + + + + #{msg.ADMIN_LIST_MOBILE_PRROVIDER_DIAL_PREFIX} + + + + + + #{msg.ADMIN_LIST_MOBILE_PRROVIDER_COUNTRY} + + + + + + #{msg.ADMIN_LIST_MOBILE_PRROVIDER_ENTRY_CREATED} + + + + + + + + +
+
+ #{msg.ADMIN_ADD_MOBILE_PROVIDER_TITLE} +
+ + + + +
+ +
+ #{msg.ADMIN_ADD_MOBILE_PROVIDER_NOTICES} +
    +
  • #{msg.ADMIN_ADD_MOBILE_PROVIDER_PATTERN}
  • +
+
+
+
+
+