From c05bce762b6daaabd28ac2602350741373fd257c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Fri, 11 Oct 2019 11:32:59 +0200 Subject: [PATCH] Don't cherry-pick: - renamed a lot files according to naming convention, like no Headquarter>s< (s is plural here) and no CompanyEmployee and so on - used java.util.Date instead of java.util.Calendar as it is done everywhere - fixed a lot errors to make this project at least compile again MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../JobsAddressbookWebSessionBean.java | 14 +-- .../JobsAddressbookWebSessionController.java | 6 +- ...a => JobsAdminEmployeeWebRequestBean.java} | 8 +- ...obsAdminEmployeeWebRequestController.java} | 0 ...n.java => JobsEmployeeWebRequestBean.java} | 0 ... => JobsEmployeeWebRequestController.java} | 0 .../data/JobsDataWebApplicationBean.java | 10 -- ...ava => JobsBasicCompanyDataConverter.java} | 0 ...verter.java => JobsEmployeeConverter.java} | 45 +++----- ...rter.java => JobsDepartmentConverter.java} | 0 .../JobsCompanyHeadquartersConverter.java | 105 ------------------ .../JobsHeadquarterConverter.java | 83 ++++++++++++++ 12 files changed, 116 insertions(+), 155 deletions(-) rename src/java/org/mxchange/jjobs/beans/business/employee/{JobsAdminCompanyEmployeeWebRequestBean.java => JobsAdminEmployeeWebRequestBean.java} (98%) rename src/java/org/mxchange/jjobs/beans/business/employee/{JobsAdminCompanyEmployeeWebRequestController.java => JobsAdminEmployeeWebRequestController.java} (100%) rename src/java/org/mxchange/jjobs/beans/business/employee/{JobsCompanyEmployeeWebRequestBean.java => JobsEmployeeWebRequestBean.java} (100%) rename src/java/org/mxchange/jjobs/beans/business/employee/{JobsCompanyEmployeeWebSessionController.java => JobsEmployeeWebRequestController.java} (100%) rename src/java/org/mxchange/jjobs/converter/business/basicdata/{JobsBusinessContactConverter.java => JobsBasicCompanyDataConverter.java} (100%) rename src/java/org/mxchange/jjobs/converter/business/company_employee/{JobsCompanyEmployeeConverter.java => JobsEmployeeConverter.java} (61%) rename src/java/org/mxchange/jjobs/converter/business/department/{JobsCompanyDepartmentConverter.java => JobsDepartmentConverter.java} (100%) delete mode 100644 src/java/org/mxchange/jjobs/converter/business/headquarters/JobsCompanyHeadquartersConverter.java create mode 100644 src/java/org/mxchange/jjobs/converter/business/headquarters/JobsHeadquarterConverter.java diff --git a/src/java/org/mxchange/jjobs/beans/addressbook/JobsAddressbookWebSessionBean.java b/src/java/org/mxchange/jjobs/beans/addressbook/JobsAddressbookWebSessionBean.java index a883a7f0..95563b83 100644 --- a/src/java/org/mxchange/jjobs/beans/addressbook/JobsAddressbookWebSessionBean.java +++ b/src/java/org/mxchange/jjobs/beans/addressbook/JobsAddressbookWebSessionBean.java @@ -17,8 +17,8 @@ package org.mxchange.jjobs.beans.addressbook; import java.text.MessageFormat; -import java.util.Calendar; import java.util.Collections; +import java.util.Date; import java.util.LinkedList; import java.util.List; import java.util.Objects; @@ -41,7 +41,7 @@ import org.mxchange.jaddressbook.exceptions.AddressbookNotFoundException; import org.mxchange.jaddressbook.model.addressbook.Addressbook; import org.mxchange.jaddressbook.model.addressbook.UserAddressbook; import org.mxchange.jaddressbook.model.addressbook.entry.AddressbookEntry; -import org.mxchange.jjobs.beans.BaseJobsController; +import org.mxchange.jjobs.beans.BaseJobsBean; import org.mxchange.jjobs.beans.user.login.JobsUserLoginWebSessionController; import org.mxchange.jusercore.model.user.User; import org.mxchange.juserlogincore.events.login.ObservableUserLoggedInEvent; @@ -53,7 +53,7 @@ import org.mxchange.juserlogincore.events.login.ObservableUserLoggedInEvent; */ @Named ("addressbookController") @SessionScoped -public class JobsAddressbookWebSessionBean extends BaseJobsController implements JobsAddressbookWebSessionController { +public class JobsAddressbookWebSessionBean extends BaseJobsBean implements JobsAddressbookWebSessionController { /** * Serial number @@ -73,7 +73,7 @@ public class JobsAddressbookWebSessionBean extends BaseJobsController implements /** * When this address book has been created */ - private Calendar addressbookCreated; + private Date addressbookCreated; /** * Address book id number (from URL for example) @@ -175,7 +175,7 @@ public class JobsAddressbookWebSessionBean extends BaseJobsController implements } // Get address book instance - Addressbook book = event.getAddressbook(); + final Addressbook book = event.getAddressbook(); // Set address book data this.setAddressbookId(book.getAddressbookId()); @@ -249,13 +249,13 @@ public class JobsAddressbookWebSessionBean extends BaseJobsController implements @Override @SuppressWarnings ("ReturnOfDateField") - public Calendar getAddressbookCreated () { + public Date getAddressbookCreated () { return this.addressbookCreated; } @Override @SuppressWarnings ("AssignmentToDateFieldFromParameter") - public void setAddressbookCreated (final Calendar addressbookCreated) { + public void setAddressbookCreated (final Date addressbookCreated) { this.addressbookCreated = addressbookCreated; } diff --git a/src/java/org/mxchange/jjobs/beans/addressbook/JobsAddressbookWebSessionController.java b/src/java/org/mxchange/jjobs/beans/addressbook/JobsAddressbookWebSessionController.java index ee30ec31..56a9d6cb 100644 --- a/src/java/org/mxchange/jjobs/beans/addressbook/JobsAddressbookWebSessionController.java +++ b/src/java/org/mxchange/jjobs/beans/addressbook/JobsAddressbookWebSessionController.java @@ -17,7 +17,7 @@ package org.mxchange.jjobs.beans.addressbook; import java.io.Serializable; -import java.util.Calendar; +import java.util.Date; import java.util.List; import org.mxchange.jaddressbook.events.addressbook.ObservableAddressbookLoadedEvent; import org.mxchange.jaddressbook.model.addressbook.Addressbook; @@ -130,14 +130,14 @@ public interface JobsAddressbookWebSessionController extends Serializable { *

* @return When the address book has been created */ - Calendar getAddressbookCreated (); + Date getAddressbookCreated (); /** * Setter for when the address book has been created *

* @param addressbookCreated When the address book has been created */ - void setAddressbookCreated (final Calendar addressbookCreated); + void setAddressbookCreated (final Date addressbookCreated); /** * This method is called when an address book has been successfully loaded diff --git a/src/java/org/mxchange/jjobs/beans/business/employee/JobsAdminCompanyEmployeeWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/business/employee/JobsAdminEmployeeWebRequestBean.java similarity index 98% rename from src/java/org/mxchange/jjobs/beans/business/employee/JobsAdminCompanyEmployeeWebRequestBean.java rename to src/java/org/mxchange/jjobs/beans/business/employee/JobsAdminEmployeeWebRequestBean.java index 961daf8e..40a862fa 100644 --- a/src/java/org/mxchange/jjobs/beans/business/employee/JobsAdminCompanyEmployeeWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/business/employee/JobsAdminEmployeeWebRequestBean.java @@ -376,7 +376,7 @@ public class JobsAdminEmployeeWebRequestBean extends BaseJobsBean implements Job private void clear () { // Clear all fields this.setEmployeeBranchOffice(null); - this.setEmployeeCompany(null); + this.setEmployeeBasicData(null); this.setEmployeeDepartment(null); this.setEmployeeEmailAddress(null); this.setEmployeeHeadquarter(null); @@ -393,7 +393,11 @@ public class JobsAdminEmployeeWebRequestBean extends BaseJobsBean implements Job */ private Employable createEmployee () { // Init instance - final Employable employee = new BusinessEmployee(this.getEmployeeCompany(), this.getEmployeeNumber(), this.getEmployeePersonalData()); + final Employable employee = new BusinessEmployee( + this.getEmployeeBasicData(), + this.getEmployeeNumber(), + this.getEmployeePersonalData() + ); // Set all othewr data employee.setEmployeeBranchOffice(this.getEmployeeBranchOffice()); diff --git a/src/java/org/mxchange/jjobs/beans/business/employee/JobsAdminCompanyEmployeeWebRequestController.java b/src/java/org/mxchange/jjobs/beans/business/employee/JobsAdminEmployeeWebRequestController.java similarity index 100% rename from src/java/org/mxchange/jjobs/beans/business/employee/JobsAdminCompanyEmployeeWebRequestController.java rename to src/java/org/mxchange/jjobs/beans/business/employee/JobsAdminEmployeeWebRequestController.java diff --git a/src/java/org/mxchange/jjobs/beans/business/employee/JobsCompanyEmployeeWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/business/employee/JobsEmployeeWebRequestBean.java similarity index 100% rename from src/java/org/mxchange/jjobs/beans/business/employee/JobsCompanyEmployeeWebRequestBean.java rename to src/java/org/mxchange/jjobs/beans/business/employee/JobsEmployeeWebRequestBean.java diff --git a/src/java/org/mxchange/jjobs/beans/business/employee/JobsCompanyEmployeeWebSessionController.java b/src/java/org/mxchange/jjobs/beans/business/employee/JobsEmployeeWebRequestController.java similarity index 100% rename from src/java/org/mxchange/jjobs/beans/business/employee/JobsCompanyEmployeeWebSessionController.java rename to src/java/org/mxchange/jjobs/beans/business/employee/JobsEmployeeWebRequestController.java diff --git a/src/java/org/mxchange/jjobs/beans/data/JobsDataWebApplicationBean.java b/src/java/org/mxchange/jjobs/beans/data/JobsDataWebApplicationBean.java index 4a7983d6..741988e0 100644 --- a/src/java/org/mxchange/jjobs/beans/data/JobsDataWebApplicationBean.java +++ b/src/java/org/mxchange/jjobs/beans/data/JobsDataWebApplicationBean.java @@ -21,7 +21,6 @@ import javax.inject.Named; import org.mxchange.jcontacts.model.contact.title.PersonalTitle; import org.mxchange.jcontactsbusiness.model.opening_time.dayofweek.DayOfTheWeek; import org.mxchange.jjobs.beans.BaseJobsBean; -import org.mxchange.jproduct.model.payment.PaymentType; import org.mxchange.jusercore.model.user.profilemodes.ProfileMode; import org.mxchange.jusercore.model.user.status.UserAccountStatus; @@ -56,15 +55,6 @@ public class JobsDataWebApplicationBean extends BaseJobsBean { return DayOfTheWeek.values(); } - /** - * Returns an array of all payment types - *

- * @return An array of all payment types - */ - public PaymentType[] getPaymentTypes () { - return PaymentType.values(); - } - /** * Returns an array of all personal titles *

diff --git a/src/java/org/mxchange/jjobs/converter/business/basicdata/JobsBusinessContactConverter.java b/src/java/org/mxchange/jjobs/converter/business/basicdata/JobsBasicCompanyDataConverter.java similarity index 100% rename from src/java/org/mxchange/jjobs/converter/business/basicdata/JobsBusinessContactConverter.java rename to src/java/org/mxchange/jjobs/converter/business/basicdata/JobsBasicCompanyDataConverter.java diff --git a/src/java/org/mxchange/jjobs/converter/business/company_employee/JobsCompanyEmployeeConverter.java b/src/java/org/mxchange/jjobs/converter/business/company_employee/JobsEmployeeConverter.java similarity index 61% rename from src/java/org/mxchange/jjobs/converter/business/company_employee/JobsCompanyEmployeeConverter.java rename to src/java/org/mxchange/jjobs/converter/business/company_employee/JobsEmployeeConverter.java index 10f02451..62917c49 100644 --- a/src/java/org/mxchange/jjobs/converter/business/company_employee/JobsCompanyEmployeeConverter.java +++ b/src/java/org/mxchange/jjobs/converter/business/company_employee/JobsEmployeeConverter.java @@ -16,47 +16,36 @@ */ package org.mxchange.jjobs.converter.business.company_employee; -import javax.faces.application.FacesMessage; +import javax.enterprise.inject.spi.CDI; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.convert.Converter; import javax.faces.convert.ConverterException; import javax.faces.convert.FacesConverter; -import javax.faces.validator.ValidatorException; -import javax.naming.Context; -import javax.naming.InitialContext; -import javax.naming.NamingException; -import org.mxchange.jcontactsbusiness.exceptions.employee.CompanyEmployeeNotFoundException; -import org.mxchange.jcontactsbusiness.model.employee.CompanyEmployeeSessionBeanRemote; -import org.mxchange.jcontactsbusiness.model.employee.Employee; +import org.mxchange.jcontactsbusiness.exceptions.employee.EmployeeNotFoundException; +import org.mxchange.jcontactsbusiness.model.employee.Employable; +import org.mxchange.jjobs.beans.business.employee.JobsEmployeeWebRequestBean; +import org.mxchange.jjobs.beans.business.employee.JobsEmployeeWebRequestController; /** * Converter for converting company employee to and from id number *

* @author Roland Häder */ -@FacesConverter ("CompanyEmployeeConverter") -public class JobsCompanyEmployeeConverter implements Converter { +@FacesConverter ("EmployeeConverter") +public class JobsEmployeeConverter implements Converter { /** - * CompanyEmployee EJB + * Employable EJB */ - private static CompanyEmployeeSessionBeanRemote EMPLOYEE_BEAN; + private static JobsEmployeeWebRequestController EMPLOYEE_CONTROLLER; @Override - public Employee getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) { + public Employable getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) { // Is the instance there? - if (EMPLOYEE_BEAN == null) { - try { - // Not yet, attempt lookup - final Context initial = new InitialContext(); - - // Lookup EJB - EMPLOYEE_BEAN = (CompanyEmployeeSessionBeanRemote) initial.lookup("java:global/jjobs-ejb/employee!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 - } + if (null == EMPLOYEE_CONTROLLER) { + // Get bean from CDI directly + EMPLOYEE_CONTROLLER = CDI.current().select(JobsEmployeeWebRequestBean.class).get(); } // Is the value null or empty? @@ -69,18 +58,18 @@ public class JobsCompanyEmployeeConverter implements Converter { } // Init instance - Employee companyEmployee = null; + Employable companyEmployee = null; try { // Try to parse the value as long final Long employeeId = Long.valueOf(submittedValue); // Try to get user instance from it - companyEmployee = EMPLOYEE_BEAN.findCompanyEmployeeById(employeeId); + companyEmployee = EMPLOYEE_CONTROLLER.findEmployeeById(employeeId); } catch (final NumberFormatException ex) { // Throw again throw new ConverterException(ex); - } catch (final CompanyEmployeeNotFoundException ex) { + } catch (final EmployeeNotFoundException ex) { // Debug message // @TODO Not working with JNDI (no remote interface) this.loggerBeanLocal.logDebug(MessageFormat.format("{0}.getAsObject(): Exception: {1} - Returning null ...", this.getClass().getSimpleName(), ex)); //NOI18N } @@ -90,7 +79,7 @@ public class JobsCompanyEmployeeConverter implements Converter { } @Override - public String getAsString (final FacesContext context, final UIComponent component, final Employee value) { + public String getAsString (final FacesContext context, final UIComponent component, final Employable value) { // Is the object null? if ((null == value) || (String.valueOf(value).isEmpty())) { // Is null diff --git a/src/java/org/mxchange/jjobs/converter/business/department/JobsCompanyDepartmentConverter.java b/src/java/org/mxchange/jjobs/converter/business/department/JobsDepartmentConverter.java similarity index 100% rename from src/java/org/mxchange/jjobs/converter/business/department/JobsCompanyDepartmentConverter.java rename to src/java/org/mxchange/jjobs/converter/business/department/JobsDepartmentConverter.java diff --git a/src/java/org/mxchange/jjobs/converter/business/headquarters/JobsCompanyHeadquartersConverter.java b/src/java/org/mxchange/jjobs/converter/business/headquarters/JobsCompanyHeadquartersConverter.java deleted file mode 100644 index 64ebf4df..00000000 --- a/src/java/org/mxchange/jjobs/converter/business/headquarters/JobsCompanyHeadquartersConverter.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * 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 . - */ -package org.mxchange.jjobs.converter.business.headquarters; - -import javax.faces.application.FacesMessage; -import javax.faces.component.UIComponent; -import javax.faces.context.FacesContext; -import javax.faces.convert.Converter; -import javax.faces.convert.ConverterException; -import javax.faces.convert.FacesConverter; -import javax.faces.validator.ValidatorException; -import javax.naming.Context; -import javax.naming.InitialContext; -import javax.naming.NamingException; -import org.mxchange.jcontactsbusiness.exceptions.headquarters.CompanyHeadquartersNotFoundException; -import org.mxchange.jcontactsbusiness.model.headquarters.CompanyHeadquartersSessionBeanRemote; -import org.mxchange.jcontactsbusiness.model.headquarters.HeadquartersData; - -/** - * Converter for converting company headquarters to and from id number - *

- * @author Roland Häder - */ -@FacesConverter ("CompanyHeadquartersConverter") -public class JobsCompanyHeadquartersConverter implements Converter { - - /** - * Headquarters backing bean - * @TODO Undone - */ - private static CompanyHeadquartersSessionBeanRemote HEADQUARTERS_CONTROLLER; - - @Override - public HeadquartersData getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) { - // Is the instance there? - if (HEADQUARTERS_CONTROLLER == null) { - try { - // Not yet, attempt lookup - final Context initial = new InitialContext(); - - // Lookup EJB - HEADQUARTERS_CONTROLLER = (CompanyHeadquartersSessionBeanRemote) initial.lookup("java:global/jjobs-ejb/headquarters!org.mxchange.jcontactsbusiness.model.headquarters.CompanyHeadquartersSessionBeanRemote"); //NOI18N - } catch (final NamingException ex) { - // Throw it again - throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Cannot lookup backing bean", ex.getMessage()), ex); //NOI18N - } - } - - // Is the value null or empty? - if ((null == submittedValue) || (submittedValue.trim().isEmpty())) { - // Warning message - // @TODO Not working with JNDI (no remote interface) this.loggerBeanLocal.logWarning(MessageFormat.format("{0}.getAsObject(): submittedValue is null or empty - EXIT!", this.getClass().getSimpleName())); //NOI18N - - // Return null - return null; - } - - // Init instance - HeadquartersData companyHeadquarters = null; - - try { - // Try to parse the value as long - final Long headquartersId = Long.valueOf(submittedValue); - - // Try to get user instance from it - companyHeadquarters = HEADQUARTERS_CONTROLLER.findCompanyHeadquartersById(headquartersId); - } catch (final NumberFormatException ex) { - // Throw again - throw new ConverterException(ex); - } catch (final CompanyHeadquartersNotFoundException ex) { - // Debug message - // @TODO Not working with JNDI (no remote interface) this.loggerBeanLocal.logDebug(MessageFormat.format("{0}.getAsObject(): Exception: {1} - Returning null ...", this.getClass().getSimpleName(), ex)); //NOI18N - } - - // Return it - return companyHeadquarters; - } - - @Override - public String getAsString (final FacesContext context, final UIComponent component, final HeadquartersData value) { - // Is the object null? - if ((null == value) || (String.valueOf(value).isEmpty())) { - // Is null - return ""; //NOI18N - } - - // Return id number - return String.valueOf(value.getHeadquartersId()); - } - -} diff --git a/src/java/org/mxchange/jjobs/converter/business/headquarters/JobsHeadquarterConverter.java b/src/java/org/mxchange/jjobs/converter/business/headquarters/JobsHeadquarterConverter.java new file mode 100644 index 00000000..c1cc945d --- /dev/null +++ b/src/java/org/mxchange/jjobs/converter/business/headquarters/JobsHeadquarterConverter.java @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2016, 2017 Roland Häder + * + * 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 . + */ +package org.mxchange.jjobs.converter.business.headquarters; + +import javax.enterprise.inject.spi.CDI; +import javax.faces.component.UIComponent; +import javax.faces.context.FacesContext; +import javax.faces.convert.Converter; +import javax.faces.convert.ConverterException; +import javax.faces.convert.FacesConverter; +import org.mxchange.jcontactsbusiness.exceptions.headquarter.HeadquarterNotFoundException; +import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter; +import org.mxchange.jjobs.beans.business.headquarter.JobsHeadquarterWebRequestBean; +import org.mxchange.jjobs.beans.business.headquarter.JobsHeadquarterWebRequestController; + +/** + * Converter for converting company headquarters to and from id number + *

+ * @author Roland Häder + */ +@FacesConverter ("HeadquarterConverter") +public class JobsHeadquarterConverter implements Converter { + + /** + * Headquarter backing bean + */ + private static JobsHeadquarterWebRequestController HEADQUARTER_CONTROLLER; + + @Override + public Headquarter getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) { + // Is the instance there? + if (null == HEADQUARTER_CONTROLLER) { + HEADQUARTER_CONTROLLER = CDI.current().select(JobsHeadquarterWebRequestBean.class).get(); + } + + // Init instance + Headquarter headquarter = null; + + try { + // Try to parse the value as long + final Long headquarterId = Long.valueOf(submittedValue); + + // Try to get user instance from it + headquarter = HEADQUARTER_CONTROLLER.findHeadquarterById(headquarterId); + } catch (final NumberFormatException ex) { + // Throw again + throw new ConverterException(ex); + } catch (final HeadquarterNotFoundException ex) { + // Debug message + // @TODO Not working with JNDI (no remote interface) this.loggerBeanLocal.logDebug(MessageFormat.format("{0}.getAsObject(): Exception: {1} - Returning null ...", this.getClass().getSimpleName(), ex)); //NOI18N + } + + // Return it + return headquarter; + } + + @Override + public String getAsString (final FacesContext context, final UIComponent component, final Headquarter value) { + // Is the object null? + if ((null == value) || (String.valueOf(value).isEmpty())) { + // Is null + return ""; //NOI18N + } + + // Return id number + return String.valueOf(value.getHeadquarterId()); + } + +} -- 2.39.5