From: Roland Häder Date: Tue, 12 Sep 2017 19:18:42 +0000 (+0200) Subject: Please cherry-pick: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=3cfee54687e99de66b89ec8d87ff78430aad7b54;p=pizzaservice-war.git Please cherry-pick: - 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 --- diff --git a/src/java/org/mxchange/localization/bundle_de_DE.properties b/src/java/org/mxchange/localization/bundle_de_DE.properties index 67b48249..30d41a8c 100644 --- a/src/java/org/mxchange/localization/bundle_de_DE.properties +++ b/src/java/org/mxchange/localization/bundle_de_DE.properties @@ -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 diff --git a/src/java/org/mxchange/localization/bundle_en_US.properties b/src/java/org/mxchange/localization/bundle_en_US.properties index 4da1b875..ced58b6d 100644 --- a/src/java/org/mxchange/localization/bundle_en_US.properties +++ b/src/java/org/mxchange/localization/bundle_en_US.properties @@ -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. diff --git a/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebRequestBean.java b/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebRequestBean.java index 9be93736..41f93b1d 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebRequestBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebRequestBean.java @@ -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 selectableContacts; + @Inject + @NamedCache (cacheName = "selectableContactsCache") + private Cache 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 selectable = new LinkedList<>(); - // Is cache there? if (!this.contactsCache.iterator().hasNext()) { // Get whole list - List list = this.contactBean.allContacts(); + final List contacts = this.contactBean.allContacts(); // Add all - for (final Iterator 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 allUsers = this.userController.allUsers(); + final List allUsers = this.userController.allUsers(); - // Get iterator - Iterator iterator = selectable.iterator(); + // Get iterator from contacts cache + final Iterator> iterator = this.contactsCache.iterator(); - // Loop through it + // Loop through all contacts while (iterator.hasNext()) { // Get next element - Contact next = iterator.next(); - - // Get iterator - Iterator userIterator = allUsers.iterator(); + final Cache.Entry 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 selectableContacts () { - return Collections.unmodifiableList(this.selectableContacts); + // Init list + final List selectableContacts = new LinkedList<>(); + + // Get iterator from cache + final Iterator> iterator = this.contactsCache.iterator(); + + // Loop through all contacts + while (iterator.hasNext()) { + // Get next element + final Cache.Entry next = iterator.next(); + + // Add entry's value to list + selectableContacts.add(next.getValue()); + } + + // Return list + return selectableContacts; } @Override diff --git a/src/java/org/mxchange/pizzaapplication/converter/business/basicdata/PizzaBasicCompanyDataConverter.java b/src/java/org/mxchange/pizzaapplication/converter/business/basicdata/PizzaBasicCompanyDataConverter.java index 599f8543..91254c09 100644 --- a/src/java/org/mxchange/pizzaapplication/converter/business/basicdata/PizzaBasicCompanyDataConverter.java +++ b/src/java/org/mxchange/pizzaapplication/converter/business/basicdata/PizzaBasicCompanyDataConverter.java @@ -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; diff --git a/web/WEB-INF/faces-config.xml b/web/WEB-INF/faces-config.xml index 132b9be4..c6cb418f 100644 --- a/web/WEB-INF/faces-config.xml +++ b/web/WEB-INF/faces-config.xml @@ -112,10 +112,6 @@ admin_list_basic_company_data /admin/basic_company_data/admin_basic_company_data_list.xhtml - - admin_export_basic_company_data - /admin/basic_company_data/admin_basic_company_data_export.xhtml - admin_list_branch_offices /admin/branch_offices/admin_branch_offices_list.xhtml diff --git a/web/WEB-INF/templates/admin/admin_menu.tpl b/web/WEB-INF/templates/admin/admin_menu.tpl index ad674c34..90b5b17a 100644 --- a/web/WEB-INF/templates/admin/admin_menu.tpl +++ b/web/WEB-INF/templates/admin/admin_menu.tpl @@ -50,7 +50,6 @@
  • -