]> git.mxchange.org Git - jjobs-war.git/commitdiff
Please cherry-pick:
authorRoland Häder <roland@mxchange.org>
Wed, 1 Apr 2020 18:24:20 +0000 (20:24 +0200)
committerRoland Häder <roland@mxchange.org>
Thu, 2 Apr 2020 16:43:09 +0000 (18:43 +0200)
- rewrote admin-countries-list view to more modern approach with filters and
  sorting
- rewrote many while(iterator) implementations to use for(item:List/Map.Entry)
  instead
- added some missing i18n keys

Signed-off-by: Roland Häder <roland@mxchange.org>
24 files changed:
src/java/org/mxchange/jjobs/beans/business/basicdata/list/JobsBasicDataListWebViewBean.java
src/java/org/mxchange/jjobs/beans/business/branchoffice/list/JobsBranchOfficeListWebViewBean.java
src/java/org/mxchange/jjobs/beans/business/department/JobsDepartmentWebRequestBean.java
src/java/org/mxchange/jjobs/beans/business/employee/JobsEmployeeWebRequestBean.java
src/java/org/mxchange/jjobs/beans/business/headquarter/JobsHeadquarterWebRequestBean.java
src/java/org/mxchange/jjobs/beans/business/opening_time/JobsOpeningTimeWebRequestBean.java
src/java/org/mxchange/jjobs/beans/contact/list/JobsContactListWebViewBean.java
src/java/org/mxchange/jjobs/beans/country/JobsAdminCountryWebRequestBean.java
src/java/org/mxchange/jjobs/beans/country/JobsCountryWebRequestBean.java
src/java/org/mxchange/jjobs/beans/country/JobsCountryWebRequestController.java
src/java/org/mxchange/jjobs/beans/country/list/JobsCountryListWebViewBean.java [new file with mode: 0644]
src/java/org/mxchange/jjobs/beans/country/list/JobsCountryListWebViewController.java [new file with mode: 0644]
src/java/org/mxchange/jjobs/beans/mobileprovider/JobsMobileProviderWebRequestBean.java
src/java/org/mxchange/jjobs/beans/phone/JobsPhoneWebRequestBean.java
src/java/org/mxchange/jjobs/beans/user/JobsUserWebRequestBean.java
src/java/org/mxchange/jjobs/beans/user/confirmlink/JobsConfirmationLinkWebRequestBean.java
src/java/org/mxchange/jjobs/beans/user/email_address/JobsEmailChangeWebRequestBean.java
src/java/org/mxchange/jjobs/converter/country/JobsCountryConverter.java
src/java/org/mxchange/localization/generic_de_DE.properties
src/java/org/mxchange/localization/generic_en_US.properties
web/WEB-INF/resources/tags/admin/columns/admin_contact_data_columns.tpl
web/WEB-INF/templates/contact/form_contact_data.tpl
web/admin/basic_data/admin_basic_data_list.xhtml
web/admin/country/admin_country_list.xhtml

index 1d64bb1efa10bdc6f1bfb85850863b9cab7724d7..026cf1f5689449bfa64327113d497013351d9fa3 100644 (file)
@@ -19,7 +19,6 @@ package org.mxchange.jjobs.beans.business.basicdata.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;
@@ -210,23 +209,17 @@ public class JobsBasicDataListWebViewBean extends BaseJobsBean implements JobsBa
 
                // Is cache there and list is not full?
                if ((this.getAllBasicData().isEmpty()) && (this.basicDataCache.iterator().hasNext())) {
-                       // Get iterator
-                       final Iterator<Cache.Entry<Long, BasicData>> iterator = this.basicDataCache.iterator();
-
                        // Build up list
-                       while (iterator.hasNext()) {
-                               // GEt next element
-                               final Cache.Entry<Long, BasicData> next = iterator.next();
-
+                       for (final Cache.Entry<Long, BasicData> currentEntry : this.basicDataCache) {
                                // Add to list
-                               this.getAllBasicData().add(next.getValue());
+                               this.getAllBasicData().add(currentEntry.getValue());
                        }
 
                        // Sort list
                        this.getAllBasicData().sort(new Comparator<BasicData>() {
                                @Override
-                               public int compare (final BasicData o1, final BasicData o2) {
-                                       return o1.getBasicDataId() > o2.getBasicDataId() ? 1 : o1.getBasicDataId() < o2.getBasicDataId() ? -1 : 0;
+                               public int compare (final BasicData basicData1, final BasicData basicData2) {
+                                       return basicData1.getBasicDataId() > basicData2.getBasicDataId() ? 1 : basicData1.getBasicDataId() < basicData2.getBasicDataId() ? -1 : 0;
                                }
                        });
 
index 7318093653d180487effec89777054a3572dcc25..fdd1a08be5da90f65c92481853171bfec3ecfd79 100644 (file)
@@ -19,7 +19,6 @@ package org.mxchange.jjobs.beans.business.branchoffice.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;
@@ -203,23 +202,17 @@ public class JobsBranchOfficeListWebViewBean extends BaseJobsBean implements Job
 
                // Is the list empty, but filled cache?
                if (this.allBranchOffices.isEmpty() && this.branchOfficeCache.iterator().hasNext()) {
-                       // Get iterator
-                       final Iterator<Cache.Entry<Long, BranchOffice>> iterator = this.branchOfficeCache.iterator();
-
                        // Build up list
-                       while (iterator.hasNext()) {
-                               // GEt next element
-                               final Cache.Entry<Long, BranchOffice> next = iterator.next();
-
+                       for (final Cache.Entry<Long, BranchOffice> currentEntry : this.branchOfficeCache) {
                                // Add to list
-                               this.allBranchOffices.add(next.getValue());
+                               this.allBranchOffices.add(currentEntry.getValue());
                        }
 
                        // Sort list
                        this.allBranchOffices.sort(new Comparator<BranchOffice>() {
                                @Override
-                               public int compare (final BranchOffice o1, final BranchOffice o2) {
-                                       return o1.getBranchId() > o2.getBranchId() ? 1 : o1.getBranchId() < o2.getBranchId() ? -1 : 0;
+                               public int compare (final BranchOffice branchOffice1, final BranchOffice branchOffice2) {
+                                       return branchOffice1.getBranchId() > branchOffice2.getBranchId() ? 1 : branchOffice1.getBranchId() < branchOffice2.getBranchId() ? -1 : 0;
                                }
                        });
                }
index 09da5b80b35cfc1fe596df0d3c2d3319a029260e..84a8283cf3251ea553a810c51f2327c0d93e58a7 100644 (file)
@@ -19,7 +19,6 @@ package org.mxchange.jjobs.beans.business.department;
 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 javax.annotation.PostConstruct;
@@ -179,23 +178,17 @@ public class JobsDepartmentWebRequestBean extends BaseJobsBean implements JobsDe
 
                // Is the list empty, but filled cache?
                if (this.allDepartments.isEmpty() && this.departmentCache.iterator().hasNext()) {
-                       // Get iterator
-                       final Iterator<Cache.Entry<Long, Department>> iterator = this.departmentCache.iterator();
-
                        // Build up list
-                       while (iterator.hasNext()) {
-                               // GEt next element
-                               final Cache.Entry<Long, Department> next = iterator.next();
-
+                       for (final Cache.Entry<Long, Department> currentEntry : this.departmentCache) {
                                // Add to list
-                               this.allDepartments.add(next.getValue());
+                               this.allDepartments.add(currentEntry.getValue());
                        }
 
                        // Sort list
                        this.allDepartments.sort(new Comparator<Department>() {
                                @Override
-                               public int compare (final Department o1, final Department o2) {
-                                       return o1.getDepartmentId() > o2.getDepartmentId() ? 1 : o1.getDepartmentId() < o2.getDepartmentId() ? -1 : 0;
+                               public int compare (final Department department1, final Department department2) {
+                                       return department1.getDepartmentId() > department2.getDepartmentId() ? 1 : department1.getDepartmentId() < department2.getDepartmentId() ? -1 : 0;
                                }
                        });
                }
index b276e9bb99a35202600203c849c5dd2221d0a868..275fb527255889f69e24ee3f20b6c605b2ba7fc3 100644 (file)
@@ -19,7 +19,6 @@ package org.mxchange.jjobs.beans.business.employee;
 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;
@@ -176,23 +175,17 @@ public class JobsEmployeeWebRequestBean extends BaseJobsBean implements JobsEmpl
 
                // Is cache filled and list is empty
                if ((this.employeeCache.iterator().hasNext()) && (this.allEmployees.isEmpty())) {
-                       // Get iterator
-                       final Iterator<Cache.Entry<Long, Employable>> iterator = this.employeeCache.iterator();
-
                        // Build up list
-                       while (iterator.hasNext()) {
-                               // GEt next element
-                               final Cache.Entry<Long, Employable> next = iterator.next();
-
+                       for (final Cache.Entry<Long, Employable> currentEntry : this.employeeCache) {
                                // Add to list
-                               this.allEmployees.add(next.getValue());
+                               this.allEmployees.add(currentEntry.getValue());
                        }
 
                        // Sort list
                        this.allEmployees.sort(new Comparator<Employable>() {
                                @Override
-                               public int compare (final Employable o1, final Employable o2) {
-                                       return o1.getEmployeeId() > o2.getEmployeeId() ? 1 : o1.getEmployeeId() < o2.getEmployeeId() ? -1 : 0;
+                               public int compare (final Employable employee1, final Employable employee2) {
+                                       return employee1.getEmployeeId() > employee2.getEmployeeId() ? 1 : employee1.getEmployeeId() < employee2.getEmployeeId() ? -1 : 0;
                                }
                        });
                }
index 10fab4f600b3535ca4d8078cbbe71f4ea951a8c8..dc43b6d5d440a49e8639812dd8a121f891f455d6 100644 (file)
@@ -19,7 +19,6 @@ package org.mxchange.jjobs.beans.business.headquarter;
 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;
@@ -180,23 +179,17 @@ public class JobsHeadquarterWebRequestBean extends BaseJobsBean implements JobsH
 
                // Is the list empty, but filled cache?
                if (this.allHeadquarter.isEmpty() && this.headquarterCache.iterator().hasNext()) {
-                       // Get iterator
-                       final Iterator<Cache.Entry<Long, Headquarter>> iterator = this.headquarterCache.iterator();
-
                        // Build up list
-                       while (iterator.hasNext()) {
-                               // GEt next element
-                               final Cache.Entry<Long, Headquarter> next = iterator.next();
-
+                       for (final Cache.Entry<Long, Headquarter> currentEntry : this.headquarterCache) {
                                // Add to list
-                               this.allHeadquarter.add(next.getValue());
+                               this.allHeadquarter.add(currentEntry.getValue());
                        }
 
                        // Sort list
                        this.allHeadquarter.sort(new Comparator<Headquarter>() {
                                @Override
-                               public int compare (final Headquarter o1, final Headquarter o2) {
-                                       return o1.getHeadquarterId() > o2.getHeadquarterId() ? 1 : o1.getHeadquarterId() < o2.getHeadquarterId() ? -1 : 0;
+                               public int compare (final Headquarter headquarter1, final Headquarter headquarter2) {
+                                       return headquarter1.getHeadquarterId() > headquarter2.getHeadquarterId() ? 1 : headquarter1.getHeadquarterId() < headquarter2.getHeadquarterId() ? -1 : 0;
                                }
                        });
                }
index 6fa7f434fdf3b1675d1899546b53f6ecc8aa250b..cfd1a0533542877ff9c2d548889036d11434cbaa 100644 (file)
@@ -19,7 +19,6 @@ package org.mxchange.jjobs.beans.business.opening_time;
 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 javax.annotation.PostConstruct;
@@ -175,23 +174,17 @@ public class JobsOpeningTimeWebRequestBean extends BaseJobsBean implements JobsO
 
                // Is the list empty, but filled cache?
                if (this.allOpeningTimes.isEmpty() && this.openingTimesCache.iterator().hasNext()) {
-                       // Get iterator
-                       final Iterator<Cache.Entry<Long, OpeningTime>> iterator = this.openingTimesCache.iterator();
-
                        // Build up list
-                       while (iterator.hasNext()) {
-                               // GEt next element
-                               final Cache.Entry<Long, OpeningTime> next = iterator.next();
-
+                       for (final Cache.Entry<Long, OpeningTime> currentEntry : this.openingTimesCache) {
                                // Add to list
-                               this.allOpeningTimes.add(next.getValue());
+                               this.allOpeningTimes.add(currentEntry.getValue());
                        }
 
                        // Sort list
                        this.allOpeningTimes.sort(new Comparator<OpeningTime>() {
                                @Override
-                               public int compare (final OpeningTime o1, final OpeningTime o2) {
-                                       return o1.getOpeningId() > o2.getOpeningId() ? 1 : o1.getOpeningId() < o2.getOpeningId() ? -1 : 0;
+                               public int compare (final OpeningTime openingTime1, final OpeningTime openingTime2) {
+                                       return openingTime1.getOpeningId() > openingTime2.getOpeningId() ? 1 : openingTime1.getOpeningId() < openingTime2.getOpeningId() ? -1 : 0;
                                }
                        }
                        );
index 10ce68f17f0d02a9686b297d1756b2ad6ab2722f..c1d06c93c238eecd8826b3f5c64568fd2ac1ce56 100644 (file)
@@ -19,7 +19,6 @@ package org.mxchange.jjobs.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;
@@ -321,7 +320,7 @@ public class JobsContactListWebViewBean extends BaseJobsBean implements JobsCont
         * Post-construction method
         */
        @PostConstruct
-       public void init () {
+       public void initializeList () {
                // Is cache there?
                if (!this.contactCache.iterator().hasNext()) {
                        // Get whole list from EJB
@@ -336,23 +335,17 @@ public class JobsContactListWebViewBean extends BaseJobsBean implements JobsCont
 
                // 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();
-
+                       for (final Cache.Entry<Long, Contact> currentEntry : this.contactCache) {
                                // Add to list
-                               this.getAllContacts().add(next.getValue());
+                               this.getAllContacts().add(currentEntry.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;
+                               public int compare (final Contact contact1, final Contact contact2) {
+                                       return contact1.getContactId() > contact2.getContactId() ? 1 : contact1.getContactId() < contact2.getContactId() ? -1 : 0;
                                }
                        });
 
@@ -366,16 +359,10 @@ public class JobsContactListWebViewBean extends BaseJobsBean implements JobsCont
                // 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();
-
+               for (final Contact currentContact : this.getAllContacts()) {
                        // Is the same?
-                       if (Contacts.isSameContact(contact, next)) {
+                       if (Contacts.isSameContact(contact, currentContact)) {
                                // Yes, then abort loop
                                IsFound = false;
                                break;
@@ -393,10 +380,7 @@ public class JobsContactListWebViewBean extends BaseJobsBean implements JobsCont
         */
        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
-               }
+               this.contactCache.remove(contact.getContactId());
        }
 
        /**
@@ -406,18 +390,12 @@ public class JobsContactListWebViewBean extends BaseJobsBean implements JobsCont
         * @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();
-
+               for (final Cache.Entry<Long, Contact> currentEntry : this.contactCache) {
                        // Is id number the same?
-                       if (Objects.equals(contact.getContactId(), next.getKey())) {
+                       if (Objects.equals(contact.getContactId(), currentEntry.getKey())) {
                                // Found entry, so remove it and abort
-                               this.removeContact(next.getValue());
+                               this.removeContact(currentEntry.getValue());
                                break;
                        }
                }
index 2e93991038c6f3a841645d149956ebf720a4619b..7b3bdc1c4cfb7e8a4735758d20c65d9ce113f122 100644 (file)
@@ -16,8 +16,6 @@
  */
 package org.mxchange.jjobs.beans.country;
 
-import java.util.Iterator;
-import java.util.List;
 import java.util.Objects;
 import javax.ejb.EJB;
 import javax.enterprise.context.RequestScoped;
@@ -33,6 +31,7 @@ import org.mxchange.jcountry.model.data.AdminCountrySessionBeanRemote;
 import org.mxchange.jcountry.model.data.Country;
 import org.mxchange.jcountry.model.data.CountryData;
 import org.mxchange.jjobs.beans.BaseJobsBean;
+import org.mxchange.jjobs.beans.country.list.JobsCountryListWebViewController;
 
 /**
  * An administrative country bean
@@ -71,12 +70,6 @@ public class JobsAdminCountryWebRequestBean extends BaseJobsBean implements Jobs
         */
        private String countryCode;
 
-       /**
-        * Regular country controller
-        */
-       @Inject
-       private JobsCountryWebRequestController countryController;
-
        /**
         * Local dial prefix
         */
@@ -92,6 +85,12 @@ public class JobsAdminCountryWebRequestBean extends BaseJobsBean implements Jobs
         */
        private Boolean countryIsLocalPrefixRequired;
 
+       /**
+        * Regular country controller
+        */
+       @Inject
+       private JobsCountryListWebViewController countryListController;
+
        /**
         * Phone code
         */
@@ -282,19 +281,10 @@ public class JobsAdminCountryWebRequestBean extends BaseJobsBean implements Jobs
                // Default is not found
                boolean isAdded = false;
 
-               // Now get whole ist
-               final List<Country> countries = this.countryController.allCountries();
-
-               // Get iterator from it
-               final Iterator<Country> iterator = countries.iterator();
-
                // Check whole list
-               while (iterator.hasNext()) {
-                       // Get next country
-                       final Country next = iterator.next();
-
+               for (final Country currentCountry : this.countryListController.getAllCountries()) {
                        // Is country code or i18n the same?
-                       if ((Objects.equals(country.getCountryCode(), next.getCountryCode())) || (Objects.equals(country.getCountryI18nKey(), next.getCountryI18nKey()))) {
+                       if ((Objects.equals(country.getCountryCode(), currentCountry.getCountryCode())) || (Objects.equals(country.getCountryI18nKey(), currentCountry.getCountryI18nKey()))) {
                                // Yes, then abort search
                                isAdded = true;
                                break;
index 02bc4ff2b6a8b5aff663029279029b311d5f92c2..d23618cb02f6566b6ec661f61dc2bdd0d51642cd 100644 (file)
  */
 package org.mxchange.jjobs.beans.country;
 
-import fish.payara.cdi.jsr107.impl.NamedCache;
-import java.text.MessageFormat;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import javax.annotation.PostConstruct;
-import javax.cache.Cache;
 import javax.ejb.EJB;
 import javax.enterprise.context.RequestScoped;
-import javax.enterprise.event.Observes;
-import javax.inject.Inject;
 import javax.inject.Named;
-import org.mxchange.jcountry.events.added.ObservableAdminAddedCountryEvent;
-import org.mxchange.jcountry.exceptions.CountryNotFoundException;
-import org.mxchange.jcountry.model.data.Country;
 import org.mxchange.jcountry.model.data.CountrySingletonBeanRemote;
 import org.mxchange.jjobs.beans.BaseJobsBean;
 
@@ -54,13 +42,6 @@ public class JobsCountryWebRequestBean extends BaseJobsBean implements JobsCount
        @EJB (lookup = "java:global/jjobs-ejb/country!org.mxchange.jcountry.model.data.CountrySingletonBeanRemote")
        private CountrySingletonBeanRemote countryBean;
 
-       /**
-        * List of all countries
-        */
-       @Inject
-       @NamedCache (cacheName = "countryCache")
-       private Cache<Long, Country> countryCache;
-
        /**
         * Default constructor
         */
@@ -69,91 +50,4 @@ public class JobsCountryWebRequestBean extends BaseJobsBean implements JobsCount
                super();
        }
 
-       /**
-        * Observing method when the event is fired that an administrator added a
-        * new country
-        * <p>
-        * @param event Event instance
-        */
-       public void afterAdminAddedCountryEvent (@Observes final ObservableAdminAddedCountryEvent event) {
-               // Is all valid?
-               if (null == event) {
-                       // Throw NPE
-                       throw new NullPointerException("event is null"); //NOI18N
-               } else if (event.getAddedCountry() == null) {
-                       // Throw again ...
-                       throw new NullPointerException("event.addedCountry is null"); //NOI18N
-               } else if (event.getAddedCountry().getCountryId() == null) {
-                       // And again ...
-                       throw new NullPointerException("event.addedCountry.countryId is null"); //NOI18N
-               } else if (event.getAddedCountry().getCountryId() < 1) {
-                       // Id is invalid
-                       throw new IllegalArgumentException(MessageFormat.format("event.addedCountry.countryId={0} is not valid.", event.getAddedCountry().getCountryId())); //NOI18N
-               }
-
-               // Add the event
-               this.countryCache.put(event.getAddedCountry().getCountryId(), event.getAddedCountry());
-       }
-
-       @Override
-       @SuppressWarnings ("ReturnOfCollectionOrArrayField")
-       public List<Country> allCountries () {
-               // Init list
-               final List<Country> list = new LinkedList<>();
-
-               // Get iterator
-               final Iterator<Cache.Entry<Long, Country>> iterator = this.countryCache.iterator();
-
-               // Loop over all
-               while (iterator.hasNext()) {
-                       // Get next entry
-                       final Cache.Entry<Long, Country> next = iterator.next();
-
-                       // Add value to list
-                       list.add(next.getValue());
-               }
-
-               // Return it
-               return list;
-       }
-
-       @Override
-       public Country findCountryById (final Long countryId) throws CountryNotFoundException {
-               // Validate parameter
-               if (null == countryId) {
-                       // Throw NPE
-                       throw new NullPointerException("countryId is null"); //NOI18N
-               } else if (countryId < 1) {
-                       // Throw IAE
-                       throw new IllegalArgumentException("countryId=" + countryId + " is invalid"); //NOI18N
-               } else if (!this.countryCache.containsKey(countryId)) {
-                       // Not found
-                       throw new CountryNotFoundException(countryId);
-               }
-
-               // Get it from cache
-               final Country country = this.countryCache.get(countryId);
-
-               // Return it
-               return country;
-       }
-
-       /**
-        * Post-construction method
-        */
-       @PostConstruct
-       public void init () {
-               // Is cache there?
-               if (!this.countryCache.iterator().hasNext()) {
-                       // Get whole list from EJB
-                       final List<Country> countries = this.countryBean.allCountries();
-
-                       // Add all
-                       for (final Country country : countries) {
-                               // Add it to cache
-                               this.countryCache.put(country.getCountryId(), country);
-                       }
-               }
-       }
-
 }
index 1f0fc0e492eda5984a3d4c7d31383f5ccfdf40a2..8c5de0d009b7e9c52129fa111b916f794c9cbece 100644 (file)
@@ -17,9 +17,6 @@
 package org.mxchange.jjobs.beans.country;
 
 import java.io.Serializable;
-import java.util.List;
-import org.mxchange.jcountry.exceptions.CountryNotFoundException;
-import org.mxchange.jcountry.model.data.Country;
 
 /**
  * An interface for country beans
@@ -28,23 +25,4 @@ import org.mxchange.jcountry.model.data.Country;
  */
 public interface JobsCountryWebRequestController extends Serializable {
 
-       /**
-        * A list of all countries
-        * <p>
-        * @return All countries
-        */
-       List<Country> allCountries ();
-
-       /**
-        * Returns a country instance found by given primary key. If not found, a
-        * proper exception is thrown.
-        * <p>
-        * @param countryId Primary key
-        * <p>
-        * @return Country data instance
-        * <p>
-        * @throws CountryNotFoundException If the primary key was not found
-        */
-       public Country findCountryById (final Long countryId) throws CountryNotFoundException;
-
 }
diff --git a/src/java/org/mxchange/jjobs/beans/country/list/JobsCountryListWebViewBean.java b/src/java/org/mxchange/jjobs/beans/country/list/JobsCountryListWebViewBean.java
new file mode 100644 (file)
index 0000000..2467e57
--- /dev/null
@@ -0,0 +1,219 @@
+/*
+ * 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.jjobs.beans.country.list;
+
+import fish.payara.cdi.jsr107.impl.NamedCache;
+import java.text.MessageFormat;
+import java.util.Comparator;
+import java.util.LinkedList;
+import java.util.List;
+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.jcountry.events.added.ObservableAdminAddedCountryEvent;
+import org.mxchange.jcountry.exceptions.CountryNotFoundException;
+import org.mxchange.jcountry.model.data.Country;
+import org.mxchange.jcountry.model.data.CountrySingletonBeanRemote;
+import org.mxchange.jjobs.beans.BaseJobsBean;
+
+/**
+ * A country-list bean
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("countryListController")
+@ViewScoped
+public class JobsCountryListWebViewBean extends BaseJobsBean implements JobsCountryListWebViewController {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 176_985_298_681_742_961L;
+
+       /**
+        * A list of all countries
+        */
+       private final List<Country> allCountries;
+
+       /**
+        * Remote country EJB
+        */
+       @EJB (lookup = "java:global/jjobs-ejb/country!org.mxchange.jcountry.model.data.CountrySingletonBeanRemote")
+       private CountrySingletonBeanRemote countryBean;
+
+       /**
+        * List of all countries
+        */
+       @Inject
+       @NamedCache (cacheName = "countryCache")
+       private transient Cache<Long, Country> countryCache;
+
+       /**
+        * A list of filtered countries
+        */
+       private List<Country> filteredCountries;
+
+       /**
+        * Selected country
+        */
+       private Country selectedCountry;
+
+       /**
+        * Default constructor
+        */
+       public JobsCountryListWebViewBean () {
+               // Call super constructor
+               super();
+
+               // Init list
+               this.allCountries = new LinkedList<>();
+       }
+
+       /**
+        * Observing method when the event is fired that an administrator added a
+        * new country
+        * <p>
+        * @param event Event instance
+        */
+       public void afterAdminAddedCountryEvent (@Observes final ObservableAdminAddedCountryEvent event) {
+               // Is all valid?
+               if (null == event) {
+                       // Throw NPE
+                       throw new NullPointerException("event is null"); //NOI18N
+               } else if (event.getAddedCountry() == null) {
+                       // Throw again ...
+                       throw new NullPointerException("event.addedCountry is null"); //NOI18N
+               } else if (event.getAddedCountry().getCountryId() == null) {
+                       // And again ...
+                       throw new NullPointerException("event.addedCountry.countryId is null"); //NOI18N
+               } else if (event.getAddedCountry().getCountryId() < 1) {
+                       // Id is invalid
+                       throw new IllegalArgumentException(MessageFormat.format("event.addedCountry.countryId={0} is not valid.", event.getAddedCountry().getCountryId())); //NOI18N
+               }
+
+               // Add the event
+               this.countryCache.put(event.getAddedCountry().getCountryId(), event.getAddedCountry());
+       }
+
+       @Override
+       public Country findCountryById (final Long countryId) throws CountryNotFoundException {
+               // Validate parameter
+               if (null == countryId) {
+                       // Throw NPE
+                       throw new NullPointerException("countryId is null"); //NOI18N
+               } else if (countryId < 1) {
+                       // Throw IAE
+                       throw new IllegalArgumentException("countryId=" + countryId + " is invalid"); //NOI18N
+               } else if (!this.countryCache.containsKey(countryId)) {
+                       // Not found
+                       throw new CountryNotFoundException(countryId);
+               }
+
+               // Get it from cache
+               final Country country = this.countryCache.get(countryId);
+
+               // Return it
+               return country;
+       }
+
+       @Override
+       @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+       public List<Country> getAllCountries () {
+               return this.allCountries;
+       }
+
+       /**
+        * Getter for filtered country list
+        * <p>
+        * @return Filtered country list
+        */
+       @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+       public List<Country> getFilteredCountries () {
+               return this.filteredCountries;
+       }
+
+       /**
+        * Setter for filtered countries list
+        * <p>
+        * @param filteredCountries Filtered countries list
+        */
+       @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter")
+       public void setFilteredCountries (final List<Country> filteredCountries) {
+               this.filteredCountries = filteredCountries;
+       }
+
+       /**
+        * Getter for selected country
+        * <p>
+        * @return Selected country
+        */
+       public Country getSelectedCountry () {
+               return this.selectedCountry;
+       }
+
+       /**
+        * Setter for selected country
+        * <p>
+        * @param selectedCountry Selected country
+        */
+       public void setSelectedCountry (final Country selectedCountry) {
+               this.selectedCountry = selectedCountry;
+       }
+
+       /**
+        * Post-construction method
+        */
+       @PostConstruct
+       public void initializeList () {
+               // Is cache there?
+               if (!this.countryCache.iterator().hasNext()) {
+                       // Get whole list from EJB
+                       final List<Country> countrys = this.countryBean.allCountries();
+
+                       // Add all
+                       for (final Country country : countrys) {
+                               // Add it to cache
+                               this.countryCache.put(country.getCountryId(), country);
+                       }
+               }
+
+               // Is cache there and list is not full?
+               if ((this.getAllCountries().isEmpty()) && (this.countryCache.iterator().hasNext())) {
+                       // Build up list
+                       for (final Cache.Entry<Long, Country> currentEntry : this.countryCache) {
+                               // Add to list
+                               this.getAllCountries().add(currentEntry.getValue());
+                       }
+
+                       // Sort list
+                       this.getAllCountries().sort(new Comparator<Country>() {
+                               @Override
+                               public int compare (final Country country1, final Country country2) {
+                                       return country1.getCountryId() > country2.getCountryId() ? 1 : country1.getCountryId() < country2.getCountryId() ? -1 : 0;
+                               }
+                       });
+
+                       // Set full list
+                       this.setFilteredCountries(this.getAllCountries());
+               }
+       }
+
+}
diff --git a/src/java/org/mxchange/jjobs/beans/country/list/JobsCountryListWebViewController.java b/src/java/org/mxchange/jjobs/beans/country/list/JobsCountryListWebViewController.java
new file mode 100644 (file)
index 0000000..51c4ec1
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * 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.jjobs.beans.country.list;
+
+import java.io.Serializable;
+import java.util.List;
+import org.mxchange.jcountry.exceptions.CountryNotFoundException;
+import org.mxchange.jcountry.model.data.Country;
+
+/**
+ * An interface for country-list beans
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface JobsCountryListWebViewController extends Serializable {
+
+       /**
+        * A list of all countries
+        * <p>
+        * @return All countries
+        */
+       List<Country> getAllCountries ();
+
+       /**
+        * Returns a country instance found by given primary key. If not found, a
+        * proper exception is thrown.
+        * <p>
+        * @param countryId Primary key
+        * <p>
+        * @return Country data instance
+        * <p>
+        * @throws CountryNotFoundException If the primary key was not found
+        */
+       public Country findCountryById (final Long countryId) throws CountryNotFoundException;
+
+}
index c2d826577ae5ad71ee093e2f323b7074c43bba02..ca1c32e9215451c45b6d89b427e2ace673b0e65e 100644 (file)
@@ -19,7 +19,6 @@ package org.mxchange.jjobs.beans.mobileprovider;
 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 javax.annotation.PostConstruct;
@@ -177,23 +176,17 @@ public class JobsMobileProviderWebRequestBean extends BaseJobsBean implements Jo
 
                // Is the list empty, but filled cache?
                if (this.allMobileProviders.isEmpty() && this.mobileProviderCache.iterator().hasNext()) {
-                       // Get iterator
-                       final Iterator<Cache.Entry<Long, MobileProvider>> iterator = this.mobileProviderCache.iterator();
-
                        // Build up list
-                       while (iterator.hasNext()) {
-                               // GEt next element
-                               final Cache.Entry<Long, MobileProvider> next = iterator.next();
-
+                       for (final Cache.Entry<Long, MobileProvider> currentEntry : this.mobileProviderCache) {
                                // Add to list
-                               this.allMobileProviders.add(next.getValue());
+                               this.allMobileProviders.add(currentEntry.getValue());
                        }
 
                        // Sort list
                        this.allMobileProviders.sort(new Comparator<MobileProvider>() {
                                @Override
-                               public int compare (final MobileProvider o1, final MobileProvider o2) {
-                                       return o1.getProviderId() > o2.getProviderId() ? 1 : o1.getProviderId() < o2.getProviderId() ? -1 : 0;
+                               public int compare (final MobileProvider mobileProvider1, final MobileProvider mobileProvider2) {
+                                       return mobileProvider1.getProviderId() > mobileProvider2.getProviderId() ? 1 : mobileProvider1.getProviderId() < mobileProvider2.getProviderId() ? -1 : 0;
                                }
                        });
                }
index b40dda971228aa7e0834e700934982f03dcdbbeb..5ee30477ff2bea02d2f9e695de17d856c57be174 100644 (file)
@@ -18,7 +18,6 @@ package org.mxchange.jjobs.beans.phone;
 
 import fish.payara.cdi.jsr107.impl.NamedCache;
 import java.text.MessageFormat;
-import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Objects;
@@ -487,16 +486,10 @@ public class JobsPhoneWebRequestBean extends BaseJobsBean implements JobsPhoneWe
                // Init list
                final List<DialableFaxNumber> list = new LinkedList<>();
 
-               // Get iterator
-               final Iterator<Cache.Entry<Long, DialableFaxNumber>> iterator = this.faxNumberCache.iterator();
-
                // Loop over all
-               while (iterator.hasNext()) {
-                       // Get next entry
-                       final Cache.Entry<Long, DialableFaxNumber> next = iterator.next();
-
+               for (final Cache.Entry<Long, DialableFaxNumber> currentEntry : this.faxNumberCache) {
                        // Add value to list
-                       list.add(next.getValue());
+                       list.add(currentEntry.getValue());
                }
 
                // Return it
@@ -509,16 +502,10 @@ public class JobsPhoneWebRequestBean extends BaseJobsBean implements JobsPhoneWe
                // Init list
                final List<DialableLandLineNumber> list = new LinkedList<>();
 
-               // Get iterator
-               final Iterator<Cache.Entry<Long, DialableLandLineNumber>> iterator = this.landLineNumberCache.iterator();
-
                // Loop over all
-               while (iterator.hasNext()) {
-                       // Get next entry
-                       final Cache.Entry<Long, DialableLandLineNumber> next = iterator.next();
-
+               for (final Cache.Entry<Long, DialableLandLineNumber> currentEntry : this.landLineNumberCache) {
                        // Add value to list
-                       list.add(next.getValue());
+                       list.add(currentEntry.getValue());
                }
 
                // Return it
@@ -531,16 +518,10 @@ public class JobsPhoneWebRequestBean extends BaseJobsBean implements JobsPhoneWe
                // Init list
                final List<DialableMobileNumber> list = new LinkedList<>();
 
-               // Get iterator
-               final Iterator<Cache.Entry<Long, DialableMobileNumber>> iterator = this.mobileNumberCache.iterator();
-
                // Loop over all
-               while (iterator.hasNext()) {
-                       // Get next entry
-                       final Cache.Entry<Long, DialableMobileNumber> next = iterator.next();
-
+               for (final Cache.Entry<Long, DialableMobileNumber> currentEntry : this.mobileNumberCache) {
                        // Add value to list
-                       list.add(next.getValue());
+                       list.add(currentEntry.getValue());
                }
 
                // Return it
index 40ce5305be839f0e311df743ec7cc486661f4d51..49165b4340bb04e76893a609f40f32e086c07272 100644 (file)
@@ -19,7 +19,6 @@ package org.mxchange.jjobs.beans.user;
 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.Locale;
@@ -142,13 +141,6 @@ public class JobsUserWebRequestBean extends BaseJobsBean implements JobsUserWebR
         */
        private String userName;
 
-       /**
-        * User name list
-        */
-       @Inject
-       @NamedCache (cacheName = "userNameCache")
-       private Cache<Long, String> userNameCache;
-
        /**
         * User password (clear-text from web form)
         */
@@ -502,9 +494,6 @@ public class JobsUserWebRequestBean extends BaseJobsBean implements JobsUserWebR
                // Update user list
                this.updateList(registeredUser);
 
-               // Add user name
-               this.addUserName(registeredUser);
-
                // Set user id again
                this.setUserId(registeredUser.getUserId());
        }
@@ -874,29 +863,22 @@ public class JobsUserWebRequestBean extends BaseJobsBean implements JobsUserWebR
                        for (final User user : users) {
                                // Add it to cache
                                this.userCache.put(user.getUserId(), user);
-                               this.userNameCache.put(user.getUserId(), user.getUserName());
                        }
                }
 
                // Is cache filled and list is empty
                if ((this.userCache.iterator().hasNext()) && (this.allUsers.isEmpty())) {
-                       // Get iterator
-                       final Iterator<Cache.Entry<Long, User>> iterator = this.userCache.iterator();
-
                        // Build up list
-                       while (iterator.hasNext()) {
-                               // GEt next element
-                               final Cache.Entry<Long, User> next = iterator.next();
-
+                       for (final Cache.Entry<Long, User> currentEntry : this.userCache) {
                                // Add to list
-                               this.allUsers.add(next.getValue());
+                               this.allUsers.add(currentEntry.getValue());
                        }
 
                        // Sort list
                        this.allUsers.sort(new Comparator<User>() {
                                @Override
-                               public int compare (final User o1, final User o2) {
-                                       return o1.getUserId() > o2.getUserId() ? 1 : o1.getUserId() < o2.getUserId() ? -1 : 0;
+                               public int compare (final User user1, final User user2) {
+                                       return user1.getUserId() > user2.getUserId() ? 1 : user1.getUserId() < user2.getUserId() ? -1 : 0;
                                }
                        });
                }
@@ -919,16 +901,10 @@ public class JobsUserWebRequestBean extends BaseJobsBean implements JobsUserWebR
                // Default is not found
                boolean isFound = false;
 
-               // Get iterator
-               final Iterator<User> iterator = this.allUsers().iterator();
-
                // Loop through all entries
-               while (iterator.hasNext()) {
-                       // Get user
-                       final User next = iterator.next();
-
+               for (final User currentUser : this.allUsers()) {
                        // Compare both objects
-                       if (Objects.equals(contact, next.getUserContact())) {
+                       if (Objects.equals(contact, currentUser.getUserContact())) {
                                // Found it
                                isFound = true;
                                break;
@@ -973,7 +949,21 @@ public class JobsUserWebRequestBean extends BaseJobsBean implements JobsUserWebR
 
        @Override
        public boolean isUserNameRegistered (final User user) {
-               return ((this.userNameCache instanceof List) && (this.userNameCache.containsKey(user.getUserId())));
+               // Default is not found
+               boolean isFound = false;
+
+               // Determine it
+               for (final User currentUser : this.allUsers()) {
+                       // Is same name found?
+                       if (Objects.equals(user.getUserName(), currentUser.getUserName())) {
+                               // Yes, then set flag and abort loop
+                               isFound = true;
+                               break;
+                       }
+               }
+
+               // Return flag
+               return isFound;
        }
 
        @Override
@@ -1003,23 +993,20 @@ public class JobsUserWebRequestBean extends BaseJobsBean implements JobsUserWebR
                User user = null;
 
                // Try to lookup it in visible user list
-               for (final Iterator<Cache.Entry<Long, User>> iterator = this.userCache.iterator(); iterator.hasNext();) {
-                       // Get next user
-                       final Cache.Entry<Long, User> next = iterator.next();
-
+               for (final Cache.Entry<Long, User> currentUser : this.userCache) {
                        // Contact should be set
-                       if (next.getValue().getUserContact() == null) {
+                       if (currentUser.getValue().getUserContact() == null) {
                                // Contact is null
-                               throw new NullPointerException(MessageFormat.format("next.userContact is null for user id {0}", next.getKey())); //NOI18N
-                       } else if (next.getValue().getUserContact().getContactEmailAddress() == null) {
+                               throw new NullPointerException(MessageFormat.format("currentUser.userContact is null for user id {0}", currentUser.getKey())); //NOI18N
+                       } else if (currentUser.getValue().getUserContact().getContactEmailAddress() == null) {
                                // Email address should be set
-                               throw new NullPointerException(MessageFormat.format("next.userContact.contactEmailAddress is null for user id {0}", next.getKey())); //NOI18N
+                               throw new NullPointerException(MessageFormat.format("currentUser.userContact.contactEmailAddress is null for user id {0}", currentUser.getKey())); //NOI18N
                        }
 
                        // Is the email address found?
-                       if (Objects.equals(next.getValue().getUserContact().getContactEmailAddress(), emailAddress)) {
+                       if (Objects.equals(currentUser.getValue().getUserContact().getContactEmailAddress(), emailAddress)) {
                                // Copy to other variable
-                               user = next.getValue();
+                               user = currentUser.getValue();
                                break;
                        }
                }
@@ -1049,14 +1036,11 @@ public class JobsUserWebRequestBean extends BaseJobsBean implements JobsUserWebR
                User user = null;
 
                // Try to lookup it in visible user list
-               for (final Iterator<Cache.Entry<Long, User>> iterator = this.userCache.iterator(); iterator.hasNext();) {
-                       // Get next user
-                       final Cache.Entry<Long, User> next = iterator.next();
-
+               for (final Cache.Entry<Long, User> currentUser : this.userCache) {
                        // Is the user id found?
-                       if (Objects.equals(next.getKey(), userId)) {
+                       if (Objects.equals(currentUser.getKey(), userId)) {
                                // Copy to other variable
-                               user = next.getValue();
+                               user = currentUser.getValue();
                                break;
                        }
                }
@@ -1071,23 +1055,6 @@ public class JobsUserWebRequestBean extends BaseJobsBean implements JobsUserWebR
                return user;
        }
 
-       /**
-        * Adds user's name to bean's internal list. It also updates the public user
-        * list if the user has decided to have a public account,
-        * <p>
-        * @param user User instance
-        */
-       private void addUserName (final User user) {
-               // Make sure the entry is not added yet
-               if (this.userNameCache.containsKey(user.getUserId())) {
-                       // Abort here
-                       throw new IllegalArgumentException(MessageFormat.format("User name {0} already added.", user.getUserName())); //NOI18N
-               }
-
-               // Add user name
-               this.userNameCache.put(user.getUserId(), user.getUserName());
-       }
-
        /**
         * Clears this bean
         */
@@ -1178,11 +1145,8 @@ public class JobsUserWebRequestBean extends BaseJobsBean implements JobsUserWebR
                }
 
                // Remove it from lists
+               this.allUsers().remove(user);
                this.userCache.remove(user.getUserId());
-               this.allUsers.remove(user);
-
-               // Remove name from list
-               this.userNameCache.remove(user.getUserId());
        }
 
        /**
index 02a0ea7520940e59981cc5b2935238de24e3c25f..ccf2ea4b2c1af2870285effca83debc25b3f24b5 100644 (file)
@@ -17,8 +17,6 @@
 package org.mxchange.jjobs.beans.user.confirmlink;
 
 import java.text.MessageFormat;
-import java.util.Iterator;
-import java.util.List;
 import java.util.Objects;
 import javax.ejb.EJB;
 import javax.enterprise.context.RequestScoped;
@@ -123,24 +121,15 @@ public class JobsConfirmationLinkWebRequestBean extends BaseJobsBean implements
                        return;
                }
 
-               // Now try to find the user in user list, first get the whole list
-               final List<User> users = this.userController.allUsers();
-
-               // Get iterator from it
-               final Iterator<User> iterator = users.iterator();
-
                // Init instance
                User user = null;
 
                // Then loop through all
-               while (iterator.hasNext()) {
-                       // Get next user
-                       final User next = iterator.next();
-
+               for (final User currentUser : this.userController.allUsers()) {
                        // Same confirmation key?
-                       if (Objects.equals(this.getConfirmationKey(), next.getUserConfirmKey())) {
+                       if (Objects.equals(this.getConfirmationKey(), currentUser.getUserConfirmKey())) {
                                // Found it, then set it and abort loop
-                               user = next;
+                               user = currentUser;
                                break;
                        }
                }
index 1981b135c8bdfd2be55ca84232fb34a82b09951b..a916b3a574a9efb02b283b1ce4edfd105af5fa51 100644 (file)
@@ -18,8 +18,6 @@ package org.mxchange.jjobs.beans.user.email_address;
 
 import fish.payara.cdi.jsr107.impl.NamedCache;
 import java.text.MessageFormat;
-import java.util.Iterator;
-import java.util.List;
 import java.util.Objects;
 import javax.annotation.PostConstruct;
 import javax.cache.Cache;
@@ -203,16 +201,10 @@ public class JobsEmailChangeWebRequestBean extends BaseJobsBean implements JobsE
        public void init () {
                // Is cache there?
                if (!this.queuedEmailCache.iterator().hasNext()) {
-                       // Get whole list from EJB
-                       final List<String> list = this.emailChangeBean.allQueuedAddresses();
-
                        // Add all
-                       for (final Iterator<String> iterator = list.iterator(); iterator.hasNext();) {
-                               // Get next element
-                               final String next = iterator.next();
-
+                       for (final String currentEmailAddress : this.emailChangeBean.allQueuedAddresses()) {
                                // Add it to cache
-                               this.queuedEmailCache.put(next, Boolean.TRUE);
+                               this.queuedEmailCache.put(currentEmailAddress, Boolean.TRUE);
                        }
                }
        }
index 2f516dd7a3a0d7088a25adb4865b02e7ea173d54..6473599f9e9992897ae0dc3de1e1b935c8e2f076 100644 (file)
@@ -24,8 +24,8 @@ import javax.faces.convert.ConverterException;
 import javax.faces.convert.FacesConverter;
 import org.mxchange.jcountry.exceptions.CountryNotFoundException;
 import org.mxchange.jcountry.model.data.Country;
-import org.mxchange.jjobs.beans.country.JobsCountryWebRequestBean;
-import org.mxchange.jjobs.beans.country.JobsCountryWebRequestController;
+import org.mxchange.jjobs.beans.country.list.JobsCountryListWebViewBean;
+import org.mxchange.jjobs.beans.country.list.JobsCountryListWebViewController;
 
 /**
  * Converter for country instance
@@ -38,16 +38,10 @@ public class JobsCountryConverter implements Converter<Country> {
        /**
         * Country backing bean
         */
-       private static JobsCountryWebRequestController COUNTRY_CONTROLLER;
+       private static JobsCountryListWebViewController COUNTRY_LIST_CONTROLLER;
 
        @Override
        public Country getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
-               // Is the instance there?
-               if (null == COUNTRY_CONTROLLER) {
-                       // Get bean from CDI directly
-                       COUNTRY_CONTROLLER = CDI.current().select(JobsCountryWebRequestBean.class).get();
-               }
-
                // Is the value null or empty?
                if ((null == submittedValue) || (submittedValue.trim().isEmpty())) {
                        // Warning message
@@ -65,8 +59,14 @@ public class JobsCountryConverter implements Converter<Country> {
                        // Convert it to long
                        final Long countryId = Long.parseLong(submittedValue);
 
+                       // Is the instance there?
+                       if (null == COUNTRY_LIST_CONTROLLER) {
+                               // Get bean from CDI directly
+                               COUNTRY_LIST_CONTROLLER = CDI.current().select(JobsCountryListWebViewBean.class).get();
+                       }
+
                        // Try to find it
-                       country = COUNTRY_CONTROLLER.findCountryById(countryId);
+                       country = COUNTRY_LIST_CONTROLLER.findCountryById(countryId);
                } catch (final NumberFormatException ex) {
                        // Throw again
                        throw new ConverterException(ex);
index fe05c837104e519723f92c9987d8fd0a2f3391b0..fac4739f2a91d2563c24602c6101fc3b27a9a654 100644 (file)
@@ -110,7 +110,6 @@ GUEST_REGISTRATION_ENTER_USER_NAME=Benutzernamen eingeben:
 GUEST_REGISTRATION_USER_NAME_NOTICE=Der Benutzername darf nur einmal vorkommen.
 GUEST_LINK_RESENT_CONFIRMATION_LINK=Nochmals den Best\u00e4tigungslink aussenden?
 GUEST_USER_REGISTRATION_COMPLETED=Die Anmeldung ist abgeschlossen und Ihr Account wartet auf Freischaltung. Es ist eine Email mit einem entsprechenden Best\u00e4tigungslink zu Ihnen unterwegs. Diesen m\u00fcssen Sie einmal anklicken oder in die Adresszeile des Browsers kopieren und dann aufrufen lassen. Danach ist Ihr Account freigegeben.
-PERSONAL_DATA_COUNTRY_CODE=L\u00e4ndercode:
 PAGE_TITLE_USER_REGISTER_DONE=Anmeldung abgeschlossen
 CONTENT_TITLE_USER_REGISTER_DONE=Die Anmeldung ist abgeschlossen:
 PAGE_TITLE_INDEX_RESEND_LINK=Best\u00e4tigungslink erneut aussenden
@@ -310,11 +309,13 @@ ADMIN_ENTER_COUNTRY_PHONE_CODE=Vorwahl f\u00fcr das Land:
 ADMIN_ENTER_COUNTRY_PHONE_CODE_EXAMPLE=(Beispiel: 49 f\u00fcr Deutschland)
 BUTTON_ADMIN_ADD_COUNTRY=L\u00e4nderdaten hinzuf\u00fcgen
 ID_HEADER=Id:
-ADMIN_LIST_COUNTRY_DATA_COUNTRY_CODE=L\u00e4ndercode:
-ADMIN_LIST_COUNTRY_DATA_COUNTRY_EXTERNAL_DIAL_PREFIX=Vorwahl ausserorts:
-ADMIN_LIST_COUNTRY_DATA_COUNTRY_NAME=Land:
+DATA_COUNTRY_EXTERNAL_DIAL_PREFIX=Vorwahl ausserorts:
+DATA_COUNTRY_ABROAD_DIAL_PREFIX=Vorwahl in's Ausland:
+DATA_COUNTRY_PHONE_CODE=Vorwahl vom Land:
+DATA_COUNTRY_NAME=Land:
+DATA_IS_REQUIRED=Wird ben\u00f6tigt?
 ADMIN_LINK_EDIT_DELETE_COUNTRY_TITLE=Editieren oder l\u00f6schen der L\u00e4nderdaten
-TABLE_SUMMARY_ADMIN_LIST_COUNTRIES=Diese Tabelle listet alle bereits angelegten L\u00e4nderdaten auf.
+TABLE_SUMMARY_ADMIN_LIST_COUNTRY=Diese Tabelle listet alle bereits angelegten L\u00e4nderdaten auf.
 ADMIN_MENU_MOBILE_PROVIDER_TITLE=Handyanbieter
 ADMIN_LINK_LIST_MOBILE_PROVIDER_TITLE=Hinzuf\u00fcgen, auflisten, \u00e4ndern und l\u00f6schen von Handyanbietern.
 PAGE_TITLE_ADMIN_MOBILE_PROVIDER_LIST=Handyanbieter verwalten
@@ -496,7 +497,7 @@ BUTTON_GUEST_CONFIRM_USER_ACCOUNT=Account best\u00e4tigen
 ADMIN_MENU_CONTACT_TITLE=Kontaktdaten
 ADMIN_LINK_LIST_CONTACT=Kontaktdaten
 ADMIN_LINK_LIST_CONTACT_TITLE=Listet alle Kontaktdaten auf, egal wo her sie angelegt wurden.
-ADMIN_CONTACT_COUNTRY_CODE=L\u00e4ndercode:
+DATA_COUNTRY_CODE=L\u00e4ndercode:
 ADMIN_CONTACT_MOBILE_NUMBER=Handynummer:
 ADMIN_CONTACT_LANDLINE_NUMBER=Telefonnummer:
 ADMIN_CONTACT_FAX_NUMBER=Faxnummer:
index 4cf5bcdec35871dc8e16c516f640b3ca571abca6..d9a515151d83a1b9b37d430628f5cc2737b4edb3 100644 (file)
@@ -109,7 +109,6 @@ GUEST_REGISTRATION_ENTER_USER_NAME=Enter user name:
 GUEST_REGISTRATION_USER_NAME_NOTICE=The user name must only exist once.
 GUEST_LINK_RESENT_CONFIRMATION_LINK=Resend again the confirmation link?
 GUEST_USER_REGISTRATION_COMPLETED=The registration is completed and your account is pending confirmation. An email has been sent to you. There you will find a confirmation link which you have to click once or copy it into your browser's address bar and call it.
-PERSONAL_DATA_COUNTRY_CODE=Country code:
 PAGE_TITLE_USER_REGISTER_DONE=Registration completed
 CONTENT_TITLE_USER_REGISTER_DONE=Registration is completed:
 PAGE_TITLE_INDEX_RESEND_LINK=Resend confirmation link
@@ -284,11 +283,13 @@ ADMIN_ENTER_COUNTRY_PHONE_CODE=Dial prefix for this country:
 ADMIN_ENTER_COUNTRY_PHONE_CODE_EXAMPLE=(Example: 1 for U.S.A.)
 BUTTON_ADMIN_ADD_COUNTRY=Add country data
 ID_HEADER=Id:
-ADMIN_LIST_COUNTRY_DATA_COUNTRY_CODE=Country code:
-ADMIN_LIST_COUNTRY_DATA_COUNTRY_EXTERNAL_DIAL_PREFIX=Dial prefix outside:
-ADMIN_LIST_COUNTRY_DATA_COUNTRY_NAME=Country:
+DATA_COUNTRY_EXTERNAL_DIAL_PREFIX=Dial prefix outside:
+DATA_COUNTRY_ABROAD_DIAL_PREFIX=Dial prefix abroad:
+DATA_COUNTRY_PHONE_CODE=Dial prefix this country:
+DATA_COUNTRY_NAME=Country:
+DATA_IS_REQUIRED=Is required?
 ADMIN_LINK_EDIT_DELETE_COUNTRY_TITLE=Edit or delete country
-TABLE_SUMMARY_ADMIN_LIST_COUNTRIES=This table lists all countries.
+TABLE_SUMMARY_ADMIN_LIST_COUNTRY=This table lists all countries.
 ADMIN_MENU_MOBILE_PROVIDER_TITLE=Mobile providers
 ADMIN_LINK_LIST_MOBILE_PROVIDER=List mobile provider
 ADMIN_LINK_LIST_MOBILE_PROVIDER_TITLE=Add, list, edit and delete mobile providers.
@@ -481,7 +482,7 @@ BUTTON_GUEST_CONFIRM_USER_ACCOUNT=Confirm account
 ADMIN_MENU_CONTACT_TITLE=Contact data
 ADMIN_LINK_LIST_CONTACT=Contact data
 ADMIN_LINK_LIST_CONTACT_TITLE=Lists all contact data regardless where they was created.
-ADMIN_CONTACT_COUNTRY_CODE=Country code:
+DATA_COUNTRY_CODE=Country code:
 ADMIN_CONTACT_MOBILE_NUMBER=Mobile number:
 ADMIN_CONTACT_LANDLINE_NUMBER=Phone number:
 ADMIN_CONTACT_FAX_NUMBER=Fax number:
index 49934fc9088f34ae8c8c5c5e70605583f1018dfb..7be60aca8eabaf78de6599d0dae22158aaaa3d65 100644 (file)
@@ -79,7 +79,7 @@
        </p:column>
 
        <p:column>
-               <p:outputLabel for="contactCountry" styleClass="table-data-label" value="#{msg.ADMIN_CONTACT_COUNTRY_CODE}" />
+               <p:outputLabel for="contactCountry" styleClass="table-data-label" value="#{msg.DATA_COUNTRY_CODE}" />
 
                <h:outputText id="contactCountry" styleClass="table-data-field" value="#{beanHelper.contact.contactCountry.countryCode}" />
        </p:column>
index 93dc2349d66df645720f89fa69d8a0dee5da3902..f64ef0b7b75f439353a2e9a1dab9d5af64535025 100644 (file)
 
                        <h:panelGroup styleClass="table-row" layout="block">
                                <div class="table-left-medium">
-                                       <p:outputLabel for="country" value="#{msg.PERSONAL_DATA_COUNTRY_CODE}" />
+                                       <p:outputLabel for="country" value="#{msg.DATA_COUNTRY_CODE}" />
                                </div>
 
                                <div class="table-right-medium">
index 290dd9bfbaedfb59c9ea8a7ec16c425c68af8690..45ce0bc89def8b7bf3deff555818fb50b50f31da 100644 (file)
                                <p:column
                                        headerText="#{msg.ENTRY_CREATED_HEADER}"
                                        sortBy="#{basicData.companyCreated}"
+                                       filterBy="#{basicData.companyCreated}"
+                                       filterMatchMode="contains"
                                        >
-                                       <h:outputText id="companyCreated" value="#{basicData.companyCreated}">
+                                       <h:outputText value="#{basicData.companyCreated}">
                                                <f:convertDateTime type="both" timeStyle="short" dateStyle="short" />
                                        </h:outputText>
                                </p:column>
index e394f038d8c84493d900a9cfb789b7dbd8dc0b51..99aa89ebb879fdf8ad0de8a77136cd0d079b9cea 100644 (file)
                        <p:dataTable
                                id="countryList"
                                var="country"
-                               value="#{countryController.allCountries()}"
+                               value="#{countryListController.allCountries}"
                                paginator="true"
+                               paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
+                               filteredValue="#{countryListController.filteredCountries}"
                                rows="10"
-                               summary="#{msg.TABLE_SUMMARY_ADMIN_LIST_COUNTRIES}"
+                               rowKey="#{country.countryId}"
+                               reflow="true"
+                               resizableColumns="true"
+                               rowsPerPageTemplate="5,10,20,50,100"
+                               sortMode="multiple"
+                               summary="#{msg.TABLE_SUMMARY_ADMIN_LIST_COUNTRY}"
                                emptyMessage="#{msg.ADMIN_EMPTY_LIST_COUNTRY}"
                                widgetVar="countryList"
+                               selectionMode="single"
+                               selection="#{countryListController.selectedCountry}"
+                               skipChildren="true"
                                >
-                               <p:column>
-                                       <f:facet name="header">
-                                               <h:outputText value="#{msg.ID_HEADER}" />
-                                       </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('countryList').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="countryList" trigger="toggler" />
+                                               </p:outputPanel>
+                                       </p:panelGrid>
+                               </f:facet>
+
+                               <p:ajax
+                                       event="rowSelect"
+                                       update=":master:form-list-countries:country-details"
+                                       oncomplete="PF('countryDialog').show()"
+                                       />
+
+                               <p:column
+                                       headerText="#{msg.ID_HEADER}"
+                                       sortBy="#{country.countryId}"
+                                       filterable="false"
+                                       >
                                        <p:link
                                                outcome="admin_show_country"
                                                value="#{country.countryId}"
                                        </p:link>
                                </p:column>
 
-                               <p:column>
-                                       <f:facet name="header">
-                                               <h:outputText value="#{msg.ADMIN_LIST_COUNTRY_DATA_COUNTRY_CODE}" />
-                                       </f:facet>
+                               <p:column
+                                       headerText="#{msg.DATA_COUNTRY_CODE}"
+                                       sortBy="#{country.countryCode}"
+                                       filterBy="#{country.countryCode}"
+                                       filterMatchMode="contains"
+                                       >
 
                                        <h:outputText value="#{country.countryCode}" />
                                </p:column>
 
-                               <p:column>
-                                       <f:facet name="header">
-                                               <h:outputText value="#{msg.ADMIN_LIST_COUNTRY_DATA_COUNTRY_EXTERNAL_DIAL_PREFIX}" />
-                                       </f:facet>
+                               <p:column
+                                       headerText="#{msg.DATA_COUNTRY_NAME}"
+                                       sortBy="#{msg[country.countryI18nKey]}"
+                                       filterBy="#{msg[country.countryI18nKey]}"
+                                       filterMatchMode="contains"
+                                       >
+
+                                       <h:outputText value="#{msg[country.countryI18nKey]}" />
+                               </p:column>
+
+                               <p:column
+                                       headerText="#{msg.DATA_COUNTRY_EXTERNAL_DIAL_PREFIX}"
+                                       sortBy="#{country.countryExternalDialPrefix}"
+                                       filterBy="#{country.countryExternalDialPrefix}"
+                                       filterMatchMode="contains"
+                                       >
 
                                        <h:outputText value="#{country.countryExternalDialPrefix}" />
                                </p:column>
 
-                               <p:column>
-                                       <f:facet name="header">
-                                               <h:outputText value="#{msg.ADMIN_LIST_COUNTRY_DATA_COUNTRY_NAME}" />
-                                       </f:facet>
+                               <p:column
+                                       headerText="#{msg.DATA_COUNTRY_ABROAD_DIAL_PREFIX}"
+                                       sortBy="#{country.countryAbroadDialPrefix}"
+                                       filterBy="#{country.countryAbroadDialPrefix}"
+                                       filterMatchMode="contains"
+                                       >
 
-                                       <h:outputText value="#{msg[country.countryI18nKey]}" />
+                                       <h:outputText value="#{country.countryAbroadDialPrefix}" />
+                               </p:column>
+
+                               <p:column
+                                       headerText="#{msg.DATA_IS_REQUIRED}"
+                                       sortBy="#{country.countryIsLocalPrefixRequired}"
+                                       filterBy="#{country.countryIsLocalPrefixRequired}"
+                                       filterMatchMode="contains"
+                                       >
+
+                                       <h:outputText value="#{country.countryIsLocalPrefixRequired ? msg.CHOICE_YES : msg.CHOICE_NO}" />
+                               </p:column>
+
+                               <p:column
+                                       headerText="#{msg.ENTRY_CREATED_HEADER}"
+                                       sortBy="#{country.countryEntryCreated}"
+                                       filterBy="#{country.countryEntryCreated}"
+                                       filterMatchMode="contains"
+                                       >
+
+                                       <h:outputText value="#{country.countryEntryCreated}">
+                                               <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.ENTRY_UPDATED_HEADER}"
+                                       sortBy="#{country.countryEntryUpdated}"
+                                       filterBy="#{country.countryEntryUpdated}"
+                                       filterMatchMode="contains"
+                                       >
 
+                                       <h:outputText value="#{country.countryEntryUpdated}">
+                                               <f:convertDateTime type="both" timeStyle="short" dateStyle="short" />
+                                       </h:outputText>
+                               </p:column>
+
+                               <p:column
+                                       headerText="#{msg.ADMIN_ACTION_LINKS_HEADER}"
+                                       filterable="false"
+                                       sortable="false"
+                                       >
                                        <links:outputCountryAdminDropdownMenu country="#{country}" />
                                </p:column>
                        </p:dataTable>
+
+                       <p:dialog
+                               dynamic="true"
+                               modal="true"
+                               resizable="false"
+                               header="#{msg.ADMIN_SINGLE_COUNTRY_DETAILS_HEADER}"
+                               hideEffect="fade"
+                               showEffect="fade"
+                               widgetVar="countryDialog"
+                               position="top"
+                               responsive="true"
+                               closeOnEscape="true"
+                               >
+                               <p:outputPanel id="country-details">
+                                       <p:panelGrid columns="2" rendered="#{not empty countryListController.selectedCountry}">
+                                               <f:facet name="header">
+                                                       <h:outputFormat value="#{msg.ADMIN_COUNTRY_DETAILS_HEADER}">
+                                                               <f:param value="#{msg[countryListController.selectedCountry.countryI18nKey]}" />
+                                                               <f:param value="#{countryListController.selectedCountry.countryId}" />
+                                                       </h:outputFormat>
+                                               </f:facet>
+
+                                               <p:outputLabel value="#{msg.ID_HEADER}" title="#{msg.COUNTRY_ID_NUMBER_TITLE}" />
+                                               <h:outputText value="#{countryListController.selectedCountry.countryId}" />
+                                       </p:panelGrid>
+                               </p:outputPanel>
+                       </p:dialog>
                </h:form>
 
                <h:form>