]> git.mxchange.org Git - jjobs-war.git/commitdiff
Refactured a lot:
authorRoland Häder <roland@mxchange.org>
Wed, 27 Apr 2016 08:54:32 +0000 (10:54 +0200)
committerRoland Haeder <roland@mxchange.org>
Thu, 5 May 2016 17:27:29 +0000 (19:27 +0200)
- administrative controller are request-scoped, therefor their "cached" lists are never cached for a longer time. So all lists has to be moved to general controllers
- added new general customer bean for above refacturing

Signed-off-by: Roland Häder <roland@haeder.net>
Signed-off-by: Roland Häder <roland@mxchange.org>
src/java/org/mxchange/jjobs/beans/helper/JobsAdminWebRequestController.java
src/java/org/mxchange/jjobs/beans/helper/JobsAdminWebRequestHelper.java
src/java/org/mxchange/jjobs/beans/user/JobsAdminUserWebRequestBean.java
src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionBean.java
src/java/org/mxchange/localization/bundle_de_DE.properties
src/java/org/mxchange/localization/bundle_en_US.properties
web/admin/contact/admin_contact_list.xhtml
web/admin/user/admin_user_list.xhtml

index 1cb8f2e75b70abb2ad82d95b07ff780c54fd120d..a5b7985f1872520c8d86639b4e0cf337b098fa42 100644 (file)
@@ -46,6 +46,16 @@ public interface JobsAdminWebRequestController extends Serializable {
         */
        void copyUserToController ();
 
+       /**
+        * Returns a message key depending on if this contact is a user and/or a
+        * contact. If this contact is unused, a default key is returned.
+        * <p>
+        * @param contact Contact instance to check
+        * <p>
+        * @return Message key
+        */
+       String getContactUsageMessageKey (final Contact contact);
+
        /**
         * Getter for contact instance
         * <p>
index 9d469410badad9bc30880f211b445f17fc748161..fafd21db74423c4e5aa9b9e530656ae4f9de0c7f 100644 (file)
@@ -40,13 +40,13 @@ public class JobsAdminWebRequestHelper implements JobsAdminWebRequestController
        private static final long serialVersionUID = 17_258_793_567_145_701L;
 
        /**
-        * Admin contact controller
+        * Administrative contact controller
         */
        @Inject
        private JobsAdminContactWebRequestController adminContactController;
 
        /**
-        * Admin user controller
+        * Administrative user controller
         */
        @Inject
        private JobsAdminUserWebRequestController adminUserController;
@@ -70,7 +70,7 @@ public class JobsAdminWebRequestHelper implements JobsAdminWebRequestController
        @Override
        public void copyContactToController () {
                // Log message
-               System.out.println("AdminHelper::copyContactToController - CALLED!"); //NOI18N
+               //* NOISY-DEBUG: */ System.out.println("AdminHelper::copyContactToController - CALLED!"); //NOI18N
 
                // Validate user instance
                if (this.getContact() == null) {
@@ -88,11 +88,14 @@ public class JobsAdminWebRequestHelper implements JobsAdminWebRequestController
                this.adminContactController.copyContactToController(this.getContact());
 
                // Log message
-               System.out.println("AdminHelper::copyContactToController - EXIT!"); //NOI18N
+               //* NOISY-DEBUG: */ System.out.println("AdminHelper::copyContactToController - EXIT!"); //NOI18N
        }
 
        @Override
        public void copyUserToController () {
+               // Log message
+               //* NOISY-DEBUG: */ System.out.println("AdminHelper::copyUserToController - CALLED!"); //NOI18N
+
                // Validate user instance
                if (this.getUser() == null) {
                        // Throw NPE
@@ -109,7 +112,7 @@ public class JobsAdminWebRequestHelper implements JobsAdminWebRequestController
                this.adminUserController.setUserName(this.getUser().getUserName());
 
                // Log message
-               System.out.println("AdminHelper::copyUserToController - EXIT!"); //NOI18N
+               //* NOISY-DEBUG: */ System.out.println("AdminHelper::copyUserToController - EXIT!"); //NOI18N
        }
 
        @Override
@@ -122,6 +125,16 @@ public class JobsAdminWebRequestHelper implements JobsAdminWebRequestController
                this.contact = contact;
        }
 
+       @Override
+       public User getUser () {
+               return this.user;
+       }
+
+       @Override
+       public void setUser (final User user) {
+               this.user = user;
+       }
+
        @Override
        public String getContactUsageMessageKey (final Contact contact) {
                // The contact must be valid
@@ -152,14 +165,4 @@ public class JobsAdminWebRequestHelper implements JobsAdminWebRequestController
                return messageKey;
        }
 
-       @Override
-       public User getUser () {
-               return this.user;
-       }
-
-       @Override
-       public void setUser (final User user) {
-               this.user = user;
-       }
-
 }
index 194a85be12a0a90ea81c6a31769a2a92fbcbf20f..ae35f28657085618bc509d691e68901bcd95f3f1 100644 (file)
@@ -142,9 +142,6 @@ public class JobsAdminUserWebRequestBean implements JobsAdminUserWebRequestContr
 
        @Override
        public String addUser () {
-               // Create new user instance
-               User user = new LoginUser();
-
                // As the form cannot validate the data (required="true"), check it here
                if (this.getUserName() == null) {
                        // Throw NPE
@@ -169,13 +166,13 @@ public class JobsAdminUserWebRequestBean implements JobsAdminUserWebRequestContr
                        } else if (this.contactController.getFamilyName().isEmpty()) {
                                // ... and again
                                throw new IllegalArgumentException("contactController.familyName is empty"); //NOI18N //NOI18N
-                       } else if (this.contactController.getEmailAddress()== null) {
+                       } else if (this.contactController.getEmailAddress() == null) {
                                // ... and again
                                throw new NullPointerException("contactController.emailAddress is null");
                        } else if (this.contactController.getEmailAddress().isEmpty()) {
                                // ... and again
                                throw new IllegalArgumentException("contactController.emailAddress is empty"); //NOI18N //NOI18N
-                       } else if (this.contactController.getEmailAddressRepeat()== null) {
+                       } else if (this.contactController.getEmailAddressRepeat() == null) {
                                // ... and again
                                throw new NullPointerException("contactController.emailAddressRepeat is null");
                        } else if (this.contactController.getEmailAddressRepeat().isEmpty()) {
@@ -187,6 +184,9 @@ public class JobsAdminUserWebRequestBean implements JobsAdminUserWebRequestContr
                        }
                }
 
+               // Create new user instance
+               User user = new LoginUser();
+
                // Set user name, CONFIRMED and INVISIBLE
                user.setUserName(this.getUserName());
                user.setUserAccountStatus(UserAccountStatus.CONFIRMED);
@@ -239,7 +239,7 @@ public class JobsAdminUserWebRequestBean implements JobsAdminUserWebRequestContr
                                // Add new contact
                                updatedUser = this.userBean.addUser(user);
                        }
-                       } catch (final UserNameAlreadyRegisteredException | EmailAddressAlreadyRegisteredException ex) {
+               } catch (final UserNameAlreadyRegisteredException | EmailAddressAlreadyRegisteredException ex) {
                        // Throw again
                        throw new FaceletException(ex);
                }
@@ -301,7 +301,7 @@ public class JobsAdminUserWebRequestBean implements JobsAdminUserWebRequestContr
                        throw new NullPointerException("adminHelper.user.userId is null"); //NOI18N //NOI18N
                } else if (user.getUserId() < 1) {
                        // Invalid id
-                       throw new IllegalStateException(MessageFormat.format("adminHelper.user.userId={0} is invalid", user.getUserId()));
+                       throw new IllegalStateException(MessageFormat.format("adminHelper.user.userId={0} is invalid", user.getUserId())); //NOI18N
                } else if (this.getUserName() == null) {
                        // Not all required fields are set
                        throw new NullPointerException("this.userName is null"); //NOI18N
index 21bbde26e002c3642abf7f0455fb35eb8bb41f2e..76d291dcb93c65ba3aa7c5ed019533132dbdea95 100644 (file)
@@ -140,7 +140,7 @@ public class JobsUserWebSessionBean implements JobsUserWebSessionController {
        }
 
        @Override
-       public void afterRegistrationEvent (final @Observes UserRegisteredEvent event) {
+       public void afterRegistrationEvent (@Observes final UserRegisteredEvent event) {
                // Trace message
                //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("UserWebBean:afterRegistration: event={0} - CALLED!", event)); //NOI18N
 
@@ -271,12 +271,12 @@ public class JobsUserWebSessionBean implements JobsUserWebSessionController {
                this.contactController.updateContactDataFromController(user.getUserContact());
 
                // It should be there, so run some tests on it
-               assert (user instanceof User) : "Instance loginController.loggedInUser is null";
-               assert (user.getUserId() instanceof Long) : "Instance loginController.loggedInUser.userId is null";
-               assert (user.getUserId() > 0) : MessageFormat.format("loginController.loggedInUser.userId={0} is invalid", user.getUserId());
-               assert (user.getUserContact() instanceof Contact) : "Instance loginController.loggedInUser.userContact is null";
-               assert (user.getUserContact().getContactId() instanceof Long) : "Instance loginController.userContact.contactId is null";
-               assert (user.getUserContact().getContactId() > 0) : MessageFormat.format("Instance loginController.userContact.contactId={0} is invalid", user.getUserContact().getContactId());
+               assert (user instanceof User) : "Instance loginController.loggedInUser is null"; //NOI18N
+               assert (user.getUserId() instanceof Long) : "Instance loginController.loggedInUser.userId is null"; //NOI18N
+               assert (user.getUserId() > 0) : MessageFormat.format("loginController.loggedInUser.userId={0} is invalid", user.getUserId()); //NOI18N
+               assert (user.getUserContact() instanceof Contact) : "Instance loginController.loggedInUser.userContact is null"; //NOI18N
+               assert (user.getUserContact().getContactId() instanceof Long) : "Instance loginController.userContact.contactId is null"; //NOI18N
+               assert (user.getUserContact().getContactId() > 0) : MessageFormat.format("Instance loginController.userContact.contactId={0} is invalid", user.getUserContact().getContactId()); //NOI18N
 
                // Update all fields
                user.setUserProfileMode(this.getUserProfileMode());
@@ -483,4 +483,5 @@ public class JobsUserWebSessionBean implements JobsUserWebSessionController {
                DialableFaxNumber fax = user.getUserContact().getContactFaxNumber();
                DialableLandLineNumber phone = user.getUserContact().getContactLandLineNumber();
        }
+
 }
index 08bdc0f1edbf98cbb1b53cb61cb629c821ec5d0b..3616ca1bd23cda56868be49e3b0cddd527f47abe 100644 (file)
@@ -471,4 +471,7 @@ ADMIN_DELETE_CONTACT_TITLE=Kontaktdaten unwiederruflich l\u00f6schen
 BUTTON_ADMIN_DELETE_CONTACT=Kontaktdaten l\u00f6schen
 ADMIN_DELETE_CONTACT_NOTICE=Sie wollen Kontaktdaten l\u00f6schen. Diese k\u00f6nnten noch evtl. mit anderen Daten verkn\u00fcft sein, was zu Fehlern f\u00fchrt. Bitte l\u00f6schen Sie nur, wenn Sie sich absolut sicher sind, dass keine fremden Daten auf diesen Datensatz mehr verweisen.
 ADMIN_CONTACT_PERSONAL_DATA_MINIMUM_NOTICE=Bitte geben Sie mindestens Anrede, Vor- und Nachnamen ein.
-ERROR_CUSTOMER_ID_NOT_FOUND=Fehler: Kundeneintrag nicht gefunden.
+ADMIN_MENU_CONTACT_TITLE=Manage contact data
+LINK_ADMIN_LIST_CONTACT=Kontaktdaten auflisten
+LINK_ADMIN_LIST_CONTACT_TITLE=Listet alle Kontaktdaten auf, egal wo her sie angelegt wurden.
+CONTACT_IS_USER=Ist Benutzer
index 1b181b87da095e07923c6cda233686a682d48289..a6b36f3b5f91c84625eb722cdfbb251a9f936e3b 100644 (file)
@@ -440,7 +440,7 @@ ADMIN_ADD_CONTACT_MINIMUM_DATA=Please enter at least gender, first name and fami
 ERROR_PARAMETER_CONTACT_NOT_SET=Error: Parameter 'contact' is not set.
 ADMIN_HEADER_SHOW_CONTACT=Contact data for {0}:
 ADMIN_CONTACT_UPDATED=Contact data updated:
-ADMIN_LINK_DELETE_CONTACT=Kontakt l\u00f6schen
+ADMIN_LINK_DELETE_CONTACT=Delete contact data
 ADMIN_LINK_DELETE_CONTACT_TITLE=Deletes contact data, a confirmation is needed.
 PAGE_TITLE_ADMIN_DELETE_CONTACT=Delete contact data
 CONTENT_TITLE_ADMIN_DELETE_CONTACT=Delete contact data:
@@ -448,4 +448,7 @@ ADMIN_DELETE_CONTACT_TITLE=Delete contact data unreverseable
 BUTTON_ADMIN_DELETE_CONTACT=Delete contact data
 ADMIN_DELETE_CONTACT_NOTICE=You want to delete contact data. This data could be still linked with other data which could lead to errors. Please delete only, if you are sure that no foreign data links to this record.
 ADMIN_CONTACT_PERSONAL_DATA_MINIMUM_NOTICE=Please enter at least gender, first name and family name.
-ERROR_CUSTOMER_ID_NOT_FOUND=Error: Customer entry not found.
+ADMIN_MENU_CONTACT_TITLE=Manage contact data
+LINK_ADMIN_LIST_CONTACT=List contact data
+LINK_ADMIN_LIST_CONTACT_TITLE=Lists all contact data regardless where they was created.
+CONTACT_IS_USER=Is a user
index dca2708a54f7f30d2ed86748891c277b3c660070..81a29c4ab929d03534f6423ad35da6c7b7617d57 100644 (file)
@@ -46,7 +46,7 @@
                                <h:column>
                                        <f:facet name="header">#{msg.ADMIN_CONTACT_USAGE}</f:facet>
 
-                                       <h:outputText value="#{msg[adminHelper.getUserCustomerUsageMessageKey(contact)]}" />
+                                       <h:outputText value="#{msg[adminHelper.getContactUsageMessageKey(contact)]}" />
                                </h:column>
 
                                <h:column>
index c0168f1d14f3667c3cfdf4c7fb2be4a9bfa5fc2c..11ead762e7f4dfd3768a77e8369b73cd802f71ad 100644 (file)
@@ -16,9 +16,9 @@
                </ui:define>
 
                <ui:define name="content">
-                       <h:dataTable id="table_list_users" var="user" value="#{adminUserController.allUsers()}" styleClass="table_big" headerClass="table_header_column" summary="#{msg.TABLE_SUMMARY_ADMIN_LIST_USERS}" rendered="#{adminUserController.hasUsers()}">
+                       <h:dataTable id="table_list_users" var="user" value="#{userController.allUsers()}" styleClass="table_big" headerClass="table_header_column" summary="#{msg.TABLE_SUMMARY_ADMIN_LIST_USERS}" rendered="#{userController.hasUsers()}">
                                <h:column>
-                                       <f:facet name="header">#{msg.ADMIN_LIST_USER_ID}</f:facet>
+                                       <f:facet name="header">#{msg.ADMIN_USER_ID}</f:facet>
 
                                        <h:link outcome="admin_show_user" title="#{msg.ADMIN_LINK_SHOW_USER_TITLE}" value="#{user.userId}">
                                                <f:param name="userId" value="#{user.userId}" />
                                </h:column>
 
                                <h:column>
-                                       <f:facet name="header">#{msg.ADMIN_LIST_USER_NAME}</f:facet>
+                                       <f:facet name="header">#{msg.ADMIN_USER_NAME}</f:facet>
 
                                        <h:outputText value="#{user.userName}" />
                                </h:column>
 
                                <h:column>
-                                       <f:facet name="header">#{msg.ADMIN_LIST_USER_GENDER}</f:facet>
+                                       <f:facet name="header">#{msg.ADMIN_CONTACT_GENDER}</f:facet>
 
                                        <h:outputText value="#{msg[user.userContact.contactGender.messageKey]}" />
                                </h:column>
 
                                <h:column>
-                                       <f:facet name="header">#{msg.ADMIN_LIST_USER_FIRST_NAME}</f:facet>
+                                       <f:facet name="header">#{msg.ADMIN_CONTACT_FIRST_NAME}</f:facet>
 
                                        <h:outputText value="#{user.userContact.contactFirstName}" />
                                </h:column>
 
                                <h:column>
-                                       <f:facet name="header">#{msg.ADMIN_LIST_USER_FAMILY_NAME}</f:facet>
+                                       <f:facet name="header">#{msg.ADMIN_CONTACT_FAMILY_NAME}</f:facet>
 
                                        <h:outputText value="#{user.userContact.contactFamilyName}" />
                                </h:column>
 
                                <h:column>
-                                       <f:facet name="header">#{msg.ADMIN_LIST_USER_ACCOUNT_STATUS}</f:facet>
+                                       <f:facet name="header">#{msg.ADMIN_USER_ACCOUNT_STATUS}</f:facet>
 
                                        <h:outputText styleClass="#{user.userAccountStatus.styleClass}" value="#{msg[user.userAccountStatus.messageKey]}" />
                                </h:column>
 
                                <h:column>
-                                       <f:facet name="header">#{msg.ADMIN_LIST_USER_PROFILE_MODE}</f:facet>
+                                       <f:facet name="header">#{msg.ADMIN_USER_PROFILE_MODE}</f:facet>
 
                                        <h:outputText value="#{msg[user.userProfileMode.messageKey]}" />
                                </h:column>
 
                                <h:column>
-                                       <f:facet name="header">#{msg.ADMIN_LIST_USER_CREATED}</f:facet>
+                                       <f:facet name="header">#{msg.ADMIN_USER_CREATED}</f:facet>
 
                                        <h:outputText id="userCreated" value="#{user.userCreated.time}">
                                                <f:convertDateTime for="userCreated" type="both" timeStyle="short" dateStyle="short" />