]> git.mxchange.org Git - pizzaservice-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>
Sat, 16 Sep 2017 14:37:49 +0000 (16:37 +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/localization/bundle_de_DE.properties
src/java/org/mxchange/localization/bundle_en_US.properties
src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebRequestBean.java
src/java/org/mxchange/pizzaapplication/converter/business/basicdata/PizzaBasicCompanyDataConverter.java
web/WEB-INF/faces-config.xml
web/WEB-INF/templates/admin/admin_menu.tpl

index 67b48249af4c28cdc7121e5668f87b16fe8a7b61..30d41a8c7fec8cfe80244896652ff181a1014319 100644 (file)
@@ -784,8 +784,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 4da1b87523eb8e74ae01e9a665446e356e7f5d39..ced58b6d13e1206e0cae8ccd543e609d153215b1 100644 (file)
@@ -775,8 +775,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 9be93736e86212c3d9be30dcbd4edcb055313390..41f93b1d61b1c5757816262d5b57ea08466cee0f 100644 (file)
@@ -18,7 +18,6 @@ package org.mxchange.pizzaapplication.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 PizzaContactWebRequestBean extends BasePizzaController implements P
        /**
         * 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 PizzaContactWebRequestBean extends BasePizzaController implements P
                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 PizzaContactWebRequestBean extends BasePizzaController implements P
                }
 
                // 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 PizzaContactWebRequestBean extends BasePizzaController implements P
         */
        @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 PizzaContactWebRequestBean extends BasePizzaController implements P
         * @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 599f85435917959eb0b5afffa458ec19a759d80b..91254c0928ad0618962a79ddfa87c599320447c9 100644 (file)
@@ -26,6 +26,7 @@ import javax.faces.validator.ValidatorException;
 import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
+import org.mxchange.jcontactsbusiness.exceptions.basicdata.BasicCompanyDataNotFoundException;
 import org.mxchange.jcontactsbusiness.model.basicdata.BasicCompanyDataSessionBeanRemote;
 import org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData;
 
index 132b9be4ba0d9baccf443dd9b06beb81e2d9de69..c6cb418f715a1f5139086bdf85c58ee807c35e06 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 ad674c34b1e8343d9b4b33b6ba6420af5f915c45..90b5b17a2aacb28ef3bf5faf4d993551225e3ebc 100644 (file)
@@ -50,7 +50,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>