]> git.mxchange.org Git - addressbook-war.git/commitdiff
Please cherry-pick:
authorRoland Häder <roland@mxchange.org>
Tue, 12 Sep 2017 19:18:42 +0000 (21:18 +0200)
committerRoland Häder <roland@mxchange.org>
Tue, 12 Sep 2017 22:47:10 +0000 (00:47 +0200)
- removed export of basic company data, one day, an other approach rather than
  "single entity" export will maybe come

Signed-off-by: Roland Häder <roland@mxchange.org>
src/java/org/mxchange/addressbook/beans/business/basicdata/AddressbookAdminBusinessDataWebRequestBean.java
src/java/org/mxchange/addressbook/beans/contact/AddressbookContactWebRequestBean.java
src/java/org/mxchange/addressbook/converter/business/basicdata/AddressbookBusinessContactConverter.java
src/java/org/mxchange/localization/bundle_de_DE.properties
src/java/org/mxchange/localization/bundle_en_US.properties
web/WEB-INF/faces-config.xml
web/WEB-INF/templates/admin/admin_menu.tpl

index ff365ab94d59ae81b45fee1cf15079f0a689864b..8bcd570c361723c86b83e7d549520761e225ef4e 100644 (file)
@@ -26,7 +26,7 @@ import javax.inject.Named;
 import org.mxchange.addressbook.beans.BaseAddressbookController;
 import org.mxchange.jcontactsbusiness.events.basicdata.added.AdminAddedBusinessBasicDataEvent;
 import org.mxchange.jcontactsbusiness.events.basicdata.added.ObservableAdminAddedBusinessBasicDataEvent;
-import org.mxchange.jcontactsbusiness.exceptions.basicdata.BusinessDataAlreadyAddedException;
+import org.mxchange.jcontactsbusiness.exceptions.basicdata.BasicCompanyDataAlreadyAddedException;
 import org.mxchange.jcontactsbusiness.model.basicdata.AdminBasicCompanyDataSessionBeanRemote;
 import org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData;
 import org.mxchange.jcontactsbusiness.model.basicdata.CompanyBasicData;
@@ -232,7 +232,7 @@ public class AddressbookAdminBusinessDataWebRequestBean extends BaseAddressbookC
 
                        // Fire event
                        this.businessDataAddedEvent.fire(new AdminAddedBusinessBasicDataEvent(updatedBasicData));
-               } catch (final BusinessDataAlreadyAddedException e) {
+               } catch (final BasicCompanyDataAlreadyAddedException e) {
                        // Does already exist
                        throw new FacesException(e);
                }
index 24a6bcd855053d27819219b91ee197e1f5c22dff..39b3a48e7793cd14020afc7c301a7c71c13e6831 100644 (file)
@@ -18,7 +18,6 @@ package org.mxchange.addressbook.beans.contact;
 
 import fish.payara.cdi.jsr107.impl.NamedCache;
 import java.text.MessageFormat;
-import java.util.Collections;
 import java.util.Date;
 import java.util.Iterator;
 import java.util.LinkedList;
@@ -210,7 +209,9 @@ public class AddressbookContactWebRequestBean extends BaseAddressbookController
        /**
         * A list of all selectable contacts
         */
-       private List<Contact> selectableContacts;
+       @Inject
+       @NamedCache (cacheName = "selectableContactsCache")
+       private Cache<Long, Contact> selectableContactsCache;
 
        /**
         * Street
@@ -271,7 +272,7 @@ public class AddressbookContactWebRequestBean extends BaseAddressbookController
                this.uniqueAddContact(event.getAddedContact());
 
                // Add to selectable contacts
-               this.selectableContacts.add(event.getAddedContact());
+               this.selectableContactsCache.put(event.getAddedContact().getContactId(), event.getAddedContact());
        }
 
        /**
@@ -325,7 +326,7 @@ public class AddressbookContactWebRequestBean extends BaseAddressbookController
                }
 
                // Remove contact from list available contacts list
-               this.selectableContacts.remove(event.getLinkedUser().getUserContact());
+               this.selectableContactsCache.remove(event.getLinkedUser().getUserContact().getContactId());
 
                // Clear all data
                this.clear();
@@ -1025,56 +1026,52 @@ public class AddressbookContactWebRequestBean extends BaseAddressbookController
         */
        @PostConstruct
        public void init () {
-               // Get all contacts
-               final List<Contact> selectable = new LinkedList<>();
-
                // Is cache there?
                if (!this.contactsCache.iterator().hasNext()) {
                        // Get whole list
-                       List<Contact> list = this.contactBean.allContacts();
+                       final List<Contact> contacts = this.contactBean.allContacts();
 
                        // Add all
-                       for (final Iterator<Contact> iterator = list.iterator(); iterator.hasNext();) {
-                               // Get next element
-                               final Contact next = iterator.next();
-
+                       for (final Contact contact : contacts) {
                                // Add it to cache
-                               this.contactsCache.put(next.getContactId(), next);
-                               this.emailAddressCache.put(next.getContactId(), next.getContactEmailAddress());
-                               selectable.add(next);
+                               this.contactsCache.put(contact.getContactId(), contact);
+                               this.emailAddressCache.put(contact.getContactId(), contact.getContactEmailAddress());
                        }
+               } else if (this.selectableContactsCache.iterator().hasNext()) {
+                       // Has already entries, avoid executing below code
+                       return;
                }
 
                // Get all users
-               List<User> allUsers = this.userController.allUsers();
+               final List<User> allUsers = this.userController.allUsers();
 
-               // Get iterator
-               Iterator<Contact> iterator = selectable.iterator();
+               // Get iterator from contacts cache
+               final Iterator<Cache.Entry<Long, Contact>> iterator = this.contactsCache.iterator();
 
-               // Loop through it
+               // Loop through all contacts
                while (iterator.hasNext()) {
                        // Get next element
-                       Contact next = iterator.next();
-
-                       // Get iterator
-                       Iterator<User> userIterator = allUsers.iterator();
+                       final Cache.Entry<Long, Contact> next = iterator.next();
 
-                       // Loop through all users
-                       while (userIterator.hasNext()) {
-                               // Get user instance
-                               User nextUser = userIterator.next();
+                       // Default is not found
+                       boolean isFound = false;
 
-                               // Is contact same?
-                               if (Objects.equals(next, nextUser.getUserContact())) {
-                                       // Found same
-                                       iterator.remove();
+                       // 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;
                                }
                        }
-               }
 
-               // Set contact list
-               this.selectableContacts = selectable;
+                       // Is contact not found?
+                       if (!isFound) {
+                               // Add it as selectable
+                               this.selectableContactsCache.put(next.getKey(), next.getValue());
+                       }
+               }
        }
 
        @Override
@@ -1131,7 +1128,23 @@ public class AddressbookContactWebRequestBean extends BaseAddressbookController
         * @return A list of all selectable contacts
         */
        public List<Contact> selectableContacts () {
-               return Collections.unmodifiableList(this.selectableContacts);
+               // Init list
+               final List<Contact> selectableContacts = new LinkedList<>();
+
+               // Get iterator from cache
+               final Iterator<Cache.Entry<Long, Contact>> iterator = this.contactsCache.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
index e718939da9eb511ddb60184c49adaf31ed7e1379..f5cc9a9fd03737377f49d7c64a3106e08898aa79 100644 (file)
@@ -26,9 +26,9 @@ import javax.faces.validator.ValidatorException;
 import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
-import org.mxchange.jcontactsbusiness.exceptions.basicdata.BusinessDataNotFoundException;
 import org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData;
 import org.mxchange.jcontactsbusiness.model.basicdata.BasicCompanyDataSessionBeanRemote;
+import org.mxchange.jcontactsbusiness.exceptions.basicdata.BasicCompanyDataNotFoundException;
 
 /**
  * Converter for contact id <-> valid business contact instance
@@ -80,7 +80,7 @@ public class AddressbookBusinessContactConverter implements Converter<BusinessBa
                } catch (final NumberFormatException ex) {
                        // Throw again
                        throw new ConverterException(ex);
-               } catch (final BusinessDataNotFoundException ex) {
+               } catch (final BasicCompanyDataNotFoundException ex) {
                        // Debug message
                        // @TODO Not working with JNDI (no remote interface) this.loggerBeanLocal.logDebug(MessageFormat.format("{0}.getAsObject(): Exception: {1} - Returning null ...", this.getClass().getSimpleName(), ex)); //NOI18N
                }
index eb5d18fcbc30ba9cb42832e28710070f89daa421..adfecb2e878ea0803ff3d3048b70138c8fa9a77c 100644 (file)
@@ -836,8 +836,6 @@ PAGE_TITLE_ADMIN_AREA=Administration
 ADMIN_MENU_BUSINESS_CONTACTS_TITLE=Geschaeftliche Kontakte
 LINK_ADMIN_LIST_BASIC_COMPANY_DATA=Stammdaten auflisten
 LINK_ADMIN_LIST_BASIC_COMPANY_DATA_TITLE=Listet Stammdaten auf
-LINK_ADMIN_EXPORT_BASIC_COMPANY_DATA=Stammdaten exportieren
-LINK_ADMIN_EXPORT_BASIC_COMPANY_DATA_TITLE=Exportiert Stammdaten
 PAGE_TITLE_ADMIN_LIST_BASIC_COMPANY_DATA=Stammdaten auflisten
 #@TODO Please fix German umlauts!
 CONTENT_TITLE_ADMIN_LIST_BASIC_COMPANY_DATA=Auflisten von Stammdaten
index cfb8e99c502e653ef57458f41a7b3655ef70baed..84536f2e7a2eb13f9d1d8603b94f15b5c9dfb2c4 100644 (file)
@@ -827,8 +827,6 @@ PAGE_TITLE_ADMIN_AREA=Administration
 ADMIN_MENU_BUSINESS_CONTACTS_TITLE=Business contacts
 LINK_ADMIN_LIST_BASIC_COMPANY_DATA=List basic company data
 LINK_ADMIN_LIST_BASIC_COMPANY_DATA_TITLE=Lists basic company data
-LINK_ADMIN_EXPORT_BASIC_COMPANY_DATA=Export basic company data
-LINK_ADMIN_EXPORT_BASIC_COMPANY_DATA_TITLE=Exports basic company data
 PAGE_TITLE_ADMIN_LIST_BASIC_COMPANY_DATA=List basic company data
 CONTENT_TITLE_ADMIN_LIST_BASIC_COMPANY_DATA=Lists basic company data
 ADMIN_BASIC_COMPANY_DATA_LIST_EMPTY=There are currently no basic company data in database.
index 35ec8402a8ff066edd19cfcb10d11bc9b4e7deba..a8e21edb0e9baf339654ace14467f610706b2832 100644 (file)
                        <from-outcome>admin_list_basic_company_data</from-outcome>
                        <to-view-id>/admin/basic_company_data/admin_basic_company_data_list.xhtml</to-view-id>
                </navigation-case>
-               <navigation-case>
-                       <from-outcome>admin_export_basic_company_data</from-outcome>
-                       <to-view-id>/admin/basic_company_data/admin_basic_company_data_export.xhtml</to-view-id>
-               </navigation-case>
                <navigation-case>
                        <from-outcome>admin_list_branch_offices</from-outcome>
                        <to-view-id>/admin/branch_offices/admin_branch_offices_list.xhtml</to-view-id>
index 8da86ec589dc79e924adfc85dba55040a50b023f..e980a3771eeab208a3a12fef3ed8db07abb3bc72 100644 (file)
@@ -40,7 +40,6 @@
 
                                <ul>
                                        <li><h:link title="#{msg.LINK_ADMIN_LIST_BASIC_COMPANY_DATA_TITLE}" outcome="admin_list_basic_company_data" value="#{msg.LINK_ADMIN_LIST_BASIC_COMPANY_DATA}" /></li>
-                                       <li><h:link title="#{msg.LINK_ADMIN_EXPORT_BASIC_COMPANY_DATA_TITLE}" outcome="admin_export_basic_company_data" value="#{msg.LINK_ADMIN_EXPORT_BASIC_COMPANY_DATA}" /></li>
                                        <li><h:link title="#{msg.LINK_ADMIN_LIST_BRANCH_OFFICES_TITLE}" outcome="admin_list_branch_offices" value="#{msg.LINK_ADMIN_LIST_BRANCH_OFFICES}" /></li>
                                </ul>
                        </ui:fragment>