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=c7fd794115db4891855464ed7f23f7c5bd1898fc;p=jfinancials-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/addressbook/beans/helper/AddressbookWebRequestHelper.java b/src/java/org/mxchange/addressbook/beans/helper/AddressbookWebRequestHelper.java index f33ff629..93c9f60d 100644 --- a/src/java/org/mxchange/addressbook/beans/helper/AddressbookWebRequestHelper.java +++ b/src/java/org/mxchange/addressbook/beans/helper/AddressbookWebRequestHelper.java @@ -21,8 +21,12 @@ import javax.enterprise.context.RequestScoped; import javax.inject.Inject; import javax.inject.Named; import org.mxchange.addressbook.beans.contact.AddressbookAdminContactWebRequestController; +import org.mxchange.addressbook.beans.phone.AddressbookAdminContactPhoneWebRequestController; import org.mxchange.addressbook.beans.user.AddressbookUserWebSessionController; import org.mxchange.jcontacts.contact.Contact; +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; /** @@ -40,11 +44,17 @@ public class AddressbookWebRequestHelper implements AddressbookWebRequestControl private static final long serialVersionUID = 17_258_793_567_145_701L; /** - * Regular contact controller + * Administrative contact controller */ @Inject private AddressbookAdminContactWebRequestController adminContactController; + /** + * Administrative phone controller + */ + @Inject + private AddressbookAdminContactPhoneWebRequestController adminPhoneController; + /** * Contact instance */ @@ -84,6 +94,9 @@ public class AddressbookWebRequestHelper implements AddressbookWebRequestControl 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()); @@ -108,6 +121,15 @@ public class AddressbookWebRequestHelper implements AddressbookWebRequestControl 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()); @@ -165,4 +187,41 @@ public class AddressbookWebRequestHelper implements AddressbookWebRequestControl 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/addressbook/beans/phone/AddressbookAdminContactPhoneWebRequestBean.java b/src/java/org/mxchange/addressbook/beans/phone/AddressbookAdminContactPhoneWebRequestBean.java index fa26a625..3284465a 100644 --- a/src/java/org/mxchange/addressbook/beans/phone/AddressbookAdminContactPhoneWebRequestBean.java +++ b/src/java/org/mxchange/addressbook/beans/phone/AddressbookAdminContactPhoneWebRequestBean.java @@ -33,11 +33,11 @@ import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber; import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber; /** - * Administrative bean (controller) for contact's phone numbers + * Administrative bean (controller) for phone numbers *

* @author Roland Haeder */ -@Named ("adminContactPhoneController") +@Named ("adminPhoneController") @RequestScoped public class AddressbookAdminContactPhoneWebRequestBean extends BaseAddressbookController implements AddressbookAdminContactPhoneWebRequestController { @@ -58,13 +58,19 @@ public class AddressbookAdminContactPhoneWebRequestBean extends BaseAddressbookC /** * 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 AddressbookAdminContactPhoneWebRequestBean extends BaseAddressbookC } @Override + @Deprecated public List allCellphoneContacts () { // Get id Long phoneId = this.getCellPhone().getPhoneId(); @@ -129,11 +136,13 @@ public class AddressbookAdminContactPhoneWebRequestBean extends BaseAddressbookC } @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/addressbook/beans/phone/AddressbookAdminContactPhoneWebRequestController.java b/src/java/org/mxchange/addressbook/beans/phone/AddressbookAdminContactPhoneWebRequestController.java index 04af7f01..2ef40a6b 100644 --- a/src/java/org/mxchange/addressbook/beans/phone/AddressbookAdminContactPhoneWebRequestController.java +++ b/src/java/org/mxchange/addressbook/beans/phone/AddressbookAdminContactPhoneWebRequestController.java @@ -36,6 +36,7 @@ public interface AddressbookAdminContactPhoneWebRequestController extends Serial *

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

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

* @param contact Linked contact account */ + @Deprecated void setContact (final Contact contact); } diff --git a/src/java/org/mxchange/localization/bundle_de_DE.properties b/src/java/org/mxchange/localization/bundle_de_DE.properties index 5dc86c49..1aadf343 100644 --- a/src/java/org/mxchange/localization/bundle_de_DE.properties +++ b/src/java/org/mxchange/localization/bundle_de_DE.properties @@ -631,3 +631,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 cd9dee42..d2be3817 100644 --- a/src/java/org/mxchange/localization/bundle_en_US.properties +++ b/src/java/org/mxchange/localization/bundle_en_US.properties @@ -628,3 +628,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/web/WEB-INF/faces-config.xml b/web/WEB-INF/faces-config.xml index 5f435f73..74e005b6 100644 --- a/web/WEB-INF/faces-config.xml +++ b/web/WEB-INF/faces-config.xml @@ -291,11 +291,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 @@ -303,7 +303,7 @@ /admin/cellphone/admin_contact_cellphone_unlink.xhtml - admin_delete_contact_cellphone + admin_delete_cellphone /admin/cellphone/admin_contact_cellphone_delete.xhtml @@ -338,11 +338,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 @@ -350,22 +350,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 @@ -376,11 +376,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 @@
- - - - +