From: Roland Häder Date: Sat, 6 Aug 2016 10:26:59 +0000 (+0200) Subject: Continued with rewrites: (please cherry-pick) X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=88faad8ed4af73343e47ffd82317e0a983168198;p=pizzaservice-war.git Continued with rewrites: (please cherry-pick) - the contact phone controller becomes a generic phone controller (see jcontacts-business-core) - marked contact-related stuff in it as deprecated - renamed it's JSF name to adminPhoneController - all phone instances are being set by beanHelper's copyUserToController() method - private method setPhoneInstances() introduced - rewrote all parameters that cannot be auto-completed by IDE to beanHelper and phone controller - added missing i18n string(s) Signed-off-by: Roland Häder --- diff --git a/src/java/org/mxchange/localization/bundle_de_DE.properties b/src/java/org/mxchange/localization/bundle_de_DE.properties index d752f589..d9c36f5f 100644 --- a/src/java/org/mxchange/localization/bundle_de_DE.properties +++ b/src/java/org/mxchange/localization/bundle_de_DE.properties @@ -603,3 +603,5 @@ ERROR_CANNOT_UN_LOCK_USER_ACCOUNT_UNCONFIRMED=Unbest\u00e4tigte Benutzeraccounts PAGE_TITLE_ADMIN_LOCK_USER=Benutzeraccount sperren CONTENT_TITLE_ADMIN_LOCK_USER=Benutzeraccount sperren: ERROR_BEAN_HELPER_USER_NOT_SET=Fehler: Instanz 'user' im Bean-Helper nicht gesetzt. +ERROR_BEAN_HELPER_CONTACT_NOT_SET=Fehler: Instanz 'contact' im Bean-Helper nicht gesetzt. +ERROR_ADMIN_BEAN_CELLPHONE_NUMBER_NOT_SET=Fehler: Instanz 'cellPhone' in administrativer Bean nicht gesetzt. diff --git a/src/java/org/mxchange/localization/bundle_en_US.properties b/src/java/org/mxchange/localization/bundle_en_US.properties index 2bbc5d37..a4ba3198 100644 --- a/src/java/org/mxchange/localization/bundle_en_US.properties +++ b/src/java/org/mxchange/localization/bundle_en_US.properties @@ -586,3 +586,5 @@ ERROR_CANNOT_UN_LOCK_USER_ACCOUNT_UNCONFIRMED=Unconfirmed user accounts cannot b PAGE_TITLE_ADMIN_LOCK_USER=Lock user account CONTENT_TITLE_ADMIN_LOCK_USER=Lock user account: ERROR_BEAN_HELPER_USER_NOT_SET=Error: Instance 'user' not set in bean helper. +ERROR_BEAN_HELPER_CONTACT_NOT_SET=Error: Instance 'contact' not set in bean helper. +ERROR_ADMIN_BEAN_CELLPHONE_NUMBER_NOT_SET=Error: Instance 'cellPhone' in administrative bean not set. diff --git a/src/java/org/mxchange/pizzaapplication/beans/helper/PizzaWebRequestHelper.java b/src/java/org/mxchange/pizzaapplication/beans/helper/PizzaWebRequestHelper.java index 9873bbac..11090b11 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/helper/PizzaWebRequestHelper.java +++ b/src/java/org/mxchange/pizzaapplication/beans/helper/PizzaWebRequestHelper.java @@ -22,10 +22,14 @@ import javax.inject.Inject; import javax.inject.Named; import org.mxchange.jcontacts.contact.Contact; import org.mxchange.jcustomercore.model.customer.Customer; +import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber; +import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber; +import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber; import org.mxchange.jusercore.model.user.User; import org.mxchange.pizzaapplication.beans.contact.PizzaAdminContactWebRequestController; import org.mxchange.pizzaapplication.beans.customer.PizzaAdminCustomerWebRequestController; import org.mxchange.pizzaapplication.beans.customer.PizzaCustomerWebSessionController; +import org.mxchange.pizzaapplication.beans.phone.PizzaAdminContactPhoneWebRequestController; import org.mxchange.pizzaapplication.beans.user.PizzaUserWebSessionController; /** @@ -43,7 +47,7 @@ public class PizzaWebRequestHelper implements PizzaWebRequestController { private static final long serialVersionUID = 17_258_793_567_145_701L; /** - * Regular contact controller + * Administrative contact controller */ @Inject private PizzaAdminContactWebRequestController adminContactController; @@ -54,6 +58,12 @@ public class PizzaWebRequestHelper implements PizzaWebRequestController { @Inject private PizzaAdminCustomerWebRequestController adminCustomerController; + /** + * Administrative phone controller + */ + @Inject + private PizzaAdminContactPhoneWebRequestController adminPhoneController; + /** * Contact instance */ @@ -104,6 +114,9 @@ public class PizzaWebRequestHelper implements PizzaWebRequestController { throw new IllegalStateException(MessageFormat.format("this.contact.contactId={0} is not valid.", this.getContact().getContactId())); //NOI18N } + // Set all phone instances + this.setPhoneInstances(this.getContact()); + // Set all fields: user this.adminContactController.copyContactToController(this.getContact()); @@ -152,6 +165,15 @@ public class PizzaWebRequestHelper implements PizzaWebRequestController { throw new IllegalStateException(MessageFormat.format("this.user.userId={0} is not valid.", this.getUser().getUserId())); //NOI18N } + // Get contact + Contact userContact = this.getUser().getUserContact(); + + // Set contact here, too. This avoids parameters that cannot auto-complete in IDEs. + this.setContact(userContact); + + // Set all phone instances + this.setPhoneInstances(userContact); + // Set all fields: user this.userController.setUserName(this.getUser().getUserName()); @@ -226,4 +248,41 @@ public class PizzaWebRequestHelper implements PizzaWebRequestController { this.user = user; } + /** + * Set's all given contact's phone instances: land-line, cellphone and fax + *

+ * @param contact Contact to set phone instances for + */ + private void setPhoneInstances (final Contact contact) { + // The contact must be valid + if (null == contact) { + // Throw NPE + throw new NullPointerException("contact is null"); //NOI18N + } else if (contact.getContactId() == null) { + // Throw again ... + throw new NullPointerException("contact.contactId is null"); //NOI18N + } else if (contact.getContactId() < 1) { + // Not valid + throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N + } + + // Is cellphone set? + if (contact.getContactCellphoneNumber() instanceof DialableCellphoneNumber) { + // Yes, then set it in admin controller + this.adminPhoneController.setCellPhone(contact.getContactCellphoneNumber()); + } + + // Is land-line set? + if (contact.getContactLandLineNumber() instanceof DialableLandLineNumber) { + // Yes, then set it in admin controller + this.adminPhoneController.setLandLine(contact.getContactLandLineNumber()); + } + + // Is fax set? + if (contact.getContactFaxNumber() instanceof DialableFaxNumber) { + // Yes, then set it in admin controller + this.adminPhoneController.setFax(contact.getContactFaxNumber()); + } + } + } diff --git a/src/java/org/mxchange/pizzaapplication/beans/phone/PizzaAdminContactPhoneWebRequestBean.java b/src/java/org/mxchange/pizzaapplication/beans/phone/PizzaAdminContactPhoneWebRequestBean.java index 4853e1fc..ef934fcd 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/phone/PizzaAdminContactPhoneWebRequestBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/phone/PizzaAdminContactPhoneWebRequestBean.java @@ -33,11 +33,11 @@ import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber; import org.mxchange.pizzaapplication.beans.BasePizzaController; /** - * Administrative bean (controller) for contact's phone numbers + * Administrative bean (controller) for phone numbers *

* @author Roland Haeder */ -@Named ("adminContactPhoneController") +@Named ("adminPhoneController") @RequestScoped public class PizzaAdminContactPhoneWebRequestBean extends BasePizzaController implements PizzaAdminContactPhoneWebRequestController { @@ -58,13 +58,19 @@ public class PizzaAdminContactPhoneWebRequestBean extends BasePizzaController im /** * Instance of linked contact account + *

+ * @deprecated This is a generic phone controller, not just for contact data */ + @Deprecated private Contact contact; /** * "Cache" for contact lists, mostly only one is assigned. So this cache * shouldn't grow beyond control. + *

+ * @deprecated This is a generic phone controller, not just for contact data */ + @Deprecated private final Map> contacts; /** @@ -98,6 +104,7 @@ public class PizzaAdminContactPhoneWebRequestBean extends BasePizzaController im } @Override + @Deprecated public List allCellphoneContacts () { // Get id Long phoneId = this.getCellPhone().getPhoneId(); @@ -129,11 +136,13 @@ public class PizzaAdminContactPhoneWebRequestBean extends BasePizzaController im } @Override + @Deprecated public Contact getContact () { return this.contact; } @Override + @Deprecated public void setContact (final Contact contact) { this.contact = contact; } diff --git a/src/java/org/mxchange/pizzaapplication/beans/phone/PizzaAdminContactPhoneWebRequestController.java b/src/java/org/mxchange/pizzaapplication/beans/phone/PizzaAdminContactPhoneWebRequestController.java index 400e97d3..e3266f6c 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/phone/PizzaAdminContactPhoneWebRequestController.java +++ b/src/java/org/mxchange/pizzaapplication/beans/phone/PizzaAdminContactPhoneWebRequestController.java @@ -36,6 +36,7 @@ public interface PizzaAdminContactPhoneWebRequestController extends Serializable *

* @return List of all linked contacts */ + @Deprecated List allCellphoneContacts (); /** @@ -85,6 +86,7 @@ public interface PizzaAdminContactPhoneWebRequestController extends Serializable *

* @return Linked contact account */ + @Deprecated Contact getContact (); /** @@ -92,6 +94,7 @@ public interface PizzaAdminContactPhoneWebRequestController extends Serializable *

* @param contact Linked contact account */ + @Deprecated void setContact (final Contact contact); } diff --git a/web/WEB-INF/faces-config.xml b/web/WEB-INF/faces-config.xml index 2bfc1191..118b4078 100644 --- a/web/WEB-INF/faces-config.xml +++ b/web/WEB-INF/faces-config.xml @@ -292,11 +292,11 @@ /admin/mobile_provider/admin_mobile_provider_show.xhtml - admin_show_contact_cellphone + admin_show_cellphone /admin/cellphone/admin_contact_cellphone_show.xhtml - admin_edit_contact_cellphone + admin_edit_cellphone /admin/cellphone/admin_contact_cellphone_edit.xhtml @@ -304,7 +304,7 @@ /admin/cellphone/admin_contact_cellphone_unlink.xhtml - admin_delete_contact_cellphone + admin_delete_cellphone /admin/cellphone/admin_contact_cellphone_delete.xhtml @@ -378,11 +378,11 @@ /admin/mobile_provider/admin_mobile_provider_show.xhtml - admin_edit_contact_cellphone + admin_edit_cellphone /admin/cellphone/admin_contact_cellphone_edit.xhtml - admin_delete_contact_cellphone + admin_delete_cellphone /admin/cellphone/admin_contact_cellphone_delete.xhtml @@ -390,22 +390,22 @@ /admin/cellphone/admin_contact_cellphone_unlink.xhtml - admin_show_contact_cellphone + admin_show_cellphone /admin/cellphone/admin_contact_cellphone_show.xhtml /admin/cellphone/admin_contact_cellphone_list.xhtml - admin_show_contact_cellphone + admin_show_cellphone /admin/cellphone/admin_contact_cellphone_show.xhtml - admin_edit_contact_cellphone + admin_edit_cellphone /admin/cellphone/admin_contact_cellphone_edit.xhtml - admin_delete_contact_cellphone + admin_delete_cellphone /admin/cellphone/admin_contact_cellphone_delete.xhtml @@ -416,11 +416,11 @@ /admin/mobile_provider/admin_mobile_provider_show.xhtml - admin_edit_contact_cellphone + admin_edit_cellphone /admin/cellphone/admin_contact_cellphone_edit.xhtml - admin_delete_contact_cellphone + admin_delete_cellphone /admin/cellphone/admin_contact_cellphone_delete.xhtml diff --git a/web/WEB-INF/templates/admin/cellphone/admin_cellphone_add_show.tpl b/web/WEB-INF/templates/admin/cellphone/admin_cellphone_add_show.tpl index 1f27e7db..4f127340 100644 --- a/web/WEB-INF/templates/admin/cellphone/admin_cellphone_add_show.tpl +++ b/web/WEB-INF/templates/admin/cellphone/admin_cellphone_add_show.tpl @@ -5,20 +5,13 @@ xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:ui="http://xmlns.jcp.org/jsf/facelets"> - - - + - - - - + + - - - - - + + diff --git a/web/WEB-INF/templates/admin/cellphone/admin_cellphone_data.tpl b/web/WEB-INF/templates/admin/cellphone/admin_cellphone_data.tpl index db480479..a7a3b925 100644 --- a/web/WEB-INF/templates/admin/cellphone/admin_cellphone_data.tpl +++ b/web/WEB-INF/templates/admin/cellphone/admin_cellphone_data.tpl @@ -5,9 +5,9 @@ xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://xmlns.jcp.org/jsf/facelets"> - + - + @@ -15,42 +15,31 @@ - + - - + + - +

- - - - - - - - - - - - - - + + +
diff --git a/web/WEB-INF/templates/admin/cellphone/admin_cellphone_links.tpl b/web/WEB-INF/templates/admin/cellphone/admin_cellphone_links.tpl index 100bed17..60540cea 100644 --- a/web/WEB-INF/templates/admin/cellphone/admin_cellphone_links.tpl +++ b/web/WEB-INF/templates/admin/cellphone/admin_cellphone_links.tpl @@ -5,40 +5,40 @@ xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://xmlns.jcp.org/jsf/facelets"> - + - +
    - +
diff --git a/web/WEB-INF/templates/admin/cellphone/admin_form_contact_cellphone.tpl b/web/WEB-INF/templates/admin/cellphone/admin_form_contact_cellphone.tpl index 914e9683..06e96e21 100644 --- a/web/WEB-INF/templates/admin/cellphone/admin_form_contact_cellphone.tpl +++ b/web/WEB-INF/templates/admin/cellphone/admin_form_contact_cellphone.tpl @@ -5,6 +5,8 @@ xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:ui="http://xmlns.jcp.org/jsf/facelets"> + + diff --git a/web/WEB-INF/templates/admin/contact/admin_contact_links.tpl b/web/WEB-INF/templates/admin/contact/admin_contact_links.tpl index 26f287c1..175474e2 100644 --- a/web/WEB-INF/templates/admin/contact/admin_contact_links.tpl +++ b/web/WEB-INF/templates/admin/contact/admin_contact_links.tpl @@ -5,9 +5,9 @@ xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://xmlns.jcp.org/jsf/facelets"> - + - +
@@ -17,14 +17,14 @@
  • - +
  • - +
diff --git a/web/admin/cellphone/admin_contact_cellphone_delete.xhtml b/web/admin/cellphone/admin_contact_cellphone_delete.xhtml index 605ec9fe..2261c4e0 100644 --- a/web/admin/cellphone/admin_contact_cellphone_delete.xhtml +++ b/web/admin/cellphone/admin_contact_cellphone_delete.xhtml @@ -8,7 +8,7 @@ > - + diff --git a/web/admin/cellphone/admin_contact_cellphone_edit.xhtml b/web/admin/cellphone/admin_contact_cellphone_edit.xhtml index eb3d93cd..95939c28 100644 --- a/web/admin/cellphone/admin_contact_cellphone_edit.xhtml +++ b/web/admin/cellphone/admin_contact_cellphone_edit.xhtml @@ -8,7 +8,7 @@ > - + diff --git a/web/admin/cellphone/admin_contact_cellphone_show.xhtml b/web/admin/cellphone/admin_contact_cellphone_show.xhtml index 7d0e1af4..0c433743 100644 --- a/web/admin/cellphone/admin_contact_cellphone_show.xhtml +++ b/web/admin/cellphone/admin_contact_cellphone_show.xhtml @@ -8,7 +8,7 @@ > - + @@ -20,14 +20,13 @@ - - + - + @@ -80,7 +79,7 @@ diff --git a/web/admin/cellphone/admin_contact_cellphone_unlink.xhtml b/web/admin/cellphone/admin_contact_cellphone_unlink.xhtml index b6f7e4ed..0b71610b 100644 --- a/web/admin/cellphone/admin_contact_cellphone_unlink.xhtml +++ b/web/admin/cellphone/admin_contact_cellphone_unlink.xhtml @@ -8,8 +8,8 @@ > - - + + diff --git a/web/admin/contact/admin_contact_show.xhtml b/web/admin/contact/admin_contact_show.xhtml index b2fd1ffd..4b3ecb30 100644 --- a/web/admin/contact/admin_contact_show.xhtml +++ b/web/admin/contact/admin_contact_show.xhtml @@ -25,16 +25,11 @@
- - - +
- - - - +
diff --git a/web/admin/user/admin_user_show.xhtml b/web/admin/user/admin_user_show.xhtml index f9c9b9cd..ca7e8dda 100644 --- a/web/admin/user/admin_user_show.xhtml +++ b/web/admin/user/admin_user_show.xhtml @@ -184,10 +184,7 @@
- - - - +