From: Roland Häder Date: Fri, 3 Nov 2017 23:56:18 +0000 (+0100) Subject: Please cherry-pick: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=626418b9ee6d5d7f548431bc89f8400e9cbc93e3;p=jjobs-war.git Please cherry-pick: - removed company from "basic_company_data" (and class names) as there will be no other basic data - added view for headquarter listing (administrative) - used more beanHelper's renderFoo(foo) methods as this is much easier to debug - renamed ADMIN_SHOW_PHONE_NUMBER to ADMIN_SHOW__NUMBER - added menu for headquarters (administrative) - added custom JSF tag for administrative "mini-links" for headquarters - added templates for form and opening times of headquarters - fixed employee link outcomes, was copy-paste mistake (ops) - renamed more headquarters -> headquarter - addEmployee() is now "basically finished" - changed h:outputLink to p:link which suits better here - added missing navigation rules for headquarters/employees - isCompanyNameUsed() and isEmailAddressRegistered() should be "basically finished" - still one isEmailAddressRegistered() is left in generic contactController - first value, then variable on comparison (null == someVariable) - lot's more fixes/improvements I cannot remember ... Signed-off-by: Roland Häder --- diff --git a/src/java/org/mxchange/jjobs/beans/business/basicdata/JobsAdminBasicDataWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/business/basicdata/JobsAdminBasicDataWebRequestBean.java new file mode 100644 index 00000000..ee1912d4 --- /dev/null +++ b/src/java/org/mxchange/jjobs/beans/business/basicdata/JobsAdminBasicDataWebRequestBean.java @@ -0,0 +1,514 @@ +/* + * 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.beans.business.basicdata; + +import javax.ejb.EJB; +import javax.enterprise.context.RequestScoped; +import javax.enterprise.event.Event; +import javax.enterprise.inject.Any; +import javax.faces.FacesException; +import javax.inject.Inject; +import javax.inject.Named; +import org.mxchange.jcontactsbusiness.events.basicdata.added.AdminAddedBusinessBasicDataEvent; +import org.mxchange.jcontactsbusiness.events.basicdata.added.ObservableAdminAddedBusinessBasicDataEvent; +import org.mxchange.jcontactsbusiness.exceptions.basicdata.BasicDataAlreadyAddedException; +import org.mxchange.jcontactsbusiness.model.basicdata.AdminBasicCompanyDataSessionBeanRemote; +import org.mxchange.jcontactsbusiness.model.basicdata.BasicData; +import org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData; +import org.mxchange.jcontactsbusiness.model.employee.Employable; +import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter; +import org.mxchange.jcountry.model.data.Country; +import org.mxchange.jjobs.beans.BaseJobsBean; +import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber; +import org.mxchange.jphone.model.phonenumbers.fax.FaxNumber; +import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber; +import org.mxchange.jphone.model.phonenumbers.landline.LandLineNumber; +import org.mxchange.jusercore.model.user.User; + +/** + * An administrative business contact bean (controller) + *

+ * @author Roland Häder + */ +@Named ("adminBasicCompanyDataController") +@RequestScoped +public class JobsAdminBasicDataWebRequestBean extends BaseJobsBean implements JobsAdminBasicDataWebRequestController { + + /** + * Serial number + */ + private static final long serialVersionUID = 56_189_028_928_374L; + + /** + * EJB for administrative purposes + */ + @EJB (lookup = "java:global/jjobs-ejb/adminBasicCompanyData!org.mxchange.jcontactsbusiness.model.basicdata.AdminBasicCompanyDataSessionBeanRemote") + private AdminBasicCompanyDataSessionBeanRemote adminBasicCompanyDataBean; + + /** + * An event being fired when basic business data has been added + */ + @Inject + @Any + private Event businessDataAddedEvent; + + /** + * Comments for this company + */ + private String companyComments; + + /** + * An employee as contact person with this company + */ + private Employable companyContactEmployee; + + /** + * Companies (main) email address (example: info@company.example) + */ + private String companyEmailAddress; + + /** + * Company founder + */ + private Employable companyFounder; + + /** + * Headquarter data for this company + */ + private Headquarter companyHeadQuarter; + + /** + * Company name + */ + private String companyName; + + /** + * Tax number + */ + private String companyTaxNumber; + + /** + * Owning user instance (which this company is assigned to) + */ + private User companyUserOwner; + + /** + * Web site URL + */ + private String companyWebsiteUrl; + + /** + * Area code for fax number + */ + private Integer faxAreaCode; + + /** + * Country for fax number + */ + private Country faxCountry; + + /** + * Dial number for fax number + */ + private Long faxNumber; + + /** + * Area code for land-line number + */ + private Integer landLineAreaCode; + + /** + * Country for land-line number + */ + private Country landLineCountry; + + /** + * Dial number for land-line number + */ + private Long landLineNumber; + + /** + * Default constructor + */ + public JobsAdminBasicDataWebRequestBean () { + // Call super constructor + super(); + } + + /** + * Adds a basic business data entry, if not yet found. + *

+ * @return Redirect outcome + */ + public String addBusinessBasicData () { + // First, validate all parameter + if (this.getCompanyName() == null) { + // Is null + throw new NullPointerException("this.companyName is null"); //NOI18N + } else if (this.getCompanyName().isEmpty()) { + // Is null + throw new IllegalArgumentException("this.companyName is empty"); //NOI18N + } + + // Prepare entity + BasicData basicData = new BusinessBasicData(this.getCompanyName()); + + // Set all opther remaining data + basicData.setCompanyComments(this.getCompanyComments()); + basicData.setCompanyContactEmployee(this.getCompanyContactEmployee()); + basicData.setCompanyEmailAddress(this.getCompanyEmailAddress()); + basicData.setCompanyFounder(this.getCompanyFounder()); + basicData.setCompanyHeadquarterData(this.getCompanyHeadQuarter()); + basicData.setCompanyTaxNumber(this.getCompanyTaxNumber()); + basicData.setCompanyUserOwner(this.getCompanyUserOwner()); + basicData.setCompanyWebsiteUrl(this.getCompanyWebsiteUrl()); + + // Set logo instance + // @TODO basicData.setCompanyLogo(); + // Generate phone number + DialableLandLineNumber landLine = new LandLineNumber(this.getLandLineCountry(), this.getLandLineAreaCode(), this.getLandLineNumber()); + DialableFaxNumber fax = new FaxNumber(this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber()); + + // Don't set null or wrong references + if ((landLine instanceof DialableLandLineNumber) && (landLine.getPhoneCountry() instanceof Country) && (this.getLandLineAreaCode() != null) && (this.getLandLineNumber() != null) && (this.getLandLineAreaCode() > 0) && (this.getLandLineNumber() > 0)) { + // Now the number must be given + if (landLine.getPhoneAreaCode() == null) { + // Is null + throw new NullPointerException("phone.phoneAreaCode is null"); //NOI18N + } else if (landLine.getPhoneAreaCode() < 1) { + // Abort here + throw new IllegalArgumentException("phone.phoneAreaCode is zero or below."); //NOI18N + } else if (landLine.getPhoneNumber() == null) { + // Is null + throw new NullPointerException("phone.phoneNumber is null"); //NOI18N + } else if (landLine.getPhoneNumber() < 1) { + // Abort here + throw new IllegalArgumentException("phone.phoneNumber is zero or below."); //NOI18N + } + + // Set phone number + basicData.setCompanyLandLineNumber(landLine); + } + + // Don't set null or wrong references + if ((fax instanceof DialableFaxNumber) && (fax.getPhoneCountry() instanceof Country) && (this.getFaxAreaCode() != null) && (this.getFaxNumber() != null) && (this.getFaxAreaCode() > 0) && (this.getFaxNumber() > 0)) { + // Now the number must be given + if (fax.getPhoneAreaCode() == null) { + // Is null + throw new NullPointerException("fax.phoneAreaCode is null"); //NOI18N + } else if (fax.getPhoneAreaCode() < 1) { + // Abort here + throw new IllegalArgumentException("fax.phoneAreaCode is zero or below."); //NOI18N + } else if (fax.getPhoneNumber() == null) { + // Is null + throw new NullPointerException("fax.phoneNumber is null"); //NOI18N + } else if (fax.getPhoneNumber() < 1) { + // Abort here + throw new IllegalArgumentException("fax.phoneNumber is zero or below."); //NOI18N + } + + // Set fax number + basicData.setCompanyFaxNumber(fax); + } + + // Now try to send to EJB and get an updated version back + try { + // Try it + final BasicData updatedBasicData = this.adminBasicCompanyDataBean.addBusinessBasicData(basicData); + + // Fire event + this.businessDataAddedEvent.fire(new AdminAddedBusinessBasicDataEvent(updatedBasicData)); + } catch (final BasicDataAlreadyAddedException e) { + // Does already exist + throw new FacesException(e); + } + + // Continue to list again + return "admin_list_basic_data"; //NOI18N + } + + /** + * Getter for comments + *

+ * @return Comments + */ + public String getCompanyComments () { + return this.companyComments; + } + + /** + * Setter for comments + *

+ * @param companyComments Comments + */ + public void setCompanyComments (final String companyComments) { + this.companyComments = companyComments; + } + + /** + * Getter for employee as contact person + *

+ * @return Employable as contact person + */ + public Employable getCompanyContactEmployee () { + return this.companyContactEmployee; + } + + /** + * Setter for employee as contact person + *

+ * @param companyContactEmployee Employable as contact person + */ + public void setCompanyContactEmployee (final Employable companyContactEmployee) { + this.companyContactEmployee = companyContactEmployee; + } + + /** + * Getter for company's (main) email address + *

+ * @return Company's (main) email address + */ + public String getCompanyEmailAddress () { + return this.companyEmailAddress; + } + + /** + * Setter for company's (main) email address + *

+ * @param companyEmailAddress Company's (main) email address + */ + public void setCompanyEmailAddress (final String companyEmailAddress) { + this.companyEmailAddress = companyEmailAddress; + } + + /** + * Getter for company founder + *

+ * @return Company founder + */ + public Employable getCompanyFounder () { + return this.companyFounder; + } + + /** + * Setter for company founder + *

+ * @param companyFounder Company founder + */ + public void setCompanyFounder (final Employable companyFounder) { + this.companyFounder = companyFounder; + } + + /** + * Getter for headquarter data + *

+ * @return Headquarter data + */ + public Headquarter getCompanyHeadQuarter () { + return this.companyHeadQuarter; + } + + /** + * Setter for headquarter data + *

+ * @param companyHeadQuarter Headquarter data + */ + public void setCompanyHeadQuarter (final Headquarter companyHeadQuarter) { + this.companyHeadQuarter = companyHeadQuarter; + } + + /** + * Getter for company name + *

+ * @return Company name + */ + public String getCompanyName () { + return this.companyName; + } + + /** + * Setter for company name + *

+ * @param companyName Company name + */ + public void setCompanyName (final String companyName) { + this.companyName = companyName; + } + + /** + * Getter for company tax number + *

+ * @return Company tax number + */ + public String getCompanyTaxNumber () { + return this.companyTaxNumber; + } + + /** + * Setter for company tax number + *

+ * @param companyTaxNumber Company tax number + */ + public void setCompanyTaxNumber (final String companyTaxNumber) { + this.companyTaxNumber = companyTaxNumber; + } + + /** + * Getter for owning user instance + *

+ * @return Owning user instance + */ + public User getCompanyUserOwner () { + return this.companyUserOwner; + } + + /** + * Setter for owning user instance + *

+ * @param companyUserOwner Owning user instance + */ + public void setCompanyUserOwner (final User companyUserOwner) { + this.companyUserOwner = companyUserOwner; + } + + /** + * Getter for company web site URL + *

+ * @return Company web site URL + */ + public String getCompanyWebsiteUrl () { + return this.companyWebsiteUrl; + } + + /** + * Getter for company web site URL + *

+ * @param companyWebsiteUrl Company web site URL + */ + public void setCompanyWebsiteUrl (final String companyWebsiteUrl) { + this.companyWebsiteUrl = companyWebsiteUrl; + } + + /** + * Getter for fax number's area code + *

+ * @return Fax number's area code + */ + public Integer getFaxAreaCode () { + return this.faxAreaCode; + } + + /** + * Setter for fax number's area code + *

+ * @param faxAreaCode Fax number's area code + */ + public void setFaxAreaCode (final Integer faxAreaCode) { + this.faxAreaCode = faxAreaCode; + } + + /** + * Getter for fax's country instance + *

+ * @return Fax' country instance + */ + public Country getFaxCountry () { + return this.faxCountry; + } + + /** + * Setter for fax's country instance + *

+ * @param faxCountry Fax' country instance + */ + public void setFaxCountry (final Country faxCountry) { + this.faxCountry = faxCountry; + } + + /** + * Getter for fax number + *

+ * @return Fax number + */ + public Long getFaxNumber () { + return this.faxNumber; + } + + /** + * Setter for fax number + *

+ * @param faxNumber Fax number + */ + public void setFaxNumber (final Long faxNumber) { + this.faxNumber = faxNumber; + } + + /** + * Getter for land-line number's area code + *

+ * @return Land-line number's area code + */ + public Integer getLandLineAreaCode () { + return this.landLineAreaCode; + } + + /** + * Setter for land-line number's area code + *

+ * @param landLineAreaCode Land-line number's area code + */ + public void setLandLineAreaCode (final Integer landLineAreaCode) { + this.landLineAreaCode = landLineAreaCode; + } + + /** + * Getter for land-line number's country instance + *

+ * @return Land-line number's country instance + */ + public Country getLandLineCountry () { + return this.landLineCountry; + } + + /** + * Setter for land-line number's country instance + *

+ * @param landLineCountry Land-line number's country instance + */ + public void setLandLineCountry (final Country landLineCountry) { + this.landLineCountry = landLineCountry; + } + + /** + * Getter for land-line number + *

+ * @return Land-line number + */ + public Long getLandLineNumber () { + return this.landLineNumber; + } + + /** + * Setter for land-line number + *

+ * @param landLineNumber Land-line number + */ + public void setLandLineNumber (final Long landLineNumber) { + this.landLineNumber = landLineNumber; + } + +} diff --git a/src/java/org/mxchange/jjobs/beans/business/basicdata/JobsAdminBasicDataWebRequestController.java b/src/java/org/mxchange/jjobs/beans/business/basicdata/JobsAdminBasicDataWebRequestController.java new file mode 100644 index 00000000..371c0f87 --- /dev/null +++ b/src/java/org/mxchange/jjobs/beans/business/basicdata/JobsAdminBasicDataWebRequestController.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 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.beans.business.basicdata; + +import java.io.Serializable; + +/** + * An interface for session-scoped financial controller + *

+ * @author Roland Häder + */ +public interface JobsAdminBasicDataWebRequestController extends Serializable { + +} diff --git a/src/java/org/mxchange/jjobs/beans/business/basicdata/JobsAdminBusinessDataWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/business/basicdata/JobsAdminBusinessDataWebRequestBean.java deleted file mode 100644 index 542a1ede..00000000 --- a/src/java/org/mxchange/jjobs/beans/business/basicdata/JobsAdminBusinessDataWebRequestBean.java +++ /dev/null @@ -1,514 +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.beans.business.basicdata; - -import javax.ejb.EJB; -import javax.enterprise.context.RequestScoped; -import javax.enterprise.event.Event; -import javax.enterprise.inject.Any; -import javax.faces.FacesException; -import javax.inject.Inject; -import javax.inject.Named; -import org.mxchange.jcontactsbusiness.events.basicdata.added.AdminAddedBusinessBasicDataEvent; -import org.mxchange.jcontactsbusiness.events.basicdata.added.ObservableAdminAddedBusinessBasicDataEvent; -import org.mxchange.jcontactsbusiness.exceptions.basicdata.BasicDataAlreadyAddedException; -import org.mxchange.jcontactsbusiness.model.basicdata.AdminBasicCompanyDataSessionBeanRemote; -import org.mxchange.jcontactsbusiness.model.basicdata.BasicData; -import org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData; -import org.mxchange.jcontactsbusiness.model.employee.Employable; -import org.mxchange.jcontactsbusiness.model.headquarters.HeadquartersData; -import org.mxchange.jcountry.model.data.Country; -import org.mxchange.jjobs.beans.BaseJobsBean; -import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber; -import org.mxchange.jphone.model.phonenumbers.fax.FaxNumber; -import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber; -import org.mxchange.jphone.model.phonenumbers.landline.LandLineNumber; -import org.mxchange.jusercore.model.user.User; - -/** - * An administrative business contact bean (controller) - *

- * @author Roland Häder - */ -@Named ("adminBasicCompanyDataController") -@RequestScoped -public class JobsAdminBusinessDataWebRequestBean extends BaseJobsBean implements JobsAdminBusinessDataWebRequestController { - - /** - * Serial number - */ - private static final long serialVersionUID = 56_189_028_928_374L; - - /** - * EJB for administrative purposes - */ - @EJB (lookup = "java:global/jjobs-ejb/adminBasicCompanyData!org.mxchange.jcontactsbusiness.model.basicdata.AdminBasicCompanyDataSessionBeanRemote") - private AdminBasicCompanyDataSessionBeanRemote adminBasicCompanyDataBean; - - /** - * An event being fired when basic business data has been added - */ - @Inject - @Any - private Event businessDataAddedEvent; - - /** - * Comments for this company - */ - private String companyComments; - - /** - * An employee as contact person with this company - */ - private Employable companyContactEmployee; - - /** - * Companies (main) email address (example: info@company.example) - */ - private String companyEmailAddress; - - /** - * Company founder - */ - private Employable companyFounder; - - /** - * Head quarter data for this company - */ - private HeadquartersData companyHeadQuarters; - - /** - * Company name - */ - private String companyName; - - /** - * Tax number - */ - private String companyTaxNumber; - - /** - * Owning user instance (which this company is assigned to) - */ - private User companyUserOwner; - - /** - * Web site URL - */ - private String companyWebsiteUrl; - - /** - * Area code for fax number - */ - private Integer faxAreaCode; - - /** - * Country for fax number - */ - private Country faxCountry; - - /** - * Dial number for fax number - */ - private Long faxNumber; - - /** - * Area code for land-line number - */ - private Integer landLineAreaCode; - - /** - * Country for land-line number - */ - private Country landLineCountry; - - /** - * Dial number for land-line number - */ - private Long landLineNumber; - - /** - * Default constructor - */ - public JobsAdminBusinessDataWebRequestBean () { - // Call super constructor - super(); - } - - /** - * Adds a basic business data entry, if not yet found. - *

- * @return Redirect outcome - */ - public String addBusinessBasicData () { - // First, validate all parameter - if (this.getCompanyName() == null) { - // Is null - throw new NullPointerException("this.companyName is null"); //NOI18N - } else if (this.getCompanyName().isEmpty()) { - // Is null - throw new IllegalArgumentException("this.companyName is empty"); //NOI18N - } - - // Prepare entity - BasicData basicData = new BusinessBasicData(this.getCompanyName()); - - // Set all opther remaining data - basicData.setCompanyComments(this.getCompanyComments()); - basicData.setCompanyContactEmployee(this.getCompanyContactEmployee()); - basicData.setCompanyEmailAddress(this.getCompanyEmailAddress()); - basicData.setCompanyFounder(this.getCompanyFounder()); - basicData.setCompanyHeadQuartersData(this.getCompanyHeadQuarters()); - basicData.setCompanyTaxNumber(this.getCompanyTaxNumber()); - basicData.setCompanyUserOwner(this.getCompanyUserOwner()); - basicData.setCompanyWebsiteUrl(this.getCompanyWebsiteUrl()); - - // Set logo instance - // @TODO basicData.setCompanyLogo(); - // Generate phone number - DialableLandLineNumber landLine = new LandLineNumber(this.getLandLineCountry(), this.getLandLineAreaCode(), this.getLandLineNumber()); - DialableFaxNumber fax = new FaxNumber(this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber()); - - // Don't set null or wrong references - if ((landLine instanceof DialableLandLineNumber) && (landLine.getPhoneCountry() instanceof Country) && (this.getLandLineAreaCode() != null) && (this.getLandLineNumber() != null) && (this.getLandLineAreaCode() > 0) && (this.getLandLineNumber() > 0)) { - // Now the number must be given - if (landLine.getPhoneAreaCode() == null) { - // Is null - throw new NullPointerException("phone.phoneAreaCode is null"); //NOI18N - } else if (landLine.getPhoneAreaCode() < 1) { - // Abort here - throw new IllegalArgumentException("phone.phoneAreaCode is zero or below."); //NOI18N - } else if (landLine.getPhoneNumber() == null) { - // Is null - throw new NullPointerException("phone.phoneNumber is null"); //NOI18N - } else if (landLine.getPhoneNumber() < 1) { - // Abort here - throw new IllegalArgumentException("phone.phoneNumber is zero or below."); //NOI18N - } - - // Set phone number - basicData.setCompanyLandLineNumber(landLine); - } - - // Don't set null or wrong references - if ((fax instanceof DialableFaxNumber) && (fax.getPhoneCountry() instanceof Country) && (this.getFaxAreaCode() != null) && (this.getFaxNumber() != null) && (this.getFaxAreaCode() > 0) && (this.getFaxNumber() > 0)) { - // Now the number must be given - if (fax.getPhoneAreaCode() == null) { - // Is null - throw new NullPointerException("fax.phoneAreaCode is null"); //NOI18N - } else if (fax.getPhoneAreaCode() < 1) { - // Abort here - throw new IllegalArgumentException("fax.phoneAreaCode is zero or below."); //NOI18N - } else if (fax.getPhoneNumber() == null) { - // Is null - throw new NullPointerException("fax.phoneNumber is null"); //NOI18N - } else if (fax.getPhoneNumber() < 1) { - // Abort here - throw new IllegalArgumentException("fax.phoneNumber is zero or below."); //NOI18N - } - - // Set fax number - basicData.setCompanyFaxNumber(fax); - } - - // Now try to send to EJB and get an updated version back - try { - // Try it - final BasicData updatedBasicData = this.adminBasicCompanyDataBean.addBusinessBasicData(basicData); - - // Fire event - this.businessDataAddedEvent.fire(new AdminAddedBusinessBasicDataEvent(updatedBasicData)); - } catch (final BasicDataAlreadyAddedException e) { - // Does already exist - throw new FacesException(e); - } - - // Continue to list again - return "admin_list_basic_company_data"; //NOI18N - } - - /** - * Getter for comments - *

- * @return Comments - */ - public String getCompanyComments () { - return this.companyComments; - } - - /** - * Setter for comments - *

- * @param companyComments Comments - */ - public void setCompanyComments (final String companyComments) { - this.companyComments = companyComments; - } - - /** - * Getter for employee as contact person - *

- * @return Employable as contact person - */ - public Employable getCompanyContactEmployee () { - return this.companyContactEmployee; - } - - /** - * Setter for employee as contact person - *

- * @param companyContactEmployee Employable as contact person - */ - public void setCompanyContactEmployee (final Employable companyContactEmployee) { - this.companyContactEmployee = companyContactEmployee; - } - - /** - * Getter for company's (main) email address - *

- * @return Company's (main) email address - */ - public String getCompanyEmailAddress () { - return this.companyEmailAddress; - } - - /** - * Setter for company's (main) email address - *

- * @param companyEmailAddress Company's (main) email address - */ - public void setCompanyEmailAddress (final String companyEmailAddress) { - this.companyEmailAddress = companyEmailAddress; - } - - /** - * Getter for company founder - *

- * @return Company founder - */ - public Employable getCompanyFounder () { - return this.companyFounder; - } - - /** - * Setter for company founder - *

- * @param companyFounder Company founder - */ - public void setCompanyFounder (final Employable companyFounder) { - this.companyFounder = companyFounder; - } - - /** - * Getter for headquarters data - *

- * @return Headquarters data - */ - public HeadquartersData getCompanyHeadQuarters () { - return this.companyHeadQuarters; - } - - /** - * Setter for headquarters data - *

- * @param companyHeadQuarters Headquarters data - */ - public void setCompanyHeadQuarters (final HeadquartersData companyHeadQuarters) { - this.companyHeadQuarters = companyHeadQuarters; - } - - /** - * Getter for company name - *

- * @return Company name - */ - public String getCompanyName () { - return this.companyName; - } - - /** - * Setter for company name - *

- * @param companyName Company name - */ - public void setCompanyName (final String companyName) { - this.companyName = companyName; - } - - /** - * Getter for company tax number - *

- * @return Company tax number - */ - public String getCompanyTaxNumber () { - return this.companyTaxNumber; - } - - /** - * Setter for company tax number - *

- * @param companyTaxNumber Company tax number - */ - public void setCompanyTaxNumber (final String companyTaxNumber) { - this.companyTaxNumber = companyTaxNumber; - } - - /** - * Getter for owning user instance - *

- * @return Owning user instance - */ - public User getCompanyUserOwner () { - return this.companyUserOwner; - } - - /** - * Setter for owning user instance - *

- * @param companyUserOwner Owning user instance - */ - public void setCompanyUserOwner (final User companyUserOwner) { - this.companyUserOwner = companyUserOwner; - } - - /** - * Getter for company web site URL - *

- * @return Company web site URL - */ - public String getCompanyWebsiteUrl () { - return this.companyWebsiteUrl; - } - - /** - * Getter for company web site URL - *

- * @param companyWebsiteUrl Company web site URL - */ - public void setCompanyWebsiteUrl (final String companyWebsiteUrl) { - this.companyWebsiteUrl = companyWebsiteUrl; - } - - /** - * Getter for fax number's area code - *

- * @return Fax number's area code - */ - public Integer getFaxAreaCode () { - return this.faxAreaCode; - } - - /** - * Setter for fax number's area code - *

- * @param faxAreaCode Fax number's area code - */ - public void setFaxAreaCode (final Integer faxAreaCode) { - this.faxAreaCode = faxAreaCode; - } - - /** - * Getter for fax's country instance - *

- * @return Fax' country instance - */ - public Country getFaxCountry () { - return this.faxCountry; - } - - /** - * Setter for fax's country instance - *

- * @param faxCountry Fax' country instance - */ - public void setFaxCountry (final Country faxCountry) { - this.faxCountry = faxCountry; - } - - /** - * Getter for fax number - *

- * @return Fax number - */ - public Long getFaxNumber () { - return this.faxNumber; - } - - /** - * Setter for fax number - *

- * @param faxNumber Fax number - */ - public void setFaxNumber (final Long faxNumber) { - this.faxNumber = faxNumber; - } - - /** - * Getter for land-line number's area code - *

- * @return Land-line number's area code - */ - public Integer getLandLineAreaCode () { - return this.landLineAreaCode; - } - - /** - * Setter for land-line number's area code - *

- * @param landLineAreaCode Land-line number's area code - */ - public void setLandLineAreaCode (final Integer landLineAreaCode) { - this.landLineAreaCode = landLineAreaCode; - } - - /** - * Getter for land-line number's country instance - *

- * @return Land-line number's country instance - */ - public Country getLandLineCountry () { - return this.landLineCountry; - } - - /** - * Setter for land-line number's country instance - *

- * @param landLineCountry Land-line number's country instance - */ - public void setLandLineCountry (final Country landLineCountry) { - this.landLineCountry = landLineCountry; - } - - /** - * Getter for land-line number - *

- * @return Land-line number - */ - public Long getLandLineNumber () { - return this.landLineNumber; - } - - /** - * Setter for land-line number - *

- * @param landLineNumber Land-line number - */ - public void setLandLineNumber (final Long landLineNumber) { - this.landLineNumber = landLineNumber; - } - -} diff --git a/src/java/org/mxchange/jjobs/beans/business/basicdata/JobsAdminBusinessDataWebRequestController.java b/src/java/org/mxchange/jjobs/beans/business/basicdata/JobsAdminBusinessDataWebRequestController.java deleted file mode 100644 index 3154e41b..00000000 --- a/src/java/org/mxchange/jjobs/beans/business/basicdata/JobsAdminBusinessDataWebRequestController.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 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.beans.business.basicdata; - -import java.io.Serializable; - -/** - * An interface for session-scoped basic data controller - *

- * @author Roland Häder - */ -public interface JobsAdminBusinessDataWebRequestController extends Serializable { - -} diff --git a/src/java/org/mxchange/jjobs/beans/business/basicdata/JobsBasicDataWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/business/basicdata/JobsBasicDataWebRequestBean.java new file mode 100644 index 00000000..e2097dda --- /dev/null +++ b/src/java/org/mxchange/jjobs/beans/business/basicdata/JobsBasicDataWebRequestBean.java @@ -0,0 +1,497 @@ +/* + * 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.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; +import java.util.Objects; +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.jcontactsbusiness.events.basicdata.added.ObservableAdminAddedBusinessBasicDataEvent; +import org.mxchange.jcontactsbusiness.exceptions.basicdata.BasicDataNotFoundException; +import org.mxchange.jcontactsbusiness.model.basicdata.AdminBasicCompanyDataSessionBeanRemote; +import org.mxchange.jcontactsbusiness.model.basicdata.BasicCompanyDataSessionBeanRemote; +import org.mxchange.jcontactsbusiness.model.basicdata.BasicData; +import org.mxchange.jcountry.model.data.Country; +import org.mxchange.jjobs.beans.BaseJobsBean; +import org.mxchange.jjobs.beans.user.login.JobsUserLoginWebSessionController; + +/** + * A business contact bean (controller) + *

+ * @author Roland Häder + */ +@Named ("basicCompanyDataController") +@RequestScoped +public class JobsBasicDataWebRequestBean extends BaseJobsBean implements JobsBasicDataWebRequestController { + + /** + * Serial number + */ + private static final long serialVersionUID = 56_189_028_928_371L; + + /** + * EJB for administrative basic business data purposes + */ + @EJB (lookup = "java:global/jjobs-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 final List allBasicData; + + /** + * A list of all registered companies (globally) + */ + @Inject + @NamedCache (cacheName = "basicDataCache") + private Cache basicDataCache; + + /** + * EJB for general basic business data purposes + */ + @EJB (lookup = "java:global/jjobs-ejb/basicCompanyData!org.mxchange.jcontactsbusiness.model.basicdata.BasicCompanyDataSessionBeanRemote", description = "A stateless session bean for general purposes.") + private BasicCompanyDataSessionBeanRemote businessDataBean; + + /** + * Comments for this company + */ + private String companyComments; + + /** + * Companies (main) email address (example: info@company.example) + */ + private String companyEmailAddress; + + /** + * Company cacheName + */ + private String companyName; + + /** + * Area code for fax number + */ + private Integer faxAreaCode; + + /** + * Country for fax number + */ + private Country faxCountry; + + /** + * Dial number for fax number + */ + private Long faxNumber; + + /** + * List of filtered basic company data + */ + private List filteredBasicCompanyData; + + /** + * Area code for land-line number + */ + private Integer landLineAreaCode; + + /** + * Country for land-line number + */ + private Country landLineCountry; + + /** + * Dial number for land-line number + */ + private Long landLineNumber; + + /** + * User instance + */ + @Inject + private JobsUserLoginWebSessionController userLoginController; + + /** + * Constructor + */ + public JobsBasicDataWebRequestBean () { + // Call super constructor + super(); + + // Init list + this.allBasicData = new LinkedList<>(); + } + + /** + * Observers events being fired when an administrator has added company + * basic data. + *

+ * @param event Event being fired + */ + public void afterAdminAddedBasicCompanyDataEvent (@Observes final ObservableAdminAddedBusinessBasicDataEvent event) { + // Is the parameter valid? + if (null == event) { + // Throw NPE + throw new NullPointerException("event is null"); //NOI18N + } else if (event.getBasicData() == null) { + // Throw NPE again + throw new NullPointerException("event.basicData is null"); //NOI18N + } else if (event.getBasicData().getBasicDataId() == null) { + // Throw NPE again + throw new NullPointerException("event.basicData.basicDataId is null"); //NOI18N + } else if (event.getBasicData().getBasicDataId() < 1) { + // Throw IAE + throw new IllegalArgumentException(MessageFormat.format("event.basicData.basicDataId={0} is invalid", event.getBasicData().getBasicDataId())); //NOI18N + } else if (event.getBasicData().getCompanyName() == null) { + // Throw NPE again + throw new NullPointerException("event.basicData.companyName is null"); //NOI18N + } else if (event.getBasicData().getCompanyName().isEmpty()) { + // Throw IAE again + throw new IllegalArgumentException("event.basicData.companyName is empty"); //NOI18N + } + + // Add it to list + this.basicDataCache.put(event.getBasicData().getBasicDataId(), event.getBasicData()); + this.allBasicData.add(event.getBasicData()); + } + + /** + * Getter for a list of all business contacts + *

+ * @return A list of all business contacts + */ + @SuppressWarnings ("ReturnOfCollectionOrArrayField") + public List allBasicData () { + return this.allBasicData; + } + + @Override + public BasicData findBasicDataById (final Long basicDataId) throws BasicDataNotFoundException { + // Validate parameter + if (null == basicDataId) { + // Throw NPE + throw new NullPointerException("basicDataId is null"); //NOI18N + } else if (basicDataId < 1) { + // Throw IAE + throw new IllegalArgumentException(MessageFormat.format("basicDataId={0} is invalid", basicDataId)); //NOI18N + } else if (!this.basicDataCache.containsKey(basicDataId)) { + // Not found + throw new BasicDataNotFoundException(basicDataId); + } + + // Get it from cache + final BasicData basicData = this.basicDataCache.get(basicDataId); + + // Return it + return basicData; + } + + /** + * Getter for comments + *

+ * @return Comments + */ + public String getCompanyComments () { + return this.companyComments; + } + + /** + * Setter for comments + *

+ * @param companyComments Comments + */ + public void setCompanyComments (final String companyComments) { + this.companyComments = companyComments; + } + + /** + * Getter for company's (main) email address + *

+ * @return Company's (main) email address + */ + public String getCompanyEmailAddress () { + return this.companyEmailAddress; + } + + /** + * Setter for company's (main) email address + *

+ * @param companyEmailAddress Company's (main) email address + */ + public void setCompanyEmailAddress (final String companyEmailAddress) { + this.companyEmailAddress = companyEmailAddress; + } + + /** + * Getter for company cacheName + *

+ * @return Company cacheName + */ + public String getCompanyName () { + return this.companyName; + } + + /** + * Setter for company cacheName + *

+ * @param companyName Company cacheName + */ + public void setCompanyName (final String companyName) { + this.companyName = companyName; + } + + /** + * Getter for fax number's area code + *

+ * @return Fax number's area code + */ + public Integer getFaxAreaCode () { + return this.faxAreaCode; + } + + /** + * Setter for fax number's area code + *

+ * @param faxAreaCode Fax number's area code + */ + public void setFaxAreaCode (final Integer faxAreaCode) { + this.faxAreaCode = faxAreaCode; + } + + /** + * Getter for fax's country instance + *

+ * @return Fax' country instance + */ + public Country getFaxCountry () { + return this.faxCountry; + } + + /** + * Setter for fax's country instance + *

+ * @param faxCountry Fax' country instance + */ + public void setFaxCountry (final Country faxCountry) { + this.faxCountry = faxCountry; + } + + /** + * Getter for fax number + *

+ * @return Fax number + */ + public Long getFaxNumber () { + return this.faxNumber; + } + + /** + * Setter for fax number + *

+ * @param faxNumber Fax number + */ + public void setFaxNumber (final Long faxNumber) { + 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 + *

+ * @return Land-line number's area code + */ + public Integer getLandLineAreaCode () { + return this.landLineAreaCode; + } + + /** + * Setter for land-line number's area code + *

+ * @param landLineAreaCode Land-line number's area code + */ + public void setLandLineAreaCode (final Integer landLineAreaCode) { + this.landLineAreaCode = landLineAreaCode; + } + + /** + * Getter for land-line number's country instance + *

+ * @return Land-line number's country instance + */ + public Country getLandLineCountry () { + return this.landLineCountry; + } + + /** + * Setter for land-line number's country instance + *

+ * @param landLineCountry Land-line number's country instance + */ + public void setLandLineCountry (final Country landLineCountry) { + this.landLineCountry = landLineCountry; + } + + /** + * Getter for land-line number + *

+ * @return Land-line number + */ + public Long getLandLineNumber () { + return this.landLineNumber; + } + + /** + * Setter for land-line number + *

+ * @param landLineNumber Land-line number + */ + public void setLandLineNumber (final Long landLineNumber) { + this.landLineNumber = landLineNumber; + } + + /** + * Initializer method + */ + @PostConstruct + public void initializeList () { + // Is cache there? + if (!this.basicDataCache.iterator().hasNext()) { + // Get whole list + final List basicDatas = this.businessDataBean.allBusinessBasicData(); + + // Add all + for (final BasicData basicData : basicDatas) { + // Add it to cache + this.basicDataCache.put(basicData.getBasicDataId(), basicData); + } + } + + // Is cache there and list is not full? + if ((this.allBasicData.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.allBasicData.add(next.getValue()); + } + + // Sort list + this.allBasicData.sort(new Comparator() { + @Override + public int compare (final BasicData o1, final BasicData o2) { + return o1.getBasicDataId() > o2.getBasicDataId() ? 1 : o1.getBasicDataId() < o2.getBasicDataId() ? -1 : 0; + } + }); + } + } + + @Override + public Boolean isCompanyNameUsed (final String companyName) { + // Validate parameter + if (null == companyName) { + // Throw NPE + throw new NullPointerException("companyName is null"); //NOI18N + } else if (companyName.isEmpty()) { + // Throw IAE + throw new IllegalArgumentException("companyName is empty"); //NOI18N + } + + // Default is not found + boolean isFound = false; + + // Check all entries + for (final BasicData basicData : this.allBasicData()) { + // Is same company name? + if (Objects.equals(basicData.getCompanyName(), companyName)) { + // Found it + isFound = true; + break; + } + } + + // Return flag + return isFound; + } + + @Override + public Boolean isEmailAddressRegistered (final String emailAddress) { + // Default is not found + boolean isFound = false; + + // Check all entries + for (final BasicData basicData : this.allBasicData()) { + // Is email address used? + if (Objects.equals(basicData.getCompanyEmailAddress(), emailAddress)) { + // Found it + isFound = true; + break; + } + } + + // Return flag + return isFound; + } + + /** + * Clears this bean + */ + private void clear () { + // Clear all data: + this.setCompanyComments(null); + this.setCompanyEmailAddress(null); + this.setCompanyName(null); + this.setFaxAreaCode(null); + this.setFaxCountry(null); + this.setFaxNumber(null); + this.setLandLineAreaCode(null); + this.setLandLineCountry(null); + this.setLandLineNumber(null); + } + +} diff --git a/src/java/org/mxchange/jjobs/beans/business/basicdata/JobsBasicDataWebRequestController.java b/src/java/org/mxchange/jjobs/beans/business/basicdata/JobsBasicDataWebRequestController.java new file mode 100644 index 00000000..056dc969 --- /dev/null +++ b/src/java/org/mxchange/jjobs/beans/business/basicdata/JobsBasicDataWebRequestController.java @@ -0,0 +1,62 @@ +/* + * Copyright (C) 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.beans.business.basicdata; + +import java.io.Serializable; +import org.mxchange.jcontactsbusiness.exceptions.basicdata.BasicDataNotFoundException; +import org.mxchange.jcontactsbusiness.model.basicdata.BasicData; + +/** + * An interface for session-scoped financial controller + *

+ * @author Roland Häder + */ +public interface JobsBasicDataWebRequestController extends Serializable { + + /** + * Checks if given email address is already registered by other basic + * company data + *

+ * @param emailAddress Email address + *

+ * @return Whether the email address has been already registered + */ + Boolean isEmailAddressRegistered (final String emailAddress); + + /** + * Retrieves a single business data entity for given id number or throws a + * proper exception if not found. + *

+ * @param basicDataId Company basic data id to lookup + *

+ * @return Business contact instance + *

+ * @throws BasicDataNotFoundException If the id number could not be looked + * up and solved into an entity + */ + BasicData findBasicDataById (final Long basicDataId) throws BasicDataNotFoundException; + + /** + * Checks whether given company name already exists + *

+ * @param companyName Company name to check + *

+ * @return Whether the company name exists + */ + Boolean isCompanyNameUsed (final String companyName); + +} diff --git a/src/java/org/mxchange/jjobs/beans/business/basicdata/JobsBusinessDataWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/business/basicdata/JobsBusinessDataWebRequestBean.java deleted file mode 100644 index 574e7405..00000000 --- a/src/java/org/mxchange/jjobs/beans/business/basicdata/JobsBusinessDataWebRequestBean.java +++ /dev/null @@ -1,454 +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.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; -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.jcontactsbusiness.events.basicdata.added.ObservableAdminAddedBusinessBasicDataEvent; -import org.mxchange.jcontactsbusiness.exceptions.basicdata.BasicDataNotFoundException; -import org.mxchange.jcontactsbusiness.model.basicdata.AdminBasicCompanyDataSessionBeanRemote; -import org.mxchange.jcontactsbusiness.model.basicdata.BasicCompanyDataSessionBeanRemote; -import org.mxchange.jcontactsbusiness.model.basicdata.BasicData; -import org.mxchange.jcountry.model.data.Country; -import org.mxchange.jjobs.beans.BaseJobsBean; -import org.mxchange.jjobs.beans.user.login.JobsUserLoginWebSessionController; - -/** - * A business contact bean (controller) - *

- * @author Roland Häder - */ -@Named ("basicCompanyDataController") -@RequestScoped -public class JobsBusinessDataWebRequestBean extends BaseJobsBean implements JobsBusinessDataWebRequestController { - - /** - * Serial number - */ - private static final long serialVersionUID = 56_189_028_928_371L; - - /** - * EJB for administrative basic business data purposes - */ - @EJB (lookup = "java:global/jjobs-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 final List allBasicData; - - /** - * A list of all registered companies (globally) - */ - @Inject - @NamedCache (cacheName = "basicDataCache") - private Cache basicDataCache; - - /** - * EJB for general basic business data purposes - */ - @EJB (lookup = "java:global/jjobs-ejb/basicCompanyData!org.mxchange.jcontactsbusiness.model.basicdata.BasicCompanyDataSessionBeanRemote", description = "A stateless session bean for general purposes.") - private BasicCompanyDataSessionBeanRemote businessDataBean; - - /** - * Comments for this company - */ - private String companyComments; - - /** - * Companies (main) email address (example: info@company.example) - */ - private String companyEmailAddress; - - /** - * Company cacheName - */ - private String companyName; - - /** - * Area code for fax number - */ - private Integer faxAreaCode; - - /** - * Country for fax number - */ - private Country faxCountry; - - /** - * Dial number for fax number - */ - private Long faxNumber; - - /** - * List of filtered basic company data - */ - private List filteredBasicCompanyData; - - /** - * Area code for land-line number - */ - private Integer landLineAreaCode; - - /** - * Country for land-line number - */ - private Country landLineCountry; - - /** - * Dial number for land-line number - */ - private Long landLineNumber; - - /** - * User instance - */ - @Inject - private JobsUserLoginWebSessionController userLoginController; - - /** - * Constructor - */ - public JobsBusinessDataWebRequestBean () { - // Call super constructor - super(); - - // Init list - this.allBasicData = new LinkedList<>(); - } - - /** - * Observers events being fired when an administrator has added company - * basic data. - *

- * @param event Event being fired - */ - public void afterAdminAddedBasicCompanyDataEvent (@Observes final ObservableAdminAddedBusinessBasicDataEvent event) { - // Is the parameter valid? - if (null == event) { - // Throw NPE - throw new NullPointerException("event is null"); - } else if (event.getBasicData() == null) { - // Throw NPE again - throw new NullPointerException("event.basicData is null"); - } else if (event.getBasicData().getBasicDataId() == null) { - // Throw NPE again - throw new NullPointerException("event.basicData.basicDataId is null"); - } else if (event.getBasicData().getBasicDataId() < 1) { - // Throw IAE - throw new IllegalArgumentException(MessageFormat.format("event.basicData.basicDataId={0} is invalid", event.getBasicData().getBasicDataId())); - } else if (event.getBasicData().getCompanyName() == null) { - // Throw NPE again - throw new NullPointerException("event.basicData.companyName is null"); - } else if (event.getBasicData().getCompanyName().isEmpty()) { - // Throw IAE again - throw new IllegalArgumentException("event.basicData.companyName is empty"); - } - - // Add it to list - this.basicDataCache.put(event.getBasicData().getBasicDataId(), event.getBasicData()); - this.allBasicData.add(event.getBasicData()); - } - - /** - * Getter for a list of all business contacts - *

- * @return A list of all business contacts - */ - @SuppressWarnings ("ReturnOfCollectionOrArrayField") - public List allBasicData () { - return this.allBasicData; - } - - @Override - public BasicData findBasicDataById (final Long basicDataId) throws BasicDataNotFoundException { - // Validate parameter - if (null == basicDataId) { - // Throw NPE - throw new NullPointerException("basicDataId is null"); //NOI18N - } else if (basicDataId < 1) { - // Throw IAE - throw new IllegalArgumentException("basicDataId=" + basicDataId + " is invalid"); //NOI18N - } else if (!this.basicDataCache.containsKey(basicDataId)) { - // Not found - throw new BasicDataNotFoundException(basicDataId); - } - - // Get it from cache - final BasicData basicData = this.basicDataCache.get(basicDataId); - - // Return it - return basicData; - } - - /** - * Getter for comments - *

- * @return Comments - */ - public String getCompanyComments () { - return this.companyComments; - } - - /** - * Setter for comments - *

- * @param companyComments Comments - */ - public void setCompanyComments (final String companyComments) { - this.companyComments = companyComments; - } - - /** - * Getter for company's (main) email address - *

- * @return Company's (main) email address - */ - public String getCompanyEmailAddress () { - return this.companyEmailAddress; - } - - /** - * Setter for company's (main) email address - *

- * @param companyEmailAddress Company's (main) email address - */ - public void setCompanyEmailAddress (final String companyEmailAddress) { - this.companyEmailAddress = companyEmailAddress; - } - - /** - * Getter for company cacheName - *

- * @return Company cacheName - */ - public String getCompanyName () { - return this.companyName; - } - - /** - * Setter for company cacheName - *

- * @param companyName Company cacheName - */ - public void setCompanyName (final String companyName) { - this.companyName = companyName; - } - - /** - * Getter for fax number's area code - *

- * @return Fax number's area code - */ - public Integer getFaxAreaCode () { - return this.faxAreaCode; - } - - /** - * Setter for fax number's area code - *

- * @param faxAreaCode Fax number's area code - */ - public void setFaxAreaCode (final Integer faxAreaCode) { - this.faxAreaCode = faxAreaCode; - } - - /** - * Getter for fax's country instance - *

- * @return Fax' country instance - */ - public Country getFaxCountry () { - return this.faxCountry; - } - - /** - * Setter for fax's country instance - *

- * @param faxCountry Fax' country instance - */ - public void setFaxCountry (final Country faxCountry) { - this.faxCountry = faxCountry; - } - - /** - * Getter for fax number - *

- * @return Fax number - */ - public Long getFaxNumber () { - return this.faxNumber; - } - - /** - * Setter for fax number - *

- * @param faxNumber Fax number - */ - public void setFaxNumber (final Long faxNumber) { - 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 - *

- * @return Land-line number's area code - */ - public Integer getLandLineAreaCode () { - return this.landLineAreaCode; - } - - /** - * Setter for land-line number's area code - *

- * @param landLineAreaCode Land-line number's area code - */ - public void setLandLineAreaCode (final Integer landLineAreaCode) { - this.landLineAreaCode = landLineAreaCode; - } - - /** - * Getter for land-line number's country instance - *

- * @return Land-line number's country instance - */ - public Country getLandLineCountry () { - return this.landLineCountry; - } - - /** - * Setter for land-line number's country instance - *

- * @param landLineCountry Land-line number's country instance - */ - public void setLandLineCountry (final Country landLineCountry) { - this.landLineCountry = landLineCountry; - } - - /** - * Getter for land-line number - *

- * @return Land-line number - */ - public Long getLandLineNumber () { - return this.landLineNumber; - } - - /** - * Setter for land-line number - *

- * @param landLineNumber Land-line number - */ - public void setLandLineNumber (final Long landLineNumber) { - this.landLineNumber = landLineNumber; - } - - /** - * Initializer method - */ - @PostConstruct - public void initializeList () { - // Is cache there? - if (!this.basicDataCache.iterator().hasNext()) { - // Get whole list - final List basicDatas = this.businessDataBean.allBusinessBasicData(); - - // Add all - for (final BasicData basicData : basicDatas) { - // Add it to cache - this.basicDataCache.put(basicData.getBasicDataId(), basicData); - } - } - - // Is cache there and list is not full? - if ((this.allBasicData.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.allBasicData.add(next.getValue()); - } - - // Sort list - this.allBasicData.sort(new Comparator() { - @Override - public int compare (final BasicData o1, final BasicData o2) { - return o1.getBasicDataId() > o2.getBasicDataId() ? 1 : o1.getBasicDataId() < o2.getBasicDataId() ? -1 : 0; - } - }); - } - } - - @Override - public Boolean isCompanyNameUsed (String companyName) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - /** - * Clears this bean - */ - private void clear () { - // Clear all data: - this.setCompanyComments(null); - this.setCompanyEmailAddress(null); - this.setCompanyName(null); - this.setFaxAreaCode(null); - this.setFaxCountry(null); - this.setFaxNumber(null); - this.setLandLineAreaCode(null); - this.setLandLineCountry(null); - this.setLandLineNumber(null); - } - -} diff --git a/src/java/org/mxchange/jjobs/beans/business/basicdata/JobsBusinessDataWebRequestController.java b/src/java/org/mxchange/jjobs/beans/business/basicdata/JobsBusinessDataWebRequestController.java deleted file mode 100644 index 89dbc778..00000000 --- a/src/java/org/mxchange/jjobs/beans/business/basicdata/JobsBusinessDataWebRequestController.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 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.beans.business.basicdata; - -import java.io.Serializable; -import org.mxchange.jcontactsbusiness.exceptions.basicdata.BasicDataNotFoundException; -import org.mxchange.jcontactsbusiness.model.basicdata.BasicData; - -/** - * An interface for session-scoped basic data controller - *

- * @author Roland Häder - */ -public interface JobsBusinessDataWebRequestController extends Serializable { - - /** - * Retrieves a single business data entity for given id number or throws a - * proper exception if not found. - *

- * @param basicDataId Company basic data id to lookup - *

- * @return Business contact instance - *

- * @throws BasicDataNotFoundException If the id number could not be - * looked up and solved into an entity - */ - BasicData findBasicDataById (final Long basicDataId) throws BasicDataNotFoundException; - - /** - * Checks whether given company name already exists - *

- * @param companyName Company name to check - *

- * @return Whether the company name exists - */ - Boolean isCompanyNameUsed (final String companyName); - -} diff --git a/src/java/org/mxchange/jjobs/beans/business/branchoffice/JobsAdminBranchOfficeWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/business/branchoffice/JobsAdminBranchOfficeWebRequestBean.java index fa0a5261..c28d15c7 100644 --- a/src/java/org/mxchange/jjobs/beans/business/branchoffice/JobsAdminBranchOfficeWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/business/branchoffice/JobsAdminBranchOfficeWebRequestBean.java @@ -29,10 +29,12 @@ import javax.inject.Named; import org.mxchange.jcontactsbusiness.events.branchoffice.added.BranchOfficeAddedEvent; import org.mxchange.jcontactsbusiness.events.branchoffice.added.ObservableBranchOfficeAddedEvent; import org.mxchange.jcontactsbusiness.exceptions.branchoffice.BranchOfficeAlreadyAddedException; +import org.mxchange.jcontactsbusiness.model.basicdata.BasicData; import org.mxchange.jcontactsbusiness.model.branchoffice.AdminBranchOfficeSessionBeanRemote; import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice; import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffices; import org.mxchange.jcontactsbusiness.model.branchoffice.BusinessBranchOffice; +import org.mxchange.jcontactsbusiness.model.employee.Employable; import org.mxchange.jcontactsbusiness.model.opening_time.BusinessOpeningTime; import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTime; import org.mxchange.jcontactsbusiness.model.opening_time.dayofweek.DayOfTheWeek; @@ -43,8 +45,6 @@ import org.mxchange.jphone.model.phonenumbers.fax.FaxNumber; import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber; import org.mxchange.jphone.model.phonenumbers.landline.LandLineNumber; import org.mxchange.jusercore.model.user.User; -import org.mxchange.jcontactsbusiness.model.employee.Employable; -import org.mxchange.jcontactsbusiness.model.basicdata.BasicData; /** * An administrative bean for branch offices @@ -55,6 +55,11 @@ import org.mxchange.jcontactsbusiness.model.basicdata.BasicData; @SessionScoped public class JobsAdminBranchOfficeWebRequestBean extends BaseJobsBean implements JobsAdminBranchOfficeWebRequestController { + /** + * Opening times of this branch office + */ + private static List branchOpeningTimes; + /** * Serial number */ @@ -114,11 +119,6 @@ public class JobsAdminBranchOfficeWebRequestBean extends BaseJobsBean implements @Inject private JobsBranchOfficeWebRequestController branchOfficeController; - /** - * Opening times of this branch office - */ - private static List branchOpeningTimes; - /** * Store */ diff --git a/src/java/org/mxchange/jjobs/beans/business/branchoffice/JobsBranchOfficeWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/business/branchoffice/JobsBranchOfficeWebRequestBean.java index e7824789..26ec02e4 100644 --- a/src/java/org/mxchange/jjobs/beans/business/branchoffice/JobsBranchOfficeWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/business/branchoffice/JobsBranchOfficeWebRequestBean.java @@ -22,6 +22,7 @@ import java.util.Comparator; import java.util.Iterator; import java.util.LinkedList; import java.util.List; +import java.util.Objects; import javax.annotation.PostConstruct; import javax.cache.Cache; import javax.ejb.EJB; @@ -201,4 +202,23 @@ public class JobsBranchOfficeWebRequestBean extends BaseJobsBean implements Jobs } } + @Override + public Boolean isEmailAddressRegistered (final String emailAddress) { + // Default is not found + boolean isFound = false; + + // Check all entries + for (final BranchOffice branchOffice : this.allBranchOffices()) { + // Is email address used? + if (Objects.equals(branchOffice.getBranchEmailAddress(), emailAddress)) { + // Found it + isFound = true; + break; + } + } + + // Return flag + return isFound; + } + } diff --git a/src/java/org/mxchange/jjobs/beans/business/branchoffice/JobsBranchOfficeWebRequestController.java b/src/java/org/mxchange/jjobs/beans/business/branchoffice/JobsBranchOfficeWebRequestController.java index ed37432b..ad50bac0 100644 --- a/src/java/org/mxchange/jjobs/beans/business/branchoffice/JobsBranchOfficeWebRequestController.java +++ b/src/java/org/mxchange/jjobs/beans/business/branchoffice/JobsBranchOfficeWebRequestController.java @@ -28,6 +28,16 @@ import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice; */ public interface JobsBranchOfficeWebRequestController extends Serializable { + /** + * Checks if given email address is already registered by an other branch + * office + *

+ * @param emailAddress Email address + *

+ * @return Whether the email address has been already registered + */ + Boolean isEmailAddressRegistered (final String emailAddress); + /** * Returns a list of all branch offices *

diff --git a/src/java/org/mxchange/jjobs/beans/business/department/JobsAdminDepartmentWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/business/department/JobsAdminDepartmentWebRequestBean.java index e88d4fef..cc8c41e7 100644 --- a/src/java/org/mxchange/jjobs/beans/business/department/JobsAdminDepartmentWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/business/department/JobsAdminDepartmentWebRequestBean.java @@ -26,16 +26,16 @@ import javax.inject.Named; import org.mxchange.jcontactsbusiness.events.department.added.DepartmentAddedEvent; import org.mxchange.jcontactsbusiness.events.department.added.ObservableDepartmentAddedEvent; import org.mxchange.jcontactsbusiness.exceptions.department.DepartmentAlreadyAddedException; +import org.mxchange.jcontactsbusiness.model.basicdata.BasicData; import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice; import org.mxchange.jcontactsbusiness.model.department.AdminDepartmentSessionBeanRemote; import org.mxchange.jcontactsbusiness.model.department.BusinessDepartment; import org.mxchange.jcontactsbusiness.model.department.Department; import org.mxchange.jcontactsbusiness.model.department.Departments; -import org.mxchange.jcontactsbusiness.model.headquarters.HeadquartersData; +import org.mxchange.jcontactsbusiness.model.employee.Employable; +import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter; import org.mxchange.jjobs.beans.BaseJobsBean; import org.mxchange.jusercore.model.user.User; -import org.mxchange.jcontactsbusiness.model.employee.Employable; -import org.mxchange.jcontactsbusiness.model.basicdata.BasicData; /** * An administrative bean for departments @@ -49,7 +49,7 @@ public class JobsAdminDepartmentWebRequestBean extends BaseJobsBean implements J /** * Serial number */ - private static final long serialVersionUID = 5_028_697_360_462L; + private static final long serialVersionUID = 5_028_697_360_464L; /** * EJB for administrative purposes @@ -81,19 +81,19 @@ public class JobsAdminDepartmentWebRequestBean extends BaseJobsBean implements J private JobsDepartmentWebRequestController departmentController; /** - * Assigned headquarters (if apply-able) + * Assigned headquarter (if apply-able) */ - private HeadquartersData departmentHeadquarters; + private Headquarter departmentHeadquarter; /** - * Lead person of this department + * Department name */ - private Employable departmentLead; + private String departmentI18nKey; /** - * Department name + * Lead person of this department */ - private String departmentI18nKey; + private Employable departmentLead; /** * Owning user instance (which this department is assigned to) @@ -182,57 +182,57 @@ public class JobsAdminDepartmentWebRequestBean extends BaseJobsBean implements J } /** - * Getter for assigned headquarters data + * Getter for assigned headquarter data *

- * @return Headquarters data + * @return Headquarter data */ - public HeadquartersData getDepartmentHeadquarters () { - return this.departmentHeadquarters; + public Headquarter getDepartmentHeadquarter () { + return this.departmentHeadquarter; } /** - * Setter for assigned headquarters data + * Setter for assigned headquarter data *

- * @param departmentHeadquarters Headquarters data + * @param departmentHeadquarter Headquarter data */ - public void setDepartmentHeadquarters (final HeadquartersData departmentHeadquarters) { - this.departmentHeadquarters = departmentHeadquarters; + public void setDepartmentHeadquarter (final Headquarter departmentHeadquarter) { + this.departmentHeadquarter = departmentHeadquarter; } /** - * Getter for department contact person + * Getter for department name *

- * @return Department contact person + * @return Department name */ - public Employable getDepartmentLead () { - return this.departmentLead; + public String getDepartmentI18nKey () { + return this.departmentI18nKey; } /** - * Setter for department contact person + * Setter for department name *

- * @param departmentLead Department contact person + * @param departmentI18nKey Department name */ - public void setDepartmentLead (final Employable departmentLead) { - this.departmentLead = departmentLead; + public void setDepartmentI18nKey (final String departmentI18nKey) { + this.departmentI18nKey = departmentI18nKey; } /** - * Getter for department name + * Getter for department contact person *

- * @return Department name + * @return Department contact person */ - public String getDepartmentI18nKey () { - return this.departmentI18nKey; + public Employable getDepartmentLead () { + return this.departmentLead; } /** - * Setter for department name + * Setter for department contact person *

- * @param departmentI18nKey Department name + * @param departmentLead Department contact person */ - public void setDepartmentI18nKey (final String departmentI18nKey) { - this.departmentI18nKey = departmentI18nKey; + public void setDepartmentLead (final Employable departmentLead) { + this.departmentLead = departmentLead; } /** @@ -265,7 +265,7 @@ public class JobsAdminDepartmentWebRequestBean extends BaseJobsBean implements J final Department department = new BusinessDepartment(this.getDepartmentCompany(), this.getDepartmentI18nKey()); // Add all optional fields - department.setDepartmentHeadquarters(this.getDepartmentHeadquarters()); + department.setDepartmentHeadquarter(this.getDepartmentHeadquarter()); department.setDepartmentBranchOffice(this.getDepartmentBranchOffice()); department.setDepartmentLead(this.getDepartmentLead()); department.setDepartmentUserOwner(this.getDepartmentUserOwner()); diff --git a/src/java/org/mxchange/jjobs/beans/business/employee/JobsAdminCompanyEmployeeWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/business/employee/JobsAdminCompanyEmployeeWebRequestBean.java index 47c9777e..931c1166 100644 --- a/src/java/org/mxchange/jjobs/beans/business/employee/JobsAdminCompanyEmployeeWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/business/employee/JobsAdminCompanyEmployeeWebRequestBean.java @@ -23,13 +23,20 @@ import javax.enterprise.inject.Any; import javax.inject.Inject; import javax.inject.Named; import org.mxchange.jcontacts.model.contact.Contact; +import org.mxchange.jcontactsbusiness.events.employee.added.EmployeeAddedEvent; import org.mxchange.jcontactsbusiness.events.employee.added.ObservableEmployeeAddedEvent; +import org.mxchange.jcontactsbusiness.exceptions.employee.EmployeeAlreadyAddedException; import org.mxchange.jcontactsbusiness.model.basicdata.BasicData; import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice; import org.mxchange.jcontactsbusiness.model.department.Department; import org.mxchange.jcontactsbusiness.model.employee.AdminEmployeeSessionBeanRemote; -import org.mxchange.jcontactsbusiness.model.headquarters.HeadquartersData; +import org.mxchange.jcontactsbusiness.model.employee.BusinessEmployee; +import org.mxchange.jcontactsbusiness.model.employee.Employable; +import org.mxchange.jcontactsbusiness.model.employee.Employees; +import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter; import org.mxchange.jjobs.beans.BaseJobsBean; +import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber; +import org.mxchange.jphone.model.phonenumbers.mobile.MobileNumber; import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider; import org.mxchange.jusercore.model.user.User; @@ -72,7 +79,13 @@ public class JobsAdminEmployeeWebRequestBean extends BaseJobsBean implements Job private BranchOffice employeeBranchOffice; /** - * Department where employee works (alternative to headquarters) + * General employee controller + */ + @Inject + private JobsEmployeeWebRequestController employeeController; + + /** + * Department where employee works (alternative to headquarter) */ private Department employeeDepartment; @@ -82,24 +95,24 @@ public class JobsAdminEmployeeWebRequestBean extends BaseJobsBean implements Job private String employeeEmailAddress; /** - * Employee's Headquarters data, if he is working there + * Employee's Headquarter data, if he is working there */ - private HeadquartersData employeeHeadquarters; + private Headquarter employeeHeadquarter; /** - * Assigned personal data of the employee + * Employee's staff number */ - private Contact employeePersonalContact; + private String employeeNumber; /** - * Employee's phone extension (on top of a "main number") + * Assigned personal data of the employee */ - private Long employeePhoneExtension; + private Contact employeePersonalContact; /** - * Employee's staff number + * Employee's phone extension (on top of a "main number") */ - private Long employeeStaffNumber; + private Integer employeePhoneExtension; /** * Assigned user account @@ -124,6 +137,46 @@ public class JobsAdminEmployeeWebRequestBean extends BaseJobsBean implements Job super(); } + /** + * Adds branch office with all data from this backing bean. First this + * action method will validate if the branch office's address is already + * registered and if found, it will output a proper faces message. + *

+ * @return Redirect outcome + */ + public String addEmployee () { + // Get instance + final Employable employee = this.createEmployee(); + + // Is the branch office not created yet? + if (this.isEmployeeCreatedByRequiredData(employee)) { + // Then show proper faces message + this.showFacesMessage("form-admin-add-employee:employeeNumber", "ADMIN_EMPLOYEE_ALREADY_CREATED"); //NOI18N + return ""; //NOI18N + } + + // Delcare updated instance + final Employable updatedOffice; + + try { + // Try to call EJB + updatedOffice = this.adminEmployeeBean.addEmployee(employee); + } catch (final EmployeeAlreadyAddedException ex) { + // Output message + this.showFacesMessage("form-admin-add-branch-office:branchStreet", "ADMIN_BRANCH_OFFICE_ALREADY_CREATED"); //NOI18N + return ""; //NOI18N + } + + // Fire event + this.addedEmployeeEvent.fire(new EmployeeAddedEvent(updatedOffice)); + + // Clear this bean + this.clear(); + + // Redirect to list + return "admin_list_branch_office"; //NOI18N + } + /** * Getter for employee's assigned branch office *

@@ -197,21 +250,39 @@ public class JobsAdminEmployeeWebRequestBean extends BaseJobsBean implements Job } /** - * Getter for employee's assigned headquarters (if no branch office) + * Getter for employee's assigned headquarter (if no branch office) + *

+ * @return Employee's assigned headquarter + */ + public Headquarter getEmployeeHeadquarter () { + return this.employeeHeadquarter; + } + + /** + * Setter for employee's assigned headquarter (if no branch office) *

- * @return Employee's assigned headquarters + * @param employeeHeadquarter Employee's assigned headquarter */ - public HeadquartersData getEmployeeHeadquarters () { - return this.employeeHeadquarters; + public void setEmployeeHeadquarter (final Headquarter employeeHeadquarter) { + this.employeeHeadquarter = employeeHeadquarter; } /** - * Setter for employee's assigned headquarters (if no branch office) + * Getter for employee's staff number *

- * @param employeeHeadquarters Employee's assigned headquarters + * @return Employee's staff number */ - public void setEmployeeHeadquarters (final HeadquartersData employeeHeadquarters) { - this.employeeHeadquarters = employeeHeadquarters; + public String getEmployeeNumber () { + return this.employeeNumber; + } + + /** + * Setter for employee's staff number + *

+ * @param employeeNumber Employee's staff number + */ + public void setEmployeeNumber (final String employeeNumber) { + this.employeeNumber = employeeNumber; } /** @@ -237,7 +308,7 @@ public class JobsAdminEmployeeWebRequestBean extends BaseJobsBean implements Job *

* @return Employee's phone extension */ - public Long getEmployeePhoneExtension () { + public Integer getEmployeePhoneExtension () { return this.employeePhoneExtension; } @@ -246,28 +317,10 @@ public class JobsAdminEmployeeWebRequestBean extends BaseJobsBean implements Job *

* @param employeePhoneExtension Employee's phone extension */ - public void setEmployeePhoneExtension (final Long employeePhoneExtension) { + public void setEmployeePhoneExtension (final Integer employeePhoneExtension) { this.employeePhoneExtension = employeePhoneExtension; } - /** - * Getter for employee's staff number - *

- * @return Employee's staff number - */ - public Long getEmployeeStaffNumber () { - return this.employeeStaffNumber; - } - - /** - * Setter for employee's staff number - *

- * @param employeeStaffNumber Employee's staff number - */ - public void setEmployeeStaffNumber (final Long employeeStaffNumber) { - this.employeeStaffNumber = employeeStaffNumber; - } - /** * Getter for employee's user "owner" *

@@ -322,4 +375,75 @@ public class JobsAdminEmployeeWebRequestBean extends BaseJobsBean implements Job this.mobileProvider = mobileProvider; } + /** + * Clears all bean fields + */ + private void clear () { + // Clear all fields + this.setEmployeeBranchOffice(null); + this.setEmployeeCompany(null); + this.setEmployeeDepartment(null); + this.setEmployeeEmailAddress(null); + this.setEmployeeHeadquarter(null); + this.setEmployeePersonalContact(null); + this.setEmployeePhoneExtension(null); + this.setEmployeeNumber(null); + this.setEmployeeUserOwner(null); + } + + /** + * Creates employee instance with all data from this bean + *

+ * @return Employee instance + */ + private Employable createEmployee () { + // Init instance + final Employable employee = new BusinessEmployee(this.getEmployeeCompany(), this.getEmployeeNumber(), this.getEmployeePersonalContact()); + + // Set all othewr data + employee.setEmployeeBranchOffice(this.getEmployeeBranchOffice()); + employee.setEmployeeDepartment(this.getEmployeeDepartment()); + employee.setEmployeeHeadquarter(this.getEmployeeHeadquarter()); + employee.setEmployeePhoneExtension(this.getEmployeePhoneExtension()); + // @TODO employee.setEmployeePosition(this.getEmployeePosition()); + employee.setEmployeeUserOwner(this.getEmployeeUserOwner()); + + // Is mobile provider and number set? + if ((this.getMobileProvider() instanceof MobileProvider) && (this.getMobileNumber() != null) && (this.getMobileNumber() > 0)) { + // Init mobile number instance + final DialableMobileNumber number = new MobileNumber(this.getMobileProvider(), this.getMobileNumber()); + + // Set it in employee + employee.setEmployeeMobileNumber(number); + } + + // Return it + return employee; + } + + /** + * Checks whether given employee is already added + *

+ * @param employee Employee to be checked + *

+ * @return Whether the employee has already been added + */ + private boolean isEmployeeCreatedByRequiredData (final Employable employee) { + // Default is not found + boolean isFound = false; + + // Check all employees + for (final Employable otherEmployee : this.employeeController.allEmployees()) { + // Is same found? + if (Employees.isSameEmployeeFound(employee, otherEmployee)) { + // Okay, found it + isFound = true; + break; + } + } + + // Return it + return isFound; + } + } diff --git a/src/java/org/mxchange/jjobs/beans/business/employee/JobsCompanyEmployeeWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/business/employee/JobsCompanyEmployeeWebRequestBean.java index 13ee9425..ef3409b6 100644 --- a/src/java/org/mxchange/jjobs/beans/business/employee/JobsCompanyEmployeeWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/business/employee/JobsCompanyEmployeeWebRequestBean.java @@ -109,11 +109,7 @@ public class JobsEmployeeWebRequestBean extends BaseJobsBean implements JobsEmpl this.allEmployees.add(event.getEmployee()); } - /** - * Returns a list of all company employees - *

- * @return List of all company employees - */ + @Override @SuppressWarnings ("ReturnOfCollectionOrArrayField") public List allEmployees () { return this.allEmployees; diff --git a/src/java/org/mxchange/jjobs/beans/business/employee/JobsCompanyEmployeeWebSessionController.java b/src/java/org/mxchange/jjobs/beans/business/employee/JobsCompanyEmployeeWebSessionController.java index ed21595e..1e8d42b3 100644 --- a/src/java/org/mxchange/jjobs/beans/business/employee/JobsCompanyEmployeeWebSessionController.java +++ b/src/java/org/mxchange/jjobs/beans/business/employee/JobsCompanyEmployeeWebSessionController.java @@ -17,6 +17,7 @@ package org.mxchange.jjobs.beans.business.employee; import java.io.Serializable; +import java.util.List; import org.mxchange.jcontactsbusiness.exceptions.employee.EmployeeNotFoundException; import org.mxchange.jcontactsbusiness.model.employee.Employable; @@ -27,6 +28,13 @@ import org.mxchange.jcontactsbusiness.model.employee.Employable; */ public interface JobsEmployeeWebRequestController extends Serializable { + /** + * Returns a list of all company employees + *

+ * @return List of all company employees + */ + List allEmployees (); + /** * Finds a company employee by given employee id *

diff --git a/src/java/org/mxchange/jjobs/beans/business/headquarter/JobsAdminHeadquarterWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/business/headquarter/JobsAdminHeadquarterWebRequestBean.java new file mode 100644 index 00000000..2d55dd32 --- /dev/null +++ b/src/java/org/mxchange/jjobs/beans/business/headquarter/JobsAdminHeadquarterWebRequestBean.java @@ -0,0 +1,836 @@ +/* + * Copyright (C) 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.beans.business.headquarter; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Objects; +import javax.ejb.EJB; +import javax.enterprise.context.SessionScoped; +import javax.enterprise.event.Event; +import javax.enterprise.inject.Any; +import javax.inject.Inject; +import javax.inject.Named; +import org.mxchange.jcontactsbusiness.events.headquarter.added.HeadquarterAddedEvent; +import org.mxchange.jcontactsbusiness.events.headquarter.added.ObservableHeadquarterAddedEvent; +import org.mxchange.jcontactsbusiness.exceptions.headquarter.HeadquarterAlreadyAddedException; +import org.mxchange.jcontactsbusiness.model.employee.Employable; +import org.mxchange.jcontactsbusiness.model.headquarter.AdminHeadquarterSessionBeanRemote; +import org.mxchange.jcontactsbusiness.model.headquarter.BusinessHeadquarter; +import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter; +import org.mxchange.jcontactsbusiness.model.headquarter.Headquarters; +import org.mxchange.jcontactsbusiness.model.opening_time.BusinessOpeningTime; +import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTime; +import org.mxchange.jcontactsbusiness.model.opening_time.dayofweek.DayOfTheWeek; +import org.mxchange.jcountry.model.data.Country; +import org.mxchange.jjobs.beans.BaseJobsBean; +import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber; +import org.mxchange.jphone.model.phonenumbers.fax.FaxNumber; +import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber; +import org.mxchange.jphone.model.phonenumbers.landline.LandLineNumber; +import org.mxchange.jusercore.model.user.User; + +/** + * An administrative bean for headquarter + *

+ * @author Roland Häder + */ +@Named ("adminHeadquarterController") +@SessionScoped +public class JobsAdminHeadquarterWebRequestBean extends BaseJobsBean implements JobsAdminHeadquarterWebRequestController { + + /** + * Opening times of this headquarter + */ + private static List headquarterOpeningTimes; + + /** + * Serial number + */ + private static final long serialVersionUID = 5_028_697_360_462L; + + /** + * EJB for administrative purposes + */ + @EJB (lookup = "java:global/jjobs-ejb/adminHeadquarter!org.mxchange.jcontactsbusiness.model.headquarter.AdminHeadquarterSessionBeanRemote") + private AdminHeadquarterSessionBeanRemote adminHeadquarterBean; + + /** + * Area code for fax number + */ + private Integer faxAreaCode; + + /** + * Country for fax number + */ + private Country faxCountry; + + /** + * Dial number for fax number + */ + private Long faxNumber; + + /** + * An event being fired when a headquarter has been successfully added + */ + @Inject + @Any + private Event headquarterAddedEvent; + + /** + * City + */ + private String headquarterCity; + + /** + * Contact person in headquarter + */ + private Employable headquarterContactEmployee; + + /** + * A general headquarter controller (backing bean) + */ + @Inject + private JobsHeadquarterWebRequestController headquarterController; + + /** + * Country + */ + private Country headquarterCountry; + + /** + * Email address + */ + private String headquarterEmailAddress; + + /** + * House number + */ + private Short headquarterHouseNumber; + + /** + * Store + */ + private Short headquarterStore; + + /** + * Headquarter street name + */ + private String headquarterStreet; + + /** + * Suite number + */ + private Short headquarterSuiteNumber; + + /** + * Owning user instance (which this headquarter is assigned to) + */ + private User headquarterUserOwner; + + /** + * ZIP code + */ + private Integer headquarterZipCode; + + /** + * Area code for land-line number + */ + private Integer landLineAreaCode; + + /** + * Country for land-line number + */ + private Country landLineCountry; + + /** + * Dial number for land-line number + */ + private Long landLineNumber; + + /** + * Ending week day + */ + private DayOfTheWeek openingEndDay; + + /** + * Ending time + */ + private Date openingEndTime; + + /** + * Starting week day + */ + private DayOfTheWeek openingStartDay; + + /** + * Starting time + */ + private Date openingStartTime; + + /** + * Default constructor + */ + public JobsAdminHeadquarterWebRequestBean () { + // Call super constructor + super(); + + // Is the opening times list there? + if (null == headquarterOpeningTimes) { + // Init list + headquarterOpeningTimes = new ArrayList<>(1); + } + } + + /** + * Adds headquarter with all data from this backing bean. First this action + * method will validate if the headquarter's address is already registered + * and if found, it will output a proper faces message. + *

+ * @return Redirect outcome + */ + public String addHeadquarter () { + // Get instance + final Headquarter headquarter = this.createHeadquarter(); + + // Is the headquarter not created yet? + if (this.isHeadquarterCreatedByRequiredData(headquarter)) { + // Then show proper faces message + this.showFacesMessage("form-admin-add-headquarter-office:headquarterStreet", "ADMIN_BRANCH_OFFICE_ALREADY_CREATED"); //NOI18N + return ""; //NOI18N + } + + // Delcare updated instance + final Headquarter updatedHeadquarter; + + try { + // Try to call EJB + updatedHeadquarter = this.adminHeadquarterBean.addHeadquarter(headquarter); + } catch (final HeadquarterAlreadyAddedException ex) { + // Output message + this.showFacesMessage("form-admin-add-headquarter-office:headquarterStreet", "ADMIN_BRANCH_OFFICE_ALREADY_CREATED"); //NOI18N + return ""; //NOI18N + } + + // Fire event + this.headquarterAddedEvent.fire(new HeadquarterAddedEvent(updatedHeadquarter)); + + // Clear this bean + this.clear(); + + // Redirect to list + return "admin_list_headquarter_office"; //NOI18N + } + + /** + * Adds opening time to temporary list which will be sent along with the + * headquarter data to the EJB. + */ + public void addOpeningTime () { + // Validate all required fields + if (this.getOpeningEndDay() == null) { + // Throw NPE + throw new NullPointerException("this.openingEndDay is null"); //NOI18N + } else if (this.getOpeningEndTime() == null) { + // Throw NPE + throw new NullPointerException("this.openingEndTime is null"); //NOI18N + } else if (this.getOpeningStartDay() == null) { + // Throw NPE + throw new NullPointerException("this.openingStartDay is null"); //NOI18N + } else if (this.getOpeningStartTime() == null) { + // Throw NPE + throw new NullPointerException("this.openingStartTime is null"); //NOI18N + } + + // Get opening time instance + final OpeningTime openingTime = this.createOpeningTimes(); + + // Is same found? + if (this.isSameOpeningTimeFound(openingTime)) { + // Yes then abort here + this.showFacesMessage("form-admin-add-headquarter-opening-time:openingStartDay", "ADMIN_OPENING_TIME_ALREADY_CREATED"); //NOI18N + return; + } + + // Add to temporary list + headquarterOpeningTimes.add(openingTime); + + // Clear opening time fields + this.clearOpeningTime(); + } + + /** + * Getter for fax number's area code + *

+ * @return Fax number's area code + */ + public Integer getFaxAreaCode () { + return this.faxAreaCode; + } + + /** + * Setter for fax number's area code + *

+ * @param faxAreaCode Fax number's area code + */ + public void setFaxAreaCode (final Integer faxAreaCode) { + this.faxAreaCode = faxAreaCode; + } + + /** + * Getter for fax's country instance + *

+ * @return Fax' country instance + */ + public Country getFaxCountry () { + return this.faxCountry; + } + + /** + * Setter for fax's country instance + *

+ * @param faxCountry Fax' country instance + */ + public void setFaxCountry (final Country faxCountry) { + this.faxCountry = faxCountry; + } + + /** + * Getter for fax number + *

+ * @return Fax number + */ + public Long getFaxNumber () { + return this.faxNumber; + } + + /** + * Setter for fax number + *

+ * @param faxNumber Fax number + */ + public void setFaxNumber (final Long faxNumber) { + this.faxNumber = faxNumber; + } + + /** + * Getter for city + *

+ * @return City + */ + public String getHeadquarterCity () { + return this.headquarterCity; + } + + /** + * Setter for city + *

+ * @param headquarterCity City + */ + public void setHeadquarterCity (final String headquarterCity) { + this.headquarterCity = headquarterCity; + } + + /** + * Getter for headquarter contact person + *

+ * @return Headquarter contact person + */ + public Employable getHeadquarterContactEmployee () { + return this.headquarterContactEmployee; + } + + /** + * Setter for headquarter contact person + *

+ * @param headquarterContactEmployee Headquarter contact person + */ + public void setHeadquarterContactEmployee (final Employable headquarterContactEmployee) { + this.headquarterContactEmployee = headquarterContactEmployee; + } + + /** + * Getter for country + *

+ * @return Country + */ + public Country getHeadquarterCountry () { + return this.headquarterCountry; + } + + /** + * Setter for country + *

+ * @param headquarterCountry Country + */ + public void setHeadquarterCountry (final Country headquarterCountry) { + this.headquarterCountry = headquarterCountry; + } + + /** + * Getter for email address + *

+ * @return Email address + */ + public String getHeadquarterEmailAddress () { + return this.headquarterEmailAddress; + } + + /** + * Getter for email address + *

+ * @param headquarterEmailAddress Email address + */ + public void setHeadquarterEmailAddress (final String headquarterEmailAddress) { + this.headquarterEmailAddress = headquarterEmailAddress; + } + + /** + * Getter for house number + *

+ * @return House number + */ + public Short getHeadquarterHouseNumber () { + return this.headquarterHouseNumber; + } + + /** + * Setter for house number + *

+ * @param headquarterHouseNumber House number + */ + public void setHeadquarterHouseNumber (final Short headquarterHouseNumber) { + this.headquarterHouseNumber = headquarterHouseNumber; + } + + /** + * Getter for opening times of this headquarter + *

+ * @return Opening times + */ + @SuppressWarnings ("ReturnOfCollectionOrArrayField") + public List getHeadquarterOpeningTimes () { + return headquarterOpeningTimes; + } + + /** + * Setter for opening times of this headquarter + *

+ * @param headquarterOpeningTimes Opening times + */ + @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter") + public void setHeadquarterOpeningTimes (final List headquarterOpeningTimes) { + JobsAdminHeadquarterWebRequestBean.headquarterOpeningTimes = headquarterOpeningTimes; + } + + /** + * Getter for store + *

+ * @return Store + */ + public Short getHeadquarterStore () { + return this.headquarterStore; + } + + /** + * Setter for store + *

+ * @param headquarterStore Store + */ + public void setHeadquarterStore (final Short headquarterStore) { + this.headquarterStore = headquarterStore; + } + + /** + * Getter for street name + *

+ * @return Street name + */ + public String getHeadquarterStreet () { + return this.headquarterStreet; + } + + /** + * Setter for street name + *

+ * @param headquarterStreet Street name + */ + public void setHeadquarterStreet (final String headquarterStreet) { + this.headquarterStreet = headquarterStreet; + } + + /** + * Getter for suite number + *

+ * @return Suite number + */ + public Short getHeadquarterSuiteNumber () { + return this.headquarterSuiteNumber; + } + + /** + * Setter for suite number + *

+ * @param headquarterSuiteNumber Suite number + */ + public void setHeadquarterSuiteNumber (final Short headquarterSuiteNumber) { + this.headquarterSuiteNumber = headquarterSuiteNumber; + } + + /** + * Getter for owning user instance + *

+ * @return Owning user instance + */ + public User getHeadquarterUserOwner () { + return this.headquarterUserOwner; + } + + /** + * Setter for owning user instance + *

+ * @param headquarterUserOwner Owning user instance + */ + public void setHeadquarterUserOwner (final User headquarterUserOwner) { + this.headquarterUserOwner = headquarterUserOwner; + } + + /** + * Getter for ZIP code\ + *

+ * @return ZIP code + */ + public Integer getHeadquarterZipCode () { + return this.headquarterZipCode; + } + + /** + * Setter for ZIP code\ + *

+ * @param headquarterZipCode ZIP code + */ + public void setHeadquarterZipCode (final Integer headquarterZipCode) { + this.headquarterZipCode = headquarterZipCode; + } + + /** + * Getter for land-line number's area code + *

+ * @return Land-line number's area code + */ + public Integer getLandLineAreaCode () { + return this.landLineAreaCode; + } + + /** + * Setter for land-line number's area code + *

+ * @param landLineAreaCode Land-line number's area code + */ + public void setLandLineAreaCode (final Integer landLineAreaCode) { + this.landLineAreaCode = landLineAreaCode; + } + + /** + * Getter for land-line number's country instance + *

+ * @return Land-line number's country instance + */ + public Country getLandLineCountry () { + return this.landLineCountry; + } + + /** + * Setter for land-line number's country instance + *

+ * @param landLineCountry Land-line number's country instance + */ + public void setLandLineCountry (final Country landLineCountry) { + this.landLineCountry = landLineCountry; + } + + /** + * Getter for land-line number + *

+ * @return Land-line number + */ + public Long getLandLineNumber () { + return this.landLineNumber; + } + + /** + * Setter for land-line number + *

+ * @param landLineNumber Land-line number + */ + public void setLandLineNumber (final Long landLineNumber) { + this.landLineNumber = landLineNumber; + } + + /** + * Getter for ending week day + *

+ * @return Ending week day + */ + public DayOfTheWeek getOpeningEndDay () { + return this.openingEndDay; + } + + /** + * Setter for ending week day + *

+ * @param openingEndDay Ending week day + */ + public void setOpeningEndDay (final DayOfTheWeek openingEndDay) { + this.openingEndDay = openingEndDay; + } + + /** + * Getter for ending time + *

+ * @return Ending time + */ + @SuppressWarnings ("ReturnOfDateField") + public Date getOpeningEndTime () { + return this.openingEndTime; + } + + /** + * Getter for ending time + *

+ * @param openingEndTime Ending time + */ + @SuppressWarnings ("AssignmentToDateFieldFromParameter") + public void setOpeningEndTime (final Date openingEndTime) { + this.openingEndTime = openingEndTime; + } + + /** + * Getter for starting week day + *

+ * @return Starting week day + */ + public DayOfTheWeek getOpeningStartDay () { + return this.openingStartDay; + } + + /** + * Getter for starting week day + *

+ * @param openingStartDay Starting week day + */ + public void setOpeningStartDay (final DayOfTheWeek openingStartDay) { + this.openingStartDay = openingStartDay; + } + + /** + * Getter for starting time + *

+ * @return Starting time + */ + @SuppressWarnings ("ReturnOfDateField") + public Date getOpeningStartTime () { + return this.openingStartTime; + } + + /** + * Getter for starting time + *

+ * @param openingStartTime Starting time + */ + @SuppressWarnings ("AssignmentToDateFieldFromParameter") + public void setOpeningStartTime (final Date openingStartTime) { + this.openingStartTime = openingStartTime; + } + + /** + * Clears this bean data + */ + private void clear () { + // Clear all headquarter data + this.setHeadquarterCity(null); + this.setHeadquarterContactEmployee(null); + this.setHeadquarterCountry(null); + this.setHeadquarterEmailAddress(null); + this.setHeadquarterHouseNumber(null); + this.setHeadquarterStore(null); + this.setHeadquarterStreet(null); + this.setHeadquarterSuiteNumber(null); + this.setHeadquarterUserOwner(null); + this.setHeadquarterZipCode(null); + this.setHeadquarterOpeningTimes(null); + + // Extra-clear opening time + this.clearOpeningTime(); + } + + /** + * Clears all opening time fields + */ + private void clearOpeningTime () { + // Clear all opening time fields + this.setOpeningEndDay(null); + this.setOpeningEndTime(null); + this.setOpeningStartDay(null); + this.setOpeningStartTime(null); + } + + /** + * Prepares an instance of a Headquarter object (entity) with all data from + * this bean. If a complete fax number or land-line number was provided, it + * will be set in the instance as well. + *

+ * @return An instance of a Headquarter class (entity) + */ + private Headquarter createHeadquarter () { + // Create new headquarter instance + final Headquarter headquarter = new BusinessHeadquarter(this.getHeadquarterCity(), this.getHeadquarterCountry(), this.getHeadquarterStreet(), this.getHeadquarterZipCode(), this.getHeadquarterHouseNumber()); + + // Add all other fields, too + headquarter.setHeadquarterContactEmployee(this.getHeadquarterContactEmployee()); + headquarter.setHeadquarterEmailAddress(this.getHeadquarterEmailAddress()); + headquarter.setHeadquarterStore(this.getHeadquarterStore()); + headquarter.setHeadquarterSuiteNumber(this.getHeadquarterSuiteNumber()); + headquarter.setHeadquarterUserOwner(this.getHeadquarterUserOwner()); + + // Generate phone number + final DialableLandLineNumber landLine = new LandLineNumber(this.getLandLineCountry(), this.getLandLineAreaCode(), this.getLandLineNumber()); + final DialableFaxNumber fax = new FaxNumber(this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber()); + + // Don't set null or wrong references + if ((landLine instanceof DialableLandLineNumber) && (landLine.getPhoneCountry() instanceof Country) && (this.getLandLineAreaCode() != null) && (this.getLandLineNumber() != null) && (this.getLandLineAreaCode() > 0) && (this.getLandLineNumber() > 0)) { + // Now the number must be given + if (landLine.getPhoneAreaCode() == null) { + // Is null + throw new NullPointerException("phone.phoneAreaCode is null"); //NOI18N + } else if (landLine.getPhoneAreaCode() < 1) { + // Abort here + throw new IllegalArgumentException("phone.phoneAreaCode is zero or below."); //NOI18N + } else if (landLine.getPhoneNumber() == null) { + // Is null + throw new NullPointerException("phone.phoneNumber is null"); //NOI18N + } else if (landLine.getPhoneNumber() < 1) { + // Abort here + throw new IllegalArgumentException("phone.phoneNumber is zero or below."); //NOI18N + } + + // Set phone number + headquarter.setHeadquarterLandLineNumber(landLine); + } + + // Don't set null or wrong references + if ((fax instanceof DialableFaxNumber) && (fax.getPhoneCountry() instanceof Country) && (this.getFaxAreaCode() != null) && (this.getFaxNumber() != null) && (this.getFaxAreaCode() > 0) && (this.getFaxNumber() > 0)) { + // Now the number must be given + if (fax.getPhoneAreaCode() == null) { + // Is null + throw new NullPointerException("fax.phoneAreaCode is null"); //NOI18N + } else if (fax.getPhoneAreaCode() < 1) { + // Abort here + throw new IllegalArgumentException("fax.phoneAreaCode is zero or below."); //NOI18N + } else if (fax.getPhoneNumber() == null) { + // Is null + throw new NullPointerException("fax.phoneNumber is null"); //NOI18N + } else if (fax.getPhoneNumber() < 1) { + // Abort here + throw new IllegalArgumentException("fax.phoneNumber is zero or below."); //NOI18N + } + + // Set fax number + headquarter.setHeadquarterFaxNumber(fax); + } + // Is the opening times list filled? + if (!this.getHeadquarterOpeningTimes().isEmpty()) { + // Yes, then set in headquarter, too + headquarter.setHeadquarterOpeningTimes(this.getHeadquarterOpeningTimes()); + } + + // Return fully prepared instance + return headquarter; + } + + /** + * Prepares an instance of a OpeningTimes object (entity) with all data from + * this bean. If a complete fax number or land-line number was provided, it + * will be set in the instance as well. + *

+ * @return An instance of a OpeningTimes class (entity) + */ + private OpeningTime createOpeningTimes () { + // Create new openingTime instance + final OpeningTime openingTime = new BusinessOpeningTime(this.getOpeningEndDay(), this.getOpeningEndTime(), this.getOpeningStartDay(), this.getOpeningStartTime()); + + // Return fully prepared instance + return openingTime; + } + + /** + * Checks whether the given headquarter' address is already found in local + * cache. Please note that this method fully relies on the cache, so you + * must always fire proper events that add/update/delete entries in cache. + *

+ * @param headquarter Headquarter to check it's address + *

+ * @return Whether the address has been found + */ + private boolean isHeadquarterCreatedByRequiredData (final Headquarter headquarter) { + // Get full list from other bean + final List allHeadquarter = this.headquarterController.allHeadquarter(); + + // Default is not found + boolean isFound = false; + + // Now check each entry + for (final Headquarter hq : allHeadquarter) { + // Is same address? + if (Headquarters.isSameAddress(hq, headquarter)) { + // Found one + isFound = true; + break; + } + } + + // Return flag + return isFound; + } + + /** + * Checks if given opening time is already added + *

+ * @param openingTime Opening time to be checked + *

+ * @return Whether it has been added already + */ + private boolean isSameOpeningTimeFound (final OpeningTime openingTime) { + // Default is not found + boolean isFound = false; + + // Loop through list + for (final OpeningTime ot : this.getHeadquarterOpeningTimes()) { + // Check it + if (Objects.equals(ot, openingTime)) { + // Found same match + isFound = true; + break; + } + } + + // Return it + return isFound; + } + +} diff --git a/src/java/org/mxchange/jjobs/beans/business/headquarter/JobsAdminHeadquarterWebRequestController.java b/src/java/org/mxchange/jjobs/beans/business/headquarter/JobsAdminHeadquarterWebRequestController.java new file mode 100644 index 00000000..f4e91336 --- /dev/null +++ b/src/java/org/mxchange/jjobs/beans/business/headquarter/JobsAdminHeadquarterWebRequestController.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 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.beans.business.headquarter; + +import java.io.Serializable; + +/** + * An interface for administrative headquarter controller + *

+ * @author Roland Häder + */ +public interface JobsAdminHeadquarterWebRequestController extends Serializable { + +} diff --git a/src/java/org/mxchange/jjobs/beans/business/headquarter/JobsHeadquarterWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/business/headquarter/JobsHeadquarterWebRequestBean.java new file mode 100644 index 00000000..892c951e --- /dev/null +++ b/src/java/org/mxchange/jjobs/beans/business/headquarter/JobsHeadquarterWebRequestBean.java @@ -0,0 +1,224 @@ +/* + * Copyright (C) 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.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; +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.jcontactsbusiness.events.headquarter.added.ObservableHeadquarterAddedEvent; +import org.mxchange.jcontactsbusiness.exceptions.headquarter.HeadquarterNotFoundException; +import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter; +import org.mxchange.jcontactsbusiness.model.headquarter.HeadquarterSessionBeanRemote; +import org.mxchange.jjobs.beans.BaseJobsBean; + +/** + * A general bean for headquarter + *

+ * @author Roland Häder + */ +@Named ("headquarterController") +@RequestScoped +public class JobsHeadquarterWebRequestBean extends BaseJobsBean implements JobsHeadquarterWebRequestController { + + /** + * Serial number + */ + private static final long serialVersionUID = 5_028_697_360_465L; + + /** + * A list of all headquarter + */ + private final List allHeadquarter; + + /** + * A list of filtered headquarter + */ + private List filteredHeadquarter; + + /** + * EJB for administrative purposes + */ + @EJB (lookup = "java:global/jjobs-ejb/headquarter!org.mxchange.jcontactsbusiness.model.headquarter.HeadquarterSessionBeanRemote") + private HeadquarterSessionBeanRemote headquarterBean; + + /** + * A list of all headquarter (globally) + */ + @Inject + @NamedCache (cacheName = "headquarterCache") + private Cache headquarterCache; + + /** + * Default constructor + */ + public JobsHeadquarterWebRequestBean () { + // Call super constructor + super(); + + // Init list + this.allHeadquarter = new LinkedList<>(); + } + + /** + * Observes events being fired when a branch office has been added. + *

+ * @param event Event being fired + *

+ * @throws NullPointerException If the parameter or it's carried instance is + * null + * @throws IllegalArgumentException If the branchId is zero or lower + */ + public void afterHeadquarterAddedEvent (@Observes final ObservableHeadquarterAddedEvent event) { + // Validate parameter + if (null == event) { + // Throw NPE + throw new NullPointerException("event is null"); //NOI18N + } else if (event.getHeadquarter() == null) { + // Throw NPE again + throw new NullPointerException("event.headquarter is null"); //NOI18N + } else if (event.getHeadquarter().getHeadquarterId() == null) { + // Throw it again + throw new NullPointerException("event.headquarter.branchId is null"); //NOI18N + } else if (event.getHeadquarter().getHeadquarterId() < 1) { + // Throw IAE + throw new IllegalArgumentException(MessageFormat.format("event.headquarter.branchId={0} is not valid", event.getHeadquarter().getHeadquarterId())); //NOI18N + } + + // Add instance to cache + this.headquarterCache.put(event.getHeadquarter().getHeadquarterId(), event.getHeadquarter()); + this.allHeadquarter.add(event.getHeadquarter()); + } + + @Override + @SuppressWarnings ("ReturnOfCollectionOrArrayField") + public List allHeadquarter () { + return this.allHeadquarter; + } + + @Override + public Headquarter findHeadquarterById (final Long headquarterId) throws HeadquarterNotFoundException { + // Validate parameter + if (null == headquarterId) { + // Throw NPE + throw new NullPointerException("headquarterId is null"); //NOI18N + } else if (headquarterId < 1) { + // Throw IAE + throw new IllegalArgumentException(MessageFormat.format("headquarterId={0} is invalid", headquarterId)); //NOI18N + } else if (!this.headquarterCache.containsKey(headquarterId)) { + // Not found + throw new HeadquarterNotFoundException(headquarterId); + } + + // Get it from cache + final Headquarter headquarter = this.headquarterCache.get(headquarterId); + + // Return it + return headquarter; + } + + /** + * Getter for a list of filtered headquarter + *

+ * @return Filtered headquarter + */ + @SuppressWarnings ("ReturnOfCollectionOrArrayField") + public List getFilteredHeadquarter () { + return this.filteredHeadquarter; + } + + /** + * Setter for a list of filtered headquarter + *

+ * @param filteredHeadquarter Filtered headquarter + */ + @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter") + public void setFilteredHeadquarter (final List filteredHeadquarter) { + this.filteredHeadquarter = filteredHeadquarter; + } + + /** + * Initializer method + */ + @PostConstruct + public void initializeList () { + // Is cache there? + if (!this.headquarterCache.iterator().hasNext()) { + // Get whole list + final List Headquarter = this.headquarterBean.allHeadquarters(); + + // Add all + for (final Headquarter headquarter : Headquarter) { + // Add it to cache + this.headquarterCache.put(headquarter.getHeadquarterId(), headquarter); + } + } + + // Is the list empty, but filled cache? + if (this.allHeadquarter.isEmpty() && this.headquarterCache.iterator().hasNext()) { + // Get iterator + final Iterator> iterator = this.headquarterCache.iterator(); + + // Build up list + while (iterator.hasNext()) { + // GEt next element + final Cache.Entry next = iterator.next(); + + // Add to list + this.allHeadquarter.add(next.getValue()); + } + + // Sort list + this.allHeadquarter.sort(new Comparator() { + @Override + public int compare (final Headquarter o1, final Headquarter o2) { + return o1.getHeadquarterId() > o2.getHeadquarterId() ? 1 : o1.getHeadquarterId() < o2.getHeadquarterId() ? -1 : 0; + } + }); + } + } + + @Override + public Boolean isEmailAddressRegistered (final String emailAddress) { + // Default is not found + boolean isFound = false; + + // Check all entries + for (final Headquarter headquarter : this.allHeadquarter()) { + // Is email address used? + if (Objects.equals(headquarter.getHeadquarterEmailAddress(), emailAddress)) { + // Found it + isFound = true; + break; + } + } + + // Return flag + return isFound; + } + +} diff --git a/src/java/org/mxchange/jjobs/beans/business/headquarter/JobsHeadquarterWebRequestController.java b/src/java/org/mxchange/jjobs/beans/business/headquarter/JobsHeadquarterWebRequestController.java new file mode 100644 index 00000000..9d65fbad --- /dev/null +++ b/src/java/org/mxchange/jjobs/beans/business/headquarter/JobsHeadquarterWebRequestController.java @@ -0,0 +1,59 @@ +/* + * Copyright (C) 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.beans.business.headquarter; + +import java.io.Serializable; +import java.util.List; +import org.mxchange.jcontactsbusiness.exceptions.headquarter.HeadquarterNotFoundException; +import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter; + +/** + * An interface for general Headquarter controller + *

+ * @author Roland Häder + */ +public interface JobsHeadquarterWebRequestController extends Serializable { + + /** + * Checks if given email address is already registered by an other + * headquarter + *

+ * @param emailAddress Email address + *

+ * @return Whether the email address has been already registered + */ + Boolean isEmailAddressRegistered (final String emailAddress); + + /** + * Returns a list of all headquarter + *

+ * @return A list of all headquarter + */ + List allHeadquarter (); + + /** + * Tries to find a headquarter with given id number + *

+ * @param headquarterId Headquarter id + *

+ * @return A headquarter instance + *

+ * @throws HeadquarterNotFoundException If the headquarter was not found + */ + Headquarter findHeadquarterById (final Long headquarterId) throws HeadquarterNotFoundException; + +} diff --git a/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebRequestBean.java index a419047d..35ae96aa 100644 --- a/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebRequestBean.java @@ -1115,7 +1115,7 @@ public class JobsContactWebRequestBean extends BaseJobsBean implements JobsConta } @Override - public boolean isEmailAddressRegistered (String emailAddress) { + public boolean isEmailAddressRegistered (final String emailAddress) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } diff --git a/src/java/org/mxchange/jjobs/beans/helper/JobsWebRequestHelperBean.java b/src/java/org/mxchange/jjobs/beans/helper/JobsWebRequestHelperBean.java index a6ac5b7c..5bc0b0fc 100644 --- a/src/java/org/mxchange/jjobs/beans/helper/JobsWebRequestHelperBean.java +++ b/src/java/org/mxchange/jjobs/beans/helper/JobsWebRequestHelperBean.java @@ -27,7 +27,8 @@ import org.mxchange.jcontacts.events.contact.created.ObservableCreatedContactEve import org.mxchange.jcontacts.model.contact.Contact; import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice; import org.mxchange.jcontactsbusiness.model.department.Department; -import org.mxchange.jcontactsbusiness.model.headquarters.HeadquartersData; +import org.mxchange.jcontactsbusiness.model.employee.Employable; +import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter; import org.mxchange.jjobs.beans.BaseJobsBean; import org.mxchange.jjobs.beans.localization.JobsLocalizationSessionController; import org.mxchange.jjobs.beans.user.JobsUserWebRequestController; @@ -567,44 +568,71 @@ public class JobsWebRequestHelperBean extends BaseJobsBean implements JobsWebReq } /** - * Returns the headquarters address. If null is provided, an empty string is + * Returns the product name and price. If null is provided, an empty string + * is returned. + *

+ * @param product Product instance + *

+ * @return Product name + */ + public String renderGenericProduct (final Product product) { + // Default is empty string, so let's get started + final StringBuilder sb = new StringBuilder(10); + + // Is a product set? + if (product instanceof Product) { + // Add name and price + sb.append(this.getMessageFromBundle(product.getProductI18nKey())); + sb.append(" ("); //NOI18N + sb.append(this.localizationController.formatCurrency(product.getProductGrossPrice())); + sb.append(" "); //NOI18N + sb.append(product.getProductCurrencyCode()); + sb.append(")"); //NOI18N + } + + // Return it + return sb.toString(); + } + + /** + * Returns the headquarter address. If null is provided, an empty string is * returned. *

- * @param headquarters Headquarters instance + * @param headquarter Headquarter instance *

- * @return Headquarters address + * @return Headquarter address */ - public String renderHeadquarters (final HeadquartersData headquarters) { + public String renderHeadquarter (final Headquarter headquarter) { // Default is empty string, so let's get started final StringBuilder sb = new StringBuilder(10); - // Is a headquarters set? - if (headquarters instanceof HeadquartersData) { + // Is a headquarter set? + if (headquarter instanceof Headquarter) { // Then create name - sb.append(headquarters.getHeadquartersStreet()); + sb.append(headquarter.getHeadquarterStreet()); sb.append(" "); //NOI18N - sb.append(headquarters.getHeadquartersHouseNumber()); + sb.append(headquarter.getHeadquarterHouseNumber()); // Is store/suite number set? - if (headquarters.getHeadquartersStore() instanceof Short) { + if (headquarter.getHeadquarterStore() instanceof Short) { sb.append(" ("); //NOI18N sb.append(this.getMessageFromBundle("DATA_STORE")); //NOI18N sb.append(" "); //NOI18N - sb.append(headquarters.getHeadquartersStore()); + sb.append(headquarter.getHeadquarterStore()); sb.append(", "); //NOI18N sb.append(this.getMessageFromBundle("DATA_SUITE_NUMBER")); //NOI18N sb.append(" "); //NOI18N - sb.append(headquarters.getHeadquartersSuiteNumber()); + sb.append(headquarter.getHeadquarterSuiteNumber()); sb.append(")"); //NOI18N } // Continue with country, ZIP code and city sb.append(", "); //NOI18N - sb.append(headquarters.getHeadquartersCountry().getCountryCode()); + sb.append(headquarter.getHeadquarterCountry().getCountryCode()); sb.append(" "); //NOI18N - sb.append(headquarters.getHeadquartersZipCode()); + sb.append(headquarter.getHeadquarterZipCode()); sb.append(" "); //NOI18N - sb.append(headquarters.getHeadquartersCity()); + sb.append(headquarter.getHeadquarterCity()); } // Return it diff --git a/src/java/org/mxchange/jjobs/converter/business/basicdata/JobsBusinessContactConverter.java b/src/java/org/mxchange/jjobs/converter/business/basicdata/JobsBusinessContactConverter.java index 83b20e21..4f41c2b4 100644 --- a/src/java/org/mxchange/jjobs/converter/business/basicdata/JobsBusinessContactConverter.java +++ b/src/java/org/mxchange/jjobs/converter/business/basicdata/JobsBusinessContactConverter.java @@ -24,8 +24,8 @@ import javax.faces.convert.ConverterException; import javax.faces.convert.FacesConverter; import org.mxchange.jcontactsbusiness.exceptions.basicdata.BasicDataNotFoundException; import org.mxchange.jcontactsbusiness.model.basicdata.BasicData; -import org.mxchange.jjobs.beans.business.basicdata.JobsBusinessDataWebRequestBean; -import org.mxchange.jjobs.beans.business.basicdata.JobsBusinessDataWebRequestController; +import org.mxchange.jjobs.beans.business.basicdata.JobsBasicDataWebRequestBean; +import org.mxchange.jjobs.beans.business.basicdata.JobsBasicDataWebRequestController; /** * Converter for basic company data id <-> valid basic company data instance @@ -38,14 +38,14 @@ public class JobsBasicCompanyDataConverter implements Converter { /** * Basic company data backing bean */ - private static JobsBusinessDataWebRequestController BASIC_DATA_CONTROLLER; + private static JobsBasicDataWebRequestController BASIC_DATA_CONTROLLER; @Override public BasicData getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) { // Is the instance there? - if (BASIC_DATA_CONTROLLER == null) { + if (null == BASIC_DATA_CONTROLLER) { // Get bean from CDI directly - BASIC_DATA_CONTROLLER = CDI.current().select(JobsBusinessDataWebRequestBean.class).get(); + BASIC_DATA_CONTROLLER = CDI.current().select(JobsBasicDataWebRequestBean.class).get(); } // Is the value null or empty? diff --git a/src/java/org/mxchange/jjobs/converter/business/branchoffice/JobsBranchOfficeConverter.java b/src/java/org/mxchange/jjobs/converter/business/branchoffice/JobsBranchOfficeConverter.java index 5c700adf..6d72217f 100644 --- a/src/java/org/mxchange/jjobs/converter/business/branchoffice/JobsBranchOfficeConverter.java +++ b/src/java/org/mxchange/jjobs/converter/business/branchoffice/JobsBranchOfficeConverter.java @@ -43,7 +43,7 @@ public class JobsBranchOfficeConverter implements Converter { @Override public BranchOffice getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) { // Is the instance there? - if (BRANCH_OFFICE_CONTROLLER == null) { + if (null == BRANCH_OFFICE_CONTROLLER) { // Get bean from CDI directly BRANCH_OFFICE_CONTROLLER = CDI.current().select(JobsBranchOfficeWebRequestBean.class).get(); } diff --git a/src/java/org/mxchange/jjobs/converter/business/department/JobsCompanyDepartmentConverter.java b/src/java/org/mxchange/jjobs/converter/business/department/JobsCompanyDepartmentConverter.java index b84061d7..b480e600 100644 --- a/src/java/org/mxchange/jjobs/converter/business/department/JobsCompanyDepartmentConverter.java +++ b/src/java/org/mxchange/jjobs/converter/business/department/JobsCompanyDepartmentConverter.java @@ -43,7 +43,7 @@ public class JobsDepartmentConverter implements Converter { @Override public Department getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) { // Is the instance there? - if (DEPARTMENT_CONTROLLER == null) { + if (null == DEPARTMENT_CONTROLLER) { // Get bean from CDI directly DEPARTMENT_CONTROLLER = CDI.current().select(JobsDepartmentWebRequestBean.class).get(); } diff --git a/src/java/org/mxchange/jjobs/converter/business/employee/JobsEmployeeConverter.java b/src/java/org/mxchange/jjobs/converter/business/employee/JobsEmployeeConverter.java index 65cc395e..646af467 100644 --- a/src/java/org/mxchange/jjobs/converter/business/employee/JobsEmployeeConverter.java +++ b/src/java/org/mxchange/jjobs/converter/business/employee/JobsEmployeeConverter.java @@ -43,7 +43,7 @@ public class JobsEmployeeConverter implements Converter { @Override public Employable getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) { // Is the instance there? - if (EMPLOYEE_CONTROLLER == null) { + if (null == EMPLOYEE_CONTROLLER) { // Get bean from CDI directly EMPLOYEE_CONTROLLER = CDI.current().select(JobsEmployeeWebRequestBean.class).get(); } diff --git a/src/java/org/mxchange/jjobs/converter/business/headquarter/JobsHeadquarterConverter.java b/src/java/org/mxchange/jjobs/converter/business/headquarter/JobsHeadquarterConverter.java new file mode 100644 index 00000000..0ee2ea4c --- /dev/null +++ b/src/java/org/mxchange/jjobs/converter/business/headquarter/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.headquarter; + +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 headquarter 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()); + } + +} diff --git a/src/java/org/mxchange/jjobs/converter/business/opening_time/JobsCompanyOpeningTimeConverter.java b/src/java/org/mxchange/jjobs/converter/business/opening_time/JobsCompanyOpeningTimeConverter.java index 8fc86430..1d88fc83 100644 --- a/src/java/org/mxchange/jjobs/converter/business/opening_time/JobsCompanyOpeningTimeConverter.java +++ b/src/java/org/mxchange/jjobs/converter/business/opening_time/JobsCompanyOpeningTimeConverter.java @@ -43,7 +43,7 @@ public class JobsCompanyOpeningTimeConverter implements Converter { @Override public OpeningTime getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) { // Is the instance there? - if (OPENING_TIMES_CONTROLLER == null) { + if (null == OPENING_TIMES_CONTROLLER) { // Get bean from CDI directly OPENING_TIMES_CONTROLLER = CDI.current().select(JobsOpeningTimeWebRequestBean.class).get(); } diff --git a/src/java/org/mxchange/jjobs/converter/contact/JobsContactConverter.java b/src/java/org/mxchange/jjobs/converter/contact/JobsContactConverter.java index 2731b969..b57562bf 100644 --- a/src/java/org/mxchange/jjobs/converter/contact/JobsContactConverter.java +++ b/src/java/org/mxchange/jjobs/converter/contact/JobsContactConverter.java @@ -43,7 +43,7 @@ public class JobsContactConverter implements Converter { @Override public Contact getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) { // Is the instance there? - if (CONTACT_CONTROLLER == null) { + if (null == CONTACT_CONTROLLER) { // Get bean from CDI directly CONTACT_CONTROLLER = CDI.current().select(JobsContactWebRequestBean.class).get(); } diff --git a/src/java/org/mxchange/jjobs/converter/country/JobsCountryConverter.java b/src/java/org/mxchange/jjobs/converter/country/JobsCountryConverter.java index 4289c3da..bf0f5461 100644 --- a/src/java/org/mxchange/jjobs/converter/country/JobsCountryConverter.java +++ b/src/java/org/mxchange/jjobs/converter/country/JobsCountryConverter.java @@ -43,7 +43,7 @@ public class JobsCountryConverter implements Converter { @Override public Country getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) { // Is the instance there? - if (COUNTRY_CONTROLLER == null) { + if (null == COUNTRY_CONTROLLER) { // Get bean from CDI directly COUNTRY_CONTROLLER = CDI.current().select(JobsCountryWebRequestBean.class).get(); } diff --git a/src/java/org/mxchange/jjobs/converter/fax/JobsFaxNumberConverter.java b/src/java/org/mxchange/jjobs/converter/fax/JobsFaxNumberConverter.java index 225fdea6..c97b4542 100644 --- a/src/java/org/mxchange/jjobs/converter/fax/JobsFaxNumberConverter.java +++ b/src/java/org/mxchange/jjobs/converter/fax/JobsFaxNumberConverter.java @@ -43,7 +43,7 @@ public class JobsFaxNumberConverter implements Converter { @Override public DialableFaxNumber getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) { // Is the instance there? - if (PHONE_CONTROLLER == null) { + if (null == PHONE_CONTROLLER) { // Get bean from CDI directly PHONE_CONTROLLER = CDI.current().select(JobsPhoneWebRequestBean.class).get(); } diff --git a/src/java/org/mxchange/jjobs/converter/landline/JobsLandLineNumberConverter.java b/src/java/org/mxchange/jjobs/converter/landline/JobsLandLineNumberConverter.java index ed7f613e..c18992f4 100644 --- a/src/java/org/mxchange/jjobs/converter/landline/JobsLandLineNumberConverter.java +++ b/src/java/org/mxchange/jjobs/converter/landline/JobsLandLineNumberConverter.java @@ -43,7 +43,7 @@ public class JobsLandLineNumberConverter implements Converter { @Override public MobileProvider getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) { // Is the instance there? - if (MOBILE_PROVIDER_CONTROLLER == null) { + if (null == MOBILE_PROVIDER_CONTROLLER) { // Get bean from CDI directly MOBILE_PROVIDER_CONTROLLER = CDI.current().select(JobsMobileProviderWebRequestBean.class).get(); } diff --git a/src/java/org/mxchange/jjobs/converter/user/JobsUserConverter.java b/src/java/org/mxchange/jjobs/converter/user/JobsUserConverter.java index e9e4dcc5..579faef2 100644 --- a/src/java/org/mxchange/jjobs/converter/user/JobsUserConverter.java +++ b/src/java/org/mxchange/jjobs/converter/user/JobsUserConverter.java @@ -43,7 +43,7 @@ public class JobsUserConverter implements Converter { @Override public User getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) { // Is the instance there? - if (USER_CONTROLLER == null) { + if (null == USER_CONTROLLER) { // Get bean from CDI directly USER_CONTROLLER = CDI.current().select(JobsUserWebRequestBean.class).get(); } diff --git a/src/java/org/mxchange/jjobs/validator/business/basicdata/JobsCompanyNameValidator.java b/src/java/org/mxchange/jjobs/validator/business/basicdata/JobsCompanyNameValidator.java index 1d45b7ae..3cc67c6f 100644 --- a/src/java/org/mxchange/jjobs/validator/business/basicdata/JobsCompanyNameValidator.java +++ b/src/java/org/mxchange/jjobs/validator/business/basicdata/JobsCompanyNameValidator.java @@ -24,8 +24,8 @@ import javax.faces.context.FacesContext; import javax.faces.validator.FacesValidator; import javax.faces.validator.ValidatorException; import org.mxchange.jcoreee.validator.string.BaseStringValidator; -import org.mxchange.jjobs.beans.business.basicdata.JobsBusinessDataWebRequestBean; -import org.mxchange.jjobs.beans.business.basicdata.JobsBusinessDataWebRequestController; +import org.mxchange.jjobs.beans.business.basicdata.JobsBasicDataWebRequestBean; +import org.mxchange.jjobs.beans.business.basicdata.JobsBasicDataWebRequestController; /** * A validator for company names @@ -38,7 +38,7 @@ public class JobsCompanyNameValidator extends BaseStringValidator { /** * Business basic data backing bean */ - private static JobsBusinessDataWebRequestController BASIC_DATA_CONTROLLER; + private static JobsBasicDataWebRequestController BASIC_DATA_CONTROLLER; /** * Serial number @@ -48,9 +48,9 @@ public class JobsCompanyNameValidator extends BaseStringValidator { @Override public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException { // Is the instance there? - if (BASIC_DATA_CONTROLLER == null) { + if (null == BASIC_DATA_CONTROLLER) { // Get bean from CDI directly - BASIC_DATA_CONTROLLER = CDI.current().select(JobsBusinessDataWebRequestBean.class).get(); + BASIC_DATA_CONTROLLER = CDI.current().select(JobsBasicDataWebRequestBean.class).get(); } // All accepted, required fields diff --git a/src/java/org/mxchange/jjobs/validator/emailaddress/JobsEmailAddressValidator.java b/src/java/org/mxchange/jjobs/validator/emailaddress/JobsEmailAddressValidator.java index f83f4ebc..24d96d79 100644 --- a/src/java/org/mxchange/jjobs/validator/emailaddress/JobsEmailAddressValidator.java +++ b/src/java/org/mxchange/jjobs/validator/emailaddress/JobsEmailAddressValidator.java @@ -58,12 +58,6 @@ public class JobsEmailAddressValidator extends BaseStringValidator { @Override public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException { - // Is the instance there? - if (CONTACT_CONTROLLER == null) { - // Get bean from CDI directly - CONTACT_CONTROLLER = CDI.current().select(JobsContactWebRequestBean.class).get(); - } - // The required field final String[] requiredFields = {"emailAddress", "emailAddressRepeat", "resendEmailAddress"}; //NOI18N @@ -117,6 +111,12 @@ public class JobsEmailAddressValidator extends BaseStringValidator { // Get client id (aka form id) final String clientId = component.getClientId(); + // Is the instance there? + if (null == CONTACT_CONTROLLER) { + // Get bean from CDI directly + CONTACT_CONTROLLER = CDI.current().select(JobsContactWebRequestBean.class).get(); + } + // Is it registered? final Boolean isRegistered = CONTACT_CONTROLLER.isEmailAddressRegistered(emailAddress); diff --git a/src/java/org/mxchange/jjobs/validator/emailaddress/basicdata/JobsBasicDataEmailAddressValidator.java b/src/java/org/mxchange/jjobs/validator/emailaddress/basicdata/JobsBasicDataEmailAddressValidator.java new file mode 100644 index 00000000..3a6b076f --- /dev/null +++ b/src/java/org/mxchange/jjobs/validator/emailaddress/basicdata/JobsBasicDataEmailAddressValidator.java @@ -0,0 +1,139 @@ +/* + * 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.validator.emailaddress.basicdata; + +import java.text.MessageFormat; +import java.util.regex.Pattern; +import javax.enterprise.inject.spi.CDI; +import javax.faces.application.FacesMessage; +import javax.faces.component.UIComponent; +import javax.faces.context.FacesContext; +import javax.faces.validator.FacesValidator; +import javax.faces.validator.ValidatorException; +import org.mxchange.jcoreee.validator.string.BaseStringValidator; +import org.mxchange.jjobs.beans.business.basicdata.JobsBasicDataWebRequestBean; +import org.mxchange.jjobs.beans.business.basicdata.JobsBasicDataWebRequestController; + +/** + * A validator for basic company data email address validation + *

+ * @author Roland Häder + */ +@FacesValidator (value = "BasicDataEmailAddressValidator") +public class JobsBasicDataEmailAddressValidator extends BaseStringValidator { + + /** + * Branch office backing bean + */ + private static JobsBasicDataWebRequestController BASIC_DATA_CONTROLLER; + + /** + * Email pattern + */ + private static final String EMAIL_REGEX = "^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$"; //NOI18N + + /** + * Pattern matcher + */ + private static final Pattern PATTERN_MATCHER = Pattern.compile(JobsBasicDataEmailAddressValidator.EMAIL_REGEX); + + /** + * Serial number + */ + private static final long serialVersionUID = 187_536_745_607_195L; + + @Override + public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException { + // The required field + final String[] requiredFields = {"emailAddress", "emailAddressRepeat", "resendEmailAddress"}; //NOI18N + + // Default is to reject empty email address fields + Boolean allowEmptyValue = Boolean.FALSE; + + // Is attribute "allowEmptyValue" set? + if (component.getAttributes().containsKey("allowEmptyValue")) { //NOI18N + // Get attribute + final Object attribute = component.getAttributes().get("allowEmptyValue"); //NOI18N + + // Make sure, it is Boolean as no String is accepted anymore + if (!(attribute instanceof String)) { + // Not valid attribute, please use "true" or "false" (default) + throw new IllegalArgumentException("allowEmptyValue must be of type String. Please use \"true\" or \"false\" for f:attribute value."); //NOI18N + } + + // Securely cast it + allowEmptyValue = Boolean.parseBoolean((String) attribute); + } + + // Pre-validation (example: not null, not a string, empty string ...) + super.preValidate(context, component, value, requiredFields, allowEmptyValue); + + // Is the email address empty and allowed? + if (null == value && allowEmptyValue) { + // Then accept this here + return; + } else if (null == value) { + // Abort here + throw new ValidatorException(new FacesMessage("No empty email address allowed.")); //NOI18N + } + + // Get string from object ... ;-) + // @TODO Add IDN support (GNU lib?) Search for emailAddressRepeat + final String emailAddress = String.valueOf(value).trim(); + + // Checks if the email address matches a regex ("low-level" check) + // @TODO Should also be done by ) + final boolean matches = PATTERN_MATCHER.matcher(emailAddress).matches(); //NOI18N + + // Is the email address valid? + if (!matches) { + // Generate message + String message = MessageFormat.format("Email address {0} does not match regular expression.", emailAddress); //NOI18N + + // Not matching + throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_WARN, message, message)); + } + + // Get client id (aka form id) + final String clientId = component.getClientId(); + + // Is the instance there? + if (null == BASIC_DATA_CONTROLLER) { + // Get bean from CDI directly + BASIC_DATA_CONTROLLER = CDI.current().select(JobsBasicDataWebRequestBean.class).get(); + } + + // Is it registered? + final Boolean isRegistered = BASIC_DATA_CONTROLLER.isEmailAddressRegistered(emailAddress); + + // Is the email address already registered? + if ((!clientId.endsWith("resendEmailAddress")) && (isRegistered)) { //NOI18N + // Generate message + final String message = MessageFormat.format("Email address {0} is already registered.", emailAddress); //NOI18N + + // No, then abort here + throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_INFO, message, message)); + } else if ((clientId.endsWith("resendEmailAddress")) && (!isRegistered)) { //NOI18N + // Generate message + final String message = MessageFormat.format("Email address {0} is not registered.", emailAddress); //NOI18N + + // No, then abort here + throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_INFO, message, message)); + } + } + +} diff --git a/src/java/org/mxchange/jjobs/validator/emailaddress/branchoffice/JobsBranchOfficeEmailAddressValidator.java b/src/java/org/mxchange/jjobs/validator/emailaddress/branchoffice/JobsBranchOfficeEmailAddressValidator.java new file mode 100644 index 00000000..acc93b90 --- /dev/null +++ b/src/java/org/mxchange/jjobs/validator/emailaddress/branchoffice/JobsBranchOfficeEmailAddressValidator.java @@ -0,0 +1,139 @@ +/* + * 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.validator.emailaddress.branchoffice; + +import java.text.MessageFormat; +import java.util.regex.Pattern; +import javax.enterprise.inject.spi.CDI; +import javax.faces.application.FacesMessage; +import javax.faces.component.UIComponent; +import javax.faces.context.FacesContext; +import javax.faces.validator.FacesValidator; +import javax.faces.validator.ValidatorException; +import org.mxchange.jcoreee.validator.string.BaseStringValidator; +import org.mxchange.jjobs.beans.business.branchoffice.JobsBranchOfficeWebRequestBean; +import org.mxchange.jjobs.beans.business.branchoffice.JobsBranchOfficeWebRequestController; + +/** + * A validator for branch office email address validation + *

+ * @author Roland Häder + */ +@FacesValidator (value = "BranchOfficeEmailAddressValidator") +public class JobsBranchOfficeEmailAddressValidator extends BaseStringValidator { + + /** + * Branch office backing bean + */ + private static JobsBranchOfficeWebRequestController BRANCH_OFFICE_CONTROLLER; + + /** + * Email pattern + */ + private static final String EMAIL_REGEX = "^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$"; //NOI18N + + /** + * Pattern matcher + */ + private static final Pattern PATTERN_MATCHER = Pattern.compile(JobsBranchOfficeEmailAddressValidator.EMAIL_REGEX); + + /** + * Serial number + */ + private static final long serialVersionUID = 187_536_745_607_195L; + + @Override + public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException { + // The required field + final String[] requiredFields = {"emailAddress", "emailAddressRepeat", "resendEmailAddress"}; //NOI18N + + // Default is to reject empty email address fields + Boolean allowEmptyValue = Boolean.FALSE; + + // Is attribute "allowEmptyValue" set? + if (component.getAttributes().containsKey("allowEmptyValue")) { //NOI18N + // Get attribute + final Object attribute = component.getAttributes().get("allowEmptyValue"); //NOI18N + + // Make sure, it is Boolean as no String is accepted anymore + if (!(attribute instanceof String)) { + // Not valid attribute, please use "true" or "false" (default) + throw new IllegalArgumentException("allowEmptyValue must be of type String. Please use \"true\" or \"false\" for f:attribute value."); //NOI18N + } + + // Securely cast it + allowEmptyValue = Boolean.parseBoolean((String) attribute); + } + + // Pre-validation (example: not null, not a string, empty string ...) + super.preValidate(context, component, value, requiredFields, allowEmptyValue); + + // Is the email address empty and allowed? + if (null == value && allowEmptyValue) { + // Then accept this here + return; + } else if (null == value) { + // Abort here + throw new ValidatorException(new FacesMessage("No empty email address allowed.")); //NOI18N + } + + // Get string from object ... ;-) + // @TODO Add IDN support (GNU lib?) Search for emailAddressRepeat + final String emailAddress = String.valueOf(value).trim(); + + // Checks if the email address matches a regex ("low-level" check) + // @TODO Should also be done by ) + final boolean matches = PATTERN_MATCHER.matcher(emailAddress).matches(); //NOI18N + + // Is the email address valid? + if (!matches) { + // Generate message + String message = MessageFormat.format("Email address {0} does not match regular expression.", emailAddress); //NOI18N + + // Not matching + throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_WARN, message, message)); + } + + // Get client id (aka form id) + final String clientId = component.getClientId(); + + // Is the instance there? + if (null == BRANCH_OFFICE_CONTROLLER) { + // Get bean from CDI directly + BRANCH_OFFICE_CONTROLLER = CDI.current().select(JobsBranchOfficeWebRequestBean.class).get(); + } + + // Is it registered? + final Boolean isRegistered = BRANCH_OFFICE_CONTROLLER.isEmailAddressRegistered(emailAddress); + + // Is the email address already registered? + if ((!clientId.endsWith("resendEmailAddress")) && (isRegistered)) { //NOI18N + // Generate message + final String message = MessageFormat.format("Email address {0} is already registered.", emailAddress); //NOI18N + + // No, then abort here + throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_INFO, message, message)); + } else if ((clientId.endsWith("resendEmailAddress")) && (!isRegistered)) { //NOI18N + // Generate message + final String message = MessageFormat.format("Email address {0} is not registered.", emailAddress); //NOI18N + + // No, then abort here + throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_INFO, message, message)); + } + } + +} diff --git a/src/java/org/mxchange/jjobs/validator/emailaddress/headquarter/JobsHeadquarterEmailAddressValidator.java b/src/java/org/mxchange/jjobs/validator/emailaddress/headquarter/JobsHeadquarterEmailAddressValidator.java new file mode 100644 index 00000000..aa566f7a --- /dev/null +++ b/src/java/org/mxchange/jjobs/validator/emailaddress/headquarter/JobsHeadquarterEmailAddressValidator.java @@ -0,0 +1,139 @@ +/* + * 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.validator.emailaddress.headquarter; + +import java.text.MessageFormat; +import java.util.regex.Pattern; +import javax.enterprise.inject.spi.CDI; +import javax.faces.application.FacesMessage; +import javax.faces.component.UIComponent; +import javax.faces.context.FacesContext; +import javax.faces.validator.FacesValidator; +import javax.faces.validator.ValidatorException; +import org.mxchange.jcoreee.validator.string.BaseStringValidator; +import org.mxchange.jjobs.beans.business.headquarter.JobsHeadquarterWebRequestBean; +import org.mxchange.jjobs.beans.business.headquarter.JobsHeadquarterWebRequestController; + +/** + * A validator for headquarter's email address validation + *

+ * @author Roland Häder + */ +@FacesValidator (value = "HeadquarterEmailAddressValidator") +public class JobsHeadquarterEmailAddressValidator extends BaseStringValidator { + + /** + * Email pattern + */ + private static final String EMAIL_REGEX = "^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$"; //NOI18N + + /** + * Headquarter backing bean + */ + private static JobsHeadquarterWebRequestController HEADQUARTER_CONTROLLER; + + /** + * Pattern matcher + */ + private static final Pattern PATTERN_MATCHER = Pattern.compile(JobsHeadquarterEmailAddressValidator.EMAIL_REGEX); + + /** + * Serial number + */ + private static final long serialVersionUID = 187_536_745_607_194L; + + @Override + public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException { + // The required field + final String[] requiredFields = {"emailAddress", "emailAddressRepeat", "resendEmailAddress"}; //NOI18N + + // Default is to reject empty email address fields + Boolean allowEmptyValue = Boolean.FALSE; + + // Is attribute "allowEmptyValue" set? + if (component.getAttributes().containsKey("allowEmptyValue")) { //NOI18N + // Get attribute + final Object attribute = component.getAttributes().get("allowEmptyValue"); //NOI18N + + // Make sure, it is Boolean as no String is accepted anymore + if (!(attribute instanceof String)) { + // Not valid attribute, please use "true" or "false" (default) + throw new IllegalArgumentException("allowEmptyValue must be of type String. Please use \"true\" or \"false\" for f:attribute value."); //NOI18N + } + + // Securely cast it + allowEmptyValue = Boolean.parseBoolean((String) attribute); + } + + // Pre-validation (example: not null, not a string, empty string ...) + super.preValidate(context, component, value, requiredFields, allowEmptyValue); + + // Is the email address empty and allowed? + if (null == value && allowEmptyValue) { + // Then accept this here + return; + } else if (null == value) { + // Abort here + throw new ValidatorException(new FacesMessage("No empty email address allowed.")); //NOI18N + } + + // Get string from object ... ;-) + // @TODO Add IDN support (GNU lib?) Search for emailAddressRepeat + final String emailAddress = String.valueOf(value).trim(); + + // Checks if the email address matches a regex ("low-level" check) + // @TODO Should also be done by ) + final boolean matches = PATTERN_MATCHER.matcher(emailAddress).matches(); //NOI18N + + // Is the email address valid? + if (!matches) { + // Generate message + String message = MessageFormat.format("Email address {0} does not match regular expression.", emailAddress); //NOI18N + + // Not matching + throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_WARN, message, message)); + } + + // Get client id (aka form id) + final String clientId = component.getClientId(); + + // Is the instance there? + if (null == HEADQUARTER_CONTROLLER) { + // Get bean from CDI directly + HEADQUARTER_CONTROLLER = CDI.current().select(JobsHeadquarterWebRequestBean.class).get(); + } + + // Is it registered? + final Boolean isRegistered = HEADQUARTER_CONTROLLER.isEmailAddressRegistered(emailAddress); + + // Is the email address already registered? + if ((!clientId.endsWith("resendEmailAddress")) && (isRegistered)) { //NOI18N + // Generate message + final String message = MessageFormat.format("Email address {0} is already registered.", emailAddress); //NOI18N + + // No, then abort here + throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_INFO, message, message)); + } else if ((clientId.endsWith("resendEmailAddress")) && (!isRegistered)) { //NOI18N + // Generate message + final String message = MessageFormat.format("Email address {0} is not registered.", emailAddress); //NOI18N + + // No, then abort here + throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_INFO, message, message)); + } + } + +} diff --git a/src/java/org/mxchange/jjobs/validator/user/JobsUserIdValidator.java b/src/java/org/mxchange/jjobs/validator/user/JobsUserIdValidator.java index b416b0e8..d3bc56a9 100644 --- a/src/java/org/mxchange/jjobs/validator/user/JobsUserIdValidator.java +++ b/src/java/org/mxchange/jjobs/validator/user/JobsUserIdValidator.java @@ -47,18 +47,18 @@ public class JobsUserIdValidator extends BaseNumberValidator { @Override public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException { - // Is the instance there? - if (USER_CONTROLLER == null) { - // Get bean from CDI directly - USER_CONTROLLER = CDI.current().select(JobsUserWebRequestBean.class).get(); - } - // All accepted, required fields final String[] requiredFields = {"userId"}; //NOI18N // Pre-validation (example: not null, not a string, empty string ...) super.preValidate(context, component, value, requiredFields, false); + // Is the instance there? + if (null == USER_CONTROLLER) { + // Get bean from CDI directly + USER_CONTROLLER = CDI.current().select(JobsUserWebRequestBean.class).get(); + } + // Cast value final Long userId = (Long) value; diff --git a/src/java/org/mxchange/localization/generic_de_DE.properties b/src/java/org/mxchange/localization/generic_de_DE.properties index 6353d3c7..ebad34de 100644 --- a/src/java/org/mxchange/localization/generic_de_DE.properties +++ b/src/java/org/mxchange/localization/generic_de_DE.properties @@ -492,6 +492,7 @@ ADMIN_LINK_EXPORT_CONTACT=Kontaktdaten exportieren ADMIN_LINK_EXPORT_CONTACT_TITLE=Kontaktdaten exportieren PERSONAL_DATA_BIRTHDAY=Geburtsdatum (tt.mm.jjjj): DATE_PATTERN=dd.MM.yyyy +DATE_TIME_PATTERN=dd.MM.yyyy HH:mm:ss ADMIN_EXPORT_CONTACT_ID=Kontaktdaten-Id ADMIN_EXPORT_CONTACT_PERSONAL_TITLE=Anrede ADMIN_EXPORT_CONTACT_ACADEMIC_TITLE=Titel @@ -578,7 +579,6 @@ ERROR_BEAN_HELPER_USER_NOT_SET=Fehler: Instanz 'user' im Bean-Helper nicht geset ERROR_BEAN_HELPER_CONTACT_NOT_SET=Fehler: Instanz 'contact' im Bean-Helper nicht gesetzt. ERROR_BEAN_HELPER_MOBILE_NUMBER_NOT_SET=Fehler: Instanz 'mobile' in Bean-Helper nicht gesetzt. CONTENT_TITLE_ADMIN_LIST_CONTACT_MOBILE_NUMBER=Auflisten von Mobiltelefonnummern: -ADMIN_LIST_MOBILE_EMPTY=Es sind keine Mobilfunknummern gespeichert. ADMIN_MENU_PHONE_NUMBERS_TITLE=Telefonnummern: ADMIN_LINK_LIST_MOBILE_PHONE_NUMBERS=Handynummern ADMIN_LINK_LIST_MOBILE_PHONE_NUMBERS_TITLE=Alle Mobilfunknummern auflisten. @@ -629,17 +629,15 @@ ADMIN_LINK_LIST_LAND_LINE_PHONE_NUMBERS=Festnetznummern ... ADMIN_LINK_LIST_LAND_LINE_PHONE_NUMBERS_TITLE=Listet alle Festnetznummern auf. ADMIN_LINK_LIST_FAX_PHONE_NUMBERS=Faxnummern ADMIN_LINK_LIST_FAX_PHONE_NUMBERS_TITLE=Listet alle Faxnummern auf. -ADMIN_LIST_FAX_NUMBER_EMPTY=Es sind keine Faxnummern gelistet. PAGE_TITLE_ADMIN_LIST_CONTACT_FAX_NUMBER=Faxnummern auflisten CONTENT_TITLE_ADMIN_LIST_CONTACT_FAX_NUMBER=Auflisten von Faxnummern: PAGE_TITLE_ADMIN_LIST_CONTACT_LAND_LINE_NUMBER=Festnetznummern auflisten CONTENT_TITLE_ADMIN_LIST_CONTACT_LAND_LINE_NUMBER=Auflisten von Festnetznummern: -ADMIN_SHOW_PHONE_NUMBER=Festnetznummer: +ADMIN_SHOW_LAND_LINE_NUMBER=Festnetznummer: PAGE_TITLE_ADMIN_SHOW_LAND_LINE_NUMBER=Festnetznummer anzeigen CONTENT_TITLE_ADMIN_SHOW_LAND_LINE_NUMBER=Festnetznummer anzeigen: ERROR_BEAN_HELPER_LAND_LINE_NUMBER_NOT_SET=Fehler: Instanz 'landLine' nicht in Bean-Helper gesetzt. ADMIN_HEADER_SHOW_LAND_LINE_NUMBER_LINKS=Alle Festnetznummer-Verkn\u00fcpfungen f\u00fcr Id-Nummer {0}: -ADMIN_LIST_LAND_LINE_EMPTY=Es sind keine Festnetznummern gelistet. ADMIN_HEADER_SHOW_LAND_LINE_NUMBER_DATA=Daten der Festnetznummer: ADMIN_SHOW_LAND_LINE_NUMBER_COMPLETE=Vollst\u00e4ndige Festnetznummer: ADMIN_HEADER_SHOW_FAX_NUMBER_DATA=Daten der Faxnummer: @@ -789,36 +787,36 @@ GUEST_REGISTRATION_PASSWORD_REPEAT_NOT_ENTERED=Bitte wiederholen Sie das eingege PAGE_TITLE_ADMIN_AREA=Administration #@TODO Please fix German umlauts! ADMIN_MENU_BUSINESS_CONTACT_TITLE=Geschaeftliche Kontakte -ADMIN_LINK_LIST_BASIC_COMPANY_DATA=Unternehmensstammdaten -ADMIN_LINK_LIST_BASIC_COMPANY_DATA_TITLE=Listet Stammdaten von Unternehmen auf. -PAGE_TITLE_ADMIN_LIST_BASIC_COMPANY_DATA=Stammdaten auflisten +ADMIN_LINK_LIST_BASIC_DATA=Unternehmensstammdaten +ADMIN_LINK_LIST_BASIC_DATA_TITLE=Listet Stammdaten von Unternehmen auf. +PAGE_TITLE_ADMIN_LIST_BASIC_DATA=Stammdaten auflisten #@TODO Please fix German umlauts! -CONTENT_TITLE_ADMIN_LIST_BASIC_COMPANY_DATA=Auflisten von Stammdaten +CONTENT_TITLE_ADMIN_LIST_BASIC_DATA=Auflisten von Stammdaten #@TODO Please fix German umlauts! -ADMIN_EMPTY_LIST_BASIC_COMPANY_DATA=Es befinden sich keine Stammdaten in der Datenbank. Oder Ihre Suche ergab keine Uebereinstimmungen. +ADMIN_EMPTY_LIST_BASIC_DATA=Es befinden sich keine Stammdaten in der Datenbank. Oder Ihre Suche ergab keine Uebereinstimmungen. #@TODO Please fix German umlauts! -TABLE_SUMMARY_ADMIN_LIST_BASIC_COMPANY_DATA=Diese Tabelle listet Stammdaten auf. -ADMIN_HEADER_BASIC_COMPANY_DATA_ID=Id-Nummer: +TABLE_SUMMARY_ADMIN_LIST_BASIC_DATA=Diese Tabelle listet Stammdaten auf. +ADMIN_HEADER_BASIC_DATA_ID=Id-Nummer: #@TODO Please fix German umlauts! ADMIN_LINK_SHOW_BASIC_COMAPNY_DATA_TITLE=Stammdaten des Unternehmens anzeigen. ADMIN_HEADER_ASSIGNED_USER=Zugew. Benutzer: -ADMIN_LINK_SHOW_BASIC_COMPANY_DATA_OWNER_USER_TITLE=Benutzerprofil des zugewiesenen Benutzers anzeigen. +ADMIN_LINK_SHOW_BASIC_DATA_OWNER_USER_TITLE=Benutzerprofil des der Filiale zugewiesenen Benutzers anzeigen. ADMIN_LINK_ASSIGN=Zuweisen #@TODO Please fix German umlauts! -ADMIN_LINK_ASSIGN_BASIC_COMPANY_DATA_OWNER_USER_TITLE=Stammdaten einen Benutzeraccount zuweisen. +ADMIN_LINK_ASSIGN_BASIC_DATA_OWNER_USER_TITLE=Stammdaten einen Benutzeraccount zuweisen. ADMIN_HEADER_BASIC_DATA_COMPANY_NAME=Firmenname: ADMIN_HEADER_COMPANY_CONTACT_PERSON=Ansprechpartner: -ADMIN_LINK_SHOW_BASIC_COMPANY_DATA_CONTACT_PERSON_TITLE=Zeigt einen Mitarbeiter an, der als Ansprechpartner eingetragen ist. -ADMIN_LINK_ASSIGN_BASIC_COMPANY_DATA_CONTACT_PERSON=Zuweisen +ADMIN_LINK_SHOW_BASIC_DATA_CONTACT_PERSON_TITLE=Zeigt einen Mitarbeiter an, der als Ansprechpartner eingetragen ist. +ADMIN_LINK_ASSIGN_BASIC_DATA_CONTACT_PERSON=Zuweisen #@TODO Please fix German umlauts! -ADMIN_LINK_ASSIGN_BASIC_COMPANY_DATA_CONTACT_PERSON_TITLE=Weisst einen Mitarbeiter als Ansprechpartner des geschaftlichen Kontaktes zu. +ADMIN_LINK_ASSIGN_BASIC_DATA_CONTACT_PERSON_TITLE=Weisst einen Mitarbeiter als Ansprechpartner des geschaftlichen Kontaktes zu. ADMIN_SHOW_FULL_CONTACT_DATA_TITLE=Zeigt das komplette Kontaktprofil an. ADMIN_BASIC_DATA_COMPANY_COMMENTS=Anmerkungen: ADMIN_BASIC_DATA_PHONE_NUMBER=Haupttelefonnummer: ADMIN_BASIC_DATA_FAX_NUMBER=Hauptfaxnummer: #@TODO Please fix German umlauts! -ADMIN_ADD_BASIC_COMPANY_DATA_TITLE=Geschaeftlichen Kontakt hinzufuegen -ADMIN_ADD_BASIC_COMPANY_DATA_MINIMUM_DATA=Bitte mindestens Firmennamen inklusive Rechtsform ein. +ADMIN_ADD_BASIC_DATA_TITLE=Geschaeftlichen Kontakt hinzufuegen +ADMIN_ADD_BASIC_DATA_MINIMUM_DATA=Bitte mindestens Firmennamen inklusive Rechtsform ein. #@TODO Please fix German umlauts! ENTERED_EMAIL_ADDRESS_IS_INVALID=Die eingegebene Email-Addresse entspricht nicht dem gueltigen Format. #@TODO Please fix German umlauts! @@ -829,33 +827,33 @@ ADMIN_BASIC_DATA_COMPANY_NAME_REQUIRED=Bitte geben Sie den Firmennamen inklusive ADMIN_BASIC_DATA_COMPANY_LEGAL_STATUS=Rechtsform (z.B. GmbH): ADMIN_BASIC_DATA_COMPANY_EMAIL_ADDRESS=Haupt-Email-Adresse: #@TODO Please fix German umlauts! -BUTTON_ADMIN_ADD_BASIC_COMPANY_DATA=Basisdaten hinzufuegen +BUTTON_ADMIN_ADD_BASIC_DATA=Basisdaten hinzufuegen ERROR_GUEST_REGISTRATION_IN_INDEX_ENABLED=Fehler: Falscher Aufruf der Anmeldeseite, da die Eingangsseite als Anmeldeseite fungiert. #@TODO Please fix German umlauts! BUTTON_CHANGE_LOCALE=Aendern #@TODO Please fix German umlauts! BUTTON_CHANGE_LOCALE_TITLE=Aendern Sie hier in der aktuellen Sitzung die angezeigte Sprache. #@TODO Please fix German umlauts! -ADMIN_SELECT_BASIC_COMPANY_DATA_COMPANY_FOUNDER=Firmengruender auswaehlen: +ADMIN_SELECT_BASIC_DATA_COMPANY_FOUNDER=Firmengruender auswaehlen: ADMIN_FEATURE_UNFINISHED_WARNING=Diese Funktion ist noch nicht fertiggestellt. ADMIN_BASIC_DATA_COMPANY_TAX_NUMBER=Steuernummer: ADMIN_BASIC_DATA_COMPANY_WEBSITE_URL=Webseiten-URL: -ADMIN_SELECT_BASIC_COMPANY_DATA_COMPANY_USER_OWNER=Unternehmen einem Benutzer zuweisen: +ADMIN_SELECT_BASIC_DATA_COMPANY_USER_OWNER=Unternehmen einem Benutzer zuweisen: #@TODO Please fix German umlauts! -ADMIN_SELECT_BASIC_COMPANY_DATA_COMPANY_LOGO=Firmenlogo auswaehlen: +ADMIN_SELECT_BASIC_DATA_COMPANY_LOGO=Firmenlogo auswaehlen: #@TODO Please fix German umlauts! URL_NOT_MATCHING_REGULAR_EXPRESSION=Die eingegebene URL entspricht nicht der ueblichen Form. #@TODO Please fix German umlauts! -ADMIN_SELECT_BASIC_COMPANY_DATA_COMPANY_CONTACT_EMPLOYEE=Mitarbeiter als Kontaktperson auswaehlen: +ADMIN_SELECT_BASIC_DATA_COMPANY_CONTACT_EMPLOYEE=Mitarbeiter als Kontaktperson auswaehlen: #@TODO Please fix German umlauts! -ADMIN_SELECT_BASIC_COMPANY_DATA_COMPANY_HEADQUARTERS=Daten des Hauptsitzesz auswaehlen: +ADMIN_SELECT_BASIC_DATA_COMPANY_HEADQUARTER=Daten des Hauptsitzesz auswaehlen: LINK_COMPANY_WEBSITE_URL_TITLE=Link zur Unternehmenswebseite (neues Fenster) #@TODO Please fix German umlauts! ADMIN_HEADER_BASIC_DATA_COMPANY_FOUNDER=Gruender #@TODO Please fix German umlauts! -ADMIN_LINK_SHOW_BASIC_COMPANY_DATA_COMPANY_FOUNDER_TITLE=Daten des Unternehmensgruenders anzeigen. +ADMIN_LINK_SHOW_BASIC_DATA_COMPANY_FOUNDER_TITLE=Daten des Unternehmensgruenders anzeigen. #@TODO Please fix German umlauts! -ADMIN_LINK_ASSIGN_BASIC_COMPANY_DATA_COMPANY_FOUNDER_TITLE=Weisst diesem Firmeneintrag einen Unternehmensgruender zu. +ADMIN_LINK_ASSIGN_BASIC_DATA_COMPANY_FOUNDER_TITLE=Weisst diesem Firmeneintrag einen Unternehmensgruender zu. ADMIN_USER_NAME_IS_REQUIRED=Bitte vergeben Sie einen Benutzernamen. Dieser muss unique sein. NO_WEBSITE_URL_ENTERED=Keine URL eingegeben. ADMIN_LINK_LIST_BRANCH_OFFICES=Filialen @@ -867,7 +865,7 @@ ADMIN_ASSIGN_BRANCH_OFFICE_CONTACT_EMPLOYEE=Kontaktperson der Filiale zuweisen: ADMIN_BRANCH_OFFICE_DATA_LEGEND=Grunddaten der Filiale: #@TODO Please fix German umlauts! ADMIN_BRANCH_OFFICE_DATA_LEGEND_TITLE=Geben Sie hier die Grunddaten der Filiale ein. -ADMIN_ASSIGN_BRANCH_OFFICE=Filiale dem Unternehmen zuweisen: +ADMIN_ASSIGN_BASIC_DATA_BRANCH_OFFICE=Unternehmen der Filiale zuweisen: PAGE_TITLE_ADMIN_LIST_BRANCH_OFFICES=Filialen auflisten CONTENT_TITLE_ADMIN_LIST_BRANCH_OFFICES=Auflisten von Filialen: #@TODO Please fix German umlauts! @@ -877,7 +875,7 @@ ADMIN_ADD_BRANCH_OFFICE_TITLE=Filiale hinzufuegen #@TODO Please fix German umlauts! ADMIN_ADD_BRANCH_OFFICE_MINIMUM_DATA=Bitte waehlen Sie mindestens das zugehoerige Unternehmen und das Land aus und geben Sie Strasse, Hausnummer, Postleitzahl und Stadt ein. ADMIN_ENTER_BRANCH_OFFICE_EMAIL_ADDRESS=Email-Addresse der Filiale: -ADMIN_ENTER_BRANCH_OFFICE_PHONE_NUMBER=Telefonnummer eingeben: +ADMIN_ENTER_BRANCH_OFFICE_LAND_LINE_NUMBER=Telefonnummer eingeben: ADMIN_ENTER_BRANCH_OFFICE_FAX_NUMBER=Faxnummer eingeben: #@TODO Please fix German umlauts! ADMIN_BRANCH_OFFICE_REQUIRED=Bitte waehlen das zur Filiale gehoerende Unternehmen aus. @@ -998,7 +996,7 @@ ADMIN_EMPLOYEE_OTHER_LEGEND=Weitere Daten des Mitarbeiters: ADMIN_EMPLOYEE_OTHER_LEGEND_TITLE=Geben Sie hier weitere Daten des Mitarbeiters ein. Diese sind alle optional. ADMIN_ENTER_PHONE_EXTENSION=Durchwahl eingeben: ADMIN_ASSIGN_EMPLOYEE_DEPARTMENT=Abteilung einem Mitarbeiter zuweisen: -ADMIN_ASSIGN_EMPLOYEE_HEADQUARTERS=Hauptsitz einem Mitarbeiter zuweisen: +ADMIN_ASSIGN_EMPLOYEE_HEADQUARTER=Hauptsitz einem Mitarbeiter zuweisen: ADMIN_ENTER_EMPLOYEE_MOBILE_NUMBER=Geschaefliche Mobilfunknummer des Mitarbeiters eingeben: ADMIN_EMPLOYEE_GENERAL_LEGEND=Allgemeine Daten des Mitarbeiters: ADMIN_EMPLOYEE_GENERAL_LEGEND_TITLE=Geben Sie hier die generellen Daten des Mitarbeiters an. @@ -1016,7 +1014,7 @@ ADMIN_ADD_EMPLOYEE_TITLE=Mitarbeiter hinzufuegen ADMIN_ADD_EMPLOYEE_MINIMUM_DATA=Bitte waehlen Sie mindestens das Unternehmen aus und geben SIe mindestens entweder die Mitarbeiternummer ein oder waehlen Sie die persoenlichen Kontaktdaten des Mitarbeiters aus. #@TODO Please fix German umlauts! BUTTON_ADMIN_ADD_EMPLOYEE=Mitarbeiter hinzufuegen -ADMIN_LIST_BASIC_COMPANY_DATA_HEADER=Alle Unternehmensgrunddaten auflisten +ADMIN_LIST_BASIC_DATA_HEADER=Alle Unternehmensgrunddaten auflisten ADMIN_LINK_LIST_DEPARTMENTS=Abteilungen ADMIN_LINK_LIST_DEPARTMENTS_TITLE=Listet Abteilungen von Unternehmen auf. #@TODO Please fix German umlauts! @@ -1027,7 +1025,7 @@ CONTENT_TITLE_ADMIN_LIST_DEPARTMENTS=Auflisten von Abteilungen: ADMIN_EMPTY_LIST_DEPARTMENTS=Es befinden sich keine Abteilungen in der Datenbank. Oder Ihre Suche ergab keine Uebereinstimmungen. ADMIN_LINK_SHOW_DEPARTMENT_TITLE=Zeigt Details zur Abteilung an. ADMIN_LINK_EDIT_DEPARTMENT_TITLE=Editieren der Abteilung -ADMIN_LINK_DELETE_DEPARTMENT_TITLE=Loescht die Abteilung +ADMIN_LINK_DELETE_DEPARTMENT_TITLE=Loescht die Abteilung. #@TODO Please fix German umlauts! ADMIN_DEPARTMENT_ALREADY_CREATED=Die Abteilung existiert bereits im ausgewaehlten Unternehmen. ADMIN_LIST_DEPARTMENTS_HEADER=Alle Abteilungen auflisten @@ -1041,7 +1039,7 @@ ADMIN_DEPARTMENT_LEGEND_TITLE=Geben Sie hier die Daten der Abteilung ein. #@TODO Please fix German umlauts! ADMIN_ADD_DEPARTMENT_MINIMUM_DATA=Bitte geben Sie mindestens den Namen der Abteilung (z.B. Verkauf) ein und waehlen Sie mindestens das Unternehmen aus. Wenn bekannt, waehlen Sie entweder eine Filiale oder eine Hauptniederlassung aus. ADMIN_ASSIGN_DEPARTMENT_BRANCH_OFFICE=Filiale der Abteilung zuweisen: -ADMIN_ASSIGN_DEPARTMENT_HEADQUARTERS=Hauptsitz der Abteilung zuweisen: +ADMIN_ASSIGN_DEPARTMENT_HEADQUARTER=Hauptsitz der Abteilung zuweisen: ADMIN_ASSIGN_DEPARTMENT_COMPANY=Unternehmen der Abteilung zuweisen: ADMIN_ASSIGN_DEPARTMENT_LEAD_EMPLOYEE=Leitender Mitarbeiter der Abteilung zuweisen: ADMIN_ASSIGN_DEPARTMENT_USER_OWNER=Benutzer als Besitzer der Abteilung zuweisen: @@ -1087,12 +1085,12 @@ ADMIN_LIST_USERS_HEADER=Liste aller Benutzer #@TODO Please fix German umlauts! ADMIN_BRANCH_OFFICE_OPENING_TIMES_LEGEND=Oeffnungszeiten der Filiale: #@TODO Please fix German umlauts! -TABLE_SUMMARY_ADMIN_LIST_BRANCH_OFFICE_OPENING_TIMES=Diese Tabelle listet Oeffnungszeiten der Filiale auf. +TABLE_SUMMARY_ADMIN_LIST_BRANCH_OFFICE_OPENING_TIMES=Diese Tabelle listet neue Oeffnungszeiten der Filiale auf. TABLE_SUMMARY_ADMIN_LIST_BRANCH_OFFICES=Diese Tabelle listet Filialen auf. #@TODO Please fix German umlauts! -ADMIN_EMPTY_LIST_BRANCH_OFFICE_OPENING_TIMES=Es befinden sich keine Oeffnungszeiten dieser Filiale in der Datenbank. +ADMIN_EMPTY_LIST_BRANCH_OFFICE_OPENING_TIMES=Es wurden noch keine Oeffnungszeiten fuer eine neue Filiale hinzugefuegt. #@TODO Please fix German umlauts! -ADMIN_LIST_BRANCH_OFFICE_OPENING_TIMES_HEADER=Alle Oeffnungszeiten der Filiale auflisten +ADMIN_LIST_BRANCH_OFFICE_OPENING_TIMES_HEADER=Oeffnungszeiten der neuen Filiale auflisten #@TODO Please fix German umlauts! ADMIN_ADD_BRANCH_OFFICE_OPENING_TIME_TITLE=Oeffnungszeit zur Filiale hinzufuegen #@TODO Please fix German umlauts! @@ -1102,3 +1100,51 @@ ADMIN_BRANCH_OFFICE_OPENING_TIME_LEGEND_TITLE=Geben Sie hier eine einzelne Oeffn #@TODO Please fix German umlauts! ADMIN_OPENING_TIME_ALREADY_CREATED=Die Oeffnungzeit wurde bereits hinzugefuegt. ADMIN_NOT_ASSIGNED=Nicht zugewiesen +ADMIN_BASIC_DATA_COMPANY_NAME=Firmenname: +ADMIN_LINK_SHOW_HEADQUARTER_TITLE=Zeigt Details zur Hauptstelle an. +ADMIN_LINK_EDIT_HEADQUARTER_TITLE=Editieren der Hauptstelle. +ADMIN_LINK_DELETE_HEADQUARTER_TITLE=Loescht die Hauptstelle. +PAGE_TITLE_ADMIN_LIST_HEADQUARTER=Haupstellen auflisten +CONTENT_TITLE_ADMIN_LIST_HEADQUARTER=Auflisten von Hauptstellen: +TABLE_SUMMARY_ADMIN_LIST_HEADQUARTER=Diese Tabelle listet alle Hauptstellen auf. +#@TODO Please fix German umlauts! +ADMIN_EMPTY_LIST_HEADQUARTER=Es befinden sich keine Hauptstellen in der Datenbank oder Ihre Suche ergab keine Uebereinstimmungen. +ADMIN_LIST_HEADQUARTER_HEADER=Alle Hauptstellen auflisten +ADMIN_LINK_SHOW_HEADQUARTER_OWNER_USER_TITLE=Benutzerprofil des der Hauptstelle zugewiesenen Benutzers anzeigen. +#@TODO Please fix German umlauts! +ADMIN_ADD_HEADQUARTER_TITLE=Hauptstelle hinzufuegen +ADMIN_LINK_LIST_HEADQUARTER=Hauptstellen +ADMIN_LINK_LIST_HEADQUARTER_TITLE=Listed alle Hauptstellen auf. +#@TODO Please fix German umlauts! +ADMIN_ADD_HEADQUARTER_MINIMUM_DATA=Bitte waehlen Sie mindestens das Land aus und geben Sie Strasse, Hausnummer, Postleitzahl und Stadt ein. +ADMIN_HEADQUARTER_LEGEND=Daten der Hauptstelle: +ADMIN_ASSIGN_HEADQUARTER_CONTACT_EMPLOYEE=Mitarbeiter als Kontaktperson fuer Hauptstelle: +ADMIN_ASSIGN_HEADQUARTER_USER_OWNER=Benutzer als Besitzer der Hauptstelle zuweisen: +ADMIN_ENTER_HEADQUARTER_EMAIL_ADDRESS=Email-Adresse der Hauptstelle eingeben: +ADMIN_ENTER_HEADQUARTER_LAND_LINE_NUMBER=Festnetznummer der Hauptstelle eingeben: +ADMIN_ENTER_HEADQUARTER_FAX_NUMBER=Faxnummer der Hauptstelle eingeben: +ADMIN_HEADQUARTER_ADDRESS_LEGEND=Adresse der Hauptstelle: +ADMIN_HEADQUARTER_STREET_NAME_REQUIRED=Bitte geben Sie den Strassennamen der Hauptstelle ein. +ADMIN_HEADQUARTER_HOUSE_NUMBER_REQUIRED=Bitte geben Sie die Hausnummer der Hauptstelle ein. +ADMIN_HEADQUARTER_ZIP_CODE_REQUIRED=Bitte geben Sie die Postleitzahl der Hauptstelle ein. +ADMIN_HEADQUARTER_CITY_REQUIRED=Bitte geben Sie die Stadt der Hauptstelle ein. +#@TODO Please fix German umlauts! +ADMIN_BRANCH_OFFICE_COUNTRY_REQUIRED=Bittw waehlen Sie ein Land fuer die Filiale aus. +#@TODO Please fix German umlauts! +ADMIN_HEADQUARTER_COUNTRY_REQUIRED=Bitte waehlen Sie ein Land fuer die Hauptstelle aus. +#@TODO Please fix German umlauts! +BUTTON_ADMIN_ADD_HEADQUARTER=Hauptstelle hinzufuegen +#@TODO Please fix German umlauts! +ADMIN_HEADQUARTER_OPENING_TIMES_LEGEND=Oeffnungszeiten der Hauptstelle: +#@TODO Please fix German umlauts! +TABLE_SUMMARY_ADMIN_LIST_HEADQUARTER_OPENING_TIMES=Diese Tabelle listet neue Oeffnungszeiten der Hauptstelle auf. +#@TODO Please fix German umlauts! +ADMIN_EMPTY_LIST_HEADQUARTER_OPENING_TIMES=Es wurden noch keine Oeffnungszeiten fuer eine neue Hauptstelle hinzugefuegt. +#@TODO Please fix German umlauts! +ADMIN_LIST_HEADQUARTER_OPENING_TIMES_HEADER=Oeffnungszeiten der neuen Hauptstelle auflisten +#@TODO Please fix German umlauts! +ADMIN_ADD_HEADQUARTER_OPENING_TIME_TITLE=Oeffnungszeit zur Hauptstelle hinzufuegen +#@TODO Please fix German umlauts! +BUTTON_ADMIN_ADD_HEADQUARTER_OPENING_TIME=Oeffnungszeit zur Hauptstelle hinzufuegen +ADMIN_LINK_ASSIGN_EMPLOYEE_BRANCH_OFFICE_TITLE=Diesem Mitarbeiter eine Abteilung zuweisen. +ADMIN_LINK_ASSIGN_EMPLOYEES_OWNER_USER_TITLE=Diesem Mitarbeiter einen besitzenden Benutzer zuweisen. diff --git a/src/java/org/mxchange/localization/generic_en_US.properties b/src/java/org/mxchange/localization/generic_en_US.properties index d9bf6bbe..35e70381 100644 --- a/src/java/org/mxchange/localization/generic_en_US.properties +++ b/src/java/org/mxchange/localization/generic_en_US.properties @@ -278,7 +278,7 @@ 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: ADMIN_LINK_EDIT_DELETE_COUNTRY_TITLE=Edit or delete country -TABLE_SUMMARY_ADMIN_LIST_COUNTRIES=List of all already added countries. +TABLE_SUMMARY_ADMIN_LIST_COUNTRIES=This table lists all countries. COUNTRY_GERMANY=Germany ADMIN_MENU_MOBILE_PROVIDER_TITLE=Mobile providers ADMIN_LINK_LIST_MOBILE_PROVIDER=List mobile provider @@ -293,7 +293,7 @@ ADMIN_MOBILE_PROVIDER_LEGEND_TITLE=Here you can enter all data of the mobile pro CONTENT_TITLE_ADMIN_MOBILE_PROVIDER_DELETE=Delete mobile provider: CONTENT_TITLE_ADMIN_MOBILE_PROVIDER_EDIT=Edit mobile provider: PAGE_TITLE_ADMIN_MOBILE_PROVIDER_DELETE=Delete mobile provider -TABLE_SUMMARY_ADMIN_LIST_MOBILE_PROVIDERS=Lists all already added mobile providers. +TABLE_SUMMARY_ADMIN_LIST_MOBILE_PROVIDERS=This table lists all mobile providers. ADMIN_ENTER_MOBILE_PROVIDER_DIAL_PREFIX=Dial prefix of provider (no leading zero): ADMIN_ENTER_MOBILE_PROVIDER_PATTERN=Pattern for mails: ADMIN_ENTER_MOBILE_PROVIDER_NAME=Name of provider: @@ -486,6 +486,7 @@ ADMIN_LINK_EXPORT_CONTACT=Export data ADMIN_LINK_EXPORT_CONTACT_TITLE=Export contact data PERSONAL_DATA_BIRTHDAY=Birthday (mm-dd-yyyy): DATE_PATTERN=MM-dd-yyyy +DATE_TIME_PATTERN=MM-dd-yyyy HH:mm:ss ADMIN_EXPORT_CONTACT_ID=Contact data id ADMIN_EXPORT_CONTACT_PERSONAL_TITLE=Gender ADMIN_EXPORT_CONTACT_ACADEMIC_TITLE=Title @@ -569,7 +570,6 @@ ERROR_BEAN_HELPER_USER_NOT_SET=Error: Instance 'user' not set in bean helper. ERROR_BEAN_HELPER_CONTACT_NOT_SET=Error: Instance 'contact' not set in bean helper. ERROR_BEAN_HELPER_MOBILE_NUMBER_NOT_SET=Error: Instance 'mobile' in bean helper not set. CONTENT_TITLE_ADMIN_LIST_CONTACT_MOBILE_NUMBER=List mobile phone numbers: -ADMIN_LIST_MOBILE_EMPTY=No mobile numbers are saved. ADMIN_MENU_PHONE_NUMBERS_TITLE=Phone numbers: ADMIN_LINK_LIST_MOBILE_PHONE_NUMBERS=Mobile numbers ADMIN_LINK_LIST_MOBILE_PHONE_NUMBERS_TITLE=List all mobile numbers. @@ -620,17 +620,15 @@ ADMIN_LINK_LIST_LAND_LINE_PHONE_NUMBERS=Land-line numbers ... ADMIN_LINK_LIST_LAND_LINE_PHONE_NUMBERS_TITLE=Lists all land-line numbers. ADMIN_LINK_LIST_FAX_PHONE_NUMBERS=Fax numbers ADMIN_LINK_LIST_FAX_PHONE_NUMBERS_TITLE=Lists all fax numbers. -ADMIN_LIST_FAX_NUMBER_EMPTY=There are no fax numbers listed. PAGE_TITLE_ADMIN_LIST_CONTACT_FAX_NUMBER=List fax numbers CONTENT_TITLE_ADMIN_LIST_CONTACT_FAX_NUMBER=List fax numbers: PAGE_TITLE_ADMIN_LIST_CONTACT_LAND_LINE_NUMBER=List land-line numbers CONTENT_TITLE_ADMIN_LIST_CONTACT_LAND_LINE_NUMBER=List land-line numbers: -ADMIN_SHOW_PHONE_NUMBER=Land-line number: +ADMIN_SHOW_LAND_LINE_NUMBER=Land-line number: PAGE_TITLE_ADMIN_SHOW_LAND_LINE_NUMBER=Show land-line number CONTENT_TITLE_ADMIN_SHOW_LAND_LINE_NUMBER=Show land-line number: ERROR_BEAN_HELPER_LAND_LINE_NUMBER_NOT_SET=Error: Instance 'landLine' not set in bean helper. ADMIN_HEADER_SHOW_LAND_LINE_NUMBER_LINKS=All links for land-line number id number {0}: -ADMIN_LIST_LAND_LINE_EMPTY=There are no land-line numbers listed. ADMIN_HEADER_SHOW_LAND_LINE_NUMBER_DATA=Data of land-line number: ADMIN_SHOW_LAND_LINE_NUMBER_COMPLETE=Complete land-line number: ADMIN_HEADER_SHOW_FAX_NUMBER_DATA=Data of fax number: @@ -693,7 +691,7 @@ CONTENT_TITLE_ADMIN_DELETE_LAND_LINE_NUMBER=Delete land-line number: ADMIN_DELETE_LAND_LINE_NUMBER_TITLE=Dou you really want to delete following land-line number? ADMIN_DELETE_LAND_LINE_NUMBER_DATA_NOTICE=If you delete the land-line number, it won't be available anymore for anything. Please consider carefully if you really want this. BUTTON_ADMIN_DELETE_LAND_LINE_NUMBER=Delete land-line number -ADMIN_EMPTY_LIST_CONTACT=No contact data found in database. Or your search criteria doesn't match anything. +ADMIN_EMPTY_LIST_CONTACT=There are no contacts of contacts in database. Or your search criteria doesn't match anything. ADMIN_EMPTY_LIST_USER=No user data found in database. Or your search criteria doesn't match anything. ADMIN_PERSONAL_DATA_COMMENT=Comment: (optional) ADMIN_LINK_RESEND_USER_CONFIRMATION_LINK=Send new confirmation key @@ -702,7 +700,6 @@ ERROR_ADMIN_CANNOT_RESEND_USER_CONFIRMATION_LINK_ACCOUNT_UNLOCKED=Error: Cannot ERROR_ADMIN_CANNOT_RESEND_USER_CONFIRMATION_LINK_ACCOUNT_LOCKED=Error: Cannot send new confirmation link to user, account is locked. BUTTON_ADMIN_RESEND_USER_CONFIRMATION_LINK_ACCOUNT=Send new confirmation link ADMIN_RESEND_USER_CONFIRMATION_LINK_TITLE=Do you want to send a new confirmation link to user {0} (id numer {1})? -#Durch das Zuschicken eines neuen Best\u00e4tigungslinkes wird der alte ung\u00fcltig und nur noch der neue Link kann verwendet werden. ADMIN_RESEND_USER_CONFIRMATION_LINK_NOTICE=By sending a new confirmation link to the user, the old link becomes invalid and only the new link can be used. PAGE_TITLE_ADMIN_RESEND_USER_CONFIRMATION_LINK=Send new confirmation link CONTENT_TITLE_ADMIN_RESEND_USER_CONFIRMATION_LINK=Send new confirmation link: @@ -778,54 +775,52 @@ GUEST_REGISTRATION_PASSWORD_NOT_ENTERED=Please enter a password. This must match GUEST_REGISTRATION_PASSWORD_REPEAT_NOT_ENTERED=Please repeat the entered password. This done to confirm the password. PAGE_TITLE_ADMIN_AREA=Administration ADMIN_MENU_BUSINESS_CONTACT_TITLE=Business contacts -ADMIN_LINK_LIST_BASIC_COMPANY_DATA=Basic company data -ADMIN_LINK_LIST_BASIC_COMPANY_DATA_TITLE=Lists basic company data. -PAGE_TITLE_ADMIN_LIST_BASIC_COMPANY_DATA=List basic company data -CONTENT_TITLE_ADMIN_LIST_BASIC_COMPANY_DATA=Lists basic company data -ADMIN_EMPTY_LIST_BASIC_COMPANY_DATA=There are currently no basic company data in database. Or your search criteria doesn't match anything. -TABLE_SUMMARY_ADMIN_LIST_BASIC_COMPANY_DATA=This table lists all basic company data. -ADMIN_HEADER_BASIC_COMPANY_DATA_ID=Id Number: +ADMIN_LINK_LIST_BASIC_DATA=Basic company data +ADMIN_LINK_LIST_BASIC_DATA_TITLE=Lists basic company data. +PAGE_TITLE_ADMIN_LIST_BASIC_DATA=List basic company data +CONTENT_TITLE_ADMIN_LIST_BASIC_DATA=Lists basic company data +ADMIN_EMPTY_LIST_BASIC_DATA=There are no basic company data in database. Or your search criteria doesn't match anything. +TABLE_SUMMARY_ADMIN_LIST_BASIC_DATA=This table lists all basic company data. +ADMIN_HEADER_BASIC_DATA_ID=Id Number: ADMIN_LINK_SHOW_BASIC_COMAPNY_DATA_TITLE=Show details of this business contact. ADMIN_HEADER_ASSIGNED_USER=Assigned user: -ADMIN_LINK_SHOW_BASIC_COMPANY_DATA_OWNER_USER_TITLE=Shows assigned user profile. +ADMIN_LINK_SHOW_BASIC_DATA_OWNER_USER_TITLE=Shows branch office's assigned user profile. ADMIN_LINK_ASSIGN=Assign -ADMIN_LINK_ASSIGN_BASIC_COMPANY_DATA_OWNER_USER_TITLE=Assigns this business contact to a user account. +ADMIN_LINK_ASSIGN_BASIC_DATA_OWNER_USER_TITLE=Assigns this business contact to a user account. ADMIN_HEADER_BASIC_DATA_COMPANY_NAME=Company name: ADMIN_HEADER_COMPANY_CONTACT_PERSON=Contact person: -ADMIN_LINK_SHOW_BASIC_COMPANY_DATA_CONTACT_PERSON_TITLE=Shows a single employee entry who has been assigned as contact person. -ADMIN_LINK_ASSIGN_BASIC_COMPANY_DATA_CONTACT_PERSON=Assign -ADMIN_LINK_ASSIGN_BASIC_COMPANY_DATA_CONTACT_PERSON_TITLE=Assigns an employee as a contact person for given business contact. +ADMIN_LINK_SHOW_BASIC_DATA_CONTACT_PERSON_TITLE=Shows a single employee entry who has been assigned as contact person. +ADMIN_LINK_ASSIGN_BASIC_DATA_CONTACT_PERSON=Assign +ADMIN_LINK_ASSIGN_BASIC_DATA_CONTACT_PERSON_TITLE=Assigns an employee as a contact person for given business contact. ADMIN_SHOW_FULL_CONTACT_DATA_TITLE=Shows complete contact profile. ADMIN_BASIC_DATA_COMPANY_COMMENTS=Comments: ADMIN_BASIC_DATA_PHONE_NUMBER=Main phone number: ADMIN_BASIC_DATA_FAX_NUMBER=Main fax number: -ADMIN_ADD_BASIC_COMPANY_DATA_TITLE=Add new business contact -ADMIN_ADD_BASIC_COMPANY_DATA_MINIMUM_DATA=Please enter at least company name including legal status. +ADMIN_ADD_BASIC_DATA_TITLE=Add new business contact +ADMIN_ADD_BASIC_DATA_MINIMUM_DATA=Please enter at least company name including legal status. ENTERED_EMAIL_ADDRESS_IS_INVALID=Your entered email address is not valid. ADMIN_BASIC_DATA_LEGEND=Basic data for business contact: -#Geben Sie die Basisdaten fuer einen geschaeftlichen Kontakt ein. ADMIN_BASIC_DATA_LEGEND_TITLE=Enter basic data for a business contact. ADMIN_BASIC_DATA_COMPANY_NAME_REQUIRED=Please enter the company's name including legal status. ADMIN_BASIC_DATA_COMPANY_LEGAL_STATUS=Legal status (e.g. Inc.): ADMIN_BASIC_DATA_COMPANY_EMAIL_ADDRESS=Main email address: -BUTTON_ADMIN_ADD_BASIC_COMPANY_DATA=Add basic data -#Fehler: Falscher Aufruf der Anmeldeseite, da die Eingangsseite als Anmeldeseite fungiert. +BUTTON_ADMIN_ADD_BASIC_DATA=Add basic data ERROR_GUEST_REGISTRATION_IN_INDEX_ENABLED=Error: Wrong request on registration page as the index page serves as registration page. BUTTON_CHANGE_LOCALE=Change BUTTON_CHANGE_LOCALE_TITLE=Change here in your current session the used language for text output. -ADMIN_SELECT_BASIC_COMPANY_DATA_COMPANY_FOUNDER=Choose company founder: +ADMIN_SELECT_BASIC_DATA_COMPANY_FOUNDER=Choose company founder: ADMIN_FEATURE_UNFINISHED_WARNING=This feature is not yet finished. ADMIN_BASIC_DATA_COMPANY_TAX_NUMBER=Tax number: ADMIN_BASIC_DATA_COMPANY_WEBSITE_URL=Website URL: -ADMIN_SELECT_BASIC_COMPANY_DATA_COMPANY_USER_OWNER=Select user to assign with company: -ADMIN_SELECT_BASIC_COMPANY_DATA_COMPANY_LOGO=Choose company logo: +ADMIN_SELECT_BASIC_DATA_COMPANY_USER_OWNER=Select user to assign with company: +ADMIN_SELECT_BASIC_DATA_COMPANY_LOGO=Choose company logo: URL_NOT_MATCHING_REGULAR_EXPRESSION=The entered URL does not match the common form. -ADMIN_SELECT_BASIC_COMPANY_DATA_COMPANY_CONTACT_EMPLOYEE=Choose employee as contact person: -ADMIN_SELECT_BASIC_COMPANY_DATA_COMPANY_HEADQUARTERS=Choose headquarters: +ADMIN_SELECT_BASIC_DATA_COMPANY_CONTACT_EMPLOYEE=Choose employee as contact person: +ADMIN_SELECT_BASIC_DATA_COMPANY_HEADQUARTER=Choose headquarter: LINK_COMPANY_WEBSITE_URL_TITLE=Link to company's web site (new window) ADMIN_HEADER_BASIC_DATA_COMPANY_FOUNDER=Founder -ADMIN_LINK_SHOW_BASIC_COMPANY_DATA_COMPANY_FOUNDER_TITLE=Show data of company founder. -ADMIN_LINK_ASSIGN_BASIC_COMPANY_DATA_COMPANY_FOUNDER_TITLE=Assigns a company founder to this company entry. +ADMIN_LINK_SHOW_BASIC_DATA_COMPANY_FOUNDER_TITLE=Show data of company founder. +ADMIN_LINK_ASSIGN_BASIC_DATA_COMPANY_FOUNDER_TITLE=Assigns a company founder to this company entry. ADMIN_USER_NAME_IS_REQUIRED=Please enter a user name. This must be unique. NO_WEBSITE_URL_ENTERED=No URL entered. ADMIN_LINK_LIST_BRANCH_OFFICES=Branch offices @@ -836,15 +831,14 @@ ADMIN_ASSIGN_BRANCH_OFFICE_USER_OWNER=Assign user to branch office: ADMIN_ASSIGN_BRANCH_OFFICE_CONTACT_EMPLOYEE=Assign contact person to branch office: ADMIN_BRANCH_OFFICE_DATA_LEGEND=Branch office basic data: ADMIN_BRANCH_OFFICE_DATA_LEGEND_TITLE=Enter branch office basic data here. -ADMIN_ASSIGN_BRANCH_OFFICE=Assign branch office to company: +ADMIN_ASSIGN_BASIC_DATA_BRANCH_OFFICE=Assign company to branch office: PAGE_TITLE_ADMIN_LIST_BRANCH_OFFICES=List branch offices CONTENT_TITLE_ADMIN_LIST_BRANCH_OFFICES=List branch offices: ADMIN_EMPTY_LIST_BRANCH_OFFICES=There are no branch offices found in database. Or your search criteria doesn't match anything. ADMIN_ADD_BRANCH_OFFICE_TITLE=Add branch office -#Bitte waehlen Sie mindestens das zugehoerige Unternehmen und das Land aus und geben Sie Strasse, Hausnummer, Postleitzahl und Stadt ein. ADMIN_ADD_BRANCH_OFFICE_MINIMUM_DATA=Please at least choose assigned company, country and enter at least street name, house number, ZIP code and city. ADMIN_ENTER_BRANCH_OFFICE_EMAIL_ADDRESS=Email address of branch office: -ADMIN_ENTER_BRANCH_OFFICE_PHONE_NUMBER=Enter land-line number: +ADMIN_ENTER_BRANCH_OFFICE_LAND_LINE_NUMBER=Enter land-line number: ADMIN_ENTER_BRANCH_OFFICE_FAX_NUMBER=Enter fax number: ADMIN_BRANCH_OFFICE_REQUIRED=Please choose a company that sohuld be assigned with the branch office. ADMIN_BRANCH_OFFICE_STREET_NAME_REQUIRED=Please enter street name of branch office. @@ -897,7 +891,6 @@ ADMIN_EMPTY_LIST_MOBILE_NUMBER=There are no mobile numbers in database. Or your ADMIN_EMPTY_LIST_CONTACT_MOBILE=There are no mobile numbers of contacts in database. Or your search criteria doesn't match anything. ADMIN_MOBILE_PROVIDER_COUNTRY_REQUIRED=Please select a country for mobile provider. LABEL_COUNTRIES=Countries -#Filter list by selecting one or more users. FILTER_BY_MULTIPLE_COUNTRY_TITLE=Filter list by selecting one or more countries. ADMIN_LIST_MOBILE_PROVIDERS_HEADER=List of all mobile providers SELECT_SHOWN_COLUMNS=Shown columns @@ -937,7 +930,7 @@ ADMIN_EMPLOYEE_OTHER_LEGEND=Other data of employee: ADMIN_EMPLOYEE_OTHER_LEGEND_TITLE=Here you can enter additional data for the employee. All fields are optional. ADMIN_ENTER_PHONE_EXTENSION=Enter phone extension: ADMIN_ASSIGN_EMPLOYEE_DEPARTMENT=Assign department to employee: -ADMIN_ASSIGN_EMPLOYEE_HEADQUARTERS=Assign headquarters to employee: +ADMIN_ASSIGN_EMPLOYEE_HEADQUARTER=Assign headquarter to employee: ADMIN_ENTER_EMPLOYEE_MOBILE_NUMBER=Enter business mobile number of employee: ADMIN_EMPLOYEE_GENERAL_LEGEND=General data of employee: ADMIN_EMPLOYEE_GENERAL_LEGEND_TITLE=You can enter here the general data of the employee. @@ -950,10 +943,9 @@ ADMIN_LINK_DELETE_BRANCH_OFFICE_TITLE=Deletes branch office. PAGE_TITLE_ADMIN_LIST_EMPLOYEE=List employees CONTENT_TITLE_ADMIN_LIST_EMPLOYEE=List employees: ADMIN_ADD_EMPLOYEE_TITLE=Add company employee -#Bitte waehlen Sie mindestens das Unternehmen aus und geben SIe mindestens entweder die Mitarbeiternummer ein oder waehlen Sie die persoenlichen Kontaktdaten des Mitarbeiters aus (beides ist auch moeglich). ADMIN_ADD_EMPLOYEE_MINIMUM_DATA=Please choose at least assigned company and enter at least employee number or choose personal data (both is possible, too). BUTTON_ADMIN_ADD_EMPLOYEE=Add employee -ADMIN_LIST_BASIC_COMPANY_DATA_HEADER=List all company basic data +ADMIN_LIST_BASIC_DATA_HEADER=List all company basic data ADMIN_LINK_LIST_DEPARTMENTS=Departments ADMIN_LINK_LIST_DEPARTMENTS_TITLE=Lists departments of companies. ADMIN_LINK_LIST_OPENING_TIMES=Opening times @@ -971,10 +963,9 @@ ADMIN_DEPARTMENT_LEAD_EMPLOYEE=Department leader: ADMIN_ADD_DEPARTMENT_TITLE=Add new department ADMIN_DEPARTMENT_LEGEND=Enter data of department: ADMIN_DEPARTMENT_LEGEND_TITLE=Here you can enter data of the new department. -#Bitte geben Sie mindestens den Namen der Abteilung (z.B. Verkauf) ein und waehlen Sie mindestens das Unternehmen aus. Wenn bekannt, waehlen Sie entweder eine Filiale oder eine Hauptniederlassung aus. -ADMIN_ADD_DEPARTMENT_MINIMUM_DATA=Please enter at least name of department (e.g. Sales) and choose assigned company. If known, choose a branch office or headquarters. +ADMIN_ADD_DEPARTMENT_MINIMUM_DATA=Please enter at least name of department (e.g. Sales) and choose assigned company. If known, choose a branch office or headquarter. ADMIN_ASSIGN_DEPARTMENT_BRANCH_OFFICE=Assign branch office to department: -ADMIN_ASSIGN_DEPARTMENT_HEADQUARTERS=Assign headquarters to department: +ADMIN_ASSIGN_DEPARTMENT_HEADQUARTER=Assign headquarter to department: ADMIN_ASSIGN_DEPARTMENT_COMPANY=Assign company to department: ADMIN_ASSIGN_DEPARTMENT_LEAD_EMPLOYEE=Assign leading employee to department: ADMIN_ASSIGN_DEPARTMENT_USER_OWNER=Assign owning user to department: @@ -999,7 +990,6 @@ ADMIN_END_TIME_REQUIRED=Please enter end time. ADMIN_OPENING_TIME_LEGEND=Data of single opening time: ADMIN_OPENING_TIME_LEGEND_TITLE=Enter data of single opening time. ADMIN_ADD_OPENING_TIME_TITLE=Add new opening time: -#BItte geben Sie zum Hinzufuegen einer Oeffnungszeit alle Angaben an. Diese sollten nicht konfliktieren. ADMIN_ADD_OPENING_TIME_MINIMUM_DATA=To add new opening time, you have to provide all data. They should not conflict. BUTTON_ADMIN_ADD_OPENING_TIME=Add opening time ADMIN_LINK_ASSIGN_DEPARTMENT_BRANCH_OFFICE_TITLE=Assign this department a branch office. @@ -1008,13 +998,50 @@ ADMIN_LINK_ASSIGN_DEPARTMENTS_OWNER_USER_TITLE=Assign this department an owning FIELD_PAYMENT_TYPE_REQUIRED=Please choose a payment method. ADMIN_LIST_USERS_HEADER=List of all users ADMIN_BRANCH_OFFICE_OPENING_TIMES_LEGEND=Opening times of branch office: -TABLE_SUMMARY_ADMIN_LIST_BRANCH_OFFICE_OPENING_TIMES=This table lists opening times of this branch office. +TABLE_SUMMARY_ADMIN_LIST_BRANCH_OFFICE_OPENING_TIMES=This table lists new opening times of this branch office. TABLE_SUMMARY_ADMIN_LIST_BRANCH_OFFICES=This table lists branch offices. -ADMIN_EMPTY_LIST_BRANCH_OFFICE_OPENING_TIMES=There are no opening times of this branch office in database. -ADMIN_LIST_BRANCH_OFFICE_OPENING_TIMES_HEADER=List all opening times of branch office +ADMIN_EMPTY_LIST_BRANCH_OFFICE_OPENING_TIMES=There are no opening times for a new branch office beging setup. +ADMIN_LIST_BRANCH_OFFICE_OPENING_TIMES_HEADER=List opening times of a new branch office ADMIN_ADD_BRANCH_OFFICE_OPENING_TIME_TITLE=Add opening time to branch office BUTTON_ADMIN_ADD_BRANCH_OFFICE_OPENING_TIME=Add opening time to branch office ADMIN_BRANCH_OFFICE_OPENING_TIME_LEGEND=Single opening time of branch office: ADMIN_BRANCH_OFFICE_OPENING_TIME_LEGEND_TITLE=Enter single opening time of branch office. ADMIN_OPENING_TIME_ALREADY_CREATED=The opening time has already been added. ADMIN_NOT_ASSIGNED=Not assigned +ADMIN_BASIC_DATA_COMPANY_NAME=Company's name: +ADMIN_LINK_SHOW_HEADQUARTER_TITLE=Shows details of a headquarter. +ADMIN_LINK_EDIT_HEADQUARTER_TITLE=Edit of a headquarter. +ADMIN_LINK_DELETE_HEADQUARTER_TITLE=Deletes a headquarter. +PAGE_TITLE_ADMIN_LIST_HEADQUARTER=List headquarters +CONTENT_TITLE_ADMIN_LIST_HEADQUARTER=List headquarters: +TABLE_SUMMARY_ADMIN_LIST_HEADQUARTER=This table lists all headquarter. +ADMIN_EMPTY_LIST_HEADQUARTER=There are no headquarter in database. Or your search criteria doesn't match anything. +ADMIN_LIST_HEADQUARTER_HEADER=List all headquarter +ADMIN_LINK_SHOW_HEADQUARTER_OWNER_USER_TITLE=Show the profile of the headquarter entry owning user. +ADMIN_ADD_HEADQUARTER_TITLE=Add headquarter +ADMIN_LINK_LIST_HEADQUARTER=Headquarter +ADMIN_LINK_LIST_HEADQUARTER_TITLE=Lists all headquarter. +ADMIN_ADD_HEADQUARTER_MINIMUM_DATA=Please at least choose country and enter at least street name, house number, ZIP code and city. +ADMIN_HEADQUARTER_LEGEND=Headquarter data: +#@TODO Please fix German umlauts! +ADMIN_ASSIGN_HEADQUARTER_CONTACT_EMPLOYEE=Assign employee as contact person for headquarter: +ADMIN_ASSIGN_HEADQUARTER_USER_OWNER=Assign owning user to headquarter: +ADMIN_ENTER_HEADQUARTER_EMAIL_ADDRESS=Enter headquarter' email address: +ADMIN_ENTER_HEADQUARTER_LAND_LINE_NUMBER=Enter land-line number of headquarter: +ADMIN_ENTER_HEADQUARTER_FAX_NUMBER=Enter fax number of headquarter +ADMIN_HEADQUARTER_ADDRESS_LEGEND=Address of headquarter: +ADMIN_HEADQUARTER_STREET_NAME_REQUIRED=Please enter street name for headquarter. +ADMIN_HEADQUARTER_HOUSE_NUMBER_REQUIRED=Please enter house number for headquarter. +ADMIN_HEADQUARTER_ZIP_CODE_REQUIRED=Please enter ZIP code for headquarter. +ADMIN_HEADQUARTER_CITY_REQUIRED=Please enter city for headquarter. +ADMIN_BRANCH_OFFICE_COUNTRY_REQUIRED=Please choose a country for branch office. +ADMIN_HEADQUARTER_COUNTRY_REQUIRED=Please choose a country for headquarter. +BUTTON_ADMIN_ADD_HEADQUARTER=Add headquarter +ADMIN_HEADQUARTER_OPENING_TIMES_LEGEND=Opening times of headquarter: +TABLE_SUMMARY_ADMIN_LIST_HEADQUARTER_OPENING_TIMES=This table lists new opening times for headquarter. +ADMIN_EMPTY_LIST_HEADQUARTER_OPENING_TIMES=There are no opening times for a new headquarter beging setup. +ADMIN_LIST_HEADQUARTER_OPENING_TIMES_HEADER=List opening times of a new headquarter +ADMIN_ADD_HEADQUARTER_OPENING_TIME_TITLE=Add opening time to headquarter +BUTTON_ADMIN_ADD_HEADQUARTER_OPENING_TIME=Add opening time to headquarter +ADMIN_LINK_ASSIGN_EMPLOYEE_BRANCH_OFFICE_TITLE=Assign a branch office to this employee. +ADMIN_LINK_ASSIGN_EMPLOYEES_OWNER_USER_TITLE=Assign an owning user to this employee. diff --git a/web/WEB-INF/faces-config.xml b/web/WEB-INF/faces-config.xml index 25ccb302..116ae73b 100644 --- a/web/WEB-INF/faces-config.xml +++ b/web/WEB-INF/faces-config.xml @@ -109,8 +109,12 @@ /admin/contact/admin_contact_export.xhtml - admin_list_basic_company_data - /admin/basic_company_data/admin_basic_company_data_list.xhtml + admin_list_headquarter + /admin/headquarter/admin_headquarter_list.xhtml + + + admin_list_basic_data + /admin/basic_data/admin_basic_data_list.xhtml admin_list_branch_office @@ -731,38 +735,69 @@ - /admin/basic_company_data/admin_basic_company_data_list.xhtml + /admin/basic_data/admin_basic_data_list.xhtml admin_show_basic_data - /admin/basic_company_data/admin_basic_company_data_show.xhtml + /admin/basic_data/admin_basic_data_show.xhtml admin_edit_basic_data - /admin/basic_company_data/admin_basic_company_data_edit.xhtml + /admin/basic_data/admin_basic_data_edit.xhtml admin_delete_basic_data - /admin/basic_company_data/admin_basic_company_data_delete.xhtml + /admin/basic_data/admin_basic_data_delete.xhtml + + + admin_assign_basic_data_contact + /admin/basic_data/admin_basic_data_assign_contact.xhtml + + + admin_assign_basic_data_founder + /admin/basic_data/admin_basic_data_assign_founder.xhtml + + + admin_assign_basic_data_owner + /admin/basic_data/admin_basic_data_assign_owner.xhtml + + + admin_show_employee + /admin/company_employee/admin_company_employee_show.xhtml + + + admin_assign_basic_data_employee + /admin/basic_data/admin_basic_data_assign_employee.xhtml + + + + /admin/headquarter/admin_headquarter_list.xhtml + + admin_show_headquarter + /admin/headquarter/admin_headquarter_show.xhtml - admin_assign_basic_company_data_contact - /admin/basic_company_data/admin_basic_company_data_assign_contact.xhtml + admin_edit_headquarter + /admin/headquarter/admin_headquarter_edit.xhtml - admin_assign_basic_company_data_founder - /admin/basic_company_data/admin_basic_company_data_assign_founder.xhtml + admin_delete_headquarter + /admin/headquarter/admin_headquarter_delete.xhtml + + + admin_show_user + /admin/user/admin_user_show.xhtml - admin_assign_basic_company_data_owner - /admin/basic_company_data/admin_basic_company_data_assign_owner.xhtml + admin_assign_headquarter_owner + /admin/headquarter/admin_headquarter_assign_owner.xhtml admin_show_employee /admin/company_employee/admin_company_employee_show.xhtml - admin_assign_basic_company_data_employee - /admin/basic_company_data/admin_basic_company_data_assign_employee.xhtml + admin_assign_headquarter_employee + /admin/headquarter/admin_headquarter_assign_employee.xhtml @@ -789,7 +824,7 @@ admin_show_basic_data - /admin/basic_company_data/admin_basic_company_data_show.xhtml + /admin/basic_data/admin_basic_data_show.xhtml admin_show_employee @@ -849,6 +884,14 @@ admin_delete_employee /admin/employee/admin_employee_delete.xhtml + + admin_show_branch_office + /admin/branch_office/admin_branch_office_show.xhtml + + + admin_assign_employee_owner + /admin/employee/admin_assign_employee_user.xhtml + /admin/opening_time/admin_opening_time_list.xhtml diff --git a/web/WEB-INF/links.jsf.taglib.xml b/web/WEB-INF/links.jsf.taglib.xml index 06af9787..0598de75 100644 --- a/web/WEB-INF/links.jsf.taglib.xml +++ b/web/WEB-INF/links.jsf.taglib.xml @@ -149,7 +149,7 @@ along with this program. If not, see . outputBasicDataAdminMiniLinks - This tag renders administrative "mini-links" for given basicData instance. + This tag renders administrative "mini-links" for given basic data instance. resources/tags/admin/links/mini/basic_data/admin_basic_data_links.tpl basicData @@ -170,6 +170,29 @@ along with this program. If not, see . java.lang.Boolean + + outputHeadquarterAdminMiniLinks + This tag renders administrative "mini-links" for given headquarter instance. + resources/tags/admin/links/mini/headquarter/admin_headquarter_links.tpl + + headquarter + The headquarter instance that provides the data for this tag. + true + org.mxchange.jcontactsbusiness.model.headquarter.HeadquarterData + + + renderShowLink + Whether to render (default: true) "show headquarter" link. + false + java.langBoolean + + + rendered + Whether this tag is being rendered by JSF engine (default: true). + false + java.lang.Boolean + + outputBranchOfficeAdminMiniLinks This tag renders administrative "mini-links" for given branchOffice instance. 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 dda35498..d973950c 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,20 +10,20 @@