]> git.mxchange.org Git - jfinancials-war.git/commitdiff
Please cherry-pick/repeat:
authorRoland Häder <roland@mxchange.org>
Sun, 29 Mar 2020 19:00:35 +0000 (21:00 +0200)
committerRoland Häder <roland@mxchange.org>
Sun, 29 Mar 2020 19:00:35 +0000 (21:00 +0200)
- rewrote "contacts-list view" into modern approach, with filters and sorting
- in the progress a ViewScoped backing bean has been added which needs to
  duplicated to all other projects, that handles "jcontacts-core data"

Signed-off-by: Roland Häder <roland@mxchange.org>
src/java/org/mxchange/jfinancials/beans/contact/FinancialsAdminContactWebRequestBean.java
src/java/org/mxchange/jfinancials/beans/contact/FinancialsContactWebRequestBean.java
src/java/org/mxchange/jfinancials/beans/contact/FinancialsContactWebRequestController.java
src/java/org/mxchange/jfinancials/beans/contact/list/FinancialsContactListWebViewBean.java [new file with mode: 0644]
src/java/org/mxchange/jfinancials/beans/contact/list/FinancialsContactListWebViewController.java [new file with mode: 0644]
src/java/org/mxchange/jfinancials/beans/contact/phone/FinancialsContactPhoneWebRequestBean.java
src/java/org/mxchange/jfinancials/converter/contact/FinancialsContactConverter.java
web/admin/contact/admin_contact_list.xhtml
web/admin/fax/admin_fax_show.xhtml
web/admin/user/admin_user_list.xhtml

index eb2c579a5ac7583d2a8b9701f6f74c1951fb48d6..cca45e73a327bd38d897ee10ef9b440753bdcdc3 100644 (file)
@@ -18,7 +18,6 @@ package org.mxchange.jfinancials.beans.contact;
 
 import java.text.MessageFormat;
 import java.util.Date;
-import java.util.Iterator;
 import javax.ejb.EJB;
 import javax.enterprise.context.RequestScoped;
 import javax.enterprise.event.Event;
@@ -41,6 +40,7 @@ import org.mxchange.jcontacts.model.contact.UserContact;
 import org.mxchange.jcontacts.model.contact.title.PersonalTitle;
 import org.mxchange.jcountry.model.data.Country;
 import org.mxchange.jfinancials.beans.BaseFinancialsBean;
+import org.mxchange.jfinancials.beans.contact.list.FinancialsContactListWebViewController;
 import org.mxchange.jphone.model.phonenumbers.DialableNumber;
 import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
 import org.mxchange.jphone.model.phonenumbers.fax.FaxNumber;
@@ -103,12 +103,6 @@ public class FinancialsAdminContactWebRequestBean extends BaseFinancialsBean imp
        @EJB (lookup = "java:global/jfinancials-ejb/contact!org.mxchange.jcontacts.model.contact.ContactSessionBeanRemote")
        private ContactSessionBeanRemote contactBean;
 
-       /**
-        * General contact controller
-        */
-       @Inject
-       private FinancialsContactWebRequestController contactController;
-
        /**
         * Country instance
         */
@@ -119,6 +113,12 @@ public class FinancialsAdminContactWebRequestBean extends BaseFinancialsBean imp
         */
        private Long contactId;
 
+       /**
+        * An instance of a contact list controller
+        */
+       @Inject
+       private FinancialsContactListWebViewController contactListController;
+
        /**
         * Email address
         */
@@ -271,7 +271,7 @@ public class FinancialsAdminContactWebRequestBean extends BaseFinancialsBean imp
                final Contact contact = this.createContactInstance();
 
                // Default is not same contact
-               if (this.isSameContactFound(contact)) {
+               if (this.contactListController.isSameContactFound(contact)) {
                        // Already registered
                        throw new FaceletException(new ContactAlreadyAddedException(contact));
                }
@@ -1086,37 +1086,6 @@ public class FinancialsAdminContactWebRequestBean extends BaseFinancialsBean imp
                this.setComment(null);
        }
 
-       /**
-        * Checks whether the given contact is found
-        * <p>
-        * @param contact Contact instance
-        *
-        * @return Whether contact has been found
-        */
-       private boolean isSameContactFound (final Contact contact) {
-               // Default is not found
-               boolean IsFound = false;
-
-               // Get iterator
-               final Iterator<Contact> iterator = this.contactController.allContacts().iterator();
-
-               // Loop through all
-               while (iterator.hasNext()) {
-                       // Get next contact
-                       final Contact next = iterator.next();
-
-                       // Is the same?
-                       if (Contacts.isSameContact(contact, next)) {
-                               // Yes, then abort loop
-                               IsFound = false;
-                               break;
-                       }
-               }
-
-               // Return status
-               return IsFound;
-       }
-
        /**
         * Updates all data in contact instance.
         * <p>
index 4ca78d274fd064a47e75ecc3b1cd9e1d0b92f555..dbb4ade814182896516328b003223f1d79d5dc7c 100644 (file)
  */
 package org.mxchange.jfinancials.beans.contact;
 
-import fish.payara.cdi.jsr107.impl.NamedCache;
 import java.text.MessageFormat;
 import java.util.Date;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
 import java.util.Objects;
-import javax.annotation.PostConstruct;
-import javax.cache.Cache;
 import javax.ejb.EJB;
 import javax.enterprise.context.RequestScoped;
 import javax.enterprise.event.Observes;
 import javax.faces.view.facelets.FaceletException;
 import javax.inject.Inject;
 import javax.inject.Named;
-import org.mxchange.jcontacts.events.contact.add.ObservableAdminAddedContactEvent;
-import org.mxchange.jcontacts.events.contact.update.ObservableAdminUpdatedContactEvent;
-import org.mxchange.jcontacts.exceptions.ContactNotFoundException;
 import org.mxchange.jcontacts.model.contact.Contact;
 import org.mxchange.jcontacts.model.contact.ContactSessionBeanRemote;
 import org.mxchange.jcontacts.model.contact.Contacts;
@@ -41,7 +32,7 @@ import org.mxchange.jcontacts.model.contact.UserContact;
 import org.mxchange.jcontacts.model.contact.title.PersonalTitle;
 import org.mxchange.jcountry.model.data.Country;
 import org.mxchange.jfinancials.beans.BaseFinancialsBean;
-import org.mxchange.jfinancials.beans.user.FinancialsUserWebRequestController;
+import org.mxchange.jfinancials.beans.contact.list.FinancialsContactListWebViewController;
 import org.mxchange.jfinancials.beans.user.login.FinancialsUserLoginWebSessionController;
 import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
 import org.mxchange.jphone.model.phonenumbers.fax.FaxNumber;
@@ -52,10 +43,7 @@ import org.mxchange.jphone.model.phonenumbers.mobile.MobileNumber;
 import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider;
 import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent;
 import org.mxchange.jusercore.events.user.linked.ObservableAdminLinkedUserEvent;
-import org.mxchange.jusercore.model.user.User;
-import org.mxchange.juserlogincore.events.confirmation.ObservableUserConfirmedAccountEvent;
 import org.mxchange.juserlogincore.events.login.ObservableUserLoggedInEvent;
-import org.mxchange.juserlogincore.events.registration.ObservableUserRegisteredEvent;
 import org.mxchange.juserlogincore.exceptions.UserPasswordMismatchException;
 
 /**
@@ -99,11 +87,9 @@ public class FinancialsContactWebRequestBean extends BaseFinancialsBean implemen
        private ContactSessionBeanRemote contactBean;
 
        /**
-        * Contact list
+        * An instance of a contact-list backing bean
         */
-       @Inject
-       @NamedCache (cacheName = "contactCache")
-       private Cache<Long, Contact> contactCache;
+       private FinancialsContactListWebViewController contactListController;
 
        /**
         * Country instance
@@ -115,13 +101,6 @@ public class FinancialsContactWebRequestBean extends BaseFinancialsBean implemen
         */
        private String emailAddress;
 
-       /**
-        * Email address list
-        */
-       @Inject
-       @NamedCache (cacheName = "emailAddressCache")
-       private Cache<Long, String> emailAddressCache;
-
        /**
         * Email address repeated
         */
@@ -207,24 +186,11 @@ public class FinancialsContactWebRequestBean extends BaseFinancialsBean implemen
         */
        private PersonalTitle personalTitle;
 
-       /**
-        * A list of all selectable contacts
-        */
-       @Inject
-       @NamedCache (cacheName = "selectableContactsCache")
-       private Cache<Long, Contact> selectableContactsCache;
-
        /**
         * Street
         */
        private String street;
 
-       /**
-        * Regular user controller
-        */
-       @Inject
-       private FinancialsUserWebRequestController userController;
-
        /**
         * Login bean (controller)
         */
@@ -244,38 +210,6 @@ public class FinancialsContactWebRequestBean extends BaseFinancialsBean implemen
                super();
        }
 
-       /**
-        * Observes events being fired when an administrator has added a new
-        * contact.
-        * <p>
-        * @param event Event being fired
-        */
-       public void afterAdminAddedContactEvent (@Observes final ObservableAdminAddedContactEvent event) {
-               // The event must be valid
-               if (null == event) {
-                       // Throw NPE
-                       throw new NullPointerException("event is null"); //NOI18N
-               } else if (event.getAddedContact() == null) {
-                       // Throw again ...
-                       throw new NullPointerException("event.addedContact is null"); //NOI18N
-               } else if (event.getAddedContact().getContactId() == null) {
-                       // ... and again
-                       throw new NullPointerException("event.addedContact.contactId is null"); //NOI18N
-               } else if (event.getAddedContact().getContactId() < 1) {
-                       // Not valid
-                       throw new IllegalArgumentException(MessageFormat.format("event.addedContact.contactId={0} is not valid", event.getAddedContact().getContactId())); //NOI18N //NOI18N
-               }
-
-               // Clear this bean
-               this.clear();
-
-               // Call other method
-               this.uniqueAddContact(event.getAddedContact());
-
-               // Add to selectable contacts
-               this.selectableContactsCache.put(event.getAddedContact().getContactId(), event.getAddedContact());
-       }
-
        /**
         * Event observer for newly added users by administrator
         * <p>
@@ -326,66 +260,10 @@ public class FinancialsContactWebRequestBean extends BaseFinancialsBean implemen
                        throw new IllegalArgumentException(MessageFormat.format("contactId of contact={0} is not valid: {1}", event.getLinkedUser(), event.getLinkedUser().getUserContact().getContactId())); //NOI18N
                }
 
-               // Remove contact from list available contacts list
-               this.selectableContactsCache.remove(event.getLinkedUser().getUserContact().getContactId());
-
                // Clear all data
                this.clear();
        }
 
-       /**
-        * Event observer for updated contact data by administrators
-        * <p>
-        * @param event Updated contact data event
-        */
-       public void afterAdminUpdatedContactDataEvent (@Observes final ObservableAdminUpdatedContactEvent event) {
-               // event should not be null
-               if (null == event) {
-                       // Throw NPE
-                       throw new NullPointerException("event is null"); //NOI18N
-               } else if (event.getUpdatedContact() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("event.updatedContact is null"); //NOI18N
-               } else if (event.getUpdatedContact().getContactId() == null) {
-                       // userId is null
-                       throw new NullPointerException("event.updatedContact.contactId is null"); //NOI18N
-               } else if (event.getUpdatedContact().getContactId() < 1) {
-                       // Not avalid id
-                       throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getUpdatedContact(), event.getUpdatedContact().getContactId())); //NOI18N
-               }
-
-               // Add contact instance only once
-               this.uniqueAddContact(event.getUpdatedContact());
-
-               // Add email address to list
-               this.emailAddressCache.put(event.getUpdatedContact().getContactId(), event.getUpdatedContact().getContactEmailAddress());
-       }
-
-       /**
-        * Event observer when user confirmed account.
-        * <p>
-        * @param event Event being fired
-        */
-       public void afterUserConfirmedAccount (@Observes final ObservableUserConfirmedAccountEvent event) {
-               // event should not be null
-               if (null == event) {
-                       // Throw NPE
-                       throw new NullPointerException("event is null"); //NOI18N
-               } else if (event.getConfirmedUser() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("event.confirmedUser is null"); //NOI18N
-               } else if (event.getConfirmedUser().getUserId() == null) {
-                       // userId is null
-                       throw new NullPointerException("event.confirmedUser.userId is null"); //NOI18N
-               } else if (event.getConfirmedUser().getUserId() < 1) {
-                       // Not avalid id
-                       throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getConfirmedUser(), event.getConfirmedUser().getUserId())); //NOI18N
-               }
-
-               // Add contact instance only once
-               this.uniqueAddContact(event.getConfirmedUser().getUserContact());
-       }
-
        /**
         * Event observer for logged-in user
         * <p>
@@ -411,65 +289,6 @@ public class FinancialsContactWebRequestBean extends BaseFinancialsBean implemen
                this.copyContact(event.getLoggedInUser().getUserContact());
        }
 
-       /**
-        * Event observer for new user registrations
-        * <p>
-        * @param event User registration event
-        */
-       public void afterUserRegistrationEvent (@Observes final ObservableUserRegisteredEvent event) {
-               // event should not be null
-               if (null == event) {
-                       // Throw NPE
-                       throw new NullPointerException("event is null"); //NOI18N
-               } else if (event.getRegisteredUser() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("event.registeredUser is null"); //NOI18N
-               } else if (event.getRegisteredUser().getUserId() == null) {
-                       // userId is null
-                       throw new NullPointerException("event.registeredUser.userId is null"); //NOI18N
-               } else if (event.getRegisteredUser().getUserId() < 1) {
-                       // Not avalid id
-                       throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getRegisteredUser(), event.getRegisteredUser().getUserId())); //NOI18N
-               }
-
-               // Get user instance
-               final Contact registeredContact = event.getRegisteredUser().getUserContact();
-
-               // Copy all data from registered->user
-               this.copyContact(registeredContact);
-
-               // Add contact instance only once
-               this.uniqueAddContact(registeredContact);
-
-               // Add user name and email address
-               this.addUserNameEmailAddress(registeredContact);
-
-               // Clear all data
-               this.clear();
-       }
-
-       @Override
-       @SuppressWarnings ("ReturnOfCollectionOrArrayField")
-       public List<Contact> allContacts () {
-               // Init list
-               final List<Contact> list = new LinkedList<>();
-
-               // Get iterator
-               final Iterator<Cache.Entry<Long, Contact>> iterator = this.contactCache.iterator();
-
-               // Loop over all
-               while (iterator.hasNext()) {
-                       // Get next entry
-                       final Cache.Entry<Long, Contact> next = iterator.next();
-
-                       // Add value to list
-                       list.add(next.getValue());
-               }
-
-               // Return it
-               return list;
-       }
-
        @Override
        public void clearEmailAddresses () {
                // Clear both
@@ -616,27 +435,6 @@ public class FinancialsContactWebRequestBean extends BaseFinancialsBean implemen
                return "contact_data_saved"; //NOI18N
        }
 
-       @Override
-       public Contact findContactById (final Long contactId) throws ContactNotFoundException {
-               // Validate parameter
-               if (null == contactId) {
-                       // Throw NPE
-                       throw new NullPointerException("contactId is null"); //NOI18N
-               } else if (contactId < 1) {
-                       // Throw IAE
-                       throw new IllegalArgumentException("contactId=" + contactId + " is invalid"); //NOI18N
-               } else if (!this.contactCache.containsKey(contactId)) {
-                       // Not found
-                       throw new ContactNotFoundException(contactId);
-               }
-
-               // Get it from cache
-               final Contact contact = this.contactCache.get(contactId);
-
-               // Return it
-               return contact;
-       }
-
        /**
         * Getter for academic title
         * <p>
@@ -1043,64 +841,6 @@ public class FinancialsContactWebRequestBean extends BaseFinancialsBean implemen
                this.zipCode = zipCode;
        }
 
-       /**
-        * Post-construction method
-        */
-       @PostConstruct
-       public void init () {
-               // Is cache there?
-               if (!this.contactCache.iterator().hasNext()) {
-                       // Get whole list from EJB
-                       final List<Contact> contacts = this.contactBean.allContacts();
-
-                       // Add all
-                       for (final Contact contact : contacts) {
-                               // Add it to cache
-                               this.contactCache.put(contact.getContactId(), contact);
-
-                               // Is email address given?
-                               if (contact.getContactEmailAddress() != null) {
-                                       // Set it, too
-                                       this.emailAddressCache.put(contact.getContactId(), contact.getContactEmailAddress());
-                               }
-                       }
-               } else if (this.selectableContactsCache.iterator().hasNext()) {
-                       // Has already entries, avoid executing below code
-                       return;
-               }
-
-               // Get all users
-               final List<User> allUsers = this.userController.allUsers();
-
-               // Get iterator from contacts cache
-               final Iterator<Cache.Entry<Long, Contact>> iterator = this.contactCache.iterator();
-
-               // Loop through all contacts
-               while (iterator.hasNext()) {
-                       // Get next element
-                       final Cache.Entry<Long, Contact> next = iterator.next();
-
-                       // Default is not found
-                       boolean isFound = false;
-
-                       // User list is not empty, check each entry, if contact is found
-                       for (final User user : allUsers) {
-                               // Is the contact the same?
-                               if (Objects.equals(user.getUserContact(), next.getValue())) {
-                                       // Found one
-                                       isFound = true;
-                                       break;
-                               }
-                       }
-
-                       // Is contact not found?
-                       if (!isFound) {
-                               // Add it as selectable
-                               this.selectableContactsCache.put(next.getKey(), next.getValue());
-                       }
-               }
-       }
-
        @Override
        public boolean isEmailAddressRegistered (final Contact contact) {
                // Cherck parameter
@@ -1115,8 +855,23 @@ public class FinancialsContactWebRequestBean extends BaseFinancialsBean implemen
                        throw new IllegalArgumentException("contact.contactEmailAddress is empty."); //NOI18N
                }
 
+               // Default is not registered
+               boolean isRegistered = false;
+
                // Determine it
-               return ((this.emailAddressCache instanceof List) && (this.emailAddressCache.containsKey(contact.getContactId())));
+               for (final Contact currentContact : this.contactListController.getAllContacts()) {
+                       // Is same contact found?
+                       if (currentContact.getContactEmailAddress().equals(contact.getContactEmailAddress())) {
+                               // Found same email address
+                               isRegistered = true;
+
+                               // Skipp further iterations
+                               break;
+                       }
+               }
+
+               // Return status
+               return isRegistered;
        }
 
        @Override
@@ -1153,32 +908,6 @@ public class FinancialsContactWebRequestBean extends BaseFinancialsBean implemen
                return (Objects.equals(this.getEmailAddress(), this.getEmailAddressRepeat()));
        }
 
-       /**
-        * Returns a list of all selectable contacts for user creation. Contacts
-        * from already existing users are excluded in this list.
-        * <p>
-        * @return A list of all selectable contacts
-        */
-       public List<Contact> selectableContacts () {
-               // Init list
-               final List<Contact> selectableContacts = new LinkedList<>();
-
-               // Get iterator from cache
-               final Iterator<Cache.Entry<Long, Contact>> iterator = this.contactCache.iterator();
-
-               // Loop through all contacts
-               while (iterator.hasNext()) {
-                       // Get next element
-                       final Cache.Entry<Long, Contact> next = iterator.next();
-
-                       // Add entry's value to list
-                       selectableContacts.add(next.getValue());
-               }
-
-               // Return list
-               return selectableContacts;
-       }
-
        @Override
        public void updateContactDataFromController (final Contact contact) {
                // Is the instance valid?
@@ -1197,22 +926,6 @@ public class FinancialsContactWebRequestBean extends BaseFinancialsBean implemen
                this.copyContact(contact);
        }
 
-       /**
-        * Adds email address to bean's internal list.
-        * <p>
-        * @param contact Contact instance
-        */
-       private void addUserNameEmailAddress (final Contact contact) {
-               // Make sure the entry is not added yet
-               if (this.emailAddressCache.containsKey(contact.getContactId())) {
-                       // Already added
-                       throw new IllegalArgumentException(MessageFormat.format("Email address {0} already added.", contact.getContactEmailAddress())); //NOI18N
-               }
-
-               // Add email addres
-               this.emailAddressCache.put(contact.getContactId(), contact.getContactEmailAddress());
-       }
-
        /**
         * Clears this bean
         */
@@ -1292,47 +1005,4 @@ public class FinancialsContactWebRequestBean extends BaseFinancialsBean implemen
                }
        }
 
-       /**
-        * Removes given contact from all lists
-        * <p>
-        * @param contact Contact instance to remove
-        */
-       private void removeContact (final Contact contact) {
-               // Remove from general list
-               if (!this.contactCache.remove(contact.getContactId())) {
-                       // Did not remove contact
-                       throw new IllegalStateException(MessageFormat.format("contact {0} was not removed.", contact.getContactId())); //NOI18N
-               }
-
-               // Remove from other lists
-               this.emailAddressCache.remove(contact.getContactId());
-       }
-
-       /**
-        * Adds unique instance to contact list. First any existing instance is
-        * being removed, then the new instance is added.
-        * <p>
-        * @param contact Contact instance to add uniquely
-        */
-       private void uniqueAddContact (final Contact contact) {
-               // Get iterator from list
-               final Iterator<Cache.Entry<Long, Contact>> iterator = this.contactCache.iterator();
-
-               // "Walk" through all entries
-               while (iterator.hasNext()) {
-                       // Get next element
-                       final Cache.Entry<Long, Contact> next = iterator.next();
-
-                       // Is id number the same?
-                       if (Objects.equals(contact.getContactId(), next.getKey())) {
-                               // Found entry, so remove it and abort
-                               this.removeContact(next.getValue());
-                               break;
-                       }
-               }
-
-               // Add contact to list
-               this.contactCache.put(contact.getContactId(), contact);
-       }
-
 }
index b50031080c1f36ed15f506695759265210d654bf..a164d11587294fcdcf864988cb1b2c0f6eb309ef 100644 (file)
@@ -17,8 +17,6 @@
 package org.mxchange.jfinancials.beans.contact;
 
 import java.io.Serializable;
-import java.util.List;
-import org.mxchange.jcontacts.exceptions.ContactNotFoundException;
 import org.mxchange.jcontacts.model.contact.Contact;
 
 /**
@@ -45,13 +43,6 @@ public interface FinancialsContactWebRequestController extends Serializable {
         */
        void clearEmailAddresses ();
 
-       /**
-        * Returns a list of all found contacts
-        * <p>
-        * @return A list of all contacts.
-        */
-       List<Contact> allContacts ();
-
        /**
         * Updates all data from bean in given contact instance
         * <p>
@@ -121,17 +112,6 @@ public interface FinancialsContactWebRequestController extends Serializable {
         */
        String doChangePersonalContactData ();
 
-       /**
-        * Returns a contact instance which has the given id number.
-        * <p>
-        * @param contactId Contact id
-        * <p>
-        * @return Contact instance
-        * <p>
-        * @throws ContactNotFoundException If the contact was not found
-        */
-       Contact findContactById (final Long contactId) throws ContactNotFoundException;
-
        /**
         * Checks whether the given email address is already registered. The email
         * address should be validated by EmailAddressValidator before calling this
diff --git a/src/java/org/mxchange/jfinancials/beans/contact/list/FinancialsContactListWebViewBean.java b/src/java/org/mxchange/jfinancials/beans/contact/list/FinancialsContactListWebViewBean.java
new file mode 100644 (file)
index 0000000..d4edde2
--- /dev/null
@@ -0,0 +1,429 @@
+/*
+ * Copyright (C) 2016 - 2020 Free Software Foundation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jfinancials.beans.contact.list;
+
+import fish.payara.cdi.jsr107.impl.NamedCache;
+import java.text.MessageFormat;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Objects;
+import javax.annotation.PostConstruct;
+import javax.cache.Cache;
+import javax.ejb.EJB;
+import javax.enterprise.event.Observes;
+import javax.faces.view.ViewScoped;
+import javax.inject.Inject;
+import javax.inject.Named;
+import org.mxchange.jcontacts.events.contact.add.ObservableAdminAddedContactEvent;
+import org.mxchange.jcontacts.events.contact.update.ObservableAdminUpdatedContactEvent;
+import org.mxchange.jcontacts.exceptions.ContactNotFoundException;
+import org.mxchange.jcontacts.model.contact.Contact;
+import org.mxchange.jcontacts.model.contact.ContactSessionBeanRemote;
+import org.mxchange.jcontacts.model.contact.Contacts;
+import org.mxchange.jfinancials.beans.BaseFinancialsBean;
+import org.mxchange.jphone.model.phonenumbers.DialableNumber;
+import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber;
+import org.mxchange.juserlogincore.events.confirmation.ObservableUserConfirmedAccountEvent;
+import org.mxchange.juserlogincore.events.registration.ObservableUserRegisteredEvent;
+
+/**
+ * A regular contact list bean (controller)
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("contactListController")
+@ViewScoped
+public class FinancialsContactListWebViewBean extends BaseFinancialsBean implements FinancialsContactListWebViewController {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 542_145_347_917L;
+
+       /**
+        * All contacts
+        */
+       private final List<Contact> allContacts;
+
+       /**
+        * Administrative contact EJB
+        */
+       @EJB (lookup = "java:global/jfinancials-ejb/contact!org.mxchange.jcontacts.model.contact.ContactSessionBeanRemote")
+       private ContactSessionBeanRemote contactBean;
+
+       /**
+        * Contact list
+        */
+       @Inject
+       @NamedCache (cacheName = "contactCache")
+       private transient Cache<Long, Contact> contactCache;
+
+       /**
+        * A list of filtered contacts
+        */
+       private List<Contact> filteredContacts;
+
+       /**
+        * Current selected contact
+        */
+       private Contact selectedContact;
+
+       /**
+        * Default constructor
+        */
+       public FinancialsContactListWebViewBean () {
+               // Call super constructor
+               super();
+
+               // Init list
+               this.allContacts = new LinkedList<>();
+       }
+
+       /**
+        * Observes events being fired when an administrator has added a new
+        * contact.
+        * <p>
+        * @param event Event being fired
+        */
+       public void afterAdminAddedContactEvent (@Observes final ObservableAdminAddedContactEvent event) {
+               // The event must be valid
+               if (null == event) {
+                       // Throw NPE
+                       throw new NullPointerException("event is null"); //NOI18N
+               } else if (event.getAddedContact() == null) {
+                       // Throw again ...
+                       throw new NullPointerException("event.addedContact is null"); //NOI18N
+               } else if (event.getAddedContact().getContactId() == null) {
+                       // ... and again
+                       throw new NullPointerException("event.addedContact.contactId is null"); //NOI18N
+               } else if (event.getAddedContact().getContactId() < 1) {
+                       // Not valid
+                       throw new IllegalArgumentException(MessageFormat.format("event.addedContact.contactId={0} is not valid", event.getAddedContact().getContactId())); //NOI18N //NOI18N
+               }
+
+               // Call other method
+               this.uniqueAddContact(event.getAddedContact());
+       }
+
+       /**
+        * Event observer for updated contact data by administrators
+        * <p>
+        * @param event Updated contact data event
+        */
+       public void afterAdminUpdatedContactDataEvent (@Observes final ObservableAdminUpdatedContactEvent event) {
+               // event should not be null
+               if (null == event) {
+                       // Throw NPE
+                       throw new NullPointerException("event is null"); //NOI18N
+               } else if (event.getUpdatedContact() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("event.updatedContact is null"); //NOI18N
+               } else if (event.getUpdatedContact().getContactId() == null) {
+                       // userId is null
+                       throw new NullPointerException("event.updatedContact.contactId is null"); //NOI18N
+               } else if (event.getUpdatedContact().getContactId() < 1) {
+                       // Not avalid id
+                       throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getUpdatedContact(), event.getUpdatedContact().getContactId())); //NOI18N
+               }
+
+               // Add contact instance only once
+               this.uniqueAddContact(event.getUpdatedContact());
+       }
+
+       /**
+        * Event observer when user confirmed account.
+        * <p>
+        * @param event Event being fired
+        */
+       public void afterUserConfirmedAccount (@Observes final ObservableUserConfirmedAccountEvent event) {
+               // event should not be null
+               if (null == event) {
+                       // Throw NPE
+                       throw new NullPointerException("event is null"); //NOI18N
+               } else if (event.getConfirmedUser() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("event.confirmedUser is null"); //NOI18N
+               } else if (event.getConfirmedUser().getUserId() == null) {
+                       // userId is null
+                       throw new NullPointerException("event.confirmedUser.userId is null"); //NOI18N
+               } else if (event.getConfirmedUser().getUserId() < 1) {
+                       // Not avalid id
+                       throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getConfirmedUser(), event.getConfirmedUser().getUserId())); //NOI18N
+               }
+
+               // Add contact instance only once
+               this.uniqueAddContact(event.getConfirmedUser().getUserContact());
+       }
+
+       /**
+        * Event observer for new user registrations
+        * <p>
+        * @param event User registration event
+        */
+       public void afterUserRegistrationEvent (@Observes final ObservableUserRegisteredEvent event) {
+               // event should not be null
+               if (null == event) {
+                       // Throw NPE
+                       throw new NullPointerException("event is null"); //NOI18N
+               } else if (event.getRegisteredUser() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("event.registeredUser is null"); //NOI18N
+               } else if (event.getRegisteredUser().getUserId() == null) {
+                       // userId is null
+                       throw new NullPointerException("event.registeredUser.userId is null"); //NOI18N
+               } else if (event.getRegisteredUser().getUserId() < 1) {
+                       // Not avalid id
+                       throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getRegisteredUser(), event.getRegisteredUser().getUserId())); //NOI18N
+               }
+
+               // Get user instance
+               final Contact registeredContact = event.getRegisteredUser().getUserContact();
+
+               // Add contact instance only once
+               this.uniqueAddContact(registeredContact);
+       }
+
+       @Override
+       public Contact findContactById (final Long contactId) throws ContactNotFoundException {
+               // Validate parameter
+               if (null == contactId) {
+                       // Throw NPE
+                       throw new NullPointerException("contactId is null"); //NOI18N
+               } else if (contactId < 1) {
+                       // Throw IAE
+                       throw new IllegalArgumentException("contactId=" + contactId + " is invalid"); //NOI18N
+               } else if (!this.contactCache.containsKey(contactId)) {
+                       // Not found
+                       throw new ContactNotFoundException(contactId);
+               }
+
+               // Get it from cache
+               final Contact contact = this.contactCache.get(contactId);
+
+               // Return it
+               return contact;
+       }
+
+       /**
+        * Returns a text representation of given mobile number or null if not set.
+        * <p>
+        * @param mobileNumber Mobile number
+        * <p>
+        * @return Text representation or null
+        */
+       public String generateMobileNumber (final DialableMobileNumber mobileNumber) {
+               // Is it null?
+               if (null == mobileNumber) {
+                       // Return null
+                       return null;
+               }
+
+               // Get all data
+               final String number = String.format(
+                                        "%s%d%d", //NOI18N
+                                        mobileNumber.getMobileProvider().getProviderCountry().getCountryExternalDialPrefix(),
+                                        mobileNumber.getMobileProvider().getProviderDialPrefix(),
+                                        mobileNumber.getPhoneNumber()
+                        );
+
+               // Return it
+               return number;
+       }
+
+       /**
+        * Returns a text representation of given land-line or fax number or null if
+        * not set.
+        * <p>
+        * @param phoneNumber Land-line or fax number
+        * <p>
+        * @return Text representation or null
+        */
+       public String generatePhoneNumber (final DialableNumber phoneNumber) {
+               // Is it null?
+               if (null == phoneNumber) {
+                       // Return null
+                       return null;
+               }
+
+               // Generate it
+               final String number = String.format(
+                                        "%s%d%d", //NOI18N
+                                        phoneNumber.getPhoneCountry().getCountryExternalDialPrefix(),
+                                        phoneNumber.getPhoneAreaCode(),
+                                        phoneNumber.getPhoneNumber()
+                        );
+
+               // Return it
+               return number;
+       }
+
+       @Override
+       @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+       public List<Contact> getAllContacts () {
+               return this.allContacts;
+       }
+
+       /**
+        * Getter for filtered contacts
+        * <p>
+        * @return
+        */
+       @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+       public List<Contact> getFilteredContacts () {
+               return this.filteredContacts;
+       }
+
+       /**
+        * Setter for filtered contacts
+        * <p>
+        * @param filteredContacts Filtered contacts list
+        */
+       @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter")
+       public void setFilteredContacts (final List<Contact> filteredContacts) {
+               this.filteredContacts = filteredContacts;
+       }
+
+       /**
+        * Getter for selected contact
+        * <p>
+        * @return Selected Contact instance
+        */
+       public Contact getSelectedContact () {
+               return this.selectedContact;
+       }
+
+       /**
+        * Setter for selected contact
+        * <p>
+        * @param selectedContact
+        */
+       public void setSelectedContact (final Contact selectedContact) {
+               this.selectedContact = selectedContact;
+       }
+
+       /**
+        * Post-construction method
+        */
+       @PostConstruct
+       public void init () {
+               // Is cache there?
+               if (!this.contactCache.iterator().hasNext()) {
+                       // Get whole list from EJB
+                       final List<Contact> contacts = this.contactBean.allContacts();
+
+                       // Add all
+                       for (final Contact contact : contacts) {
+                               // Add it to cache
+                               this.contactCache.put(contact.getContactId(), contact);
+                       }
+               }
+
+               // Is cache there and list is not full?
+               if ((this.getAllContacts().isEmpty()) && (this.contactCache.iterator().hasNext())) {
+                       // Get iterator
+                       final Iterator<Cache.Entry<Long, Contact>> iterator = this.contactCache.iterator();
+
+                       // Build up list
+                       while (iterator.hasNext()) {
+                               // GEt next element
+                               final Cache.Entry<Long, Contact> next = iterator.next();
+
+                               // Add to list
+                               this.getAllContacts().add(next.getValue());
+                       }
+
+                       // Sort list
+                       this.getAllContacts().sort(new Comparator<Contact>() {
+                               @Override
+                               public int compare (final Contact o1, final Contact o2) {
+                                       return o1.getContactId() > o2.getContactId() ? 1 : o1.getContactId() < o2.getContactId() ? -1 : 0;
+                               }
+                       });
+
+                       // Set full list
+                       this.setFilteredContacts(this.getAllContacts());
+               }
+       }
+
+       @Override
+       public boolean isSameContactFound (final Contact contact) {
+               // Default is not found
+               boolean IsFound = false;
+
+               // Get iterator
+               final Iterator<Contact> iterator = this.getAllContacts().iterator();
+
+               // Loop through all
+               while (iterator.hasNext()) {
+                       // Get next contact
+                       final Contact next = iterator.next();
+
+                       // Is the same?
+                       if (Contacts.isSameContact(contact, next)) {
+                               // Yes, then abort loop
+                               IsFound = false;
+                               break;
+                       }
+               }
+
+               // Return status
+               return IsFound;
+       }
+
+       /**
+        * Removes given contact from all lists
+        * <p>
+        * @param contact Contact instance to remove
+        */
+       private void removeContact (final Contact contact) {
+               // Remove from general list
+               if (!this.contactCache.remove(contact.getContactId())) {
+                       // Did not remove contact
+                       throw new IllegalStateException(MessageFormat.format("contact {0} was not removed.", contact.getContactId())); //NOI18N
+               }
+       }
+
+       /**
+        * Adds unique instance to contact list. First any existing instance is
+        * being removed, then the new instance is added.
+        * <p>
+        * @param contact Contact instance to add uniquely
+        */
+       private void uniqueAddContact (final Contact contact) {
+               // Get iterator from list
+               final Iterator<Cache.Entry<Long, Contact>> iterator = this.contactCache.iterator();
+
+               // "Walk" through all entries
+               while (iterator.hasNext()) {
+                       // Get next element
+                       final Cache.Entry<Long, Contact> next = iterator.next();
+
+                       // Is id number the same?
+                       if (Objects.equals(contact.getContactId(), next.getKey())) {
+                               // Found entry, so remove it and abort
+                               this.removeContact(next.getValue());
+                               break;
+                       }
+               }
+
+               // Add contact to list
+               this.contactCache.put(contact.getContactId(), contact);
+       }
+
+}
diff --git a/src/java/org/mxchange/jfinancials/beans/contact/list/FinancialsContactListWebViewController.java b/src/java/org/mxchange/jfinancials/beans/contact/list/FinancialsContactListWebViewController.java
new file mode 100644 (file)
index 0000000..51d3346
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2016 - 2020 Free Software Foundation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jfinancials.beans.contact.list;
+
+import java.io.Serializable;
+import java.util.List;
+import org.mxchange.jcontacts.exceptions.ContactNotFoundException;
+import org.mxchange.jcontacts.model.contact.Contact;
+
+/**
+ * An administrative interface for user beans
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface FinancialsContactListWebViewController extends Serializable {
+
+       /**
+        * Returns a contact instance which has the given id number.
+        * <p>
+        * @param contactId Contact id
+        * <p>
+        * @return Contact instance
+        * <p>
+        * @throws ContactNotFoundException If the contact was not found
+        */
+       Contact findContactById (final Long contactId) throws ContactNotFoundException;
+
+       /**
+        * Checks whether the given contact is found
+        * <p>
+        * @param contact Contact instance
+        *
+        * @return Whether contact has been found
+        */
+       boolean isSameContactFound (final Contact contact);
+
+       /**
+        * Getter for all contacts
+        *
+        * @return All contact
+        */
+       @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+       List<Contact> getAllContacts ();
+
+}
index 54805fe22fe865561e9d9e77a1505bacce83e7cb..1be5d85e542508bfe03442d36fd82efa155090c0 100644 (file)
@@ -33,7 +33,7 @@ import org.mxchange.jcontacts.events.landline.unlinked.ObservableAdminUnlinkedLa
 import org.mxchange.jcontacts.events.mobile.unlinked.ObservableAdminUnlinkedMobileNumberEvent;
 import org.mxchange.jcontacts.model.contact.Contact;
 import org.mxchange.jfinancials.beans.BaseFinancialsBean;
-import org.mxchange.jfinancials.beans.contact.FinancialsContactWebRequestController;
+import org.mxchange.jfinancials.beans.contact.list.FinancialsContactListWebViewController;
 import org.mxchange.jphone.events.fax.created.ObservableCreatedFaxNumberEvent;
 import org.mxchange.jphone.events.landline.created.ObservableCreatedLandLineNumberEvent;
 import org.mxchange.jphone.events.mobile.created.ObservableCreatedMobileNumberEvent;
@@ -58,10 +58,10 @@ public class FinancialsContactPhoneWebRequestBean extends BaseFinancialsBean imp
        private static final long serialVersionUID = 542_145_347_916L;
 
        /**
-        * General contact controller
+        * An instance of a contact-list controller
         */
        @Inject
-       private FinancialsContactWebRequestController contactController;
+       private FinancialsContactListWebViewController contactListController;
 
        /**
         * "Cache" for contact's mobile, land-line and fax numbers. Currently one
@@ -338,7 +338,7 @@ public class FinancialsContactPhoneWebRequestBean extends BaseFinancialsBean imp
         * <p>
         * @return List of all linked contacts
         */
-       public List<Contact> allCurrentFaxNumberContacts () {
+       public List<Contact> getAllCurrentFaxNumberContacts () {
                // Get id
                final DialableFaxNumber number = this.getFaxNumber();
 
@@ -351,7 +351,7 @@ public class FinancialsContactPhoneWebRequestBean extends BaseFinancialsBean imp
                        final List<Contact> list = new LinkedList<>();
 
                        // "Walk" through all contacts
-                       for (final Contact contact : this.contactController.allContacts()) {
+                       for (final Contact contact : this.contactListController.getAllContacts()) {
                                // Is mobile instance the same?
                                if (Objects.equals(contact.getContactFaxNumber(), number)) {
                                        // Found one
@@ -385,7 +385,7 @@ public class FinancialsContactPhoneWebRequestBean extends BaseFinancialsBean imp
                        final List<Contact> list = new LinkedList<>();
 
                        // "Walk" through all contacts
-                       for (final Contact contact : this.contactController.allContacts()) {
+                       for (final Contact contact : this.contactListController.getAllContacts()) {
                                // Is mobile instance the same?
                                if (Objects.equals(contact.getContactLandLineNumber(), number)) {
                                        // Found one
@@ -419,7 +419,7 @@ public class FinancialsContactPhoneWebRequestBean extends BaseFinancialsBean imp
                        final List<Contact> list = new LinkedList<>();
 
                        // "Walk" through all contacts
-                       for (final Contact contact : this.contactController.allContacts()) {
+                       for (final Contact contact : this.contactListController.getAllContacts()) {
                                // Is mobile instance the same?
                                if (Objects.equals(contact.getContactMobileNumber(), number)) {
                                        // Found one
index e619ea314fcb751527d997ab05c6d44870507118..752483757e640122e482a2adb16785b083fa21df 100644 (file)
@@ -24,8 +24,8 @@ import javax.faces.convert.ConverterException;
 import javax.faces.convert.FacesConverter;
 import org.mxchange.jcontacts.exceptions.ContactNotFoundException;
 import org.mxchange.jcontacts.model.contact.Contact;
-import org.mxchange.jfinancials.beans.contact.FinancialsContactWebRequestBean;
-import org.mxchange.jfinancials.beans.contact.FinancialsContactWebRequestController;
+import org.mxchange.jfinancials.beans.contact.list.FinancialsContactListWebViewBean;
+import org.mxchange.jfinancials.beans.contact.list.FinancialsContactListWebViewController;
 
 /**
  * Converter for contact id <-> valid contact instance
@@ -38,14 +38,14 @@ public class FinancialsContactConverter implements Converter<Contact> {
        /**
         * Contact EJB
         */
-       private static FinancialsContactWebRequestController CONTACT_CONTROLLER;
+       private static FinancialsContactListWebViewController CONTACT_LIST_CONTROLLER;
 
        @Override
        public Contact getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
                // Is the instance there?
-               if (null == CONTACT_CONTROLLER) {
+               if (null == CONTACT_LIST_CONTROLLER) {
                        // Get bean from CDI directly
-                       CONTACT_CONTROLLER = CDI.current().select(FinancialsContactWebRequestBean.class).get();
+                       CONTACT_LIST_CONTROLLER = CDI.current().select(FinancialsContactListWebViewBean.class).get();
                }
 
                // Is the value null or empty?
@@ -65,7 +65,7 @@ public class FinancialsContactConverter implements Converter<Contact> {
                        final Long contactId = Long.valueOf(submittedValue);
 
                        // Try to get user instance from it
-                       contact = CONTACT_CONTROLLER.findContactById(contactId);
+                       contact = CONTACT_LIST_CONTROLLER.findContactById(contactId);
                } catch (final NumberFormatException ex) {
                        // Throw again
                        throw new ConverterException(ex);
index eec56139a8cbc0ca5906853d78d6bc267a725b0d..15ce96640b363958847c6216f6466f81f05011c7 100644 (file)
                        <p:dataTable
                                id="contactList"
                                var="contact"
-                               value="#{contactController.allContacts()}"
+                               value="#{contactListController.allContacts}"
                                paginator="true"
+                               paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
+                               filteredValue="#{contactListController.filteredContacts}"
                                rows="10"
+                               rowKey="#{contact.contactId}"
+                               reflow="true"
+                               resizableColumns="true"
+                               rowsPerPageTemplate="5,10,20,50,100"
+                               sortMode="multiple"
                                summary="#{msg.TABLE_SUMMARY_ADMIN_LIST_CONTACT}"
                                emptyMessage="#{msg.ADMIN_EMPTY_LIST_CONTACT}"
                                widgetVar="contactList"
+                               selectionMode="single"
+                               selection="#{contactListController.selectedContact}"
+                               skipChildren="true"
                                >
-                               <p:column>
-                                       <f:facet name="header">
-                                               <h:outputText value="#{msg.ADMIN_CONTACT_ID}" />
-                                       </f:facet>
 
+                               <f:facet name="header">
+                                       <p:panelGrid
+                                               columns="3"
+                                               layout="grid"
+                                               columnClasses="ui-grid-col-4,ui-grid-col-6,ui-grid-col-2"
+                                               >
+                                               <p:spacer />
+
+                                               <p:panelGrid
+                                                       columns="2"
+                                                       columnClasses="ui-grid-4,ui-grid-8"
+                                                       layout="grid"
+                                                       styleClass="ui-noborder"
+                                                       >
+                                                       <p:outputLabel for="globalFilter" value="#{msg.SEARCH_ALL_FIELDS}" style="float: right" />
+                                                       <p:inputText id="globalFilter" onkeyup="PF('contactList').filter()" placeholder="#{msg.ENTER_KEYWORD}"/>
+                                               </p:panelGrid>
+
+                                               <p:outputPanel>
+                                                       <p:spacer height="4" />
+
+                                                       <p:commandButton
+                                                               id="toggler"
+                                                               type="button"
+                                                               value="#{msg.SELECT_SHOWN_COLUMNS}"
+                                                               styleClass="column-selector"
+                                                               />
+
+                                                       <p:columnToggler datasource="contactList" trigger="toggler" />
+                                               </p:outputPanel>
+                                       </p:panelGrid>
+                               </f:facet>
+
+                               <p:ajax
+                                       event="rowSelect"
+                                       update=":master:form-list-contacts:contact-details"
+                                       oncomplete="PF('contactDialog').show()"
+                                       />
+
+                               <p:column
+                                       headerText="#{msg.ID_HEADER}"
+                                       sortBy="#{contact.contactId}"
+                                       filterable="false"
+                                       >
                                        <p:link
                                                outcome="admin_show_contact"
                                                value="#{contact.contactId}"
                                        </p:link>
                                </p:column>
 
-                               <p:column>
-                                       <f:facet name="header">
-                                               <h:outputText value="#{msg.ADMIN_CONTACT_PERSONAL_TITLE}" />
+                               <p:column
+                                       headerText="#{msg.ADMIN_CONTACT_PERSONAL_TITLE}"
+                                       sortBy="#{contact.contactPersonalTitle}"
+                                       filterBy="#{contact.contactPersonalTitle}"
+                                       filterMatchMode="exact"
+                                       >
+                                       <f:facet name="filter">
+                                               <p:selectOneMenu onchange="PF('contactList').filter()">
+                                                       <f:converter converterId="PersonalTitleConverter" />
+                                                       <f:selectItem itemLabel="#{msg.CHOICE_ALL}" itemValue="#{null}" />
+                                                       <f:selectItems
+                                                               value="#{dataController.personalTitles}"
+                                                               var="personalTitle"
+                                                               itemValue="#{personalTitle}"
+                                                               itemLabel="#{msg[personalTitle.messageKey]}"
+                                                               />
+                                               </p:selectOneMenu>
                                        </f:facet>
-
                                        <h:outputText value="#{msg[contact.contactPersonalTitle.messageKey]}" />
                                </p:column>
 
-                               <p:column>
-                                       <f:facet name="header">
-                                               <h:outputText value="#{msg.ADMIN_CONTACT_FIRST_NAME}" />
-                                       </f:facet>
-
+                               <p:column
+                                       headerText="#{msg.ADMIN_CONTACT_FIRST_NAME}"
+                                       sortBy="#{contact.contactFirstName}"
+                                       filterBy="#{contact.contactFirstName}"
+                                       filterMatchMode="contains"
+                                       >
                                        <h:outputText value="#{contact.contactFirstName}" />
                                </p:column>
 
-                               <p:column>
-                                       <f:facet name="header">
-                                               <h:outputText value="#{msg.ADMIN_CONTACT_FAMILY_NAME}" />
-                                       </f:facet>
-
+                               <p:column
+                                       headerText="#{msg.ADMIN_CONTACT_FAMILY_NAME}"
+                                       sortBy="#{contact.contactFamilyName}"
+                                       filterBy="#{contact.contactFamilyName}"
+                                       filterMatchMode="contains"
+                                       >
                                        <h:outputText value="#{contact.contactFamilyName}" />
                                </p:column>
 
-                               <p:column>
-                                       <f:facet name="header">
-                                               <h:outputText value="#{msg.ADMIN_CONTACT_USAGE}" />
-                                       </f:facet>
-
+                               <p:column
+                                       headerText="#{msg.ADMIN_CONTACT_USAGE}"
+                                       sortable="false"
+                                       filterable="false"
+                                       >
                                        <h:outputText value="#{msg[beanHelper.getContactUsageMessageKey(contact)]}" />
                                </p:column>
 
-                               <p:column>
-                                       <f:facet name="header">
-                                               <h:outputText value="#{msg.ENTRY_CREATED_HEADER}" />
-                                       </f:facet>
-
+                               <p:column
+                                       headerText="#{msg.ENTRY_CREATED_HEADER}"
+                                       sortBy="#{contact.contactCreated}"
+                                       filterBy="#{contact.contactCreated}"
+                                       filterMatchMode="contains"
+                                       >
                                        <h:outputText id="contactCreated" value="#{contact.contactCreated}">
                                                <f:convertDateTime type="both" timeStyle="short" dateStyle="short" />
                                        </h:outputText>
                                </p:column>
 
-                               <p:column>
-                                       <f:facet name="header">
-                                               <h:outputText value="#{msg.ADMIN_ACTION_LINKS_HEADER}" />
-                                       </f:facet>
-
+                               <p:column
+                                       headerText="#{msg.ADMIN_ACTION_LINKS_HEADER}"
+                                       sortable="false"
+                                       filterable="false"
+                                       >
                                        <links:outputContactAdminDropdownMenu contact="#{contact}" />
                                </p:column>
                        </p:dataTable>
+
+                       <p:dialog
+                               dynamic="true"
+                               modal="true"
+                               resizable="false"
+                               header="#{msg.ADMIN_SINGLE_CONTACT_DETAILS_HEADER}"
+                               hideEffect="fade"
+                               showEffect="fade"
+                               widgetVar="contactDialog"
+                               position="top"
+                               responsive="true"
+                               closeOnEscape="true"
+                               >
+                               <p:outputPanel id="contact-details">
+                                       <p:panelGrid columns="2" rendered="#{not empty contactListController.selectedContact}">
+                                               <f:facet name="header">
+                                                       <h:outputFormat value="#{msg.ADMIN_CONTACT_DETAILS_HEADER}">
+                                                               <f:param value="#{contactListController.selectedContact.companyName}" />
+                                                               <f:param value="#{contactListController.selectedContact.contactId}" />
+                                                       </h:outputFormat>
+                                               </f:facet>
+
+                                               <p:outputLabel value="#{msg.ID_HEADER}" title="#{msg.CONTACT_ID_NUMBER_TITLE}" />
+                                               <h:outputText value="#{contactListController.selectedContact.contactId}" />
+                                       </p:panelGrid>
+                               </p:outputPanel>
+                       </p:dialog>
                </h:form>
 
                <h:form>
index 32e13320cee4392163e0fe3b6b335cad244ff87e..1c52c3ed9237b9400f5d2fa268b5cf5785084652 100644 (file)
@@ -30,7 +30,7 @@
                <p:dataTable
                        id="contact_fax_link"
                        var="contact"
-                       value="#{contactPhoneController.allCurrentFaxNumberContacts()}"
+                       value="#{contactPhoneController.allCurrentFaxNumberContacts}"
                        summary="#{msg.TABLE_SUMMARY_ADMIN_SHOW_ADMINISTRATIVE_LINKS}"
                        >
                        <f:facet name="header">
index eeda9a552b22ddf9a9aa802c6a2f673fb9ebc90c..f99488b072ecd00cce0b679d83093f0dd110b326 100644 (file)
                                                        <f:converter converterId="ContactConverter" />
 
                                                        <f:selectItems
-                                                               value="#{contactController.selectableContacts()}"
+                                                               value="#{contactListController.allContacts}"
                                                                var="contact"
                                                                itemValue="#{contact}"
                                                                itemLabel="#{beanHelper.renderContact(contact)}"