From 9eb6d967b594a2167109ced215ce9fc731d5a210 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 1 Oct 2017 21:51:14 +0200 Subject: [PATCH] Please cherry-pick: - rewrote branch office/employee list to filtering, sorting list - also used f:facet name="" instead of h:panelGroup+hX to make more generic table footer and header - disabled filtering for creation timestamps and action links - renamed some i18n strings, let them have plural (more than one item could be listed) - renamed COMPANY_FOO to only FOO as no other employees or departments (e.g. fire department) will this application be about - had switched STATE_SAVING_METHOD to server for testing things, missed to set it back before committing, now set back to client - added navigation rules for departments and opening times - added missing i18n strings MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../FinancialsBusinessDataWebRequestBean.java | 79 +++- .../FinancialsWebRequestHelperBean.java | 4 +- .../FinancialsCompanyEmployeeConverter.java | 8 +- .../FinancialsCompanyDepartmentConverter.java | 8 +- .../localization/bundle_de_DE.properties | 84 +++-- .../localization/bundle_en_US.properties | 75 ++-- web/WEB-INF/faces-config.xml | 8 + .../mini/employee/admin_employee_links.tpl | 6 +- web/WEB-INF/templates/admin/admin_menu.tpl | 11 +- .../admin_form_basic_company_data.tpl | 345 +++++------------- .../admin_form_branch_office_data.tpl | 4 +- .../employee/admin_form_employee_data.tpl | 28 +- web/WEB-INF/web.xml | 2 +- .../admin_basic_company_data_list.xhtml | 133 ++++--- .../admin_branch_office_list.xhtml | 49 +-- web/admin/employee/admin_employee_list.xhtml | 75 ++-- 16 files changed, 442 insertions(+), 477 deletions(-) diff --git a/src/java/org/mxchange/jfinancials/beans/business/basicdata/FinancialsBusinessDataWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/business/basicdata/FinancialsBusinessDataWebRequestBean.java index df7a630d..7b49d0af 100644 --- a/src/java/org/mxchange/jfinancials/beans/business/basicdata/FinancialsBusinessDataWebRequestBean.java +++ b/src/java/org/mxchange/jfinancials/beans/business/basicdata/FinancialsBusinessDataWebRequestBean.java @@ -18,6 +18,7 @@ package org.mxchange.jfinancials.beans.business.basicdata; 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; @@ -56,6 +57,11 @@ public class FinancialsBusinessDataWebRequestBean extends BaseFinancialsBean imp @EJB (lookup = "java:global/jfinancials-ejb/adminBasicCompanyData!org.mxchange.jcontactsbusiness.model.basicdata.AdminBasicCompanyDataSessionBeanRemote", description = "A stateless session bean for administrative purposes.") private AdminBasicCompanyDataSessionBeanRemote adminBasicCompanyDataBean; + /** + * List of all basic company data + */ + private List allCompanyBasicData; + /** * A list of all registered companies (globally) */ @@ -99,6 +105,11 @@ public class FinancialsBusinessDataWebRequestBean extends BaseFinancialsBean imp */ private Long faxNumber; + /** + * List of filtered basic company data + */ + private List filteredBasicCompanyData; + /** * Area code for land-line number */ @@ -126,6 +137,9 @@ public class FinancialsBusinessDataWebRequestBean extends BaseFinancialsBean imp public FinancialsBusinessDataWebRequestBean () { // Call super constructor super(); + + // Init list + this.allCompanyBasicData = new LinkedList<>(); } /** @@ -158,32 +172,17 @@ public class FinancialsBusinessDataWebRequestBean extends BaseFinancialsBean imp // Add it to list this.basicDataCache.put(event.getBasicData().getBasicDataId(), event.getBasicData()); + this.allCompanyBasicData.add(event.getBasicData()); } /** - * Returns a list of all business contacts + * Getter for a list of all business contacts *

* @return A list of all business contacts */ @SuppressWarnings ("ReturnOfCollectionOrArrayField") public List allCompanyBasicData () { - // Init list - final List list = new LinkedList<>(); - - // Get iterator - final Iterator> iterator = this.basicDataCache.iterator(); - - // Loop over all - while (iterator.hasNext()) { - // Get next entry - final Cache.Entry next = iterator.next(); - - // Add value to list - list.add(next.getValue()); - } - - // Return it - return list; + return this.allCompanyBasicData; } /** @@ -294,6 +293,26 @@ public class FinancialsBusinessDataWebRequestBean extends BaseFinancialsBean imp this.faxNumber = faxNumber; } + /** + * Getter for filtered basic company data + *

+ * @return Filtered basic company data + */ + @SuppressWarnings ("ReturnOfCollectionOrArrayField") + public List getFilteredBasicCompanyData () { + return this.filteredBasicCompanyData; + } + + /** + * Setter for filtered basic company data + *

+ * @param filteredBasicCompanyData Filtered basic company data + */ + @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter") + public void setFilteredBasicCompanyData (final List filteredBasicCompanyData) { + this.filteredBasicCompanyData = filteredBasicCompanyData; + } + /** * Getter for land-line number's area code *

@@ -367,6 +386,30 @@ public class FinancialsBusinessDataWebRequestBean extends BaseFinancialsBean imp this.basicDataCache.put(next.getBasicDataId(), next); } } + + // Is cache there and list is not full? + if ((this.allCompanyBasicData.isEmpty()) && (this.basicDataCache.iterator().hasNext())) { + // Get iterator + final Iterator> iterator = this.basicDataCache.iterator(); + + // Build up list + while (iterator.hasNext()) { + // GEt next element + final Cache.Entry next = iterator.next(); + + // Add to list + this.allCompanyBasicData.add(next.getValue()); + } + + // Sort list + this.allCompanyBasicData.sort(new Comparator() { + @Override + public int compare (final BusinessBasicData o1, final BusinessBasicData o2) { + return o1.getBasicDataId() > o2.getBasicDataId() ? 1 : o1.getBasicDataId() < o2.getBasicDataId() ? -1 : 0; + } + } + ); + } } /** diff --git a/src/java/org/mxchange/jfinancials/beans/helper/FinancialsWebRequestHelperBean.java b/src/java/org/mxchange/jfinancials/beans/helper/FinancialsWebRequestHelperBean.java index 14eb2cd9..67272bae 100644 --- a/src/java/org/mxchange/jfinancials/beans/helper/FinancialsWebRequestHelperBean.java +++ b/src/java/org/mxchange/jfinancials/beans/helper/FinancialsWebRequestHelperBean.java @@ -486,9 +486,9 @@ public class FinancialsWebRequestHelperBean extends BaseFinancialsBean implement // Then create name sb.append(this.getMessageFromBundle(contact.getContactPersonalTitle().getMessageKey())); sb.append(" "); //NOI18N - sb.append(contact.getContactFamilyName()); - sb.append(" "); //NOI18N sb.append(contact.getContactFirstName()); + sb.append(" "); //NOI18N + sb.append(contact.getContactFamilyName()); } // Return it diff --git a/src/java/org/mxchange/jfinancials/converter/business/company_employee/FinancialsCompanyEmployeeConverter.java b/src/java/org/mxchange/jfinancials/converter/business/company_employee/FinancialsCompanyEmployeeConverter.java index f0dee830..cd886fff 100644 --- a/src/java/org/mxchange/jfinancials/converter/business/company_employee/FinancialsCompanyEmployeeConverter.java +++ b/src/java/org/mxchange/jfinancials/converter/business/company_employee/FinancialsCompanyEmployeeConverter.java @@ -41,18 +41,18 @@ public class FinancialsCompanyEmployeeConverter implements Converter { /** * CompanyEmployee EJB */ - private static CompanyEmployeeSessionBeanRemote COMPANY_EMPLOYEE_BEAN; + private static CompanyEmployeeSessionBeanRemote EMPLOYEE_BEAN; @Override public Employee getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) { // Is the instance there? - if (COMPANY_EMPLOYEE_BEAN == null) { + if (EMPLOYEE_BEAN == null) { try { // Not yet, attempt lookup final Context initial = new InitialContext(); // Lookup EJB - COMPANY_EMPLOYEE_BEAN = (CompanyEmployeeSessionBeanRemote) initial.lookup("java:global/jfinancials-ejb/companyEmployee!org.mxchange.jcontactsbusiness.model.employee.CompanyEmployeeSessionBeanRemote"); //NOI18N + EMPLOYEE_BEAN = (CompanyEmployeeSessionBeanRemote) initial.lookup("java:global/jfinancials-ejb/companyEmployee!org.mxchange.jcontactsbusiness.model.employee.CompanyEmployeeSessionBeanRemote"); //NOI18N } catch (final NamingException ex) { // Throw it again throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Cannot lookup EJB", ex.getMessage()), ex); //NOI18N @@ -76,7 +76,7 @@ public class FinancialsCompanyEmployeeConverter implements Converter { final Long employeeId = Long.valueOf(submittedValue); // Try to get user instance from it - companyEmployee = COMPANY_EMPLOYEE_BEAN.findCompanyEmployeeById(employeeId); + companyEmployee = EMPLOYEE_BEAN.findCompanyEmployeeById(employeeId); } catch (final NumberFormatException ex) { // Throw again throw new ConverterException(ex); diff --git a/src/java/org/mxchange/jfinancials/converter/business/department/FinancialsCompanyDepartmentConverter.java b/src/java/org/mxchange/jfinancials/converter/business/department/FinancialsCompanyDepartmentConverter.java index 5686d360..8681cbc8 100644 --- a/src/java/org/mxchange/jfinancials/converter/business/department/FinancialsCompanyDepartmentConverter.java +++ b/src/java/org/mxchange/jfinancials/converter/business/department/FinancialsCompanyDepartmentConverter.java @@ -41,18 +41,18 @@ public class FinancialsCompanyDepartmentConverter implements Converteradmin_list_branch_office /admin/branch_office/admin_branch_office_list.xhtml + + admin_list_department + /admin/department/admin_department_list.xhtml + + + admin_list_opening_time + /admin/opening_time/admin_opening_time_list.xhtml + admin_list_company_employee /admin/employee/admin_employee_list.xhtml diff --git a/web/WEB-INF/resources/tags/admin/links/mini/employee/admin_employee_links.tpl b/web/WEB-INF/resources/tags/admin/links/mini/employee/admin_employee_links.tpl index 5a935432..dda35498 100644 --- a/web/WEB-INF/resources/tags/admin/links/mini/employee/admin_employee_links.tpl +++ b/web/WEB-INF/resources/tags/admin/links/mini/employee/admin_employee_links.tpl @@ -10,21 +10,21 @@