]> git.mxchange.org Git - jjobs-war.git/commitdiff
Continued with rewrites:
authorRoland Häder <roland@mxchange.org>
Mon, 6 Jun 2016 14:02:42 +0000 (16:02 +0200)
committerRoland Haeder <roland@mxchange.org>
Sun, 7 Aug 2016 11:48:34 +0000 (13:48 +0200)
- moved selectableContacts to contact controller, makes more sense
- fixed template for above
- introduced isGenderRequired() to make difference between general and administrative contact controller
- added new context parameter for above method
- fired event when a new user account has been linked with existing contact data
- the other event (added user) is being fired now on else path
- No more need for afterAdminAddedContact() in general user controller

Signed-off-by: Roland Häder <roland@mxchange.org>
src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestBean.java
src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestController.java
src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionBean.java
src/java/org/mxchange/jjobs/beans/user/JobsAdminUserWebRequestBean.java
src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionBean.java
web/admin/user/admin_user_list.xhtml

index 420ae887f41aa29503460a7df71b17e902553738..8b93305b84cb560aba769bbfb3658fb2e838f2b2 100644 (file)
@@ -23,6 +23,7 @@ import javax.annotation.PostConstruct;
 import javax.enterprise.context.RequestScoped;
 import javax.enterprise.event.Event;
 import javax.enterprise.inject.Any;
+import javax.faces.context.FacesContext;
 import javax.faces.view.facelets.FaceletException;
 import javax.inject.Inject;
 import javax.inject.Named;
@@ -728,6 +729,18 @@ public class JobsAdminContactWebRequestBean extends BaseJobsController implement
        public void init () {
        }
 
+       @Override
+       public boolean isGenderRequired () {
+               // Get context parameter
+               String contextParameter = FacesContext.getCurrentInstance().getExternalContext().getInitParameter("is_admin_gender_enabled"); //NOI18N
+
+               // Is it set?
+               boolean isRequired = ((contextParameter instanceof String) && (contextParameter.toLowerCase().equals("true"))); //NOI18N
+
+               // Return value
+               return isRequired;
+       }
+
        /**
         * Clears this bean
         */
index af2c64b7ab7334852250d038d8eef50c919d473f..e4c9484a87ba13a95cf5e301c7390e1e356b5329 100644 (file)
@@ -431,4 +431,12 @@ public interface JobsAdminContactWebRequestController extends Serializable {
         */
        String generateCellphoneNumber (final DialableCellphoneNumber cellphoneNumber);
 
+       /**
+        * Checks/returns whether the gender/salutation is required for this
+        * controller.
+        * <p>
+        * @return Whether gender is required
+        */
+       boolean isGenderRequired ();
+
 }
index f40bb6f3576ab557f1720778df240913dc2c7a66..99117f9f57b853c1a2513c742d4bb6239aea8bc9 100644 (file)
@@ -243,6 +243,9 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job
 
        @Override
        public void afterAdminAddedContact (@Observes final AdminAddedContactEvent event) {
+               // Trace message
+               /* NOISY-DEBUG: */ System.out.println(MessageFormat.format("contactController.afterAdminAddedContact(): event={0} - CALLED!", event)); //NOI18N
+
                // The event must be valid
                if (null == event) {
                        // Throw NPE
index 682bdb2b9a84e2585e9dabb5840ec1e0b0310248..022e2b989fef1a9ea3d95bc6e2a4c5b958a22a95 100644 (file)
@@ -39,6 +39,7 @@ import org.mxchange.jusercore.container.login.UserLoginContainer;
 import org.mxchange.jusercore.events.registration.UserRegisteredEvent;
 import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent;
 import org.mxchange.jusercore.events.user.add.AdminUserAddedEvent;
+import org.mxchange.jusercore.events.user.linked.AdminLinkedUserEvent;
 import org.mxchange.jusercore.events.user.linked.AdminUserLinkedEvent;
 import org.mxchange.jusercore.events.user.update.AdminUpdatedUserDataEvent;
 import org.mxchange.jusercore.events.user.update.AdminUserDataUpdatedEvent;
@@ -119,6 +120,14 @@ public class JobsAdminUserWebRequestBean extends BaseJobsController implements J
        @Inject
        private JobsUserWebSessionController userController;
 
+       /**
+        * An event fired when the administrator has linked a user with existing
+        * contact data.
+        */
+       @Inject
+       @Any
+       private Event<AdminLinkedUserEvent> userLinkedEvent;
+
        /**
         * User lock reason
         */
@@ -284,6 +293,9 @@ public class JobsAdminUserWebRequestBean extends BaseJobsController implements J
                // Clear helper
                this.beanHelper.setContact(null);
 
+               // Clear this bean
+               this.clear();
+
                // Return to user list (for now)
                return "admin_list_user"; //NOI18N
        }
@@ -313,7 +325,6 @@ public class JobsAdminUserWebRequestBean extends BaseJobsController implements J
 
                // Debug message
                //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("UserWebBean:afterRegistration: registeredUser={0}", registeredUser)); //NOI18N
-
                // Clear all data
                this.clear();
 
index c962011be1af3da38a0edef00a4b40d969b0a601..2040fcd43bba5a157aa27ebe085dc8208af42f19 100644 (file)
@@ -597,37 +597,6 @@ public class JobsUserWebSessionBean extends BaseJobsController implements JobsUs
                        // Initialize user list
                        this.visibleUserList = this.userBean.allPublicUsers();
                }
-
-               // Get all users
-               List<User> allUsers = this.allUsers();
-
-               // Get all contacts
-               List<Contact> allContacts = this.contactBean.getAllContacts();
-
-               // Get iterator
-               Iterator<Contact> iterator = allContacts.iterator();
-
-               // Loop through it
-               while (iterator.hasNext()) {
-                       // Get next element
-                       Contact next = iterator.next();
-
-                       // Get iterator
-                       Iterator<User> userIterator = allUsers.iterator();
-
-                       // Loop through all users
-                       while (userIterator.hasNext()) {
-                               // Get user instance
-                               User nextUser = userIterator.next();
-
-                               // Is contact same?
-                               if (Objects.equals(next, nextUser.getUserContact())) {
-                                       // Found same
-                                       iterator.remove();
-                                       break;
-                               }
-                       }
-               }
        }
 
        @Override
index 19327c8fcf584f92229af72a52ed5287173d15e0..d00e40f1223f6977112cd10e5059a5fbfeb4f922 100644 (file)
                                                                <div class="table_right_medium">
                                                                        <h:selectOneMenu styleClass="select" id="userContact" value="#{beanHelper.contact}" converter="ContactConverter">
                                                                                <f:selectItem itemValue="" itemLabel="#{msg.NONE_SELECTED}" />
-                                                                               <f:selectItems value="#{userController.selectableContacts()}" var="contact" itemValue="#{contact}" itemLabel="#{contact.contactId}: #{msg[contact.contactGender.messageKey]} #{contact.contactFirstName} #{contact.contactFamilyName}" />
+                                                                               <f:selectItems value="#{contactController.selectableContacts()}" var="contact" itemValue="#{contact}" itemLabel="#{contact.contactId}: #{msg[contact.contactGender.messageKey]} #{contact.contactFirstName} #{contact.contactFamilyName}" />
                                                                        </h:selectOneMenu>
                                                                </div>