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=ee76e475fde2bf4b7b3182302ad49789a6dcbe0e;p=jjobs-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/jjobs/beans/helper/JobsWebRequestHelper.java b/src/java/org/mxchange/jjobs/beans/helper/JobsWebRequestHelper.java index 99d676d8..3cf2f558 100644 --- a/src/java/org/mxchange/jjobs/beans/helper/JobsWebRequestHelper.java +++ b/src/java/org/mxchange/jjobs/beans/helper/JobsWebRequestHelper.java @@ -23,6 +23,9 @@ import javax.inject.Named; import org.mxchange.jcontacts.contact.Contact; import org.mxchange.jjobs.beans.contact.JobsAdminContactWebRequestController; import org.mxchange.jjobs.beans.user.JobsUserWebSessionController; +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 +43,17 @@ public class JobsWebRequestHelper implements JobsWebRequestController { private static final long serialVersionUID = 17_258_793_567_145_701L; /** - * Regular contact controller + * Administrative contact controller */ @Inject private JobsAdminContactWebRequestController adminContactController; + /** + * Administrative phone controller + */ + @Inject + private JobsAdminContactPhoneWebRequestController adminPhoneController; + /** * Contact instance */ @@ -84,6 +93,9 @@ public class JobsWebRequestHelper implements JobsWebRequestController { 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 +120,15 @@ public class JobsWebRequestHelper implements JobsWebRequestController { throw new IllegalStateException(MessageFormat.format("this.user.userId={0} is not valid.", this.getUser().getUserId())); } + // 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 +186,41 @@ public class JobsWebRequestHelper implements JobsWebRequestController { 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/jjobs/beans/phone/JobsAdminContactPhoneWebSessionBean.java b/src/java/org/mxchange/jjobs/beans/phone/JobsAdminContactPhoneWebSessionBean.java index 4b6a9245..80a42699 100644 --- a/src/java/org/mxchange/jjobs/beans/phone/JobsAdminContactPhoneWebSessionBean.java +++ b/src/java/org/mxchange/jjobs/beans/phone/JobsAdminContactPhoneWebSessionBean.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 JobsAdminContactPhoneWebSessionBean extends BaseJobsController implements JobsAdminContactPhoneWebSessionController { @@ -58,13 +58,19 @@ public class JobsAdminContactPhoneWebSessionBean extends BaseJobsController impl /** * 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 JobsAdminContactPhoneWebSessionBean extends BaseJobsController impl } @Override + @Deprecated public List allCellphoneContacts () { // Get id Long phoneId = this.getCellPhone().getPhoneId(); @@ -129,11 +136,13 @@ public class JobsAdminContactPhoneWebSessionBean extends BaseJobsController impl } @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/jjobs/beans/phone/JobsAdminContactPhoneWebSessionController.java b/src/java/org/mxchange/jjobs/beans/phone/JobsAdminContactPhoneWebSessionController.java index b0e7e9cd..989f9894 100644 --- a/src/java/org/mxchange/jjobs/beans/phone/JobsAdminContactPhoneWebSessionController.java +++ b/src/java/org/mxchange/jjobs/beans/phone/JobsAdminContactPhoneWebSessionController.java @@ -36,6 +36,7 @@ public interface JobsAdminContactPhoneWebSessionController extends Serializable *

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

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

* @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 927f25a6..7749593d 100644 --- a/src/java/org/mxchange/localization/bundle_de_DE.properties +++ b/src/java/org/mxchange/localization/bundle_de_DE.properties @@ -598,3 +598,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 937559a1..340e5951 100644 --- a/src/java/org/mxchange/localization/bundle_en_US.properties +++ b/src/java/org/mxchange/localization/bundle_en_US.properties @@ -598,3 +598,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 6abcbe2f..0f7c58db 100644 --- a/web/WEB-INF/faces-config.xml +++ b/web/WEB-INF/faces-config.xml @@ -287,11 +287,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 @@ -299,7 +299,7 @@ /admin/cellphone/admin_contact_cellphone_unlink.xhtml - admin_delete_contact_cellphone + admin_delete_cellphone /admin/cellphone/admin_contact_cellphone_delete.xhtml @@ -334,11 +334,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 @@ -346,22 +346,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 @@ -372,11 +372,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 abd24354..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 823263f8..7a8be2ad 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 646e9f6b..0d33f603 100644 --- a/web/admin/user/admin_user_show.xhtml +++ b/web/admin/user/admin_user_show.xhtml @@ -184,10 +184,7 @@
- - - - +